Skip to content

Instantly share code, notes, and snippets.

@AlexJWayne
Created February 16, 2014 19:16
Show Gist options
  • Save AlexJWayne/9039212 to your computer and use it in GitHub Desktop.
Save AlexJWayne/9039212 to your computer and use it in GitHub Desktop.
function animate() {
// new frame!
ctx.clearRect(0, 0, canvas.width, canvas.height);
// decide if it's time to spawn a new circle
if (shouldSpawnCircle()) {
circles.push(new Circle())
}
// update and draw all circles
var circle;
for (var i = 0; i < circles.length; i++) {
circle = circles[i];
circle.update();
circle.draw(ctx);
}
// queue up next frame
requestAnimFrame(animate);
};
animate(); // starts animation loop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment