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: engine/engine.cpp
- Revision:
- 10:ef01b3076040
- Parent:
- 9:d217a636c18d
- Child:
- 11:7027f69672fc
--- a/engine/engine.cpp Thu Apr 19 23:07:14 2018 +0000
+++ b/engine/engine.cpp Sun Apr 22 23:34:39 2018 +0000
@@ -113,12 +113,13 @@
Vector2D money_pos = _money.get_pos();
if (
- (boom_pos.x >= rect_pos.x))
-
-
-
+ (boom_pos.x-2 >= rect_pos.x)and
+ (boom_pos.x+2 <= rect_pos.x+10)and
+ (boom_pos.y == 38))
+
{
- // money_pos.y = 0;
+ boom_pos.y = 0;
+ boom_pos.x = rand()%84;
pad.tone(750.0,0.1);
}
@@ -127,4 +128,38 @@
_rect.set_pos(rect_pos);
}
+void engine::check_goal(Gamepad &pad)
+{
+ Vector2D boom_pos = _boom.get_pos();
+ Vector2D rect_pos = _rect.get_pos();
+ Vector2D money_pos = _money.get_pos();
+
+ if ((boom_pos.x-2 >= rect_pos.x)and
+ (boom_pos.x+2 <= rect_pos.x+10)and
+ (boom_pos.y == 38)){
+ _rect.add_score();
+ //_ball.init(_ball_size,_speed);
+ pad.tone(1500.0,0.5);
+ pad.leds_on();
+ wait(0.5);
+ pad.leds_off();
+ }
+}
+
+void engine::print_scores(N5110 &lcd)
+{
+
+ int rect_score = _rect.get_score();
+
+ // print to LCD i
+ char buffer[14];
+ sprintf(buffer,"%2d",rect_score);
+ lcd.printString(buffer,WIDTH/2 - 20,1); // font is 8 wide, so leave 4 pixel gape from middle assuming two digits
+
+}
+
+
+
+
+