This new method called SpawnEnemy
will create one enemy and initialize its position and the path to follow:
1. Create a new method called
SpawnEnemy
, inside the game class. It will have thex
position as a parameter. They
position will be fixed and always on top.Method SpawnEnemy:Int (x:Float)
2. Add a new instance of the
Enemy
class to theenemyList
field of thegame
class. They
position is always0
and there are25
path nodes to be created:enemyList.AddLast(New Enemy(x,0.0,25)) Return 0 End
This method created an enemy with 25 path nodes and stored it inside the enemy list of the game
class.