Skip to content

Instantly share code, notes, and snippets.

@colormono
Created June 24, 2013 12:19
Show Gist options
  • Save colormono/5849653 to your computer and use it in GitHub Desktop.
Save colormono/5849653 to your computer and use it in GitHub Desktop.
Bouncing. The object bounce when reach the screen borders.
void bounce(){
if ( (location.x > width) || (location.x < 0) ) {
velocity.x = velocity.x * -1;
}
if ( (location.y > height) || (location.y < 0) ) {
velocity.y = velocity.y * -1;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment