Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
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 |
diff -r dd8df17df666 -r 1e5cd98fc2aa bouncing_ball.cpp
--- 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:
