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: Game/Game.cpp
- Revision:
- 19:1073cc64cb0b
- Parent:
- 18:ba4159ab4da7
- Child:
- 20:ad13b0fdd8ff
diff -r ba4159ab4da7 -r 1073cc64cb0b Game/Game.cpp
--- a/Game/Game.cpp Wed May 08 15:01:45 2019 +0000
+++ b/Game/Game.cpp Wed May 08 18:12:27 2019 +0000
@@ -10,10 +10,11 @@
void Game::init(){
smiley.init(x,y);
- _lives = 3;
+ _lives = 10;
coin1.init(41, 42);
coin2.init(41, 23);
- coin3.init(81, 42);
+ coin3.init(78, 42);
+ coin4.init(31, 35);
}
void Game::dirmag(Gamepad &pad){
@@ -28,6 +29,7 @@
coin1.drawSprite(lcd);
coin2.drawSprite(lcd);
coin3.drawSprite(lcd);
+ coin4.drawSprite(lcd);
smiley.drawSprite(lcd);
}
@@ -41,6 +43,9 @@
int x = smiley.get_x_char();
int y = smiley.get_y_char();
coin1.spawn(x, y, lcd, pad);
+ coin2.spawn(x, y, lcd, pad);
+ coin3.spawn(x, y, lcd, pad);
+ coin4.spawn(x, y, lcd, pad);
}
void Game::damage(N5110 &lcd, Gamepad &pad){
@@ -48,6 +53,7 @@
int y = smiley.get_y_char();
if (enemy1.collidePlayer(x, y, pad) == true || enemy2.collidePlayer(x, y, pad) == true ){
_lives--;
+ wait(0.1);
}
}
@@ -67,4 +73,10 @@
int Game::get_lives() {
return _lives;
+}
+
+void Game::display_health(N5110 &lcd) {
+ char buffer[14];
+ sprintf(buffer,"%d",_lives);
+ lcd.printString(buffer,2,5);
}
\ No newline at end of file