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.
Dependencies: mbed
Diff: GameEngine/GameEngine.cpp
- Revision:
- 8:5fde4e54a2f4
- Parent:
- 5:df0bf821b4cc
--- a/GameEngine/GameEngine.cpp Thu May 09 15:20:53 2019 +0000
+++ b/GameEngine/GameEngine.cpp Thu May 09 15:39:17 2019 +0000
@@ -63,9 +63,7 @@
void GameEngine::check_obstacle_collisions(Gamepad &pad)
{
Vector2D o1_pos = _o1.get_pos();
- //Vector2D ball_velocity = _ball.get_velocity();
-
- // check p1 first
+
Vector2D r_pos = _r.get_pos();
// see if obstacle has hit the runner by checking for overlaps
@@ -75,30 +73,20 @@
(o1_pos.x >= _rx) && //left
(o1_pos.x <= _rx + _runner_width) //right
) {
- // if it has, fix position and reflect x velocity
- // ball_pos.x = _p1x + _paddle_width;
- // ball_velocity.x = -ball_velocity.x;
- pad.tone(1200.0,1.0);
+ pad.tone(1200.0,1.0); // audio feedback
while(1) {
pad.leds_on();
}
- // audio feedback
-
}
- // write new attributes
- //_ball.set_velocity(ball_velocity);
- // _ball.set_pos(ball_pos);
}
void GameEngine::check_pass(Gamepad &pad)
{
Vector2D o1_pos = _o1.get_pos();
- // P2 has scored
if (o1_pos.x == START - 5) {
_r.add_score();
- //_ball.init(_ball_size,_speed);
pad.tone(1500.0,0.3);
}
@@ -108,13 +96,10 @@
{
// get score
int r_score = _r.get_score();
- //int p2_score = _p2.get_score();
- // print to LCD i
+ // print to LCD
char buffer1[14];
sprintf(buffer1,"%2d",r_score);
lcd.printString(buffer1,WIDTH/2 - 20,1); // font is 8 wide, so leave 4 pixel gape from middle assuming two digits
- //char buffer2[14];
- // sprintf(buffer2,"%2d",p2_score);
- // lcd.printString(buffer2,WIDTH/2 + 4,1);
+
}
\ No newline at end of file