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:
- 17:ce6b54422113
- Parent:
- 16:37d98c281eb3
- Child:
- 18:ba4159ab4da7
diff -r 37d98c281eb3 -r ce6b54422113 Game/Game.cpp
--- a/Game/Game.cpp Wed May 08 09:05:27 2019 +0000
+++ b/Game/Game.cpp Wed May 08 13:03:24 2019 +0000
@@ -1,7 +1,7 @@
#include "Game.h"
Game::Game(){
-
+
}
Game::~Game(){
@@ -10,6 +10,7 @@
void Game::init(){
smiley.init(x,y);
+ _lives = 1;
}
void Game::dirmag(Gamepad &pad){
@@ -25,17 +26,16 @@
smiley.drawSprite(lcd);
}
+void Game::movement(Gamepad &pad, N5110 &lcd){
+ smiley.movement(dir,lcd);
+ enemy1.movement(lcd);
+ enemy2.movement(lcd);
+}
+
void Game::collect(N5110 &lcd, Gamepad &pad){
int x = smiley.get_x_char();
int y = smiley.get_y_char();
coin.spawn(x, y, lcd, pad);
-
-}
-
-void Game::movement(Gamepad &pad, N5110 &lcd){
- smiley.movement(dir,lcd);
- enemy1.movement(lcd);
- enemy2.movement(lcd);
}
void Game::damage(N5110 &lcd, Gamepad &pad){
@@ -46,19 +46,20 @@
}
}
-bool Game::death(int lives){
- if (lives == 0){
- return true;
- } else {
- return false;
+void Game::death(N5110 &lcd, Gamepad &pad){
+ if (_lives == 0) {
+ lcd.clear();
+ lcd.printString("YOU",30,2);
+ lcd.printString("DIED",30,3);
+ lcd.refresh();
+ wait(1);
}
}
void Game::UI(Gamepad &pad, N5110 &lcd){
- // while(death(lives) == true){
- if (_lives == 0) {
- // lcd.clear();
- menu.main(lcd,pad);
- // lcd.refresh();
- }
+ menu.main(lcd,pad);
+}
+
+int Game::get_lives() {
+ return _lives;
}
\ No newline at end of file