January 2016
Intermediate to advanced
304 pages
6h 17m
English
Now we know what obstacles lie ahead, and how the level data is stored, let's take a look at how we can spawn items at random locations in our roguelike object.
The first step is to calculate the level bounds. Since we're making a 2D roguelike object, described in a 2D array, we need to identify the tiles that are suitable to spawn items on. If this was done for a 3D game, you would also have to take into account the third axis. Though we could just find the top left point of the map and calculate the distance to the bottom right, this would almost certainly cause problems.
We mentioned earlier that it's important that items are spawned within valid level areas. If we take this simple approach, ...
Read now
Unlock full access