コード例 #1
0
ファイル: Game.cs プロジェクト: Azathotep/LiteEngineSamples
        protected override void DrawFrame(GameTime gameTime, XnaRenderer renderer)
        {
            Vector2 mp = base.GetMousePosition();

            mp = _camera.ViewToWorld(mp);


            renderer.BeginDraw(_camera);
            foreach (Polygon p in _polygons)
            {
                p.Draw(renderer);
            }

            renderer.DrawPoint(mp, _cursorSize, Color.Lerp(Color.Green, Color.Cyan, (_cursorSize - 2) / 2), 1f);

            if (_stage == 0)
            {
                renderer.DrawArrow(_forceStart, _forceEnd, 0.2f, Color.Green);
            }

            foreach (Arrow arrow in ArrowCollection.Arrows.Values)
            {
                renderer.DrawArrow(arrow.Start, arrow.End, 0.1f, arrow.Color);
            }

            renderer.DrawPoint(Vector2.Zero, 0.2f, Color.Red, 0.5f);

            renderer.EndDraw();
        }
コード例 #2
0
        public void Draw(XnaRenderer renderer)
        {
            renderer.DrawDepth = 1f;
            Color tileColor = Color.White;

            if (IsWall)
            {
                tileColor = Color.SlateGray;
                if (_strength == 1)
                {
                    tileColor = Color.LightBlue;
                }
                if (_strength == 2)
                {
                    tileColor = Color.DarkBlue;
                }
            }
            renderer.DrawFilledRectangle(new RectangleF(-0.45f, -0.45f, 0.9f, 0.9f), tileColor);
            renderer.DrawDepth = 0.8f;
            if (ContainsFood)
            {
                renderer.DrawPoint(new Vector2(0, 0), 1f, Color.Green, 1f);
            }

            if (IsEmpty && Anim > 0)
            {
                float width = (float)Anim / 50 * 0.45f;
                renderer.DrawFilledRectangle(new RectangleF(-width, -width, width * 2, width * 2), Color.Gray);
                Anim--;
            }
        }
コード例 #3
0
 internal void Draw(XnaRenderer renderer)
 {
     renderer.DrawPoint(_position, 10f, _color * 0.1f, 0f);
     renderer.DrawPoint(_position, 4f, _color * 0.2f, 0f);
     renderer.DrawPoint(_position, 2f, _color * 0.5f, 0f);
     renderer.DrawPoint(_position, 1f, Color.White, 1);
 }
コード例 #4
0
ファイル: Game.cs プロジェクト: Azathotep/LiteEngineSamples
 void DrawNonRectangular(XnaRenderer renderer, Vector2 position, Vector2 origin)
 {
     renderer.DrawOffset = position;
     renderer.DrawDepth  = 0.7f;
     renderer.DrawSprite(new LiteEngine.Textures.Texture("solid"), new Corners(new Vector2(0, 0), new Vector2(15, 0), new Vector2(2.5f, 10), new Vector2(12.5f, 10)), _angle, origin, Color.Red);
     renderer.DrawDepth = 0.5f;
     renderer.DrawSprite(new LiteEngine.Textures.Texture("zombie"), new Corners(new Vector2(0, 0), new Vector2(15, 0), new Vector2(2.5f, 10), new Vector2(12.5f, 10)), _angle, origin, Color.Red);
 }
コード例 #5
0
 public void Draw(XnaRenderer renderer)
 {
     GridHelper.Foreach(_grid, (x, y) =>
     {
         renderer.Transformation = Matrix.CreateTranslation(x + 0.5f, y + 0.5f, 0);
         _grid[x, y].Draw(renderer);
     });
 }
コード例 #6
0
ファイル: Game.cs プロジェクト: Azathotep/LiteEngineSamples
 protected override void DrawFrame(GameTime gameTime, XnaRenderer renderer)
 {
     renderer.BeginDraw(_camera);
     foreach (FireFly fly in _fireFlies)
     {
         fly.Draw(renderer);
     }
     renderer.EndDraw();
 }
コード例 #7
0
        protected override void DrawFrame(GameTime gameTime, XnaRenderer renderer)
        {
            renderer.BeginDraw(_camera);
            renderer.DrawPoint(new Vector2(100, 100) + Util.AngleToVector(_angle) * 20f, 5f, Color.Green, 1f);
            //_camera.Zoom = 0.5f;

            //renderer.DrawString("This is some text", new Vector2(0, 0), Color.Red);

            renderer.EndDraw();
        }
コード例 #8
0
ファイル: Game.cs プロジェクト: Azathotep/LiteEngineSamples
        protected override void Initialize(XnaRenderer renderer)
        {
            _camera = new Camera2D(new Vector2(0, 0), new Vector2(80, 60));
            renderer.SetResolution(1200, 900, false);
            Polygon polygon = new Polygon(new Vector2[] { new Vector2(-4, 3), new Vector2(4, 3), new Vector2(0, -3) });

            _polygons.Add(polygon);
            polygon.Position = new Vector2(4f, 3f);
            polygon.Angle    = 0.1f;
            polygon          = new Polygon(new Vector2[] { new Vector2(-8, 3), new Vector2(8, 3), new Vector2(0, 0) });
            polygon.Position = new Vector2(7, 7);
            _polygons.Add(polygon);
        }
コード例 #9
0
        protected override void Initialize(XnaRenderer renderer)
        {
            _camera = new Camera2D(new Vector2(100, 100), new Vector2(50, 80));
            //renderer.SetScreenSize(1024, 796, false);
            renderer.SetResolution(600, 480, false);
            _textBox           = new TextBox();
            _textBox.Position  = new Vector2(50, 50);
            _textBox.TextScale = 10f;
            _textBox.Text      = "This is some text for the textbox";
            _textBox.TextColor = Color.White;

            _textBox.BorderWidth = 2f;
            UserInterface.AddChild(_textBox);
        }
コード例 #10
0
        protected override void DrawFrame(GameTime gameTime, XnaRenderer renderer)
        {
            renderer.Clear(Color.White);
            Vector2 start = new Vector2(0, 0);
            Vector2 end   = start + Util.AngleToVector(_angle) * _lineLength;

            renderer.BeginDraw(_camera);

            renderer.DrawPoint(start, 3f, Color.Green, 1f);
            renderer.DrawPoint(end, 3f, Color.Red, 1f);
            renderer.DrawArrow(start, end, 0.5f, Color.Black, 1f);

            renderer.EndDraw();
        }
コード例 #11
0
ファイル: Game.cs プロジェクト: Azathotep/LiteEngineSamples
        protected override void DrawFrame(GameTime gameTime, XnaRenderer renderer)
        {
            //Texture2D texture = renderer.ContentManager.Load<Texture2D>("solid");

            //Effect effect = renderer.ContentManager.Load<Effect>("basicshader.mgfxo");
            //effect.Parameters["xWorld"].SetValue(_camera.World);
            //effect.Parameters["xProjection"].SetValue(_camera.Projection);
            //effect.Parameters["xView"].SetValue(_camera.View);
            //effect.Parameters["TextureSampler"].SetValue(texture);
            //effect.Techniques["Basic"].Passes[0].Apply();

            //renderer.GraphicsDevice.DrawUserIndexedPrimitives(PrimitiveType.TriangleList, _vertexData, 0, 4, _indexData, 0, 2, VertexPositionColorTexture.VertexDeclaration);

            renderer.BeginDraw(_camera);
            LiteEngine.Textures.Texture solidTexture = new LiteEngine.Textures.Texture("solid");

            renderer.DrawDepth = 0.9f;
            DrawTiles(renderer);


            renderer.DrawDepth = 0.7f;
            //this sprite will rotate around it's top corner (20,20)
            renderer.DrawSprite(solidTexture, new RectangleF(20, 20, 20, 2f), Color.Red, _angle);

            //this sprite will rotate around it's center placed at (30,30)
            renderer.DrawSprite(solidTexture, new Vector2(30, 30), new Vector2(20, 2), _angle);

            //this sprite will rotate around it's center placed at (70,20)
            renderer.DrawSprite(solidTexture, new RectangleF(70, 20, 20, 2f), renderer.DrawDepth, _angle, new Vector2(0.5f, 0.5f), Color.Red);

            renderer.DrawPoint(new Vector2(0, 0), 1f, Color.White, 1f);

            renderer.DrawSprite(_stickmanAnimation.CurrentTexture, new RectangleF(10, 60, 30, 30));
            _stickmanAnimation.Advance(gameTime.ElapsedGameTime.Milliseconds);
            //renderer.DrawSprite(new LiteEngine.Textures.Texture("point"), new RectangleF(2, 0, 1, 1), 0.5f, _angle, new Vector2(0.5f,0.5f), Color.Blue);

            //renderer.DrawSprite(new LiteEngine.Textures.Texture("point", new RectangleI(0, 0, 32, 32)), new RectangleF(2, 0, 1, 1), 0.5f, _angle, new Vector2(0.5f, 0.5f), Color.Blue);

            //draw non-rectangular sprite centered and rotating around (50,50)
            DrawNonRectangular(renderer, new Vector2(50, 50), new Vector2(0.5f, 0.5f));

            //draw non-rectangular sprite rotating around its bottom right corner at (70,70)
            DrawNonRectangular(renderer, new Vector2(70, 70), new Vector2(1f, 1f));

            //draw a non rectangular texture
            _angle += 0.01f;
            renderer.EndDraw();
        }
コード例 #12
0
ファイル: Game.cs プロジェクト: Azathotep/LiteEngineSamples
 void DrawTiles(XnaRenderer renderer)
 {
     LiteEngine.Textures.Texture solidTexture = new LiteEngine.Textures.Texture("solid");
     for (int y = 0; y < 10; y++)
     {
         for (int x = 0; x < 10; x++)
         {
             Color color = Color.BlanchedAlmond;
             if ((x + y) % 2 == 0)
             {
                 color = Color.PaleTurquoise;
             }
             renderer.DrawSprite(solidTexture, new RectangleF(x * 10f, y * 10f, 10f, 10f), color);
         }
     }
 }
コード例 #13
0
ファイル: Game.cs プロジェクト: Azathotep/LiteEngineSamples
        protected override void DrawFrame(GameTime gameTime, XnaRenderer renderer)
        {
            renderer.BeginDraw(_camera);

            renderer.DrawDepth = 0.9f;
            _world.Draw(renderer);
            renderer.DrawDepth      = 0.5f;
            renderer.Transformation = Matrix.Identity;
            _snake.Draw(renderer);


            renderer.EndDraw();


            //renderer.BeginDraw(_screenCamera);
            //renderer.DrawString("5", new Vector2(0, 0), Color.Black, 10);
            //renderer.EndDraw();
        }
コード例 #14
0
ファイル: Game.cs プロジェクト: Azathotep/LiteEngineSamples
 protected override void Initialize(XnaRenderer renderer)
 {
     renderer.SetResolution(1024, 768, false);
     TextureBook.AddSpriteSheet(@"textures\snake");
     _world = new TileGrid(20, 20);
     _world.GetRandomEmptyTile().ContainsFood = true;
     _camera = new Camera2D(new Vector2(_world.Size.Width / 2, _world.Size.Height / 2), new Vector2(_world.Size.Width, _world.Size.Height));
     _snake  = new Snake(this, _world);
     _snake.Place(_world.GetTile(10, 10));
     _txtBox           = new TextBox();
     _txtBox.Text      = "5";
     _txtBox.TextScale = 5;
     _txtBox.AutoSize  = true;
     _txtBox.TextColor = Color.Black;
     _txtBox.Position  = new Vector2(0, 0);
     UserInterface.SetResolution(600, 480);
     this.UserInterface.AddChild(_txtBox);
 }
コード例 #15
0
ファイル: Game.cs プロジェクト: Azathotep/LiteEngineSamples
        public void Draw(XnaRenderer renderer)
        {
            //renderer.DrawPoint(ToWorld(_centerOfMass), 1f, Color.Red, 1f);
            renderer.Transformation = Matrix.CreateTranslation(-_centerOfMass.X, -_centerOfMass.Y, 0) * Matrix.CreateRotationZ(Angle) * Matrix.CreateTranslation(_centerOfMass.X, _centerOfMass.Y, 0) * Matrix.CreateTranslation(Position.X, Position.Y, 0);
            renderer.DrawPoint(_centerOfMass, 1f, Color.Red, 1f);

            for (int i = 0; i < _points.Length; i++)
            {
                renderer.DrawPoint(_points[i], 1f, Color.White, 1f);

                //draw edge
                Vector2 start = _points[i];
                Vector2 end   = _points[(i + 1) % _points.Length];
                renderer.DrawLine(start, end, 0.1f, Color.White, 1f);
                //renderer.DrawArrow((start + end) * 0.5f, (start + end) * 0.5f + _normals[i] * 1f, 0.1f, Color.DarkGray, 0.6f);
            }

            renderer.Transformation = Matrix.Identity;
            renderer.DrawArrow(CenterOfMass, CenterOfMass + Velocity * 50f, 0.2f, Color.Blue);
        }
