Пример #1
0
 /*
  * public void DrawImage(Image2D image, double x, double y, double scale)
  * {
  *      Draw(
  *              image.Texture,
  *              new Rectangle(
  *                      _translation[_translationIndex] + (int)x,
  *                      _translation[_translationIndex + 1] + (int)y,
  *                      (int)(image.Width * scale), (int)(image.Height * scale)),
  *              new Rectangle(image.SubX, image.SubY, image.Width, image.Height),
  *              Color.White
  *      );
  * }
  */
 public void DrawImage(AmImage2D image, double x, double y, double scaleX, double scaleY)
 {
     Draw(
         image.Texture,
         new Rectangle(
             (int)_translation[_translationIndex] + (int)x,
             (int)_translation[_translationIndex + 1] + (int)y,
             (int)(image.Width * scaleX), (int)(image.Height * scaleY)),
         new Rectangle(image.SubX, image.SubY, image.Width, image.Height),
         Color.White
         );
 }
Пример #2
0
        public void DrawImage(AmImage2D image, double x, double y, double rotation)
        {
            /*
             * (Texture2D texture,
             * Rectangle destinationRectangle,
             * Rectangle? sourceRectangle,
             * Color color,
             * float rotation,
             * Vector2 origin,
             * SpriteEffects effects,
             * float layerDepth)
             */
            /*
             * Draw(
             *      image.Texture,
             *      new Rectangle(
             *              (int)_translation[_translationIndex] + (int)x,
             *              (int)_translation[_translationIndex + 1] + (int)y,
             *              image.Width, image.Height),
             *      new Rectangle(image.SubX, image.SubY, image.Width, image.Height),
             *      Color.White,
             *      rotation,
             *      Vector2.Zero,
             *      SpriteEffects.None,
             *      0.0f
             * );*/
            /*
             * Texture2D texture,
             * Vector2 position,
             * Rectangle? sourceRectangle,
             * Color color,
             * float rotation,
             * Vector2 origin,
             * float scale,
             * SpriteEffects effects,
             * float layerDepth);
             */
            var position = new Vector2((int)_translation[_translationIndex] + (int)x,
                                       (int)_translation[_translationIndex] + (int)y);
            var origin = new Vector2(image.Width / 2, image.Height / 2);

            Draw(image.Texture,
                 position,
                 new Rectangle(image.SubX, image.SubY, image.Width, image.Height),
                 Color.White,
                 (float)(rotation * AmMath.Deg2Rad),
                 origin,
                 1.0f,
                 SpriteEffects.None,
                 0.0f
                 );
            //this.Draw();
        }
Пример #3
0
        public void Draw(GameTime gameTime, AmSpriteBatch graphics, int x = 0, int y = 0)
        {
            for (int i = 0; i < Tiles.Length; ++i)
            {
                int gx = i % tilemap.GridWidth;
                int gy = i / tilemap.GridWidth;
                int rx = gx * tilemap.TileWidth + x;
                int ry = gy * tilemap.TileHeight + y;

                int tileData    = Tiles[gx, gy];
                int tilesheetId = (tileData >> 24) & 0xFF;
                int tileId      = tileData & 0xFFFFFF;

                if (tilesheetId == 127)
                {
                    continue;
                }

                AmImage2D curTile = tilemap.tilesheets[tilesheetId].GetImage(tileId);

                graphics.DrawImage(curTile, rx, ry);
            }
        }