Last active
January 24, 2018 09:12
-
-
Save iampava/258f3ae48ad1022cce9e9ef480763b96 to your computer and use it in GitHub Desktop.
An overview of the logic inside the "paint" function.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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