HTML and CSS Reference
In-Depth Information
10. When reseing the game, we need to remove all the bullets from the efect layer.
Since the Board object manages the bullet list, we remove the bullets from the
Board object:
Board.prototype.removeAllBullets = function(){
this.bulletList.length = 0;
game.effectLayer.removeAllChildren();
};
11. Finally, we update the HUD object and display the next wave number in the
hud.js file:
waves.textContent = game.waves.nextWave + 1; // logic
starts at 0, our display starts at 1
Objective complete - mini debriefing
We have created a leveling system. We separated the game into waves. In each wave,
we define how many enemies appear along with their spawning frequency.
We know that each wave is cleared after all the enemies are spawned and removed from
the board. The enemies may be killed by the castle bullets, or they may pass the botom
line and get removed.
When no lives remain during the waves, the game is over.
The enemy spawn logic
At each level, we define the amount of each type of enemies that should be spawned.
Then, we use a simple couning method to spawn the types in order. The order follows
the enemySummonOrders variable. The logic compares the sum of spawned enemies
and the amount of deiniion to know the next type of enemy to spawn. The following
figure explains how we can compare the total enemies spawned using the waves' data:
 
Search WWH ::




Custom Search