Skip to content

Instantly share code, notes, and snippets.

@botrosg
Created August 23, 2017 01:31
Show Gist options
  • Save botrosg/d2bb38eaefda08add617a96af5c33f14 to your computer and use it in GitHub Desktop.
Save botrosg/d2bb38eaefda08add617a96af5c33f14 to your computer and use it in GitHub Desktop.
if(this.x - 5 < 0) { // hitting the left wall
this.x = 5;
this.x_speed = -this.x_speed;
} else if(this.x + 5 > canvas.width) { // hitting the right wall
this.x = canvas.width - this.radius;
this.x_speed = -this.x_speed;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment