1
Dependencies: mbed Gamepad N5110
Diff: main.cpp
- Revision:
- 2:1234b0a1a51d
- Parent:
- 1:db2a69ca4929
- Child:
- 3:7b28047013d2
--- a/main.cpp Sat Apr 27 06:18:24 2019 +0000 +++ b/main.cpp Sun Apr 28 05:49:15 2019 +0000 @@ -25,21 +25,29 @@ Gamepad pad; Snake snake; Direction d; -int SNAKY[11][48] = { - {0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,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,1,1,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, - {0,1,1,1,0,0,1,0,0,0,1,1,0,0,0,1,1,0,0,0,0,0,1,1,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,1,1,1,0,0,0,1,1,0,0,0,0,1,1,0,0,1,1,0,0,0,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,1,1,0,0,1,1,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1,1,1,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,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,1,1,0,0,0,0,0,0,1,1,1,1,1,1,1,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,1,0,0,0,0,0,0,0,0,1,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,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1,1,0,0,0}, - {0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,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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,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,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}, @@ -57,8 +65,7 @@ /************************Prototypes************************/ void start_game(); void game_setting(); -void game_music(); -void game_music_2(); +int game_music_2(); /************************Variables************************/ @@ -68,344 +75,438 @@ /************************Main code************************/ int main() -{ - lcd.init();//initializing display - pad.init(); +{ snake.Highest_score = 0; + while(1){ + int _Flag = 1; + lcd.init();//initializing display + pad.init(); + start_game(); + game_setting(); + snake.init(25,25,5,3); + //pc.printf("initalized"); - snake.init(25,25,5,3); - game_music_2(); - start_game(); - game_setting(); - while (1) { - //printf("updated"); - snake.drawsnake(lcd); + while (_Flag) { + snake.drawsnake(lcd,pad); snake.snakemov(pad); - } + if(snake.live <= 0) { + _Flag = 0; + } + } + } } /************************Functions************************/ -void game_music_2(){ - pad.tone(1047.0,0.125); //H1_ +int game_music_2(){ + pad.tone(1047.0,0.125); //gap + wait(0.125); + if(pad.check_event(Gamepad::A_PRESSED) == true){ + return 0; + } + pad.tone(1175.0,0.125); //1_ + wait(0.125); + if(pad.check_event(Gamepad::A_PRESSED) == true){ + return 0; + } + pad.tone(1319.0,0.25); //2_ + wait(0.25); + if(pad.check_event(Gamepad::A_PRESSED) == true){ + return 0; + } + pad.tone(1047.0,0.125); //3_ + wait(0.125); + if(pad.check_event(Gamepad::A_PRESSED) == true){ + return 0; + } + pad.tone(880.0,0.125); //1_ + wait(0.125); + if(pad.check_event(Gamepad::A_PRESSED) == true){ + return 0; + } + pad.tone(880.0,0.25); //5 3/4 + wait(0.25); + if(pad.check_event(Gamepad::A_PRESSED) == true){ + return 0; + } + pad.tone(1175.0,0.25); //3_ + wait(0.25); + if(pad.check_event(Gamepad::A_PRESSED) == true){ + return 0; + } + pad.tone(988.0,0.25); //2 + wait(0.25); + if(pad.check_event(Gamepad::A_PRESSED) == true){ + return 0; + } + pad.tone(784.0,0.125); //5 + wait(0.125); + if(pad.check_event(Gamepad::A_PRESSED) == true){ + return 0; + } + pad.tone(659.0,0.125); //2 wait(0.125); - pad.tone(1175.0,0.125); //H2_ + if(pad.check_event(Gamepad::A_PRESSED) == true){ + return 0; + } + pad.tone(659.0,0.25); //1. + wait(0.25); + if(pad.check_event(Gamepad::A_PRESSED) == true){ + return 0; + } + pad.tone(988.0,0.25); //l6. + wait(0.25); + if(pad.check_event(Gamepad::A_PRESSED) == true){ + return 0; + } + pad.tone(880.0,0.25); //3 3/4 + wait(0.25); + if(pad.check_event(Gamepad::A_PRESSED) == true){ + return 0; + } + pad.tone(784.0,0.125); //1. + wait(0.125); + if(pad.check_event(Gamepad::A_PRESSED) == true){ + return 0; + } + pad.tone(523.0,0.125); //l7 + wait(0.125); + if(pad.check_event(Gamepad::A_PRESSED) == true){ + return 0; + } + pad.tone(523.0,0.25); //gap + wait(0.25); + if(pad.check_event(Gamepad::A_PRESSED) == true){ + return 0; + } + pad.tone(784.0,0.25); //l7 + wait(0.25); + if(pad.check_event(Gamepad::A_PRESSED) == true){ + return 0; + } + pad.tone(659.0,0.25); //l6 + wait(0.25); + if(pad.check_event(Gamepad::A_PRESSED) == true){ + return 0; + } + pad.tone(0.0,0.25); //l7 + wait(0.25); + if(pad.check_event(Gamepad::A_PRESSED) == true){ + return 0; + } + pad.tone(0.0,0.25); //1. + wait(0.25); + if(pad.check_event(Gamepad::A_PRESSED) == true){ + return 0; + } + pad.tone(587.0,0.125); //2. + wait(0.125); + if(pad.check_event(Gamepad::A_PRESSED) == true){ + return 0; + } + pad.tone(659.0,0.125); //l5 wait(0.125); - pad.tone(1319.0,0.25); //H3 + if(pad.check_event(Gamepad::A_PRESSED) == true){ + return 0; + } + pad.tone(698.0,0.25); //1 + wait(0.25); + if(pad.check_event(Gamepad::A_PRESSED) == true){ + return 0; + } + pad.tone(0.0,0.25); //2. + wait(0.25); + if(pad.check_event(Gamepad::A_PRESSED) == true){ + return 0; + } + pad.tone(1047.0,0.25); //3. + wait(0.25); + if(pad.check_event(Gamepad::A_PRESSED) == true){ + return 0; + } + pad.tone(988.0,0.0833); //4 + wait(0.0833); + if(pad.check_event(Gamepad::A_PRESSED) == true){ + return 0; + } + pad.tone(988.0,0.0833); //4. + wait(0.0833); + if(pad.check_event(Gamepad::A_PRESSED) == true){ + return 0; + } + pad.tone(1047.0,0.0833); //3. + wait(0.0833); + if(pad.check_event(Gamepad::A_PRESSED) == true){ + return 0; + } + pad.tone(784.0,0.25); //2. + wait(0.25); + if(pad.check_event(Gamepad::A_PRESSED) == true){ + return 0; + } + pad.tone(0.0,0.25); //1. + wait(0.25); + if(pad.check_event(Gamepad::A_PRESSED) == true){ + return 0; + } + pad.tone(698.0,0.25); //2 + wait(0.25); + if(pad.check_event(Gamepad::A_PRESSED) == true){ + return 0; + } + pad.tone(659.0,0.1875); //gap + wait(0.1875); + if(pad.check_event(Gamepad::A_PRESSED) == true){ + return 0; + } + pad.tone(698.0,0.0625); //1. + wait(0.0625); + if(pad.check_event(Gamepad::A_PRESSED) == true){ + return 0; + } + pad.tone(740.0,0.25); //2. wait(0.25); - pad.tone(1047.0,0.125); //H1_ + if(pad.check_event(Gamepad::A_PRESSED) == true){ + return 0; + } + pad.tone(0.0,0.25); //3. + wait(0.25); + if(pad.check_event(Gamepad::A_PRESSED) == true){ + return 0; + } + pad.tone(1047.0,0.25); //1. + wait(0.25); + if(pad.check_event(Gamepad::A_PRESSED) == true){ + return 0; + } + pad.tone(988.0,0.0833); //5 3/4 + wait(0.0833); + if(pad.check_event(Gamepad::A_PRESSED) == true){ + return 0; + } + pad.tone(988.0,0.0833); //3. + wait(0.0833); + if(pad.check_event(Gamepad::A_PRESSED) == true){ + return 0; + } + pad.tone(880.0,0.0833); //2 + wait(0.0833); + if(pad.check_event(Gamepad::A_PRESSED) == true){ + return 0; + } + pad.tone(831.0,0.25); //5 + wait(0.25); + if(pad.check_event(Gamepad::A_PRESSED) == true){ + return 0; + } + pad.tone(0.0,0.25); //2 + wait(0.25); + if(pad.check_event(Gamepad::A_PRESSED) == true){ + return 0; + } + pad.tone(0.0,0.25); //1. + wait(0.25); + if(pad.check_event(Gamepad::A_PRESSED) == true){ + return 0; + } + pad.tone(1047.0,0.125); //l6. wait(0.125); - pad.tone(880.0,0.125); //6_ + if(pad.check_event(Gamepad::A_PRESSED) == true){ + return 0; + } + pad.tone(1175.0,0.125); //l6 + wait(0.125); + if(pad.check_event(Gamepad::A_PRESSED) == true){ + return 0; + } + pad.tone(1319.0,0.25); //l7. + wait(0.25); + if(pad.check_event(Gamepad::A_PRESSED) == true){ + return 0; + } + pad.tone(1047.0,0.125); //1. + wait(0.125); + if(pad.check_event(Gamepad::A_PRESSED) == true){ + return 0; + } + pad.tone(880.0,0.125); //l5 + //////////////////////////////////////////////////// wait(0.125); pad.tone(880.0,0.25); //6 wait(0.25); pad.tone(1175.0,0.25); //H2 wait(0.25); + if(pad.check_event(Gamepad::A_PRESSED) == true){ + return 0; + } pad.tone(988.0,0.25); //7 wait(0.25); pad.tone(784.0,0.125); //5_ wait(0.125); pad.tone(659.0,0.125); //3_ wait(0.125); + if(pad.check_event(Gamepad::A_PRESSED) == true){ + return 0; + } pad.tone(659.0,0.25); //3 wait(0.25); pad.tone(988.0,0.25); //7 wait(0.25); + if(pad.check_event(Gamepad::A_PRESSED) == true){ + return 0; + } pad.tone(880.0,0.25); //6 wait(0.25); pad.tone(784.0,0.125); //5_ wait(0.125); + if(pad.check_event(Gamepad::A_PRESSED) == true){ + return 0; + } pad.tone(523.0,0.125); //1_ wait(0.125); pad.tone(523.0,0.25); //1 wait(0.25); + if(pad.check_event(Gamepad::A_PRESSED) == true){ + return 0; + } pad.tone(784.0,0.25); //5 wait(0.25); pad.tone(659.0,0.25); //3 wait(0.25); + if(pad.check_event(Gamepad::A_PRESSED) == true){ + return 0; + } pad.tone(0.0,0.25); //gap wait(0.25); pad.tone(0.0,0.25); //gap wait(0.25); + if(pad.check_event(Gamepad::A_PRESSED) == true){ + return 0; + } pad.tone(587.0,0.125); //2_ wait(0.125); pad.tone(659.0,0.125); //3_ wait(0.125); - pad.tone(698.0,0.25); //4 - wait(0.25); - pad.tone(0.0,0.25); //gap - wait(0.25); - pad.tone(1047.0,0.25); //H1 - wait(0.25); - pad.tone(988.0,0.0833); //7_3 - wait(0.0833); - pad.tone(988.0,0.0833); //7_3 - wait(0.0833); - pad.tone(1047.0,0.0833); //H1_3 - wait(0.0833); - pad.tone(784.0,0.25); //5 - wait(0.25); - pad.tone(0.0,0.25); //gap - wait(0.25); - pad.tone(698.0,0.25); //4 - wait(0.25); - pad.tone(659.0,0.1875); //3 3/4*0.25 - wait(0.1875); - pad.tone(698.0,0.0625); //4 1/4*0.25 - wait(0.0625); - pad.tone(740.0,0.25); //4 - wait(0.25); - pad.tone(0.0,0.25); //gap - wait(0.25); - pad.tone(1047.0,0.25); //H1 - wait(0.25); - pad.tone(988.0,0.0833); //7_3 - wait(0.0833); - pad.tone(988.0,0.0833); //7_3 - wait(0.0833); - pad.tone(880.0,0.0833); //6_3 - wait(0.0833); - pad.tone(831.0,0.25); //5 - wait(0.25); - pad.tone(0.0,0.25); //gap - wait(0.25); - pad.tone(0.0,0.25); //gap - wait(0.25); - pad.tone(1047.0,0.125); //H1_ - wait(0.125); - pad.tone(1175.0,0.125); //H2_ - wait(0.125); - pad.tone(1319.0,0.25); //H3 - wait(0.25); - pad.tone(1047.0,0.125); //H1_ - wait(0.125); - pad.tone(880.0,0.125); //6_ - wait(0.125); - pad.tone(880.0,0.25); //6 - wait(0.25); - pad.tone(1175.0,0.25); //H2 - wait(0.25); - pad.tone(988.0,0.25); //7 - wait(0.25); - pad.tone(784.0,0.125); //5_ - wait(0.125); - pad.tone(659.0,0.125); //3_ - wait(0.125); - pad.tone(659.0,0.25); //3 - wait(0.25); - pad.tone(988.0,0.25); //7 - wait(0.25); - pad.tone(880.0,0.25); //6 - wait(0.25); - pad.tone(784.0,0.125); //5_ - wait(0.125); - pad.tone(523.0,0.125); //1_ - wait(0.125); - pad.tone(523.0,0.25); //1 - wait(0.25); - pad.tone(784.0,0.25); //5 - wait(0.25); - pad.tone(659.0,0.25); //3 - wait(0.25); - pad.tone(0.0,0.25); //gap - wait(0.25); - pad.tone(0.0,0.25); //gap - wait(0.25); - pad.tone(587.0,0.125); //2_ - wait(0.125); - pad.tone(659.0,0.125); //3_ - wait(0.125); + if(pad.check_event(Gamepad::A_PRESSED) == true){ + return 0; + } pad.tone(698.0,0.25); //4 wait(0.25); pad.tone(0.0,0.25); //gap wait(0.25); pad.tone(784.0,0.25); //5 wait(0.25); + if(pad.check_event(Gamepad::A_PRESSED) == true){ + return 0; + } pad.tone(698.0,0.08333); //4_3 wait(0.08333); pad.tone(698.0,0.08333); //4_3 wait(0.08333); pad.tone(784.0,0.08333); //5_3 wait(0.08333); + if(pad.check_event(Gamepad::A_PRESSED) == true){ + return 0; + } pad.tone(659.0,0.25); //3 wait(0.25); pad.tone(784.0,0.25); //5 wait(0.25); + if(pad.check_event(Gamepad::A_PRESSED) == true){ + return 0; + } pad.tone(1046.0,0.25); //H1 wait(0.25); pad.tone(1318.0,0.25); //H3 wait(0.25); + if(pad.check_event(Gamepad::A_PRESSED) == true){ + return 0; + } pad.tone(1175.0,0.1875); //H2 3/4 wait(0.1875); pad.tone(1175.0,0.125); //H2_ wait(0.125); + if(pad.check_event(Gamepad::A_PRESSED) == true){ + return 0; + } pad.tone(1175.0,0.125); //H2_ wait(0.125); pad.tone(1046.0,0.25); //H1 wait(0.25); pad.tone(1046.0,0.125); //H1_ wait(0.125); + if(pad.check_event(Gamepad::A_PRESSED) == true){ + return 0; + } pad.tone(1046.0,0.25); //H1 wait(0.25); pad.tone(0.0,0.25); //GAP wait(0.25); + if(pad.check_event(Gamepad::A_PRESSED) == true){ + return 0; + } pad.tone(0.0,0.25); //GAP wait(0.25); pad.tone(0.0,0.25); //GAP wait(0.25); + return 0; } -void game_music(){ - - pad.tone(659.0,0.5); //3 - wait(0.5); - pad.tone(659.0,0.25); //3_ - wait(0.25); - pad.tone(587.0,0.25); //2_ - wait(0.25); - pad.tone(523.0,0.5); //1 - wait(0.5); - pad.tone(523.0,0.25); //1_ - wait(0.25); - pad.tone(440.0,0.25); //L6_ - wait(0.25); - pad.tone(587.0,0.25); //2_ - wait(0.25); - pad.tone(659.0,0.25); //3_ - wait(0.25); - pad.tone(587.0,0.25); //2_ - wait(0.25); - pad.tone(659.0,0.25); //3_ - wait(0.25); - pad.tone(392.0,0.5); // - wait(0.5); - pad.tone(0.0,0.5); //gap - wait(0.5); - ///////////////////////////// - pad.tone(440.0,0.5);//6 - wait(0.5); - pad.tone(440.0,0.25);//L6_ - wait(0.25); - pad.tone(392.0,0.25);//L5_ - wait(0.25); - pad.tone(440.0,0.5);//6 - wait(0.5); - pad.tone(523.0,0.5);//1 - wait(0.5); - pad.tone(784.0,0.25);//5_ - wait(0.25); - pad.tone(880.0,0.25);//6_ - wait(0.25); - pad.tone(659.0,0.25);//3_ - wait(0.25); - pad.tone(784.0,0.25);//5_ - wait(0.25); - pad.tone(587.0,0.5);//2 - wait(0.5); - pad.tone(0.0,0.5);//gap - wait(0.5); - /////////////////////////// - pad.tone(659.0,0.5);//3 - wait(0.5); - pad.tone(659.0,0.25);//3_ - wait(0.25); - pad.tone(587.0,0.25);//2_ - wait(0.25); - pad.tone(659.0,0.5);//3 - wait(0.5); - pad.tone(784.0,0.5);//5 - wait(0.5); - pad.tone(880.0,0.25);//6_ - wait(0.25); - pad.tone(880.0,0.25);//6_ - wait(0.25); - pad.tone(880.0,0.25);//6_ - wait(0.25); - pad.tone(1047.0,0.25);//H1_ - wait(0.25); - pad.tone(880.0,0.5);//6 - wait(0.5); - pad.tone(784.0,0.25);//5_ - wait(0.25); - pad.tone(659.0,0.25);//3_ - wait(0.25); - ///////////////////////////////// - pad.tone(587.0,0.5);//2 - wait(0.5); - pad.tone(587.0,0.25);//2_ - wait(0.25); - pad.tone(659.0,0.25);//3_ - wait(0.25); - pad.tone(784.0,0.5);//5 - wait(0.5); - pad.tone(392.0,0.5);//L5 - wait(0.5); - pad.tone(587.0,0.25);//2_ - wait(0.25); - pad.tone(659.0,0.25);//3_ - wait(0.25); - pad.tone(587.0,0.25);//2_ - wait(0.25); - pad.tone(659.0,0.25);//3_ - wait(0.25); - pad.tone(523.0,0.5);//1 - wait(0.5); - pad.tone(0.0,0.5);//gap - wait(0.5); - } void start_game(){ lcd.printString(" LI Saiwen",0,3); - lcd.printString(" Press A",0,5); + lcd.printString("Press twice A",0,5); lcd.refresh(); - lcd.drawSprite(60,5,11,48,(int *)SNAKY); + lcd.drawSprite(60,5,15,48,(int *)SNAKY); lcd.refresh(); wait(0.2); - lcd.drawSprite(60,5,11,48,(int *)_SNAKY); + lcd.drawSprite(60,5,15,48,(int *)_SNAKY); lcd.refresh(); - lcd.drawSprite(55,5,11,48,(int *)SNAKY); + lcd.drawSprite(55,5,15,48,(int *)SNAKY); lcd.refresh(); wait(0.2); - lcd.drawSprite(55,5,11,48,(int *)_SNAKY); + lcd.drawSprite(55,5,15,48,(int *)_SNAKY); lcd.refresh(); - lcd.drawSprite(50,5,11,48,(int *)SNAKY); + lcd.drawSprite(50,5,15,48,(int *)SNAKY); lcd.refresh(); wait(0.2); - lcd.drawSprite(50,5,11,48,(int *)_SNAKY); + lcd.drawSprite(50,5,15,48,(int *)_SNAKY); lcd.refresh(); - lcd.drawSprite(45,5,11,48,(int *)SNAKY); + lcd.drawSprite(45,5,15,48,(int *)SNAKY); lcd.refresh(); wait(0.2); - lcd.drawSprite(45,5,11,48,(int *)_SNAKY); + lcd.drawSprite(45,5,15,48,(int *)_SNAKY); lcd.refresh(); - lcd.drawSprite(40,5,11,48,(int *)SNAKY); + lcd.drawSprite(40,5,15,48,(int *)SNAKY); lcd.refresh(); wait(0.2); - lcd.drawSprite(40,5,11,48,(int *)_SNAKY); + lcd.drawSprite(40,5,15,48,(int *)_SNAKY); lcd.refresh(); - lcd.drawSprite(35,5,11,48,(int *)SNAKY); + lcd.drawSprite(35,5,15,48,(int *)SNAKY); lcd.refresh(); wait(0.2); - lcd.drawSprite(35,5,11,48,(int *)_SNAKY); + lcd.drawSprite(35,5,15,48,(int *)_SNAKY); lcd.refresh(); - lcd.drawSprite(30,5,11,48,(int *)SNAKY); + lcd.drawSprite(30,5,15,48,(int *)SNAKY); lcd.refresh(); wait(0.2); - lcd.drawSprite(30,5,11,48,(int *)_SNAKY); + lcd.drawSprite(30,5,15,48,(int *)_SNAKY); lcd.refresh(); - lcd.drawSprite(25,5,11,48,(int *)SNAKY); + lcd.drawSprite(25,5,15,48,(int *)SNAKY); lcd.refresh(); wait(0.2); - lcd.drawSprite(25,5,11,48,(int *)_SNAKY); + lcd.drawSprite(25,5,15,48,(int *)_SNAKY); - lcd.drawSprite(20,5,11,48,(int *)SNAKY); + lcd.drawSprite(20,5,15,48,(int *)SNAKY); lcd.refresh(); + while ( pad.check_event(Gamepad::A_PRESSED) == false) { + game_music_2(); pad.leds_on(); wait(0.1); pad.leds_off(); @@ -441,6 +542,7 @@ lcd.printString(" Normal <",0,2); lcd.printString(" Difficult",0,3); lcd.printString(" Hell",0,4); + lcd.printString(" Press back ",0,5); lcd.refresh(); while(IsCheck == false){ d = pad.get_direction(); @@ -451,6 +553,7 @@ lcd.printString(" Normal <",0,2); lcd.printString(" Difficult",0,3); lcd.printString(" Hell",0,4); + lcd.printString(" Press back ",0,5); c = 1; lcd.refresh(); } @@ -461,6 +564,7 @@ lcd.printString(" Normal",0,2); lcd.printString(" Difficult <",0,3); lcd.printString(" Hell",0,4); + lcd.printString(" Press back ",0,5); c = 2; lcd.refresh(); } @@ -471,6 +575,7 @@ lcd.printString(" Normal",0,2); lcd.printString(" Difficult <",0,3); lcd.printString(" Hell",0,4); + lcd.printString(" Press back ",0,5); c = 1; lcd.refresh(); } @@ -481,6 +586,7 @@ lcd.printString(" Normal",0,2); lcd.printString(" Difficult",0,3); lcd.printString(" Hell <",0,4); + lcd.printString(" Press back ",0,5); c = 3; lcd.refresh(); } @@ -491,6 +597,7 @@ lcd.printString(" Normal",0,2); lcd.printString(" Difficult",0,3); lcd.printString(" Hell <",0,4); + lcd.printString(" Press back ",0,5); c = 3; lcd.refresh(); } @@ -501,6 +608,7 @@ lcd.printString(" Normal",0,2); lcd.printString(" Difficult <",0,3); lcd.printString(" Hell",0,4); + lcd.printString(" Press back ",0,5); c = 2; lcd.refresh(); } @@ -571,9 +679,9 @@ if(q == 2 && pad.check_event(Gamepad::A_PRESSED) == true) { lcd.clear(); sprintf(_Buffer,"%2d",snake.Highest_score); - lcd.printString(_Buffer,24,3); + lcd.printString(_Buffer,34,3); lcd.printString("Highest score",0,1); - lcd.printString(" Press Back",0,4); + lcd.printString(" Press Back",0,5); lcd.refresh(); while(pad.check_event(Gamepad::BACK_PRESSED) == false){