Time for action – creating the TileMap module
Add a new module called
TileMap
to the Robot Rampage project.Add declarations to the
TileMap
module:#Region "Declarations" Public Const TileWidth As Integer = 32 Public Const TileHeight As Integer = 32 Public Const MapWidth As Integer = 50 Public Const MapHeight As Integer = 50 Public Const FloorTileStart As Integer = 0 Public Const FloorTileEnd As Integer = 3 Public Const WallTileStart As Integer = 4 Public Const WallTileEnd As Integer = 7 Private _texture As Texture2D Private _tiles As List(Of Rectangle) = new List(Of Rectangle)() Private _mapSquares(MapWidth, MapHeight) As Integer Private _rand As Random = new Random() #End Region
Add the
Initialize()
method to theTileMap
class:#Region "Initialization" Public Sub Initialize(texture As Texture2D) _texture = texture _tiles.Clear() _tiles.Add(New Rectangle(0, 0, TileWidth, TileHeight)) _tiles.Add(New Rectangle(32, 0, TileWidth, TileHeight)) _tiles...