HTML and CSS Reference
In-Depth Information
// determine next enemy type from the enemy summon order.
var accumunateTargetCount = 0;
for (var i=0, len=this.enemySummonOrders.length; i<len; i++)
var enemyType = this.enemySummonOrders[i];
var targetCount = this.currentWave[enemyType] || 0; //
default 0 if the wave did not set that enemy type.
accumunateTargetCount += targetCount;
if(this.enemiesSummoned < accumunateTargetCount){
if(this.enemiesSummoned >= accumunateTargetCount) {
this.isActive = false;
} else {
// summon the enemy
this.enemiesSummoned += 1;
}).call(this, game, createjs);
5. That's all the code we have for the waves.js file. Let's go to the game.js file. We
set up some graphics to celebrate that the current wave is cleared, and we celebrate
with the player. By default, we hide this sprite with a large x offset:
// game waves
game.nextWaveSprite = new lib.WaveCleared();
game.nextWaveSprite.x = 999;
6. Then, we start the next wave when the game starts:
7. The game object is in charge of spawning the enemies through the waves object.
In the game.tick object, we check whether the current wave is cleared and then
reset the board for the next wave:
game.tick = function(){
// existing code goes here.
Search WWH ::

Custom Search