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.
Dependents: Barros_Assignment4
Revision 3:d4138ad4f452, committed 2017-12-07
- Comitter:
- Kaitlyn_Barros
- Date:
- Thu Dec 07 23:20:16 2017 +0000
- Parent:
- 2:6ba843cde0bb
- Commit message:
- Assignment 6
Changed in this revision
physics_ball.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/physics_ball.cpp Fri Nov 17 04:09:18 2017 +0000 +++ b/physics_ball.cpp Thu Dec 07 23:20:16 2017 +0000 @@ -46,13 +46,18 @@ //Ball Physics if ((posx <= radius) || (posx >= 128-radius)){ - speedx = -1 * speedx; - } + speedx = -1 * speedx; + } if ((radius < posx) && (posx < 128- radius)){ speedx = speedx; } + if ((posy <= radius) || (posy >= 128-radius)) { - speedy = -1 * speedy; + speedy = -1 * speedy; + + if ((radius < posy) && (posy < 128- radius)){ + speedy = speedy; + } } old_posx = posx; @@ -60,8 +65,6 @@ // Reset when sensor is flipped upside down (For Ball 1 & 2) if (accel.readZ() < 0){ - - set_state(DEFAULT_POSX, DEFAULT_POSY, 5, 5); } }