The spawning of environmental features will be covered briefly here as there's a whole chapter toward the end of the book that is dedicated to procedurally generating the game map. This is our end goal. So, to get started, we'll generate some superficial environmental features that will be ready for the random level generation later.
Adding a new tile
to the game will greatly increase the diversity of levels. One of the problems with procedural generation is that environments can feel too unnatural and generic. So this will help avoid that.
Let's add the following declaration to Game.h
:
/** * Spawns a given number of a certain tile at random locations in the level. */ void SpawnRandomTiles(TILE tileType, int count);
We have two parameters in this function. One allows us to specify a tile
index that we would like to spawn, and the second allows us to specify how many. We could have skipped the creation of a function and just hard-coded the behavior in the Game::PopulateLevel...