ELEC2645 (2015/16)
/
el14ws_Project
Snake Game
Fork of ProjectSnake by
main.cpp@0:4b8288518876, 2016-05-04 (annotated)
- Committer:
- el14ws
- Date:
- Wed May 04 17:31:50 2016 +0000
- Revision:
- 0:4b8288518876
- Child:
- 1:44cc07feab7e
Snake Game, Snake has the ability to collect food and grow.; Collisions need to be completed
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
el14ws | 0:4b8288518876 | 1 | #include "mbed.h" |
el14ws | 0:4b8288518876 | 2 | #include "N5110.h" |
el14ws | 0:4b8288518876 | 3 | #define DIRECTION_TOLERANCE 0.05// change this to alter tolerance of joystick direction |
el14ws | 0:4b8288518876 | 4 | |
el14ws | 0:4b8288518876 | 5 | DigitalIn button(PTB11);// connections for joystick |
el14ws | 0:4b8288518876 | 6 | AnalogIn xPot(PTB2); |
el14ws | 0:4b8288518876 | 7 | AnalogIn yPot(PTB3); |
el14ws | 0:4b8288518876 | 8 | Ticker pollJoystick;// timer to regularly read the joystick |
el14ws | 0:4b8288518876 | 9 | // Serial for debug |
el14ws | 0:4b8288518876 | 10 | Serial serial(USBTX,USBRX);// Serial for debug |
el14ws | 0:4b8288518876 | 11 | // create enumerated type (0,1,2,3 etc. for direction) |
el14ws | 0:4b8288518876 | 12 | // could be extended for diagonals etc. |
el14ws | 0:4b8288518876 | 13 | enum DirectionName { |
el14ws | 0:4b8288518876 | 14 | UP, |
el14ws | 0:4b8288518876 | 15 | DOWN, |
el14ws | 0:4b8288518876 | 16 | LEFT, |
el14ws | 0:4b8288518876 | 17 | RIGHT, |
el14ws | 0:4b8288518876 | 18 | CENTRE, |
el14ws | 0:4b8288518876 | 19 | UNKNOWN |
el14ws | 0:4b8288518876 | 20 | }; |
el14ws | 0:4b8288518876 | 21 | typedef struct JoyStick Joystick;// struct for Joystick |
el14ws | 0:4b8288518876 | 22 | struct JoyStick { |
el14ws | 0:4b8288518876 | 23 | float x; // current x value |
el14ws | 0:4b8288518876 | 24 | float x0; // 'centred' x value |
el14ws | 0:4b8288518876 | 25 | float y; // current y value |
el14ws | 0:4b8288518876 | 26 | float y0; // 'centred' y value |
el14ws | 0:4b8288518876 | 27 | int button; // button state (assume pull-down used, so 1 = pressed, 0 = unpressed) |
el14ws | 0:4b8288518876 | 28 | DirectionName direction; // current direction |
el14ws | 0:4b8288518876 | 29 | }; |
el14ws | 0:4b8288518876 | 30 | Joystick joystick;// create struct variable |
el14ws | 0:4b8288518876 | 31 | int printFlag = 0; |
el14ws | 0:4b8288518876 | 32 | |
el14ws | 0:4b8288518876 | 33 | // VCC, SCE, RST, D/C, MOSI, SCLK, LED |
el14ws | 0:4b8288518876 | 34 | N5110 lcd( PTE26, PTA0, PTC4, PTD0, PTD2, PTD1, PTC3); |
el14ws | 0:4b8288518876 | 35 | DigitalIn buttonA(PTB18); |
el14ws | 0:4b8288518876 | 36 | int ni = 84; |
el14ws | 0:4b8288518876 | 37 | int x = 0; |
el14ws | 0:4b8288518876 | 38 | int x1 = 0; |
el14ws | 0:4b8288518876 | 39 | int x2 = 0; |
el14ws | 0:4b8288518876 | 40 | int x3 = 0; |
el14ws | 0:4b8288518876 | 41 | int x4 = 0; |
el14ws | 0:4b8288518876 | 42 | int x5 = 0; |
el14ws | 0:4b8288518876 | 43 | int x6 = 0; |
el14ws | 0:4b8288518876 | 44 | int x7 = 0; |
el14ws | 0:4b8288518876 | 45 | int x8 = 0; |
el14ws | 0:4b8288518876 | 46 | int x9 = 0; |
el14ws | 0:4b8288518876 | 47 | int x10 = 0; |
el14ws | 0:4b8288518876 | 48 | int x11 = 0; |
el14ws | 0:4b8288518876 | 49 | int x12 = 0; |
el14ws | 0:4b8288518876 | 50 | int x13 = 0; |
el14ws | 0:4b8288518876 | 51 | int x14 = 0; |
el14ws | 0:4b8288518876 | 52 | int x15 = 0; |
el14ws | 0:4b8288518876 | 53 | int x16 = 0; |
el14ws | 0:4b8288518876 | 54 | int x17 = 0; |
el14ws | 0:4b8288518876 | 55 | int x18 = 0; |
el14ws | 0:4b8288518876 | 56 | int x19 = 0; |
el14ws | 0:4b8288518876 | 57 | int x20 = 0; |
el14ws | 0:4b8288518876 | 58 | int x21 = 0; |
el14ws | 0:4b8288518876 | 59 | int x22 = 0; |
el14ws | 0:4b8288518876 | 60 | int x23 = 0; |
el14ws | 0:4b8288518876 | 61 | int x24 = 0; |
el14ws | 0:4b8288518876 | 62 | int y = 0; |
el14ws | 0:4b8288518876 | 63 | int y1 = 1; |
el14ws | 0:4b8288518876 | 64 | int y2 = 2; |
el14ws | 0:4b8288518876 | 65 | int y3 = 3; |
el14ws | 0:4b8288518876 | 66 | int y4 = 4; |
el14ws | 0:4b8288518876 | 67 | int y5 = 5; |
el14ws | 0:4b8288518876 | 68 | int y6 = 6; |
el14ws | 0:4b8288518876 | 69 | int y7 = 7; |
el14ws | 0:4b8288518876 | 70 | int y8 = 8; |
el14ws | 0:4b8288518876 | 71 | int y9 = 9; |
el14ws | 0:4b8288518876 | 72 | int y10 = 10; |
el14ws | 0:4b8288518876 | 73 | int y11 = 11; |
el14ws | 0:4b8288518876 | 74 | int y12 = 12; |
el14ws | 0:4b8288518876 | 75 | int y13 = 13; |
el14ws | 0:4b8288518876 | 76 | int y14 = 14; |
el14ws | 0:4b8288518876 | 77 | int y15 = 15; |
el14ws | 0:4b8288518876 | 78 | int y16 = 16; |
el14ws | 0:4b8288518876 | 79 | int y17 = 17; |
el14ws | 0:4b8288518876 | 80 | int y18 = 18; |
el14ws | 0:4b8288518876 | 81 | int y19 = 19; |
el14ws | 0:4b8288518876 | 82 | int y20 = 20; |
el14ws | 0:4b8288518876 | 83 | int y21 = 21; |
el14ws | 0:4b8288518876 | 84 | int y22 = 22; |
el14ws | 0:4b8288518876 | 85 | int y23 = 23; |
el14ws | 0:4b8288518876 | 86 | int y24 = 24; |
el14ws | 0:4b8288518876 | 87 | int change = 1; |
el14ws | 0:4b8288518876 | 88 | int n[84][48]; |
el14ws | 0:4b8288518876 | 89 | int array[48][84]; |
el14ws | 0:4b8288518876 | 90 | int nj = 48; |
el14ws | 0:4b8288518876 | 91 | int cells[84][48]; |
el14ws | 0:4b8288518876 | 92 | int Score = 0; |
el14ws | 0:4b8288518876 | 93 | int randX; |
el14ws | 0:4b8288518876 | 94 | int randY; |
el14ws | 0:4b8288518876 | 95 | char str[64]; |
el14ws | 0:4b8288518876 | 96 | int pause=0; |
el14ws | 0:4b8288518876 | 97 | |
el14ws | 0:4b8288518876 | 98 | void Menu(); //Start screen |
el14ws | 0:4b8288518876 | 99 | void Welcomescreen(); //Prints Welcome to snake on screen |
el14ws | 0:4b8288518876 | 100 | void clearCells(); //Clears Screen |
el14ws | 0:4b8288518876 | 101 | void checkerBoard(); //produces checkers before game begins |
el14ws | 0:4b8288518876 | 102 | void DrawArray(); //Sets the pixel depending on whether 0 or higher than 1 |
el14ws | 0:4b8288518876 | 103 | void ClearArray();//Checks over each individual pixel and if its 0 it will clear |
el14ws | 0:4b8288518876 | 104 | void GenerateFood();//Generates food at random places |
el14ws | 0:4b8288518876 | 105 | void MakeSnake(); //sets the pixels for the snake |
el14ws | 0:4b8288518876 | 106 | void SnakeGame(); // Game Rules |
el14ws | 0:4b8288518876 | 107 | void MoveSnake(); //moving the snake using the joy stick |
el14ws | 0:4b8288518876 | 108 | void calibrateJoystick(); |
el14ws | 0:4b8288518876 | 109 | void updateJoystick(); |
el14ws | 0:4b8288518876 | 110 | void SnakeGrowing(); |
el14ws | 0:4b8288518876 | 111 | void GameOver();//Game ends |
el14ws | 0:4b8288518876 | 112 | void drawLine(); |
el14ws | 0:4b8288518876 | 113 | void calibrateJoystick(); |
el14ws | 0:4b8288518876 | 114 | void updateJoystick(); |
el14ws | 0:4b8288518876 | 115 | |
el14ws | 0:4b8288518876 | 116 | int main() |
el14ws | 0:4b8288518876 | 117 | { |
el14ws | 0:4b8288518876 | 118 | buttonA.mode(PullDown); |
el14ws | 0:4b8288518876 | 119 | calibrateJoystick(); // get centred values of joystick |
el14ws | 0:4b8288518876 | 120 | pollJoystick.attach(&updateJoystick,1.0/10.0); // read joystick 10 times per second |
el14ws | 0:4b8288518876 | 121 | calibrateJoystick(); |
el14ws | 0:4b8288518876 | 122 | updateJoystick(); |
el14ws | 0:4b8288518876 | 123 | lcd.init(); |
el14ws | 0:4b8288518876 | 124 | Welcomescreen(); |
el14ws | 0:4b8288518876 | 125 | lcd.clear(); |
el14ws | 0:4b8288518876 | 126 | GenerateFood(); |
el14ws | 0:4b8288518876 | 127 | DrawArray(); |
el14ws | 0:4b8288518876 | 128 | Menu(); |
el14ws | 0:4b8288518876 | 129 | while(1) { |
el14ws | 0:4b8288518876 | 130 | |
el14ws | 0:4b8288518876 | 131 | MakeSnake(); |
el14ws | 0:4b8288518876 | 132 | ClearArray(); |
el14ws | 0:4b8288518876 | 133 | DrawArray(); |
el14ws | 0:4b8288518876 | 134 | } |
el14ws | 0:4b8288518876 | 135 | } |
el14ws | 0:4b8288518876 | 136 | //menu screen |
el14ws | 0:4b8288518876 | 137 | void Menu() |
el14ws | 0:4b8288518876 | 138 | { |
el14ws | 0:4b8288518876 | 139 | // first need to initialise display |
el14ws | 0:4b8288518876 | 140 | |
el14ws | 0:4b8288518876 | 141 | lcd.clear(); |
el14ws | 0:4b8288518876 | 142 | lcd.printString("Press Button",6,1); |
el14ws | 0:4b8288518876 | 143 | lcd.printString("To",35,3); |
el14ws | 0:4b8288518876 | 144 | lcd.printString("START",27,5); |
el14ws | 0:4b8288518876 | 145 | wait(0.3); |
el14ws | 0:4b8288518876 | 146 | |
el14ws | 0:4b8288518876 | 147 | while(1) { |
el14ws | 0:4b8288518876 | 148 | if (buttonA==1) { |
el14ws | 0:4b8288518876 | 149 | lcd.clear(); |
el14ws | 0:4b8288518876 | 150 | checkerBoard(); |
el14ws | 0:4b8288518876 | 151 | wait(0.5); |
el14ws | 0:4b8288518876 | 152 | lcd.clear(); |
el14ws | 0:4b8288518876 | 153 | |
el14ws | 0:4b8288518876 | 154 | |
el14ws | 0:4b8288518876 | 155 | while(1) { |
el14ws | 0:4b8288518876 | 156 | |
el14ws | 0:4b8288518876 | 157 | wait(0.005); |
el14ws | 0:4b8288518876 | 158 | SnakeGame(); |
el14ws | 0:4b8288518876 | 159 | if (buttonA==1) { |
el14ws | 0:4b8288518876 | 160 | pause=0; |
el14ws | 0:4b8288518876 | 161 | Menu(); |
el14ws | 0:4b8288518876 | 162 | } |
el14ws | 0:4b8288518876 | 163 | |
el14ws | 0:4b8288518876 | 164 | if (button==1) { |
el14ws | 0:4b8288518876 | 165 | pause=0; |
el14ws | 0:4b8288518876 | 166 | lcd.clear(); |
el14ws | 0:4b8288518876 | 167 | sprintf(str,"%d",Score); |
el14ws | 0:4b8288518876 | 168 | lcd.printString(str,37,2); |
el14ws | 0:4b8288518876 | 169 | wait(1); |
el14ws | 0:4b8288518876 | 170 | } |
el14ws | 0:4b8288518876 | 171 | } |
el14ws | 0:4b8288518876 | 172 | } |
el14ws | 0:4b8288518876 | 173 | } |
el14ws | 0:4b8288518876 | 174 | } |
el14ws | 0:4b8288518876 | 175 | |
el14ws | 0:4b8288518876 | 176 | void Welcomescreen() // Display welcome screen |
el14ws | 0:4b8288518876 | 177 | { |
el14ws | 0:4b8288518876 | 178 | lcd.printString("Welcome",20,1); // display Welcome |
el14ws | 0:4b8288518876 | 179 | wait(0.1); |
el14ws | 0:4b8288518876 | 180 | lcd.printString("To",35,3); // display To |
el14ws | 0:4b8288518876 | 181 | wait(0.1); |
el14ws | 0:4b8288518876 | 182 | lcd.printString("SNAKE",27,5); // display Snake |
el14ws | 0:4b8288518876 | 183 | wait(1); |
el14ws | 0:4b8288518876 | 184 | } |
el14ws | 0:4b8288518876 | 185 | |
el14ws | 0:4b8288518876 | 186 | void checkerBoard() |
el14ws | 0:4b8288518876 | 187 | { |
el14ws | 0:4b8288518876 | 188 | // |
el14ws | 0:4b8288518876 | 189 | for (int i = 0; i < ni ; i+=2) { |
el14ws | 0:4b8288518876 | 190 | for (int j = 0; j < nj ; j+=2) { |
el14ws | 0:4b8288518876 | 191 | lcd.setPixel(i,j); |
el14ws | 0:4b8288518876 | 192 | } |
el14ws | 0:4b8288518876 | 193 | } |
el14ws | 0:4b8288518876 | 194 | lcd.refresh(); |
el14ws | 0:4b8288518876 | 195 | } |
el14ws | 0:4b8288518876 | 196 | |
el14ws | 0:4b8288518876 | 197 | void DrawArray() |
el14ws | 0:4b8288518876 | 198 | { |
el14ws | 0:4b8288518876 | 199 | for(int x=0; x<84; x++) { |
el14ws | 0:4b8288518876 | 200 | for (int y=0; y<48; y++) { |
el14ws | 0:4b8288518876 | 201 | if(array[y][x]>=1) { |
el14ws | 0:4b8288518876 | 202 | lcd.setPixel(x,y); |
el14ws | 0:4b8288518876 | 203 | } else { |
el14ws | 0:4b8288518876 | 204 | lcd.clearPixel(x,y); |
el14ws | 0:4b8288518876 | 205 | } |
el14ws | 0:4b8288518876 | 206 | } |
el14ws | 0:4b8288518876 | 207 | } |
el14ws | 0:4b8288518876 | 208 | lcd.refresh(); |
el14ws | 0:4b8288518876 | 209 | } |
el14ws | 0:4b8288518876 | 210 | |
el14ws | 0:4b8288518876 | 211 | void ClearArray() |
el14ws | 0:4b8288518876 | 212 | { |
el14ws | 0:4b8288518876 | 213 | for(int x=0; x<84; x++) { |
el14ws | 0:4b8288518876 | 214 | for(int y=0; y<48; y++) { |
el14ws | 0:4b8288518876 | 215 | if (array[y][x]==0) { |
el14ws | 0:4b8288518876 | 216 | lcd.clearPixel(x,y); |
el14ws | 0:4b8288518876 | 217 | } else { |
el14ws | 0:4b8288518876 | 218 | lcd.setPixel(x,y); |
el14ws | 0:4b8288518876 | 219 | } |
el14ws | 0:4b8288518876 | 220 | } |
el14ws | 0:4b8288518876 | 221 | } |
el14ws | 0:4b8288518876 | 222 | lcd.refresh(); |
el14ws | 0:4b8288518876 | 223 | } |
el14ws | 0:4b8288518876 | 224 | |
el14ws | 0:4b8288518876 | 225 | void calibrateJoystick()// read default positions of the joystick to calibrate later readings |
el14ws | 0:4b8288518876 | 226 | { |
el14ws | 0:4b8288518876 | 227 | button.mode(PullDown); // must not move during calibration |
el14ws | 0:4b8288518876 | 228 | joystick.x0 = xPot; // initial positions in the range 0.0 to 1.0 (0.5 if centred exactly) |
el14ws | 0:4b8288518876 | 229 | joystick.y0 = yPot; |
el14ws | 0:4b8288518876 | 230 | } |
el14ws | 0:4b8288518876 | 231 | void updateJoystick() |
el14ws | 0:4b8288518876 | 232 | { |
el14ws | 0:4b8288518876 | 233 | joystick.x = xPot - joystick.x0;// read current joystick values relative to calibrated values (in range -0.5 to 0.5, 0.0 is centred) |
el14ws | 0:4b8288518876 | 234 | joystick.y = yPot - joystick.y0;// read button state |
el14ws | 0:4b8288518876 | 235 | joystick.button = button; // calculate direction depending on x,y values |
el14ws | 0:4b8288518876 | 236 | if ( fabs(joystick.y) < DIRECTION_TOLERANCE && fabs(joystick.x) < DIRECTION_TOLERANCE) { // tolerance allows a little lee-way in case joystick not exactly in the stated direction |
el14ws | 0:4b8288518876 | 237 | joystick.direction = CENTRE; |
el14ws | 0:4b8288518876 | 238 | } else if ( joystick.y > DIRECTION_TOLERANCE && fabs(joystick.x) < DIRECTION_TOLERANCE) { |
el14ws | 0:4b8288518876 | 239 | joystick.direction = LEFT; |
el14ws | 0:4b8288518876 | 240 | } else if ( joystick.y < DIRECTION_TOLERANCE && fabs(joystick.x) < DIRECTION_TOLERANCE) { |
el14ws | 0:4b8288518876 | 241 | joystick.direction = RIGHT; |
el14ws | 0:4b8288518876 | 242 | } else if ( joystick.x > DIRECTION_TOLERANCE && fabs(joystick.y) < DIRECTION_TOLERANCE) { |
el14ws | 0:4b8288518876 | 243 | joystick.direction = DOWN; |
el14ws | 0:4b8288518876 | 244 | } else if ( joystick.x < DIRECTION_TOLERANCE && fabs(joystick.y) < DIRECTION_TOLERANCE) { |
el14ws | 0:4b8288518876 | 245 | joystick.direction = UP; |
el14ws | 0:4b8288518876 | 246 | } else { |
el14ws | 0:4b8288518876 | 247 | joystick.direction = UNKNOWN; |
el14ws | 0:4b8288518876 | 248 | } |
el14ws | 0:4b8288518876 | 249 | printFlag = 1;// set flag for printing |
el14ws | 0:4b8288518876 | 250 | } |
el14ws | 0:4b8288518876 | 251 | |
el14ws | 0:4b8288518876 | 252 | void GenerateFood() |
el14ws | 0:4b8288518876 | 253 | { |
el14ws | 0:4b8288518876 | 254 | randX = rand() %83; //make random number between 0 - 84 |
el14ws | 0:4b8288518876 | 255 | randY = rand() %47; //make random number between 0 - 48 |
el14ws | 0:4b8288518876 | 256 | while(array[randY][randX]) { |
el14ws | 0:4b8288518876 | 257 | randX= rand() %83; |
el14ws | 0:4b8288518876 | 258 | randY= rand() %47; |
el14ws | 0:4b8288518876 | 259 | } |
el14ws | 0:4b8288518876 | 260 | array[randY][randX]= 5; |
el14ws | 0:4b8288518876 | 261 | } |
el14ws | 0:4b8288518876 | 262 | void MakeSnake() |
el14ws | 0:4b8288518876 | 263 | { |
el14ws | 0:4b8288518876 | 264 | array[y+36][x+5]= 1; |
el14ws | 0:4b8288518876 | 265 | array[y1+36][x1+5]= 1; |
el14ws | 0:4b8288518876 | 266 | array[y2+36][x2+5]= 1; |
el14ws | 0:4b8288518876 | 267 | array[y3+36][x3+5]= 1; |
el14ws | 0:4b8288518876 | 268 | array[y4+36][x4+5]= 1; |
el14ws | 0:4b8288518876 | 269 | array[y5+36][x5+5]= 0; |
el14ws | 0:4b8288518876 | 270 | array[y6+36][x6+5]= 0; |
el14ws | 0:4b8288518876 | 271 | array[y7+36][x7+5]= 0; |
el14ws | 0:4b8288518876 | 272 | array[y8+36][x7+5]= 0; |
el14ws | 0:4b8288518876 | 273 | array[y9+36][x9+5]= 0; |
el14ws | 0:4b8288518876 | 274 | array[y10+36][x10+5]= 0; |
el14ws | 0:4b8288518876 | 275 | array[y11+36][x11+5]= 0; |
el14ws | 0:4b8288518876 | 276 | array[y12+36][x12+5]= 0; |
el14ws | 0:4b8288518876 | 277 | array[y13+36][x13+5]= 0; |
el14ws | 0:4b8288518876 | 278 | array[y14+36][x14+5]= 0; |
el14ws | 0:4b8288518876 | 279 | array[y15+36][x15+5]= 0; |
el14ws | 0:4b8288518876 | 280 | array[y16+36][x16+5]= 0; |
el14ws | 0:4b8288518876 | 281 | array[y17+36][x17+5]= 0; |
el14ws | 0:4b8288518876 | 282 | array[y18+36][x18+5]= 0; |
el14ws | 0:4b8288518876 | 283 | array[y19+36][x19+5]= 0; |
el14ws | 0:4b8288518876 | 284 | array[y20+36][x20+5]= 0; |
el14ws | 0:4b8288518876 | 285 | array[y21+36][x21+5]= 0; |
el14ws | 0:4b8288518876 | 286 | array[y22+36][x22+5]= 0; |
el14ws | 0:4b8288518876 | 287 | array[y23+36][x23+5]= 0; |
el14ws | 0:4b8288518876 | 288 | array[y24+36][x24+5]= 0; |
el14ws | 0:4b8288518876 | 289 | } |
el14ws | 0:4b8288518876 | 290 | |
el14ws | 0:4b8288518876 | 291 | void SnakeGame() |
el14ws | 0:4b8288518876 | 292 | { |
el14ws | 0:4b8288518876 | 293 | MakeSnake(); |
el14ws | 0:4b8288518876 | 294 | ClearArray(); |
el14ws | 0:4b8288518876 | 295 | DrawArray(); |
el14ws | 0:4b8288518876 | 296 | SnakeGrowing(); |
el14ws | 0:4b8288518876 | 297 | if(pause==0) { |
el14ws | 0:4b8288518876 | 298 | MoveSnake(); |
el14ws | 0:4b8288518876 | 299 | } |
el14ws | 0:4b8288518876 | 300 | if(y+36==randY && x+5==randX) { |
el14ws | 0:4b8288518876 | 301 | GenerateFood(); |
el14ws | 0:4b8288518876 | 302 | |
el14ws | 0:4b8288518876 | 303 | Score= Score+10; |
el14ws | 0:4b8288518876 | 304 | } |
el14ws | 0:4b8288518876 | 305 | |
el14ws | 0:4b8288518876 | 306 | } |
el14ws | 0:4b8288518876 | 307 | void MoveSnake() |
el14ws | 0:4b8288518876 | 308 | { |
el14ws | 0:4b8288518876 | 309 | array[y+36][x+5]= 0; |
el14ws | 0:4b8288518876 | 310 | |
el14ws | 0:4b8288518876 | 311 | array[y1+36][x1+5]= 0; |
el14ws | 0:4b8288518876 | 312 | |
el14ws | 0:4b8288518876 | 313 | array[y2+36][x2+5]= 0; |
el14ws | 0:4b8288518876 | 314 | |
el14ws | 0:4b8288518876 | 315 | array[y3+36][x3+5]= 0; |
el14ws | 0:4b8288518876 | 316 | |
el14ws | 0:4b8288518876 | 317 | array[y4+36][x4+5]= 0; |
el14ws | 0:4b8288518876 | 318 | |
el14ws | 0:4b8288518876 | 319 | array[y5+36][x5+5]= 0; |
el14ws | 0:4b8288518876 | 320 | |
el14ws | 0:4b8288518876 | 321 | array[y6+36][x6+5]= 0; |
el14ws | 0:4b8288518876 | 322 | |
el14ws | 0:4b8288518876 | 323 | array[y7+36][x7+5]= 0; |
el14ws | 0:4b8288518876 | 324 | |
el14ws | 0:4b8288518876 | 325 | array[y8+36][x8+5]= 0; |
el14ws | 0:4b8288518876 | 326 | |
el14ws | 0:4b8288518876 | 327 | array[y9+36][x9+5]= 0; |
el14ws | 0:4b8288518876 | 328 | |
el14ws | 0:4b8288518876 | 329 | array[y10+36][x10+5]= 0; |
el14ws | 0:4b8288518876 | 330 | |
el14ws | 0:4b8288518876 | 331 | array[y11+36][x11+5]= 0; |
el14ws | 0:4b8288518876 | 332 | |
el14ws | 0:4b8288518876 | 333 | array[y12+36][x12+5]= 0; |
el14ws | 0:4b8288518876 | 334 | |
el14ws | 0:4b8288518876 | 335 | array[y13+36][x13+5]= 0; |
el14ws | 0:4b8288518876 | 336 | |
el14ws | 0:4b8288518876 | 337 | array[y14+36][x14+5]= 0; |
el14ws | 0:4b8288518876 | 338 | |
el14ws | 0:4b8288518876 | 339 | array[y15+36][x15+5]= 0; |
el14ws | 0:4b8288518876 | 340 | |
el14ws | 0:4b8288518876 | 341 | array[y16+36][x16+5]= 0; |
el14ws | 0:4b8288518876 | 342 | |
el14ws | 0:4b8288518876 | 343 | array[y17+36][x17+5]= 0; |
el14ws | 0:4b8288518876 | 344 | |
el14ws | 0:4b8288518876 | 345 | array[y18+36][x18+5]= 0; |
el14ws | 0:4b8288518876 | 346 | |
el14ws | 0:4b8288518876 | 347 | array[y19+36][x19+5]= 0; |
el14ws | 0:4b8288518876 | 348 | |
el14ws | 0:4b8288518876 | 349 | array[y20+36][x20+5]= 0; |
el14ws | 0:4b8288518876 | 350 | |
el14ws | 0:4b8288518876 | 351 | array[y21+36][x21+5]= 0; |
el14ws | 0:4b8288518876 | 352 | |
el14ws | 0:4b8288518876 | 353 | array[y22+36][x22+5]= 0; |
el14ws | 0:4b8288518876 | 354 | |
el14ws | 0:4b8288518876 | 355 | array[y23+36][x23+5]= 0; |
el14ws | 0:4b8288518876 | 356 | |
el14ws | 0:4b8288518876 | 357 | array[y24+36][x24+5]= 0; |
el14ws | 0:4b8288518876 | 358 | |
el14ws | 0:4b8288518876 | 359 | x24=x23; |
el14ws | 0:4b8288518876 | 360 | y24=y23; |
el14ws | 0:4b8288518876 | 361 | x23=x22; |
el14ws | 0:4b8288518876 | 362 | y23=y22; |
el14ws | 0:4b8288518876 | 363 | x22=x21; |
el14ws | 0:4b8288518876 | 364 | y22=y21; |
el14ws | 0:4b8288518876 | 365 | x21=x20; |
el14ws | 0:4b8288518876 | 366 | y21=y20; |
el14ws | 0:4b8288518876 | 367 | x20=x19; |
el14ws | 0:4b8288518876 | 368 | y20=y19; |
el14ws | 0:4b8288518876 | 369 | x19=x18; |
el14ws | 0:4b8288518876 | 370 | y19=y18; |
el14ws | 0:4b8288518876 | 371 | x18=x17; |
el14ws | 0:4b8288518876 | 372 | y18=y17; |
el14ws | 0:4b8288518876 | 373 | x17=x16; |
el14ws | 0:4b8288518876 | 374 | y17=y16; |
el14ws | 0:4b8288518876 | 375 | x16=x15; |
el14ws | 0:4b8288518876 | 376 | y16=y15; |
el14ws | 0:4b8288518876 | 377 | x15=x14; |
el14ws | 0:4b8288518876 | 378 | y15=y14; |
el14ws | 0:4b8288518876 | 379 | x14=x13; |
el14ws | 0:4b8288518876 | 380 | y14=y13; |
el14ws | 0:4b8288518876 | 381 | x13=x12; |
el14ws | 0:4b8288518876 | 382 | y13=y12; |
el14ws | 0:4b8288518876 | 383 | x12=x11; |
el14ws | 0:4b8288518876 | 384 | y12=y11; |
el14ws | 0:4b8288518876 | 385 | x11=x10; |
el14ws | 0:4b8288518876 | 386 | y11=y10; |
el14ws | 0:4b8288518876 | 387 | x10=x9; |
el14ws | 0:4b8288518876 | 388 | y10=y9; |
el14ws | 0:4b8288518876 | 389 | x9=x8; |
el14ws | 0:4b8288518876 | 390 | y9=y8; |
el14ws | 0:4b8288518876 | 391 | x8=x7; |
el14ws | 0:4b8288518876 | 392 | y8=y7; |
el14ws | 0:4b8288518876 | 393 | x7=x6; |
el14ws | 0:4b8288518876 | 394 | y7=y6; |
el14ws | 0:4b8288518876 | 395 | x6=x5; |
el14ws | 0:4b8288518876 | 396 | y6=y5; |
el14ws | 0:4b8288518876 | 397 | x5=x4; |
el14ws | 0:4b8288518876 | 398 | y5=y4; |
el14ws | 0:4b8288518876 | 399 | x4=x3; |
el14ws | 0:4b8288518876 | 400 | y4=y3; |
el14ws | 0:4b8288518876 | 401 | x3=x2; |
el14ws | 0:4b8288518876 | 402 | y3=y2; |
el14ws | 0:4b8288518876 | 403 | x2=x1; |
el14ws | 0:4b8288518876 | 404 | y2=y1; |
el14ws | 0:4b8288518876 | 405 | x1 = x; |
el14ws | 0:4b8288518876 | 406 | y1 = y; |
el14ws | 0:4b8288518876 | 407 | if (joystick.direction == CENTRE) { |
el14ws | 0:4b8288518876 | 408 | //lcd.printString("CENTRE",20,1); // display welcome |
el14ws | 0:4b8288518876 | 409 | wait(0.05); |
el14ws | 0:4b8288518876 | 410 | } else if (joystick.direction == UP) { |
el14ws | 0:4b8288518876 | 411 | //lcd.printString("UP",20,1); // display welcome |
el14ws | 0:4b8288518876 | 412 | wait(0.05); |
el14ws | 0:4b8288518876 | 413 | change = 1; |
el14ws | 0:4b8288518876 | 414 | } else if (joystick.direction == DOWN) { |
el14ws | 0:4b8288518876 | 415 | //lcd.printString("DOWN",20,1); // display welcome |
el14ws | 0:4b8288518876 | 416 | wait(0.05); |
el14ws | 0:4b8288518876 | 417 | change = 2; |
el14ws | 0:4b8288518876 | 418 | } else if (joystick.direction == LEFT) { |
el14ws | 0:4b8288518876 | 419 | //lcd.printString("LEFT",20,1); // display welcome |
el14ws | 0:4b8288518876 | 420 | wait(0.05); |
el14ws | 0:4b8288518876 | 421 | change = 3; |
el14ws | 0:4b8288518876 | 422 | } else if (joystick.direction == RIGHT) { |
el14ws | 0:4b8288518876 | 423 | //lcd.printString("RIGHT",20,1); // display welcome |
el14ws | 0:4b8288518876 | 424 | wait(0.05); |
el14ws | 0:4b8288518876 | 425 | change = 4; |
el14ws | 0:4b8288518876 | 426 | } |
el14ws | 0:4b8288518876 | 427 | if (change == 1) { |
el14ws | 0:4b8288518876 | 428 | y--; |
el14ws | 0:4b8288518876 | 429 | } else if (change == 2) { |
el14ws | 0:4b8288518876 | 430 | y++; |
el14ws | 0:4b8288518876 | 431 | } else if (change == 3) { |
el14ws | 0:4b8288518876 | 432 | x--; |
el14ws | 0:4b8288518876 | 433 | } else if (change == 4) { |
el14ws | 0:4b8288518876 | 434 | x++; |
el14ws | 0:4b8288518876 | 435 | } |
el14ws | 0:4b8288518876 | 436 | |
el14ws | 0:4b8288518876 | 437 | } |
el14ws | 0:4b8288518876 | 438 | void SnakeGrowing() |
el14ws | 0:4b8288518876 | 439 | { |
el14ws | 0:4b8288518876 | 440 | |
el14ws | 0:4b8288518876 | 441 | |
el14ws | 0:4b8288518876 | 442 | if(Score>=10) { |
el14ws | 0:4b8288518876 | 443 | array[y+36][x+5]= 1; |
el14ws | 0:4b8288518876 | 444 | |
el14ws | 0:4b8288518876 | 445 | array[y1+36][x1+5]= 1; |
el14ws | 0:4b8288518876 | 446 | |
el14ws | 0:4b8288518876 | 447 | array[y2+36][x2+5]= 1; |
el14ws | 0:4b8288518876 | 448 | |
el14ws | 0:4b8288518876 | 449 | array[y3+36][x3+5]= 1; |
el14ws | 0:4b8288518876 | 450 | |
el14ws | 0:4b8288518876 | 451 | array[y4+36][x4+5]= 1; |
el14ws | 0:4b8288518876 | 452 | |
el14ws | 0:4b8288518876 | 453 | array[y5+36][x5+5]= 1; |
el14ws | 0:4b8288518876 | 454 | |
el14ws | 0:4b8288518876 | 455 | array[y6+36][x6+5]= 1; |
el14ws | 0:4b8288518876 | 456 | |
el14ws | 0:4b8288518876 | 457 | } |
el14ws | 0:4b8288518876 | 458 | |
el14ws | 0:4b8288518876 | 459 | |
el14ws | 0:4b8288518876 | 460 | if(Score>=20) { |
el14ws | 0:4b8288518876 | 461 | array[y+36][x+5]= 1; |
el14ws | 0:4b8288518876 | 462 | |
el14ws | 0:4b8288518876 | 463 | array[y1+36][x1+5]= 1; |
el14ws | 0:4b8288518876 | 464 | |
el14ws | 0:4b8288518876 | 465 | array[y2+36][x2+5]= 1; |
el14ws | 0:4b8288518876 | 466 | |
el14ws | 0:4b8288518876 | 467 | array[y3+36][x3+5]= 1; |
el14ws | 0:4b8288518876 | 468 | |
el14ws | 0:4b8288518876 | 469 | array[y4+36][x4+5]= 1; |
el14ws | 0:4b8288518876 | 470 | |
el14ws | 0:4b8288518876 | 471 | array[y5+36][x5+5]= 1; |
el14ws | 0:4b8288518876 | 472 | |
el14ws | 0:4b8288518876 | 473 | array[y6+36][x6+5]= 1; |
el14ws | 0:4b8288518876 | 474 | |
el14ws | 0:4b8288518876 | 475 | array[y7+36][x7+5]= 1; |
el14ws | 0:4b8288518876 | 476 | |
el14ws | 0:4b8288518876 | 477 | array[y8+36][x8+5]= 1; |
el14ws | 0:4b8288518876 | 478 | } |
el14ws | 0:4b8288518876 | 479 | if(Score>=30) { |
el14ws | 0:4b8288518876 | 480 | array[y+36][x+5]= 1; |
el14ws | 0:4b8288518876 | 481 | |
el14ws | 0:4b8288518876 | 482 | array[y1+36][x1+5]= 1; |
el14ws | 0:4b8288518876 | 483 | |
el14ws | 0:4b8288518876 | 484 | array[y2+36][x2+5]= 1; |
el14ws | 0:4b8288518876 | 485 | |
el14ws | 0:4b8288518876 | 486 | array[y3+36][x3+5]= 1; |
el14ws | 0:4b8288518876 | 487 | |
el14ws | 0:4b8288518876 | 488 | array[y4+36][x4+5]= 1; |
el14ws | 0:4b8288518876 | 489 | |
el14ws | 0:4b8288518876 | 490 | array[y5+36][x5+5]= 1; |
el14ws | 0:4b8288518876 | 491 | |
el14ws | 0:4b8288518876 | 492 | array[y6+36][x6+5]= 1; |
el14ws | 0:4b8288518876 | 493 | |
el14ws | 0:4b8288518876 | 494 | array[y7+36][x7+5]= 1; |
el14ws | 0:4b8288518876 | 495 | |
el14ws | 0:4b8288518876 | 496 | array[y8+36][x8+5]= 1; |
el14ws | 0:4b8288518876 | 497 | |
el14ws | 0:4b8288518876 | 498 | array[y9+36][x9+5]= 1; |
el14ws | 0:4b8288518876 | 499 | |
el14ws | 0:4b8288518876 | 500 | array[y10+36][x10+5]= 1; |
el14ws | 0:4b8288518876 | 501 | |
el14ws | 0:4b8288518876 | 502 | } |
el14ws | 0:4b8288518876 | 503 | if(Score>=40) { |
el14ws | 0:4b8288518876 | 504 | array[y+36][x+5]= 1; |
el14ws | 0:4b8288518876 | 505 | |
el14ws | 0:4b8288518876 | 506 | array[y1+36][x1+5]= 1; |
el14ws | 0:4b8288518876 | 507 | |
el14ws | 0:4b8288518876 | 508 | array[y2+36][x2+5]= 1; |
el14ws | 0:4b8288518876 | 509 | |
el14ws | 0:4b8288518876 | 510 | array[y3+36][x3+5]= 1; |
el14ws | 0:4b8288518876 | 511 | |
el14ws | 0:4b8288518876 | 512 | array[y4+36][x4+5]= 1; |
el14ws | 0:4b8288518876 | 513 | |
el14ws | 0:4b8288518876 | 514 | array[y5+36][x5+5]= 1; |
el14ws | 0:4b8288518876 | 515 | |
el14ws | 0:4b8288518876 | 516 | array[y6+36][x6+5]= 1; |
el14ws | 0:4b8288518876 | 517 | |
el14ws | 0:4b8288518876 | 518 | array[y7+36][x7+5]= 1; |
el14ws | 0:4b8288518876 | 519 | |
el14ws | 0:4b8288518876 | 520 | array[y8+36][x8+5]= 1; |
el14ws | 0:4b8288518876 | 521 | |
el14ws | 0:4b8288518876 | 522 | array[y9+36][x9+5]= 1; |
el14ws | 0:4b8288518876 | 523 | |
el14ws | 0:4b8288518876 | 524 | array[y10+36][x10+5]= 1; |
el14ws | 0:4b8288518876 | 525 | |
el14ws | 0:4b8288518876 | 526 | array[y11+36][x11+5]= 1; |
el14ws | 0:4b8288518876 | 527 | |
el14ws | 0:4b8288518876 | 528 | array[y12+36][x12+5]= 1; |
el14ws | 0:4b8288518876 | 529 | |
el14ws | 0:4b8288518876 | 530 | } |
el14ws | 0:4b8288518876 | 531 | if(Score>=50) { |
el14ws | 0:4b8288518876 | 532 | array[y+36][x+5]= 1; |
el14ws | 0:4b8288518876 | 533 | |
el14ws | 0:4b8288518876 | 534 | array[y1+36][x1+5]= 1; |
el14ws | 0:4b8288518876 | 535 | |
el14ws | 0:4b8288518876 | 536 | array[y2+36][x2+5]= 1; |
el14ws | 0:4b8288518876 | 537 | |
el14ws | 0:4b8288518876 | 538 | array[y3+36][x3+5]= 1; |
el14ws | 0:4b8288518876 | 539 | |
el14ws | 0:4b8288518876 | 540 | array[y4+36][x4+5]= 1; |
el14ws | 0:4b8288518876 | 541 | |
el14ws | 0:4b8288518876 | 542 | array[y5+36][x5+5]= 1; |
el14ws | 0:4b8288518876 | 543 | |
el14ws | 0:4b8288518876 | 544 | array[y6+36][x6+5]= 1; |
el14ws | 0:4b8288518876 | 545 | |
el14ws | 0:4b8288518876 | 546 | array[y7+36][x7+5]= 1; |
el14ws | 0:4b8288518876 | 547 | |
el14ws | 0:4b8288518876 | 548 | array[y8+36][x8+5]= 1; |
el14ws | 0:4b8288518876 | 549 | |
el14ws | 0:4b8288518876 | 550 | array[y9+36][x9+5]= 1; |
el14ws | 0:4b8288518876 | 551 | |
el14ws | 0:4b8288518876 | 552 | array[y10+36][x10+5]= 1; |
el14ws | 0:4b8288518876 | 553 | |
el14ws | 0:4b8288518876 | 554 | array[y11+36][x11+5]= 1; |
el14ws | 0:4b8288518876 | 555 | |
el14ws | 0:4b8288518876 | 556 | array[y12+36][x12+5]= 1; |
el14ws | 0:4b8288518876 | 557 | |
el14ws | 0:4b8288518876 | 558 | array[y13+36][x13+5]= 1; |
el14ws | 0:4b8288518876 | 559 | |
el14ws | 0:4b8288518876 | 560 | array[y14+36][x14+5]= 1; |
el14ws | 0:4b8288518876 | 561 | |
el14ws | 0:4b8288518876 | 562 | } |
el14ws | 0:4b8288518876 | 563 | if(Score>=60) { |
el14ws | 0:4b8288518876 | 564 | array[y+36][x+5]= 1; |
el14ws | 0:4b8288518876 | 565 | |
el14ws | 0:4b8288518876 | 566 | array[y1+36][x1+5]= 1; |
el14ws | 0:4b8288518876 | 567 | |
el14ws | 0:4b8288518876 | 568 | array[y2+36][x2+5]= 1; |
el14ws | 0:4b8288518876 | 569 | |
el14ws | 0:4b8288518876 | 570 | array[y3+36][x3+5]= 1; |
el14ws | 0:4b8288518876 | 571 | |
el14ws | 0:4b8288518876 | 572 | array[y4+36][x4+5]= 1; |
el14ws | 0:4b8288518876 | 573 | |
el14ws | 0:4b8288518876 | 574 | array[y5+36][x5+5]= 1; |
el14ws | 0:4b8288518876 | 575 | |
el14ws | 0:4b8288518876 | 576 | array[y6+36][x6+5]= 1; |
el14ws | 0:4b8288518876 | 577 | |
el14ws | 0:4b8288518876 | 578 | array[y7+36][x7+5]= 1; |
el14ws | 0:4b8288518876 | 579 | |
el14ws | 0:4b8288518876 | 580 | array[y8+36][x8+5]= 1; |
el14ws | 0:4b8288518876 | 581 | |
el14ws | 0:4b8288518876 | 582 | array[y9+36][x9+5]= 1; |
el14ws | 0:4b8288518876 | 583 | |
el14ws | 0:4b8288518876 | 584 | array[y10+36][x10+5]= 1; |
el14ws | 0:4b8288518876 | 585 | |
el14ws | 0:4b8288518876 | 586 | array[y11+36][x11+5]= 1; |
el14ws | 0:4b8288518876 | 587 | |
el14ws | 0:4b8288518876 | 588 | array[y12+36][x12+5]= 1; |
el14ws | 0:4b8288518876 | 589 | |
el14ws | 0:4b8288518876 | 590 | array[y13+36][x13+5]= 1; |
el14ws | 0:4b8288518876 | 591 | |
el14ws | 0:4b8288518876 | 592 | array[y14+36][x14+5]= 1; |
el14ws | 0:4b8288518876 | 593 | |
el14ws | 0:4b8288518876 | 594 | array[y15+36][x15+5]= 1; |
el14ws | 0:4b8288518876 | 595 | |
el14ws | 0:4b8288518876 | 596 | array[y16+36][x16+5]= 1; |
el14ws | 0:4b8288518876 | 597 | |
el14ws | 0:4b8288518876 | 598 | } |
el14ws | 0:4b8288518876 | 599 | if(Score>=70) { |
el14ws | 0:4b8288518876 | 600 | array[y+36][x+5]= 1; |
el14ws | 0:4b8288518876 | 601 | |
el14ws | 0:4b8288518876 | 602 | array[y1+36][x1+5]= 1; |
el14ws | 0:4b8288518876 | 603 | |
el14ws | 0:4b8288518876 | 604 | array[y2+36][x2+5]= 1; |
el14ws | 0:4b8288518876 | 605 | |
el14ws | 0:4b8288518876 | 606 | array[y3+36][x3+5]= 1; |
el14ws | 0:4b8288518876 | 607 | |
el14ws | 0:4b8288518876 | 608 | array[y4+36][x4+5]= 1; |
el14ws | 0:4b8288518876 | 609 | |
el14ws | 0:4b8288518876 | 610 | array[y5+36][x5+5]= 1; |
el14ws | 0:4b8288518876 | 611 | |
el14ws | 0:4b8288518876 | 612 | array[y6+36][x6+5]= 1; |
el14ws | 0:4b8288518876 | 613 | |
el14ws | 0:4b8288518876 | 614 | array[y7+36][x7+5]= 1; |
el14ws | 0:4b8288518876 | 615 | |
el14ws | 0:4b8288518876 | 616 | array[y8+36][x8+5]= 1; |
el14ws | 0:4b8288518876 | 617 | |
el14ws | 0:4b8288518876 | 618 | array[y9+36][x9+5]= 1; |
el14ws | 0:4b8288518876 | 619 | |
el14ws | 0:4b8288518876 | 620 | array[y10+36][x10+5]= 1; |
el14ws | 0:4b8288518876 | 621 | |
el14ws | 0:4b8288518876 | 622 | array[y11+36][x11+5]= 1; |
el14ws | 0:4b8288518876 | 623 | |
el14ws | 0:4b8288518876 | 624 | array[y12+36][x12+5]= 1; |
el14ws | 0:4b8288518876 | 625 | |
el14ws | 0:4b8288518876 | 626 | array[y13+36][x13+5]= 1; |
el14ws | 0:4b8288518876 | 627 | |
el14ws | 0:4b8288518876 | 628 | array[y14+36][x14+5]= 1; |
el14ws | 0:4b8288518876 | 629 | |
el14ws | 0:4b8288518876 | 630 | array[y15+36][x15+5]= 1; |
el14ws | 0:4b8288518876 | 631 | |
el14ws | 0:4b8288518876 | 632 | array[y16+36][x16+5]= 1; |
el14ws | 0:4b8288518876 | 633 | |
el14ws | 0:4b8288518876 | 634 | array[y17+36][x17+5]= 1; |
el14ws | 0:4b8288518876 | 635 | |
el14ws | 0:4b8288518876 | 636 | array[y18+36][x18+5]= 1; |
el14ws | 0:4b8288518876 | 637 | |
el14ws | 0:4b8288518876 | 638 | } |
el14ws | 0:4b8288518876 | 639 | if(Score>=80) { |
el14ws | 0:4b8288518876 | 640 | array[y+36][x+5]= 1; |
el14ws | 0:4b8288518876 | 641 | |
el14ws | 0:4b8288518876 | 642 | array[y1+36][x1+5]= 1; |
el14ws | 0:4b8288518876 | 643 | |
el14ws | 0:4b8288518876 | 644 | array[y2+36][x2+5]= 1; |
el14ws | 0:4b8288518876 | 645 | |
el14ws | 0:4b8288518876 | 646 | array[y3+36][x3+5]= 1; |
el14ws | 0:4b8288518876 | 647 | |
el14ws | 0:4b8288518876 | 648 | array[y4+36][x4+5]= 1; |
el14ws | 0:4b8288518876 | 649 | |
el14ws | 0:4b8288518876 | 650 | array[y5+36][x5+5]= 1; |
el14ws | 0:4b8288518876 | 651 | |
el14ws | 0:4b8288518876 | 652 | array[y6+36][x6+5]= 1; |
el14ws | 0:4b8288518876 | 653 | |
el14ws | 0:4b8288518876 | 654 | array[y7+36][x7+5]= 1; |
el14ws | 0:4b8288518876 | 655 | |
el14ws | 0:4b8288518876 | 656 | array[y8+36][x8+5]= 1; |
el14ws | 0:4b8288518876 | 657 | |
el14ws | 0:4b8288518876 | 658 | array[y9+36][x9+5]= 1; |
el14ws | 0:4b8288518876 | 659 | |
el14ws | 0:4b8288518876 | 660 | array[y10+36][x10+5]= 1; |
el14ws | 0:4b8288518876 | 661 | |
el14ws | 0:4b8288518876 | 662 | array[y11+36][x11+5]= 1; |
el14ws | 0:4b8288518876 | 663 | |
el14ws | 0:4b8288518876 | 664 | array[y12+36][x12+5]= 1; |
el14ws | 0:4b8288518876 | 665 | |
el14ws | 0:4b8288518876 | 666 | array[y13+36][x13+5]= 1; |
el14ws | 0:4b8288518876 | 667 | |
el14ws | 0:4b8288518876 | 668 | array[y14+36][x14+5]= 1; |
el14ws | 0:4b8288518876 | 669 | |
el14ws | 0:4b8288518876 | 670 | array[y15+36][x15+5]= 1; |
el14ws | 0:4b8288518876 | 671 | |
el14ws | 0:4b8288518876 | 672 | array[y16+36][x16+5]= 1; |
el14ws | 0:4b8288518876 | 673 | |
el14ws | 0:4b8288518876 | 674 | array[y17+36][x17+5]= 1; |
el14ws | 0:4b8288518876 | 675 | |
el14ws | 0:4b8288518876 | 676 | array[y18+36][x18+5]= 1; |
el14ws | 0:4b8288518876 | 677 | |
el14ws | 0:4b8288518876 | 678 | array[y19+36][x19+5]= 1; |
el14ws | 0:4b8288518876 | 679 | |
el14ws | 0:4b8288518876 | 680 | array[y20+36][x20+5]= 1; |
el14ws | 0:4b8288518876 | 681 | |
el14ws | 0:4b8288518876 | 682 | } |
el14ws | 0:4b8288518876 | 683 | if(Score>=90) { |
el14ws | 0:4b8288518876 | 684 | array[y+36][x+5]= 1; |
el14ws | 0:4b8288518876 | 685 | |
el14ws | 0:4b8288518876 | 686 | array[y1+36][x1+5]= 1; |
el14ws | 0:4b8288518876 | 687 | |
el14ws | 0:4b8288518876 | 688 | array[y2+36][x2+5]= 1; |
el14ws | 0:4b8288518876 | 689 | |
el14ws | 0:4b8288518876 | 690 | array[y3+36][x3+5]= 1; |
el14ws | 0:4b8288518876 | 691 | |
el14ws | 0:4b8288518876 | 692 | array[y4+36][x4+5]= 1; |
el14ws | 0:4b8288518876 | 693 | |
el14ws | 0:4b8288518876 | 694 | array[y5+36][x5+5]= 1; |
el14ws | 0:4b8288518876 | 695 | |
el14ws | 0:4b8288518876 | 696 | array[y6+36][x6+5]= 1; |
el14ws | 0:4b8288518876 | 697 | |
el14ws | 0:4b8288518876 | 698 | array[y7+36][x7+5]= 1; |
el14ws | 0:4b8288518876 | 699 | |
el14ws | 0:4b8288518876 | 700 | array[y8+36][x8+5]= 1; |
el14ws | 0:4b8288518876 | 701 | |
el14ws | 0:4b8288518876 | 702 | array[y9+36][x9+5]= 1; |
el14ws | 0:4b8288518876 | 703 | |
el14ws | 0:4b8288518876 | 704 | array[y10+36][x10+5]= 1; |
el14ws | 0:4b8288518876 | 705 | |
el14ws | 0:4b8288518876 | 706 | array[y11+36][x11+5]= 1; |
el14ws | 0:4b8288518876 | 707 | |
el14ws | 0:4b8288518876 | 708 | array[y12+36][x12+5]= 1; |
el14ws | 0:4b8288518876 | 709 | |
el14ws | 0:4b8288518876 | 710 | array[y13+36][x13+5]= 1; |
el14ws | 0:4b8288518876 | 711 | |
el14ws | 0:4b8288518876 | 712 | array[y14+36][x14+5]= 1; |
el14ws | 0:4b8288518876 | 713 | |
el14ws | 0:4b8288518876 | 714 | array[y15+36][x15+5]= 1; |
el14ws | 0:4b8288518876 | 715 | |
el14ws | 0:4b8288518876 | 716 | array[y16+36][x16+5]= 1; |
el14ws | 0:4b8288518876 | 717 | |
el14ws | 0:4b8288518876 | 718 | array[y17+36][x17+5]= 1; |
el14ws | 0:4b8288518876 | 719 | |
el14ws | 0:4b8288518876 | 720 | array[y18+36][x18+5]= 1; |
el14ws | 0:4b8288518876 | 721 | |
el14ws | 0:4b8288518876 | 722 | array[y19+36][x19+5]= 1; |
el14ws | 0:4b8288518876 | 723 | |
el14ws | 0:4b8288518876 | 724 | array[y20+36][x20+5]= 1; |
el14ws | 0:4b8288518876 | 725 | |
el14ws | 0:4b8288518876 | 726 | array[y21+36][x21+5]= 1; |
el14ws | 0:4b8288518876 | 727 | |
el14ws | 0:4b8288518876 | 728 | array[y22+36][x22+5]= 1; |
el14ws | 0:4b8288518876 | 729 | |
el14ws | 0:4b8288518876 | 730 | } |
el14ws | 0:4b8288518876 | 731 | if(Score>=100) { |
el14ws | 0:4b8288518876 | 732 | array[y+36][x+5]= 1; |
el14ws | 0:4b8288518876 | 733 | |
el14ws | 0:4b8288518876 | 734 | array[y1+36][x1+5]= 1; |
el14ws | 0:4b8288518876 | 735 | |
el14ws | 0:4b8288518876 | 736 | array[y2+36][x2+5]= 1; |
el14ws | 0:4b8288518876 | 737 | |
el14ws | 0:4b8288518876 | 738 | array[y3+36][x3+5]= 1; |
el14ws | 0:4b8288518876 | 739 | |
el14ws | 0:4b8288518876 | 740 | array[y4+36][x4+5]= 1; |
el14ws | 0:4b8288518876 | 741 | |
el14ws | 0:4b8288518876 | 742 | array[y5+36][x5+5]= 1; |
el14ws | 0:4b8288518876 | 743 | |
el14ws | 0:4b8288518876 | 744 | array[y6+36][x6+5]= 1; |
el14ws | 0:4b8288518876 | 745 | |
el14ws | 0:4b8288518876 | 746 | array[y7+36][x7+5]= 1; |
el14ws | 0:4b8288518876 | 747 | |
el14ws | 0:4b8288518876 | 748 | array[y8+36][x8+5]= 1; |
el14ws | 0:4b8288518876 | 749 | |
el14ws | 0:4b8288518876 | 750 | array[y9+36][x9+5]= 1; |
el14ws | 0:4b8288518876 | 751 | |
el14ws | 0:4b8288518876 | 752 | array[y10+36][x10+5]= 1; |
el14ws | 0:4b8288518876 | 753 | |
el14ws | 0:4b8288518876 | 754 | array[y11+36][x11+5]= 1; |
el14ws | 0:4b8288518876 | 755 | |
el14ws | 0:4b8288518876 | 756 | array[y12+36][x12+5]= 1; |
el14ws | 0:4b8288518876 | 757 | |
el14ws | 0:4b8288518876 | 758 | array[y13+36][x13+5]= 1; |
el14ws | 0:4b8288518876 | 759 | |
el14ws | 0:4b8288518876 | 760 | array[y14+36][x14+5]= 1; |
el14ws | 0:4b8288518876 | 761 | |
el14ws | 0:4b8288518876 | 762 | array[y15+36][x15+5]= 1; |
el14ws | 0:4b8288518876 | 763 | |
el14ws | 0:4b8288518876 | 764 | array[y16+36][x16+5]= 1; |
el14ws | 0:4b8288518876 | 765 | |
el14ws | 0:4b8288518876 | 766 | array[y17+36][x17+5]= 1; |
el14ws | 0:4b8288518876 | 767 | |
el14ws | 0:4b8288518876 | 768 | array[y18+36][x18+5]= 1; |
el14ws | 0:4b8288518876 | 769 | |
el14ws | 0:4b8288518876 | 770 | array[y19+36][x19+5]= 1; |
el14ws | 0:4b8288518876 | 771 | |
el14ws | 0:4b8288518876 | 772 | array[y20+36][x20+5]= 1; |
el14ws | 0:4b8288518876 | 773 | |
el14ws | 0:4b8288518876 | 774 | array[y21+36][x21+5]= 1; |
el14ws | 0:4b8288518876 | 775 | |
el14ws | 0:4b8288518876 | 776 | array[y22+36][x22+5]= 1; |
el14ws | 0:4b8288518876 | 777 | |
el14ws | 0:4b8288518876 | 778 | array[y23+36][x23+5]= 1; |
el14ws | 0:4b8288518876 | 779 | |
el14ws | 0:4b8288518876 | 780 | array[y24+36][x24+5]= 1; |
el14ws | 0:4b8288518876 | 781 | |
el14ws | 0:4b8288518876 | 782 | } |
el14ws | 0:4b8288518876 | 783 | DrawArray(); |
el14ws | 0:4b8288518876 | 784 | |
el14ws | 0:4b8288518876 | 785 | |
el14ws | 0:4b8288518876 | 786 | |
el14ws | 0:4b8288518876 | 787 | } |
el14ws | 0:4b8288518876 | 788 | |
el14ws | 0:4b8288518876 | 789 | |
el14ws | 0:4b8288518876 | 790 | /*void GameOver() |
el14ws | 0:4b8288518876 | 791 | { |
el14ws | 0:4b8288518876 | 792 | |
el14ws | 0:4b8288518876 | 793 | if (button==1) { |
el14ws | 0:4b8288518876 | 794 | |
el14ws | 0:4b8288518876 | 795 | lcd.clear(); |
el14ws | 0:4b8288518876 | 796 | |
el14ws | 0:4b8288518876 | 797 | lcd.printString("Welcome",20,1); // display welcome |
el14ws | 0:4b8288518876 | 798 | //wait(0.1); |
el14ws | 0:4b8288518876 | 799 | lcd.printString("To",35,3); // display To the game |
el14ws | 0:4b8288518876 | 800 | //wait(0.1); |
el14ws | 0:4b8288518876 | 801 | lcd.printString("SNAKE",27,5); // display of life |
el14ws | 0:4b8288518876 | 802 | //wait(1); |
el14ws | 0:4b8288518876 | 803 | } |
el14ws | 0:4b8288518876 | 804 | } |
el14ws | 0:4b8288518876 | 805 | */ |