Fork of bouncing_ball by
Revision 6:1e5cd98fc2aa, committed 2017-11-15
- Comitter:
- rsean10
- Date:
- Wed Nov 15 20:58:54 2017 +0000
- Parent:
- 5:dd8df17df666
- Commit message:
Changed in this revision
bouncing_ball.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/bouncing_ball.cpp Tue Nov 14 14:57:59 2017 +0000 +++ b/bouncing_ball.cpp Wed Nov 15 20:58:54 2017 +0000 @@ -63,20 +63,20 @@ // Make circle bounce off of edges if at the edges: if (posx <= radius) { + posx = radius + BUFFER; speedx = -speedx; - posx = radius + BUFFER; } if ((posx + radius) >= _width) { + posx = _width - radius - BUFFER; speedx = -speedx; - posx = posx + radius - BUFFER; } if (posy <= radius) { + posy = radius + BUFFER; speedy = -speedy; - posy = radius + BUFFER; } if ((posy + radius) >= _height){ + posy = _height - radius - BUFFER; speedy = -speedy; - posy = posy + radius - BUFFER; } //Accelerate per actual real world physics: