1

Dependencies:   mbed Gamepad N5110

Committer:
1012754868
Date:
Sun May 05 12:10:48 2019 +0000
Revision:
7:cafa0b96e8d3
Parent:
3:7b28047013d2
Fix some bug

Who changed what in which revision?

UserRevisionLine numberNew contents of line
1012754868 0:5fcd72a90b20 1 /*
1012754868 3:7b28047013d2 2 ELEC2645 Embedded Systems Project
1012754868 3:7b28047013d2 3 School of Electronic & Electrical Engineering
1012754868 3:7b28047013d2 4 University of Leeds
1012754868 3:7b28047013d2 5 Name: Li Saiwen
1012754868 3:7b28047013d2 6 Username: Li Saiwen
1012754868 3:7b28047013d2 7 Student ID Number: LEEDS ID: 201089052 SWJTU ID:2016110325
1012754868 3:7b28047013d2 8 Date:
1012754868 0:5fcd72a90b20 9 */
1012754868 0:5fcd72a90b20 10 #include "mbed.h"
1012754868 0:5fcd72a90b20 11 #include "N5110.h"
1012754868 0:5fcd72a90b20 12 #include "Gamepad.h"
1012754868 0:5fcd72a90b20 13
1012754868 0:5fcd72a90b20 14 #include "Snake.h"
1012754868 0:5fcd72a90b20 15
1012754868 7:cafa0b96e8d3 16
1012754868 0:5fcd72a90b20 17 struct UserInput {
1012754868 0:5fcd72a90b20 18 Direction d;
1012754868 0:5fcd72a90b20 19
1012754868 0:5fcd72a90b20 20 };
1012754868 0:5fcd72a90b20 21
1012754868 0:5fcd72a90b20 22
1012754868 7:cafa0b96e8d3 23 N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
1012754868 0:5fcd72a90b20 24 Gamepad pad;
1012754868 0:5fcd72a90b20 25 Snake snake;
1012754868 0:5fcd72a90b20 26 Direction d;
1012754868 2:1234b0a1a51d 27 int SNAKY[15][48] = {
1012754868 2:1234b0a1a51d 28 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,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},
1012754868 2:1234b0a1a51d 29 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
1012754868 2:1234b0a1a51d 30 {0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
1012754868 2:1234b0a1a51d 31 {0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,1,1,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
1012754868 2:1234b0a1a51d 32 {0,0,0,0,0,1,1,1,0,0,0,1,0,1,0,0,1,1,0,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},
1012754868 2:1234b0a1a51d 33 {0,0,0,0,0,1,0,1,0,0,0,1,0,0,1,0,0,0,1,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},
1012754868 2:1234b0a1a51d 34 {1,0,1,1,0,1,0,1,0,0,0,0,1,0,0,1,1,1,0,0,0,1,1,0,0,0,0,0,0,0,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0},
1012754868 2:1234b0a1a51d 35 {0,0,0,1,0,1,0,1,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,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0},
1012754868 2:1234b0a1a51d 36 {0,0,0,1,1,1,0,1,0,0,0,0,0,1,0,0,0,0,0,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},
1012754868 2:1234b0a1a51d 37 {0,0,0,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0,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,0},
1012754868 2:1234b0a1a51d 38 {0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,1,0,1,0,0,0,0,0,0,0,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
1012754868 2:1234b0a1a51d 39 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,1,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
1012754868 2:1234b0a1a51d 40 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,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},
1012754868 2:1234b0a1a51d 41 {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},
1012754868 0:5fcd72a90b20 42 {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}
1012754868 0:5fcd72a90b20 43 };
1012754868 0:5fcd72a90b20 44
1012754868 2:1234b0a1a51d 45 int _SNAKY[15][48] = {
1012754868 2:1234b0a1a51d 46 {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},
1012754868 2:1234b0a1a51d 47 {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},
1012754868 2:1234b0a1a51d 48 {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},
1012754868 2:1234b0a1a51d 49 {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},
1012754868 0:5fcd72a90b20 50 {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},
1012754868 0:5fcd72a90b20 51 {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},
1012754868 0:5fcd72a90b20 52 {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},
1012754868 0:5fcd72a90b20 53 {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},
1012754868 0:5fcd72a90b20 54 {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},
1012754868 0:5fcd72a90b20 55 {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},
1012754868 0:5fcd72a90b20 56 {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},
1012754868 0:5fcd72a90b20 57 {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},
1012754868 0:5fcd72a90b20 58 {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},
1012754868 0:5fcd72a90b20 59 {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},
1012754868 0:5fcd72a90b20 60 {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}
1012754868 0:5fcd72a90b20 61 };
1012754868 0:5fcd72a90b20 62
1012754868 0:5fcd72a90b20 63 char _Buffer[200];
1012754868 7:cafa0b96e8d3 64
1012754868 0:5fcd72a90b20 65 void start_game();
1012754868 0:5fcd72a90b20 66 void game_setting();
1012754868 2:1234b0a1a51d 67 int game_music_2();
1012754868 0:5fcd72a90b20 68
1012754868 0:5fcd72a90b20 69
1012754868 0:5fcd72a90b20 70 int main()
1012754868 2:1234b0a1a51d 71 { snake.Highest_score = 0;
1012754868 2:1234b0a1a51d 72 while(1){
1012754868 2:1234b0a1a51d 73 int _Flag = 1;
1012754868 7:cafa0b96e8d3 74 lcd.init();
1012754868 2:1234b0a1a51d 75 pad.init();
1012754868 2:1234b0a1a51d 76 start_game();
1012754868 2:1234b0a1a51d 77 game_setting();
1012754868 2:1234b0a1a51d 78 snake.init(25,25,5,3);
1012754868 2:1234b0a1a51d 79
1012754868 2:1234b0a1a51d 80 while (_Flag) {
1012754868 2:1234b0a1a51d 81 snake.drawsnake(lcd,pad);
1012754868 0:5fcd72a90b20 82 snake.snakemov(pad);
1012754868 2:1234b0a1a51d 83 if(snake.live <= 0) {
1012754868 2:1234b0a1a51d 84 _Flag = 0;
1012754868 2:1234b0a1a51d 85 }
1012754868 2:1234b0a1a51d 86 }
1012754868 2:1234b0a1a51d 87 }
1012754868 0:5fcd72a90b20 88 }
1012754868 7:cafa0b96e8d3 89
1012754868 2:1234b0a1a51d 90 int game_music_2(){
1012754868 2:1234b0a1a51d 91 pad.tone(1047.0,0.125); //gap
1012754868 2:1234b0a1a51d 92 wait(0.125);
1012754868 2:1234b0a1a51d 93 if(pad.check_event(Gamepad::A_PRESSED) == true){
1012754868 2:1234b0a1a51d 94 return 0;
1012754868 2:1234b0a1a51d 95 }
1012754868 2:1234b0a1a51d 96 pad.tone(1175.0,0.125); //1_
1012754868 2:1234b0a1a51d 97 wait(0.125);
1012754868 2:1234b0a1a51d 98 if(pad.check_event(Gamepad::A_PRESSED) == true){
1012754868 2:1234b0a1a51d 99 return 0;
1012754868 2:1234b0a1a51d 100 }
1012754868 2:1234b0a1a51d 101 pad.tone(1319.0,0.25); //2_
1012754868 2:1234b0a1a51d 102 wait(0.25);
1012754868 2:1234b0a1a51d 103 if(pad.check_event(Gamepad::A_PRESSED) == true){
1012754868 2:1234b0a1a51d 104 return 0;
1012754868 2:1234b0a1a51d 105 }
1012754868 2:1234b0a1a51d 106 pad.tone(1047.0,0.125); //3_
1012754868 2:1234b0a1a51d 107 wait(0.125);
1012754868 2:1234b0a1a51d 108 if(pad.check_event(Gamepad::A_PRESSED) == true){
1012754868 2:1234b0a1a51d 109 return 0;
1012754868 2:1234b0a1a51d 110 }
1012754868 2:1234b0a1a51d 111 pad.tone(880.0,0.125); //1_
1012754868 2:1234b0a1a51d 112 wait(0.125);
1012754868 2:1234b0a1a51d 113 if(pad.check_event(Gamepad::A_PRESSED) == true){
1012754868 2:1234b0a1a51d 114 return 0;
1012754868 2:1234b0a1a51d 115 }
1012754868 2:1234b0a1a51d 116 pad.tone(880.0,0.25); //5 3/4
1012754868 2:1234b0a1a51d 117 wait(0.25);
1012754868 2:1234b0a1a51d 118 if(pad.check_event(Gamepad::A_PRESSED) == true){
1012754868 2:1234b0a1a51d 119 return 0;
1012754868 2:1234b0a1a51d 120 }
1012754868 2:1234b0a1a51d 121 pad.tone(1175.0,0.25); //3_
1012754868 2:1234b0a1a51d 122 wait(0.25);
1012754868 2:1234b0a1a51d 123 if(pad.check_event(Gamepad::A_PRESSED) == true){
1012754868 2:1234b0a1a51d 124 return 0;
1012754868 2:1234b0a1a51d 125 }
1012754868 2:1234b0a1a51d 126 pad.tone(988.0,0.25); //2
1012754868 2:1234b0a1a51d 127 wait(0.25);
1012754868 2:1234b0a1a51d 128 if(pad.check_event(Gamepad::A_PRESSED) == true){
1012754868 2:1234b0a1a51d 129 return 0;
1012754868 2:1234b0a1a51d 130 }
1012754868 2:1234b0a1a51d 131 pad.tone(784.0,0.125); //5
1012754868 2:1234b0a1a51d 132 wait(0.125);
1012754868 2:1234b0a1a51d 133 if(pad.check_event(Gamepad::A_PRESSED) == true){
1012754868 2:1234b0a1a51d 134 return 0;
1012754868 2:1234b0a1a51d 135 }
1012754868 2:1234b0a1a51d 136 pad.tone(659.0,0.125); //2
1012754868 1:db2a69ca4929 137 wait(0.125);
1012754868 2:1234b0a1a51d 138 if(pad.check_event(Gamepad::A_PRESSED) == true){
1012754868 2:1234b0a1a51d 139 return 0;
1012754868 2:1234b0a1a51d 140 }
1012754868 2:1234b0a1a51d 141 pad.tone(659.0,0.25); //1.
1012754868 2:1234b0a1a51d 142 wait(0.25);
1012754868 2:1234b0a1a51d 143 if(pad.check_event(Gamepad::A_PRESSED) == true){
1012754868 2:1234b0a1a51d 144 return 0;
1012754868 2:1234b0a1a51d 145 }
1012754868 2:1234b0a1a51d 146 pad.tone(988.0,0.25); //l6.
1012754868 2:1234b0a1a51d 147 wait(0.25);
1012754868 2:1234b0a1a51d 148 if(pad.check_event(Gamepad::A_PRESSED) == true){
1012754868 2:1234b0a1a51d 149 return 0;
1012754868 2:1234b0a1a51d 150 }
1012754868 2:1234b0a1a51d 151 pad.tone(880.0,0.25); //3 3/4
1012754868 2:1234b0a1a51d 152 wait(0.25);
1012754868 2:1234b0a1a51d 153 if(pad.check_event(Gamepad::A_PRESSED) == true){
1012754868 2:1234b0a1a51d 154 return 0;
1012754868 2:1234b0a1a51d 155 }
1012754868 2:1234b0a1a51d 156 pad.tone(784.0,0.125); //1.
1012754868 2:1234b0a1a51d 157 wait(0.125);
1012754868 2:1234b0a1a51d 158 if(pad.check_event(Gamepad::A_PRESSED) == true){
1012754868 2:1234b0a1a51d 159 return 0;
1012754868 2:1234b0a1a51d 160 }
1012754868 2:1234b0a1a51d 161 pad.tone(523.0,0.125); //l7
1012754868 2:1234b0a1a51d 162 wait(0.125);
1012754868 2:1234b0a1a51d 163 if(pad.check_event(Gamepad::A_PRESSED) == true){
1012754868 2:1234b0a1a51d 164 return 0;
1012754868 2:1234b0a1a51d 165 }
1012754868 2:1234b0a1a51d 166 pad.tone(523.0,0.25); //gap
1012754868 2:1234b0a1a51d 167 wait(0.25);
1012754868 2:1234b0a1a51d 168 if(pad.check_event(Gamepad::A_PRESSED) == true){
1012754868 2:1234b0a1a51d 169 return 0;
1012754868 2:1234b0a1a51d 170 }
1012754868 2:1234b0a1a51d 171 pad.tone(784.0,0.25); //l7
1012754868 2:1234b0a1a51d 172 wait(0.25);
1012754868 2:1234b0a1a51d 173 if(pad.check_event(Gamepad::A_PRESSED) == true){
1012754868 2:1234b0a1a51d 174 return 0;
1012754868 2:1234b0a1a51d 175 }
1012754868 2:1234b0a1a51d 176 pad.tone(659.0,0.25); //l6
1012754868 2:1234b0a1a51d 177 wait(0.25);
1012754868 2:1234b0a1a51d 178 if(pad.check_event(Gamepad::A_PRESSED) == true){
1012754868 2:1234b0a1a51d 179 return 0;
1012754868 2:1234b0a1a51d 180 }
1012754868 2:1234b0a1a51d 181 pad.tone(0.0,0.25); //l7
1012754868 2:1234b0a1a51d 182 wait(0.25);
1012754868 2:1234b0a1a51d 183 if(pad.check_event(Gamepad::A_PRESSED) == true){
1012754868 2:1234b0a1a51d 184 return 0;
1012754868 2:1234b0a1a51d 185 }
1012754868 2:1234b0a1a51d 186 pad.tone(0.0,0.25); //1.
1012754868 2:1234b0a1a51d 187 wait(0.25);
1012754868 2:1234b0a1a51d 188 if(pad.check_event(Gamepad::A_PRESSED) == true){
1012754868 2:1234b0a1a51d 189 return 0;
1012754868 2:1234b0a1a51d 190 }
1012754868 2:1234b0a1a51d 191 pad.tone(587.0,0.125); //2.
1012754868 2:1234b0a1a51d 192 wait(0.125);
1012754868 2:1234b0a1a51d 193 if(pad.check_event(Gamepad::A_PRESSED) == true){
1012754868 2:1234b0a1a51d 194 return 0;
1012754868 2:1234b0a1a51d 195 }
1012754868 2:1234b0a1a51d 196 pad.tone(659.0,0.125); //l5
1012754868 1:db2a69ca4929 197 wait(0.125);
1012754868 2:1234b0a1a51d 198 if(pad.check_event(Gamepad::A_PRESSED) == true){
1012754868 2:1234b0a1a51d 199 return 0;
1012754868 2:1234b0a1a51d 200 }
1012754868 2:1234b0a1a51d 201 pad.tone(698.0,0.25); //1
1012754868 2:1234b0a1a51d 202 wait(0.25);
1012754868 2:1234b0a1a51d 203 if(pad.check_event(Gamepad::A_PRESSED) == true){
1012754868 2:1234b0a1a51d 204 return 0;
1012754868 2:1234b0a1a51d 205 }
1012754868 2:1234b0a1a51d 206 pad.tone(0.0,0.25); //2.
1012754868 2:1234b0a1a51d 207 wait(0.25);
1012754868 2:1234b0a1a51d 208 if(pad.check_event(Gamepad::A_PRESSED) == true){
1012754868 2:1234b0a1a51d 209 return 0;
1012754868 2:1234b0a1a51d 210 }
1012754868 2:1234b0a1a51d 211 pad.tone(1047.0,0.25); //3.
1012754868 2:1234b0a1a51d 212 wait(0.25);
1012754868 2:1234b0a1a51d 213 if(pad.check_event(Gamepad::A_PRESSED) == true){
1012754868 2:1234b0a1a51d 214 return 0;
1012754868 2:1234b0a1a51d 215 }
1012754868 2:1234b0a1a51d 216 pad.tone(988.0,0.0833); //4
1012754868 2:1234b0a1a51d 217 wait(0.0833);
1012754868 2:1234b0a1a51d 218 if(pad.check_event(Gamepad::A_PRESSED) == true){
1012754868 2:1234b0a1a51d 219 return 0;
1012754868 2:1234b0a1a51d 220 }
1012754868 2:1234b0a1a51d 221 pad.tone(988.0,0.0833); //4.
1012754868 2:1234b0a1a51d 222 wait(0.0833);
1012754868 2:1234b0a1a51d 223 if(pad.check_event(Gamepad::A_PRESSED) == true){
1012754868 2:1234b0a1a51d 224 return 0;
1012754868 2:1234b0a1a51d 225 }
1012754868 2:1234b0a1a51d 226 pad.tone(1047.0,0.0833); //3.
1012754868 2:1234b0a1a51d 227 wait(0.0833);
1012754868 2:1234b0a1a51d 228 if(pad.check_event(Gamepad::A_PRESSED) == true){
1012754868 2:1234b0a1a51d 229 return 0;
1012754868 2:1234b0a1a51d 230 }
1012754868 2:1234b0a1a51d 231 pad.tone(784.0,0.25); //2.
1012754868 2:1234b0a1a51d 232 wait(0.25);
1012754868 2:1234b0a1a51d 233 if(pad.check_event(Gamepad::A_PRESSED) == true){
1012754868 2:1234b0a1a51d 234 return 0;
1012754868 2:1234b0a1a51d 235 }
1012754868 2:1234b0a1a51d 236 pad.tone(0.0,0.25); //1.
1012754868 2:1234b0a1a51d 237 wait(0.25);
1012754868 2:1234b0a1a51d 238 if(pad.check_event(Gamepad::A_PRESSED) == true){
1012754868 2:1234b0a1a51d 239 return 0;
1012754868 2:1234b0a1a51d 240 }
1012754868 2:1234b0a1a51d 241 pad.tone(698.0,0.25); //2
1012754868 2:1234b0a1a51d 242 wait(0.25);
1012754868 2:1234b0a1a51d 243 if(pad.check_event(Gamepad::A_PRESSED) == true){
1012754868 2:1234b0a1a51d 244 return 0;
1012754868 2:1234b0a1a51d 245 }
1012754868 2:1234b0a1a51d 246 pad.tone(659.0,0.1875); //gap
1012754868 2:1234b0a1a51d 247 wait(0.1875);
1012754868 2:1234b0a1a51d 248 if(pad.check_event(Gamepad::A_PRESSED) == true){
1012754868 2:1234b0a1a51d 249 return 0;
1012754868 2:1234b0a1a51d 250 }
1012754868 2:1234b0a1a51d 251 pad.tone(698.0,0.0625); //1.
1012754868 2:1234b0a1a51d 252 wait(0.0625);
1012754868 2:1234b0a1a51d 253 if(pad.check_event(Gamepad::A_PRESSED) == true){
1012754868 2:1234b0a1a51d 254 return 0;
1012754868 2:1234b0a1a51d 255 }
1012754868 2:1234b0a1a51d 256 pad.tone(740.0,0.25); //2.
1012754868 1:db2a69ca4929 257 wait(0.25);
1012754868 2:1234b0a1a51d 258 if(pad.check_event(Gamepad::A_PRESSED) == true){
1012754868 2:1234b0a1a51d 259 return 0;
1012754868 2:1234b0a1a51d 260 }
1012754868 2:1234b0a1a51d 261 pad.tone(0.0,0.25); //3.
1012754868 2:1234b0a1a51d 262 wait(0.25);
1012754868 2:1234b0a1a51d 263 if(pad.check_event(Gamepad::A_PRESSED) == true){
1012754868 2:1234b0a1a51d 264 return 0;
1012754868 2:1234b0a1a51d 265 }
1012754868 2:1234b0a1a51d 266 pad.tone(1047.0,0.25); //1.
1012754868 2:1234b0a1a51d 267 wait(0.25);
1012754868 2:1234b0a1a51d 268 if(pad.check_event(Gamepad::A_PRESSED) == true){
1012754868 2:1234b0a1a51d 269 return 0;
1012754868 2:1234b0a1a51d 270 }
1012754868 2:1234b0a1a51d 271 pad.tone(988.0,0.0833); //5 3/4
1012754868 2:1234b0a1a51d 272 wait(0.0833);
1012754868 2:1234b0a1a51d 273 if(pad.check_event(Gamepad::A_PRESSED) == true){
1012754868 2:1234b0a1a51d 274 return 0;
1012754868 2:1234b0a1a51d 275 }
1012754868 2:1234b0a1a51d 276 pad.tone(988.0,0.0833); //3.
1012754868 2:1234b0a1a51d 277 wait(0.0833);
1012754868 2:1234b0a1a51d 278 if(pad.check_event(Gamepad::A_PRESSED) == true){
1012754868 2:1234b0a1a51d 279 return 0;
1012754868 2:1234b0a1a51d 280 }
1012754868 2:1234b0a1a51d 281 pad.tone(880.0,0.0833); //2
1012754868 2:1234b0a1a51d 282 wait(0.0833);
1012754868 2:1234b0a1a51d 283 if(pad.check_event(Gamepad::A_PRESSED) == true){
1012754868 2:1234b0a1a51d 284 return 0;
1012754868 2:1234b0a1a51d 285 }
1012754868 2:1234b0a1a51d 286 pad.tone(831.0,0.25); //5
1012754868 2:1234b0a1a51d 287 wait(0.25);
1012754868 2:1234b0a1a51d 288 if(pad.check_event(Gamepad::A_PRESSED) == true){
1012754868 2:1234b0a1a51d 289 return 0;
1012754868 2:1234b0a1a51d 290 }
1012754868 2:1234b0a1a51d 291 pad.tone(0.0,0.25); //2
1012754868 2:1234b0a1a51d 292 wait(0.25);
1012754868 2:1234b0a1a51d 293 if(pad.check_event(Gamepad::A_PRESSED) == true){
1012754868 2:1234b0a1a51d 294 return 0;
1012754868 2:1234b0a1a51d 295 }
1012754868 2:1234b0a1a51d 296 pad.tone(0.0,0.25); //1.
1012754868 2:1234b0a1a51d 297 wait(0.25);
1012754868 2:1234b0a1a51d 298 if(pad.check_event(Gamepad::A_PRESSED) == true){
1012754868 2:1234b0a1a51d 299 return 0;
1012754868 2:1234b0a1a51d 300 }
1012754868 2:1234b0a1a51d 301 pad.tone(1047.0,0.125); //l6.
1012754868 1:db2a69ca4929 302 wait(0.125);
1012754868 2:1234b0a1a51d 303 if(pad.check_event(Gamepad::A_PRESSED) == true){
1012754868 2:1234b0a1a51d 304 return 0;
1012754868 2:1234b0a1a51d 305 }
1012754868 2:1234b0a1a51d 306 pad.tone(1175.0,0.125); //l6
1012754868 2:1234b0a1a51d 307 wait(0.125);
1012754868 2:1234b0a1a51d 308 if(pad.check_event(Gamepad::A_PRESSED) == true){
1012754868 2:1234b0a1a51d 309 return 0;
1012754868 2:1234b0a1a51d 310 }
1012754868 2:1234b0a1a51d 311 pad.tone(1319.0,0.25); //l7.
1012754868 2:1234b0a1a51d 312 wait(0.25);
1012754868 2:1234b0a1a51d 313 if(pad.check_event(Gamepad::A_PRESSED) == true){
1012754868 2:1234b0a1a51d 314 return 0;
1012754868 2:1234b0a1a51d 315 }
1012754868 2:1234b0a1a51d 316 pad.tone(1047.0,0.125); //1.
1012754868 2:1234b0a1a51d 317 wait(0.125);
1012754868 2:1234b0a1a51d 318 if(pad.check_event(Gamepad::A_PRESSED) == true){
1012754868 2:1234b0a1a51d 319 return 0;
1012754868 2:1234b0a1a51d 320 }
1012754868 2:1234b0a1a51d 321 pad.tone(880.0,0.125); //l5
1012754868 2:1234b0a1a51d 322 ////////////////////////////////////////////////////
1012754868 1:db2a69ca4929 323 wait(0.125);
1012754868 1:db2a69ca4929 324 pad.tone(880.0,0.25); //6
1012754868 1:db2a69ca4929 325 wait(0.25);
1012754868 1:db2a69ca4929 326 pad.tone(1175.0,0.25); //H2
1012754868 1:db2a69ca4929 327 wait(0.25);
1012754868 2:1234b0a1a51d 328 if(pad.check_event(Gamepad::A_PRESSED) == true){
1012754868 2:1234b0a1a51d 329 return 0;
1012754868 2:1234b0a1a51d 330 }
1012754868 1:db2a69ca4929 331 pad.tone(988.0,0.25); //7
1012754868 1:db2a69ca4929 332 wait(0.25);
1012754868 1:db2a69ca4929 333 pad.tone(784.0,0.125); //5_
1012754868 1:db2a69ca4929 334 wait(0.125);
1012754868 1:db2a69ca4929 335 pad.tone(659.0,0.125); //3_
1012754868 1:db2a69ca4929 336 wait(0.125);
1012754868 2:1234b0a1a51d 337 if(pad.check_event(Gamepad::A_PRESSED) == true){
1012754868 2:1234b0a1a51d 338 return 0;
1012754868 2:1234b0a1a51d 339 }
1012754868 1:db2a69ca4929 340 pad.tone(659.0,0.25); //3
1012754868 1:db2a69ca4929 341 wait(0.25);
1012754868 1:db2a69ca4929 342 pad.tone(988.0,0.25); //7
1012754868 1:db2a69ca4929 343 wait(0.25);
1012754868 2:1234b0a1a51d 344 if(pad.check_event(Gamepad::A_PRESSED) == true){
1012754868 2:1234b0a1a51d 345 return 0;
1012754868 2:1234b0a1a51d 346 }
1012754868 1:db2a69ca4929 347 pad.tone(880.0,0.25); //6
1012754868 1:db2a69ca4929 348 wait(0.25);
1012754868 1:db2a69ca4929 349 pad.tone(784.0,0.125); //5_
1012754868 1:db2a69ca4929 350 wait(0.125);
1012754868 2:1234b0a1a51d 351 if(pad.check_event(Gamepad::A_PRESSED) == true){
1012754868 2:1234b0a1a51d 352 return 0;
1012754868 2:1234b0a1a51d 353 }
1012754868 1:db2a69ca4929 354 pad.tone(523.0,0.125); //1_
1012754868 1:db2a69ca4929 355 wait(0.125);
1012754868 1:db2a69ca4929 356 pad.tone(523.0,0.25); //1
1012754868 1:db2a69ca4929 357 wait(0.25);
1012754868 2:1234b0a1a51d 358 if(pad.check_event(Gamepad::A_PRESSED) == true){
1012754868 2:1234b0a1a51d 359 return 0;
1012754868 2:1234b0a1a51d 360 }
1012754868 1:db2a69ca4929 361 pad.tone(784.0,0.25); //5
1012754868 1:db2a69ca4929 362 wait(0.25);
1012754868 1:db2a69ca4929 363 pad.tone(659.0,0.25); //3
1012754868 1:db2a69ca4929 364 wait(0.25);
1012754868 2:1234b0a1a51d 365 if(pad.check_event(Gamepad::A_PRESSED) == true){
1012754868 2:1234b0a1a51d 366 return 0;
1012754868 2:1234b0a1a51d 367 }
1012754868 1:db2a69ca4929 368 pad.tone(0.0,0.25); //gap
1012754868 1:db2a69ca4929 369 wait(0.25);
1012754868 1:db2a69ca4929 370 pad.tone(0.0,0.25); //gap
1012754868 1:db2a69ca4929 371 wait(0.25);
1012754868 2:1234b0a1a51d 372 if(pad.check_event(Gamepad::A_PRESSED) == true){
1012754868 2:1234b0a1a51d 373 return 0;
1012754868 2:1234b0a1a51d 374 }
1012754868 1:db2a69ca4929 375 pad.tone(587.0,0.125); //2_
1012754868 1:db2a69ca4929 376 wait(0.125);
1012754868 1:db2a69ca4929 377 pad.tone(659.0,0.125); //3_
1012754868 1:db2a69ca4929 378 wait(0.125);
1012754868 2:1234b0a1a51d 379 if(pad.check_event(Gamepad::A_PRESSED) == true){
1012754868 2:1234b0a1a51d 380 return 0;
1012754868 2:1234b0a1a51d 381 }
1012754868 1:db2a69ca4929 382 pad.tone(698.0,0.25); //4
1012754868 1:db2a69ca4929 383 wait(0.25);
1012754868 1:db2a69ca4929 384 pad.tone(0.0,0.25); //gap
1012754868 1:db2a69ca4929 385 wait(0.25);
1012754868 1:db2a69ca4929 386 pad.tone(784.0,0.25); //5
1012754868 1:db2a69ca4929 387 wait(0.25);
1012754868 2:1234b0a1a51d 388 if(pad.check_event(Gamepad::A_PRESSED) == true){
1012754868 2:1234b0a1a51d 389 return 0;
1012754868 2:1234b0a1a51d 390 }
1012754868 1:db2a69ca4929 391 pad.tone(698.0,0.08333); //4_3
1012754868 1:db2a69ca4929 392 wait(0.08333);
1012754868 1:db2a69ca4929 393 pad.tone(698.0,0.08333); //4_3
1012754868 1:db2a69ca4929 394 wait(0.08333);
1012754868 1:db2a69ca4929 395 pad.tone(784.0,0.08333); //5_3
1012754868 1:db2a69ca4929 396 wait(0.08333);
1012754868 2:1234b0a1a51d 397 if(pad.check_event(Gamepad::A_PRESSED) == true){
1012754868 2:1234b0a1a51d 398 return 0;
1012754868 2:1234b0a1a51d 399 }
1012754868 1:db2a69ca4929 400 pad.tone(659.0,0.25); //3
1012754868 1:db2a69ca4929 401 wait(0.25);
1012754868 1:db2a69ca4929 402 pad.tone(784.0,0.25); //5
1012754868 1:db2a69ca4929 403 wait(0.25);
1012754868 2:1234b0a1a51d 404 if(pad.check_event(Gamepad::A_PRESSED) == true){
1012754868 2:1234b0a1a51d 405 return 0;
1012754868 2:1234b0a1a51d 406 }
1012754868 1:db2a69ca4929 407 pad.tone(1046.0,0.25); //H1
1012754868 1:db2a69ca4929 408 wait(0.25);
1012754868 1:db2a69ca4929 409 pad.tone(1318.0,0.25); //H3
1012754868 1:db2a69ca4929 410 wait(0.25);
1012754868 2:1234b0a1a51d 411 if(pad.check_event(Gamepad::A_PRESSED) == true){
1012754868 2:1234b0a1a51d 412 return 0;
1012754868 2:1234b0a1a51d 413 }
1012754868 1:db2a69ca4929 414 pad.tone(1175.0,0.1875); //H2 3/4
1012754868 1:db2a69ca4929 415 wait(0.1875);
1012754868 1:db2a69ca4929 416 pad.tone(1175.0,0.125); //H2_
1012754868 1:db2a69ca4929 417 wait(0.125);
1012754868 2:1234b0a1a51d 418 if(pad.check_event(Gamepad::A_PRESSED) == true){
1012754868 2:1234b0a1a51d 419 return 0;
1012754868 2:1234b0a1a51d 420 }
1012754868 1:db2a69ca4929 421 pad.tone(1175.0,0.125); //H2_
1012754868 1:db2a69ca4929 422 wait(0.125);
1012754868 1:db2a69ca4929 423 pad.tone(1046.0,0.25); //H1
1012754868 1:db2a69ca4929 424 wait(0.25);
1012754868 1:db2a69ca4929 425 pad.tone(1046.0,0.125); //H1_
1012754868 1:db2a69ca4929 426 wait(0.125);
1012754868 2:1234b0a1a51d 427 if(pad.check_event(Gamepad::A_PRESSED) == true){
1012754868 2:1234b0a1a51d 428 return 0;
1012754868 2:1234b0a1a51d 429 }
1012754868 1:db2a69ca4929 430 pad.tone(1046.0,0.25); //H1
1012754868 1:db2a69ca4929 431 wait(0.25);
1012754868 1:db2a69ca4929 432 pad.tone(0.0,0.25); //GAP
1012754868 1:db2a69ca4929 433 wait(0.25);
1012754868 2:1234b0a1a51d 434 if(pad.check_event(Gamepad::A_PRESSED) == true){
1012754868 2:1234b0a1a51d 435 return 0;
1012754868 2:1234b0a1a51d 436 }
1012754868 1:db2a69ca4929 437 pad.tone(0.0,0.25); //GAP
1012754868 1:db2a69ca4929 438 wait(0.25);
1012754868 1:db2a69ca4929 439 pad.tone(0.0,0.25); //GAP
1012754868 1:db2a69ca4929 440 wait(0.25);
1012754868 2:1234b0a1a51d 441 return 0;
1012754868 1:db2a69ca4929 442 }
1012754868 1:db2a69ca4929 443
1012754868 0:5fcd72a90b20 444
1012754868 0:5fcd72a90b20 445 void start_game(){
1012754868 0:5fcd72a90b20 446 lcd.printString(" LI Saiwen",0,3);
1012754868 2:1234b0a1a51d 447 lcd.printString("Press twice A",0,5);
1012754868 0:5fcd72a90b20 448 lcd.refresh();
1012754868 0:5fcd72a90b20 449
1012754868 2:1234b0a1a51d 450 lcd.drawSprite(60,5,15,48,(int *)SNAKY);
1012754868 0:5fcd72a90b20 451 lcd.refresh();
1012754868 0:5fcd72a90b20 452 wait(0.2);
1012754868 2:1234b0a1a51d 453 lcd.drawSprite(60,5,15,48,(int *)_SNAKY);
1012754868 0:5fcd72a90b20 454 lcd.refresh();
1012754868 0:5fcd72a90b20 455
1012754868 2:1234b0a1a51d 456 lcd.drawSprite(55,5,15,48,(int *)SNAKY);
1012754868 0:5fcd72a90b20 457 lcd.refresh();
1012754868 0:5fcd72a90b20 458 wait(0.2);
1012754868 2:1234b0a1a51d 459 lcd.drawSprite(55,5,15,48,(int *)_SNAKY);
1012754868 0:5fcd72a90b20 460 lcd.refresh();
1012754868 0:5fcd72a90b20 461
1012754868 2:1234b0a1a51d 462 lcd.drawSprite(50,5,15,48,(int *)SNAKY);
1012754868 0:5fcd72a90b20 463 lcd.refresh();
1012754868 0:5fcd72a90b20 464 wait(0.2);
1012754868 2:1234b0a1a51d 465 lcd.drawSprite(50,5,15,48,(int *)_SNAKY);
1012754868 0:5fcd72a90b20 466 lcd.refresh();
1012754868 0:5fcd72a90b20 467
1012754868 2:1234b0a1a51d 468 lcd.drawSprite(45,5,15,48,(int *)SNAKY);
1012754868 0:5fcd72a90b20 469 lcd.refresh();
1012754868 0:5fcd72a90b20 470 wait(0.2);
1012754868 2:1234b0a1a51d 471 lcd.drawSprite(45,5,15,48,(int *)_SNAKY);
1012754868 0:5fcd72a90b20 472 lcd.refresh();
1012754868 0:5fcd72a90b20 473
1012754868 2:1234b0a1a51d 474 lcd.drawSprite(40,5,15,48,(int *)SNAKY);
1012754868 0:5fcd72a90b20 475 lcd.refresh();
1012754868 0:5fcd72a90b20 476 wait(0.2);
1012754868 2:1234b0a1a51d 477 lcd.drawSprite(40,5,15,48,(int *)_SNAKY);
1012754868 0:5fcd72a90b20 478 lcd.refresh();
1012754868 0:5fcd72a90b20 479
1012754868 2:1234b0a1a51d 480 lcd.drawSprite(35,5,15,48,(int *)SNAKY);
1012754868 0:5fcd72a90b20 481 lcd.refresh();
1012754868 0:5fcd72a90b20 482 wait(0.2);
1012754868 2:1234b0a1a51d 483 lcd.drawSprite(35,5,15,48,(int *)_SNAKY);
1012754868 0:5fcd72a90b20 484 lcd.refresh();
1012754868 0:5fcd72a90b20 485
1012754868 2:1234b0a1a51d 486 lcd.drawSprite(30,5,15,48,(int *)SNAKY);
1012754868 0:5fcd72a90b20 487 lcd.refresh();
1012754868 0:5fcd72a90b20 488 wait(0.2);
1012754868 2:1234b0a1a51d 489 lcd.drawSprite(30,5,15,48,(int *)_SNAKY);
1012754868 0:5fcd72a90b20 490 lcd.refresh();
1012754868 0:5fcd72a90b20 491
1012754868 2:1234b0a1a51d 492 lcd.drawSprite(25,5,15,48,(int *)SNAKY);
1012754868 0:5fcd72a90b20 493 lcd.refresh();
1012754868 0:5fcd72a90b20 494 wait(0.2);
1012754868 2:1234b0a1a51d 495 lcd.drawSprite(25,5,15,48,(int *)_SNAKY);
1012754868 0:5fcd72a90b20 496
1012754868 2:1234b0a1a51d 497 lcd.drawSprite(20,5,15,48,(int *)SNAKY);
1012754868 0:5fcd72a90b20 498 lcd.refresh();
1012754868 2:1234b0a1a51d 499
1012754868 0:5fcd72a90b20 500 while ( pad.check_event(Gamepad::A_PRESSED) == false) {
1012754868 2:1234b0a1a51d 501 game_music_2();
1012754868 0:5fcd72a90b20 502 pad.leds_on();
1012754868 0:5fcd72a90b20 503 wait(0.1);
1012754868 0:5fcd72a90b20 504 pad.leds_off();
1012754868 0:5fcd72a90b20 505 wait(0.1);
1012754868 0:5fcd72a90b20 506 }
1012754868 0:5fcd72a90b20 507 lcd.clear();
1012754868 0:5fcd72a90b20 508 }
1012754868 0:5fcd72a90b20 509
1012754868 0:5fcd72a90b20 510 void game_setting() {
1012754868 0:5fcd72a90b20 511 lcd.printString(" Menu",0,0);
1012754868 0:5fcd72a90b20 512 lcd.printString(" A to set",0,1);
1012754868 0:5fcd72a90b20 513 lcd.printString("set speed <",0,2);
1012754868 0:5fcd72a90b20 514 lcd.printString("history ",0,3);
1012754868 0:5fcd72a90b20 515 lcd.printString(" press start",0,5);
1012754868 0:5fcd72a90b20 516 lcd.refresh();
1012754868 0:5fcd72a90b20 517 int q = 1;
1012754868 0:5fcd72a90b20 518 while ( pad.check_event(Gamepad::START_PRESSED) == false) {
1012754868 0:5fcd72a90b20 519 d = pad.get_direction();
1012754868 0:5fcd72a90b20 520 if(d == N || q == 1){
1012754868 0:5fcd72a90b20 521 lcd.clear();
1012754868 0:5fcd72a90b20 522 lcd.printString(" Menu",0,0);
1012754868 0:5fcd72a90b20 523 lcd.printString(" A to set",0,1);
1012754868 0:5fcd72a90b20 524 lcd.printString("set speed <",0,2);
1012754868 0:5fcd72a90b20 525 lcd.printString("history ",0,3);
1012754868 0:5fcd72a90b20 526 lcd.printString(" press start",0,5);
1012754868 0:5fcd72a90b20 527 lcd.refresh();
1012754868 0:5fcd72a90b20 528 if(pad.check_event(Gamepad::A_PRESSED) == true) {
1012754868 0:5fcd72a90b20 529 bool IsCheck = false;
1012754868 0:5fcd72a90b20 530 int c = 1;
1012754868 0:5fcd72a90b20 531 lcd.clear();
1012754868 0:5fcd72a90b20 532 lcd.printString(" Speed set",0,0);
1012754868 0:5fcd72a90b20 533 lcd.printString(" B to set",0,1);
1012754868 0:5fcd72a90b20 534 lcd.printString(" Normal <",0,2);
1012754868 0:5fcd72a90b20 535 lcd.printString(" Difficult",0,3);
1012754868 0:5fcd72a90b20 536 lcd.printString(" Hell",0,4);
1012754868 2:1234b0a1a51d 537 lcd.printString(" Press back ",0,5);
1012754868 0:5fcd72a90b20 538 lcd.refresh();
1012754868 0:5fcd72a90b20 539 while(IsCheck == false){
1012754868 0:5fcd72a90b20 540 d = pad.get_direction();
1012754868 0:5fcd72a90b20 541 if(d == N && c == 1){
1012754868 0:5fcd72a90b20 542 lcd.clear();
1012754868 0:5fcd72a90b20 543 lcd.printString(" Speed set",0,0);
1012754868 0:5fcd72a90b20 544 lcd.printString(" B to set",0,1);
1012754868 0:5fcd72a90b20 545 lcd.printString(" Normal <",0,2);
1012754868 0:5fcd72a90b20 546 lcd.printString(" Difficult",0,3);
1012754868 0:5fcd72a90b20 547 lcd.printString(" Hell",0,4);
1012754868 2:1234b0a1a51d 548 lcd.printString(" Press back ",0,5);
1012754868 0:5fcd72a90b20 549 c = 1;
1012754868 0:5fcd72a90b20 550 lcd.refresh();
1012754868 0:5fcd72a90b20 551 }
1012754868 0:5fcd72a90b20 552 else if(d == S && c == 1 ){
1012754868 0:5fcd72a90b20 553 lcd.clear();
1012754868 0:5fcd72a90b20 554 lcd.printString(" Speed set",0,0);
1012754868 0:5fcd72a90b20 555 lcd.printString(" B to set",0,1);
1012754868 0:5fcd72a90b20 556 lcd.printString(" Normal",0,2);
1012754868 0:5fcd72a90b20 557 lcd.printString(" Difficult <",0,3);
1012754868 0:5fcd72a90b20 558 lcd.printString(" Hell",0,4);
1012754868 2:1234b0a1a51d 559 lcd.printString(" Press back ",0,5);
1012754868 0:5fcd72a90b20 560 c = 2;
1012754868 0:5fcd72a90b20 561 lcd.refresh();
1012754868 0:5fcd72a90b20 562 }
1012754868 0:5fcd72a90b20 563 else if(d == N && c == 2){
1012754868 0:5fcd72a90b20 564 lcd.clear();
1012754868 0:5fcd72a90b20 565 lcd.printString(" Speed set",0,0);
1012754868 0:5fcd72a90b20 566 lcd.printString(" B to set",0,1);
1012754868 0:5fcd72a90b20 567 lcd.printString(" Normal",0,2);
1012754868 0:5fcd72a90b20 568 lcd.printString(" Difficult <",0,3);
1012754868 0:5fcd72a90b20 569 lcd.printString(" Hell",0,4);
1012754868 2:1234b0a1a51d 570 lcd.printString(" Press back ",0,5);
1012754868 0:5fcd72a90b20 571 c = 1;
1012754868 0:5fcd72a90b20 572 lcd.refresh();
1012754868 0:5fcd72a90b20 573 }
1012754868 0:5fcd72a90b20 574 else if(d == S && c == 2){
1012754868 0:5fcd72a90b20 575 lcd.clear();
1012754868 0:5fcd72a90b20 576 lcd.printString(" Speed set",0,0);
1012754868 0:5fcd72a90b20 577 lcd.printString(" B to set",0,1);
1012754868 0:5fcd72a90b20 578 lcd.printString(" Normal",0,2);
1012754868 0:5fcd72a90b20 579 lcd.printString(" Difficult",0,3);
1012754868 0:5fcd72a90b20 580 lcd.printString(" Hell <",0,4);
1012754868 2:1234b0a1a51d 581 lcd.printString(" Press back ",0,5);
1012754868 0:5fcd72a90b20 582 c = 3;
1012754868 0:5fcd72a90b20 583 lcd.refresh();
1012754868 0:5fcd72a90b20 584 }
1012754868 0:5fcd72a90b20 585 else if(d == S && c == 3){
1012754868 0:5fcd72a90b20 586 lcd.clear();
1012754868 0:5fcd72a90b20 587 lcd.printString(" Speed set",0,0);
1012754868 0:5fcd72a90b20 588 lcd.printString(" B to set",0,1);
1012754868 0:5fcd72a90b20 589 lcd.printString(" Normal",0,2);
1012754868 0:5fcd72a90b20 590 lcd.printString(" Difficult",0,3);
1012754868 0:5fcd72a90b20 591 lcd.printString(" Hell <",0,4);
1012754868 2:1234b0a1a51d 592 lcd.printString(" Press back ",0,5);
1012754868 0:5fcd72a90b20 593 c = 3;
1012754868 0:5fcd72a90b20 594 lcd.refresh();
1012754868 0:5fcd72a90b20 595 }
1012754868 0:5fcd72a90b20 596 else if(d == N && c == 3){
1012754868 0:5fcd72a90b20 597 lcd.clear();
1012754868 0:5fcd72a90b20 598 lcd.printString(" Speed set",0,0);
1012754868 0:5fcd72a90b20 599 lcd.printString(" B to set",0,1);
1012754868 0:5fcd72a90b20 600 lcd.printString(" Normal",0,2);
1012754868 0:5fcd72a90b20 601 lcd.printString(" Difficult <",0,3);
1012754868 0:5fcd72a90b20 602 lcd.printString(" Hell",0,4);
1012754868 2:1234b0a1a51d 603 lcd.printString(" Press back ",0,5);
1012754868 0:5fcd72a90b20 604 c = 2;
1012754868 0:5fcd72a90b20 605 lcd.refresh();
1012754868 0:5fcd72a90b20 606 }
1012754868 0:5fcd72a90b20 607 wait(0.3);
1012754868 0:5fcd72a90b20 608 if(c == 1 && pad.check_event(Gamepad::B_PRESSED) == true) {
1012754868 0:5fcd72a90b20 609 snake._speed = 0;
1012754868 0:5fcd72a90b20 610 lcd.clear();
1012754868 0:5fcd72a90b20 611 lcd.printString(" set success!",0,2);
1012754868 0:5fcd72a90b20 612 lcd.printString(" Press Back!",0,4);
1012754868 0:5fcd72a90b20 613 lcd.refresh();
1012754868 0:5fcd72a90b20 614 }
1012754868 0:5fcd72a90b20 615 else if(c == 2 && pad.check_event(Gamepad::B_PRESSED) == true) {
1012754868 0:5fcd72a90b20 616 snake._speed = 10;
1012754868 0:5fcd72a90b20 617 lcd.clear();
1012754868 0:5fcd72a90b20 618 lcd.printString(" set success!",0,2);
1012754868 0:5fcd72a90b20 619 lcd.printString(" Press Back!",0,4);
1012754868 0:5fcd72a90b20 620 lcd.refresh();
1012754868 0:5fcd72a90b20 621 }
1012754868 0:5fcd72a90b20 622 else if(c == 3 && pad.check_event(Gamepad::B_PRESSED) == true) {
1012754868 0:5fcd72a90b20 623 snake._speed = 50;
1012754868 0:5fcd72a90b20 624 lcd.clear();
1012754868 0:5fcd72a90b20 625 lcd.printString(" set success",0,2);
1012754868 0:5fcd72a90b20 626 lcd.printString(" Press Back!",0,4);
1012754868 0:5fcd72a90b20 627 lcd.refresh();
1012754868 0:5fcd72a90b20 628 }
1012754868 0:5fcd72a90b20 629 if(pad.check_event(Gamepad::BACK_PRESSED) == true){
1012754868 0:5fcd72a90b20 630 IsCheck = true;
1012754868 0:5fcd72a90b20 631 }
1012754868 0:5fcd72a90b20 632 }
1012754868 0:5fcd72a90b20 633
1012754868 0:5fcd72a90b20 634 if(pad.check_event(Gamepad::BACK_PRESSED) == true){
1012754868 0:5fcd72a90b20 635 break;
1012754868 0:5fcd72a90b20 636 }
1012754868 0:5fcd72a90b20 637 }
1012754868 0:5fcd72a90b20 638
1012754868 0:5fcd72a90b20 639 }
1012754868 0:5fcd72a90b20 640 if(d == S && q == 1){
1012754868 0:5fcd72a90b20 641 lcd.clear();
1012754868 0:5fcd72a90b20 642 lcd.printString(" Menu",0,0);
1012754868 0:5fcd72a90b20 643 lcd.printString(" A to set",0,1);
1012754868 0:5fcd72a90b20 644 lcd.printString("set speed",0,2);
1012754868 0:5fcd72a90b20 645 lcd.printString("history <",0,3);
1012754868 0:5fcd72a90b20 646 lcd.printString(" press start",0,5);
1012754868 0:5fcd72a90b20 647 lcd.refresh();
1012754868 0:5fcd72a90b20 648 q = 2;
1012754868 0:5fcd72a90b20 649 }
1012754868 0:5fcd72a90b20 650 if(d == S && q == 2){
1012754868 0:5fcd72a90b20 651 lcd.clear();
1012754868 0:5fcd72a90b20 652 lcd.printString(" Menu",0,0);
1012754868 0:5fcd72a90b20 653 lcd.printString(" A to set",0,1);
1012754868 0:5fcd72a90b20 654 lcd.printString("set speed",0,2);
1012754868 0:5fcd72a90b20 655 lcd.printString("history <",0,3);
1012754868 0:5fcd72a90b20 656 lcd.printString(" press start",0,5);
1012754868 0:5fcd72a90b20 657 lcd.refresh();
1012754868 0:5fcd72a90b20 658 q = 2;
1012754868 0:5fcd72a90b20 659 }
1012754868 0:5fcd72a90b20 660 if(d == N && q == 2) {
1012754868 0:5fcd72a90b20 661 lcd.clear();
1012754868 0:5fcd72a90b20 662 lcd.printString(" Menu",0,0);
1012754868 0:5fcd72a90b20 663 lcd.printString(" A to set",0,1);
1012754868 0:5fcd72a90b20 664 lcd.printString("set speed <",0,2);
1012754868 0:5fcd72a90b20 665 lcd.printString("history ",0,3);
1012754868 0:5fcd72a90b20 666 lcd.printString(" press start",0,5);
1012754868 0:5fcd72a90b20 667 lcd.refresh();
1012754868 0:5fcd72a90b20 668 q = 1;
1012754868 0:5fcd72a90b20 669 }
1012754868 0:5fcd72a90b20 670
1012754868 0:5fcd72a90b20 671 if(q == 2 && pad.check_event(Gamepad::A_PRESSED) == true) {
1012754868 0:5fcd72a90b20 672 lcd.clear();
1012754868 0:5fcd72a90b20 673 sprintf(_Buffer,"%2d",snake.Highest_score);
1012754868 2:1234b0a1a51d 674 lcd.printString(_Buffer,34,3);
1012754868 0:5fcd72a90b20 675 lcd.printString("Highest score",0,1);
1012754868 2:1234b0a1a51d 676 lcd.printString(" Press Back",0,5);
1012754868 0:5fcd72a90b20 677 lcd.refresh();
1012754868 0:5fcd72a90b20 678 while(pad.check_event(Gamepad::BACK_PRESSED) == false){
1012754868 0:5fcd72a90b20 679
1012754868 0:5fcd72a90b20 680 }
1012754868 0:5fcd72a90b20 681 lcd.clear();
1012754868 0:5fcd72a90b20 682 lcd.printString("MOVE joystick",0,1);
1012754868 0:5fcd72a90b20 683 lcd.refresh();
1012754868 0:5fcd72a90b20 684 }
1012754868 0:5fcd72a90b20 685
1012754868 0:5fcd72a90b20 686 pad.leds_on();
1012754868 0:5fcd72a90b20 687 wait(0.1);
1012754868 0:5fcd72a90b20 688 pad.leds_off();
1012754868 0:5fcd72a90b20 689 wait(0.1);
1012754868 0:5fcd72a90b20 690 }
1012754868 0:5fcd72a90b20 691
1012754868 0:5fcd72a90b20 692
1012754868 0:5fcd72a90b20 693
1012754868 0:5fcd72a90b20 694 lcd.clear();
1012754868 0:5fcd72a90b20 695 lcd.printString(" start!!!",0,1);
1012754868 0:5fcd72a90b20 696 lcd.printString("Enjoy yourself",0,3);
1012754868 0:5fcd72a90b20 697 lcd.refresh();
1012754868 0:5fcd72a90b20 698 wait(2);
1012754868 0:5fcd72a90b20 699 }
1012754868 0:5fcd72a90b20 700
1012754868 0:5fcd72a90b20 701
1012754868 0:5fcd72a90b20 702
1012754868 0:5fcd72a90b20 703