コード例 #16
0
ファイル: Game.cs プロジェクト: Azathotep/LiteEngineSamples
        protected override void Initialize(XnaRenderer renderer)
        {
            _camera = new Camera2D(new Vector2(50, 50), new Vector2(100, 100));
            renderer.SetResolution(800, 600, false);


            _vertexData[0].Position          = new Vector3(0, 0, 0);
            _vertexData[0].TextureCoordinate = new Vector2(0, 0);
            _vertexData[0].Color             = Color.White;

            _vertexData[1].Position          = new Vector3(1, 0, 0);
            _vertexData[1].TextureCoordinate = new Vector2(1, 0);
            _vertexData[1].Color             = Color.White;

            _vertexData[2].Position          = new Vector3(0, 1, 0);
            _vertexData[2].TextureCoordinate = new Vector2(0, 1);
            _vertexData[2].Color             = Color.White;

            _vertexData[3].Position          = new Vector3(1, 1, 0);
            _vertexData[3].TextureCoordinate = new Vector2(1, 1);
            _vertexData[3].Color             = Color.White;

            _indexData[0] = 0;
            _indexData[1] = 1;
            _indexData[2] = 2;
            _indexData[3] = 2;
            _indexData[4] = 1;
            _indexData[5] = 3;

            TextureBook.AddSpriteSheet(@"Textures\spritesheet1");
            _stickmanAnimation.AddFrame(TextureBook.GetTexture(@"Textures\spritesheet1.man2"), 1000);
            _stickmanAnimation.AddFrame(TextureBook.GetTexture(@"Textures\spritesheet1.man1"), 500);
            _stickmanAnimation.AddFrame(TextureBook.GetTexture(@"Textures\spritesheet1.man3"), 500);
            _stickmanAnimation.AddFrame(TextureBook.GetTexture(@"Textures\spritesheet1.man4"), 500);
            _stickmanAnimation.AddFrame(TextureBook.GetTexture(@"Textures\spritesheet1.man5"), 500);
            _stickmanAnimation.Loop = true;
        }
コード例 #17
0
ファイル: Snake.cs プロジェクト: Azathotep/LiteEngineSamples
 public void Draw(XnaRenderer renderer)
 {
     Tile[] parts = _body.ToArray();
     for (int i = 0; i < parts.Length; i++)
     {
         Texture texture;
         float   angle = 0;
         Tile    part  = parts[i];
         if (i == parts.Length - 1)
         {
             texture = _headAnimation.CurrentTexture;
             angle   = Compass.GetAngle(MoveDirection);
         }
         else if (i == 0)
         {
             texture = _tailTexture;
             CardinalDirection directionOfLast = Compass.GetDirection(parts[i + 1].Position - parts[i].Position);
             angle = Compass.GetAngle(directionOfLast);
         }
         else
         {
             CardinalDirection directionOfNext = Compass.GetDirection(parts[i - 1].Position - parts[i].Position);
             CardinalDirection directionOfLast = Compass.GetDirection(parts[i + 1].Position - parts[i].Position);
             if (Compass.GetOppositeDirection(directionOfLast) == directionOfNext)
             {
                 texture = _bodyNsTexture;
                 if (directionOfNext == CardinalDirection.East || directionOfNext == CardinalDirection.West)
                 {
                     angle = MathHelper.PiOver2;
                 }
             }
             else
             {
                 texture = _bodyNeTexture;
                 if (directionOfLast == CardinalDirection.North && directionOfNext == CardinalDirection.West)
                 {
                     angle = MathHelper.PiOver2 * 3;
                 }
                 if (directionOfLast == CardinalDirection.East && directionOfNext == CardinalDirection.South)
                 {
                     angle = MathHelper.PiOver2;
                 }
                 if (directionOfLast == CardinalDirection.South && directionOfNext == CardinalDirection.East)
                 {
                     angle = MathHelper.PiOver2;
                 }
                 if (directionOfLast == CardinalDirection.South && directionOfNext == CardinalDirection.West)
                 {
                     angle = MathHelper.Pi;
                 }
                 if (directionOfLast == CardinalDirection.West && directionOfNext == CardinalDirection.South)
                 {
                     angle = MathHelper.Pi;
                 }
                 if (directionOfLast == CardinalDirection.West && directionOfNext == CardinalDirection.North)
                 {
                     angle = MathHelper.PiOver2 * 3;
                 }
             }
         }
         renderer.DrawSprite(texture, new Vector2(part.Position.X + 0.5f, part.Position.Y + 0.5f), new Vector2(1f, 1f), angle, Color.Green, 1f);
     }
 }
