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: Eng.cpp
- Revision:
- 10:6c574b8524df
- Parent:
- 9:2836fc3d9ede
- Child:
- 11:9661467412cf
diff -r 2836fc3d9ede -r 6c574b8524df Eng.cpp
--- a/Eng.cpp Mon May 18 12:41:06 2020 +0000
+++ b/Eng.cpp Mon May 18 13:12:35 2020 +0000
@@ -40,7 +40,7 @@
if (shot == 1){
aim.draw(lcd, fire);
lcd.refresh();
- check_hit(pad);
+ check_hit(pad, lcd);
}
int c_score = heston.checkscore();
@@ -62,7 +62,7 @@
//spikes.update();
_s1.update();
_s2.update();
- check_s_hit();
+ check_s_hit(pad);
}
}
@@ -77,10 +77,10 @@
_s1.draw(lcd);
_s2.draw(lcd);
}
- //print_score(lcd);
+
}
-void Eng::check_hit(Gamepad &pad)
+void Eng::check_hit(Gamepad &pad, N5110 &lcd)
{
Vector2D aim_pos = aim.get_pos();
Vector2D h1_pos = heston.get_pos();
@@ -88,9 +88,9 @@
if (
(aim_pos.y >= h1_pos.y) && //top
- (aim_pos.y <= h1_pos.y + 11) && //bottom
+ (aim_pos.y <= h1_pos.y + 12) && //bottom
(aim_pos.x >= h1_pos.x) && //left
- (aim_pos.x <= h1_pos.x + 10) //right
+ (aim_pos.x <= h1_pos.x + 11) //right
) {
heston.hit(pad);
}
@@ -108,6 +108,8 @@
}
else {
heston.miss(pad);
+ print_score(lcd);
+ lcd.refresh();
}
wait(0.4);
pad.leds_off();
@@ -145,7 +147,7 @@
lcd.printString(buffer1,1,1); // font is 8 wide, so leave 4 pixel gape from middle assuming two digits
}
-void Eng::check_s_hit(){
+void Eng::check_s_hit(Gamepad &pad){
Vector2D s1_pos = _s1.get_pos();
Vector2D s2_pos = _s2.get_pos();
Vector2D aim_pos = aim.get_pos();
@@ -157,6 +159,7 @@
(aim_pos.x <= s1_pos.x + 4) //right
) {
spike_f = false;
+ spikes.hit(pad);
}
if (
(aim_pos.y >= s2_pos.y) && //top
@@ -165,6 +168,7 @@
(aim_pos.x <= s2_pos.x + 4) //right
) {
spike_f = false;
+ spikes.hit(pad);
}