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.
Diff: BreakoutEngine/BreakoutEngine.cpp
- Revision:
- 48:966f2cf803ec
- Parent:
- 47:1d1a827be81b
- Child:
- 57:d498dd835cfc
--- a/BreakoutEngine/BreakoutEngine.cpp Fri Apr 26 21:43:55 2019 +0000
+++ b/BreakoutEngine/BreakoutEngine.cpp Fri Apr 26 21:57:09 2019 +0000
@@ -333,7 +333,14 @@
(ball_pos.y <= it_R -> get_y() + BRICK_HEIGHT) //top
) { // edit this so that if it hits the middle, reflect, else change angle depending on how far off centre (add angle to ball)
// if it has, fix position and reflect x velocity
- ball_pos.y = it_R -> get_y() + BRICK_HEIGHT;
+ if (ball_velocity.y < 0)
+ {
+ ball_pos.y = it_R -> get_y() + BRICK_HEIGHT;
+ }
+ else
+ {
+ ball_pos.y = it_R -> get_y();
+ }
ball_velocity.y = -ball_velocity.y;
// audio feedback
pad.tone(1000.0,0.1);