コード例 #18
0
        protected override void Initialize(XnaRenderer renderer)
        {
            renderer.SetResolution(800, 600, false);
            UserInterface.SetResolution(800, 600);

            UserInterface.ShowMouseCursor = true;
            _textBox                 = new TextBox();
            _textBox.Text            = "This textbox is docked in the center of the screen";
            _textBox.AutoSize        = true;
            _textBox.BackgroundColor = Color.Azure;
            _textBox.BorderWidth     = 2;
            _textBox.Dock            = DockPosition.Center;
            UserInterface.AddChild(_textBox);

            TextBox topText = CreateTextBox();

            topText.Text     = "This textbox is docked at the top of the screen";
            topText.Dock     = DockPosition.Top;
            topText.AutoSize = true;
            UserInterface.AddChild(topText);

            TextBox rightText = CreateTextBox();

            rightText.Text = "This textbox is docked at the right of the screen";
            rightText.Dock = DockPosition.Right;
            rightText.Size = new SizeF(100, 0);
            UserInterface.AddChild(rightText);

            TextBox leftText = CreateTextBox();

            leftText.Text = "This textbox is docked at the left of the screen";
            leftText.Dock = DockPosition.Left;
            leftText.Size = new SizeF(100, 0);
            UserInterface.AddChild(leftText);

            TextBox bottomText = CreateTextBox();

            bottomText.Text     = "This textbox is docked at the bottom of the screen";
            bottomText.Dock     = DockPosition.Bottom;
            bottomText.AutoSize = true;
            UserInterface.AddChild(bottomText);

            TextBox topLeft = CreateTextBox();

            topLeft.Text = "This textbox is docked at the top left of the screen";
            topLeft.Size = new SizeF(150, 0);
            topLeft.Dock = DockPosition.TopLeft;
            UserInterface.AddChild(topLeft);

            TextBox topRight = CreateTextBox();

            topRight.Text = "This textbox is docked at the top right of the screen";
            topRight.Size = new SizeF(150, 0);
            topRight.Dock = DockPosition.TopRight;
            UserInterface.AddChild(topRight);

            TextBox bottomRight = CreateTextBox();

            bottomRight.Text = "This textbox is docked at the bottom right of the screen";
            bottomRight.Size = new SizeF(150, 0);
            bottomRight.Dock = DockPosition.BottomRight;
            UserInterface.AddChild(bottomRight);

            TextBox bottomLeft = CreateTextBox();

            bottomLeft.Text = "This textbox is docked at the bottom left of the screen";
            bottomLeft.Size = new SizeF(150, 0);
            bottomLeft.Dock = DockPosition.BottomLeft;
            UserInterface.AddChild(bottomLeft);

            Button button = new Button();

            button.Bounds  = new RectangleF(200, 150, 150, 100);
            button.OnClick = () =>
            {
                UserInterface.ShowDialog(new SimpleDialog());

                topText.Text += "!";
            };
            button.Text = "This is a button";
            UserInterface.AddChild(button);

            //ImageControl image = new ImageControl(new Texture("point"));
            //image.Size = new SizeF(300, 300);
            //image.Dock = DockPosition.Center;
            //image.BackgroundColor = Color.PaleGreen;
            //image.BorderWidth = 3f;
            //UserInterface.AddChild(image);
        }
コード例 #19
0
 protected override void DrawFrame(GameTime gameTime, XnaRenderer renderer)
 {
     renderer.Clear(Color.White);
 }
コード例 #20
0
 protected override void Initialize(XnaRenderer renderer)
 {
     _camera = new Camera2D(new Vector2(0, 0), new Vector2(80, 60));
     renderer.SetResolution(800, 600, false);
 }
コード例 #21
0
ファイル: Game.cs プロジェクト: Azathotep/LiteEngineSamples
 protected override void Initialize(XnaRenderer renderer)
 {
     _camera = new Camera2D(new Vector2(0, 0), new Vector2(50, 50));
     renderer.SetResolution(1024, 768, false);
 }