Last active
December 6, 2019 09:56
-
-
Save CodeDraken/053085fc5ace145d0e0836d6982e4ee6 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 | |
function init () { | |
// our canvas variables | |
// ... | |
// set the canvas size | |
// ... | |
// world/scene settings | |
// ... | |
// starting objects | |
ball = { | |
bounce: 0.75, // energy lost on bounce (25%) | |
radius: 30, | |
x: canvas.width / 2, | |
y: canvas.height / 2, | |
velX: (Math.random() * 15 + 5) * (Math.floor(Math.random() * 2) || -1), | |
velY: (Math.random() * 15 + 5) * (Math.floor(Math.random() * 2) || -1) | |
} | |
// begin update loop | |
// ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment