Game Development Reference
In-Depth Information
object. The newly created enemy is then added to the _enemies list, spawning it
in the game world.
CreateEnemyFromDef does pretty much what it says; it takes an EnemyDef
object and returns an Enemy object. There's only one type of enemy at the
moment so it's quite a simple function, but there's a lot of scope for adding new
enemy types.
Run the program now and as the level time ticks down, three enemies will spawn
in the level.
Enemy Movement
Enemies in a scrolling shooter should sweep in from the right of the screen and
attempt to exit to the right without getting blown up. The enemy advance is
shown in Figure 10.12. The player bullets already have movement code so the
enemies could reuse that code. This would work, but the enemy movement
would be pretty boring; they'd move from right to left in a straight line. Enemy
movement should be far more interesting, and the easiest way to do this is to give
Enemy Advance
Figure 10.12
The enemy advance.
 
Search WWH ::




Custom Search