// Simply create a sand sprite...a bit hacky. there's probably a better way public Level() { const int SandTilePos = 15; int spriteSheetY = (SandTilePos / SpriteSheetTileWidth) * TileHeight + (SandTilePos / SpriteSheetTileWidth); int spriteSheetX = (SandTilePos % SpriteSheetTileWidth) * TileWidth + (SandTilePos % SpriteSheetTileWidth); SandSprite = new StaticSprite(GameTextures.TileMap, new System.Drawing.Rectangle(spriteSheetX, spriteSheetY, TileWidth, TileHeight)); GrassSprite = new StaticSprite(GameTextures.SquirrelMap, new Rectangle(350, 109, 55, 55)); }
// // Hmmm...I don't like how these are taking a BitmapSprite // I think i will have to try and abstract the BitmapSprite // up to a Sprite // public abstract void TileSprite(BitmapSprite sprite);
public abstract void RenderSprite(BitmapSprite sprite);
public override void RenderSprite(BitmapSprite sprite) { if (sprite.RotateFlipType == RotateFlipType.RotateNoneFlipNone) { graphics.DrawImage( sprite.MasterImage, sprite.GameRectangle, sprite.Crop, GraphicsUnit.Pixel); } else { Bitmap tempImage = new Bitmap(sprite.Crop.Width, sprite.Crop.Height); Graphics tempGraphics = Graphics.FromImage(tempImage); tempGraphics.DrawImage(sprite.MasterImage, new Rectangle(0, 0, tempImage.Width, tempImage.Height), sprite.Crop, GraphicsUnit.Pixel); tempImage.RotateFlip(sprite.RotateFlipType); graphics.DrawImage(tempImage, sprite.GameRectangle); tempGraphics.Dispose(); } }
public override void TileSprite(BitmapSprite sprite) { Bitmap temp = new Bitmap(sprite.Crop.Width, sprite.Crop.Height); Graphics g = Graphics.FromImage(temp); g.DrawImage( sprite.MasterImage, new Rectangle(0, 0, temp.Width, temp.Height), sprite.Crop, GraphicsUnit.Pixel); TextureBrush tileBrush = new TextureBrush(temp, System.Drawing.Drawing2D.WrapMode.Tile); graphics.FillRectangle(tileBrush, form.ClientRectangle); }