Ahmed Adamjee
/
SnakeVSBlock
Snake vs Block Game to be run upon K64F.
Diff: GameEngine/WinLoose/WinLoose.cpp
- Revision:
- 51:387249f9b333
- Parent:
- 49:441c32f6603e
- Child:
- 55:df0825049171
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/GameEngine/WinLoose/WinLoose.cpp Fri Apr 26 18:30:25 2019 +0000 @@ -0,0 +1,55 @@ +#include "WinLoose.h" + +WinLoose::WinLoose() +{ + +} + +WinLoose::~WinLoose() +{ + +} + +int WinLoose::LevelComplete(N5110 &lcd, Gamepad &pad, int level) +{ + level += 1; + lcd.clear(); + lcd.printString("Level Complete",0,1); + lcd.printString("Press Start",10,3); + lcd.printString("to Proceed",12,4); + lcd.refresh(); + pad.init(); //to fix an issue with debouncing. + while (pad.check_event(Gamepad::START_PRESSED) == false) { + pad.leds_on(); + pad.tone(rand()%1001,0.1); //helps to set max freq for random sound + wait(0.1); + pad.leds_off(); + wait(0.1); + } + WinLoose::displayLevel(lcd, level); + return level; +} + +void WinLoose::displayLevel(N5110 &lcd, int level) +{ + lcd.clear(); + sprintf(bufferlevel,"%d",level); + lcd.printString("Level:",25,1); + lcd.printString(bufferlevel,40,3); + lcd.refresh(); + wait(2); +} + +void WinLoose::GameOver(N5110 &lcd, Gamepad &pad) +{ + pad.init(); + while ((pad.check_event(Gamepad::BACK_PRESSED) == false)) { + lcd.clear(); + lcd.printString("Game",33,1); + lcd.printString("Over",33,3); + lcd.printString("Press Back",14,5); //Function used to promt the user to Restart. + lcd.refresh(); + wait(0.1); + } + //NVIC_SystemReset(); //Software Reset. +} \ No newline at end of file