So, the tile width and tile height for this example are both 50px, which makes up the total level size of 300x300px - that is, six rows and six columns of tiles measuring 50x50px each. Here we assume that tile width and tile height are equal (and the same for all tiles), and match the tile images' dimensions. This is a straightforward 2D grid implementation, which we could code like so: for (i, loop through rows) I hope the concept of the tile-based approach is now clear. We can enhance this by adding corner tiles and separate vertical and horizontal wall tiles, requiring five additional tiles: , Arranging the tiles according to the level data will produce the below level image:Ī simple level, displayed in a top-down view. Here, 0 denotes a grass tile and 1 denotes a wall tile. These tiles are each the same size as each other, and are each square, so the tile height and tile width are the same.įor a level with grassland enclosed on all sides by walls, the level data's 2D array will look like this: , For example let us consider a standard top-down 2D view with two tiles - a grass tile and a wall tile - as shown here:
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
May 2023
Categories |