HTML and CSS Reference
var pos = this.rowColToScreen(0, col);
sprite.x = pos.x;
sprite.y = pos.y;
// store row/col for easy access later
sprite.row = 0;
sprite.col = col;
8. In order to test the enemies, we manually call the addEnemy funcion in the game.
js file. In a later task, we will use a level controller to control the summoning of
// temporary code
// end temporary code
9. In order to end the game for debugging, we temporarily decrease the default lives
to be less than or equal to the enemies that we have added temporarily:
game.lives = 2;
Now, we should get the enemy moving down the board.
Objective complete - mini debriefing
We defined a base enemy class. Then, we extended this base to create a wide range of
enemies with diferent graphics and characterisics. By having a base deiniion, we can
easily create a new type of enemy with diferent properies without copying and pasing
all the common logic everywhere.
For example, in the sample game, we created four levels of enemies and two bosses.
Their diferent movement speeds and HPs create a large combinaion of diiculies.
Enemies that reach the earth
Each game starts with 20 lives. We reduce the lives for each enemy that passes the botom line
and reaches the earth. We know that the enemy succeeds when it moves beyond the last row.