Skip to content

Instantly share code, notes, and snippets.

@iampava
Last active January 24, 2018 09:12
Show Gist options
  • Save iampava/258f3ae48ad1022cce9e9ef480763b96 to your computer and use it in GitHub Desktop.
Save iampava/258f3ae48ad1022cce9e9ef480763b96 to your computer and use it in GitHub Desktop.
An overview of the logic inside the "paint" function.
let enemyList = [];
paint();
function paint() {
//This function gets called every frame
if(checkGameOver()) {
alert('Game over');
}
enemyList.forEach(growEnemy);
if(timeForNewEnemy()) {
enemyList.push(createNewEnemy());
}
updateScore();
window.requestAnimationFrame(paint);
}
/** Utility Functions */
function checkGameOver() { /* ... */ }
function growEnemy(enemy) { /* ... */ }
function timeForNewEnemy() { /* ... */ }
function createNewEnemy() { /* ... */ }
function updateScore() { /* ... */ }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment