Game Development Reference
In-Depth Information
var playerLasers =
playerLaserGunComp.getShots();
for (var i = 0, len = playerLasers.length;
i < len; i++) {
phy.addPlayerShots(playerLasers[i]);
}
// Update positions
enMan.update();
player.update();
// Check for collisions
phy.checkCollisions();
// Draw
canvas.clear();
for (var i = 0, len = enemies.length; i <
len; i++) {
enemies[i].draw();
}
for (var i = 0, len = playerLasers.length;
i < len; i++) {
playerLasers[i].draw();
}
player.draw();
playerEnergy.setEnergy(playerStrengthComp.getEnergy());
});
// Get the game going
gameLoop.run();
})();
The main reason for the self-invoked main function is to privately scope all of the
variables contained within the function is to prevent users from manipulating the
Search WWH ::




Custom Search