January 2016
Intermediate to advanced
304 pages
6h 17m
English
Now, let's tie all of this together to spawn items randomly in the map. Here is a quick overview of the steps that we'll take:
tile from the level data.floor tile. If not, go to step 1.The first step is to select a random tile in the level data. Earlier in this chapter, we covered how we'll achieve this:
// Declare the variables we need. int columnIndex(0), rowIndex(0); Tile tileType; // Generate a random index for the row and column. columnIndex = std::rand() % GRID_WIDTH; rowIndex = std::rand() % GRID_HEIGHT; // Get the tile type. tileType = m_level.GetTileType(columnIndex, rowIndex);
We now ...
Read now
Unlock full access