Last active
December 5, 2019 10:01
-
-
Save CodeDraken/6698d4aa700612039782a4b426f69e41 to your computer and use it in GitHub Desktop.
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
// global variables that will be loaded/initialized later | |
let canvas, ctx, gravity, ball, friction | |
// runs once at the beginning | |
// loads any data and kickstarts the loop | |
function init () { | |
// load and initialize data here | |
// ... | |
// begin update loop | |
// ... | |
} | |
// draws stuff to the screen | |
// allows us to separate calculations and drawing | |
function draw () { | |
// clear the canvas | |
// ... | |
// draw things | |
// ... | |
} | |
// the main piece of the loop | |
// runs everything | |
function update () { | |
// queue the next update | |
// ... | |
// logic goes here | |
// ... | |
// draw after logic/calculations | |
draw() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment