Ahmed Adamjee
/
SnakeVSBlock
Snake vs Block Game to be run upon K64F.
Diff: MenuClasses/Tutorial/Tutorial.cpp
- Revision:
- 78:10e5cc013806
- Parent:
- 69:55e309da7efd
- Child:
- 80:51ca38c5dcdf
--- a/MenuClasses/Tutorial/Tutorial.cpp Sun May 05 16:02:24 2019 +0000 +++ b/MenuClasses/Tutorial/Tutorial.cpp Sun May 05 17:22:48 2019 +0000 @@ -16,11 +16,11 @@ {0,0,0,0,1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1,0,0,0,0}, {0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0}, {0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0}, - {0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0}, - {0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,1,0,0,0,0,0,0,1,0,0,0,0}, - {0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,1,0,0,0,0,0,1,0,0,0,0}, - {0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,1,0,0,0,0,0,1,0,0,0,0}, - {0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,1,0,0,0,0,0,0,0,1,0,0,0}, + {0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,1,1,1,0,0,1,0,1,0,0,0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0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0}, @@ -197,19 +197,109 @@ void Tutorial::Implement(N5110 &lcd, Gamepad &pad) { - lcd.clear(); //pad.init(); Tutorial::gamePad(lcd, pad); - pad.tone(1000.0,0.1); - while (pad.check_event(Gamepad::BACK_PRESSED) == false) { } //if button pressed. + Tutorial::settings(lcd, pad); + Tutorial::controlsToNavigateInMenu(lcd, pad); + Tutorial::controlsToNavigateGameModeSpeed(lcd,pad); + Tutorial::controlsToPlayGame(lcd, pad); + Tutorial::controlsForPreviousOrNext(lcd, pad); } void Tutorial::gamePad(N5110 &lcd, Gamepad &pad) { + lcd.clear(); while ((pad.check_event(Gamepad::START_PRESSED) == false)&&(pad.check_event(Gamepad::A_PRESSED) == false)) { //if button pressed. lcd.drawSprite(20,0,27,44,(int *)g_pad); //Function used to draw the sprite. - lcd.printString("This is your",7,4); - lcd.printString("GamePad",22,5); + lcd.printString("Press Start or",0,4); + lcd.printString("A to proceed",7,5); + lcd.refresh(); + } + wait(0.25); + pad.tone(1000.0,0.1); +} + +void Tutorial::settings(N5110 &lcd, Gamepad &pad) +{ + lcd.clear(); + while ((pad.check_event(Gamepad::START_PRESSED) == false)&&(pad.check_event(Gamepad::A_PRESSED) == false)) { //if button pressed. + lcd.drawSprite(20,0,27,44,(int *)Pot); //Function used to draw the sprite. + lcd.printString("Rotate pot",12,4); + lcd.printString("in settings",9,5); + lcd.refresh(); + } + wait(0.25); + pad.tone(1000.0,0.1); +} + +void Tutorial::controlsToNavigateInMenu(N5110 &lcd, Gamepad &pad) +{ + lcd.clear(); + while ((pad.check_event(Gamepad::START_PRESSED) == false)&&(pad.check_event(Gamepad::A_PRESSED) == false)) { //if button pressed. + lcd.drawSprite(20,0,27,44,(int *)UpDown); //Function used to draw the sprite. + lcd.printString("Up/Down",21,4); + lcd.printString("for Main Menu",3,5); + lcd.refresh(); + } + wait(0.25); + pad.tone(1000.0,0.1); +} + +void Tutorial::controlsToNavigateGameModeSpeed(N5110 &lcd, Gamepad &pad) +{ + lcd.clear(); + while ((pad.check_event(Gamepad::START_PRESSED) == false)&&(pad.check_event(Gamepad::A_PRESSED) == false)) { //if button pressed. + lcd.drawSprite(20,0,27,44,(int *)LeftRight); //Function used to draw the sprite. + lcd.printString("Left/Right for",0,4); + lcd.printString("Mode & Speed",7,5); lcd.refresh(); } + wait(0.3); + pad.tone(1000.0,0.1); +} + +void Tutorial::controlsToPlayGame(N5110 &lcd, Gamepad &pad) +{ + lcd.clear(); + while ((pad.check_event(Gamepad::START_PRESSED) == false)&&(pad.check_event(Gamepad::A_PRESSED) == false)) { //if button pressed. + lcd.drawSprite(20,0,31,44,(int *)GameControls); //Function used to draw the sprite. + lcd.printString("InGameControls",0,4); + lcd.printString("to moove snake",0,5); + lcd.refresh(); + } + wait(0.25); + pad.tone(1000.0,0.1); + + lcd.clear(); + while ((pad.check_event(Gamepad::START_PRESSED) == false)&&(pad.check_event(Gamepad::A_PRESSED) == false)) { //if button pressed. + lcd.drawSprite(20,0,31,44,(int *)GameControls); //Function used to draw the sprite. + lcd.printString("Depends on",12,4); + lcd.printString("mode selection",0,5); + lcd.refresh(); + } + wait(0.25); + pad.tone(1000.0,0.1); +} + +void Tutorial::controlsForPreviousOrNext(N5110 &lcd, Gamepad &pad) +{ + lcd.clear(); + while ((pad.check_event(Gamepad::START_PRESSED) == false)&&(pad.check_event(Gamepad::A_PRESSED) == false)) { //if button pressed. + lcd.drawSprite(20,0,27,44,(int *)NextBack); //Function used to draw the sprite. + lcd.printString("Previous/Next",4,4); + lcd.printString("End/Start",16,5); + lcd.refresh(); + } + wait(0.3); + pad.tone(1000.0,0.1); + + lcd.clear(); + while ((pad.check_event(Gamepad::START_PRESSED) == false)&&(pad.check_event(Gamepad::A_PRESSED) == false)) { //if button pressed. + lcd.drawSprite(20,0,27,44,(int *)NextBack); //Function used to draw the sprite. + lcd.printString("Works in both",5,4); + lcd.printString("menu and game",5,5); + lcd.refresh(); + } + wait(0.3); + pad.tone(1000.0,0.1); } \ No newline at end of file