Snake vs Block Game to be run upon K64F.

Dependencies:   mbed

GameEngine/WinLoose/WinLoose.cpp

Committer:
AhmedPlaymaker
Date:
2019-04-30
Revision:
61:f3c402bc2ad0
Parent:
59:c65a2e933c47
Child:
62:ebf6ecf8a6d5

File content as of revision 61:f3c402bc2ad0:

#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();
    wait(0.1);
    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);
    }
    lcd.clear();
    //NVIC_SystemReset(); //Software Reset.
}