Li Saiwen 201089052
Dependencies: mbed Gamepad N5110
Snake/Snake.cpp@7:cafa0b96e8d3, 2019-05-05 (annotated)
- 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?
User | Revision | Line number | New contents of line |
---|---|---|---|
1012754868 | 3:7b28047013d2 | 1 | #include "Snake.h" |
1012754868 | 3:7b28047013d2 | 2 | |
1012754868 | 3:7b28047013d2 | 3 | |
1012754868 | 3:7b28047013d2 | 4 | #define WIDTH 84 |
1012754868 | 3:7b28047013d2 | 5 | #define HEIGHT 48 |
1012754868 | 3:7b28047013d2 | 6 | #define CEILING 8 |
1012754868 | 3:7b28047013d2 | 7 | #define FLOOR 48 |
1012754868 | 3:7b28047013d2 | 8 | |
1012754868 | 3:7b28047013d2 | 9 | snakePart snak; |
1012754868 | 3:7b28047013d2 | 10 | int LIFE[7][7] = { |
1012754868 | 3:7b28047013d2 | 11 | |
1012754868 | 3:7b28047013d2 | 12 | {0,1,0,0,0,1,0}, |
1012754868 | 3:7b28047013d2 | 13 | {1,1,1,0,1,1,1}, |
1012754868 | 3:7b28047013d2 | 14 | {1,1,1,1,1,1,1}, |
1012754868 | 3:7b28047013d2 | 15 | {0,1,1,1,1,1,0}, |
1012754868 | 3:7b28047013d2 | 16 | {0,0,1,1,1,0,0}, |
1012754868 | 3:7b28047013d2 | 17 | {0,0,0,1,0,0,0}, |
1012754868 | 3:7b28047013d2 | 18 | }; |
1012754868 | 3:7b28047013d2 | 19 | |
1012754868 | 3:7b28047013d2 | 20 | |
1012754868 | 3:7b28047013d2 | 21 | Snake::Snake() |
1012754868 | 3:7b28047013d2 | 22 | { |
1012754868 | 3:7b28047013d2 | 23 | |
1012754868 | 3:7b28047013d2 | 24 | } |
1012754868 | 3:7b28047013d2 | 25 | Snake::~Snake() |
1012754868 | 3:7b28047013d2 | 26 | { |
1012754868 | 3:7b28047013d2 | 27 | |
1012754868 | 3:7b28047013d2 | 28 | } |
1012754868 | 3:7b28047013d2 | 29 | |
1012754868 | 3:7b28047013d2 | 30 | /************************Functions************************/ |
1012754868 | 3:7b28047013d2 | 31 | |
1012754868 | 3:7b28047013d2 | 32 | void Snake::init(int x, int y, int length, int _live){//initalizing the starting variables |
1012754868 | 3:7b28047013d2 | 33 | live=_live; |
1012754868 | 3:7b28047013d2 | 34 | _length = length; |
1012754868 | 3:7b28047013d2 | 35 | _food.init(); |
1012754868 | 3:7b28047013d2 | 36 | initx=x; |
1012754868 | 3:7b28047013d2 | 37 | inity=y; |
1012754868 | 3:7b28047013d2 | 38 | initl=length; |
1012754868 | 3:7b28047013d2 | 39 | snak._x[0] = x; |
1012754868 | 3:7b28047013d2 | 40 | snak._y[0] = y; |
1012754868 | 7:cafa0b96e8d3 | 41 | snak._dirc[0] = 1; |
1012754868 | 3:7b28047013d2 | 42 | for (int i=1; i < _length ;i++) |
1012754868 | 3:7b28047013d2 | 43 | { |
1012754868 | 3:7b28047013d2 | 44 | snak._x[i]=snak._x[0]+i; |
1012754868 | 3:7b28047013d2 | 45 | snak._y[i]=snak._y[0]; |
1012754868 | 3:7b28047013d2 | 46 | snak._dirc[i]=1; |
1012754868 | 3:7b28047013d2 | 47 | } |
1012754868 | 7:cafa0b96e8d3 | 48 | snak._x[_length]=x+_length-1; |
1012754868 | 3:7b28047013d2 | 49 | snak._y[_length]=y; |
1012754868 | 3:7b28047013d2 | 50 | snak._dirc[_length]=1; |
1012754868 | 3:7b28047013d2 | 51 | } |
1012754868 | 3:7b28047013d2 | 52 | |
1012754868 | 3:7b28047013d2 | 53 | void Snake::drawsnake(N5110 &lcd, Gamepad &pad){ |
1012754868 | 7:cafa0b96e8d3 | 54 | check_WallCollision(lcd,pad); |
1012754868 | 3:7b28047013d2 | 55 | check_TailCollision(lcd,pad); |
1012754868 | 3:7b28047013d2 | 56 | if (live!=0){ |
1012754868 | 3:7b28047013d2 | 57 | lcd.clear(); |
1012754868 | 7:cafa0b96e8d3 | 58 | waitExpect=((float)_length/4)+6; |
1012754868 | 3:7b28047013d2 | 59 | waitTime=(1/(waitExpect+_speed)); |
1012754868 | 3:7b28047013d2 | 60 | wait(waitTime); |
1012754868 | 7:cafa0b96e8d3 | 61 | _food.drawfood(lcd); |
1012754868 | 7:cafa0b96e8d3 | 62 | lcd.drawRect(0,8,84,48-9,FILL_TRANSPARENT); |
1012754868 | 3:7b28047013d2 | 63 | drawscore(lcd); |
1012754868 | 7:cafa0b96e8d3 | 64 | for ( int i=0; i < _length ;i++){ |
1012754868 | 3:7b28047013d2 | 65 | |
1012754868 | 3:7b28047013d2 | 66 | lcd.setPixel(snak._x[i],snak._y[i]); |
1012754868 | 3:7b28047013d2 | 67 | lcd.refresh(); |
1012754868 | 3:7b28047013d2 | 68 | } |
1012754868 | 3:7b28047013d2 | 69 | } |
1012754868 | 3:7b28047013d2 | 70 | |
1012754868 | 3:7b28047013d2 | 71 | } |
1012754868 | 3:7b28047013d2 | 72 | void Snake::snakemov(Gamepad &pad){ |
1012754868 | 3:7b28047013d2 | 73 | |
1012754868 | 3:7b28047013d2 | 74 | if (live!=0){ |
1012754868 | 7:cafa0b96e8d3 | 75 | d=pad.get_direction(); |
1012754868 | 7:cafa0b96e8d3 | 76 | if (d==N){ |
1012754868 | 7:cafa0b96e8d3 | 77 | |
1012754868 | 7:cafa0b96e8d3 | 78 | if (snak._dirc[_length-1]!=4) |
1012754868 | 7:cafa0b96e8d3 | 79 | { |
1012754868 | 7:cafa0b96e8d3 | 80 | snak._dirc[_length-1] = 2; |
1012754868 | 7:cafa0b96e8d3 | 81 | snak._dirc[_length] = 2; |
1012754868 | 7:cafa0b96e8d3 | 82 | } |
1012754868 | 7:cafa0b96e8d3 | 83 | |
1012754868 | 7:cafa0b96e8d3 | 84 | } |
1012754868 | 7:cafa0b96e8d3 | 85 | |
1012754868 | 7:cafa0b96e8d3 | 86 | if (d==E){ |
1012754868 | 7:cafa0b96e8d3 | 87 | |
1012754868 | 7:cafa0b96e8d3 | 88 | if (snak._dirc[_length-1]!=3) |
1012754868 | 7:cafa0b96e8d3 | 89 | { |
1012754868 | 7:cafa0b96e8d3 | 90 | snak._dirc[_length-1] = 1; |
1012754868 | 7:cafa0b96e8d3 | 91 | snak._dirc[_length] = 1; |
1012754868 | 7:cafa0b96e8d3 | 92 | } |
1012754868 | 7:cafa0b96e8d3 | 93 | |
1012754868 | 7:cafa0b96e8d3 | 94 | } |
1012754868 | 7:cafa0b96e8d3 | 95 | |
1012754868 | 7:cafa0b96e8d3 | 96 | if (d==W){ |
1012754868 | 7:cafa0b96e8d3 | 97 | |
1012754868 | 7:cafa0b96e8d3 | 98 | if (snak._dirc[_length-1]!=1) |
1012754868 | 7:cafa0b96e8d3 | 99 | { |
1012754868 | 7:cafa0b96e8d3 | 100 | snak._dirc[_length-1] = 3; |
1012754868 | 7:cafa0b96e8d3 | 101 | snak._dirc[_length] = 3; |
1012754868 | 7:cafa0b96e8d3 | 102 | } |
1012754868 | 7:cafa0b96e8d3 | 103 | |
1012754868 | 7:cafa0b96e8d3 | 104 | |
1012754868 | 7:cafa0b96e8d3 | 105 | } |
1012754868 | 7:cafa0b96e8d3 | 106 | |
1012754868 | 7:cafa0b96e8d3 | 107 | if (d==S){ |
1012754868 | 7:cafa0b96e8d3 | 108 | |
1012754868 | 7:cafa0b96e8d3 | 109 | if (snak._dirc[_length-1]!=2) |
1012754868 | 7:cafa0b96e8d3 | 110 | { |
1012754868 | 7:cafa0b96e8d3 | 111 | snak._dirc[_length-1] = 4; |
1012754868 | 7:cafa0b96e8d3 | 112 | snak._dirc[_length] = 4; |
1012754868 | 7:cafa0b96e8d3 | 113 | } |
1012754868 | 7:cafa0b96e8d3 | 114 | |
1012754868 | 7:cafa0b96e8d3 | 115 | |
1012754868 | 7:cafa0b96e8d3 | 116 | } |
1012754868 | 7:cafa0b96e8d3 | 117 | |
1012754868 | 7:cafa0b96e8d3 | 118 | if (snak._dirc[_length-1]==1) |
1012754868 | 7:cafa0b96e8d3 | 119 | { |
1012754868 | 7:cafa0b96e8d3 | 120 | snak._x[_length] = snak._x[_length] + 1; |
1012754868 | 7:cafa0b96e8d3 | 121 | |
1012754868 | 3:7b28047013d2 | 122 | } |
1012754868 | 3:7b28047013d2 | 123 | |
1012754868 | 3:7b28047013d2 | 124 | if (snak._dirc[_length-1]==2) |
1012754868 | 3:7b28047013d2 | 125 | { |
1012754868 | 7:cafa0b96e8d3 | 126 | snak._y[_length] = snak._y[_length] - 1; |
1012754868 | 7:cafa0b96e8d3 | 127 | |
1012754868 | 3:7b28047013d2 | 128 | |
1012754868 | 3:7b28047013d2 | 129 | } |
1012754868 | 3:7b28047013d2 | 130 | |
1012754868 | 3:7b28047013d2 | 131 | if (snak._dirc[_length-1]==3) |
1012754868 | 3:7b28047013d2 | 132 | { |
1012754868 | 7:cafa0b96e8d3 | 133 | snak._x[_length] = snak._x[_length] - 1; |
1012754868 | 7:cafa0b96e8d3 | 134 | |
1012754868 | 3:7b28047013d2 | 135 | } |
1012754868 | 3:7b28047013d2 | 136 | |
1012754868 | 3:7b28047013d2 | 137 | if (snak._dirc[_length-1]==4) |
1012754868 | 3:7b28047013d2 | 138 | { |
1012754868 | 7:cafa0b96e8d3 | 139 | snak._y[_length] = snak._y[_length] + 1; |
1012754868 | 3:7b28047013d2 | 140 | } |
1012754868 | 7:cafa0b96e8d3 | 141 | for (int i=0 ;i < _length ;i++) |
1012754868 | 3:7b28047013d2 | 142 | { |
1012754868 | 3:7b28047013d2 | 143 | snak._x[i]=snak._x[i+1]; |
1012754868 | 7:cafa0b96e8d3 | 144 | snak._y[i]=snak._y[i+1]; |
1012754868 | 3:7b28047013d2 | 145 | } |
1012754868 | 3:7b28047013d2 | 146 | eat(pad); |
1012754868 | 7:cafa0b96e8d3 | 147 | } |
1012754868 | 7:cafa0b96e8d3 | 148 | } |
1012754868 | 3:7b28047013d2 | 149 | |
1012754868 | 3:7b28047013d2 | 150 | void Snake::eat(Gamepad &pad){ |
1012754868 | 3:7b28047013d2 | 151 | |
1012754868 | 3:7b28047013d2 | 152 | Foodpos foodPos = _food.returnPos(); |
1012754868 | 3:7b28047013d2 | 153 | if(snak._x[_length-1]==foodPos.x && snak._y[_length-1]== foodPos.y) |
1012754868 | 3:7b28047013d2 | 154 | { |
1012754868 | 7:cafa0b96e8d3 | 155 | _length=_length+1; |
1012754868 | 7:cafa0b96e8d3 | 156 | snak._x[_length] = snak._x[_length - 1]; |
1012754868 | 7:cafa0b96e8d3 | 157 | snak._y[_length] = snak._y[_length - 1]; |
1012754868 | 7:cafa0b96e8d3 | 158 | _food.createfood(); |
1012754868 | 3:7b28047013d2 | 159 | Tone_1(pad); |
1012754868 | 3:7b28047013d2 | 160 | } |
1012754868 | 7:cafa0b96e8d3 | 161 | } |
1012754868 | 3:7b28047013d2 | 162 | |
1012754868 | 3:7b28047013d2 | 163 | int Snake::dead(N5110 &lcd, Gamepad &pad){ |
1012754868 | 3:7b28047013d2 | 164 | |
1012754868 | 3:7b28047013d2 | 165 | |
1012754868 | 7:cafa0b96e8d3 | 166 | live--; |
1012754868 | 3:7b28047013d2 | 167 | while(live==0) { |
1012754868 | 3:7b28047013d2 | 168 | lcd.clear(); |
1012754868 | 3:7b28047013d2 | 169 | lcd.printString("Game Over",0,1); |
1012754868 | 3:7b28047013d2 | 170 | lcd.printString("Press Reset",0,2); |
1012754868 | 3:7b28047013d2 | 171 | lcd.printString("To Back",0,4); |
1012754868 | 3:7b28047013d2 | 172 | lcd.refresh(); |
1012754868 | 3:7b28047013d2 | 173 | |
1012754868 | 3:7b28047013d2 | 174 | pad.tone(0.0,0.5); //gap |
1012754868 | 3:7b28047013d2 | 175 | wait(0.5); |
1012754868 | 3:7b28047013d2 | 176 | if(pad.check_event(Gamepad::BACK_PRESSED) == true){ |
1012754868 | 3:7b28047013d2 | 177 | return 0; |
1012754868 | 3:7b28047013d2 | 178 | } |
1012754868 | 3:7b28047013d2 | 179 | pad.tone(523.0,0.25); //1. |
1012754868 | 3:7b28047013d2 | 180 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 181 | if(pad.check_event(Gamepad::BACK_PRESSED) == true){ |
1012754868 | 3:7b28047013d2 | 182 | return 0; |
1012754868 | 3:7b28047013d2 | 183 | } |
1012754868 | 3:7b28047013d2 | 184 | pad.tone(587.0,0.25); //2. |
1012754868 | 3:7b28047013d2 | 185 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 186 | if(pad.check_event(Gamepad::BACK_PRESSED) == true){ |
1012754868 | 3:7b28047013d2 | 187 | return 0; |
1012754868 | 3:7b28047013d2 | 188 | } |
1012754868 | 3:7b28047013d2 | 189 | pad.tone(659.0,0.25); //3. |
1012754868 | 3:7b28047013d2 | 190 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 191 | if(pad.check_event(Gamepad::BACK_PRESSED) == true){ |
1012754868 | 3:7b28047013d2 | 192 | return 0; |
1012754868 | 3:7b28047013d2 | 193 | } |
1012754868 | 3:7b28047013d2 | 194 | pad.tone(523.0,0.25); //1. |
1012754868 | 3:7b28047013d2 | 195 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 196 | pad.tone(784.0,0.75); //5- |
1012754868 | 3:7b28047013d2 | 197 | wait(0.75); |
1012754868 | 3:7b28047013d2 | 198 | pad.tone(659.0,0.25); //3. |
1012754868 | 3:7b28047013d2 | 199 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 200 | if(pad.check_event(Gamepad::BACK_PRESSED) == true){ |
1012754868 | 3:7b28047013d2 | 201 | return 0; |
1012754868 | 3:7b28047013d2 | 202 | } |
1012754868 | 3:7b28047013d2 | 203 | pad.tone(587.0,0.5); //2 |
1012754868 | 3:7b28047013d2 | 204 | wait(0.5); |
1012754868 | 3:7b28047013d2 | 205 | pad.tone(784.0,0.5); //5 |
1012754868 | 3:7b28047013d2 | 206 | wait(0.5); |
1012754868 | 3:7b28047013d2 | 207 | pad.tone(587.0,0.5); //2 |
1012754868 | 3:7b28047013d2 | 208 | wait(0.5); |
1012754868 | 3:7b28047013d2 | 209 | if(pad.check_event(Gamepad::BACK_PRESSED) == true){ |
1012754868 | 3:7b28047013d2 | 210 | return 0; |
1012754868 | 3:7b28047013d2 | 211 | } |
1012754868 | 3:7b28047013d2 | 212 | pad.tone(523.0,0.25); //1. |
1012754868 | 3:7b28047013d2 | 213 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 214 | pad.tone(440.0,0.25); //l6. |
1012754868 | 3:7b28047013d2 | 215 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 216 | pad.tone(659.0,0.75); //3- |
1012754868 | 3:7b28047013d2 | 217 | wait(0.75); |
1012754868 | 3:7b28047013d2 | 218 | if(pad.check_event(Gamepad::BACK_PRESSED) == true){ |
1012754868 | 3:7b28047013d2 | 219 | return 0; |
1012754868 | 3:7b28047013d2 | 220 | } |
1012754868 | 3:7b28047013d2 | 221 | pad.tone(523.0,0.25); //1. |
1012754868 | 3:7b28047013d2 | 222 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 223 | pad.tone(494.0,0.5); //l7 |
1012754868 | 3:7b28047013d2 | 224 | wait(0.5); |
1012754868 | 3:7b28047013d2 | 225 | pad.tone(0.0,0.5); //gap |
1012754868 | 3:7b28047013d2 | 226 | wait(0.5); |
1012754868 | 3:7b28047013d2 | 227 | pad.tone(494.0,0.5); //l7 |
1012754868 | 3:7b28047013d2 | 228 | wait(0.5); |
1012754868 | 3:7b28047013d2 | 229 | if(pad.check_event(Gamepad::BACK_PRESSED) == true){ |
1012754868 | 3:7b28047013d2 | 230 | return 0; |
1012754868 | 3:7b28047013d2 | 231 | } |
1012754868 | 3:7b28047013d2 | 232 | pad.tone(440.0,0.5); //l6 |
1012754868 | 3:7b28047013d2 | 233 | wait(0.5); |
1012754868 | 3:7b28047013d2 | 234 | pad.tone(494.0,0.5); //l7 |
1012754868 | 3:7b28047013d2 | 235 | wait(0.5); |
1012754868 | 3:7b28047013d2 | 236 | pad.tone(523.0,0.25); //1. |
1012754868 | 3:7b28047013d2 | 237 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 238 | if(pad.check_event(Gamepad::BACK_PRESSED) == true){ |
1012754868 | 3:7b28047013d2 | 239 | return 0; |
1012754868 | 3:7b28047013d2 | 240 | } |
1012754868 | 3:7b28047013d2 | 241 | pad.tone(587.0,0.25); //2. |
1012754868 | 3:7b28047013d2 | 242 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 243 | pad.tone(392.0,0.5); //l5 |
1012754868 | 3:7b28047013d2 | 244 | wait(0.5); |
1012754868 | 3:7b28047013d2 | 245 | if(pad.check_event(Gamepad::BACK_PRESSED) == true){ |
1012754868 | 3:7b28047013d2 | 246 | return 0; |
1012754868 | 3:7b28047013d2 | 247 | } |
1012754868 | 3:7b28047013d2 | 248 | pad.tone(523.0,0.5); //1 |
1012754868 | 3:7b28047013d2 | 249 | wait(0.5); |
1012754868 | 3:7b28047013d2 | 250 | pad.tone(587.0,0.25); //2. |
1012754868 | 3:7b28047013d2 | 251 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 252 | if(pad.check_event(Gamepad::BACK_PRESSED) == true){ |
1012754868 | 3:7b28047013d2 | 253 | return 0; |
1012754868 | 3:7b28047013d2 | 254 | } |
1012754868 | 3:7b28047013d2 | 255 | pad.tone(659.0,0.25); //3. |
1012754868 | 3:7b28047013d2 | 256 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 257 | pad.tone(698.0,0.5); //4 |
1012754868 | 3:7b28047013d2 | 258 | wait(0.5); |
1012754868 | 3:7b28047013d2 | 259 | if(pad.check_event(Gamepad::BACK_PRESSED) == true){ |
1012754868 | 3:7b28047013d2 | 260 | return 0; |
1012754868 | 3:7b28047013d2 | 261 | } |
1012754868 | 3:7b28047013d2 | 262 | pad.tone(698.0,0.25); //4. |
1012754868 | 3:7b28047013d2 | 263 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 264 | pad.tone(659.0,0.25); //3. |
1012754868 | 3:7b28047013d2 | 265 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 266 | pad.tone(587.0,0.25); //2. |
1012754868 | 3:7b28047013d2 | 267 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 268 | if(pad.check_event(Gamepad::BACK_PRESSED) == true){ |
1012754868 | 3:7b28047013d2 | 269 | return 0; |
1012754868 | 3:7b28047013d2 | 270 | } |
1012754868 | 3:7b28047013d2 | 271 | pad.tone(523.0,0.25); //1. |
1012754868 | 3:7b28047013d2 | 272 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 273 | pad.tone(587.0,0.5); //2 |
1012754868 | 3:7b28047013d2 | 274 | wait(0.5); |
1012754868 | 3:7b28047013d2 | 275 | if(pad.check_event(Gamepad::BACK_PRESSED) == true){ |
1012754868 | 3:7b28047013d2 | 276 | return 0; |
1012754868 | 3:7b28047013d2 | 277 | } |
1012754868 | 3:7b28047013d2 | 278 | pad.tone(0.0,5); //gap |
1012754868 | 3:7b28047013d2 | 279 | wait(0.5); |
1012754868 | 3:7b28047013d2 | 280 | pad.tone(523.0,0.25); //1. |
1012754868 | 3:7b28047013d2 | 281 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 282 | pad.tone(587.0,0.25); //2. |
1012754868 | 3:7b28047013d2 | 283 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 284 | if(pad.check_event(Gamepad::BACK_PRESSED) == true){ |
1012754868 | 3:7b28047013d2 | 285 | return 0; |
1012754868 | 3:7b28047013d2 | 286 | } |
1012754868 | 3:7b28047013d2 | 287 | pad.tone(659.0,0.25); //3. |
1012754868 | 3:7b28047013d2 | 288 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 289 | pad.tone(523.0,0.25); //1. |
1012754868 | 3:7b28047013d2 | 290 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 291 | pad.tone(784.0,0.75); //5- |
1012754868 | 3:7b28047013d2 | 292 | wait(0.75); |
1012754868 | 3:7b28047013d2 | 293 | if(pad.check_event(Gamepad::BACK_PRESSED) == true){ |
1012754868 | 3:7b28047013d2 | 294 | return 0; |
1012754868 | 3:7b28047013d2 | 295 | } |
1012754868 | 3:7b28047013d2 | 296 | pad.tone(659.0,0.25); //3. |
1012754868 | 3:7b28047013d2 | 297 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 298 | pad.tone(587.0,0.5); //2 |
1012754868 | 3:7b28047013d2 | 299 | wait(0.5); |
1012754868 | 3:7b28047013d2 | 300 | pad.tone(784.0,0.5); //5 |
1012754868 | 3:7b28047013d2 | 301 | wait(0.5); |
1012754868 | 3:7b28047013d2 | 302 | if(pad.check_event(Gamepad::BACK_PRESSED) == true){ |
1012754868 | 3:7b28047013d2 | 303 | return 0; |
1012754868 | 3:7b28047013d2 | 304 | } |
1012754868 | 3:7b28047013d2 | 305 | pad.tone(587.0,0.5); //2 |
1012754868 | 3:7b28047013d2 | 306 | wait(0.5); |
1012754868 | 3:7b28047013d2 | 307 | pad.tone(523.0,0.25); //1. |
1012754868 | 3:7b28047013d2 | 308 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 309 | if(pad.check_event(Gamepad::BACK_PRESSED) == true){ |
1012754868 | 3:7b28047013d2 | 310 | return 0; |
1012754868 | 3:7b28047013d2 | 311 | } |
1012754868 | 3:7b28047013d2 | 312 | pad.tone(440.0,0.25); //l6. |
1012754868 | 3:7b28047013d2 | 313 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 314 | pad.tone(440.0,0.5); //l6 |
1012754868 | 3:7b28047013d2 | 315 | wait(0.5); |
1012754868 | 3:7b28047013d2 | 316 | pad.tone(494.0,0.25); //l7. |
1012754868 | 3:7b28047013d2 | 317 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 318 | if(pad.check_event(Gamepad::BACK_PRESSED) == true){ |
1012754868 | 3:7b28047013d2 | 319 | return 0; |
1012754868 | 3:7b28047013d2 | 320 | } |
1012754868 | 3:7b28047013d2 | 321 | pad.tone(523.0,0.25); //1. |
1012754868 | 3:7b28047013d2 | 322 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 323 | pad.tone(392.0,0.5); //l5 |
1012754868 | 3:7b28047013d2 | 324 | wait(0.5); |
1012754868 | 3:7b28047013d2 | 325 | if(pad.check_event(Gamepad::BACK_PRESSED) == true){ |
1012754868 | 3:7b28047013d2 | 326 | return 0; |
1012754868 | 3:7b28047013d2 | 327 | } |
1012754868 | 3:7b28047013d2 | 328 | pad.tone(0.0,0.5); //gap |
1012754868 | 3:7b28047013d2 | 329 | wait(0.5); |
1012754868 | 3:7b28047013d2 | 330 | pad.tone(0.0,0.25); //gap. |
1012754868 | 3:7b28047013d2 | 331 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 332 | pad.tone(494.0,0.5); //l7 |
1012754868 | 3:7b28047013d2 | 333 | wait(0.5); |
1012754868 | 3:7b28047013d2 | 334 | pad.tone(523.0,0.25); //1. |
1012754868 | 3:7b28047013d2 | 335 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 336 | if(pad.check_event(Gamepad::BACK_PRESSED) == true){ |
1012754868 | 3:7b28047013d2 | 337 | return 0; |
1012754868 | 3:7b28047013d2 | 338 | } |
1012754868 | 3:7b28047013d2 | 339 | pad.tone(587.0,0.25); //2. |
1012754868 | 3:7b28047013d2 | 340 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 341 | pad.tone(392.0,0.5); //l5 |
1012754868 | 3:7b28047013d2 | 342 | wait(0.5); |
1012754868 | 3:7b28047013d2 | 343 | pad.tone(523.0,0.5); //1 |
1012754868 | 3:7b28047013d2 | 344 | wait(0.5); |
1012754868 | 3:7b28047013d2 | 345 | if(pad.check_event(Gamepad::BACK_PRESSED) == true){ |
1012754868 | 3:7b28047013d2 | 346 | return 0; |
1012754868 | 3:7b28047013d2 | 347 | } |
1012754868 | 3:7b28047013d2 | 348 | pad.tone(587.0,0.25); //2. |
1012754868 | 3:7b28047013d2 | 349 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 350 | pad.tone(659.0,0.25); //3. |
1012754868 | 3:7b28047013d2 | 351 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 352 | pad.tone(698.0,0.5); //4 |
1012754868 | 3:7b28047013d2 | 353 | wait(0.5); |
1012754868 | 3:7b28047013d2 | 354 | pad.tone(698.0,0.25); //4. |
1012754868 | 3:7b28047013d2 | 355 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 356 | pad.tone(659.0,0.25); //3. |
1012754868 | 3:7b28047013d2 | 357 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 358 | if(pad.check_event(Gamepad::BACK_PRESSED) == true){ |
1012754868 | 3:7b28047013d2 | 359 | return 0; |
1012754868 | 3:7b28047013d2 | 360 | } |
1012754868 | 3:7b28047013d2 | 361 | pad.tone(587.0,0.25); //2. |
1012754868 | 3:7b28047013d2 | 362 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 363 | pad.tone(523.0,0.25); //1. |
1012754868 | 3:7b28047013d2 | 364 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 365 | pad.tone(523.0,0.5); //1 |
1012754868 | 3:7b28047013d2 | 366 | wait(0.5); |
1012754868 | 3:7b28047013d2 | 367 | if(pad.check_event(Gamepad::BACK_PRESSED) == true){ |
1012754868 | 3:7b28047013d2 | 368 | return 0; |
1012754868 | 3:7b28047013d2 | 369 | } |
1012754868 | 3:7b28047013d2 | 370 | pad.tone(0.0,0.5); //gap |
1012754868 | 3:7b28047013d2 | 371 | wait(0.5); |
1012754868 | 3:7b28047013d2 | 372 | pad.tone(0.0,0.5); //gap |
1012754868 | 3:7b28047013d2 | 373 | wait(0.5); |
1012754868 | 3:7b28047013d2 | 374 | if(pad.check_event(Gamepad::BACK_PRESSED) == true){ |
1012754868 | 3:7b28047013d2 | 375 | return 0; |
1012754868 | 3:7b28047013d2 | 376 | } |
1012754868 | 3:7b28047013d2 | 377 | pad.tone(659.0,0.25); //3. |
1012754868 | 3:7b28047013d2 | 378 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 379 | pad.tone(698.0,0.25); //4. |
1012754868 | 3:7b28047013d2 | 380 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 381 | pad.tone(784.0,0.5); //5 |
1012754868 | 3:7b28047013d2 | 382 | wait(0.5); |
1012754868 | 3:7b28047013d2 | 383 | if(pad.check_event(Gamepad::BACK_PRESSED) == true){ |
1012754868 | 3:7b28047013d2 | 384 | return 0; |
1012754868 | 3:7b28047013d2 | 385 | } |
1012754868 | 3:7b28047013d2 | 386 | pad.tone(784.0,0.5); //5 |
1012754868 | 3:7b28047013d2 | 387 | wait(0.5); |
1012754868 | 3:7b28047013d2 | 388 | pad.tone(784.0,0.5); //5 |
1012754868 | 3:7b28047013d2 | 389 | wait(0.5); |
1012754868 | 3:7b28047013d2 | 390 | pad.tone(784.0,0.5); //5 |
1012754868 | 3:7b28047013d2 | 391 | wait(0.5); |
1012754868 | 3:7b28047013d2 | 392 | if(pad.check_event(Gamepad::BACK_PRESSED) == true){ |
1012754868 | 3:7b28047013d2 | 393 | return 0; |
1012754868 | 3:7b28047013d2 | 394 | } |
1012754868 | 3:7b28047013d2 | 395 | pad.tone(784.0,0.25); //5. |
1012754868 | 3:7b28047013d2 | 396 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 397 | pad.tone(880.0,0.25); //6. |
1012754868 | 3:7b28047013d2 | 398 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 399 | pad.tone(784.0,0.25); //5. |
1012754868 | 3:7b28047013d2 | 400 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 401 | pad.tone(698.0,0.25); //4. |
1012754868 | 3:7b28047013d2 | 402 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 403 | if(pad.check_event(Gamepad::BACK_PRESSED) == true){ |
1012754868 | 3:7b28047013d2 | 404 | return 0; |
1012754868 | 3:7b28047013d2 | 405 | } |
1012754868 | 3:7b28047013d2 | 406 | pad.tone(659.0,0.5); //3 |
1012754868 | 3:7b28047013d2 | 407 | wait(0.5); |
1012754868 | 3:7b28047013d2 | 408 | pad.tone(659.0,0.5); //3 |
1012754868 | 3:7b28047013d2 | 409 | wait(0.5); |
1012754868 | 3:7b28047013d2 | 410 | pad.tone(659.0,0.5); //3 |
1012754868 | 3:7b28047013d2 | 411 | wait(0.5); |
1012754868 | 3:7b28047013d2 | 412 | if(pad.check_event(Gamepad::BACK_PRESSED) == true){ |
1012754868 | 3:7b28047013d2 | 413 | return 0; |
1012754868 | 3:7b28047013d2 | 414 | } |
1012754868 | 3:7b28047013d2 | 415 | pad.tone(659.0,0.5); //3 |
1012754868 | 3:7b28047013d2 | 416 | wait(0.5); |
1012754868 | 3:7b28047013d2 | 417 | pad.tone(659.0,0.25); //3. |
1012754868 | 3:7b28047013d2 | 418 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 419 | pad.tone(698.0,0.25); //4. |
1012754868 | 3:7b28047013d2 | 420 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 421 | if(pad.check_event(Gamepad::BACK_PRESSED) == true){ |
1012754868 | 3:7b28047013d2 | 422 | return 0; |
1012754868 | 3:7b28047013d2 | 423 | } |
1012754868 | 3:7b28047013d2 | 424 | pad.tone(659.0,0.25); //3. |
1012754868 | 3:7b28047013d2 | 425 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 426 | pad.tone(587.0,0.25); //2. |
1012754868 | 3:7b28047013d2 | 427 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 428 | pad.tone(523.0,0.5); //1 |
1012754868 | 3:7b28047013d2 | 429 | wait(0.5); |
1012754868 | 3:7b28047013d2 | 430 | if(pad.check_event(Gamepad::BACK_PRESSED) == true){ |
1012754868 | 3:7b28047013d2 | 431 | return 0; |
1012754868 | 3:7b28047013d2 | 432 | } |
1012754868 | 3:7b28047013d2 | 433 | pad.tone(523.0,0.5); //1 |
1012754868 | 3:7b28047013d2 | 434 | wait(0.5); |
1012754868 | 3:7b28047013d2 | 435 | pad.tone(523.0,0.5); //1. |
1012754868 | 3:7b28047013d2 | 436 | wait(0.5); |
1012754868 | 3:7b28047013d2 | 437 | pad.tone(494.0,0.25); //l7. |
1012754868 | 3:7b28047013d2 | 438 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 439 | if(pad.check_event(Gamepad::BACK_PRESSED) == true){ |
1012754868 | 3:7b28047013d2 | 440 | return 0; |
1012754868 | 3:7b28047013d2 | 441 | } |
1012754868 | 3:7b28047013d2 | 442 | pad.tone(440.0,0.5); //l6 |
1012754868 | 3:7b28047013d2 | 443 | wait(0.5); |
1012754868 | 3:7b28047013d2 | 444 | pad.tone(494.0,0.5); //l7 |
1012754868 | 3:7b28047013d2 | 445 | wait(0.5); |
1012754868 | 3:7b28047013d2 | 446 | pad.tone(494.0,0.25); //l7. |
1012754868 | 3:7b28047013d2 | 447 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 448 | if(pad.check_event(Gamepad::BACK_PRESSED) == true){ |
1012754868 | 3:7b28047013d2 | 449 | return 0; |
1012754868 | 3:7b28047013d2 | 450 | } |
1012754868 | 3:7b28047013d2 | 451 | pad.tone(523.0,0.25); //1. |
1012754868 | 3:7b28047013d2 | 452 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 453 | pad.tone(587.0,0.5); //2 |
1012754868 | 3:7b28047013d2 | 454 | wait(0.5); |
1012754868 | 3:7b28047013d2 | 455 | pad.tone(587.0,0.25); //2. |
1012754868 | 3:7b28047013d2 | 456 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 457 | if(pad.check_event(Gamepad::BACK_PRESSED) == true){ |
1012754868 | 3:7b28047013d2 | 458 | return 0; |
1012754868 | 3:7b28047013d2 | 459 | } |
1012754868 | 3:7b28047013d2 | 460 | pad.tone(659.0,0.25); //3. |
1012754868 | 3:7b28047013d2 | 461 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 462 | pad.tone(587.0,0.25); //2. |
1012754868 | 3:7b28047013d2 | 463 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 464 | pad.tone(659.0,0.25); //3. |
1012754868 | 3:7b28047013d2 | 465 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 466 | if(pad.check_event(Gamepad::BACK_PRESSED) == true){ |
1012754868 | 3:7b28047013d2 | 467 | return 0; |
1012754868 | 3:7b28047013d2 | 468 | } |
1012754868 | 3:7b28047013d2 | 469 | pad.tone(587.0,0.5); //2 |
1012754868 | 3:7b28047013d2 | 470 | wait(0.5); |
1012754868 | 3:7b28047013d2 | 471 | pad.tone(0.0,0.5); //gap |
1012754868 | 3:7b28047013d2 | 472 | wait(0.5); |
1012754868 | 3:7b28047013d2 | 473 | pad.tone(659.0,0.25); //3. |
1012754868 | 3:7b28047013d2 | 474 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 475 | if(pad.check_event(Gamepad::BACK_PRESSED) == true){ |
1012754868 | 3:7b28047013d2 | 476 | return 0; |
1012754868 | 3:7b28047013d2 | 477 | } |
1012754868 | 3:7b28047013d2 | 478 | pad.tone(698.0,0.25); //4. |
1012754868 | 3:7b28047013d2 | 479 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 480 | pad.tone(784.0,0.5); //5 |
1012754868 | 3:7b28047013d2 | 481 | wait(0.5); |
1012754868 | 3:7b28047013d2 | 482 | pad.tone(784.0,0.5); //5 |
1012754868 | 3:7b28047013d2 | 483 | wait(0.5); |
1012754868 | 3:7b28047013d2 | 484 | if(pad.check_event(Gamepad::BACK_PRESSED) == true){ |
1012754868 | 3:7b28047013d2 | 485 | return 0; |
1012754868 | 3:7b28047013d2 | 486 | } |
1012754868 | 3:7b28047013d2 | 487 | pad.tone(784.0,0.5); //5 |
1012754868 | 3:7b28047013d2 | 488 | wait(0.5); |
1012754868 | 3:7b28047013d2 | 489 | pad.tone(784.0,0.5); //5 |
1012754868 | 3:7b28047013d2 | 490 | wait(0.5); |
1012754868 | 3:7b28047013d2 | 491 | if(pad.check_event(Gamepad::BACK_PRESSED) == true){ |
1012754868 | 3:7b28047013d2 | 492 | return 0; |
1012754868 | 3:7b28047013d2 | 493 | } |
1012754868 | 3:7b28047013d2 | 494 | pad.tone(784.0,0.25); //5. |
1012754868 | 3:7b28047013d2 | 495 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 496 | pad.tone(880.0,0.25); //6. |
1012754868 | 3:7b28047013d2 | 497 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 498 | pad.tone(784.0,0.25); //5. |
1012754868 | 3:7b28047013d2 | 499 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 500 | if(pad.check_event(Gamepad::BACK_PRESSED) == true){ |
1012754868 | 3:7b28047013d2 | 501 | return 0; |
1012754868 | 3:7b28047013d2 | 502 | } |
1012754868 | 3:7b28047013d2 | 503 | pad.tone(698.0,0.25); //4. |
1012754868 | 3:7b28047013d2 | 504 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 505 | pad.tone(659.0,0.5); //3 |
1012754868 | 3:7b28047013d2 | 506 | wait(0.5); |
1012754868 | 3:7b28047013d2 | 507 | pad.tone(659.0,0.5); //3 |
1012754868 | 3:7b28047013d2 | 508 | wait(0.5); |
1012754868 | 3:7b28047013d2 | 509 | if(pad.check_event(Gamepad::BACK_PRESSED) == true){ |
1012754868 | 3:7b28047013d2 | 510 | return 0; |
1012754868 | 3:7b28047013d2 | 511 | } |
1012754868 | 3:7b28047013d2 | 512 | pad.tone(659.0,0.5); //3 |
1012754868 | 3:7b28047013d2 | 513 | wait(0.5); |
1012754868 | 3:7b28047013d2 | 514 | pad.tone(659.0,0.25); //3. |
1012754868 | 3:7b28047013d2 | 515 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 516 | pad.tone(698.0,0.25); //4. |
1012754868 | 3:7b28047013d2 | 517 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 518 | if(pad.check_event(Gamepad::BACK_PRESSED) == true){ |
1012754868 | 3:7b28047013d2 | 519 | return 0; |
1012754868 | 3:7b28047013d2 | 520 | } |
1012754868 | 3:7b28047013d2 | 521 | pad.tone(659.0,0.25); //3. |
1012754868 | 3:7b28047013d2 | 522 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 523 | pad.tone(587.0,0.25); //2. |
1012754868 | 3:7b28047013d2 | 524 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 525 | if(pad.check_event(Gamepad::BACK_PRESSED) == true){ |
1012754868 | 3:7b28047013d2 | 526 | return 0; |
1012754868 | 3:7b28047013d2 | 527 | } |
1012754868 | 3:7b28047013d2 | 528 | pad.tone(523.0,0.25); //1. |
1012754868 | 3:7b28047013d2 | 529 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 530 | |
1012754868 | 3:7b28047013d2 | 531 | pad.tone(494.0,0.25); //l7. |
1012754868 | 3:7b28047013d2 | 532 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 533 | pad.tone(440.0,0.5); //l6 |
1012754868 | 3:7b28047013d2 | 534 | wait(0.5); |
1012754868 | 3:7b28047013d2 | 535 | if(pad.check_event(Gamepad::BACK_PRESSED) == true){ |
1012754868 | 3:7b28047013d2 | 536 | return 0; |
1012754868 | 3:7b28047013d2 | 537 | } |
1012754868 | 3:7b28047013d2 | 538 | pad.tone(440.0,0.25); //l6. |
1012754868 | 3:7b28047013d2 | 539 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 540 | pad.tone(494.0,0.25); //l7. |
1012754868 | 3:7b28047013d2 | 541 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 542 | pad.tone(523.0,0.25); //1. |
1012754868 | 3:7b28047013d2 | 543 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 544 | if(pad.check_event(Gamepad::BACK_PRESSED) == true){ |
1012754868 | 3:7b28047013d2 | 545 | return 0; |
1012754868 | 3:7b28047013d2 | 546 | } |
1012754868 | 3:7b28047013d2 | 547 | pad.tone(587.0,0.25); //2. |
1012754868 | 3:7b28047013d2 | 548 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 549 | pad.tone(392.0,0.5); //l5 |
1012754868 | 3:7b28047013d2 | 550 | wait(0.5); |
1012754868 | 3:7b28047013d2 | 551 | pad.tone(523.0,0.5); //1 |
1012754868 | 3:7b28047013d2 | 552 | wait(0.5); |
1012754868 | 3:7b28047013d2 | 553 | if(pad.check_event(Gamepad::BACK_PRESSED) == true){ |
1012754868 | 3:7b28047013d2 | 554 | return 0; |
1012754868 | 3:7b28047013d2 | 555 | } |
1012754868 | 3:7b28047013d2 | 556 | pad.tone(587.0,0.25); //2. |
1012754868 | 3:7b28047013d2 | 557 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 558 | pad.tone(659.0,0.25); //3. |
1012754868 | 3:7b28047013d2 | 559 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 560 | pad.tone(587.0,0.75); //2- |
1012754868 | 3:7b28047013d2 | 561 | wait(0.75); |
1012754868 | 3:7b28047013d2 | 562 | if(pad.check_event(Gamepad::BACK_PRESSED) == true){ |
1012754868 | 3:7b28047013d2 | 563 | return 0; |
1012754868 | 3:7b28047013d2 | 564 | } |
1012754868 | 3:7b28047013d2 | 565 | pad.tone(587.0,0.25); //2. |
1012754868 | 3:7b28047013d2 | 566 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 567 | pad.tone(587.0,0.25); //2. |
1012754868 | 3:7b28047013d2 | 568 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 569 | pad.tone(523.0,0.25); //1. |
1012754868 | 3:7b28047013d2 | 570 | wait(0.25); |
1012754868 | 3:7b28047013d2 | 571 | if(pad.check_event(Gamepad::BACK_PRESSED) == true){ |
1012754868 | 3:7b28047013d2 | 572 | return 0; |
1012754868 | 3:7b28047013d2 | 573 | } |
1012754868 | 3:7b28047013d2 | 574 | pad.tone(523.0,0.5); //1 |
1012754868 | 3:7b28047013d2 | 575 | wait(0.5); |
1012754868 | 3:7b28047013d2 | 576 | pad.tone(0.0,0.5); //gap |
1012754868 | 3:7b28047013d2 | 577 | wait(0.5); |
1012754868 | 3:7b28047013d2 | 578 | pad.tone(0.0,0.5); //gap |
1012754868 | 3:7b28047013d2 | 579 | wait(0.5); |
1012754868 | 3:7b28047013d2 | 580 | if(pad.check_event(Gamepad::BACK_PRESSED) == true){ |
1012754868 | 3:7b28047013d2 | 581 | return 0; |
1012754868 | 3:7b28047013d2 | 582 | } |
1012754868 | 3:7b28047013d2 | 583 | |
1012754868 | 3:7b28047013d2 | 584 | } |
1012754868 | 3:7b28047013d2 | 585 | if(Highest_score < (_length - 5)){ |
1012754868 | 3:7b28047013d2 | 586 | Highest_score = _length - 5; |
1012754868 | 3:7b28047013d2 | 587 | } |
1012754868 | 3:7b28047013d2 | 588 | init(initx,inity,initl,live); |
1012754868 | 3:7b28047013d2 | 589 | //end of deadSnake |
1012754868 | 3:7b28047013d2 | 590 | return 0; |
1012754868 | 3:7b28047013d2 | 591 | } |
1012754868 | 3:7b28047013d2 | 592 | |
1012754868 | 3:7b28047013d2 | 593 | void Snake::Tone_1(Gamepad &pad){ |
1012754868 | 3:7b28047013d2 | 594 | pad.tone(750.0,0.1); |
1012754868 | 3:7b28047013d2 | 595 | } |
1012754868 | 3:7b28047013d2 | 596 | |
1012754868 | 3:7b28047013d2 | 597 | void Snake::check_WallCollision(N5110 &lcd, Gamepad &pad){ |
1012754868 | 3:7b28047013d2 | 598 | |
1012754868 | 3:7b28047013d2 | 599 | if (snak._x[_length] == 0 || snak._x[_length] == WIDTH)//if snake head hits side walls |
1012754868 | 3:7b28047013d2 | 600 | { |
1012754868 | 3:7b28047013d2 | 601 | game_music(pad); |
1012754868 | 3:7b28047013d2 | 602 | dead(lcd,pad); |
1012754868 | 3:7b28047013d2 | 603 | } |
1012754868 | 7:cafa0b96e8d3 | 604 | if (snak._y[_length]== FLOOR ||snak._y[_length]== CEILING ) |
1012754868 | 3:7b28047013d2 | 605 | { |
1012754868 | 3:7b28047013d2 | 606 | game_music(pad); |
1012754868 | 3:7b28047013d2 | 607 | dead(lcd,pad); |
1012754868 | 3:7b28047013d2 | 608 | } |
1012754868 | 3:7b28047013d2 | 609 | |
1012754868 | 7:cafa0b96e8d3 | 610 | } |
1012754868 | 3:7b28047013d2 | 611 | |
1012754868 | 7:cafa0b96e8d3 | 612 | void Snake::check_TailCollision(N5110 &lcd, Gamepad &pad){ |
1012754868 | 7:cafa0b96e8d3 | 613 | for (int i=0 ;i < (_length - 2) ;i++){ |
1012754868 | 3:7b28047013d2 | 614 | |
1012754868 | 3:7b28047013d2 | 615 | if (snak._x[_length-1]==snak._x[i] && snak._y[_length-1]==snak._y[i]) |
1012754868 | 3:7b28047013d2 | 616 | { |
1012754868 | 3:7b28047013d2 | 617 | game_music(pad); |
1012754868 | 3:7b28047013d2 | 618 | dead(lcd,pad); |
1012754868 | 3:7b28047013d2 | 619 | } |
1012754868 | 3:7b28047013d2 | 620 | } |
1012754868 | 3:7b28047013d2 | 621 | |
1012754868 | 3:7b28047013d2 | 622 | |
1012754868 | 7:cafa0b96e8d3 | 623 | } |
1012754868 | 3:7b28047013d2 | 624 | |
1012754868 | 3:7b28047013d2 | 625 | void Snake::game_music(Gamepad &pad){ |
1012754868 | 3:7b28047013d2 | 626 | |
1012754868 | 3:7b28047013d2 | 627 | pad.tone(1046.0,0.125); |
1012754868 | 3:7b28047013d2 | 628 | wait(0.125); |
1012754868 | 3:7b28047013d2 | 629 | pad.tone(1075.0,0.125); |
1012754868 | 3:7b28047013d2 | 630 | wait(0.125); |
1012754868 | 3:7b28047013d2 | 631 | pad.tone(1318.0,0.125); |
1012754868 | 3:7b28047013d2 | 632 | wait(0.125); |
1012754868 | 3:7b28047013d2 | 633 | } |
1012754868 | 3:7b28047013d2 | 634 | |
1012754868 | 3:7b28047013d2 | 635 | void Snake::drawscore(N5110 &lcd){ |
1012754868 | 7:cafa0b96e8d3 | 636 | char buffer_1[15]; |
1012754868 | 7:cafa0b96e8d3 | 637 | char buffer_2[15]; |
1012754868 | 7:cafa0b96e8d3 | 638 | sprintf(buffer_1,"%2d",live); |
1012754868 | 7:cafa0b96e8d3 | 639 | sprintf(buffer_2,"%2d",_length-5); |
1012754868 | 7:cafa0b96e8d3 | 640 | lcd.printString(buffer_1,20,0); |
1012754868 | 7:cafa0b96e8d3 | 641 | lcd.printString(buffer_2,70,0); |
1012754868 | 3:7b28047013d2 | 642 | lcd.drawSprite(6,1,7,7,(int *)LIFE); |
1012754868 | 3:7b28047013d2 | 643 | lcd.printString(":",17,0); |
1012754868 | 7:cafa0b96e8d3 | 644 | lcd.printString("Score:",40,0); |
1012754868 | 3:7b28047013d2 | 645 | |
1012754868 | 7:cafa0b96e8d3 | 646 | } |