Time for action – creating the TileMap class
Add a new class called "TileMap" to the Robot Rampage project.
Add the following
using
directives to the top of the class file:using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics;
Modify the declaration of the TileMap class to make it a static class:
static class TileMap
Add declarations to the TileMap class:
#region Declarations public const int TileWidth = 32; public const int TileHeight = 32; public const int MapWidth = 50; public const int MapHeight = 50; public const int FloorTileStart = 0; public const int FloorTileEnd = 3; public const int WallTileStart = 4; public const int WallTileEnd = 7; static private Texture2D texture; static private List<Rectangle> tiles = new List<Rectangle>(); static private int[,] mapSquares = new int[MapWidth, MapHeight]; static private Random rand = new Random(); #endregion
Add the
Initialize()
method to the TileMap class:#region Initialization static public void Initialize(Texture2D...