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:
- 41:fe383cbb51b2
- Parent:
- 40:ac53905346fb
- Child:
- 42:347c20a16ee6
--- a/BreakoutEngine/BreakoutEngine.cpp Fri Apr 26 07:07:42 2019 +0000
+++ b/BreakoutEngine/BreakoutEngine.cpp Fri Apr 26 08:11:02 2019 +0000
@@ -166,6 +166,7 @@
check_paddle_collisions(pad);
check_brick_collisions(pad);
check_laser_collisions(pad);
+ check_laser_ceiling_collision();
}
@@ -252,6 +253,18 @@
}
+void BreakoutEngine::check_laser_ceiling_collision()
+{
+ for (it_L = listofLasers.begin(); it_L != listofLasers.end(); ++it_L){
+ if (
+ (it_L -> get_y() <= GAP_TOP - 1)
+ ) { // 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
+ it_L -> set_posx(-10);
+ }
+ }
+}
+
void BreakoutEngine::check_paddle_collisions(Gamepad &pad)
{
// read current ball attributes