HTML and CSS Reference
In-Depth Information
}
switchGameState(GAME_STATE_EVALUATE_OUTCOME);
}
function gameStateEvaluateOutcome(){
if (player.hit){
player.dead = true;
createExplode(player);
}
for (var eCtr=enemy.length-1;eCtr>=0;eCtr--){
var tempEnemy = enemy[eCtr];
if (tempEnemy.hit){
score += enemyScore;
tempEnemy.dead = true;
createExplode(tempEnemy)
enemy.splice(eCtr,1);
tempEnemy = null;
}
}
switchGameState(GAME_STATE_ANIMATE_EXPLODE);
}
function createExplode(object){
var newExplode = {};
newExplode.currentTile = 0;
newExplode.row = object.row;
newExplode.col = object.com;
newExplode.x = object.x;
newExplode.y = object.y;
newExplode.rotation = 0;
explosions.push(newExplode);
}
function gameStateAnimateExplode(){
for (var eCtr=explosions.length-1;eCtr>=0;eCtr--){
var tempExplosion = explosions[eCtr];
renderPlayField();
tempExplosion.currentTile++;
if (tempExplosion.currentTile == explodeTiles.length){
explosions.splice(eCtr,1);
tempExplode = null;
}
}
if (explosions.length==0){
switchGameState(GAME_STATE_CHECK_FOR_GAME_OVER);
}
}
function gameStateCheckForGameOver() {
if (player.dead){
switchGameState(GAME_STATE_PLAYER_LOSE);
Search WWH ::




Custom Search