HTML and CSS Reference
In-Depth Information
frequency: 150 // how frequent enemy appears
},
{ // wave 3
'EnemyDummy' : 1,
'Enemy1' : 1,
'Enemy2' : 1,
'Enemy3' : 1,
'Boss' : 1,
'Boss2' : 30,
frequency: 50
}
];
2. We define a startWave method as the wave entry point for the game object to call.
It resets the game parameters:
game.waves.startWave = function() {
// reset energies
game.energies = 120;
this.currentWave = this.data[this.nextWave];
this.isActive = true;
this.enemiesSummoned = 0;
};
3. When the wave is cleared, we start with the next wave:
game.waves.waveCleared = function() {
this.nextWave += 1;
if (this.nextWave >= this.data.length) { // bound to max waves
data
this.nextWave = this.data.length -1;
}
this.startWave();
};
4. On each tick , we check the frequency to see whether it's ime to spawn the
next enemy:
game.waves.tick = function() {
if (!this.isActive) { return; } // wait until wave started
// time to summon new enemy
if (cjs.Ticker.getTicks() % this.currentWave.frequency === 0)
{
 
Search WWH ::




Custom Search