Skip to content

Instantly share code, notes, and snippets.

@brandonjank
Created November 24, 2015 06:22
Show Gist options
  • Save brandonjank/dc9de2f044b6e805acb2 to your computer and use it in GitHub Desktop.
Save brandonjank/dc9de2f044b6e805acb2 to your computer and use it in GitHub Desktop.
x += velocity * Math.cos(angle * Math.PI /180);
y += velocity * Math.sin(angle * Math.PI /180);
if (x < 0 || x > canvas.width) {
angle = 180 - angle;
}
else if (y < 0 ||y > canvas.height) {
angle = 360 - angle;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment