Additional exercises – Sharpening the axe
- Enemies get spawned at a slow, fixed rate. This can get a little boring because the difficulty never really increases. Make it so that enemies get spawned faster and faster after every round. For a simple way of doing this, you could follow the next steps:
- Add
start_interval,end_interval, andtime_deltaas export variables to theEntitySpawnernode. Thestart_intervalvariable will be the time we use between spawning entities at the start of the game,end_intervalwill be the final value, andtime_deltais the increment at which we will go from thestart_intervalvariable to theend_intervalvariable:
- Add
Figure 10.54 – The new exported variables for the EntitySpawner node
- Now, track in a separate variable,
_current_spawn_interval, the time for the next enemy to spawn. Set_current_spawn_intervalequal to thestart_intervalvariable at the start of the game. This variable replaces the old...