Esempio n. 1
0
 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);
 }
Esempio n. 2
0
        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();
        }
Esempio n. 3
0
 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);
         }
     }
 }
Esempio n. 4
0
 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);
     }
 }