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:
- 15:a080c64cf301
- Parent:
- 14:d0650d0de063
- Child:
- 16:37d98c281eb3
diff -r d0650d0de063 -r a080c64cf301 Game/Game.cpp
--- a/Game/Game.cpp Mon May 06 14:13:09 2019 +0000
+++ b/Game/Game.cpp Mon May 06 18:39:40 2019 +0000
@@ -28,7 +28,7 @@
void Game::collect(Smiley smiley,Coin coin,N5110 &lcd){
int x_coin;
int y_coin;
- if(smiley.get_x_char() + 7 == coin.get_x_coin() && smiley.get_y_char() + 7 == coin.get_y_coin()){
+ if(smiley.northCollision(x_char, y_char, lcd) == true && coin.southCollision(x_char, y_char, lcd) == true){
x_coin = 100;
y_coin = 100;
}
@@ -38,4 +38,18 @@
smiley.movement(dir,lcd);
enemy1.movement(lcd);
enemy2.movement(lcd);
+}
+
+void Game::damage(int lives){
+ lives = 3;
+
+ if(smiley.northCollision(x_char, y_char, lcd) == true && enemy1.southCollision(x_char, y_char, lcd) == true){
+ lives--;
+ } else if(smiley.southCollision(x_char, y_char, lcd) == true && enemy1.northCollision(x_char, y_char, lcd) == true){
+ lives--;
+ } else if(smiley.eastCollision(x_char, y_char, lcd) == true && enemy1.westCollision(x_char, y_char, lcd) == true){
+ lives--;
+ } else if(smiley.westCollision(x_char, y_char, lcd) == true && enemy1.eastCollision(x_char, y_char, lcd) == true){
+ lives--;
+ }
}
\ No newline at end of file