Ahmed Adamjee
/
SnakeVSBlock
Snake vs Block Game to be run upon K64F.
Diff: MenuClasses/StartScreen/StartScreen.cpp
- Revision:
- 59:c65a2e933c47
- Parent:
- 58:affb42c56cf8
- Child:
- 60:d3a9e0e4a0de
diff -r affb42c56cf8 -r c65a2e933c47 MenuClasses/StartScreen/StartScreen.cpp --- a/MenuClasses/StartScreen/StartScreen.cpp Sun Apr 28 19:40:50 2019 +0000 +++ b/MenuClasses/StartScreen/StartScreen.cpp Mon Apr 29 12:09:31 2019 +0000 @@ -43,8 +43,8 @@ {1,0,0,0,0,0,1,1,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,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,0,0,0,0,0,0,0,0,0,0,0,0,0,1}, {1,0,0,0,0,1,1,1,1,1,1,0,1,1,0,0,0,1,0,0,0,1,1,1,0,0,0,1,1,0,0,1,1,0,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,1,1,0,0,0,1,1,1,0,0,0,1,1,1,1,0,1,1,0,0,1,1,0,1}, {1,0,0,0,0,1,1,0,0,0,0,0,1,1,1,0,0,1,0,0,1,0,0,0,1,0,0,1,1,0,0,1,0,0,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,1,0,1,1,0,0,1,1,0,1,1,0,1,1,0,0,1,0,1,1,0,0,1,0,0,1}, - {1,0,0,0,0,1,1,1,1,0,0,0,1,1,0,1,0,1,0,1,1,0,0,0,1,1,0,1,1,0,1,1,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,1,0,1,1,0,0,1,0,0,0,1,0,1,1,0,0,0,0,1,1,0,1,1,0,0,1}, - {1,0,0,0,0,0,0,1,1,1,1,0,1,1,0,1,0,1,0,1,1,1,1,1,1,1,0,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.refresh(); pad.tone(song[(ani+48)/3],0.1); + Start_Pressed = 0; + if((pad.check_event(Gamepad::START_PRESSED) == true)||(pad.check_event(Gamepad::A_PRESSED) == true)) { //to allow the gamer to skip the long starting animation if they are not a fan. + Start_Pressed = 1; + break; + } wait(0.2); } - - wait(0.3); + if (Start_Pressed == 0) { wait(0.3); } //dont wait anymore if start is pressed. pad.leds_off(); lcd.clear(); @@ -169,12 +173,12 @@ void StartScreen::instruct(N5110 &lcd, Gamepad &pad) { - lcd.printString("Please Press",5,1); //Function used to promt the user to start. - lcd.printString("Start",25,3); - lcd.printString("to Begin",15,5); - lcd.refresh(); pad.init(); - while ( pad.check_event(Gamepad::START_PRESSED) == false) { + while ((pad.check_event(Gamepad::START_PRESSED) == false)&&(pad.check_event(Gamepad::A_PRESSED) == false)&&(Start_Pressed == 0)) { + lcd.printString("Please Press",5,1); //Function used to promt the user to start. + lcd.printString("Start",25,3); + lcd.printString("to Begin",15,5); + lcd.refresh(); pad.leds_on(); wait(0.1); pad.leds_off(); @@ -225,10 +229,10 @@ lcd.printString("Stats",0,4); lcd.printString("Tutorial",0,5); Direction d = pad.get_direction(); - if((d==N)&&(i>16)) { + if(((d==N)||(pad.check_event(Gamepad::L_PRESSED) == true))&&(i>16)) { i=i-8; } - if((d==S)&&(i<40)) { + if(((d==S)||(pad.check_event(Gamepad::R_PRESSED) == true))&&(i<40)) { i=i+8; } lcd.drawSprite(50,i,7,9,(int *)arrow); //Function used to draw the sprite. @@ -276,12 +280,12 @@ else {back_pressed = 0;} } pad.tone(1000.0,0.1); - if (g_mode == 2) { StartScreen::motionControlInstructions(lcd); } if(back_pressed) { main_menu(lcd, pad); } else { - pad.tone(1000.0,0.1); + if (g_mode == 2) { StartScreen::motionControlInstructions(lcd); } + else { pad.tone(1000.0,0.1); } lcd.clear(); game_speed(lcd, pad); } @@ -311,11 +315,11 @@ { Direction d = pad.get_direction(); wait(1/cs); - if(((d==E)||(d==W))&&(g_mode==1)) { + if(((d==E)||(d==W)||(pad.check_event(Gamepad::R_PRESSED) == true)||(pad.check_event(Gamepad::L_PRESSED) == true))&&(g_mode==1)) { g_mode=2; } - else if(((d==E)||(d==W))&&(g_mode==2)) { + else if(((d==E)||(d==W)||(pad.check_event(Gamepad::R_PRESSED) == true)||(pad.check_event(Gamepad::L_PRESSED) == true))&&(g_mode==2)) { g_mode=1; } } @@ -361,16 +365,16 @@ { Direction d = pad.get_direction(); wait(1/cs); - if((d==E)&&(gs==4)) { + if(((d==E)||(pad.check_event(Gamepad::R_PRESSED) == true))&&(gs==4)) { gs=1; } - else if((d==W)&&(gs==1)) { + else if(((d==W)||(pad.check_event(Gamepad::L_PRESSED) == true))&&(gs==1)) { gs=4; } - else if((d==E)&&(1<=gs<=3)) { + else if(((d==E)||(pad.check_event(Gamepad::R_PRESSED) == true))&&(1<=gs<=3)) { gs=gs+1; } - else if((d==W)&&(2<=gs<=4)) { + else if(((d==W)||(pad.check_event(Gamepad::L_PRESSED) == true))&&(2<=gs<=4)) { gs=gs-1; } } @@ -383,7 +387,7 @@ lcd.printString("Game Speed",10,1); switch (gs) { case 1: - lcd.printString("SNAIL",28,3); + lcd.printString("SNAKE",28,3); fps = 12; break; case 2: