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: PongEngine/PongEngine.cpp
- Revision:
- 20:e88c2eb13791
- Parent:
- 18:e5eb50c5e61f
diff -r 06f4d39b9290 -r e88c2eb13791 PongEngine/PongEngine.cpp
--- a/PongEngine/PongEngine.cpp Tue Apr 23 18:37:58 2019 +0000
+++ b/PongEngine/PongEngine.cpp Tue Apr 23 18:40:01 2019 +0000
@@ -303,7 +303,7 @@
(ball_pos.y <= _brick11_pos.y + HEIGHT_BRICK) //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 = _brick11_pos.y + HEIGHT_BRICK/2;
+ ball_pos.y = _brick11_pos.y + HEIGHT_BRICK;
ball_velocity.y = -ball_velocity.y;
// audio feedback
pad.tone(1000.0,0.1);
@@ -325,7 +325,7 @@
(ball_pos.y <= _brick12_pos.y + HEIGHT_BRICK) //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 = _brick12_pos.y + HEIGHT_BRICK/2;
+ ball_pos.y = _brick12_pos.y + HEIGHT_BRICK;
ball_velocity.y = -ball_velocity.y;
// audio feedback
pad.tone(1000.0,0.1);
@@ -347,7 +347,7 @@
(ball_pos.y <= _brick13_pos.y + HEIGHT_BRICK) //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 = _brick13_pos.y+ HEIGHT_BRICK/2;
+ ball_pos.y = _brick13_pos.y+ HEIGHT_BRICK;
ball_velocity.y = -ball_velocity.y;
// audio feedback
pad.tone(1000.0,0.1);
@@ -369,7 +369,7 @@
(ball_pos.y <= _brick14_pos.y + HEIGHT_BRICK) //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 = _brick14_pos.y+ HEIGHT_BRICK/2;
+ ball_pos.y = _brick14_pos.y+ HEIGHT_BRICK;
ball_velocity.y = -ball_velocity.y;
// audio feedback
pad.tone(1000.0,0.1);
@@ -391,7 +391,7 @@
(ball_pos.y <= _brick15_pos.y + HEIGHT_BRICK) //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 = _brick15_pos.y+ HEIGHT_BRICK/2;
+ ball_pos.y = _brick15_pos.y+ HEIGHT_BRICK;
ball_velocity.y = -ball_velocity.y;
// audio feedback
pad.tone(1000.0,0.1);
@@ -413,7 +413,7 @@
(ball_pos.y <= _brick16_pos.y + HEIGHT_BRICK) //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 = _brick16_pos.y+ HEIGHT_BRICK/2;
+ ball_pos.y = _brick16_pos.y+ HEIGHT_BRICK;
ball_velocity.y = -ball_velocity.y;
// audio feedback
pad.tone(1000.0,0.1);
@@ -435,7 +435,7 @@
(ball_pos.y <= _brick21_pos.y + HEIGHT_BRICK) //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 = _brick21_pos.y+ HEIGHT_BRICK/2;
+ ball_pos.y = _brick21_pos.y+ HEIGHT_BRICK;
ball_velocity.y = -ball_velocity.y;
// audio feedback
pad.tone(1000.0,0.1);
@@ -457,7 +457,7 @@
(ball_pos.y <= _brick22_pos.y + HEIGHT_BRICK) //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 = _brick22_pos.y+ HEIGHT_BRICK/2;
+ ball_pos.y = _brick22_pos.y+ HEIGHT_BRICK;
ball_velocity.y = -ball_velocity.y;
// audio feedback
pad.tone(1000.0,0.1);
@@ -479,7 +479,7 @@
(ball_pos.y <= _brick23_pos.y + HEIGHT_BRICK) //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 = _brick23_pos.y+ HEIGHT_BRICK/2;
+ ball_pos.y = _brick23_pos.y+ HEIGHT_BRICK;
ball_velocity.y = -ball_velocity.y;
// audio feedback
pad.tone(1000.0,0.1);
@@ -501,7 +501,7 @@
(ball_pos.y <= _brick24_pos.y + HEIGHT_BRICK) //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 = _brick24_pos.y+ HEIGHT_BRICK/2;
+ ball_pos.y = _brick24_pos.y+ HEIGHT_BRICK;
ball_velocity.y = -ball_velocity.y;
// audio feedback
pad.tone(1000.0,0.1);
@@ -523,7 +523,7 @@
(ball_pos.y <= _brick25_pos.y + HEIGHT_BRICK) //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 = _brick25_pos.y+ HEIGHT_BRICK/2;
+ ball_pos.y = _brick25_pos.y+ HEIGHT_BRICK;
ball_velocity.y = -ball_velocity.y;
// audio feedback
pad.tone(1000.0,0.1);
@@ -545,7 +545,7 @@
(ball_pos.y <= _brick26_pos.y + HEIGHT_BRICK) //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 = _brick26_pos.y+ HEIGHT_BRICK/2;
+ ball_pos.y = _brick26_pos.y+ HEIGHT_BRICK;
ball_velocity.y = -ball_velocity.y;
// audio feedback
pad.tone(1000.0,0.1);
@@ -567,7 +567,7 @@
(ball_pos.y <= _brick31_pos.y + HEIGHT_BRICK) //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 = _brick31_pos.y+ HEIGHT_BRICK/2;
+ ball_pos.y = _brick31_pos.y+ HEIGHT_BRICK;
ball_velocity.y = -ball_velocity.y;
// audio feedback
pad.tone(1000.0,0.1);
@@ -589,7 +589,7 @@
(ball_pos.y <= _brick32_pos.y + HEIGHT_BRICK) //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 = _brick32_pos.y+ HEIGHT_BRICK/2;
+ ball_pos.y = _brick32_pos.y+ HEIGHT_BRICK;
ball_velocity.y = -ball_velocity.y;
// audio feedback
pad.tone(1000.0,0.1);
@@ -611,7 +611,7 @@
(ball_pos.y <= _brick33_pos.y + HEIGHT_BRICK) //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 = _brick33_pos.y+ HEIGHT_BRICK/2;
+ ball_pos.y = _brick33_pos.y+ HEIGHT_BRICK;
ball_velocity.y = -ball_velocity.y;
// audio feedback
pad.tone(1000.0,0.1);
@@ -633,7 +633,7 @@
(ball_pos.y <= _brick34_pos.y + HEIGHT_BRICK) //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 = _brick34_pos.y+ HEIGHT_BRICK/2;
+ ball_pos.y = _brick34_pos.y+ HEIGHT_BRICK;
ball_velocity.y = -ball_velocity.y;
// audio feedback
pad.tone(1000.0,0.1);
@@ -655,7 +655,7 @@
(ball_pos.y <= _brick35_pos.y + HEIGHT_BRICK) //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 = _brick35_pos.y+ HEIGHT_BRICK/2;
+ ball_pos.y = _brick35_pos.y+ HEIGHT_BRICK;
ball_velocity.y = -ball_velocity.y;
// audio feedback
pad.tone(1000.0,0.1);
@@ -677,7 +677,7 @@
(ball_pos.y <= _brick36_pos.y + HEIGHT_BRICK) //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 = _brick36_pos.y+ HEIGHT_BRICK/2;
+ ball_pos.y = _brick36_pos.y+ HEIGHT_BRICK;
ball_velocity.y = -ball_velocity.y;
// audio feedback
pad.tone(1000.0,0.1);