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:
- 16:37d98c281eb3
- Parent:
- 15:a080c64cf301
- Child:
- 17:ce6b54422113
--- a/Game/Game.cpp Mon May 06 18:39:40 2019 +0000 +++ b/Game/Game.cpp Wed May 08 09:05:27 2019 +0000 @@ -25,13 +25,11 @@ smiley.drawSprite(lcd); } -void Game::collect(Smiley smiley,Coin coin,N5110 &lcd){ - int x_coin; - int 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; - } +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){ @@ -40,16 +38,27 @@ 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--; +void Game::damage(N5110 &lcd, Gamepad &pad){ + int x = smiley.get_x_char(); + int y = smiley.get_y_char(); + if (enemy1.collidePlayer(x, y, pad) == true || enemy2.collidePlayer(x, y, pad) == true ){ + _lives--; + } +} + +bool Game::death(int lives){ + if (lives == 0){ + return true; + } else { + return false; + } +} + +void Game::UI(Gamepad &pad, N5110 &lcd){ + // while(death(lives) == true){ + if (_lives == 0) { + // lcd.clear(); + menu.main(lcd,pad); + // lcd.refresh(); } } \ No newline at end of file