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:
- 115:aee684f62361
- Parent:
- 114:280903dd7e06
- Child:
- 116:2793d31ca691
--- a/BreakoutEngine/BreakoutEngine.cpp Wed May 08 13:08:55 2019 +0000
+++ b/BreakoutEngine/BreakoutEngine.cpp Wed May 08 13:30:52 2019 +0000
@@ -399,17 +399,14 @@
void BreakoutEngine::check_powerup_collisions(Gamepad &pad)
{
- // read current ball attributes
-
- // check paddle first
Vector2D paddle_pos = _paddle.get_pos();
// see if ball has hit the paddle by checking for overlaps
if (
(_powerup.get_x() >= paddle_pos.x) && //left
- (_powerup.get_x() <= paddle_pos.x + _paddle_width) && //right
- (_powerup.get_y() +9>= _paddley) && //bottom
- (_powerup.get_y() +9<= _paddley + _paddle_height) //top
+ (_powerup.get_x() + 8 <= paddle_pos.x + _paddle_width) && //right
+ (_powerup.get_y() + 8 >= _paddley) && //bottom
+ (_powerup.get_y() + 8 >= _paddley) //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
pad.tone(2500.0,0.1);