![](/media/cache/profiles/LinkedIn_0NghoZJ.jpeg.50x50_q85.jpg)
Snake vs Block Game to be run upon K64F.
Snake/Snake.cpp@21:e41126528cc6, 2019-04-10 (annotated)
- Committer:
- AhmedPlaymaker
- Date:
- Wed Apr 10 04:08:13 2019 +0000
- Revision:
- 21:e41126528cc6
- Parent:
- 20:1e6338403427
- Child:
- 22:ee698f66146f
Starting to divide my code
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
AhmedPlaymaker | 7:48ba87cd79b5 | 1 | #include "Snake.h" |
AhmedPlaymaker | 7:48ba87cd79b5 | 2 | |
AhmedPlaymaker | 7:48ba87cd79b5 | 3 | Snake::Snake() |
AhmedPlaymaker | 7:48ba87cd79b5 | 4 | { |
AhmedPlaymaker | 7:48ba87cd79b5 | 5 | |
AhmedPlaymaker | 7:48ba87cd79b5 | 6 | } |
AhmedPlaymaker | 7:48ba87cd79b5 | 7 | |
AhmedPlaymaker | 7:48ba87cd79b5 | 8 | Snake::~Snake() |
AhmedPlaymaker | 7:48ba87cd79b5 | 9 | { |
AhmedPlaymaker | 7:48ba87cd79b5 | 10 | |
AhmedPlaymaker | 7:48ba87cd79b5 | 11 | } |
AhmedPlaymaker | 7:48ba87cd79b5 | 12 | |
AhmedPlaymaker | 7:48ba87cd79b5 | 13 | //The Snake Sprite. |
AhmedPlaymaker | 8:890b986b16a4 | 14 | int snake_sprite[3][3] = { |
AhmedPlaymaker | 8:890b986b16a4 | 15 | {0,1,0}, |
AhmedPlaymaker | 8:890b986b16a4 | 16 | {1,0,1}, |
AhmedPlaymaker | 8:890b986b16a4 | 17 | {0,1,0}, |
AhmedPlaymaker | 9:d1d79d4ee673 | 18 | }; |
AhmedPlaymaker | 7:48ba87cd79b5 | 19 | |
AhmedPlaymaker | 7:48ba87cd79b5 | 20 | int m = 0; //Variable used to allow a starting location for the player. |
AhmedPlaymaker | 7:48ba87cd79b5 | 21 | |
AhmedPlaymaker | 7:48ba87cd79b5 | 22 | |
AhmedPlaymaker | 7:48ba87cd79b5 | 23 | void Snake::init() |
AhmedPlaymaker | 7:48ba87cd79b5 | 24 | { |
AhmedPlaymaker | 7:48ba87cd79b5 | 25 | |
AhmedPlaymaker | 18:b391caa5754c | 26 | _speed = 1;// change this according to the options selected |
AhmedPlaymaker | 7:48ba87cd79b5 | 27 | |
AhmedPlaymaker | 7:48ba87cd79b5 | 28 | } |
AhmedPlaymaker | 7:48ba87cd79b5 | 29 | |
AhmedPlaymaker | 7:48ba87cd79b5 | 30 | |
AhmedPlaymaker | 20:1e6338403427 | 31 | int Snake::draw(Gamepad &pad, N5110 &lcd, int length, int level) |
AhmedPlaymaker | 7:48ba87cd79b5 | 32 | { |
AhmedPlaymaker | 7:48ba87cd79b5 | 33 | if(m == 0){ |
AhmedPlaymaker | 21:e41126528cc6 | 34 | _x[0] = WIDTH/2; //Spawns player sprite near the middle of the screen. |
AhmedPlaymaker | 21:e41126528cc6 | 35 | _x[1] = _x[0]; |
AhmedPlaymaker | 21:e41126528cc6 | 36 | _x[2] = _x[1]; |
AhmedPlaymaker | 21:e41126528cc6 | 37 | _x[3] = _x[2]; |
AhmedPlaymaker | 21:e41126528cc6 | 38 | _x[4] = _x[3]; |
AhmedPlaymaker | 21:e41126528cc6 | 39 | _x[5] = _x[4]; |
AhmedPlaymaker | 21:e41126528cc6 | 40 | _x[6] = _x[5]; |
AhmedPlaymaker | 21:e41126528cc6 | 41 | _x[7] = _x[6]; |
AhmedPlaymaker | 21:e41126528cc6 | 42 | _x[8] = _x[7]; |
AhmedPlaymaker | 21:e41126528cc6 | 43 | _x[9] = _x[8]; |
AhmedPlaymaker | 21:e41126528cc6 | 44 | _x[10] = _x[9]; |
AhmedPlaymaker | 21:e41126528cc6 | 45 | _x[11] = _x[10]; |
AhmedPlaymaker | 21:e41126528cc6 | 46 | _x[12] = _x[11]; |
AhmedPlaymaker | 21:e41126528cc6 | 47 | _x[13] = _x[12]; |
AhmedPlaymaker | 21:e41126528cc6 | 48 | _x[14] = _x[13]; |
AhmedPlaymaker | 21:e41126528cc6 | 49 | _y[0] = HEIGHT - 3; |
AhmedPlaymaker | 21:e41126528cc6 | 50 | _y[1] = _y[0] - 3; |
AhmedPlaymaker | 21:e41126528cc6 | 51 | _y[2] = _y[0] - 6; |
AhmedPlaymaker | 21:e41126528cc6 | 52 | _y[3] = _y[0] - 9; |
AhmedPlaymaker | 21:e41126528cc6 | 53 | _y[4] = _y[0] - 12; |
AhmedPlaymaker | 21:e41126528cc6 | 54 | _y[5] = _y[0] - 15; |
AhmedPlaymaker | 21:e41126528cc6 | 55 | _y[6] = _y[0] - 18; |
AhmedPlaymaker | 21:e41126528cc6 | 56 | _y[7] = _y[0] - 21; |
AhmedPlaymaker | 21:e41126528cc6 | 57 | _y[8] = _y[0] - 24; |
AhmedPlaymaker | 21:e41126528cc6 | 58 | _y[9] = _y[0] - 27; |
AhmedPlaymaker | 21:e41126528cc6 | 59 | _y[10] = _y[0] - 30; |
AhmedPlaymaker | 21:e41126528cc6 | 60 | _y[11] = _y[0] - 33; |
AhmedPlaymaker | 21:e41126528cc6 | 61 | _y[12] = _y[0] - 36; |
AhmedPlaymaker | 21:e41126528cc6 | 62 | _y[13] = _y[0] - 39; |
AhmedPlaymaker | 21:e41126528cc6 | 63 | _y[14] = _y[0] - 42; |
AhmedPlaymaker | 21:e41126528cc6 | 64 | b[0] = 1; |
AhmedPlaymaker | 21:e41126528cc6 | 65 | b[1] = 1; |
AhmedPlaymaker | 21:e41126528cc6 | 66 | b[2] = 1; |
AhmedPlaymaker | 21:e41126528cc6 | 67 | b[3] = 1; |
AhmedPlaymaker | 21:e41126528cc6 | 68 | b[4] = 1; |
AhmedPlaymaker | 21:e41126528cc6 | 69 | b[5] = 1; |
AhmedPlaymaker | 21:e41126528cc6 | 70 | b[6] = 1; |
AhmedPlaymaker | 21:e41126528cc6 | 71 | b[7] = 1; |
AhmedPlaymaker | 21:e41126528cc6 | 72 | b[8] = 1; |
AhmedPlaymaker | 21:e41126528cc6 | 73 | b[9] = 1; |
AhmedPlaymaker | 21:e41126528cc6 | 74 | b[10] = 1; |
AhmedPlaymaker | 21:e41126528cc6 | 75 | b[11] = 1; |
AhmedPlaymaker | 21:e41126528cc6 | 76 | b[12] = 1; |
AhmedPlaymaker | 21:e41126528cc6 | 77 | b[13] = 1; |
AhmedPlaymaker | 21:e41126528cc6 | 78 | b[14] = 1; |
AhmedPlaymaker | 7:48ba87cd79b5 | 79 | m = m+1; |
AhmedPlaymaker | 7:48ba87cd79b5 | 80 | } |
AhmedPlaymaker | 21:e41126528cc6 | 81 | //printf("SPRITE %d %d \n", _x[0], _y[0]); |
AhmedPlaymaker | 8:890b986b16a4 | 82 | if(length == 0) { |
AhmedPlaymaker | 16:7b474f873683 | 83 | while ((pad.check_event(Gamepad::BACK_PRESSED) == false)) { |
AhmedPlaymaker | 16:7b474f873683 | 84 | lcd.clear(); |
AhmedPlaymaker | 16:7b474f873683 | 85 | lcd.printString("Game",33,1); |
AhmedPlaymaker | 16:7b474f873683 | 86 | lcd.printString("Over",33,3); |
AhmedPlaymaker | 16:7b474f873683 | 87 | lcd.printString("Press Back",14,5); //Function used to promt the user to Restart. |
AhmedPlaymaker | 16:7b474f873683 | 88 | lcd.refresh(); |
AhmedPlaymaker | 16:7b474f873683 | 89 | wait(0.1); |
AhmedPlaymaker | 16:7b474f873683 | 90 | } |
AhmedPlaymaker | 16:7b474f873683 | 91 | NVIC_SystemReset(); //Software Reset. //change this condition to loosing screen. |
AhmedPlaymaker | 8:890b986b16a4 | 92 | } |
AhmedPlaymaker | 16:7b474f873683 | 93 | else if(length == 1) { |
AhmedPlaymaker | 21:e41126528cc6 | 94 | lcd.drawSprite(_x[0],_y[0],3,3,(int *)snake_sprite); //Function used to draw the sprite. |
AhmedPlaymaker | 8:890b986b16a4 | 95 | } |
AhmedPlaymaker | 16:7b474f873683 | 96 | else if(length == 2) { |
AhmedPlaymaker | 21:e41126528cc6 | 97 | lcd.drawSprite(_x[0],_y[0],3,3,(int *)snake_sprite); //Function used to draw the sprite. |
AhmedPlaymaker | 21:e41126528cc6 | 98 | lcd.drawSprite(_x[1],_y[1],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 8:890b986b16a4 | 99 | } |
AhmedPlaymaker | 16:7b474f873683 | 100 | else if(length == 3) { |
AhmedPlaymaker | 21:e41126528cc6 | 101 | lcd.drawSprite(_x[0],_y[0],3,3,(int *)snake_sprite); //Function used to draw the sprite. |
AhmedPlaymaker | 21:e41126528cc6 | 102 | lcd.drawSprite(_x[1],_y[1],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 103 | lcd.drawSprite(_x[2],_y[2],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 8:890b986b16a4 | 104 | } |
AhmedPlaymaker | 16:7b474f873683 | 105 | else if(length == 4) { |
AhmedPlaymaker | 21:e41126528cc6 | 106 | lcd.drawSprite(_x[0],_y[0],3,3,(int *)snake_sprite); //Function used to draw the sprite. |
AhmedPlaymaker | 21:e41126528cc6 | 107 | lcd.drawSprite(_x[1],_y[1],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 108 | lcd.drawSprite(_x[2],_y[2],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 109 | lcd.drawSprite(_x[3],_y[3],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 8:890b986b16a4 | 110 | } |
AhmedPlaymaker | 16:7b474f873683 | 111 | else if(length == 5) { |
AhmedPlaymaker | 21:e41126528cc6 | 112 | lcd.drawSprite(_x[0],_y[0],3,3,(int *)snake_sprite); //Function used to draw the sprite. |
AhmedPlaymaker | 21:e41126528cc6 | 113 | lcd.drawSprite(_x[1],_y[1],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 114 | lcd.drawSprite(_x[2],_y[2],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 115 | lcd.drawSprite(_x[3],_y[3],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 116 | lcd.drawSprite(_x[4],_y[4],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 8:890b986b16a4 | 117 | } |
AhmedPlaymaker | 16:7b474f873683 | 118 | else if(length == 6) { |
AhmedPlaymaker | 21:e41126528cc6 | 119 | lcd.drawSprite(_x[0],_y[0],3,3,(int *)snake_sprite); //Function used to draw the sprite. |
AhmedPlaymaker | 21:e41126528cc6 | 120 | lcd.drawSprite(_x[1],_y[1],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 121 | lcd.drawSprite(_x[2],_y[2],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 122 | lcd.drawSprite(_x[3],_y[3],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 123 | lcd.drawSprite(_x[4],_y[4],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 124 | lcd.drawSprite(_x[5],_y[5],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 8:890b986b16a4 | 125 | } |
AhmedPlaymaker | 16:7b474f873683 | 126 | else if(length == 7) { |
AhmedPlaymaker | 21:e41126528cc6 | 127 | lcd.drawSprite(_x[0],_y[0],3,3,(int *)snake_sprite); //Function used to draw the sprite. |
AhmedPlaymaker | 21:e41126528cc6 | 128 | lcd.drawSprite(_x[1],_y[1],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 129 | lcd.drawSprite(_x[2],_y[2],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 130 | lcd.drawSprite(_x[3],_y[3],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 131 | lcd.drawSprite(_x[4],_y[4],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 132 | lcd.drawSprite(_x[5],_y[5],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 133 | lcd.drawSprite(_x[6],_y[6],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 8:890b986b16a4 | 134 | } |
AhmedPlaymaker | 16:7b474f873683 | 135 | else if(length == 8) { |
AhmedPlaymaker | 21:e41126528cc6 | 136 | lcd.drawSprite(_x[0],_y[0],3,3,(int *)snake_sprite); //Function used to draw the sprite. |
AhmedPlaymaker | 21:e41126528cc6 | 137 | lcd.drawSprite(_x[1],_y[1],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 138 | lcd.drawSprite(_x[2],_y[2],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 139 | lcd.drawSprite(_x[3],_y[3],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 140 | lcd.drawSprite(_x[4],_y[4],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 141 | lcd.drawSprite(_x[5],_y[5],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 142 | lcd.drawSprite(_x[6],_y[6],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 143 | lcd.drawSprite(_x[7],_y[7],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 8:890b986b16a4 | 144 | } |
AhmedPlaymaker | 16:7b474f873683 | 145 | else if(length == 9) { |
AhmedPlaymaker | 21:e41126528cc6 | 146 | lcd.drawSprite(_x[0],_y[0],3,3,(int *)snake_sprite); //Function used to draw the sprite. |
AhmedPlaymaker | 21:e41126528cc6 | 147 | lcd.drawSprite(_x[1],_y[1],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 148 | lcd.drawSprite(_x[2],_y[2],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 149 | lcd.drawSprite(_x[3],_y[3],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 150 | lcd.drawSprite(_x[4],_y[4],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 151 | lcd.drawSprite(_x[5],_y[5],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 152 | lcd.drawSprite(_x[6],_y[6],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 153 | lcd.drawSprite(_x[7],_y[7],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 154 | lcd.drawSprite(_x[8],_y[8],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 8:890b986b16a4 | 155 | } |
AhmedPlaymaker | 16:7b474f873683 | 156 | else if(length == 10) { |
AhmedPlaymaker | 21:e41126528cc6 | 157 | lcd.drawSprite(_x[0],_y[0],3,3,(int *)snake_sprite); //Function used to draw the sprite. |
AhmedPlaymaker | 21:e41126528cc6 | 158 | lcd.drawSprite(_x[1],_y[1],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 159 | lcd.drawSprite(_x[2],_y[2],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 160 | lcd.drawSprite(_x[3],_y[3],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 161 | lcd.drawSprite(_x[4],_y[4],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 162 | lcd.drawSprite(_x[5],_y[5],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 163 | lcd.drawSprite(_x[6],_y[6],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 164 | lcd.drawSprite(_x[7],_y[7],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 165 | lcd.drawSprite(_x[8],_y[8],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 166 | lcd.drawSprite(_x[9],_y[9],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 8:890b986b16a4 | 167 | } |
AhmedPlaymaker | 16:7b474f873683 | 168 | else if(length == 11) { |
AhmedPlaymaker | 21:e41126528cc6 | 169 | lcd.drawSprite(_x[0],_y[0],3,3,(int *)snake_sprite); //Function used to draw the sprite. |
AhmedPlaymaker | 21:e41126528cc6 | 170 | lcd.drawSprite(_x[1],_y[1],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 171 | lcd.drawSprite(_x[2],_y[2],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 172 | lcd.drawSprite(_x[3],_y[3],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 173 | lcd.drawSprite(_x[4],_y[4],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 174 | lcd.drawSprite(_x[5],_y[5],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 175 | lcd.drawSprite(_x[6],_y[6],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 176 | lcd.drawSprite(_x[7],_y[7],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 177 | lcd.drawSprite(_x[8],_y[8],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 178 | lcd.drawSprite(_x[9],_y[9],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 179 | lcd.drawSprite(_x[10],_y[10],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 8:890b986b16a4 | 180 | } |
AhmedPlaymaker | 16:7b474f873683 | 181 | else if(length == 12) { |
AhmedPlaymaker | 21:e41126528cc6 | 182 | lcd.drawSprite(_x[0],_y[0],3,3,(int *)snake_sprite); //Function used to draw the sprite. |
AhmedPlaymaker | 21:e41126528cc6 | 183 | lcd.drawSprite(_x[1],_y[1],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 184 | lcd.drawSprite(_x[2],_y[2],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 185 | lcd.drawSprite(_x[3],_y[3],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 186 | lcd.drawSprite(_x[4],_y[4],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 187 | lcd.drawSprite(_x[5],_y[5],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 188 | lcd.drawSprite(_x[6],_y[6],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 189 | lcd.drawSprite(_x[7],_y[7],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 190 | lcd.drawSprite(_x[8],_y[8],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 191 | lcd.drawSprite(_x[9],_y[9],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 192 | lcd.drawSprite(_x[10],_y[10],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 193 | lcd.drawSprite(_x[11],_y[11],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 8:890b986b16a4 | 194 | } |
AhmedPlaymaker | 16:7b474f873683 | 195 | else if(length == 13) { |
AhmedPlaymaker | 21:e41126528cc6 | 196 | lcd.drawSprite(_x[0],_y[0],3,3,(int *)snake_sprite); //Function used to draw the sprite. |
AhmedPlaymaker | 21:e41126528cc6 | 197 | lcd.drawSprite(_x[1],_y[1],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 198 | lcd.drawSprite(_x[2],_y[2],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 199 | lcd.drawSprite(_x[3],_y[3],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 200 | lcd.drawSprite(_x[4],_y[4],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 201 | lcd.drawSprite(_x[5],_y[5],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 202 | lcd.drawSprite(_x[6],_y[6],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 203 | lcd.drawSprite(_x[7],_y[7],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 204 | lcd.drawSprite(_x[8],_y[8],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 205 | lcd.drawSprite(_x[9],_y[9],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 206 | lcd.drawSprite(_x[10],_y[10],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 207 | lcd.drawSprite(_x[11],_y[11],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 208 | lcd.drawSprite(_x[12],_y[12],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 8:890b986b16a4 | 209 | } |
AhmedPlaymaker | 16:7b474f873683 | 210 | else if(length == 14) { |
AhmedPlaymaker | 21:e41126528cc6 | 211 | lcd.drawSprite(_x[0],_y[0],3,3,(int *)snake_sprite); //Function used to draw the sprite. |
AhmedPlaymaker | 21:e41126528cc6 | 212 | lcd.drawSprite(_x[1],_y[1],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 213 | lcd.drawSprite(_x[2],_y[2],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 214 | lcd.drawSprite(_x[3],_y[3],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 215 | lcd.drawSprite(_x[4],_y[4],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 216 | lcd.drawSprite(_x[5],_y[5],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 217 | lcd.drawSprite(_x[6],_y[6],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 218 | lcd.drawSprite(_x[7],_y[7],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 219 | lcd.drawSprite(_x[8],_y[8],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 220 | lcd.drawSprite(_x[9],_y[9],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 221 | lcd.drawSprite(_x[10],_y[10],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 222 | lcd.drawSprite(_x[11],_y[11],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 223 | lcd.drawSprite(_x[12],_y[12],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 224 | lcd.drawSprite(_x[13],_y[13],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 8:890b986b16a4 | 225 | } |
AhmedPlaymaker | 16:7b474f873683 | 226 | else if(length == 15) { |
AhmedPlaymaker | 21:e41126528cc6 | 227 | lcd.drawSprite(_x[0],_y[0],3,3,(int *)snake_sprite); //Function used to draw the sprite. |
AhmedPlaymaker | 21:e41126528cc6 | 228 | lcd.drawSprite(_x[1],_y[1],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 229 | lcd.drawSprite(_x[2],_y[2],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 230 | lcd.drawSprite(_x[3],_y[3],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 231 | lcd.drawSprite(_x[4],_y[4],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 232 | lcd.drawSprite(_x[5],_y[5],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 233 | lcd.drawSprite(_x[6],_y[6],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 234 | lcd.drawSprite(_x[7],_y[7],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 235 | lcd.drawSprite(_x[8],_y[8],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 236 | lcd.drawSprite(_x[9],_y[9],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 237 | lcd.drawSprite(_x[10],_y[10],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 238 | lcd.drawSprite(_x[11],_y[11],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 239 | lcd.drawSprite(_x[12],_y[12],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 240 | lcd.drawSprite(_x[13],_y[13],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 21:e41126528cc6 | 241 | lcd.drawSprite(_x[14],_y[14],3,3,(int *)snake_sprite); |
AhmedPlaymaker | 8:890b986b16a4 | 242 | } |
AhmedPlaymaker | 17:54e13faeaf64 | 243 | else if(length > 15) { |
AhmedPlaymaker | 17:54e13faeaf64 | 244 | lcd.clear(); |
AhmedPlaymaker | 17:54e13faeaf64 | 245 | lcd.printString("Level Complete",0,1); |
AhmedPlaymaker | 17:54e13faeaf64 | 246 | lcd.refresh(); |
AhmedPlaymaker | 21:e41126528cc6 | 247 | wait(2); |
AhmedPlaymaker | 20:1e6338403427 | 248 | lcd.clear(); |
AhmedPlaymaker | 21:e41126528cc6 | 249 | lcd.printString("Press Start",10,1); |
AhmedPlaymaker | 21:e41126528cc6 | 250 | lcd.printString("to Proceed",12,3); |
AhmedPlaymaker | 20:1e6338403427 | 251 | lcd.refresh(); |
AhmedPlaymaker | 21:e41126528cc6 | 252 | int sound = 1000; //helps to set max freq for random sound |
AhmedPlaymaker | 20:1e6338403427 | 253 | while ( pad.check_event(Gamepad::START_PRESSED) == false) { |
AhmedPlaymaker | 20:1e6338403427 | 254 | pad.leds_on(); |
AhmedPlaymaker | 20:1e6338403427 | 255 | pad.tone(rand()%sound,0.1); |
AhmedPlaymaker | 20:1e6338403427 | 256 | wait(0.1); |
AhmedPlaymaker | 20:1e6338403427 | 257 | pad.leds_off(); |
AhmedPlaymaker | 20:1e6338403427 | 258 | wait(0.1); |
AhmedPlaymaker | 20:1e6338403427 | 259 | } |
AhmedPlaymaker | 20:1e6338403427 | 260 | lcd.clear(); |
AhmedPlaymaker | 20:1e6338403427 | 261 | char bufferlevel[14]; |
AhmedPlaymaker | 20:1e6338403427 | 262 | sprintf(bufferlevel,"%d",level); |
AhmedPlaymaker | 20:1e6338403427 | 263 | lcd.printString("Level:",25,1); |
AhmedPlaymaker | 20:1e6338403427 | 264 | lcd.printString(bufferlevel,40,3); |
AhmedPlaymaker | 20:1e6338403427 | 265 | lcd.refresh(); |
AhmedPlaymaker | 20:1e6338403427 | 266 | wait(2); |
AhmedPlaymaker | 17:54e13faeaf64 | 267 | length = 3; |
AhmedPlaymaker | 17:54e13faeaf64 | 268 | } |
AhmedPlaymaker | 17:54e13faeaf64 | 269 | return length; |
AhmedPlaymaker | 7:48ba87cd79b5 | 270 | } |
AhmedPlaymaker | 19:05cc9f801468 | 271 | |
AhmedPlaymaker | 9:d1d79d4ee673 | 272 | Vector2D Snake::get_pos(int length) |
AhmedPlaymaker | 7:48ba87cd79b5 | 273 | { |
AhmedPlaymaker | 9:d1d79d4ee673 | 274 | if(length == 1) { |
AhmedPlaymaker | 21:e41126528cc6 | 275 | Vector2D snakepos = {_x[0],_y[0]}; //Obtains the snake position. |
AhmedPlaymaker | 9:d1d79d4ee673 | 276 | return snakepos; |
AhmedPlaymaker | 9:d1d79d4ee673 | 277 | } |
AhmedPlaymaker | 9:d1d79d4ee673 | 278 | else if(length == 2) { |
AhmedPlaymaker | 21:e41126528cc6 | 279 | Vector2D snakepos = {_x[1],_y[1]}; //Obtains the snake position. |
AhmedPlaymaker | 9:d1d79d4ee673 | 280 | return snakepos; |
AhmedPlaymaker | 9:d1d79d4ee673 | 281 | } |
AhmedPlaymaker | 9:d1d79d4ee673 | 282 | else if(length==3) { |
AhmedPlaymaker | 21:e41126528cc6 | 283 | Vector2D snakepos = {_x[2],_y[2]}; //Obtains the snake position. |
AhmedPlaymaker | 9:d1d79d4ee673 | 284 | return snakepos; |
AhmedPlaymaker | 9:d1d79d4ee673 | 285 | } |
AhmedPlaymaker | 9:d1d79d4ee673 | 286 | else if(length==4) { |
AhmedPlaymaker | 21:e41126528cc6 | 287 | Vector2D snakepos = {_x[3],_y[3]}; //Obtains the snake position. |
AhmedPlaymaker | 9:d1d79d4ee673 | 288 | return snakepos; |
AhmedPlaymaker | 9:d1d79d4ee673 | 289 | } |
AhmedPlaymaker | 9:d1d79d4ee673 | 290 | else if(length==5) { |
AhmedPlaymaker | 21:e41126528cc6 | 291 | Vector2D snakepos = {_x[4],_y[4]}; //Obtains the snake position. |
AhmedPlaymaker | 9:d1d79d4ee673 | 292 | return snakepos; |
AhmedPlaymaker | 9:d1d79d4ee673 | 293 | } |
AhmedPlaymaker | 9:d1d79d4ee673 | 294 | else if(length==6) { |
AhmedPlaymaker | 21:e41126528cc6 | 295 | Vector2D snakepos = {_x[5],_y[5]}; //Obtains the snake position. |
AhmedPlaymaker | 9:d1d79d4ee673 | 296 | return snakepos; |
AhmedPlaymaker | 9:d1d79d4ee673 | 297 | } |
AhmedPlaymaker | 9:d1d79d4ee673 | 298 | else if(length==7) { |
AhmedPlaymaker | 21:e41126528cc6 | 299 | Vector2D snakepos = {_x[6],_y[6]}; //Obtains the snake position. |
AhmedPlaymaker | 9:d1d79d4ee673 | 300 | return snakepos; |
AhmedPlaymaker | 9:d1d79d4ee673 | 301 | } |
AhmedPlaymaker | 9:d1d79d4ee673 | 302 | else if(length==8) { |
AhmedPlaymaker | 21:e41126528cc6 | 303 | Vector2D snakepos = {_x[7],_y[7]}; //Obtains the snake position. |
AhmedPlaymaker | 9:d1d79d4ee673 | 304 | return snakepos; |
AhmedPlaymaker | 9:d1d79d4ee673 | 305 | } |
AhmedPlaymaker | 9:d1d79d4ee673 | 306 | else if(length==9) { |
AhmedPlaymaker | 21:e41126528cc6 | 307 | Vector2D snakepos = {_x[8],_y[8]}; //Obtains the snake position. |
AhmedPlaymaker | 9:d1d79d4ee673 | 308 | return snakepos; |
AhmedPlaymaker | 9:d1d79d4ee673 | 309 | } |
AhmedPlaymaker | 9:d1d79d4ee673 | 310 | else if(length==10) { |
AhmedPlaymaker | 21:e41126528cc6 | 311 | Vector2D snakepos = {_x[9],_y[9]}; //Obtains the snake position. |
AhmedPlaymaker | 9:d1d79d4ee673 | 312 | return snakepos; |
AhmedPlaymaker | 9:d1d79d4ee673 | 313 | } |
AhmedPlaymaker | 9:d1d79d4ee673 | 314 | else if(length==11) { |
AhmedPlaymaker | 21:e41126528cc6 | 315 | Vector2D snakepos = {_x[10],_y[10]}; //Obtains the snake position. |
AhmedPlaymaker | 9:d1d79d4ee673 | 316 | return snakepos; |
AhmedPlaymaker | 9:d1d79d4ee673 | 317 | } |
AhmedPlaymaker | 9:d1d79d4ee673 | 318 | else if(length==12) { |
AhmedPlaymaker | 21:e41126528cc6 | 319 | Vector2D snakepos = {_x[11],_y[11]}; //Obtains the snake position. |
AhmedPlaymaker | 9:d1d79d4ee673 | 320 | return snakepos; |
AhmedPlaymaker | 9:d1d79d4ee673 | 321 | } |
AhmedPlaymaker | 9:d1d79d4ee673 | 322 | else if(length==13) { |
AhmedPlaymaker | 21:e41126528cc6 | 323 | Vector2D snakepos = {_x[12],_y[12]}; //Obtains the snake position. |
AhmedPlaymaker | 9:d1d79d4ee673 | 324 | return snakepos; |
AhmedPlaymaker | 9:d1d79d4ee673 | 325 | } |
AhmedPlaymaker | 9:d1d79d4ee673 | 326 | else if(length == 14) { |
AhmedPlaymaker | 21:e41126528cc6 | 327 | Vector2D snakepos = {_x[13],_y[13]}; //Obtains the snake position. |
AhmedPlaymaker | 9:d1d79d4ee673 | 328 | return snakepos; |
AhmedPlaymaker | 9:d1d79d4ee673 | 329 | } |
AhmedPlaymaker | 9:d1d79d4ee673 | 330 | else if(length==15) { |
AhmedPlaymaker | 21:e41126528cc6 | 331 | Vector2D snakepos = {_x[14],_y[14]}; //Obtains the snake position. |
AhmedPlaymaker | 9:d1d79d4ee673 | 332 | return snakepos; |
AhmedPlaymaker | 9:d1d79d4ee673 | 333 | } |
AhmedPlaymaker | 7:48ba87cd79b5 | 334 | //printf("snakepos from player = %f %f \n", snakepos.x, snakepos.y); |
AhmedPlaymaker | 13:9785f2404045 | 335 | else { |
AhmedPlaymaker | 13:9785f2404045 | 336 | Vector2D snakepos = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 337 | return snakepos; |
AhmedPlaymaker | 13:9785f2404045 | 338 | } |
AhmedPlaymaker | 13:9785f2404045 | 339 | } |
AhmedPlaymaker | 13:9785f2404045 | 340 | |
AhmedPlaymaker | 13:9785f2404045 | 341 | Vector2D Snake::get_pos_before1(int length) //this sends data of following sprites. |
AhmedPlaymaker | 13:9785f2404045 | 342 | { |
AhmedPlaymaker | 21:e41126528cc6 | 343 | if(length == 2) { |
AhmedPlaymaker | 21:e41126528cc6 | 344 | Vector2D snakepos_b1 = {_x[0],_y[0]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 345 | return snakepos_b1; |
AhmedPlaymaker | 13:9785f2404045 | 346 | } |
AhmedPlaymaker | 13:9785f2404045 | 347 | else if(length==3) { |
AhmedPlaymaker | 21:e41126528cc6 | 348 | Vector2D snakepos_b1 = {_x[1],_y[1]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 349 | return snakepos_b1; |
AhmedPlaymaker | 13:9785f2404045 | 350 | } |
AhmedPlaymaker | 13:9785f2404045 | 351 | else if(length==4) { |
AhmedPlaymaker | 21:e41126528cc6 | 352 | Vector2D snakepos_b1 = {_x[2],_y[2]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 353 | return snakepos_b1; |
AhmedPlaymaker | 13:9785f2404045 | 354 | } |
AhmedPlaymaker | 13:9785f2404045 | 355 | else if(length==5) { |
AhmedPlaymaker | 21:e41126528cc6 | 356 | Vector2D snakepos_b1 = {_x[3],_y[3]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 357 | return snakepos_b1; |
AhmedPlaymaker | 13:9785f2404045 | 358 | } |
AhmedPlaymaker | 13:9785f2404045 | 359 | else if(length==6) { |
AhmedPlaymaker | 21:e41126528cc6 | 360 | Vector2D snakepos_b1 = {_x[4],_y[4]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 361 | return snakepos_b1; |
AhmedPlaymaker | 13:9785f2404045 | 362 | } |
AhmedPlaymaker | 13:9785f2404045 | 363 | else if(length==7) { |
AhmedPlaymaker | 21:e41126528cc6 | 364 | Vector2D snakepos_b1 = {_x[5],_y[5]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 365 | return snakepos_b1; |
AhmedPlaymaker | 13:9785f2404045 | 366 | } |
AhmedPlaymaker | 13:9785f2404045 | 367 | else if(length==8) { |
AhmedPlaymaker | 21:e41126528cc6 | 368 | Vector2D snakepos_b1 = {_x[6],_y[6]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 369 | return snakepos_b1; |
AhmedPlaymaker | 13:9785f2404045 | 370 | } |
AhmedPlaymaker | 13:9785f2404045 | 371 | else if(length==9) { |
AhmedPlaymaker | 21:e41126528cc6 | 372 | Vector2D snakepos_b1 = {_x[7],_y[7]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 373 | return snakepos_b1; |
AhmedPlaymaker | 13:9785f2404045 | 374 | } |
AhmedPlaymaker | 13:9785f2404045 | 375 | else if(length==10) { |
AhmedPlaymaker | 21:e41126528cc6 | 376 | Vector2D snakepos_b1 = {_x[8],_y[8]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 377 | return snakepos_b1; |
AhmedPlaymaker | 13:9785f2404045 | 378 | } |
AhmedPlaymaker | 13:9785f2404045 | 379 | else if(length==11) { |
AhmedPlaymaker | 21:e41126528cc6 | 380 | Vector2D snakepos_b1 = {_x[9],_y[9]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 381 | return snakepos_b1; |
AhmedPlaymaker | 13:9785f2404045 | 382 | } |
AhmedPlaymaker | 13:9785f2404045 | 383 | else if(length==12) { |
AhmedPlaymaker | 21:e41126528cc6 | 384 | Vector2D snakepos_b1 = {_x[10],_y[10]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 385 | return snakepos_b1; |
AhmedPlaymaker | 13:9785f2404045 | 386 | } |
AhmedPlaymaker | 13:9785f2404045 | 387 | else if(length==13) { |
AhmedPlaymaker | 21:e41126528cc6 | 388 | Vector2D snakepos_b1 = {_x[11],_y[11]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 389 | return snakepos_b1; |
AhmedPlaymaker | 13:9785f2404045 | 390 | } |
AhmedPlaymaker | 13:9785f2404045 | 391 | else if(length == 14) { |
AhmedPlaymaker | 21:e41126528cc6 | 392 | Vector2D snakepos_b1 = {_x[12],_y[12]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 393 | return snakepos_b1; |
AhmedPlaymaker | 13:9785f2404045 | 394 | } |
AhmedPlaymaker | 13:9785f2404045 | 395 | else if(length==15) { |
AhmedPlaymaker | 21:e41126528cc6 | 396 | Vector2D snakepos_b1 = {_x[13],_y[13]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 397 | return snakepos_b1; |
AhmedPlaymaker | 13:9785f2404045 | 398 | } |
AhmedPlaymaker | 13:9785f2404045 | 399 | //printf("snakepos from player = %f %f \n", snakepos.x, snakepos.y); |
AhmedPlaymaker | 13:9785f2404045 | 400 | else { |
AhmedPlaymaker | 13:9785f2404045 | 401 | Vector2D snakepos_b1 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 402 | return snakepos_b1; |
AhmedPlaymaker | 13:9785f2404045 | 403 | } |
AhmedPlaymaker | 13:9785f2404045 | 404 | } |
AhmedPlaymaker | 13:9785f2404045 | 405 | |
AhmedPlaymaker | 13:9785f2404045 | 406 | Vector2D Snake::get_pos_before2(int length) //this sends data of following sprites. |
AhmedPlaymaker | 13:9785f2404045 | 407 | { |
AhmedPlaymaker | 21:e41126528cc6 | 408 | if(length == 3) { |
AhmedPlaymaker | 21:e41126528cc6 | 409 | Vector2D snakepos_b2 = {_x[0],_y[0]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 410 | return snakepos_b2; |
AhmedPlaymaker | 13:9785f2404045 | 411 | } |
AhmedPlaymaker | 13:9785f2404045 | 412 | else if(length==4) { |
AhmedPlaymaker | 21:e41126528cc6 | 413 | Vector2D snakepos_b2 = {_x[1],_y[1]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 414 | return snakepos_b2; |
AhmedPlaymaker | 13:9785f2404045 | 415 | } |
AhmedPlaymaker | 13:9785f2404045 | 416 | else if(length==5) { |
AhmedPlaymaker | 21:e41126528cc6 | 417 | Vector2D snakepos_b2 = {_x[2],_y[2]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 418 | return snakepos_b2; |
AhmedPlaymaker | 13:9785f2404045 | 419 | } |
AhmedPlaymaker | 13:9785f2404045 | 420 | else if(length==6) { |
AhmedPlaymaker | 21:e41126528cc6 | 421 | Vector2D snakepos_b2 = {_x[3],_y[3]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 422 | return snakepos_b2; |
AhmedPlaymaker | 13:9785f2404045 | 423 | } |
AhmedPlaymaker | 13:9785f2404045 | 424 | else if(length==7) { |
AhmedPlaymaker | 21:e41126528cc6 | 425 | Vector2D snakepos_b2 = {_x[4],_y[4]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 426 | return snakepos_b2; |
AhmedPlaymaker | 13:9785f2404045 | 427 | } |
AhmedPlaymaker | 13:9785f2404045 | 428 | else if(length==8) { |
AhmedPlaymaker | 21:e41126528cc6 | 429 | Vector2D snakepos_b2 = {_x[5],_y[5]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 430 | return snakepos_b2; |
AhmedPlaymaker | 13:9785f2404045 | 431 | } |
AhmedPlaymaker | 13:9785f2404045 | 432 | else if(length==9) { |
AhmedPlaymaker | 21:e41126528cc6 | 433 | Vector2D snakepos_b2 = {_x[6],_y[6]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 434 | return snakepos_b2; |
AhmedPlaymaker | 13:9785f2404045 | 435 | } |
AhmedPlaymaker | 13:9785f2404045 | 436 | else if(length==10) { |
AhmedPlaymaker | 21:e41126528cc6 | 437 | Vector2D snakepos_b2 = {_x[7],_y[7]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 438 | return snakepos_b2; |
AhmedPlaymaker | 13:9785f2404045 | 439 | } |
AhmedPlaymaker | 13:9785f2404045 | 440 | else if(length==11) { |
AhmedPlaymaker | 21:e41126528cc6 | 441 | Vector2D snakepos_b2 = {_x[8],_y[8]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 442 | return snakepos_b2; |
AhmedPlaymaker | 13:9785f2404045 | 443 | } |
AhmedPlaymaker | 13:9785f2404045 | 444 | else if(length==12) { |
AhmedPlaymaker | 21:e41126528cc6 | 445 | Vector2D snakepos_b2 = {_x[9],_y[9]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 446 | return snakepos_b2; |
AhmedPlaymaker | 13:9785f2404045 | 447 | } |
AhmedPlaymaker | 13:9785f2404045 | 448 | else if(length==13) { |
AhmedPlaymaker | 21:e41126528cc6 | 449 | Vector2D snakepos_b2 = {_x[10],_y[10]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 450 | return snakepos_b2; |
AhmedPlaymaker | 13:9785f2404045 | 451 | } |
AhmedPlaymaker | 13:9785f2404045 | 452 | else if(length==14) { |
AhmedPlaymaker | 21:e41126528cc6 | 453 | Vector2D snakepos_b2 = {_x[11],_y[11]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 454 | return snakepos_b2; |
AhmedPlaymaker | 13:9785f2404045 | 455 | } |
AhmedPlaymaker | 13:9785f2404045 | 456 | else if(length == 15) { |
AhmedPlaymaker | 21:e41126528cc6 | 457 | Vector2D snakepos_b2 = {_x[12],_y[12]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 458 | return snakepos_b2; |
AhmedPlaymaker | 13:9785f2404045 | 459 | } |
AhmedPlaymaker | 13:9785f2404045 | 460 | //printf("snakepos from player = %f %f \n", snakepos.x, snakepos.y); |
AhmedPlaymaker | 13:9785f2404045 | 461 | else { |
AhmedPlaymaker | 13:9785f2404045 | 462 | Vector2D snakepos_b2 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 463 | return snakepos_b2; |
AhmedPlaymaker | 13:9785f2404045 | 464 | } |
AhmedPlaymaker | 13:9785f2404045 | 465 | } |
AhmedPlaymaker | 13:9785f2404045 | 466 | |
AhmedPlaymaker | 13:9785f2404045 | 467 | Vector2D Snake::get_pos_before3(int length) //this sends data of following sprites. |
AhmedPlaymaker | 13:9785f2404045 | 468 | { |
AhmedPlaymaker | 21:e41126528cc6 | 469 | if(length == 4) { |
AhmedPlaymaker | 21:e41126528cc6 | 470 | Vector2D snakepos_b3 = {_x[0],_y[0]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 471 | return snakepos_b3; |
AhmedPlaymaker | 13:9785f2404045 | 472 | } |
AhmedPlaymaker | 13:9785f2404045 | 473 | else if(length==5) { |
AhmedPlaymaker | 21:e41126528cc6 | 474 | Vector2D snakepos_b3 = {_x[1],_y[1]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 475 | return snakepos_b3; |
AhmedPlaymaker | 13:9785f2404045 | 476 | } |
AhmedPlaymaker | 13:9785f2404045 | 477 | else if(length==6) { |
AhmedPlaymaker | 21:e41126528cc6 | 478 | Vector2D snakepos_b3 = {_x[2],_y[2]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 479 | return snakepos_b3; |
AhmedPlaymaker | 13:9785f2404045 | 480 | } |
AhmedPlaymaker | 13:9785f2404045 | 481 | else if(length==7) { |
AhmedPlaymaker | 21:e41126528cc6 | 482 | Vector2D snakepos_b3 = {_x[3],_y[3]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 483 | return snakepos_b3; |
AhmedPlaymaker | 13:9785f2404045 | 484 | } |
AhmedPlaymaker | 13:9785f2404045 | 485 | else if(length==8) { |
AhmedPlaymaker | 21:e41126528cc6 | 486 | Vector2D snakepos_b3 = {_x[4],_y[4]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 487 | return snakepos_b3; |
AhmedPlaymaker | 13:9785f2404045 | 488 | } |
AhmedPlaymaker | 13:9785f2404045 | 489 | else if(length==9) { |
AhmedPlaymaker | 21:e41126528cc6 | 490 | Vector2D snakepos_b3 = {_x[5],_y[5]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 491 | return snakepos_b3; |
AhmedPlaymaker | 13:9785f2404045 | 492 | } |
AhmedPlaymaker | 13:9785f2404045 | 493 | else if(length==10) { |
AhmedPlaymaker | 21:e41126528cc6 | 494 | Vector2D snakepos_b3 = {_x[6],_y[6]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 495 | return snakepos_b3; |
AhmedPlaymaker | 13:9785f2404045 | 496 | } |
AhmedPlaymaker | 13:9785f2404045 | 497 | else if(length==11) { |
AhmedPlaymaker | 21:e41126528cc6 | 498 | Vector2D snakepos_b3 = {_x[7],_y[7]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 499 | return snakepos_b3; |
AhmedPlaymaker | 13:9785f2404045 | 500 | } |
AhmedPlaymaker | 13:9785f2404045 | 501 | else if(length==12) { |
AhmedPlaymaker | 21:e41126528cc6 | 502 | Vector2D snakepos_b3 = {_x[8],_y[8]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 503 | return snakepos_b3; |
AhmedPlaymaker | 13:9785f2404045 | 504 | } |
AhmedPlaymaker | 13:9785f2404045 | 505 | else if(length==13) { |
AhmedPlaymaker | 21:e41126528cc6 | 506 | Vector2D snakepos_b3 = {_x[9],_y[9]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 507 | return snakepos_b3; |
AhmedPlaymaker | 13:9785f2404045 | 508 | } |
AhmedPlaymaker | 13:9785f2404045 | 509 | else if(length==14) { |
AhmedPlaymaker | 21:e41126528cc6 | 510 | Vector2D snakepos_b3 = {_x[10],_y[10]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 511 | return snakepos_b3; |
AhmedPlaymaker | 13:9785f2404045 | 512 | } |
AhmedPlaymaker | 13:9785f2404045 | 513 | else if(length==15) { |
AhmedPlaymaker | 21:e41126528cc6 | 514 | Vector2D snakepos_b3 = {_x[11],_y[11]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 515 | return snakepos_b3; |
AhmedPlaymaker | 13:9785f2404045 | 516 | } |
AhmedPlaymaker | 13:9785f2404045 | 517 | //printf("snakepos from player = %f %f \n", snakepos.x, snakepos.y); |
AhmedPlaymaker | 13:9785f2404045 | 518 | else { |
AhmedPlaymaker | 13:9785f2404045 | 519 | Vector2D snakepos_b3 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 520 | return snakepos_b3; |
AhmedPlaymaker | 13:9785f2404045 | 521 | } |
AhmedPlaymaker | 13:9785f2404045 | 522 | } |
AhmedPlaymaker | 13:9785f2404045 | 523 | |
AhmedPlaymaker | 13:9785f2404045 | 524 | Vector2D Snake::get_pos_before4(int length) //this sends data of following sprites. |
AhmedPlaymaker | 13:9785f2404045 | 525 | { |
AhmedPlaymaker | 21:e41126528cc6 | 526 | if(length == 5) { |
AhmedPlaymaker | 21:e41126528cc6 | 527 | Vector2D snakepos_b4 = {_x[0],_y[0]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 528 | return snakepos_b4; |
AhmedPlaymaker | 13:9785f2404045 | 529 | } |
AhmedPlaymaker | 13:9785f2404045 | 530 | else if(length==6) { |
AhmedPlaymaker | 21:e41126528cc6 | 531 | Vector2D snakepos_b4 = {_x[1],_y[1]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 532 | return snakepos_b4; |
AhmedPlaymaker | 13:9785f2404045 | 533 | } |
AhmedPlaymaker | 13:9785f2404045 | 534 | else if(length==7) { |
AhmedPlaymaker | 21:e41126528cc6 | 535 | Vector2D snakepos_b4 = {_x[2],_y[2]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 536 | return snakepos_b4; |
AhmedPlaymaker | 13:9785f2404045 | 537 | } |
AhmedPlaymaker | 13:9785f2404045 | 538 | else if(length==8) { |
AhmedPlaymaker | 21:e41126528cc6 | 539 | Vector2D snakepos_b4 = {_x[3],_y[3]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 540 | return snakepos_b4; |
AhmedPlaymaker | 13:9785f2404045 | 541 | } |
AhmedPlaymaker | 13:9785f2404045 | 542 | else if(length==9) { |
AhmedPlaymaker | 21:e41126528cc6 | 543 | Vector2D snakepos_b4 = {_x[4],_y[4]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 544 | return snakepos_b4; |
AhmedPlaymaker | 13:9785f2404045 | 545 | } |
AhmedPlaymaker | 13:9785f2404045 | 546 | else if(length==10) { |
AhmedPlaymaker | 21:e41126528cc6 | 547 | Vector2D snakepos_b4 = {_x[5],_y[5]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 548 | return snakepos_b4; |
AhmedPlaymaker | 13:9785f2404045 | 549 | } |
AhmedPlaymaker | 13:9785f2404045 | 550 | else if(length==11) { |
AhmedPlaymaker | 21:e41126528cc6 | 551 | Vector2D snakepos_b4 = {_x[6],_y[6]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 552 | return snakepos_b4; |
AhmedPlaymaker | 13:9785f2404045 | 553 | } |
AhmedPlaymaker | 13:9785f2404045 | 554 | else if(length==12) { |
AhmedPlaymaker | 21:e41126528cc6 | 555 | Vector2D snakepos_b4 = {_x[7],_y[7]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 556 | return snakepos_b4; |
AhmedPlaymaker | 13:9785f2404045 | 557 | } |
AhmedPlaymaker | 13:9785f2404045 | 558 | else if(length==13) { |
AhmedPlaymaker | 21:e41126528cc6 | 559 | Vector2D snakepos_b4 = {_x[8],_y[8]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 560 | return snakepos_b4; |
AhmedPlaymaker | 13:9785f2404045 | 561 | } |
AhmedPlaymaker | 13:9785f2404045 | 562 | else if(length==14) { |
AhmedPlaymaker | 21:e41126528cc6 | 563 | Vector2D snakepos_b4 = {_x[9],_y[9]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 564 | return snakepos_b4; |
AhmedPlaymaker | 13:9785f2404045 | 565 | } |
AhmedPlaymaker | 13:9785f2404045 | 566 | else if(length==15) { |
AhmedPlaymaker | 21:e41126528cc6 | 567 | Vector2D snakepos_b4 = {_x[10],_y[10]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 568 | return snakepos_b4; |
AhmedPlaymaker | 13:9785f2404045 | 569 | } |
AhmedPlaymaker | 13:9785f2404045 | 570 | //printf("snakepos from player = %f %f \n", snakepos.x, snakepos.y); |
AhmedPlaymaker | 13:9785f2404045 | 571 | else { |
AhmedPlaymaker | 13:9785f2404045 | 572 | Vector2D snakepos_b4 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 573 | return snakepos_b4; |
AhmedPlaymaker | 13:9785f2404045 | 574 | } |
AhmedPlaymaker | 13:9785f2404045 | 575 | } |
AhmedPlaymaker | 13:9785f2404045 | 576 | |
AhmedPlaymaker | 13:9785f2404045 | 577 | Vector2D Snake::get_pos_before5(int length) //this sends data of following sprites. |
AhmedPlaymaker | 13:9785f2404045 | 578 | { |
AhmedPlaymaker | 21:e41126528cc6 | 579 | if(length == 6) { |
AhmedPlaymaker | 21:e41126528cc6 | 580 | Vector2D snakepos_b5 = {_x[0],_y[0]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 581 | return snakepos_b5; |
AhmedPlaymaker | 13:9785f2404045 | 582 | } |
AhmedPlaymaker | 13:9785f2404045 | 583 | else if(length==7) { |
AhmedPlaymaker | 21:e41126528cc6 | 584 | Vector2D snakepos_b5 = {_x[1],_y[1]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 585 | return snakepos_b5; |
AhmedPlaymaker | 13:9785f2404045 | 586 | } |
AhmedPlaymaker | 13:9785f2404045 | 587 | else if(length==8) { |
AhmedPlaymaker | 21:e41126528cc6 | 588 | Vector2D snakepos_b5 = {_x[2],_y[2]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 589 | return snakepos_b5; |
AhmedPlaymaker | 13:9785f2404045 | 590 | } |
AhmedPlaymaker | 13:9785f2404045 | 591 | else if(length==9) { |
AhmedPlaymaker | 21:e41126528cc6 | 592 | Vector2D snakepos_b5 = {_x[3],_y[3]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 593 | return snakepos_b5; |
AhmedPlaymaker | 13:9785f2404045 | 594 | } |
AhmedPlaymaker | 13:9785f2404045 | 595 | else if(length==10) { |
AhmedPlaymaker | 21:e41126528cc6 | 596 | Vector2D snakepos_b5 = {_x[4],_y[4]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 597 | return snakepos_b5; |
AhmedPlaymaker | 13:9785f2404045 | 598 | } |
AhmedPlaymaker | 13:9785f2404045 | 599 | else if(length==11) { |
AhmedPlaymaker | 21:e41126528cc6 | 600 | Vector2D snakepos_b5 = {_x[5],_y[5]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 601 | return snakepos_b5; |
AhmedPlaymaker | 13:9785f2404045 | 602 | } |
AhmedPlaymaker | 13:9785f2404045 | 603 | else if(length==12) { |
AhmedPlaymaker | 21:e41126528cc6 | 604 | Vector2D snakepos_b5 = {_x[6],_y[6]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 605 | return snakepos_b5; |
AhmedPlaymaker | 13:9785f2404045 | 606 | } |
AhmedPlaymaker | 13:9785f2404045 | 607 | else if(length==13) { |
AhmedPlaymaker | 21:e41126528cc6 | 608 | Vector2D snakepos_b5 = {_x[7],_y[7]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 609 | return snakepos_b5; |
AhmedPlaymaker | 13:9785f2404045 | 610 | } |
AhmedPlaymaker | 13:9785f2404045 | 611 | else if(length==14) { |
AhmedPlaymaker | 21:e41126528cc6 | 612 | Vector2D snakepos_b5 = {_x[8],_y[8]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 613 | return snakepos_b5; |
AhmedPlaymaker | 13:9785f2404045 | 614 | } |
AhmedPlaymaker | 13:9785f2404045 | 615 | else if(length==15) { |
AhmedPlaymaker | 21:e41126528cc6 | 616 | Vector2D snakepos_b5 = {_x[9],_y[9]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 617 | return snakepos_b5; |
AhmedPlaymaker | 13:9785f2404045 | 618 | } |
AhmedPlaymaker | 13:9785f2404045 | 619 | //printf("snakepos from player = %f %f \n", snakepos.x, snakepos.y); |
AhmedPlaymaker | 13:9785f2404045 | 620 | else { |
AhmedPlaymaker | 13:9785f2404045 | 621 | Vector2D snakepos_b5 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 622 | return snakepos_b5; |
AhmedPlaymaker | 13:9785f2404045 | 623 | } |
AhmedPlaymaker | 13:9785f2404045 | 624 | } |
AhmedPlaymaker | 13:9785f2404045 | 625 | |
AhmedPlaymaker | 13:9785f2404045 | 626 | Vector2D Snake::get_pos_before6(int length) //this sends data of following sprites. |
AhmedPlaymaker | 13:9785f2404045 | 627 | { |
AhmedPlaymaker | 21:e41126528cc6 | 628 | if(length == 7) { |
AhmedPlaymaker | 21:e41126528cc6 | 629 | Vector2D snakepos_b6 = {_x[0],_y[0]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 630 | return snakepos_b6; |
AhmedPlaymaker | 13:9785f2404045 | 631 | } |
AhmedPlaymaker | 13:9785f2404045 | 632 | else if(length==8) { |
AhmedPlaymaker | 21:e41126528cc6 | 633 | Vector2D snakepos_b6 = {_x[1],_y[1]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 634 | return snakepos_b6; |
AhmedPlaymaker | 13:9785f2404045 | 635 | } |
AhmedPlaymaker | 13:9785f2404045 | 636 | else if(length==9) { |
AhmedPlaymaker | 21:e41126528cc6 | 637 | Vector2D snakepos_b6 = {_x[2],_y[2]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 638 | return snakepos_b6; |
AhmedPlaymaker | 13:9785f2404045 | 639 | } |
AhmedPlaymaker | 13:9785f2404045 | 640 | else if(length==10) { |
AhmedPlaymaker | 21:e41126528cc6 | 641 | Vector2D snakepos_b6 = {_x[3],_y[3]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 642 | return snakepos_b6; |
AhmedPlaymaker | 13:9785f2404045 | 643 | } |
AhmedPlaymaker | 13:9785f2404045 | 644 | else if(length==11) { |
AhmedPlaymaker | 21:e41126528cc6 | 645 | Vector2D snakepos_b6 = {_x[4],_y[4]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 646 | return snakepos_b6; |
AhmedPlaymaker | 13:9785f2404045 | 647 | } |
AhmedPlaymaker | 13:9785f2404045 | 648 | else if(length==12) { |
AhmedPlaymaker | 21:e41126528cc6 | 649 | Vector2D snakepos_b6 = {_x[5],_y[5]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 650 | return snakepos_b6; |
AhmedPlaymaker | 13:9785f2404045 | 651 | } |
AhmedPlaymaker | 13:9785f2404045 | 652 | else if(length==13) { |
AhmedPlaymaker | 21:e41126528cc6 | 653 | Vector2D snakepos_b6 = {_x[6],_y[6]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 654 | return snakepos_b6; |
AhmedPlaymaker | 13:9785f2404045 | 655 | } |
AhmedPlaymaker | 13:9785f2404045 | 656 | else if(length==14) { |
AhmedPlaymaker | 21:e41126528cc6 | 657 | Vector2D snakepos_b6 = {_x[7],_y[7]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 658 | return snakepos_b6; |
AhmedPlaymaker | 13:9785f2404045 | 659 | } |
AhmedPlaymaker | 13:9785f2404045 | 660 | else if(length==15) { |
AhmedPlaymaker | 21:e41126528cc6 | 661 | Vector2D snakepos_b6 = {_x[8],_y[8]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 662 | return snakepos_b6; |
AhmedPlaymaker | 13:9785f2404045 | 663 | } |
AhmedPlaymaker | 13:9785f2404045 | 664 | //printf("snakepos from player = %f %f \n", snakepos.x, snakepos.y); |
AhmedPlaymaker | 13:9785f2404045 | 665 | else { |
AhmedPlaymaker | 13:9785f2404045 | 666 | Vector2D snakepos_b6 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 667 | return snakepos_b6; |
AhmedPlaymaker | 13:9785f2404045 | 668 | } |
AhmedPlaymaker | 13:9785f2404045 | 669 | } |
AhmedPlaymaker | 13:9785f2404045 | 670 | |
AhmedPlaymaker | 13:9785f2404045 | 671 | Vector2D Snake::get_pos_before7(int length) //this sends data of following sprites. |
AhmedPlaymaker | 13:9785f2404045 | 672 | { |
AhmedPlaymaker | 21:e41126528cc6 | 673 | if(length == 8) { |
AhmedPlaymaker | 21:e41126528cc6 | 674 | Vector2D snakepos_b7 = {_x[0],_y[0]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 675 | return snakepos_b7; |
AhmedPlaymaker | 13:9785f2404045 | 676 | } |
AhmedPlaymaker | 13:9785f2404045 | 677 | else if(length==9) { |
AhmedPlaymaker | 21:e41126528cc6 | 678 | Vector2D snakepos_b7 = {_x[1],_y[1]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 679 | return snakepos_b7; |
AhmedPlaymaker | 13:9785f2404045 | 680 | } |
AhmedPlaymaker | 13:9785f2404045 | 681 | else if(length==10) { |
AhmedPlaymaker | 21:e41126528cc6 | 682 | Vector2D snakepos_b7 = {_x[2],_y[2]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 683 | return snakepos_b7; |
AhmedPlaymaker | 13:9785f2404045 | 684 | } |
AhmedPlaymaker | 13:9785f2404045 | 685 | else if(length==11) { |
AhmedPlaymaker | 21:e41126528cc6 | 686 | Vector2D snakepos_b7 = {_x[3],_y[3]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 687 | return snakepos_b7; |
AhmedPlaymaker | 13:9785f2404045 | 688 | } |
AhmedPlaymaker | 13:9785f2404045 | 689 | else if(length==12) { |
AhmedPlaymaker | 21:e41126528cc6 | 690 | Vector2D snakepos_b7 = {_x[4],_y[4]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 691 | return snakepos_b7; |
AhmedPlaymaker | 13:9785f2404045 | 692 | } |
AhmedPlaymaker | 13:9785f2404045 | 693 | else if(length==13) { |
AhmedPlaymaker | 21:e41126528cc6 | 694 | Vector2D snakepos_b7 = {_x[5],_y[5]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 695 | return snakepos_b7; |
AhmedPlaymaker | 13:9785f2404045 | 696 | } |
AhmedPlaymaker | 13:9785f2404045 | 697 | else if(length==14) { |
AhmedPlaymaker | 21:e41126528cc6 | 698 | Vector2D snakepos_b7 = {_x[6],_y[6]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 699 | return snakepos_b7; |
AhmedPlaymaker | 13:9785f2404045 | 700 | } |
AhmedPlaymaker | 13:9785f2404045 | 701 | else if(length==15) { |
AhmedPlaymaker | 21:e41126528cc6 | 702 | Vector2D snakepos_b7 = {_x[7],_y[7]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 703 | return snakepos_b7; |
AhmedPlaymaker | 13:9785f2404045 | 704 | } |
AhmedPlaymaker | 13:9785f2404045 | 705 | //printf("snakepos from player = %f %f \n", snakepos.x, snakepos.y); |
AhmedPlaymaker | 13:9785f2404045 | 706 | else { |
AhmedPlaymaker | 13:9785f2404045 | 707 | Vector2D snakepos_b7 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 708 | return snakepos_b7; |
AhmedPlaymaker | 13:9785f2404045 | 709 | } |
AhmedPlaymaker | 7:48ba87cd79b5 | 710 | } |
AhmedPlaymaker | 7:48ba87cd79b5 | 711 | |
AhmedPlaymaker | 13:9785f2404045 | 712 | Vector2D Snake::get_pos_before8(int length) //this sends data of following sprites. |
AhmedPlaymaker | 13:9785f2404045 | 713 | { |
AhmedPlaymaker | 21:e41126528cc6 | 714 | if(length == 9) { |
AhmedPlaymaker | 21:e41126528cc6 | 715 | Vector2D snakepos_b8 = {_x[0],_y[0]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 716 | return snakepos_b8; |
AhmedPlaymaker | 13:9785f2404045 | 717 | } |
AhmedPlaymaker | 13:9785f2404045 | 718 | else if(length==10) { |
AhmedPlaymaker | 21:e41126528cc6 | 719 | Vector2D snakepos_b8 = {_x[1],_y[1]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 720 | return snakepos_b8; |
AhmedPlaymaker | 13:9785f2404045 | 721 | } |
AhmedPlaymaker | 13:9785f2404045 | 722 | else if(length==11) { |
AhmedPlaymaker | 21:e41126528cc6 | 723 | Vector2D snakepos_b8 = {_x[2],_y[2]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 724 | return snakepos_b8; |
AhmedPlaymaker | 13:9785f2404045 | 725 | } |
AhmedPlaymaker | 13:9785f2404045 | 726 | else if(length==12) { |
AhmedPlaymaker | 21:e41126528cc6 | 727 | Vector2D snakepos_b8 = {_x[3],_y[3]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 728 | return snakepos_b8; |
AhmedPlaymaker | 13:9785f2404045 | 729 | } |
AhmedPlaymaker | 13:9785f2404045 | 730 | else if(length==13) { |
AhmedPlaymaker | 21:e41126528cc6 | 731 | Vector2D snakepos_b8 = {_x[4],_y[4]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 732 | return snakepos_b8; |
AhmedPlaymaker | 13:9785f2404045 | 733 | } |
AhmedPlaymaker | 13:9785f2404045 | 734 | else if(length==14) { |
AhmedPlaymaker | 21:e41126528cc6 | 735 | Vector2D snakepos_b8 = {_x[5],_y[5]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 736 | return snakepos_b8; |
AhmedPlaymaker | 13:9785f2404045 | 737 | } |
AhmedPlaymaker | 13:9785f2404045 | 738 | else if(length==15) { |
AhmedPlaymaker | 21:e41126528cc6 | 739 | Vector2D snakepos_b8 = {_x[6],_y[6]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 740 | return snakepos_b8; |
AhmedPlaymaker | 13:9785f2404045 | 741 | } |
AhmedPlaymaker | 13:9785f2404045 | 742 | //printf("snakepos from player = %f %f \n", snakepos.x, snakepos.y); |
AhmedPlaymaker | 13:9785f2404045 | 743 | else { |
AhmedPlaymaker | 13:9785f2404045 | 744 | Vector2D snakepos_b8 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 745 | return snakepos_b8; |
AhmedPlaymaker | 13:9785f2404045 | 746 | } |
AhmedPlaymaker | 13:9785f2404045 | 747 | } |
AhmedPlaymaker | 7:48ba87cd79b5 | 748 | |
AhmedPlaymaker | 13:9785f2404045 | 749 | Vector2D Snake::get_pos_before9(int length) //this sends data of following sprites. |
AhmedPlaymaker | 13:9785f2404045 | 750 | { |
AhmedPlaymaker | 21:e41126528cc6 | 751 | if(length == 10) { |
AhmedPlaymaker | 21:e41126528cc6 | 752 | Vector2D snakepos_b9 = {_x[0],_y[0]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 753 | return snakepos_b9; |
AhmedPlaymaker | 13:9785f2404045 | 754 | } |
AhmedPlaymaker | 13:9785f2404045 | 755 | else if(length==11) { |
AhmedPlaymaker | 21:e41126528cc6 | 756 | Vector2D snakepos_b9 = {_x[1],_y[1]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 757 | return snakepos_b9; |
AhmedPlaymaker | 13:9785f2404045 | 758 | } |
AhmedPlaymaker | 13:9785f2404045 | 759 | else if(length==12) { |
AhmedPlaymaker | 21:e41126528cc6 | 760 | Vector2D snakepos_b9 = {_x[2],_y[2]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 761 | return snakepos_b9; |
AhmedPlaymaker | 13:9785f2404045 | 762 | } |
AhmedPlaymaker | 13:9785f2404045 | 763 | else if(length==13) { |
AhmedPlaymaker | 21:e41126528cc6 | 764 | Vector2D snakepos_b9 = {_x[3],_y[3]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 765 | return snakepos_b9; |
AhmedPlaymaker | 13:9785f2404045 | 766 | } |
AhmedPlaymaker | 13:9785f2404045 | 767 | else if(length==14) { |
AhmedPlaymaker | 21:e41126528cc6 | 768 | Vector2D snakepos_b9 = {_x[4],_y[4]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 769 | return snakepos_b9; |
AhmedPlaymaker | 13:9785f2404045 | 770 | } |
AhmedPlaymaker | 13:9785f2404045 | 771 | else if(length==15) { |
AhmedPlaymaker | 21:e41126528cc6 | 772 | Vector2D snakepos_b9 = {_x[5],_y[5]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 773 | return snakepos_b9; |
AhmedPlaymaker | 13:9785f2404045 | 774 | } |
AhmedPlaymaker | 13:9785f2404045 | 775 | //printf("snakepos from player = %f %f \n", snakepos.x, snakepos.y); |
AhmedPlaymaker | 13:9785f2404045 | 776 | else { |
AhmedPlaymaker | 13:9785f2404045 | 777 | Vector2D snakepos_b9 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 778 | return snakepos_b9; |
AhmedPlaymaker | 13:9785f2404045 | 779 | } |
AhmedPlaymaker | 13:9785f2404045 | 780 | } |
AhmedPlaymaker | 13:9785f2404045 | 781 | |
AhmedPlaymaker | 13:9785f2404045 | 782 | Vector2D Snake::get_pos_before10(int length) //this sends data of following sprites. |
AhmedPlaymaker | 13:9785f2404045 | 783 | { |
AhmedPlaymaker | 21:e41126528cc6 | 784 | if(length == 11) { |
AhmedPlaymaker | 21:e41126528cc6 | 785 | Vector2D snakepos_b10 = {_x[0],_y[0]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 786 | return snakepos_b10; |
AhmedPlaymaker | 13:9785f2404045 | 787 | } |
AhmedPlaymaker | 13:9785f2404045 | 788 | else if(length==12) { |
AhmedPlaymaker | 21:e41126528cc6 | 789 | Vector2D snakepos_b10 = {_x[1],_y[1]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 790 | return snakepos_b10; |
AhmedPlaymaker | 13:9785f2404045 | 791 | } |
AhmedPlaymaker | 13:9785f2404045 | 792 | else if(length==13) { |
AhmedPlaymaker | 21:e41126528cc6 | 793 | Vector2D snakepos_b10 = {_x[2],_y[2]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 794 | return snakepos_b10; |
AhmedPlaymaker | 13:9785f2404045 | 795 | } |
AhmedPlaymaker | 13:9785f2404045 | 796 | else if(length==14) { |
AhmedPlaymaker | 21:e41126528cc6 | 797 | Vector2D snakepos_b10 = {_x[3],_y[3]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 798 | return snakepos_b10; |
AhmedPlaymaker | 13:9785f2404045 | 799 | } |
AhmedPlaymaker | 13:9785f2404045 | 800 | else if(length==15) { |
AhmedPlaymaker | 21:e41126528cc6 | 801 | Vector2D snakepos_b10 = {_x[4],_y[4]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 802 | return snakepos_b10; |
AhmedPlaymaker | 13:9785f2404045 | 803 | } |
AhmedPlaymaker | 13:9785f2404045 | 804 | //printf("snakepos from player = %f %f \n", snakepos.x, snakepos.y); |
AhmedPlaymaker | 13:9785f2404045 | 805 | else { |
AhmedPlaymaker | 13:9785f2404045 | 806 | Vector2D snakepos_b10 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 807 | return snakepos_b10; |
AhmedPlaymaker | 13:9785f2404045 | 808 | } |
AhmedPlaymaker | 13:9785f2404045 | 809 | } |
AhmedPlaymaker | 13:9785f2404045 | 810 | |
AhmedPlaymaker | 13:9785f2404045 | 811 | Vector2D Snake::get_pos_before11(int length) //this sends data of following sprites. |
AhmedPlaymaker | 13:9785f2404045 | 812 | { |
AhmedPlaymaker | 21:e41126528cc6 | 813 | if(length == 12) { |
AhmedPlaymaker | 21:e41126528cc6 | 814 | Vector2D snakepos_b11 = {_x[0],_y[0]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 815 | return snakepos_b11; |
AhmedPlaymaker | 13:9785f2404045 | 816 | } |
AhmedPlaymaker | 13:9785f2404045 | 817 | else if(length==13) { |
AhmedPlaymaker | 21:e41126528cc6 | 818 | Vector2D snakepos_b11 = {_x[1],_y[1]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 819 | return snakepos_b11; |
AhmedPlaymaker | 13:9785f2404045 | 820 | } |
AhmedPlaymaker | 13:9785f2404045 | 821 | else if(length==14) { |
AhmedPlaymaker | 21:e41126528cc6 | 822 | Vector2D snakepos_b11 = {_x[2],_y[2]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 823 | return snakepos_b11; |
AhmedPlaymaker | 13:9785f2404045 | 824 | } |
AhmedPlaymaker | 13:9785f2404045 | 825 | else if(length==15) { |
AhmedPlaymaker | 21:e41126528cc6 | 826 | Vector2D snakepos_b11 = {_x[3],_y[3]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 827 | return snakepos_b11; |
AhmedPlaymaker | 13:9785f2404045 | 828 | } |
AhmedPlaymaker | 13:9785f2404045 | 829 | //printf("snakepos from player = %f %f \n", snakepos.x, snakepos.y); |
AhmedPlaymaker | 13:9785f2404045 | 830 | else { |
AhmedPlaymaker | 13:9785f2404045 | 831 | Vector2D snakepos_b11 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 832 | return snakepos_b11; |
AhmedPlaymaker | 13:9785f2404045 | 833 | } |
AhmedPlaymaker | 13:9785f2404045 | 834 | } |
AhmedPlaymaker | 13:9785f2404045 | 835 | |
AhmedPlaymaker | 13:9785f2404045 | 836 | Vector2D Snake::get_pos_before12(int length) //this sends data of following sprites. |
AhmedPlaymaker | 7:48ba87cd79b5 | 837 | { |
AhmedPlaymaker | 21:e41126528cc6 | 838 | if(length == 13) { |
AhmedPlaymaker | 21:e41126528cc6 | 839 | Vector2D snakepos_b12 = {_x[0],_y[0]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 840 | return snakepos_b12; |
AhmedPlaymaker | 13:9785f2404045 | 841 | } |
AhmedPlaymaker | 13:9785f2404045 | 842 | else if(length==14) { |
AhmedPlaymaker | 21:e41126528cc6 | 843 | Vector2D snakepos_b12 = {_x[1],_y[1]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 844 | return snakepos_b12; |
AhmedPlaymaker | 13:9785f2404045 | 845 | } |
AhmedPlaymaker | 13:9785f2404045 | 846 | else if(length==15) { |
AhmedPlaymaker | 21:e41126528cc6 | 847 | Vector2D snakepos_b12 = {_x[2],_y[2]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 848 | return snakepos_b12; |
AhmedPlaymaker | 13:9785f2404045 | 849 | } |
AhmedPlaymaker | 13:9785f2404045 | 850 | //printf("snakepos from player = %f %f \n", snakepos.x, snakepos.y); |
AhmedPlaymaker | 13:9785f2404045 | 851 | else { |
AhmedPlaymaker | 13:9785f2404045 | 852 | Vector2D snakepos_b12 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 853 | return snakepos_b12; |
AhmedPlaymaker | 13:9785f2404045 | 854 | } |
AhmedPlaymaker | 13:9785f2404045 | 855 | } |
AhmedPlaymaker | 13:9785f2404045 | 856 | |
AhmedPlaymaker | 13:9785f2404045 | 857 | Vector2D Snake::get_pos_before13(int length) //this sends data of following sprites. |
AhmedPlaymaker | 13:9785f2404045 | 858 | { |
AhmedPlaymaker | 21:e41126528cc6 | 859 | if(length == 14) { |
AhmedPlaymaker | 21:e41126528cc6 | 860 | Vector2D snakepos_b13 = {_x[0],_y[0]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 861 | return snakepos_b13; |
AhmedPlaymaker | 13:9785f2404045 | 862 | } |
AhmedPlaymaker | 13:9785f2404045 | 863 | else if(length==15) { |
AhmedPlaymaker | 21:e41126528cc6 | 864 | Vector2D snakepos_b13 = {_x[1],_y[1]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 865 | return snakepos_b13; |
AhmedPlaymaker | 13:9785f2404045 | 866 | } |
AhmedPlaymaker | 13:9785f2404045 | 867 | //printf("snakepos from player = %f %f \n", snakepos.x, snakepos.y); |
AhmedPlaymaker | 13:9785f2404045 | 868 | else { |
AhmedPlaymaker | 13:9785f2404045 | 869 | Vector2D snakepos_b13 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 870 | return snakepos_b13; |
AhmedPlaymaker | 13:9785f2404045 | 871 | } |
AhmedPlaymaker | 13:9785f2404045 | 872 | } |
AhmedPlaymaker | 13:9785f2404045 | 873 | |
AhmedPlaymaker | 13:9785f2404045 | 874 | Vector2D Snake::get_pos_before14(int length) //this sends data of following sprites. |
AhmedPlaymaker | 13:9785f2404045 | 875 | { |
AhmedPlaymaker | 21:e41126528cc6 | 876 | if(length==15) { |
AhmedPlaymaker | 21:e41126528cc6 | 877 | Vector2D snakepos_b14 = {_x[0],_y[0]}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 878 | return snakepos_b14; |
AhmedPlaymaker | 13:9785f2404045 | 879 | } |
AhmedPlaymaker | 13:9785f2404045 | 880 | else { |
AhmedPlaymaker | 13:9785f2404045 | 881 | Vector2D snakepos_b14 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 882 | return snakepos_b14; |
AhmedPlaymaker | 13:9785f2404045 | 883 | } |
AhmedPlaymaker | 21:e41126528cc6 | 884 | //printf("snakepos from player = %f %f \n", snakepos.x, snakepos.y); |
AhmedPlaymaker | 13:9785f2404045 | 885 | } |
AhmedPlaymaker | 13:9785f2404045 | 886 | |
AhmedPlaymaker | 18:b391caa5754c | 887 | |
AhmedPlaymaker | 13:9785f2404045 | 888 | |
AhmedPlaymaker | 18:b391caa5754c | 889 | void Snake::update(Direction d,float mag,int length, int speed, int* b0_to_b14) |
AhmedPlaymaker | 13:9785f2404045 | 890 | { |
AhmedPlaymaker | 13:9785f2404045 | 891 | _speed = speed; //Speed changes depending on how much you push the joystick.(As Of Now) |
AhmedPlaymaker | 21:e41126528cc6 | 892 | b[0] = b0_to_b14[0]; |
AhmedPlaymaker | 21:e41126528cc6 | 893 | b[1] = b0_to_b14[1]; |
AhmedPlaymaker | 21:e41126528cc6 | 894 | b[2] = b0_to_b14[2]; |
AhmedPlaymaker | 21:e41126528cc6 | 895 | b[3] = b0_to_b14[3]; |
AhmedPlaymaker | 21:e41126528cc6 | 896 | b[4] = b0_to_b14[4]; |
AhmedPlaymaker | 21:e41126528cc6 | 897 | b[5] = b0_to_b14[5]; |
AhmedPlaymaker | 21:e41126528cc6 | 898 | b[6] = b0_to_b14[6]; |
AhmedPlaymaker | 21:e41126528cc6 | 899 | b[7] = b0_to_b14[7]; |
AhmedPlaymaker | 21:e41126528cc6 | 900 | b[8] = b0_to_b14[8]; |
AhmedPlaymaker | 21:e41126528cc6 | 901 | b[9] = b0_to_b14[9]; |
AhmedPlaymaker | 21:e41126528cc6 | 902 | b[10] = b0_to_b14[10]; |
AhmedPlaymaker | 21:e41126528cc6 | 903 | b[11] = b0_to_b14[11]; |
AhmedPlaymaker | 21:e41126528cc6 | 904 | b[12] = b0_to_b14[12]; |
AhmedPlaymaker | 21:e41126528cc6 | 905 | b[13] = b0_to_b14[13]; |
AhmedPlaymaker | 21:e41126528cc6 | 906 | b[14] = b0_to_b14[14]; |
AhmedPlaymaker | 8:890b986b16a4 | 907 | |
AhmedPlaymaker | 8:890b986b16a4 | 908 | if(length > 1) { |
AhmedPlaymaker | 21:e41126528cc6 | 909 | if ((_x[0] > _x[1])&&(b[1] == 1)&&(b[0] == 1)) { |
AhmedPlaymaker | 21:e41126528cc6 | 910 | _x[0]-=_speed; |
AhmedPlaymaker | 8:890b986b16a4 | 911 | } |
AhmedPlaymaker | 21:e41126528cc6 | 912 | if ((_x[0] < _x[1])&&(b[1] == 1)&&(b[0] == 1)) { |
AhmedPlaymaker | 21:e41126528cc6 | 913 | _x[0]+=_speed; |
AhmedPlaymaker | 21:e41126528cc6 | 914 | } |
AhmedPlaymaker | 21:e41126528cc6 | 915 | } |
AhmedPlaymaker | 21:e41126528cc6 | 916 | if(length > 2) { |
AhmedPlaymaker | 21:e41126528cc6 | 917 | if ((_x[1] > _x[2])&&(b[2] == 1)&&(b[1] == 1)) { |
AhmedPlaymaker | 21:e41126528cc6 | 918 | _x[1]-=_speed; |
AhmedPlaymaker | 8:890b986b16a4 | 919 | } |
AhmedPlaymaker | 21:e41126528cc6 | 920 | if ((_x[1] < _x[2])&&(b[2] == 1)&&(b[1] == 1)) { |
AhmedPlaymaker | 21:e41126528cc6 | 921 | _x[1]+=_speed; |
AhmedPlaymaker | 21:e41126528cc6 | 922 | } |
AhmedPlaymaker | 21:e41126528cc6 | 923 | } |
AhmedPlaymaker | 21:e41126528cc6 | 924 | if(length > 3) { |
AhmedPlaymaker | 21:e41126528cc6 | 925 | if ((_x[2] > _x[3])&&(b[3] == 1)&&(b[2] == 1)) { |
AhmedPlaymaker | 21:e41126528cc6 | 926 | _x[2]-=_speed; |
AhmedPlaymaker | 8:890b986b16a4 | 927 | } |
AhmedPlaymaker | 21:e41126528cc6 | 928 | if ((_x[2] < _x[3])&&(b[3] == 1)&&(b[2] == 1)) { |
AhmedPlaymaker | 21:e41126528cc6 | 929 | _x[2]+=_speed; |
AhmedPlaymaker | 8:890b986b16a4 | 930 | } |
AhmedPlaymaker | 21:e41126528cc6 | 931 | } |
AhmedPlaymaker | 21:e41126528cc6 | 932 | if(length > 4) { |
AhmedPlaymaker | 21:e41126528cc6 | 933 | if ((_x[3] > _x[4])&&(b[4] == 1)&&(b[3] == 1)) { |
AhmedPlaymaker | 21:e41126528cc6 | 934 | _x[3]-=_speed; |
AhmedPlaymaker | 21:e41126528cc6 | 935 | } |
AhmedPlaymaker | 21:e41126528cc6 | 936 | if ((_x[3] < _x[4])&&(b[4] == 1)&&(b[3] == 1)) { |
AhmedPlaymaker | 21:e41126528cc6 | 937 | _x[3]+=_speed; |
AhmedPlaymaker | 21:e41126528cc6 | 938 | } |
AhmedPlaymaker | 21:e41126528cc6 | 939 | } |
AhmedPlaymaker | 21:e41126528cc6 | 940 | if(length > 5) { |
AhmedPlaymaker | 21:e41126528cc6 | 941 | if ((_x[4] > _x[5])&&(b[5] == 1)&&(b[4] == 1)) { |
AhmedPlaymaker | 21:e41126528cc6 | 942 | _x[4]-=_speed; |
AhmedPlaymaker | 21:e41126528cc6 | 943 | } |
AhmedPlaymaker | 21:e41126528cc6 | 944 | if ((_x[4] < _x[5])&&(b[5] == 1)&&(b[4] == 1)) { |
AhmedPlaymaker | 21:e41126528cc6 | 945 | _x[4]+=_speed; |
AhmedPlaymaker | 21:e41126528cc6 | 946 | } |
AhmedPlaymaker | 21:e41126528cc6 | 947 | } |
AhmedPlaymaker | 21:e41126528cc6 | 948 | if(length > 6) { |
AhmedPlaymaker | 21:e41126528cc6 | 949 | if ((_x[5] > _x[6])&&(b[6] == 1)&&(b[5] == 1)) { |
AhmedPlaymaker | 21:e41126528cc6 | 950 | _x[5]-=_speed; |
AhmedPlaymaker | 21:e41126528cc6 | 951 | } |
AhmedPlaymaker | 21:e41126528cc6 | 952 | if ((_x[5] < _x[6])&&(b[6] == 1)&&(b[5] == 1)) { |
AhmedPlaymaker | 21:e41126528cc6 | 953 | _x[5]+=_speed; |
AhmedPlaymaker | 21:e41126528cc6 | 954 | } |
AhmedPlaymaker | 21:e41126528cc6 | 955 | } |
AhmedPlaymaker | 21:e41126528cc6 | 956 | if(length > 7) { |
AhmedPlaymaker | 21:e41126528cc6 | 957 | if ((_x[6] > _x[7])&&(b[7] == 1)&&(b[6] == 1)) { |
AhmedPlaymaker | 21:e41126528cc6 | 958 | _x[6]-=_speed; |
AhmedPlaymaker | 21:e41126528cc6 | 959 | } |
AhmedPlaymaker | 21:e41126528cc6 | 960 | if ((_x[6] < _x[7])&&(b[7] == 1)&&(b[6] == 1)) { |
AhmedPlaymaker | 21:e41126528cc6 | 961 | _x[6]+=_speed; |
AhmedPlaymaker | 21:e41126528cc6 | 962 | } |
AhmedPlaymaker | 21:e41126528cc6 | 963 | } |
AhmedPlaymaker | 21:e41126528cc6 | 964 | if(length > 8) { |
AhmedPlaymaker | 21:e41126528cc6 | 965 | if ((_x[7] > _x[8])&&(b[8] == 1)&&(b[7] == 1)) { |
AhmedPlaymaker | 21:e41126528cc6 | 966 | _x[7]-=_speed; |
AhmedPlaymaker | 21:e41126528cc6 | 967 | } |
AhmedPlaymaker | 21:e41126528cc6 | 968 | if ((_x[7] < _x[8])&&(b[8] == 1)&&(b[7] == 1)) { |
AhmedPlaymaker | 21:e41126528cc6 | 969 | _x[7]+=_speed; |
AhmedPlaymaker | 21:e41126528cc6 | 970 | } |
AhmedPlaymaker | 21:e41126528cc6 | 971 | } |
AhmedPlaymaker | 21:e41126528cc6 | 972 | if(length > 9) { |
AhmedPlaymaker | 21:e41126528cc6 | 973 | if ((_x[8] > _x[9])&&(b[9] == 1)&&(b[8] == 1)) { |
AhmedPlaymaker | 21:e41126528cc6 | 974 | _x[8]-=_speed; |
AhmedPlaymaker | 21:e41126528cc6 | 975 | } |
AhmedPlaymaker | 21:e41126528cc6 | 976 | if ((_x[8] < _x[9])&&(b[9] == 1)&&(b[8] == 1)) { |
AhmedPlaymaker | 21:e41126528cc6 | 977 | _x[8]+=_speed; |
AhmedPlaymaker | 21:e41126528cc6 | 978 | } |
AhmedPlaymaker | 21:e41126528cc6 | 979 | } |
AhmedPlaymaker | 21:e41126528cc6 | 980 | if(length > 10) { |
AhmedPlaymaker | 21:e41126528cc6 | 981 | if ((_x[9] > _x[10])&&(b[10] == 1)&&(b[9] == 1)) { |
AhmedPlaymaker | 21:e41126528cc6 | 982 | _x[9]-=_speed; |
AhmedPlaymaker | 21:e41126528cc6 | 983 | } |
AhmedPlaymaker | 21:e41126528cc6 | 984 | if ((_x[9] < _x[10])&&(b[10] == 1)&&(b[9] == 1)) { |
AhmedPlaymaker | 21:e41126528cc6 | 985 | _x[9]+=_speed; |
AhmedPlaymaker | 21:e41126528cc6 | 986 | } |
AhmedPlaymaker | 21:e41126528cc6 | 987 | } |
AhmedPlaymaker | 21:e41126528cc6 | 988 | if(length > 11) { |
AhmedPlaymaker | 21:e41126528cc6 | 989 | if ((_x[10] > _x[11])&&(b[11] == 1)&&(b[10] == 1)) { |
AhmedPlaymaker | 21:e41126528cc6 | 990 | _x[10]-=_speed; |
AhmedPlaymaker | 21:e41126528cc6 | 991 | } |
AhmedPlaymaker | 21:e41126528cc6 | 992 | if ((_x[10] < _x[11])&&(b[11] == 1)&&(b[10] == 1)) { |
AhmedPlaymaker | 21:e41126528cc6 | 993 | _x[10]+=_speed; |
AhmedPlaymaker | 21:e41126528cc6 | 994 | } |
AhmedPlaymaker | 21:e41126528cc6 | 995 | } |
AhmedPlaymaker | 21:e41126528cc6 | 996 | if(length > 12) { |
AhmedPlaymaker | 21:e41126528cc6 | 997 | if ((_x[11] > _x[12])&&(b[12] == 1)&&(b[11] == 1)) { |
AhmedPlaymaker | 21:e41126528cc6 | 998 | _x[11]-=_speed; |
AhmedPlaymaker | 21:e41126528cc6 | 999 | } |
AhmedPlaymaker | 21:e41126528cc6 | 1000 | if ((_x[11] < _x[12])&&(b[12] == 1)&&(b[11] == 1)) { |
AhmedPlaymaker | 21:e41126528cc6 | 1001 | _x[11]+=_speed; |
AhmedPlaymaker | 21:e41126528cc6 | 1002 | } |
AhmedPlaymaker | 21:e41126528cc6 | 1003 | } |
AhmedPlaymaker | 21:e41126528cc6 | 1004 | if(length > 13) { |
AhmedPlaymaker | 21:e41126528cc6 | 1005 | if ((_x[12] > _x[13])&&(b[13] == 1)&&(b[12] == 1)) { |
AhmedPlaymaker | 21:e41126528cc6 | 1006 | _x[12]-=_speed; |
AhmedPlaymaker | 21:e41126528cc6 | 1007 | } |
AhmedPlaymaker | 21:e41126528cc6 | 1008 | if ((_x[12] < _x[13])&&(b[13] == 1)&&(b[12] == 1)) { |
AhmedPlaymaker | 21:e41126528cc6 | 1009 | _x[12]+=_speed; |
AhmedPlaymaker | 21:e41126528cc6 | 1010 | } |
AhmedPlaymaker | 21:e41126528cc6 | 1011 | } |
AhmedPlaymaker | 21:e41126528cc6 | 1012 | if(length > 14) { |
AhmedPlaymaker | 21:e41126528cc6 | 1013 | if ((_x[13] > _x[14])&&(b[14] == 1)&&(b[13] == 1)) { |
AhmedPlaymaker | 21:e41126528cc6 | 1014 | _x[13]-=_speed; |
AhmedPlaymaker | 21:e41126528cc6 | 1015 | } |
AhmedPlaymaker | 21:e41126528cc6 | 1016 | if ((_x[13] < _x[14])&&(b[14] == 1)&&(b[13] == 1)) { |
AhmedPlaymaker | 21:e41126528cc6 | 1017 | _x[13]+=_speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1018 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1019 | } |
AhmedPlaymaker | 21:e41126528cc6 | 1020 | |
AhmedPlaymaker | 21:e41126528cc6 | 1021 | if((length == 15)&&(b[14] == 1)) { |
AhmedPlaymaker | 8:890b986b16a4 | 1022 | if (d == E) { |
AhmedPlaymaker | 21:e41126528cc6 | 1023 | _x[14]+= _speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1024 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1025 | if (d == W) { |
AhmedPlaymaker | 21:e41126528cc6 | 1026 | _x[14]-= _speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1027 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1028 | } |
AhmedPlaymaker | 21:e41126528cc6 | 1029 | if((length == 14)&&(b[13] == 1)) { |
AhmedPlaymaker | 8:890b986b16a4 | 1030 | if (d == E) { |
AhmedPlaymaker | 21:e41126528cc6 | 1031 | _x[13]+= _speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1032 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1033 | if (d == W) { |
AhmedPlaymaker | 21:e41126528cc6 | 1034 | _x[13]-= _speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1035 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1036 | } |
AhmedPlaymaker | 21:e41126528cc6 | 1037 | if((length == 13)&&(b[12] == 1)) { |
AhmedPlaymaker | 8:890b986b16a4 | 1038 | if (d == E) { |
AhmedPlaymaker | 21:e41126528cc6 | 1039 | _x[12]+= _speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1040 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1041 | if (d == W) { |
AhmedPlaymaker | 21:e41126528cc6 | 1042 | _x[12]-= _speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1043 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1044 | } |
AhmedPlaymaker | 21:e41126528cc6 | 1045 | if((length == 12)&&(b[11] == 1)) { |
AhmedPlaymaker | 8:890b986b16a4 | 1046 | if (d == E) { |
AhmedPlaymaker | 21:e41126528cc6 | 1047 | _x[11]+= _speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1048 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1049 | if (d == W) { |
AhmedPlaymaker | 21:e41126528cc6 | 1050 | _x[11]-= _speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1051 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1052 | } |
AhmedPlaymaker | 21:e41126528cc6 | 1053 | if((length == 11)&&(b[10] == 1)) { |
AhmedPlaymaker | 8:890b986b16a4 | 1054 | if (d == E) { |
AhmedPlaymaker | 21:e41126528cc6 | 1055 | _x[10]+= _speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1056 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1057 | if (d == W) { |
AhmedPlaymaker | 21:e41126528cc6 | 1058 | _x[10]-= _speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1059 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1060 | } |
AhmedPlaymaker | 21:e41126528cc6 | 1061 | if((length == 10)&&(b[9] == 1)) { |
AhmedPlaymaker | 8:890b986b16a4 | 1062 | if (d == E) { |
AhmedPlaymaker | 21:e41126528cc6 | 1063 | _x[9]+= _speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1064 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1065 | if (d == W) { |
AhmedPlaymaker | 21:e41126528cc6 | 1066 | _x[9]-= _speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1067 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1068 | } |
AhmedPlaymaker | 21:e41126528cc6 | 1069 | if((length == 9)&&(b[8] == 1)) { |
AhmedPlaymaker | 8:890b986b16a4 | 1070 | if (d == E) { |
AhmedPlaymaker | 21:e41126528cc6 | 1071 | _x[8]+= _speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1072 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1073 | if (d == W) { |
AhmedPlaymaker | 21:e41126528cc6 | 1074 | _x[8]-= _speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1075 | } |
AhmedPlaymaker | 7:48ba87cd79b5 | 1076 | } |
AhmedPlaymaker | 21:e41126528cc6 | 1077 | if((length == 8)&&(b[7] == 1)) { |
AhmedPlaymaker | 8:890b986b16a4 | 1078 | if (d == E) { |
AhmedPlaymaker | 21:e41126528cc6 | 1079 | _x[7]+= _speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1080 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1081 | if (d == W) { |
AhmedPlaymaker | 21:e41126528cc6 | 1082 | _x[7]-= _speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1083 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1084 | } |
AhmedPlaymaker | 21:e41126528cc6 | 1085 | if((length == 7)&&(b[6] == 1)) { |
AhmedPlaymaker | 8:890b986b16a4 | 1086 | if (d == E) { |
AhmedPlaymaker | 21:e41126528cc6 | 1087 | _x[6]+= _speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1088 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1089 | if (d == W) { |
AhmedPlaymaker | 21:e41126528cc6 | 1090 | _x[6]-= _speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1091 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1092 | } |
AhmedPlaymaker | 21:e41126528cc6 | 1093 | if((length == 6)&&(b[5] == 1)) { |
AhmedPlaymaker | 8:890b986b16a4 | 1094 | if (d == E) { |
AhmedPlaymaker | 21:e41126528cc6 | 1095 | _x[5]+= _speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1096 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1097 | if (d == W) { |
AhmedPlaymaker | 21:e41126528cc6 | 1098 | _x[5]-= _speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1099 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1100 | } |
AhmedPlaymaker | 21:e41126528cc6 | 1101 | if((length == 5)&&(b[4] == 1)) { |
AhmedPlaymaker | 8:890b986b16a4 | 1102 | if (d == E) { |
AhmedPlaymaker | 21:e41126528cc6 | 1103 | _x[4]+= _speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1104 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1105 | if (d == W) { |
AhmedPlaymaker | 21:e41126528cc6 | 1106 | _x[4]-= _speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1107 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1108 | } |
AhmedPlaymaker | 21:e41126528cc6 | 1109 | if((length == 4)&&(b[3] == 1)) { |
AhmedPlaymaker | 8:890b986b16a4 | 1110 | if (d == E) { |
AhmedPlaymaker | 21:e41126528cc6 | 1111 | _x[3]+= _speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1112 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1113 | if (d == W) { |
AhmedPlaymaker | 21:e41126528cc6 | 1114 | _x[3]-= _speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1115 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1116 | } |
AhmedPlaymaker | 21:e41126528cc6 | 1117 | if((length == 3)&&(b[2] == 1)) { |
AhmedPlaymaker | 8:890b986b16a4 | 1118 | if (d == E) { |
AhmedPlaymaker | 21:e41126528cc6 | 1119 | _x[2]+= _speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1120 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1121 | if (d == W) { |
AhmedPlaymaker | 21:e41126528cc6 | 1122 | _x[2]-= _speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1123 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1124 | } |
AhmedPlaymaker | 21:e41126528cc6 | 1125 | if((length == 2)&&(b[1] == 1)) { |
AhmedPlaymaker | 8:890b986b16a4 | 1126 | if (d == E) { |
AhmedPlaymaker | 21:e41126528cc6 | 1127 | _x[1]+= _speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1128 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1129 | if (d == W) { |
AhmedPlaymaker | 21:e41126528cc6 | 1130 | _x[1]-= _speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1131 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1132 | } |
AhmedPlaymaker | 21:e41126528cc6 | 1133 | if((length == 1)&&(b[0] == 1)) { |
AhmedPlaymaker | 8:890b986b16a4 | 1134 | if (d == E) { |
AhmedPlaymaker | 21:e41126528cc6 | 1135 | _x[0]+= _speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1136 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1137 | if (d == W) { |
AhmedPlaymaker | 21:e41126528cc6 | 1138 | _x[0]-= _speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1139 | } |
AhmedPlaymaker | 7:48ba87cd79b5 | 1140 | } |
AhmedPlaymaker | 7:48ba87cd79b5 | 1141 | |
AhmedPlaymaker | 9:d1d79d4ee673 | 1142 | // the following makes sure that when the length is increased, the snake stays where it was when it ate food. |
AhmedPlaymaker | 7:48ba87cd79b5 | 1143 | |
AhmedPlaymaker | 9:d1d79d4ee673 | 1144 | if(length < 2) { |
AhmedPlaymaker | 21:e41126528cc6 | 1145 | _x[1] = _x[0]; |
AhmedPlaymaker | 9:d1d79d4ee673 | 1146 | } |
AhmedPlaymaker | 9:d1d79d4ee673 | 1147 | else if(length < 3) { |
AhmedPlaymaker | 21:e41126528cc6 | 1148 | _x[2] = _x[1]; |
AhmedPlaymaker | 9:d1d79d4ee673 | 1149 | } |
AhmedPlaymaker | 9:d1d79d4ee673 | 1150 | else if(length < 4) { |
AhmedPlaymaker | 21:e41126528cc6 | 1151 | _x[3] = _x[2]; |
AhmedPlaymaker | 9:d1d79d4ee673 | 1152 | } |
AhmedPlaymaker | 9:d1d79d4ee673 | 1153 | else if(length < 5) { |
AhmedPlaymaker | 21:e41126528cc6 | 1154 | _x[4] = _x[3]; |
AhmedPlaymaker | 9:d1d79d4ee673 | 1155 | } |
AhmedPlaymaker | 9:d1d79d4ee673 | 1156 | else if(length < 6) { |
AhmedPlaymaker | 21:e41126528cc6 | 1157 | _x[5] = _x[4]; |
AhmedPlaymaker | 9:d1d79d4ee673 | 1158 | } |
AhmedPlaymaker | 9:d1d79d4ee673 | 1159 | else if(length < 7) { |
AhmedPlaymaker | 21:e41126528cc6 | 1160 | _x[6] = _x[5]; |
AhmedPlaymaker | 9:d1d79d4ee673 | 1161 | } |
AhmedPlaymaker | 9:d1d79d4ee673 | 1162 | else if(length < 8) { |
AhmedPlaymaker | 21:e41126528cc6 | 1163 | _x[7] = _x[6]; |
AhmedPlaymaker | 9:d1d79d4ee673 | 1164 | } |
AhmedPlaymaker | 9:d1d79d4ee673 | 1165 | else if(length < 9) { |
AhmedPlaymaker | 21:e41126528cc6 | 1166 | _x[8] = _x[7]; |
AhmedPlaymaker | 9:d1d79d4ee673 | 1167 | } |
AhmedPlaymaker | 9:d1d79d4ee673 | 1168 | else if(length < 10) { |
AhmedPlaymaker | 21:e41126528cc6 | 1169 | _x[9] = _x[8]; |
AhmedPlaymaker | 9:d1d79d4ee673 | 1170 | } |
AhmedPlaymaker | 18:b391caa5754c | 1171 | else if(length < 11) { |
AhmedPlaymaker | 21:e41126528cc6 | 1172 | _x[10] = _x[9]; |
AhmedPlaymaker | 9:d1d79d4ee673 | 1173 | } |
AhmedPlaymaker | 9:d1d79d4ee673 | 1174 | else if(length < 12) { |
AhmedPlaymaker | 21:e41126528cc6 | 1175 | _x[11] = _x[10]; |
AhmedPlaymaker | 9:d1d79d4ee673 | 1176 | } |
AhmedPlaymaker | 9:d1d79d4ee673 | 1177 | else if(length < 13) { |
AhmedPlaymaker | 21:e41126528cc6 | 1178 | _x[12] = _x[11]; |
AhmedPlaymaker | 9:d1d79d4ee673 | 1179 | } |
AhmedPlaymaker | 9:d1d79d4ee673 | 1180 | else if(length < 14) { |
AhmedPlaymaker | 21:e41126528cc6 | 1181 | _x[13] = _x[12]; |
AhmedPlaymaker | 9:d1d79d4ee673 | 1182 | } |
AhmedPlaymaker | 9:d1d79d4ee673 | 1183 | else if(length < 15) { |
AhmedPlaymaker | 21:e41126528cc6 | 1184 | _x[14] = _x[13]; |
AhmedPlaymaker | 9:d1d79d4ee673 | 1185 | } |
AhmedPlaymaker | 9:d1d79d4ee673 | 1186 | |
AhmedPlaymaker | 7:48ba87cd79b5 | 1187 | //Limits set so that the sprite does not travel off the screen. |
AhmedPlaymaker | 21:e41126528cc6 | 1188 | if (_y[0] <= 0) { |
AhmedPlaymaker | 21:e41126528cc6 | 1189 | _y[0] = 0; |
AhmedPlaymaker | 7:48ba87cd79b5 | 1190 | } |
AhmedPlaymaker | 21:e41126528cc6 | 1191 | if (_x[0] <= 0) { |
AhmedPlaymaker | 21:e41126528cc6 | 1192 | _x[0] = 0; |
AhmedPlaymaker | 7:48ba87cd79b5 | 1193 | } |
AhmedPlaymaker | 21:e41126528cc6 | 1194 | if (_x[1] <= 0) { |
AhmedPlaymaker | 21:e41126528cc6 | 1195 | _x[1] = 0; |
AhmedPlaymaker | 8:890b986b16a4 | 1196 | } |
AhmedPlaymaker | 21:e41126528cc6 | 1197 | if (_x[2] <= 0) { |
AhmedPlaymaker | 21:e41126528cc6 | 1198 | _x[2] = 0; |
AhmedPlaymaker | 8:890b986b16a4 | 1199 | } |
AhmedPlaymaker | 21:e41126528cc6 | 1200 | if (_x[3] <= 0) { |
AhmedPlaymaker | 21:e41126528cc6 | 1201 | _x[3] = 0; |
AhmedPlaymaker | 8:890b986b16a4 | 1202 | } |
AhmedPlaymaker | 21:e41126528cc6 | 1203 | if (_x[4] <= 0) { |
AhmedPlaymaker | 21:e41126528cc6 | 1204 | _x[4] = 0; |
AhmedPlaymaker | 8:890b986b16a4 | 1205 | } |
AhmedPlaymaker | 21:e41126528cc6 | 1206 | if (_x[5] <= 0) { |
AhmedPlaymaker | 21:e41126528cc6 | 1207 | _x[5] = 0; |
AhmedPlaymaker | 8:890b986b16a4 | 1208 | } |
AhmedPlaymaker | 21:e41126528cc6 | 1209 | if (_x[6] <= 0) { |
AhmedPlaymaker | 21:e41126528cc6 | 1210 | _x[6] = 0; |
AhmedPlaymaker | 8:890b986b16a4 | 1211 | } |
AhmedPlaymaker | 21:e41126528cc6 | 1212 | if (_x[7] <= 0) { |
AhmedPlaymaker | 21:e41126528cc6 | 1213 | _x[7] = 0; |
AhmedPlaymaker | 8:890b986b16a4 | 1214 | } |
AhmedPlaymaker | 21:e41126528cc6 | 1215 | if (_x[8] <= 0) { |
AhmedPlaymaker | 21:e41126528cc6 | 1216 | _x[8] = 0; |
AhmedPlaymaker | 8:890b986b16a4 | 1217 | } |
AhmedPlaymaker | 21:e41126528cc6 | 1218 | if (_x[9] <= 0) { |
AhmedPlaymaker | 21:e41126528cc6 | 1219 | _x[9] = 0; |
AhmedPlaymaker | 8:890b986b16a4 | 1220 | } |
AhmedPlaymaker | 21:e41126528cc6 | 1221 | if (_x[10] <= 0) { |
AhmedPlaymaker | 21:e41126528cc6 | 1222 | _x[10] = 0; |
AhmedPlaymaker | 8:890b986b16a4 | 1223 | } |
AhmedPlaymaker | 21:e41126528cc6 | 1224 | if (_x[11] <= 0) { |
AhmedPlaymaker | 21:e41126528cc6 | 1225 | _x[11] = 0; |
AhmedPlaymaker | 8:890b986b16a4 | 1226 | } |
AhmedPlaymaker | 21:e41126528cc6 | 1227 | if (_x[12] <= 0) { |
AhmedPlaymaker | 21:e41126528cc6 | 1228 | _x[12] = 0; |
AhmedPlaymaker | 8:890b986b16a4 | 1229 | } |
AhmedPlaymaker | 21:e41126528cc6 | 1230 | if (_x[13] <= 0) { |
AhmedPlaymaker | 21:e41126528cc6 | 1231 | _x[13] = 0; |
AhmedPlaymaker | 8:890b986b16a4 | 1232 | } |
AhmedPlaymaker | 21:e41126528cc6 | 1233 | if (_x[14] <= 0) { |
AhmedPlaymaker | 21:e41126528cc6 | 1234 | _x[14] = 0; |
AhmedPlaymaker | 7:48ba87cd79b5 | 1235 | } |
AhmedPlaymaker | 21:e41126528cc6 | 1236 | if (_x[0] > 81) { |
AhmedPlaymaker | 21:e41126528cc6 | 1237 | _x[0] = 81; |
AhmedPlaymaker | 8:890b986b16a4 | 1238 | } |
AhmedPlaymaker | 21:e41126528cc6 | 1239 | if (_x[1] > 81) { |
AhmedPlaymaker | 21:e41126528cc6 | 1240 | _x[1] = 81; |
AhmedPlaymaker | 8:890b986b16a4 | 1241 | } |
AhmedPlaymaker | 21:e41126528cc6 | 1242 | if (_x[2] > 81) { |
AhmedPlaymaker | 21:e41126528cc6 | 1243 | _x[2] = 81; |
AhmedPlaymaker | 8:890b986b16a4 | 1244 | } |
AhmedPlaymaker | 21:e41126528cc6 | 1245 | if (_x[3] > 81) { |
AhmedPlaymaker | 21:e41126528cc6 | 1246 | _x[3] = 81; |
AhmedPlaymaker | 8:890b986b16a4 | 1247 | } |
AhmedPlaymaker | 21:e41126528cc6 | 1248 | if (_x[4] > 81) { |
AhmedPlaymaker | 21:e41126528cc6 | 1249 | _x[4] = 81; |
AhmedPlaymaker | 8:890b986b16a4 | 1250 | } |
AhmedPlaymaker | 21:e41126528cc6 | 1251 | if (_x[5] > 81) { |
AhmedPlaymaker | 21:e41126528cc6 | 1252 | _x[5] = 81; |
AhmedPlaymaker | 8:890b986b16a4 | 1253 | } |
AhmedPlaymaker | 21:e41126528cc6 | 1254 | if (_x[6] > 81) { |
AhmedPlaymaker | 21:e41126528cc6 | 1255 | _x[6] = 81; |
AhmedPlaymaker | 7:48ba87cd79b5 | 1256 | } |
AhmedPlaymaker | 21:e41126528cc6 | 1257 | if (_x[7] > 81) { |
AhmedPlaymaker | 21:e41126528cc6 | 1258 | _x[7] = 81; |
AhmedPlaymaker | 8:890b986b16a4 | 1259 | } |
AhmedPlaymaker | 21:e41126528cc6 | 1260 | if (_x[8] > 81) { |
AhmedPlaymaker | 21:e41126528cc6 | 1261 | _x[8] = 81; |
AhmedPlaymaker | 8:890b986b16a4 | 1262 | } |
AhmedPlaymaker | 21:e41126528cc6 | 1263 | if (_x[9] > 81) { |
AhmedPlaymaker | 21:e41126528cc6 | 1264 | _x[9] = 81; |
AhmedPlaymaker | 8:890b986b16a4 | 1265 | } |
AhmedPlaymaker | 21:e41126528cc6 | 1266 | if (_x[10] > 81) { |
AhmedPlaymaker | 21:e41126528cc6 | 1267 | _x[10] = 81; |
AhmedPlaymaker | 8:890b986b16a4 | 1268 | } |
AhmedPlaymaker | 21:e41126528cc6 | 1269 | if (_x[11] > 81) { |
AhmedPlaymaker | 21:e41126528cc6 | 1270 | _x[11] = 81; |
AhmedPlaymaker | 8:890b986b16a4 | 1271 | } |
AhmedPlaymaker | 21:e41126528cc6 | 1272 | if (_x[12] > 81) { |
AhmedPlaymaker | 21:e41126528cc6 | 1273 | _x[12] = 81; |
AhmedPlaymaker | 8:890b986b16a4 | 1274 | } |
AhmedPlaymaker | 21:e41126528cc6 | 1275 | if (_x[13] > 81) { |
AhmedPlaymaker | 21:e41126528cc6 | 1276 | _x[13] = 81; |
AhmedPlaymaker | 8:890b986b16a4 | 1277 | } |
AhmedPlaymaker | 21:e41126528cc6 | 1278 | if (_x[14] > 81) { |
AhmedPlaymaker | 21:e41126528cc6 | 1279 | _x[14] = 81; |
AhmedPlaymaker | 8:890b986b16a4 | 1280 | } |
AhmedPlaymaker | 7:48ba87cd79b5 | 1281 | } |
AhmedPlaymaker | 7:48ba87cd79b5 | 1282 |