protected override void Initialize() { // Set default settings IsMouseVisible = true; Content.RootDirectory = "Content"; Window.Title = "Pixel Defense Force"; // Perhaps retrieve/create a settings file here? _graphics.PreferMultiSampling = false; _graphics.PreferredBackBufferWidth = 1280; _graphics.PreferredBackBufferHeight = 720; _graphics.ApplyChanges(); // Create the camera _camera = new Camera { Resolution = new Point(_graphics.PreferredBackBufferWidth, _graphics.PreferredBackBufferHeight), Position = new Vector2(0, 0), Zoom = 2, TileSize = new Point(32, 32) }; // Generate a test map for now _tileMap = new TileMap {Tiles = new Tile[16][]}; for (var x = 0; x < _tileMap.Tiles.Length; x++) _tileMap.Tiles[x] = new Tile[16]; base.Initialize(); }
public void Draw(SpriteBatch spriteBatch, Camera camera, TileMap tileMap) { for (var x = 0; x < tileMap.Tiles.Length; x++) { for (var y = 0; y < tileMap.Tiles[x].Length; y++) { var tile = tileMap.Tiles[x][y]; spriteBatch.Draw( tileMap.Tileset, camera.ToAbsolute(new Vector2(x, y)), new Rectangle( 32, 0, //tile.TileType.TextureLocation.X, tile.TileType.TextureLocation.Y, 32, 32), Color.White, 0f, Vector2.Zero, camera.Zoom, SpriteEffects.None, 0f); } } }