Skip to content

Instantly share code, notes, and snippets.

@CodeDraken
Created December 6, 2019 10:02
Show Gist options
  • Select an option

  • Save CodeDraken/7c4e1f4d39e78eb3daf392113a344d32 to your computer and use it in GitHub Desktop.

Select an option

Save CodeDraken/7c4e1f4d39e78eb3daf392113a344d32 to your computer and use it in GitHub Desktop.
// draws stuff to the screen
// allows us to separate calculations and drawing
function draw () {
// clear the canvas and redraw everything
ctx.clearRect(0, 0, canvas.width, canvas.height)
// draw the ball (only object in this scene)
ctx.beginPath()
ctx.fillStyle = 'red'
ctx.arc(
ball.x, ball.y,
ball.radius,
0, Math.PI * 2
)
ctx.fill()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment