![](/media/cache/profiles/LinkedIn_0NghoZJ.jpeg.50x50_q85.jpg)
Snake vs Block Game to be run upon K64F.
Snake/Snake.cpp@19:05cc9f801468, 2019-04-08 (annotated)
- Committer:
- AhmedPlaymaker
- Date:
- Mon Apr 08 16:46:14 2019 +0000
- Revision:
- 19:05cc9f801468
- Parent:
- 18:b391caa5754c
- Child:
- 20:1e6338403427
made progressive levels slightly more difficult, will test on people later, have to print levels on screen after each progressive level.
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 | 17:54e13faeaf64 | 31 | int Snake::draw(Gamepad &pad, N5110 &lcd, int length) |
AhmedPlaymaker | 7:48ba87cd79b5 | 32 | { |
AhmedPlaymaker | 7:48ba87cd79b5 | 33 | if(m == 0){ |
AhmedPlaymaker | 7:48ba87cd79b5 | 34 | _x = WIDTH/2; //Spawns player sprite near the middle of the screen. |
AhmedPlaymaker | 8:890b986b16a4 | 35 | _xa = _x; |
AhmedPlaymaker | 9:d1d79d4ee673 | 36 | _xb = _xa; |
AhmedPlaymaker | 9:d1d79d4ee673 | 37 | _xc = _xb; |
AhmedPlaymaker | 9:d1d79d4ee673 | 38 | _xd = _xc; |
AhmedPlaymaker | 9:d1d79d4ee673 | 39 | _xe = _xd; |
AhmedPlaymaker | 9:d1d79d4ee673 | 40 | _xf = _xe; |
AhmedPlaymaker | 9:d1d79d4ee673 | 41 | _xg = _xf; |
AhmedPlaymaker | 9:d1d79d4ee673 | 42 | _xh = _xg; |
AhmedPlaymaker | 9:d1d79d4ee673 | 43 | _xi = _xh; |
AhmedPlaymaker | 9:d1d79d4ee673 | 44 | _xj = _xi; |
AhmedPlaymaker | 9:d1d79d4ee673 | 45 | _xk = _xj; |
AhmedPlaymaker | 9:d1d79d4ee673 | 46 | _xl = _xk; |
AhmedPlaymaker | 9:d1d79d4ee673 | 47 | _xm = _xl; |
AhmedPlaymaker | 9:d1d79d4ee673 | 48 | _xn = _xm; |
AhmedPlaymaker | 13:9785f2404045 | 49 | _y = HEIGHT - 3; |
AhmedPlaymaker | 13:9785f2404045 | 50 | _ya = _y-3; |
AhmedPlaymaker | 13:9785f2404045 | 51 | _yb = _y-6; |
AhmedPlaymaker | 13:9785f2404045 | 52 | _yc = _y-9; |
AhmedPlaymaker | 13:9785f2404045 | 53 | _yd = _y-12; |
AhmedPlaymaker | 13:9785f2404045 | 54 | _ye = _y-15; |
AhmedPlaymaker | 13:9785f2404045 | 55 | _yf = _y-18; |
AhmedPlaymaker | 13:9785f2404045 | 56 | _yg = _y-21; |
AhmedPlaymaker | 13:9785f2404045 | 57 | _yh = _y-24; |
AhmedPlaymaker | 13:9785f2404045 | 58 | _yi = _y-27; |
AhmedPlaymaker | 13:9785f2404045 | 59 | _yj = _y-30; |
AhmedPlaymaker | 13:9785f2404045 | 60 | _yk = _y-33; |
AhmedPlaymaker | 13:9785f2404045 | 61 | _yl = _y-36; |
AhmedPlaymaker | 13:9785f2404045 | 62 | _ym = _y-39; |
AhmedPlaymaker | 18:b391caa5754c | 63 | _yn = _y-42; |
AhmedPlaymaker | 18:b391caa5754c | 64 | b0 = 1; |
AhmedPlaymaker | 18:b391caa5754c | 65 | b1 = 1; |
AhmedPlaymaker | 18:b391caa5754c | 66 | b2 = 1; |
AhmedPlaymaker | 18:b391caa5754c | 67 | b3 = 1; |
AhmedPlaymaker | 18:b391caa5754c | 68 | b4 = 1; |
AhmedPlaymaker | 18:b391caa5754c | 69 | b5 = 1; |
AhmedPlaymaker | 18:b391caa5754c | 70 | b6 = 1; |
AhmedPlaymaker | 18:b391caa5754c | 71 | b7 = 1; |
AhmedPlaymaker | 18:b391caa5754c | 72 | b8 = 1; |
AhmedPlaymaker | 18:b391caa5754c | 73 | b9 = 1; |
AhmedPlaymaker | 18:b391caa5754c | 74 | b10 = 1; |
AhmedPlaymaker | 18:b391caa5754c | 75 | b11 = 1; |
AhmedPlaymaker | 18:b391caa5754c | 76 | b12 = 1; |
AhmedPlaymaker | 18:b391caa5754c | 77 | b13 = 1; |
AhmedPlaymaker | 18:b391caa5754c | 78 | b14 = 1; |
AhmedPlaymaker | 7:48ba87cd79b5 | 79 | m = m+1; |
AhmedPlaymaker | 7:48ba87cd79b5 | 80 | } |
AhmedPlaymaker | 7:48ba87cd79b5 | 81 | //printf("SPRITE %d %d \n", _x, _y); |
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 | 8:890b986b16a4 | 94 | lcd.drawSprite(_x,_y,3,3,(int *)snake_sprite); //Function used to draw the sprite. |
AhmedPlaymaker | 8:890b986b16a4 | 95 | } |
AhmedPlaymaker | 16:7b474f873683 | 96 | else if(length == 2) { |
AhmedPlaymaker | 8:890b986b16a4 | 97 | lcd.drawSprite(_x,_y,3,3,(int *)snake_sprite); //Function used to draw the sprite. |
AhmedPlaymaker | 13:9785f2404045 | 98 | lcd.drawSprite(_xa,_ya,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 8:890b986b16a4 | 99 | } |
AhmedPlaymaker | 16:7b474f873683 | 100 | else if(length == 3) { |
AhmedPlaymaker | 8:890b986b16a4 | 101 | lcd.drawSprite(_x,_y,3,3,(int *)snake_sprite); //Function used to draw the sprite. |
AhmedPlaymaker | 13:9785f2404045 | 102 | lcd.drawSprite(_xa,_ya,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 103 | lcd.drawSprite(_xb,_yb,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 8:890b986b16a4 | 104 | } |
AhmedPlaymaker | 16:7b474f873683 | 105 | else if(length == 4) { |
AhmedPlaymaker | 8:890b986b16a4 | 106 | lcd.drawSprite(_x,_y,3,3,(int *)snake_sprite); //Function used to draw the sprite. |
AhmedPlaymaker | 13:9785f2404045 | 107 | lcd.drawSprite(_xa,_ya,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 108 | lcd.drawSprite(_xb,_yb,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 109 | lcd.drawSprite(_xc,_yc,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 8:890b986b16a4 | 110 | } |
AhmedPlaymaker | 16:7b474f873683 | 111 | else if(length == 5) { |
AhmedPlaymaker | 8:890b986b16a4 | 112 | lcd.drawSprite(_x,_y,3,3,(int *)snake_sprite); //Function used to draw the sprite. |
AhmedPlaymaker | 13:9785f2404045 | 113 | lcd.drawSprite(_xa,_ya,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 114 | lcd.drawSprite(_xb,_yb,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 115 | lcd.drawSprite(_xc,_yc,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 116 | lcd.drawSprite(_xd,_yd,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 8:890b986b16a4 | 117 | } |
AhmedPlaymaker | 16:7b474f873683 | 118 | else if(length == 6) { |
AhmedPlaymaker | 8:890b986b16a4 | 119 | lcd.drawSprite(_x,_y,3,3,(int *)snake_sprite); //Function used to draw the sprite. |
AhmedPlaymaker | 13:9785f2404045 | 120 | lcd.drawSprite(_xa,_ya,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 121 | lcd.drawSprite(_xb,_yb,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 122 | lcd.drawSprite(_xc,_yc,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 123 | lcd.drawSprite(_xd,_yd,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 124 | lcd.drawSprite(_xe,_ye,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 8:890b986b16a4 | 125 | } |
AhmedPlaymaker | 16:7b474f873683 | 126 | else if(length == 7) { |
AhmedPlaymaker | 8:890b986b16a4 | 127 | lcd.drawSprite(_x,_y,3,3,(int *)snake_sprite); //Function used to draw the sprite. |
AhmedPlaymaker | 13:9785f2404045 | 128 | lcd.drawSprite(_xa,_ya,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 129 | lcd.drawSprite(_xb,_yb,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 130 | lcd.drawSprite(_xc,_yc,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 131 | lcd.drawSprite(_xd,_yd,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 132 | lcd.drawSprite(_xe,_ye,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 133 | lcd.drawSprite(_xf,_yf,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 8:890b986b16a4 | 134 | } |
AhmedPlaymaker | 16:7b474f873683 | 135 | else if(length == 8) { |
AhmedPlaymaker | 8:890b986b16a4 | 136 | lcd.drawSprite(_x,_y,3,3,(int *)snake_sprite); //Function used to draw the sprite. |
AhmedPlaymaker | 13:9785f2404045 | 137 | lcd.drawSprite(_xa,_ya,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 138 | lcd.drawSprite(_xb,_yb,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 139 | lcd.drawSprite(_xc,_yc,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 140 | lcd.drawSprite(_xd,_yd,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 141 | lcd.drawSprite(_xe,_ye,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 142 | lcd.drawSprite(_xf,_yf,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 143 | lcd.drawSprite(_xg,_yg,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 8:890b986b16a4 | 144 | } |
AhmedPlaymaker | 16:7b474f873683 | 145 | else if(length == 9) { |
AhmedPlaymaker | 8:890b986b16a4 | 146 | lcd.drawSprite(_x,_y,3,3,(int *)snake_sprite); //Function used to draw the sprite. |
AhmedPlaymaker | 13:9785f2404045 | 147 | lcd.drawSprite(_xa,_ya,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 148 | lcd.drawSprite(_xb,_yb,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 149 | lcd.drawSprite(_xc,_yc,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 150 | lcd.drawSprite(_xd,_yd,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 151 | lcd.drawSprite(_xe,_ye,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 152 | lcd.drawSprite(_xf,_yf,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 153 | lcd.drawSprite(_xg,_yg,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 154 | lcd.drawSprite(_xh,_yh,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 8:890b986b16a4 | 155 | } |
AhmedPlaymaker | 16:7b474f873683 | 156 | else if(length == 10) { |
AhmedPlaymaker | 8:890b986b16a4 | 157 | lcd.drawSprite(_x,_y,3,3,(int *)snake_sprite); //Function used to draw the sprite. |
AhmedPlaymaker | 13:9785f2404045 | 158 | lcd.drawSprite(_xa,_ya,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 159 | lcd.drawSprite(_xb,_yb,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 160 | lcd.drawSprite(_xc,_yc,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 161 | lcd.drawSprite(_xd,_yd,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 162 | lcd.drawSprite(_xe,_ye,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 163 | lcd.drawSprite(_xf,_yf,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 164 | lcd.drawSprite(_xg,_yg,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 165 | lcd.drawSprite(_xh,_yh,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 166 | lcd.drawSprite(_xi,_yi,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 8:890b986b16a4 | 167 | } |
AhmedPlaymaker | 16:7b474f873683 | 168 | else if(length == 11) { |
AhmedPlaymaker | 8:890b986b16a4 | 169 | lcd.drawSprite(_x,_y,3,3,(int *)snake_sprite); //Function used to draw the sprite. |
AhmedPlaymaker | 13:9785f2404045 | 170 | lcd.drawSprite(_xa,_ya,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 171 | lcd.drawSprite(_xb,_yb,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 172 | lcd.drawSprite(_xc,_yc,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 173 | lcd.drawSprite(_xd,_yd,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 174 | lcd.drawSprite(_xe,_ye,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 175 | lcd.drawSprite(_xf,_yf,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 176 | lcd.drawSprite(_xg,_yg,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 177 | lcd.drawSprite(_xh,_yh,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 178 | lcd.drawSprite(_xi,_yi,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 179 | lcd.drawSprite(_xj,_yj,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 8:890b986b16a4 | 180 | } |
AhmedPlaymaker | 16:7b474f873683 | 181 | else if(length == 12) { |
AhmedPlaymaker | 8:890b986b16a4 | 182 | lcd.drawSprite(_x,_y,3,3,(int *)snake_sprite); //Function used to draw the sprite. |
AhmedPlaymaker | 13:9785f2404045 | 183 | lcd.drawSprite(_xa,_ya,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 184 | lcd.drawSprite(_xb,_yb,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 185 | lcd.drawSprite(_xc,_yc,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 186 | lcd.drawSprite(_xd,_yd,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 187 | lcd.drawSprite(_xe,_ye,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 188 | lcd.drawSprite(_xf,_yf,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 189 | lcd.drawSprite(_xg,_yg,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 190 | lcd.drawSprite(_xh,_yh,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 191 | lcd.drawSprite(_xi,_yi,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 192 | lcd.drawSprite(_xj,_yj,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 193 | lcd.drawSprite(_xk,_yk,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 8:890b986b16a4 | 194 | } |
AhmedPlaymaker | 16:7b474f873683 | 195 | else if(length == 13) { |
AhmedPlaymaker | 8:890b986b16a4 | 196 | lcd.drawSprite(_x,_y,3,3,(int *)snake_sprite); //Function used to draw the sprite. |
AhmedPlaymaker | 13:9785f2404045 | 197 | lcd.drawSprite(_xa,_ya,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 198 | lcd.drawSprite(_xb,_yb,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 199 | lcd.drawSprite(_xc,_yc,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 200 | lcd.drawSprite(_xd,_yd,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 201 | lcd.drawSprite(_xe,_ye,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 202 | lcd.drawSprite(_xf,_yf,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 203 | lcd.drawSprite(_xg,_yg,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 204 | lcd.drawSprite(_xh,_yh,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 205 | lcd.drawSprite(_xi,_yi,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 206 | lcd.drawSprite(_xj,_yj,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 207 | lcd.drawSprite(_xk,_yk,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 208 | lcd.drawSprite(_xl,_yl,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 8:890b986b16a4 | 209 | } |
AhmedPlaymaker | 16:7b474f873683 | 210 | else if(length == 14) { |
AhmedPlaymaker | 8:890b986b16a4 | 211 | lcd.drawSprite(_x,_y,3,3,(int *)snake_sprite); //Function used to draw the sprite. |
AhmedPlaymaker | 13:9785f2404045 | 212 | lcd.drawSprite(_xa,_ya,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 213 | lcd.drawSprite(_xb,_yb,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 214 | lcd.drawSprite(_xc,_yc,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 215 | lcd.drawSprite(_xd,_yd,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 216 | lcd.drawSprite(_xe,_ye,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 217 | lcd.drawSprite(_xf,_yf,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 218 | lcd.drawSprite(_xg,_yg,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 219 | lcd.drawSprite(_xh,_yh,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 220 | lcd.drawSprite(_xi,_yi,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 221 | lcd.drawSprite(_xj,_yj,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 222 | lcd.drawSprite(_xk,_yk,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 223 | lcd.drawSprite(_xl,_yl,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 224 | lcd.drawSprite(_xm,_ym,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 8:890b986b16a4 | 225 | } |
AhmedPlaymaker | 16:7b474f873683 | 226 | else if(length == 15) { |
AhmedPlaymaker | 8:890b986b16a4 | 227 | lcd.drawSprite(_x,_y,3,3,(int *)snake_sprite); //Function used to draw the sprite. |
AhmedPlaymaker | 13:9785f2404045 | 228 | lcd.drawSprite(_xa,_ya,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 229 | lcd.drawSprite(_xb,_yb,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 230 | lcd.drawSprite(_xc,_yc,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 231 | lcd.drawSprite(_xd,_yd,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 232 | lcd.drawSprite(_xe,_ye,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 233 | lcd.drawSprite(_xf,_yf,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 234 | lcd.drawSprite(_xg,_yg,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 235 | lcd.drawSprite(_xh,_yh,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 236 | lcd.drawSprite(_xi,_yi,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 237 | lcd.drawSprite(_xj,_yj,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 238 | lcd.drawSprite(_xk,_yk,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 239 | lcd.drawSprite(_xl,_yl,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 240 | lcd.drawSprite(_xm,_ym,3,3,(int *)snake_sprite); |
AhmedPlaymaker | 13:9785f2404045 | 241 | lcd.drawSprite(_xn,_yn,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 | 17:54e13faeaf64 | 247 | wait(1); |
AhmedPlaymaker | 17:54e13faeaf64 | 248 | length = 3; |
AhmedPlaymaker | 17:54e13faeaf64 | 249 | } |
AhmedPlaymaker | 17:54e13faeaf64 | 250 | return length; |
AhmedPlaymaker | 7:48ba87cd79b5 | 251 | } |
AhmedPlaymaker | 19:05cc9f801468 | 252 | |
AhmedPlaymaker | 9:d1d79d4ee673 | 253 | Vector2D Snake::get_pos(int length) |
AhmedPlaymaker | 7:48ba87cd79b5 | 254 | { |
AhmedPlaymaker | 9:d1d79d4ee673 | 255 | if(length == 1) { |
AhmedPlaymaker | 9:d1d79d4ee673 | 256 | Vector2D snakepos = {_x,_y}; //Obtains the snake position. |
AhmedPlaymaker | 9:d1d79d4ee673 | 257 | return snakepos; |
AhmedPlaymaker | 9:d1d79d4ee673 | 258 | } |
AhmedPlaymaker | 9:d1d79d4ee673 | 259 | else if(length == 2) { |
AhmedPlaymaker | 13:9785f2404045 | 260 | Vector2D snakepos = {_xa,_ya}; //Obtains the snake position. |
AhmedPlaymaker | 9:d1d79d4ee673 | 261 | return snakepos; |
AhmedPlaymaker | 9:d1d79d4ee673 | 262 | } |
AhmedPlaymaker | 9:d1d79d4ee673 | 263 | else if(length==3) { |
AhmedPlaymaker | 13:9785f2404045 | 264 | Vector2D snakepos = {_xb,_yb}; //Obtains the snake position. |
AhmedPlaymaker | 9:d1d79d4ee673 | 265 | return snakepos; |
AhmedPlaymaker | 9:d1d79d4ee673 | 266 | } |
AhmedPlaymaker | 9:d1d79d4ee673 | 267 | else if(length==4) { |
AhmedPlaymaker | 13:9785f2404045 | 268 | Vector2D snakepos = {_xc,_yc}; //Obtains the snake position. |
AhmedPlaymaker | 9:d1d79d4ee673 | 269 | return snakepos; |
AhmedPlaymaker | 9:d1d79d4ee673 | 270 | } |
AhmedPlaymaker | 9:d1d79d4ee673 | 271 | else if(length==5) { |
AhmedPlaymaker | 13:9785f2404045 | 272 | Vector2D snakepos = {_xd,_yd}; //Obtains the snake position. |
AhmedPlaymaker | 9:d1d79d4ee673 | 273 | return snakepos; |
AhmedPlaymaker | 9:d1d79d4ee673 | 274 | } |
AhmedPlaymaker | 9:d1d79d4ee673 | 275 | else if(length==6) { |
AhmedPlaymaker | 13:9785f2404045 | 276 | Vector2D snakepos = {_xe,_ye}; //Obtains the snake position. |
AhmedPlaymaker | 9:d1d79d4ee673 | 277 | return snakepos; |
AhmedPlaymaker | 9:d1d79d4ee673 | 278 | } |
AhmedPlaymaker | 9:d1d79d4ee673 | 279 | else if(length==7) { |
AhmedPlaymaker | 13:9785f2404045 | 280 | Vector2D snakepos = {_xf,_yf}; //Obtains the snake position. |
AhmedPlaymaker | 9:d1d79d4ee673 | 281 | return snakepos; |
AhmedPlaymaker | 9:d1d79d4ee673 | 282 | } |
AhmedPlaymaker | 9:d1d79d4ee673 | 283 | else if(length==8) { |
AhmedPlaymaker | 13:9785f2404045 | 284 | Vector2D snakepos = {_xg,_yg}; //Obtains the snake position. |
AhmedPlaymaker | 9:d1d79d4ee673 | 285 | return snakepos; |
AhmedPlaymaker | 9:d1d79d4ee673 | 286 | } |
AhmedPlaymaker | 9:d1d79d4ee673 | 287 | else if(length==9) { |
AhmedPlaymaker | 13:9785f2404045 | 288 | Vector2D snakepos = {_xh,_yh}; //Obtains the snake position. |
AhmedPlaymaker | 9:d1d79d4ee673 | 289 | return snakepos; |
AhmedPlaymaker | 9:d1d79d4ee673 | 290 | } |
AhmedPlaymaker | 9:d1d79d4ee673 | 291 | else if(length==10) { |
AhmedPlaymaker | 13:9785f2404045 | 292 | Vector2D snakepos = {_xi,_yi}; //Obtains the snake position. |
AhmedPlaymaker | 9:d1d79d4ee673 | 293 | return snakepos; |
AhmedPlaymaker | 9:d1d79d4ee673 | 294 | } |
AhmedPlaymaker | 9:d1d79d4ee673 | 295 | else if(length==11) { |
AhmedPlaymaker | 13:9785f2404045 | 296 | Vector2D snakepos = {_xj,_yj}; //Obtains the snake position. |
AhmedPlaymaker | 9:d1d79d4ee673 | 297 | return snakepos; |
AhmedPlaymaker | 9:d1d79d4ee673 | 298 | } |
AhmedPlaymaker | 9:d1d79d4ee673 | 299 | else if(length==12) { |
AhmedPlaymaker | 13:9785f2404045 | 300 | Vector2D snakepos = {_xk,_yk}; //Obtains the snake position. |
AhmedPlaymaker | 9:d1d79d4ee673 | 301 | return snakepos; |
AhmedPlaymaker | 9:d1d79d4ee673 | 302 | } |
AhmedPlaymaker | 9:d1d79d4ee673 | 303 | else if(length==13) { |
AhmedPlaymaker | 13:9785f2404045 | 304 | Vector2D snakepos = {_xl,_yl}; //Obtains the snake position. |
AhmedPlaymaker | 9:d1d79d4ee673 | 305 | return snakepos; |
AhmedPlaymaker | 9:d1d79d4ee673 | 306 | } |
AhmedPlaymaker | 9:d1d79d4ee673 | 307 | else if(length == 14) { |
AhmedPlaymaker | 13:9785f2404045 | 308 | Vector2D snakepos = {_xm,_ym}; //Obtains the snake position. |
AhmedPlaymaker | 9:d1d79d4ee673 | 309 | return snakepos; |
AhmedPlaymaker | 9:d1d79d4ee673 | 310 | } |
AhmedPlaymaker | 9:d1d79d4ee673 | 311 | else if(length==15) { |
AhmedPlaymaker | 13:9785f2404045 | 312 | Vector2D snakepos = {_xn,_yn}; //Obtains the snake position. |
AhmedPlaymaker | 9:d1d79d4ee673 | 313 | return snakepos; |
AhmedPlaymaker | 9:d1d79d4ee673 | 314 | } |
AhmedPlaymaker | 7:48ba87cd79b5 | 315 | //printf("snakepos from player = %f %f \n", snakepos.x, snakepos.y); |
AhmedPlaymaker | 13:9785f2404045 | 316 | else { |
AhmedPlaymaker | 13:9785f2404045 | 317 | Vector2D snakepos = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 318 | return snakepos; |
AhmedPlaymaker | 13:9785f2404045 | 319 | } |
AhmedPlaymaker | 13:9785f2404045 | 320 | } |
AhmedPlaymaker | 13:9785f2404045 | 321 | |
AhmedPlaymaker | 13:9785f2404045 | 322 | Vector2D Snake::get_pos_before1(int length) //this sends data of following sprites. |
AhmedPlaymaker | 13:9785f2404045 | 323 | { |
AhmedPlaymaker | 13:9785f2404045 | 324 | if(length == 1) { |
AhmedPlaymaker | 13:9785f2404045 | 325 | Vector2D snakepos_b1 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 326 | return snakepos_b1; |
AhmedPlaymaker | 13:9785f2404045 | 327 | } |
AhmedPlaymaker | 13:9785f2404045 | 328 | else if(length == 2) { |
AhmedPlaymaker | 13:9785f2404045 | 329 | Vector2D snakepos_b1 = {_x,_y}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 330 | return snakepos_b1; |
AhmedPlaymaker | 13:9785f2404045 | 331 | } |
AhmedPlaymaker | 13:9785f2404045 | 332 | else if(length==3) { |
AhmedPlaymaker | 13:9785f2404045 | 333 | Vector2D snakepos_b1 = {_xa,_ya}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 334 | return snakepos_b1; |
AhmedPlaymaker | 13:9785f2404045 | 335 | } |
AhmedPlaymaker | 13:9785f2404045 | 336 | else if(length==4) { |
AhmedPlaymaker | 13:9785f2404045 | 337 | Vector2D snakepos_b1 = {_xb,_yb}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 338 | return snakepos_b1; |
AhmedPlaymaker | 13:9785f2404045 | 339 | } |
AhmedPlaymaker | 13:9785f2404045 | 340 | else if(length==5) { |
AhmedPlaymaker | 13:9785f2404045 | 341 | Vector2D snakepos_b1 = {_xc,_yc}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 342 | return snakepos_b1; |
AhmedPlaymaker | 13:9785f2404045 | 343 | } |
AhmedPlaymaker | 13:9785f2404045 | 344 | else if(length==6) { |
AhmedPlaymaker | 13:9785f2404045 | 345 | Vector2D snakepos_b1 = {_xd,_yd}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 346 | return snakepos_b1; |
AhmedPlaymaker | 13:9785f2404045 | 347 | } |
AhmedPlaymaker | 13:9785f2404045 | 348 | else if(length==7) { |
AhmedPlaymaker | 13:9785f2404045 | 349 | Vector2D snakepos_b1 = {_xe,_ye}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 350 | return snakepos_b1; |
AhmedPlaymaker | 13:9785f2404045 | 351 | } |
AhmedPlaymaker | 13:9785f2404045 | 352 | else if(length==8) { |
AhmedPlaymaker | 13:9785f2404045 | 353 | Vector2D snakepos_b1 = {_xf,_yf}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 354 | return snakepos_b1; |
AhmedPlaymaker | 13:9785f2404045 | 355 | } |
AhmedPlaymaker | 13:9785f2404045 | 356 | else if(length==9) { |
AhmedPlaymaker | 13:9785f2404045 | 357 | Vector2D snakepos_b1 = {_xg,_yg}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 358 | return snakepos_b1; |
AhmedPlaymaker | 13:9785f2404045 | 359 | } |
AhmedPlaymaker | 13:9785f2404045 | 360 | else if(length==10) { |
AhmedPlaymaker | 13:9785f2404045 | 361 | Vector2D snakepos_b1 = {_xh,_yh}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 362 | return snakepos_b1; |
AhmedPlaymaker | 13:9785f2404045 | 363 | } |
AhmedPlaymaker | 13:9785f2404045 | 364 | else if(length==11) { |
AhmedPlaymaker | 13:9785f2404045 | 365 | Vector2D snakepos_b1 = {_xi,_yi}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 366 | return snakepos_b1; |
AhmedPlaymaker | 13:9785f2404045 | 367 | } |
AhmedPlaymaker | 13:9785f2404045 | 368 | else if(length==12) { |
AhmedPlaymaker | 13:9785f2404045 | 369 | Vector2D snakepos_b1 = {_xj,_yj}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 370 | return snakepos_b1; |
AhmedPlaymaker | 13:9785f2404045 | 371 | } |
AhmedPlaymaker | 13:9785f2404045 | 372 | else if(length==13) { |
AhmedPlaymaker | 13:9785f2404045 | 373 | Vector2D snakepos_b1 = {_xk,_yk}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 374 | return snakepos_b1; |
AhmedPlaymaker | 13:9785f2404045 | 375 | } |
AhmedPlaymaker | 13:9785f2404045 | 376 | else if(length == 14) { |
AhmedPlaymaker | 13:9785f2404045 | 377 | Vector2D snakepos_b1 = {_xl,_yl}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 378 | return snakepos_b1; |
AhmedPlaymaker | 13:9785f2404045 | 379 | } |
AhmedPlaymaker | 13:9785f2404045 | 380 | else if(length==15) { |
AhmedPlaymaker | 13:9785f2404045 | 381 | Vector2D snakepos_b1 = {_xm,_ym}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 382 | return snakepos_b1; |
AhmedPlaymaker | 13:9785f2404045 | 383 | } |
AhmedPlaymaker | 13:9785f2404045 | 384 | //printf("snakepos from player = %f %f \n", snakepos.x, snakepos.y); |
AhmedPlaymaker | 13:9785f2404045 | 385 | else { |
AhmedPlaymaker | 13:9785f2404045 | 386 | Vector2D snakepos_b1 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 387 | return snakepos_b1; |
AhmedPlaymaker | 13:9785f2404045 | 388 | } |
AhmedPlaymaker | 13:9785f2404045 | 389 | } |
AhmedPlaymaker | 13:9785f2404045 | 390 | |
AhmedPlaymaker | 13:9785f2404045 | 391 | Vector2D Snake::get_pos_before2(int length) //this sends data of following sprites. |
AhmedPlaymaker | 13:9785f2404045 | 392 | { |
AhmedPlaymaker | 13:9785f2404045 | 393 | if(length == 1) { |
AhmedPlaymaker | 13:9785f2404045 | 394 | Vector2D snakepos_b2 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 395 | return snakepos_b2; |
AhmedPlaymaker | 13:9785f2404045 | 396 | } |
AhmedPlaymaker | 13:9785f2404045 | 397 | else if(length == 2) { |
AhmedPlaymaker | 13:9785f2404045 | 398 | Vector2D snakepos_b2 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 399 | return snakepos_b2; |
AhmedPlaymaker | 13:9785f2404045 | 400 | } |
AhmedPlaymaker | 13:9785f2404045 | 401 | else if(length == 3) { |
AhmedPlaymaker | 13:9785f2404045 | 402 | Vector2D snakepos_b2 = {_x,_y}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 403 | return snakepos_b2; |
AhmedPlaymaker | 13:9785f2404045 | 404 | } |
AhmedPlaymaker | 13:9785f2404045 | 405 | else if(length==4) { |
AhmedPlaymaker | 13:9785f2404045 | 406 | Vector2D snakepos_b2 = {_xa,_ya}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 407 | return snakepos_b2; |
AhmedPlaymaker | 13:9785f2404045 | 408 | } |
AhmedPlaymaker | 13:9785f2404045 | 409 | else if(length==5) { |
AhmedPlaymaker | 13:9785f2404045 | 410 | Vector2D snakepos_b2 = {_xb,_yb}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 411 | return snakepos_b2; |
AhmedPlaymaker | 13:9785f2404045 | 412 | } |
AhmedPlaymaker | 13:9785f2404045 | 413 | else if(length==6) { |
AhmedPlaymaker | 13:9785f2404045 | 414 | Vector2D snakepos_b2 = {_xc,_yc}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 415 | return snakepos_b2; |
AhmedPlaymaker | 13:9785f2404045 | 416 | } |
AhmedPlaymaker | 13:9785f2404045 | 417 | else if(length==7) { |
AhmedPlaymaker | 13:9785f2404045 | 418 | Vector2D snakepos_b2 = {_xd,_yd}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 419 | return snakepos_b2; |
AhmedPlaymaker | 13:9785f2404045 | 420 | } |
AhmedPlaymaker | 13:9785f2404045 | 421 | else if(length==8) { |
AhmedPlaymaker | 13:9785f2404045 | 422 | Vector2D snakepos_b2 = {_xe,_ye}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 423 | return snakepos_b2; |
AhmedPlaymaker | 13:9785f2404045 | 424 | } |
AhmedPlaymaker | 13:9785f2404045 | 425 | else if(length==9) { |
AhmedPlaymaker | 13:9785f2404045 | 426 | Vector2D snakepos_b2 = {_xf,_yf}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 427 | return snakepos_b2; |
AhmedPlaymaker | 13:9785f2404045 | 428 | } |
AhmedPlaymaker | 13:9785f2404045 | 429 | else if(length==10) { |
AhmedPlaymaker | 13:9785f2404045 | 430 | Vector2D snakepos_b2 = {_xg,_yg}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 431 | return snakepos_b2; |
AhmedPlaymaker | 13:9785f2404045 | 432 | } |
AhmedPlaymaker | 13:9785f2404045 | 433 | else if(length==11) { |
AhmedPlaymaker | 13:9785f2404045 | 434 | Vector2D snakepos_b2 = {_xh,_yh}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 435 | return snakepos_b2; |
AhmedPlaymaker | 13:9785f2404045 | 436 | } |
AhmedPlaymaker | 13:9785f2404045 | 437 | else if(length==12) { |
AhmedPlaymaker | 13:9785f2404045 | 438 | Vector2D snakepos_b2 = {_xi,_yi}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 439 | return snakepos_b2; |
AhmedPlaymaker | 13:9785f2404045 | 440 | } |
AhmedPlaymaker | 13:9785f2404045 | 441 | else if(length==13) { |
AhmedPlaymaker | 13:9785f2404045 | 442 | Vector2D snakepos_b2 = {_xj,_yj}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 443 | return snakepos_b2; |
AhmedPlaymaker | 13:9785f2404045 | 444 | } |
AhmedPlaymaker | 13:9785f2404045 | 445 | else if(length==14) { |
AhmedPlaymaker | 13:9785f2404045 | 446 | Vector2D snakepos_b2 = {_xk,_yk}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 447 | return snakepos_b2; |
AhmedPlaymaker | 13:9785f2404045 | 448 | } |
AhmedPlaymaker | 13:9785f2404045 | 449 | else if(length == 15) { |
AhmedPlaymaker | 13:9785f2404045 | 450 | Vector2D snakepos_b2 = {_xl,_yl}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 451 | return snakepos_b2; |
AhmedPlaymaker | 13:9785f2404045 | 452 | } |
AhmedPlaymaker | 13:9785f2404045 | 453 | //printf("snakepos from player = %f %f \n", snakepos.x, snakepos.y); |
AhmedPlaymaker | 13:9785f2404045 | 454 | else { |
AhmedPlaymaker | 13:9785f2404045 | 455 | Vector2D snakepos_b2 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 456 | return snakepos_b2; |
AhmedPlaymaker | 13:9785f2404045 | 457 | } |
AhmedPlaymaker | 13:9785f2404045 | 458 | } |
AhmedPlaymaker | 13:9785f2404045 | 459 | |
AhmedPlaymaker | 13:9785f2404045 | 460 | Vector2D Snake::get_pos_before3(int length) //this sends data of following sprites. |
AhmedPlaymaker | 13:9785f2404045 | 461 | { |
AhmedPlaymaker | 13:9785f2404045 | 462 | if(length == 1) { |
AhmedPlaymaker | 13:9785f2404045 | 463 | Vector2D snakepos_b3 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 464 | return snakepos_b3; |
AhmedPlaymaker | 13:9785f2404045 | 465 | } |
AhmedPlaymaker | 13:9785f2404045 | 466 | else if(length == 2) { |
AhmedPlaymaker | 13:9785f2404045 | 467 | Vector2D snakepos_b3 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 468 | return snakepos_b3; |
AhmedPlaymaker | 13:9785f2404045 | 469 | } |
AhmedPlaymaker | 13:9785f2404045 | 470 | else if(length == 3) { |
AhmedPlaymaker | 13:9785f2404045 | 471 | Vector2D snakepos_b3 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 472 | return snakepos_b3; |
AhmedPlaymaker | 13:9785f2404045 | 473 | } |
AhmedPlaymaker | 13:9785f2404045 | 474 | else if(length == 4) { |
AhmedPlaymaker | 13:9785f2404045 | 475 | Vector2D snakepos_b3 = {_x,_y}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 476 | return snakepos_b3; |
AhmedPlaymaker | 13:9785f2404045 | 477 | } |
AhmedPlaymaker | 13:9785f2404045 | 478 | else if(length==5) { |
AhmedPlaymaker | 13:9785f2404045 | 479 | Vector2D snakepos_b3 = {_xa,_ya}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 480 | return snakepos_b3; |
AhmedPlaymaker | 13:9785f2404045 | 481 | } |
AhmedPlaymaker | 13:9785f2404045 | 482 | else if(length==6) { |
AhmedPlaymaker | 13:9785f2404045 | 483 | Vector2D snakepos_b3 = {_xb,_yb}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 484 | return snakepos_b3; |
AhmedPlaymaker | 13:9785f2404045 | 485 | } |
AhmedPlaymaker | 13:9785f2404045 | 486 | else if(length==7) { |
AhmedPlaymaker | 13:9785f2404045 | 487 | Vector2D snakepos_b3 = {_xc,_yc}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 488 | return snakepos_b3; |
AhmedPlaymaker | 13:9785f2404045 | 489 | } |
AhmedPlaymaker | 13:9785f2404045 | 490 | else if(length==8) { |
AhmedPlaymaker | 13:9785f2404045 | 491 | Vector2D snakepos_b3 = {_xd,_yd}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 492 | return snakepos_b3; |
AhmedPlaymaker | 13:9785f2404045 | 493 | } |
AhmedPlaymaker | 13:9785f2404045 | 494 | else if(length==9) { |
AhmedPlaymaker | 13:9785f2404045 | 495 | Vector2D snakepos_b3 = {_xe,_ye}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 496 | return snakepos_b3; |
AhmedPlaymaker | 13:9785f2404045 | 497 | } |
AhmedPlaymaker | 13:9785f2404045 | 498 | else if(length==10) { |
AhmedPlaymaker | 13:9785f2404045 | 499 | Vector2D snakepos_b3 = {_xf,_yf}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 500 | return snakepos_b3; |
AhmedPlaymaker | 13:9785f2404045 | 501 | } |
AhmedPlaymaker | 13:9785f2404045 | 502 | else if(length==11) { |
AhmedPlaymaker | 13:9785f2404045 | 503 | Vector2D snakepos_b3 = {_xg,_yg}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 504 | return snakepos_b3; |
AhmedPlaymaker | 13:9785f2404045 | 505 | } |
AhmedPlaymaker | 13:9785f2404045 | 506 | else if(length==12) { |
AhmedPlaymaker | 13:9785f2404045 | 507 | Vector2D snakepos_b3 = {_xh,_yh}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 508 | return snakepos_b3; |
AhmedPlaymaker | 13:9785f2404045 | 509 | } |
AhmedPlaymaker | 13:9785f2404045 | 510 | else if(length==13) { |
AhmedPlaymaker | 13:9785f2404045 | 511 | Vector2D snakepos_b3 = {_xi,_yi}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 512 | return snakepos_b3; |
AhmedPlaymaker | 13:9785f2404045 | 513 | } |
AhmedPlaymaker | 13:9785f2404045 | 514 | else if(length==14) { |
AhmedPlaymaker | 13:9785f2404045 | 515 | Vector2D snakepos_b3 = {_xj,_yj}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 516 | return snakepos_b3; |
AhmedPlaymaker | 13:9785f2404045 | 517 | } |
AhmedPlaymaker | 13:9785f2404045 | 518 | else if(length==15) { |
AhmedPlaymaker | 13:9785f2404045 | 519 | Vector2D snakepos_b3 = {_xk,_yk}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 520 | return snakepos_b3; |
AhmedPlaymaker | 13:9785f2404045 | 521 | } |
AhmedPlaymaker | 13:9785f2404045 | 522 | //printf("snakepos from player = %f %f \n", snakepos.x, snakepos.y); |
AhmedPlaymaker | 13:9785f2404045 | 523 | else { |
AhmedPlaymaker | 13:9785f2404045 | 524 | Vector2D snakepos_b3 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 525 | return snakepos_b3; |
AhmedPlaymaker | 13:9785f2404045 | 526 | } |
AhmedPlaymaker | 13:9785f2404045 | 527 | } |
AhmedPlaymaker | 13:9785f2404045 | 528 | |
AhmedPlaymaker | 13:9785f2404045 | 529 | Vector2D Snake::get_pos_before4(int length) //this sends data of following sprites. |
AhmedPlaymaker | 13:9785f2404045 | 530 | { |
AhmedPlaymaker | 13:9785f2404045 | 531 | if(length == 1) { |
AhmedPlaymaker | 13:9785f2404045 | 532 | Vector2D snakepos_b4 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 533 | return snakepos_b4; |
AhmedPlaymaker | 13:9785f2404045 | 534 | } |
AhmedPlaymaker | 13:9785f2404045 | 535 | else if(length == 2) { |
AhmedPlaymaker | 13:9785f2404045 | 536 | Vector2D snakepos_b4 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 537 | return snakepos_b4; |
AhmedPlaymaker | 13:9785f2404045 | 538 | } |
AhmedPlaymaker | 13:9785f2404045 | 539 | else if(length == 3) { |
AhmedPlaymaker | 13:9785f2404045 | 540 | Vector2D snakepos_b4 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 541 | return snakepos_b4; |
AhmedPlaymaker | 13:9785f2404045 | 542 | } |
AhmedPlaymaker | 13:9785f2404045 | 543 | else if(length == 4) { |
AhmedPlaymaker | 13:9785f2404045 | 544 | Vector2D snakepos_b4 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 545 | return snakepos_b4; |
AhmedPlaymaker | 13:9785f2404045 | 546 | } |
AhmedPlaymaker | 13:9785f2404045 | 547 | else if(length == 5) { |
AhmedPlaymaker | 13:9785f2404045 | 548 | Vector2D snakepos_b4 = {_x,_y}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 549 | return snakepos_b4; |
AhmedPlaymaker | 13:9785f2404045 | 550 | } |
AhmedPlaymaker | 13:9785f2404045 | 551 | else if(length==6) { |
AhmedPlaymaker | 13:9785f2404045 | 552 | Vector2D snakepos_b4 = {_xa,_ya}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 553 | return snakepos_b4; |
AhmedPlaymaker | 13:9785f2404045 | 554 | } |
AhmedPlaymaker | 13:9785f2404045 | 555 | else if(length==7) { |
AhmedPlaymaker | 13:9785f2404045 | 556 | Vector2D snakepos_b4 = {_xb,_yb}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 557 | return snakepos_b4; |
AhmedPlaymaker | 13:9785f2404045 | 558 | } |
AhmedPlaymaker | 13:9785f2404045 | 559 | else if(length==8) { |
AhmedPlaymaker | 13:9785f2404045 | 560 | Vector2D snakepos_b4 = {_xc,_yc}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 561 | return snakepos_b4; |
AhmedPlaymaker | 13:9785f2404045 | 562 | } |
AhmedPlaymaker | 13:9785f2404045 | 563 | else if(length==9) { |
AhmedPlaymaker | 13:9785f2404045 | 564 | Vector2D snakepos_b4 = {_xd,_yd}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 565 | return snakepos_b4; |
AhmedPlaymaker | 13:9785f2404045 | 566 | } |
AhmedPlaymaker | 13:9785f2404045 | 567 | else if(length==10) { |
AhmedPlaymaker | 13:9785f2404045 | 568 | Vector2D snakepos_b4 = {_xe,_ye}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 569 | return snakepos_b4; |
AhmedPlaymaker | 13:9785f2404045 | 570 | } |
AhmedPlaymaker | 13:9785f2404045 | 571 | else if(length==11) { |
AhmedPlaymaker | 13:9785f2404045 | 572 | Vector2D snakepos_b4 = {_xf,_yf}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 573 | return snakepos_b4; |
AhmedPlaymaker | 13:9785f2404045 | 574 | } |
AhmedPlaymaker | 13:9785f2404045 | 575 | else if(length==12) { |
AhmedPlaymaker | 13:9785f2404045 | 576 | Vector2D snakepos_b4 = {_xg,_yg}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 577 | return snakepos_b4; |
AhmedPlaymaker | 13:9785f2404045 | 578 | } |
AhmedPlaymaker | 13:9785f2404045 | 579 | else if(length==13) { |
AhmedPlaymaker | 13:9785f2404045 | 580 | Vector2D snakepos_b4 = {_xh,_yh}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 581 | return snakepos_b4; |
AhmedPlaymaker | 13:9785f2404045 | 582 | } |
AhmedPlaymaker | 13:9785f2404045 | 583 | else if(length==14) { |
AhmedPlaymaker | 13:9785f2404045 | 584 | Vector2D snakepos_b4 = {_xi,_yi}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 585 | return snakepos_b4; |
AhmedPlaymaker | 13:9785f2404045 | 586 | } |
AhmedPlaymaker | 13:9785f2404045 | 587 | else if(length==15) { |
AhmedPlaymaker | 13:9785f2404045 | 588 | Vector2D snakepos_b4 = {_xj,_yj}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 589 | return snakepos_b4; |
AhmedPlaymaker | 13:9785f2404045 | 590 | } |
AhmedPlaymaker | 13:9785f2404045 | 591 | //printf("snakepos from player = %f %f \n", snakepos.x, snakepos.y); |
AhmedPlaymaker | 13:9785f2404045 | 592 | else { |
AhmedPlaymaker | 13:9785f2404045 | 593 | Vector2D snakepos_b4 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 594 | return snakepos_b4; |
AhmedPlaymaker | 13:9785f2404045 | 595 | } |
AhmedPlaymaker | 13:9785f2404045 | 596 | } |
AhmedPlaymaker | 13:9785f2404045 | 597 | |
AhmedPlaymaker | 13:9785f2404045 | 598 | Vector2D Snake::get_pos_before5(int length) //this sends data of following sprites. |
AhmedPlaymaker | 13:9785f2404045 | 599 | { |
AhmedPlaymaker | 13:9785f2404045 | 600 | if(length == 1) { |
AhmedPlaymaker | 13:9785f2404045 | 601 | Vector2D snakepos_b5 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 602 | return snakepos_b5; |
AhmedPlaymaker | 13:9785f2404045 | 603 | } |
AhmedPlaymaker | 13:9785f2404045 | 604 | else if(length == 2) { |
AhmedPlaymaker | 13:9785f2404045 | 605 | Vector2D snakepos_b5 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 606 | return snakepos_b5; |
AhmedPlaymaker | 13:9785f2404045 | 607 | } |
AhmedPlaymaker | 13:9785f2404045 | 608 | else if(length == 3) { |
AhmedPlaymaker | 13:9785f2404045 | 609 | Vector2D snakepos_b5 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 610 | return snakepos_b5; |
AhmedPlaymaker | 13:9785f2404045 | 611 | } |
AhmedPlaymaker | 13:9785f2404045 | 612 | else if(length == 4) { |
AhmedPlaymaker | 13:9785f2404045 | 613 | Vector2D snakepos_b5 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 614 | return snakepos_b5; |
AhmedPlaymaker | 13:9785f2404045 | 615 | } |
AhmedPlaymaker | 13:9785f2404045 | 616 | else if(length == 5) { |
AhmedPlaymaker | 13:9785f2404045 | 617 | Vector2D snakepos_b5 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 618 | return snakepos_b5; |
AhmedPlaymaker | 13:9785f2404045 | 619 | } |
AhmedPlaymaker | 13:9785f2404045 | 620 | else if(length == 6) { |
AhmedPlaymaker | 13:9785f2404045 | 621 | Vector2D snakepos_b5 = {_x,_y}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 622 | return snakepos_b5; |
AhmedPlaymaker | 13:9785f2404045 | 623 | } |
AhmedPlaymaker | 13:9785f2404045 | 624 | else if(length==7) { |
AhmedPlaymaker | 13:9785f2404045 | 625 | Vector2D snakepos_b5 = {_xa,_ya}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 626 | return snakepos_b5; |
AhmedPlaymaker | 13:9785f2404045 | 627 | } |
AhmedPlaymaker | 13:9785f2404045 | 628 | else if(length==8) { |
AhmedPlaymaker | 13:9785f2404045 | 629 | Vector2D snakepos_b5 = {_xb,_yb}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 630 | return snakepos_b5; |
AhmedPlaymaker | 13:9785f2404045 | 631 | } |
AhmedPlaymaker | 13:9785f2404045 | 632 | else if(length==9) { |
AhmedPlaymaker | 13:9785f2404045 | 633 | Vector2D snakepos_b5 = {_xc,_yc}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 634 | return snakepos_b5; |
AhmedPlaymaker | 13:9785f2404045 | 635 | } |
AhmedPlaymaker | 13:9785f2404045 | 636 | else if(length==10) { |
AhmedPlaymaker | 13:9785f2404045 | 637 | Vector2D snakepos_b5 = {_xd,_yd}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 638 | return snakepos_b5; |
AhmedPlaymaker | 13:9785f2404045 | 639 | } |
AhmedPlaymaker | 13:9785f2404045 | 640 | else if(length==11) { |
AhmedPlaymaker | 13:9785f2404045 | 641 | Vector2D snakepos_b5 = {_xe,_ye}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 642 | return snakepos_b5; |
AhmedPlaymaker | 13:9785f2404045 | 643 | } |
AhmedPlaymaker | 13:9785f2404045 | 644 | else if(length==12) { |
AhmedPlaymaker | 13:9785f2404045 | 645 | Vector2D snakepos_b5 = {_xf,_yf}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 646 | return snakepos_b5; |
AhmedPlaymaker | 13:9785f2404045 | 647 | } |
AhmedPlaymaker | 13:9785f2404045 | 648 | else if(length==13) { |
AhmedPlaymaker | 13:9785f2404045 | 649 | Vector2D snakepos_b5 = {_xg,_yg}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 650 | return snakepos_b5; |
AhmedPlaymaker | 13:9785f2404045 | 651 | } |
AhmedPlaymaker | 13:9785f2404045 | 652 | else if(length==14) { |
AhmedPlaymaker | 13:9785f2404045 | 653 | Vector2D snakepos_b5 = {_xh,_yh}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 654 | return snakepos_b5; |
AhmedPlaymaker | 13:9785f2404045 | 655 | } |
AhmedPlaymaker | 13:9785f2404045 | 656 | else if(length==15) { |
AhmedPlaymaker | 13:9785f2404045 | 657 | Vector2D snakepos_b5 = {_xi,_yi}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 658 | return snakepos_b5; |
AhmedPlaymaker | 13:9785f2404045 | 659 | } |
AhmedPlaymaker | 13:9785f2404045 | 660 | //printf("snakepos from player = %f %f \n", snakepos.x, snakepos.y); |
AhmedPlaymaker | 13:9785f2404045 | 661 | else { |
AhmedPlaymaker | 13:9785f2404045 | 662 | Vector2D snakepos_b5 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 663 | return snakepos_b5; |
AhmedPlaymaker | 13:9785f2404045 | 664 | } |
AhmedPlaymaker | 13:9785f2404045 | 665 | } |
AhmedPlaymaker | 13:9785f2404045 | 666 | |
AhmedPlaymaker | 13:9785f2404045 | 667 | Vector2D Snake::get_pos_before6(int length) //this sends data of following sprites. |
AhmedPlaymaker | 13:9785f2404045 | 668 | { |
AhmedPlaymaker | 13:9785f2404045 | 669 | if(length == 1) { |
AhmedPlaymaker | 13:9785f2404045 | 670 | Vector2D snakepos_b6 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 671 | return snakepos_b6; |
AhmedPlaymaker | 13:9785f2404045 | 672 | } |
AhmedPlaymaker | 13:9785f2404045 | 673 | else if(length == 2) { |
AhmedPlaymaker | 13:9785f2404045 | 674 | Vector2D snakepos_b6 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 675 | return snakepos_b6; |
AhmedPlaymaker | 13:9785f2404045 | 676 | } |
AhmedPlaymaker | 13:9785f2404045 | 677 | else if(length == 3) { |
AhmedPlaymaker | 13:9785f2404045 | 678 | Vector2D snakepos_b6 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 679 | return snakepos_b6; |
AhmedPlaymaker | 13:9785f2404045 | 680 | } |
AhmedPlaymaker | 13:9785f2404045 | 681 | else if(length == 4) { |
AhmedPlaymaker | 13:9785f2404045 | 682 | Vector2D snakepos_b6 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 683 | return snakepos_b6; |
AhmedPlaymaker | 13:9785f2404045 | 684 | } |
AhmedPlaymaker | 13:9785f2404045 | 685 | else if(length == 5) { |
AhmedPlaymaker | 13:9785f2404045 | 686 | Vector2D snakepos_b6 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 687 | return snakepos_b6; |
AhmedPlaymaker | 13:9785f2404045 | 688 | } |
AhmedPlaymaker | 13:9785f2404045 | 689 | else if(length == 6) { |
AhmedPlaymaker | 13:9785f2404045 | 690 | Vector2D snakepos_b6 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 691 | return snakepos_b6; |
AhmedPlaymaker | 13:9785f2404045 | 692 | } |
AhmedPlaymaker | 13:9785f2404045 | 693 | else if(length == 7) { |
AhmedPlaymaker | 13:9785f2404045 | 694 | Vector2D snakepos_b6 = {_x,_y}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 695 | return snakepos_b6; |
AhmedPlaymaker | 13:9785f2404045 | 696 | } |
AhmedPlaymaker | 13:9785f2404045 | 697 | else if(length==8) { |
AhmedPlaymaker | 13:9785f2404045 | 698 | Vector2D snakepos_b6 = {_xa,_ya}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 699 | return snakepos_b6; |
AhmedPlaymaker | 13:9785f2404045 | 700 | } |
AhmedPlaymaker | 13:9785f2404045 | 701 | else if(length==9) { |
AhmedPlaymaker | 13:9785f2404045 | 702 | Vector2D snakepos_b6 = {_xb,_yb}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 703 | return snakepos_b6; |
AhmedPlaymaker | 13:9785f2404045 | 704 | } |
AhmedPlaymaker | 13:9785f2404045 | 705 | else if(length==10) { |
AhmedPlaymaker | 13:9785f2404045 | 706 | Vector2D snakepos_b6 = {_xc,_yc}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 707 | return snakepos_b6; |
AhmedPlaymaker | 13:9785f2404045 | 708 | } |
AhmedPlaymaker | 13:9785f2404045 | 709 | else if(length==11) { |
AhmedPlaymaker | 13:9785f2404045 | 710 | Vector2D snakepos_b6 = {_xd,_yd}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 711 | return snakepos_b6; |
AhmedPlaymaker | 13:9785f2404045 | 712 | } |
AhmedPlaymaker | 13:9785f2404045 | 713 | else if(length==12) { |
AhmedPlaymaker | 13:9785f2404045 | 714 | Vector2D snakepos_b6 = {_xe,_ye}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 715 | return snakepos_b6; |
AhmedPlaymaker | 13:9785f2404045 | 716 | } |
AhmedPlaymaker | 13:9785f2404045 | 717 | else if(length==13) { |
AhmedPlaymaker | 13:9785f2404045 | 718 | Vector2D snakepos_b6 = {_xf,_yf}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 719 | return snakepos_b6; |
AhmedPlaymaker | 13:9785f2404045 | 720 | } |
AhmedPlaymaker | 13:9785f2404045 | 721 | else if(length==14) { |
AhmedPlaymaker | 13:9785f2404045 | 722 | Vector2D snakepos_b6 = {_xg,_yg}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 723 | return snakepos_b6; |
AhmedPlaymaker | 13:9785f2404045 | 724 | } |
AhmedPlaymaker | 13:9785f2404045 | 725 | else if(length==15) { |
AhmedPlaymaker | 13:9785f2404045 | 726 | Vector2D snakepos_b6 = {_xh,_yh}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 727 | return snakepos_b6; |
AhmedPlaymaker | 13:9785f2404045 | 728 | } |
AhmedPlaymaker | 13:9785f2404045 | 729 | //printf("snakepos from player = %f %f \n", snakepos.x, snakepos.y); |
AhmedPlaymaker | 13:9785f2404045 | 730 | else { |
AhmedPlaymaker | 13:9785f2404045 | 731 | Vector2D snakepos_b6 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 732 | return snakepos_b6; |
AhmedPlaymaker | 13:9785f2404045 | 733 | } |
AhmedPlaymaker | 13:9785f2404045 | 734 | } |
AhmedPlaymaker | 13:9785f2404045 | 735 | |
AhmedPlaymaker | 13:9785f2404045 | 736 | Vector2D Snake::get_pos_before7(int length) //this sends data of following sprites. |
AhmedPlaymaker | 13:9785f2404045 | 737 | { |
AhmedPlaymaker | 13:9785f2404045 | 738 | if(length == 1) { |
AhmedPlaymaker | 13:9785f2404045 | 739 | Vector2D snakepos_b7 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 740 | return snakepos_b7; |
AhmedPlaymaker | 13:9785f2404045 | 741 | } |
AhmedPlaymaker | 13:9785f2404045 | 742 | else if(length == 2) { |
AhmedPlaymaker | 13:9785f2404045 | 743 | Vector2D snakepos_b7 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 744 | return snakepos_b7; |
AhmedPlaymaker | 13:9785f2404045 | 745 | } |
AhmedPlaymaker | 13:9785f2404045 | 746 | else if(length == 3) { |
AhmedPlaymaker | 13:9785f2404045 | 747 | Vector2D snakepos_b7 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 748 | return snakepos_b7; |
AhmedPlaymaker | 13:9785f2404045 | 749 | } |
AhmedPlaymaker | 13:9785f2404045 | 750 | else if(length == 4) { |
AhmedPlaymaker | 13:9785f2404045 | 751 | Vector2D snakepos_b7 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 752 | return snakepos_b7; |
AhmedPlaymaker | 13:9785f2404045 | 753 | } |
AhmedPlaymaker | 13:9785f2404045 | 754 | else if(length == 5) { |
AhmedPlaymaker | 13:9785f2404045 | 755 | Vector2D snakepos_b7 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 756 | return snakepos_b7; |
AhmedPlaymaker | 13:9785f2404045 | 757 | } |
AhmedPlaymaker | 13:9785f2404045 | 758 | else if(length == 6) { |
AhmedPlaymaker | 13:9785f2404045 | 759 | Vector2D snakepos_b7 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 760 | return snakepos_b7; |
AhmedPlaymaker | 13:9785f2404045 | 761 | } |
AhmedPlaymaker | 13:9785f2404045 | 762 | else if(length == 7) { |
AhmedPlaymaker | 13:9785f2404045 | 763 | Vector2D snakepos_b7 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 764 | return snakepos_b7; |
AhmedPlaymaker | 13:9785f2404045 | 765 | } |
AhmedPlaymaker | 13:9785f2404045 | 766 | else if(length == 8) { |
AhmedPlaymaker | 13:9785f2404045 | 767 | Vector2D snakepos_b7 = {_x,_y}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 768 | return snakepos_b7; |
AhmedPlaymaker | 13:9785f2404045 | 769 | } |
AhmedPlaymaker | 13:9785f2404045 | 770 | else if(length==9) { |
AhmedPlaymaker | 13:9785f2404045 | 771 | Vector2D snakepos_b7 = {_xa,_ya}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 772 | return snakepos_b7; |
AhmedPlaymaker | 13:9785f2404045 | 773 | } |
AhmedPlaymaker | 13:9785f2404045 | 774 | else if(length==10) { |
AhmedPlaymaker | 13:9785f2404045 | 775 | Vector2D snakepos_b7 = {_xb,_yb}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 776 | return snakepos_b7; |
AhmedPlaymaker | 13:9785f2404045 | 777 | } |
AhmedPlaymaker | 13:9785f2404045 | 778 | else if(length==11) { |
AhmedPlaymaker | 13:9785f2404045 | 779 | Vector2D snakepos_b7 = {_xc,_yc}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 780 | return snakepos_b7; |
AhmedPlaymaker | 13:9785f2404045 | 781 | } |
AhmedPlaymaker | 13:9785f2404045 | 782 | else if(length==12) { |
AhmedPlaymaker | 13:9785f2404045 | 783 | Vector2D snakepos_b7 = {_xd,_yd}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 784 | return snakepos_b7; |
AhmedPlaymaker | 13:9785f2404045 | 785 | } |
AhmedPlaymaker | 13:9785f2404045 | 786 | else if(length==13) { |
AhmedPlaymaker | 13:9785f2404045 | 787 | Vector2D snakepos_b7 = {_xe,_ye}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 788 | return snakepos_b7; |
AhmedPlaymaker | 13:9785f2404045 | 789 | } |
AhmedPlaymaker | 13:9785f2404045 | 790 | else if(length==14) { |
AhmedPlaymaker | 13:9785f2404045 | 791 | Vector2D snakepos_b7 = {_xf,_yf}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 792 | return snakepos_b7; |
AhmedPlaymaker | 13:9785f2404045 | 793 | } |
AhmedPlaymaker | 13:9785f2404045 | 794 | else if(length==15) { |
AhmedPlaymaker | 13:9785f2404045 | 795 | Vector2D snakepos_b7 = {_xg,_yg}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 796 | return snakepos_b7; |
AhmedPlaymaker | 13:9785f2404045 | 797 | } |
AhmedPlaymaker | 13:9785f2404045 | 798 | //printf("snakepos from player = %f %f \n", snakepos.x, snakepos.y); |
AhmedPlaymaker | 13:9785f2404045 | 799 | else { |
AhmedPlaymaker | 13:9785f2404045 | 800 | Vector2D snakepos_b7 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 801 | return snakepos_b7; |
AhmedPlaymaker | 13:9785f2404045 | 802 | } |
AhmedPlaymaker | 7:48ba87cd79b5 | 803 | } |
AhmedPlaymaker | 7:48ba87cd79b5 | 804 | |
AhmedPlaymaker | 13:9785f2404045 | 805 | Vector2D Snake::get_pos_before8(int length) //this sends data of following sprites. |
AhmedPlaymaker | 13:9785f2404045 | 806 | { |
AhmedPlaymaker | 13:9785f2404045 | 807 | if(length == 1) { |
AhmedPlaymaker | 13:9785f2404045 | 808 | Vector2D snakepos_b8 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 809 | return snakepos_b8; |
AhmedPlaymaker | 13:9785f2404045 | 810 | } |
AhmedPlaymaker | 13:9785f2404045 | 811 | else if(length == 2) { |
AhmedPlaymaker | 13:9785f2404045 | 812 | Vector2D snakepos_b8 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 813 | return snakepos_b8; |
AhmedPlaymaker | 13:9785f2404045 | 814 | } |
AhmedPlaymaker | 13:9785f2404045 | 815 | else if(length == 3) { |
AhmedPlaymaker | 13:9785f2404045 | 816 | Vector2D snakepos_b8 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 817 | return snakepos_b8; |
AhmedPlaymaker | 13:9785f2404045 | 818 | } |
AhmedPlaymaker | 13:9785f2404045 | 819 | else if(length == 4) { |
AhmedPlaymaker | 13:9785f2404045 | 820 | Vector2D snakepos_b8 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 821 | return snakepos_b8; |
AhmedPlaymaker | 13:9785f2404045 | 822 | } |
AhmedPlaymaker | 13:9785f2404045 | 823 | else if(length == 5) { |
AhmedPlaymaker | 13:9785f2404045 | 824 | Vector2D snakepos_b8 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 825 | return snakepos_b8; |
AhmedPlaymaker | 13:9785f2404045 | 826 | } |
AhmedPlaymaker | 13:9785f2404045 | 827 | else if(length == 6) { |
AhmedPlaymaker | 13:9785f2404045 | 828 | Vector2D snakepos_b8 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 829 | return snakepos_b8; |
AhmedPlaymaker | 13:9785f2404045 | 830 | } |
AhmedPlaymaker | 13:9785f2404045 | 831 | else if(length == 7) { |
AhmedPlaymaker | 13:9785f2404045 | 832 | Vector2D snakepos_b8 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 833 | return snakepos_b8; |
AhmedPlaymaker | 13:9785f2404045 | 834 | } |
AhmedPlaymaker | 13:9785f2404045 | 835 | else if(length == 8) { |
AhmedPlaymaker | 13:9785f2404045 | 836 | Vector2D snakepos_b8 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 837 | return snakepos_b8; |
AhmedPlaymaker | 13:9785f2404045 | 838 | } |
AhmedPlaymaker | 13:9785f2404045 | 839 | else if(length == 9) { |
AhmedPlaymaker | 13:9785f2404045 | 840 | Vector2D snakepos_b8 = {_x,_y}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 841 | return snakepos_b8; |
AhmedPlaymaker | 13:9785f2404045 | 842 | } |
AhmedPlaymaker | 13:9785f2404045 | 843 | else if(length==10) { |
AhmedPlaymaker | 13:9785f2404045 | 844 | Vector2D snakepos_b8 = {_xa,_ya}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 845 | return snakepos_b8; |
AhmedPlaymaker | 13:9785f2404045 | 846 | } |
AhmedPlaymaker | 13:9785f2404045 | 847 | else if(length==11) { |
AhmedPlaymaker | 13:9785f2404045 | 848 | Vector2D snakepos_b8 = {_xb,_yb}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 849 | return snakepos_b8; |
AhmedPlaymaker | 13:9785f2404045 | 850 | } |
AhmedPlaymaker | 13:9785f2404045 | 851 | else if(length==12) { |
AhmedPlaymaker | 13:9785f2404045 | 852 | Vector2D snakepos_b8 = {_xc,_yc}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 853 | return snakepos_b8; |
AhmedPlaymaker | 13:9785f2404045 | 854 | } |
AhmedPlaymaker | 13:9785f2404045 | 855 | else if(length==13) { |
AhmedPlaymaker | 13:9785f2404045 | 856 | Vector2D snakepos_b8 = {_xd,_yd}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 857 | return snakepos_b8; |
AhmedPlaymaker | 13:9785f2404045 | 858 | } |
AhmedPlaymaker | 13:9785f2404045 | 859 | else if(length==14) { |
AhmedPlaymaker | 13:9785f2404045 | 860 | Vector2D snakepos_b8 = {_xe,_ye}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 861 | return snakepos_b8; |
AhmedPlaymaker | 13:9785f2404045 | 862 | } |
AhmedPlaymaker | 13:9785f2404045 | 863 | else if(length==15) { |
AhmedPlaymaker | 13:9785f2404045 | 864 | Vector2D snakepos_b8 = {_xf,_yf}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 865 | return snakepos_b8; |
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_b8 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 870 | return snakepos_b8; |
AhmedPlaymaker | 13:9785f2404045 | 871 | } |
AhmedPlaymaker | 13:9785f2404045 | 872 | } |
AhmedPlaymaker | 7:48ba87cd79b5 | 873 | |
AhmedPlaymaker | 13:9785f2404045 | 874 | Vector2D Snake::get_pos_before9(int length) //this sends data of following sprites. |
AhmedPlaymaker | 13:9785f2404045 | 875 | { |
AhmedPlaymaker | 13:9785f2404045 | 876 | if(length == 1) { |
AhmedPlaymaker | 13:9785f2404045 | 877 | Vector2D snakepos_b9 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 878 | return snakepos_b9; |
AhmedPlaymaker | 13:9785f2404045 | 879 | } |
AhmedPlaymaker | 13:9785f2404045 | 880 | else if(length == 2) { |
AhmedPlaymaker | 13:9785f2404045 | 881 | Vector2D snakepos_b9 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 882 | return snakepos_b9; |
AhmedPlaymaker | 13:9785f2404045 | 883 | } |
AhmedPlaymaker | 13:9785f2404045 | 884 | else if(length == 3) { |
AhmedPlaymaker | 13:9785f2404045 | 885 | Vector2D snakepos_b9 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 886 | return snakepos_b9; |
AhmedPlaymaker | 13:9785f2404045 | 887 | } |
AhmedPlaymaker | 13:9785f2404045 | 888 | else if(length == 4) { |
AhmedPlaymaker | 13:9785f2404045 | 889 | Vector2D snakepos_b9 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 890 | return snakepos_b9; |
AhmedPlaymaker | 13:9785f2404045 | 891 | } |
AhmedPlaymaker | 13:9785f2404045 | 892 | else if(length == 5) { |
AhmedPlaymaker | 13:9785f2404045 | 893 | Vector2D snakepos_b9 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 894 | return snakepos_b9; |
AhmedPlaymaker | 13:9785f2404045 | 895 | } |
AhmedPlaymaker | 13:9785f2404045 | 896 | else if(length == 6) { |
AhmedPlaymaker | 13:9785f2404045 | 897 | Vector2D snakepos_b9 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 898 | return snakepos_b9; |
AhmedPlaymaker | 13:9785f2404045 | 899 | } |
AhmedPlaymaker | 13:9785f2404045 | 900 | else if(length == 7) { |
AhmedPlaymaker | 13:9785f2404045 | 901 | Vector2D snakepos_b9 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 902 | return snakepos_b9; |
AhmedPlaymaker | 13:9785f2404045 | 903 | } |
AhmedPlaymaker | 13:9785f2404045 | 904 | else if(length == 8) { |
AhmedPlaymaker | 13:9785f2404045 | 905 | Vector2D snakepos_b9 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 906 | return snakepos_b9; |
AhmedPlaymaker | 13:9785f2404045 | 907 | } |
AhmedPlaymaker | 13:9785f2404045 | 908 | else if(length == 9) { |
AhmedPlaymaker | 13:9785f2404045 | 909 | Vector2D snakepos_b9 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 910 | return snakepos_b9; |
AhmedPlaymaker | 13:9785f2404045 | 911 | } |
AhmedPlaymaker | 13:9785f2404045 | 912 | else if(length == 10) { |
AhmedPlaymaker | 13:9785f2404045 | 913 | Vector2D snakepos_b9 = {_x,_y}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 914 | return snakepos_b9; |
AhmedPlaymaker | 13:9785f2404045 | 915 | } |
AhmedPlaymaker | 13:9785f2404045 | 916 | else if(length==11) { |
AhmedPlaymaker | 13:9785f2404045 | 917 | Vector2D snakepos_b9 = {_xa,_ya}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 918 | return snakepos_b9; |
AhmedPlaymaker | 13:9785f2404045 | 919 | } |
AhmedPlaymaker | 13:9785f2404045 | 920 | else if(length==12) { |
AhmedPlaymaker | 13:9785f2404045 | 921 | Vector2D snakepos_b9 = {_xb,_yb}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 922 | return snakepos_b9; |
AhmedPlaymaker | 13:9785f2404045 | 923 | } |
AhmedPlaymaker | 13:9785f2404045 | 924 | else if(length==13) { |
AhmedPlaymaker | 13:9785f2404045 | 925 | Vector2D snakepos_b9 = {_xc,_yc}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 926 | return snakepos_b9; |
AhmedPlaymaker | 13:9785f2404045 | 927 | } |
AhmedPlaymaker | 13:9785f2404045 | 928 | else if(length==14) { |
AhmedPlaymaker | 13:9785f2404045 | 929 | Vector2D snakepos_b9 = {_xd,_yd}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 930 | return snakepos_b9; |
AhmedPlaymaker | 13:9785f2404045 | 931 | } |
AhmedPlaymaker | 13:9785f2404045 | 932 | else if(length==15) { |
AhmedPlaymaker | 13:9785f2404045 | 933 | Vector2D snakepos_b9 = {_xe,_ye}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 934 | return snakepos_b9; |
AhmedPlaymaker | 13:9785f2404045 | 935 | } |
AhmedPlaymaker | 13:9785f2404045 | 936 | //printf("snakepos from player = %f %f \n", snakepos.x, snakepos.y); |
AhmedPlaymaker | 13:9785f2404045 | 937 | else { |
AhmedPlaymaker | 13:9785f2404045 | 938 | Vector2D snakepos_b9 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 939 | return snakepos_b9; |
AhmedPlaymaker | 13:9785f2404045 | 940 | } |
AhmedPlaymaker | 13:9785f2404045 | 941 | } |
AhmedPlaymaker | 13:9785f2404045 | 942 | |
AhmedPlaymaker | 13:9785f2404045 | 943 | Vector2D Snake::get_pos_before10(int length) //this sends data of following sprites. |
AhmedPlaymaker | 13:9785f2404045 | 944 | { |
AhmedPlaymaker | 13:9785f2404045 | 945 | if(length == 1) { |
AhmedPlaymaker | 13:9785f2404045 | 946 | Vector2D snakepos_b10 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 947 | return snakepos_b10; |
AhmedPlaymaker | 13:9785f2404045 | 948 | } |
AhmedPlaymaker | 13:9785f2404045 | 949 | else if(length == 2) { |
AhmedPlaymaker | 13:9785f2404045 | 950 | Vector2D snakepos_b10 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 951 | return snakepos_b10; |
AhmedPlaymaker | 13:9785f2404045 | 952 | } |
AhmedPlaymaker | 13:9785f2404045 | 953 | else if(length == 3) { |
AhmedPlaymaker | 13:9785f2404045 | 954 | Vector2D snakepos_b10 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 955 | return snakepos_b10; |
AhmedPlaymaker | 13:9785f2404045 | 956 | } |
AhmedPlaymaker | 13:9785f2404045 | 957 | else if(length == 4) { |
AhmedPlaymaker | 13:9785f2404045 | 958 | Vector2D snakepos_b10 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 959 | return snakepos_b10; |
AhmedPlaymaker | 13:9785f2404045 | 960 | } |
AhmedPlaymaker | 13:9785f2404045 | 961 | else if(length == 5) { |
AhmedPlaymaker | 13:9785f2404045 | 962 | Vector2D snakepos_b10 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 963 | return snakepos_b10; |
AhmedPlaymaker | 13:9785f2404045 | 964 | } |
AhmedPlaymaker | 13:9785f2404045 | 965 | else if(length == 6) { |
AhmedPlaymaker | 13:9785f2404045 | 966 | Vector2D snakepos_b10 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 967 | return snakepos_b10; |
AhmedPlaymaker | 13:9785f2404045 | 968 | } |
AhmedPlaymaker | 13:9785f2404045 | 969 | else if(length == 7) { |
AhmedPlaymaker | 13:9785f2404045 | 970 | Vector2D snakepos_b10 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 971 | return snakepos_b10; |
AhmedPlaymaker | 13:9785f2404045 | 972 | } |
AhmedPlaymaker | 13:9785f2404045 | 973 | else if(length == 8) { |
AhmedPlaymaker | 13:9785f2404045 | 974 | Vector2D snakepos_b10 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 975 | return snakepos_b10; |
AhmedPlaymaker | 13:9785f2404045 | 976 | } |
AhmedPlaymaker | 13:9785f2404045 | 977 | else if(length == 9) { |
AhmedPlaymaker | 13:9785f2404045 | 978 | Vector2D snakepos_b10 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 979 | return snakepos_b10; |
AhmedPlaymaker | 13:9785f2404045 | 980 | } |
AhmedPlaymaker | 13:9785f2404045 | 981 | else if(length == 10) { |
AhmedPlaymaker | 13:9785f2404045 | 982 | Vector2D snakepos_b10 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 983 | return snakepos_b10; |
AhmedPlaymaker | 13:9785f2404045 | 984 | } |
AhmedPlaymaker | 13:9785f2404045 | 985 | else if(length == 11) { |
AhmedPlaymaker | 13:9785f2404045 | 986 | Vector2D snakepos_b10 = {_x,_y}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 987 | return snakepos_b10; |
AhmedPlaymaker | 13:9785f2404045 | 988 | } |
AhmedPlaymaker | 13:9785f2404045 | 989 | else if(length==12) { |
AhmedPlaymaker | 13:9785f2404045 | 990 | Vector2D snakepos_b10 = {_xa,_ya}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 991 | return snakepos_b10; |
AhmedPlaymaker | 13:9785f2404045 | 992 | } |
AhmedPlaymaker | 13:9785f2404045 | 993 | else if(length==13) { |
AhmedPlaymaker | 13:9785f2404045 | 994 | Vector2D snakepos_b10 = {_xb,_yb}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 995 | return snakepos_b10; |
AhmedPlaymaker | 13:9785f2404045 | 996 | } |
AhmedPlaymaker | 13:9785f2404045 | 997 | else if(length==14) { |
AhmedPlaymaker | 13:9785f2404045 | 998 | Vector2D snakepos_b10 = {_xc,_yc}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 999 | return snakepos_b10; |
AhmedPlaymaker | 13:9785f2404045 | 1000 | } |
AhmedPlaymaker | 13:9785f2404045 | 1001 | else if(length==15) { |
AhmedPlaymaker | 13:9785f2404045 | 1002 | Vector2D snakepos_b10 = {_xd,_yd}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 1003 | return snakepos_b10; |
AhmedPlaymaker | 13:9785f2404045 | 1004 | } |
AhmedPlaymaker | 13:9785f2404045 | 1005 | //printf("snakepos from player = %f %f \n", snakepos.x, snakepos.y); |
AhmedPlaymaker | 13:9785f2404045 | 1006 | else { |
AhmedPlaymaker | 13:9785f2404045 | 1007 | Vector2D snakepos_b10 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 1008 | return snakepos_b10; |
AhmedPlaymaker | 13:9785f2404045 | 1009 | } |
AhmedPlaymaker | 13:9785f2404045 | 1010 | } |
AhmedPlaymaker | 13:9785f2404045 | 1011 | |
AhmedPlaymaker | 13:9785f2404045 | 1012 | Vector2D Snake::get_pos_before11(int length) //this sends data of following sprites. |
AhmedPlaymaker | 13:9785f2404045 | 1013 | { |
AhmedPlaymaker | 13:9785f2404045 | 1014 | if(length == 1) { |
AhmedPlaymaker | 13:9785f2404045 | 1015 | Vector2D snakepos_b11 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 1016 | return snakepos_b11; |
AhmedPlaymaker | 13:9785f2404045 | 1017 | } |
AhmedPlaymaker | 13:9785f2404045 | 1018 | else if(length == 2) { |
AhmedPlaymaker | 13:9785f2404045 | 1019 | Vector2D snakepos_b11 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 1020 | return snakepos_b11; |
AhmedPlaymaker | 13:9785f2404045 | 1021 | } |
AhmedPlaymaker | 13:9785f2404045 | 1022 | else if(length == 3) { |
AhmedPlaymaker | 13:9785f2404045 | 1023 | Vector2D snakepos_b11 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 1024 | return snakepos_b11; |
AhmedPlaymaker | 13:9785f2404045 | 1025 | } |
AhmedPlaymaker | 13:9785f2404045 | 1026 | else if(length == 4) { |
AhmedPlaymaker | 13:9785f2404045 | 1027 | Vector2D snakepos_b11 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 1028 | return snakepos_b11; |
AhmedPlaymaker | 13:9785f2404045 | 1029 | } |
AhmedPlaymaker | 13:9785f2404045 | 1030 | else if(length == 5) { |
AhmedPlaymaker | 13:9785f2404045 | 1031 | Vector2D snakepos_b11 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 1032 | return snakepos_b11; |
AhmedPlaymaker | 13:9785f2404045 | 1033 | } |
AhmedPlaymaker | 13:9785f2404045 | 1034 | else if(length == 6) { |
AhmedPlaymaker | 13:9785f2404045 | 1035 | Vector2D snakepos_b11 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 1036 | return snakepos_b11; |
AhmedPlaymaker | 13:9785f2404045 | 1037 | } |
AhmedPlaymaker | 13:9785f2404045 | 1038 | else if(length == 7) { |
AhmedPlaymaker | 13:9785f2404045 | 1039 | Vector2D snakepos_b11 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 1040 | return snakepos_b11; |
AhmedPlaymaker | 13:9785f2404045 | 1041 | } |
AhmedPlaymaker | 13:9785f2404045 | 1042 | else if(length == 8) { |
AhmedPlaymaker | 13:9785f2404045 | 1043 | Vector2D snakepos_b11 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 1044 | return snakepos_b11; |
AhmedPlaymaker | 13:9785f2404045 | 1045 | } |
AhmedPlaymaker | 13:9785f2404045 | 1046 | else if(length == 9) { |
AhmedPlaymaker | 13:9785f2404045 | 1047 | Vector2D snakepos_b11 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 1048 | return snakepos_b11; |
AhmedPlaymaker | 13:9785f2404045 | 1049 | } |
AhmedPlaymaker | 13:9785f2404045 | 1050 | else if(length == 10) { |
AhmedPlaymaker | 13:9785f2404045 | 1051 | Vector2D snakepos_b11 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 1052 | return snakepos_b11; |
AhmedPlaymaker | 13:9785f2404045 | 1053 | } |
AhmedPlaymaker | 13:9785f2404045 | 1054 | else if(length == 11) { |
AhmedPlaymaker | 13:9785f2404045 | 1055 | Vector2D snakepos_b11 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 1056 | return snakepos_b11; |
AhmedPlaymaker | 13:9785f2404045 | 1057 | } |
AhmedPlaymaker | 13:9785f2404045 | 1058 | else if(length == 12) { |
AhmedPlaymaker | 13:9785f2404045 | 1059 | Vector2D snakepos_b11 = {_x,_y}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 1060 | return snakepos_b11; |
AhmedPlaymaker | 13:9785f2404045 | 1061 | } |
AhmedPlaymaker | 13:9785f2404045 | 1062 | else if(length==13) { |
AhmedPlaymaker | 13:9785f2404045 | 1063 | Vector2D snakepos_b11 = {_xa,_ya}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 1064 | return snakepos_b11; |
AhmedPlaymaker | 13:9785f2404045 | 1065 | } |
AhmedPlaymaker | 13:9785f2404045 | 1066 | else if(length==14) { |
AhmedPlaymaker | 13:9785f2404045 | 1067 | Vector2D snakepos_b11 = {_xb,_yb}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 1068 | return snakepos_b11; |
AhmedPlaymaker | 13:9785f2404045 | 1069 | } |
AhmedPlaymaker | 13:9785f2404045 | 1070 | else if(length==15) { |
AhmedPlaymaker | 13:9785f2404045 | 1071 | Vector2D snakepos_b11 = {_xc,_yc}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 1072 | return snakepos_b11; |
AhmedPlaymaker | 13:9785f2404045 | 1073 | } |
AhmedPlaymaker | 13:9785f2404045 | 1074 | //printf("snakepos from player = %f %f \n", snakepos.x, snakepos.y); |
AhmedPlaymaker | 13:9785f2404045 | 1075 | else { |
AhmedPlaymaker | 13:9785f2404045 | 1076 | Vector2D snakepos_b11 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 1077 | return snakepos_b11; |
AhmedPlaymaker | 13:9785f2404045 | 1078 | } |
AhmedPlaymaker | 13:9785f2404045 | 1079 | } |
AhmedPlaymaker | 13:9785f2404045 | 1080 | |
AhmedPlaymaker | 13:9785f2404045 | 1081 | Vector2D Snake::get_pos_before12(int length) //this sends data of following sprites. |
AhmedPlaymaker | 7:48ba87cd79b5 | 1082 | { |
AhmedPlaymaker | 13:9785f2404045 | 1083 | if(length == 1) { |
AhmedPlaymaker | 13:9785f2404045 | 1084 | Vector2D snakepos_b12 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 1085 | return snakepos_b12; |
AhmedPlaymaker | 13:9785f2404045 | 1086 | } |
AhmedPlaymaker | 13:9785f2404045 | 1087 | else if(length == 2) { |
AhmedPlaymaker | 13:9785f2404045 | 1088 | Vector2D snakepos_b12 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 1089 | return snakepos_b12; |
AhmedPlaymaker | 13:9785f2404045 | 1090 | } |
AhmedPlaymaker | 13:9785f2404045 | 1091 | else if(length == 3) { |
AhmedPlaymaker | 13:9785f2404045 | 1092 | Vector2D snakepos_b12 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 1093 | return snakepos_b12; |
AhmedPlaymaker | 13:9785f2404045 | 1094 | } |
AhmedPlaymaker | 13:9785f2404045 | 1095 | else if(length == 4) { |
AhmedPlaymaker | 13:9785f2404045 | 1096 | Vector2D snakepos_b12 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 1097 | return snakepos_b12; |
AhmedPlaymaker | 13:9785f2404045 | 1098 | } |
AhmedPlaymaker | 13:9785f2404045 | 1099 | else if(length == 5) { |
AhmedPlaymaker | 13:9785f2404045 | 1100 | Vector2D snakepos_b12 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 1101 | return snakepos_b12; |
AhmedPlaymaker | 13:9785f2404045 | 1102 | } |
AhmedPlaymaker | 13:9785f2404045 | 1103 | else if(length == 6) { |
AhmedPlaymaker | 13:9785f2404045 | 1104 | Vector2D snakepos_b12 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 1105 | return snakepos_b12; |
AhmedPlaymaker | 13:9785f2404045 | 1106 | } |
AhmedPlaymaker | 13:9785f2404045 | 1107 | else if(length == 7) { |
AhmedPlaymaker | 13:9785f2404045 | 1108 | Vector2D snakepos_b12 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 1109 | return snakepos_b12; |
AhmedPlaymaker | 13:9785f2404045 | 1110 | } |
AhmedPlaymaker | 13:9785f2404045 | 1111 | else if(length == 8) { |
AhmedPlaymaker | 13:9785f2404045 | 1112 | Vector2D snakepos_b12 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 1113 | return snakepos_b12; |
AhmedPlaymaker | 13:9785f2404045 | 1114 | } |
AhmedPlaymaker | 13:9785f2404045 | 1115 | else if(length == 9) { |
AhmedPlaymaker | 13:9785f2404045 | 1116 | Vector2D snakepos_b12 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 1117 | return snakepos_b12; |
AhmedPlaymaker | 13:9785f2404045 | 1118 | } |
AhmedPlaymaker | 13:9785f2404045 | 1119 | else if(length == 10) { |
AhmedPlaymaker | 13:9785f2404045 | 1120 | Vector2D snakepos_b12 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 1121 | return snakepos_b12; |
AhmedPlaymaker | 13:9785f2404045 | 1122 | } |
AhmedPlaymaker | 13:9785f2404045 | 1123 | else if(length == 11) { |
AhmedPlaymaker | 13:9785f2404045 | 1124 | Vector2D snakepos_b12 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 1125 | return snakepos_b12; |
AhmedPlaymaker | 13:9785f2404045 | 1126 | } |
AhmedPlaymaker | 13:9785f2404045 | 1127 | else if(length == 12) { |
AhmedPlaymaker | 13:9785f2404045 | 1128 | Vector2D snakepos_b12 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 1129 | return snakepos_b12; |
AhmedPlaymaker | 13:9785f2404045 | 1130 | } |
AhmedPlaymaker | 13:9785f2404045 | 1131 | else if(length == 13) { |
AhmedPlaymaker | 13:9785f2404045 | 1132 | Vector2D snakepos_b12 = {_x,_y}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 1133 | return snakepos_b12; |
AhmedPlaymaker | 13:9785f2404045 | 1134 | } |
AhmedPlaymaker | 13:9785f2404045 | 1135 | else if(length==14) { |
AhmedPlaymaker | 13:9785f2404045 | 1136 | Vector2D snakepos_b12 = {_xa,_ya}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 1137 | return snakepos_b12; |
AhmedPlaymaker | 13:9785f2404045 | 1138 | } |
AhmedPlaymaker | 13:9785f2404045 | 1139 | else if(length==15) { |
AhmedPlaymaker | 13:9785f2404045 | 1140 | Vector2D snakepos_b12 = {_xb,_yb}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 1141 | return snakepos_b12; |
AhmedPlaymaker | 13:9785f2404045 | 1142 | } |
AhmedPlaymaker | 13:9785f2404045 | 1143 | //printf("snakepos from player = %f %f \n", snakepos.x, snakepos.y); |
AhmedPlaymaker | 13:9785f2404045 | 1144 | else { |
AhmedPlaymaker | 13:9785f2404045 | 1145 | Vector2D snakepos_b12 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 1146 | return snakepos_b12; |
AhmedPlaymaker | 13:9785f2404045 | 1147 | } |
AhmedPlaymaker | 13:9785f2404045 | 1148 | } |
AhmedPlaymaker | 13:9785f2404045 | 1149 | |
AhmedPlaymaker | 13:9785f2404045 | 1150 | Vector2D Snake::get_pos_before13(int length) //this sends data of following sprites. |
AhmedPlaymaker | 13:9785f2404045 | 1151 | { |
AhmedPlaymaker | 13:9785f2404045 | 1152 | if(length == 1) { |
AhmedPlaymaker | 13:9785f2404045 | 1153 | Vector2D snakepos_b13 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 1154 | return snakepos_b13; |
AhmedPlaymaker | 13:9785f2404045 | 1155 | } |
AhmedPlaymaker | 13:9785f2404045 | 1156 | else if(length == 2) { |
AhmedPlaymaker | 13:9785f2404045 | 1157 | Vector2D snakepos_b13 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 1158 | return snakepos_b13; |
AhmedPlaymaker | 13:9785f2404045 | 1159 | } |
AhmedPlaymaker | 13:9785f2404045 | 1160 | else if(length == 3) { |
AhmedPlaymaker | 13:9785f2404045 | 1161 | Vector2D snakepos_b13 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 1162 | return snakepos_b13; |
AhmedPlaymaker | 13:9785f2404045 | 1163 | } |
AhmedPlaymaker | 13:9785f2404045 | 1164 | else if(length == 4) { |
AhmedPlaymaker | 13:9785f2404045 | 1165 | Vector2D snakepos_b13 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 1166 | return snakepos_b13; |
AhmedPlaymaker | 13:9785f2404045 | 1167 | } |
AhmedPlaymaker | 13:9785f2404045 | 1168 | else if(length == 5) { |
AhmedPlaymaker | 13:9785f2404045 | 1169 | Vector2D snakepos_b13 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 1170 | return snakepos_b13; |
AhmedPlaymaker | 13:9785f2404045 | 1171 | } |
AhmedPlaymaker | 13:9785f2404045 | 1172 | else if(length == 6) { |
AhmedPlaymaker | 13:9785f2404045 | 1173 | Vector2D snakepos_b13 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 1174 | return snakepos_b13; |
AhmedPlaymaker | 13:9785f2404045 | 1175 | } |
AhmedPlaymaker | 13:9785f2404045 | 1176 | else if(length == 7) { |
AhmedPlaymaker | 13:9785f2404045 | 1177 | Vector2D snakepos_b13 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 1178 | return snakepos_b13; |
AhmedPlaymaker | 13:9785f2404045 | 1179 | } |
AhmedPlaymaker | 13:9785f2404045 | 1180 | else if(length == 8) { |
AhmedPlaymaker | 13:9785f2404045 | 1181 | Vector2D snakepos_b13 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 1182 | return snakepos_b13; |
AhmedPlaymaker | 13:9785f2404045 | 1183 | } |
AhmedPlaymaker | 13:9785f2404045 | 1184 | else if(length == 9) { |
AhmedPlaymaker | 13:9785f2404045 | 1185 | Vector2D snakepos_b13 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 1186 | return snakepos_b13; |
AhmedPlaymaker | 13:9785f2404045 | 1187 | } |
AhmedPlaymaker | 13:9785f2404045 | 1188 | else if(length == 10) { |
AhmedPlaymaker | 13:9785f2404045 | 1189 | Vector2D snakepos_b13 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 1190 | return snakepos_b13; |
AhmedPlaymaker | 13:9785f2404045 | 1191 | } |
AhmedPlaymaker | 13:9785f2404045 | 1192 | else if(length == 11) { |
AhmedPlaymaker | 13:9785f2404045 | 1193 | Vector2D snakepos_b13 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 1194 | return snakepos_b13; |
AhmedPlaymaker | 13:9785f2404045 | 1195 | } |
AhmedPlaymaker | 13:9785f2404045 | 1196 | else if(length == 12) { |
AhmedPlaymaker | 13:9785f2404045 | 1197 | Vector2D snakepos_b13 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 1198 | return snakepos_b13; |
AhmedPlaymaker | 13:9785f2404045 | 1199 | } |
AhmedPlaymaker | 13:9785f2404045 | 1200 | else if(length == 13) { |
AhmedPlaymaker | 13:9785f2404045 | 1201 | Vector2D snakepos_b13 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 1202 | return snakepos_b13; |
AhmedPlaymaker | 13:9785f2404045 | 1203 | } |
AhmedPlaymaker | 13:9785f2404045 | 1204 | else if(length == 14) { |
AhmedPlaymaker | 13:9785f2404045 | 1205 | Vector2D snakepos_b13 = {_x,_y}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 1206 | return snakepos_b13; |
AhmedPlaymaker | 13:9785f2404045 | 1207 | } |
AhmedPlaymaker | 13:9785f2404045 | 1208 | else if(length==15) { |
AhmedPlaymaker | 13:9785f2404045 | 1209 | Vector2D snakepos_b13 = {_xa,_ya}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 1210 | return snakepos_b13; |
AhmedPlaymaker | 13:9785f2404045 | 1211 | } |
AhmedPlaymaker | 13:9785f2404045 | 1212 | //printf("snakepos from player = %f %f \n", snakepos.x, snakepos.y); |
AhmedPlaymaker | 13:9785f2404045 | 1213 | else { |
AhmedPlaymaker | 13:9785f2404045 | 1214 | Vector2D snakepos_b13 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 1215 | return snakepos_b13; |
AhmedPlaymaker | 13:9785f2404045 | 1216 | } |
AhmedPlaymaker | 13:9785f2404045 | 1217 | } |
AhmedPlaymaker | 13:9785f2404045 | 1218 | |
AhmedPlaymaker | 13:9785f2404045 | 1219 | Vector2D Snake::get_pos_before14(int length) //this sends data of following sprites. |
AhmedPlaymaker | 13:9785f2404045 | 1220 | { |
AhmedPlaymaker | 13:9785f2404045 | 1221 | if(length == 1) { |
AhmedPlaymaker | 13:9785f2404045 | 1222 | Vector2D snakepos_b14 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 1223 | return snakepos_b14; |
AhmedPlaymaker | 13:9785f2404045 | 1224 | } |
AhmedPlaymaker | 13:9785f2404045 | 1225 | else if(length == 2) { |
AhmedPlaymaker | 13:9785f2404045 | 1226 | Vector2D snakepos_b14 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 1227 | return snakepos_b14; |
AhmedPlaymaker | 13:9785f2404045 | 1228 | } |
AhmedPlaymaker | 13:9785f2404045 | 1229 | else if(length == 3) { |
AhmedPlaymaker | 13:9785f2404045 | 1230 | Vector2D snakepos_b14 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 1231 | return snakepos_b14; |
AhmedPlaymaker | 13:9785f2404045 | 1232 | } |
AhmedPlaymaker | 13:9785f2404045 | 1233 | else if(length == 4) { |
AhmedPlaymaker | 13:9785f2404045 | 1234 | Vector2D snakepos_b14 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 1235 | return snakepos_b14; |
AhmedPlaymaker | 13:9785f2404045 | 1236 | } |
AhmedPlaymaker | 13:9785f2404045 | 1237 | else if(length == 5) { |
AhmedPlaymaker | 13:9785f2404045 | 1238 | Vector2D snakepos_b14 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 1239 | return snakepos_b14; |
AhmedPlaymaker | 13:9785f2404045 | 1240 | } |
AhmedPlaymaker | 13:9785f2404045 | 1241 | else if(length == 6) { |
AhmedPlaymaker | 13:9785f2404045 | 1242 | Vector2D snakepos_b14 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 1243 | return snakepos_b14; |
AhmedPlaymaker | 13:9785f2404045 | 1244 | } |
AhmedPlaymaker | 13:9785f2404045 | 1245 | else if(length == 7) { |
AhmedPlaymaker | 13:9785f2404045 | 1246 | Vector2D snakepos_b14 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 1247 | return snakepos_b14; |
AhmedPlaymaker | 13:9785f2404045 | 1248 | } |
AhmedPlaymaker | 13:9785f2404045 | 1249 | else if(length == 8) { |
AhmedPlaymaker | 13:9785f2404045 | 1250 | Vector2D snakepos_b14 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 1251 | return snakepos_b14; |
AhmedPlaymaker | 13:9785f2404045 | 1252 | } |
AhmedPlaymaker | 13:9785f2404045 | 1253 | else if(length == 9) { |
AhmedPlaymaker | 13:9785f2404045 | 1254 | Vector2D snakepos_b14 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 1255 | return snakepos_b14; |
AhmedPlaymaker | 13:9785f2404045 | 1256 | } |
AhmedPlaymaker | 13:9785f2404045 | 1257 | else if(length == 10) { |
AhmedPlaymaker | 13:9785f2404045 | 1258 | Vector2D snakepos_b14 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 1259 | return snakepos_b14; |
AhmedPlaymaker | 13:9785f2404045 | 1260 | } |
AhmedPlaymaker | 13:9785f2404045 | 1261 | else if(length == 11) { |
AhmedPlaymaker | 13:9785f2404045 | 1262 | Vector2D snakepos_b14 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 1263 | return snakepos_b14; |
AhmedPlaymaker | 13:9785f2404045 | 1264 | } |
AhmedPlaymaker | 13:9785f2404045 | 1265 | else if(length == 12) { |
AhmedPlaymaker | 13:9785f2404045 | 1266 | Vector2D snakepos_b14 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 1267 | return snakepos_b14; |
AhmedPlaymaker | 13:9785f2404045 | 1268 | } |
AhmedPlaymaker | 13:9785f2404045 | 1269 | else if(length == 13) { |
AhmedPlaymaker | 13:9785f2404045 | 1270 | Vector2D snakepos_b14 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 1271 | return snakepos_b14; |
AhmedPlaymaker | 13:9785f2404045 | 1272 | } |
AhmedPlaymaker | 13:9785f2404045 | 1273 | else if(length == 14) { |
AhmedPlaymaker | 13:9785f2404045 | 1274 | Vector2D snakepos_b14 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 1275 | return snakepos_b14; |
AhmedPlaymaker | 13:9785f2404045 | 1276 | } |
AhmedPlaymaker | 13:9785f2404045 | 1277 | else if(length==15) { |
AhmedPlaymaker | 13:9785f2404045 | 1278 | Vector2D snakepos_b14 = {_x,_y}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 1279 | return snakepos_b14; |
AhmedPlaymaker | 13:9785f2404045 | 1280 | } |
AhmedPlaymaker | 13:9785f2404045 | 1281 | //printf("snakepos from player = %f %f \n", snakepos.x, snakepos.y); |
AhmedPlaymaker | 13:9785f2404045 | 1282 | else { |
AhmedPlaymaker | 13:9785f2404045 | 1283 | Vector2D snakepos_b14 = {-20,-20}; //Obtains the snake position. |
AhmedPlaymaker | 13:9785f2404045 | 1284 | return snakepos_b14; |
AhmedPlaymaker | 13:9785f2404045 | 1285 | } |
AhmedPlaymaker | 13:9785f2404045 | 1286 | } |
AhmedPlaymaker | 13:9785f2404045 | 1287 | |
AhmedPlaymaker | 18:b391caa5754c | 1288 | |
AhmedPlaymaker | 13:9785f2404045 | 1289 | |
AhmedPlaymaker | 18:b391caa5754c | 1290 | void Snake::update(Direction d,float mag,int length, int speed, int* b0_to_b14) |
AhmedPlaymaker | 13:9785f2404045 | 1291 | { |
AhmedPlaymaker | 13:9785f2404045 | 1292 | _speed = speed; //Speed changes depending on how much you push the joystick.(As Of Now) |
AhmedPlaymaker | 18:b391caa5754c | 1293 | b0 = b0_to_b14[0]; |
AhmedPlaymaker | 18:b391caa5754c | 1294 | b1 = b0_to_b14[1]; |
AhmedPlaymaker | 18:b391caa5754c | 1295 | b2 = b0_to_b14[2]; |
AhmedPlaymaker | 18:b391caa5754c | 1296 | b3 = b0_to_b14[3]; |
AhmedPlaymaker | 18:b391caa5754c | 1297 | b4 = b0_to_b14[4]; |
AhmedPlaymaker | 18:b391caa5754c | 1298 | b5 = b0_to_b14[5]; |
AhmedPlaymaker | 18:b391caa5754c | 1299 | b6 = b0_to_b14[6]; |
AhmedPlaymaker | 18:b391caa5754c | 1300 | b7 = b0_to_b14[7]; |
AhmedPlaymaker | 18:b391caa5754c | 1301 | b8 = b0_to_b14[8]; |
AhmedPlaymaker | 18:b391caa5754c | 1302 | b9 = b0_to_b14[9]; |
AhmedPlaymaker | 18:b391caa5754c | 1303 | b10 = b0_to_b14[10]; |
AhmedPlaymaker | 18:b391caa5754c | 1304 | b11 = b0_to_b14[11]; |
AhmedPlaymaker | 18:b391caa5754c | 1305 | b12 = b0_to_b14[12]; |
AhmedPlaymaker | 18:b391caa5754c | 1306 | b13 = b0_to_b14[13]; |
AhmedPlaymaker | 18:b391caa5754c | 1307 | b14 = b0_to_b14[14]; |
AhmedPlaymaker | 8:890b986b16a4 | 1308 | |
AhmedPlaymaker | 8:890b986b16a4 | 1309 | if(length > 1) { |
AhmedPlaymaker | 18:b391caa5754c | 1310 | if ((_x > _xa)&&(b1 == 1)&&(b0 == 1)) { |
AhmedPlaymaker | 8:890b986b16a4 | 1311 | _x-=_speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1312 | } |
AhmedPlaymaker | 18:b391caa5754c | 1313 | if ((_x < _xa)&&(b1 == 1)&&(b0 == 1)) { |
AhmedPlaymaker | 8:890b986b16a4 | 1314 | _x+=_speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1315 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1316 | if(length > 2) { |
AhmedPlaymaker | 18:b391caa5754c | 1317 | if ((_xa > _xb)&&(b2 == 1)&&(b1 == 1)) { |
AhmedPlaymaker | 8:890b986b16a4 | 1318 | _xa-=_speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1319 | } |
AhmedPlaymaker | 18:b391caa5754c | 1320 | if ((_xa < _xb)&&(b2 == 1)&&(b1 == 1)) { |
AhmedPlaymaker | 8:890b986b16a4 | 1321 | _xa+=_speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1322 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1323 | if(length > 3) { |
AhmedPlaymaker | 18:b391caa5754c | 1324 | if ((_xb > _xc)&&(b3 == 1)&&(b2 == 1)) { |
AhmedPlaymaker | 8:890b986b16a4 | 1325 | _xb-=_speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1326 | } |
AhmedPlaymaker | 18:b391caa5754c | 1327 | if ((_xb < _xc)&&(b3 == 1)&&(b2 == 1)) { |
AhmedPlaymaker | 8:890b986b16a4 | 1328 | _xb+=_speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1329 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1330 | if(length > 4) { |
AhmedPlaymaker | 18:b391caa5754c | 1331 | if ((_xc > _xd)&&(b4 == 1)&&(b3 == 1)) { |
AhmedPlaymaker | 8:890b986b16a4 | 1332 | _xc-=_speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1333 | } |
AhmedPlaymaker | 18:b391caa5754c | 1334 | if ((_xc < _xd)&&(b4 == 1)&&(b3 == 1)) { |
AhmedPlaymaker | 8:890b986b16a4 | 1335 | _xc+=_speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1336 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1337 | if(length > 5) { |
AhmedPlaymaker | 18:b391caa5754c | 1338 | if ((_xd > _xe)&&(b5 == 1)&&(b4 == 1)) { |
AhmedPlaymaker | 8:890b986b16a4 | 1339 | _xd-=_speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1340 | } |
AhmedPlaymaker | 18:b391caa5754c | 1341 | if ((_xd < _xe)&&(b5 == 1)&&(b4 == 1)) { |
AhmedPlaymaker | 8:890b986b16a4 | 1342 | _xd+=_speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1343 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1344 | if(length > 6) { |
AhmedPlaymaker | 18:b391caa5754c | 1345 | if ((_xe > _xf)&&(b6 == 1)&&(b5 == 1)) { |
AhmedPlaymaker | 8:890b986b16a4 | 1346 | _xe-=_speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1347 | } |
AhmedPlaymaker | 18:b391caa5754c | 1348 | if ((_xe < _xf)&&(b6 == 1)&&(b5 == 1)) { |
AhmedPlaymaker | 8:890b986b16a4 | 1349 | _xe+=_speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1350 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1351 | if(length > 7) { |
AhmedPlaymaker | 18:b391caa5754c | 1352 | if ((_xf > _xg)&&(b7 == 1)&&(b6 == 1)) { |
AhmedPlaymaker | 8:890b986b16a4 | 1353 | _xf-=_speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1354 | } |
AhmedPlaymaker | 18:b391caa5754c | 1355 | if ((_xf < _xg)&&(b7 == 1)&&(b6 == 1)) { |
AhmedPlaymaker | 8:890b986b16a4 | 1356 | _xf+=_speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1357 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1358 | if(length > 8) { |
AhmedPlaymaker | 18:b391caa5754c | 1359 | if ((_xg > _xh)&&(b8 == 1)&&(b7 == 1)) { |
AhmedPlaymaker | 8:890b986b16a4 | 1360 | _xg-=_speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1361 | } |
AhmedPlaymaker | 18:b391caa5754c | 1362 | if ((_xg < _xh)&&(b8 == 1)&&(b7 == 1)) { |
AhmedPlaymaker | 8:890b986b16a4 | 1363 | _xg+=_speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1364 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1365 | if(length > 9) { |
AhmedPlaymaker | 18:b391caa5754c | 1366 | if ((_xh > _xi)&&(b9 == 1)&&(b8 == 1)) { |
AhmedPlaymaker | 8:890b986b16a4 | 1367 | _xh-=_speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1368 | } |
AhmedPlaymaker | 18:b391caa5754c | 1369 | if ((_xh < _xi)&&(b9 == 1)&&(b8 == 1)) { |
AhmedPlaymaker | 8:890b986b16a4 | 1370 | _xh+=_speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1371 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1372 | if(length > 10) { |
AhmedPlaymaker | 18:b391caa5754c | 1373 | if ((_xi > _xj)&&(b10 == 1)&&(b9 == 1)) { |
AhmedPlaymaker | 8:890b986b16a4 | 1374 | _xi-=_speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1375 | } |
AhmedPlaymaker | 18:b391caa5754c | 1376 | if ((_xi < _xj)&&(b10 == 1)&&(b9 == 1)) { |
AhmedPlaymaker | 8:890b986b16a4 | 1377 | _xi+=_speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1378 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1379 | if(length > 11) { |
AhmedPlaymaker | 18:b391caa5754c | 1380 | if ((_xj > _xk)&&(b11 == 1)&&(b10 == 1)) { |
AhmedPlaymaker | 8:890b986b16a4 | 1381 | _xj-=_speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1382 | } |
AhmedPlaymaker | 18:b391caa5754c | 1383 | if ((_xj < _xk)&&(b11 == 1)&&(b10 == 1)) { |
AhmedPlaymaker | 8:890b986b16a4 | 1384 | _xj+=_speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1385 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1386 | if(length > 12) { |
AhmedPlaymaker | 18:b391caa5754c | 1387 | if ((_xk > _xl)&&(b12 == 1)&&(b11 == 1)) { |
AhmedPlaymaker | 8:890b986b16a4 | 1388 | _xk-=_speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1389 | } |
AhmedPlaymaker | 18:b391caa5754c | 1390 | if ((_xk < _xl)&&(b12 == 1)&&(b11 == 1)) { |
AhmedPlaymaker | 8:890b986b16a4 | 1391 | _xk+=_speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1392 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1393 | if(length > 13) { |
AhmedPlaymaker | 18:b391caa5754c | 1394 | if ((_xl > _xm)&&(b13 == 1)&&(b12 == 1)) { |
AhmedPlaymaker | 8:890b986b16a4 | 1395 | _xl-=_speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1396 | } |
AhmedPlaymaker | 18:b391caa5754c | 1397 | if ((_xl < _xm)&&(b13 == 1)&&(b12 == 1)) { |
AhmedPlaymaker | 8:890b986b16a4 | 1398 | _xl+=_speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1399 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1400 | if(length > 14) { |
AhmedPlaymaker | 18:b391caa5754c | 1401 | if ((_xm > _xn)&&(b14 == 1)&&(b13 == 1)) { |
AhmedPlaymaker | 8:890b986b16a4 | 1402 | _xm-=_speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1403 | } |
AhmedPlaymaker | 18:b391caa5754c | 1404 | if ((_xm < _xn)&&(b14 == 1)&&(b13 == 1)) { |
AhmedPlaymaker | 18:b391caa5754c | 1405 | _xm+=_speed; |
AhmedPlaymaker | 18:b391caa5754c | 1406 | |
AhmedPlaymaker | 8:890b986b16a4 | 1407 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1408 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1409 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1410 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1411 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1412 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1413 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1414 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1415 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1416 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1417 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1418 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1419 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1420 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1421 | } |
AhmedPlaymaker | 18:b391caa5754c | 1422 | if((length == 15)&&(b14 == 1)) { |
AhmedPlaymaker | 8:890b986b16a4 | 1423 | if (d == E) { |
AhmedPlaymaker | 8:890b986b16a4 | 1424 | _xn+= _speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1425 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1426 | if (d == W) { |
AhmedPlaymaker | 8:890b986b16a4 | 1427 | _xn-= _speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1428 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1429 | } |
AhmedPlaymaker | 18:b391caa5754c | 1430 | if((length == 14)&&(b13 == 1)) { |
AhmedPlaymaker | 8:890b986b16a4 | 1431 | if (d == E) { |
AhmedPlaymaker | 8:890b986b16a4 | 1432 | _xm+= _speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1433 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1434 | if (d == W) { |
AhmedPlaymaker | 8:890b986b16a4 | 1435 | _xm-= _speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1436 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1437 | } |
AhmedPlaymaker | 18:b391caa5754c | 1438 | if((length == 13)&&(b12 == 1)) { |
AhmedPlaymaker | 8:890b986b16a4 | 1439 | if (d == E) { |
AhmedPlaymaker | 8:890b986b16a4 | 1440 | _xl+= _speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1441 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1442 | if (d == W) { |
AhmedPlaymaker | 8:890b986b16a4 | 1443 | _xl-= _speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1444 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1445 | } |
AhmedPlaymaker | 18:b391caa5754c | 1446 | if((length == 12)&&(b11 == 1)) { |
AhmedPlaymaker | 8:890b986b16a4 | 1447 | if (d == E) { |
AhmedPlaymaker | 8:890b986b16a4 | 1448 | _xk+= _speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1449 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1450 | if (d == W) { |
AhmedPlaymaker | 8:890b986b16a4 | 1451 | _xk-= _speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1452 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1453 | } |
AhmedPlaymaker | 18:b391caa5754c | 1454 | if((length == 11)&&(b10 == 1)) { |
AhmedPlaymaker | 8:890b986b16a4 | 1455 | if (d == E) { |
AhmedPlaymaker | 8:890b986b16a4 | 1456 | _xj+= _speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1457 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1458 | if (d == W) { |
AhmedPlaymaker | 8:890b986b16a4 | 1459 | _xj-= _speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1460 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1461 | } |
AhmedPlaymaker | 18:b391caa5754c | 1462 | if((length == 10)&&(b9 == 1)) { |
AhmedPlaymaker | 8:890b986b16a4 | 1463 | if (d == E) { |
AhmedPlaymaker | 8:890b986b16a4 | 1464 | _xi+= _speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1465 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1466 | if (d == W) { |
AhmedPlaymaker | 8:890b986b16a4 | 1467 | _xi-= _speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1468 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1469 | } |
AhmedPlaymaker | 18:b391caa5754c | 1470 | if((length == 9)&&(b8 == 1)) { |
AhmedPlaymaker | 8:890b986b16a4 | 1471 | if (d == E) { |
AhmedPlaymaker | 8:890b986b16a4 | 1472 | _xh+= _speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1473 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1474 | if (d == W) { |
AhmedPlaymaker | 8:890b986b16a4 | 1475 | _xh-= _speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1476 | } |
AhmedPlaymaker | 7:48ba87cd79b5 | 1477 | } |
AhmedPlaymaker | 18:b391caa5754c | 1478 | if((length == 8)&&(b7 == 1)) { |
AhmedPlaymaker | 8:890b986b16a4 | 1479 | if (d == E) { |
AhmedPlaymaker | 8:890b986b16a4 | 1480 | _xg+= _speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1481 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1482 | if (d == W) { |
AhmedPlaymaker | 8:890b986b16a4 | 1483 | _xg-= _speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1484 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1485 | } |
AhmedPlaymaker | 18:b391caa5754c | 1486 | if((length == 7)&&(b6 == 1)) { |
AhmedPlaymaker | 8:890b986b16a4 | 1487 | if (d == E) { |
AhmedPlaymaker | 8:890b986b16a4 | 1488 | _xf+= _speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1489 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1490 | if (d == W) { |
AhmedPlaymaker | 8:890b986b16a4 | 1491 | _xf-= _speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1492 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1493 | } |
AhmedPlaymaker | 18:b391caa5754c | 1494 | if((length == 6)&&(b5 == 1)) { |
AhmedPlaymaker | 8:890b986b16a4 | 1495 | if (d == E) { |
AhmedPlaymaker | 8:890b986b16a4 | 1496 | _xe+= _speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1497 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1498 | if (d == W) { |
AhmedPlaymaker | 8:890b986b16a4 | 1499 | _xe-= _speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1500 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1501 | } |
AhmedPlaymaker | 18:b391caa5754c | 1502 | if((length == 5)&&(b4 == 1)) { |
AhmedPlaymaker | 8:890b986b16a4 | 1503 | if (d == E) { |
AhmedPlaymaker | 8:890b986b16a4 | 1504 | _xd+= _speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1505 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1506 | if (d == W) { |
AhmedPlaymaker | 8:890b986b16a4 | 1507 | _xd-= _speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1508 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1509 | } |
AhmedPlaymaker | 18:b391caa5754c | 1510 | if((length == 4)&&(b3 == 1)) { |
AhmedPlaymaker | 8:890b986b16a4 | 1511 | if (d == E) { |
AhmedPlaymaker | 8:890b986b16a4 | 1512 | _xc+= _speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1513 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1514 | if (d == W) { |
AhmedPlaymaker | 8:890b986b16a4 | 1515 | _xc-= _speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1516 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1517 | } |
AhmedPlaymaker | 18:b391caa5754c | 1518 | if((length == 3)&&(b2 == 1)) { |
AhmedPlaymaker | 8:890b986b16a4 | 1519 | if (d == E) { |
AhmedPlaymaker | 8:890b986b16a4 | 1520 | _xb+= _speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1521 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1522 | if (d == W) { |
AhmedPlaymaker | 8:890b986b16a4 | 1523 | _xb-= _speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1524 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1525 | } |
AhmedPlaymaker | 18:b391caa5754c | 1526 | if((length == 2)&&(b1 == 1)) { |
AhmedPlaymaker | 8:890b986b16a4 | 1527 | if (d == E) { |
AhmedPlaymaker | 8:890b986b16a4 | 1528 | _xa+= _speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1529 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1530 | if (d == W) { |
AhmedPlaymaker | 8:890b986b16a4 | 1531 | _xa-= _speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1532 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1533 | } |
AhmedPlaymaker | 18:b391caa5754c | 1534 | if((length == 1)&&(b0 == 1)) { |
AhmedPlaymaker | 8:890b986b16a4 | 1535 | if (d == E) { |
AhmedPlaymaker | 8:890b986b16a4 | 1536 | _x+= _speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1537 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1538 | if (d == W) { |
AhmedPlaymaker | 8:890b986b16a4 | 1539 | _x-= _speed; |
AhmedPlaymaker | 8:890b986b16a4 | 1540 | } |
AhmedPlaymaker | 7:48ba87cd79b5 | 1541 | } |
AhmedPlaymaker | 7:48ba87cd79b5 | 1542 | |
AhmedPlaymaker | 9:d1d79d4ee673 | 1543 | // the following makes sure that when the length is increased, the snake stays where it was when it ate food. |
AhmedPlaymaker | 7:48ba87cd79b5 | 1544 | |
AhmedPlaymaker | 9:d1d79d4ee673 | 1545 | if(length < 2) { |
AhmedPlaymaker | 9:d1d79d4ee673 | 1546 | _xa = _x; |
AhmedPlaymaker | 9:d1d79d4ee673 | 1547 | } |
AhmedPlaymaker | 9:d1d79d4ee673 | 1548 | else if(length < 3) { |
AhmedPlaymaker | 9:d1d79d4ee673 | 1549 | _xb = _xa; |
AhmedPlaymaker | 9:d1d79d4ee673 | 1550 | } |
AhmedPlaymaker | 9:d1d79d4ee673 | 1551 | else if(length < 4) { |
AhmedPlaymaker | 9:d1d79d4ee673 | 1552 | _xc = _xb; |
AhmedPlaymaker | 9:d1d79d4ee673 | 1553 | } |
AhmedPlaymaker | 9:d1d79d4ee673 | 1554 | else if(length < 5) { |
AhmedPlaymaker | 9:d1d79d4ee673 | 1555 | _xd = _xc; |
AhmedPlaymaker | 9:d1d79d4ee673 | 1556 | } |
AhmedPlaymaker | 9:d1d79d4ee673 | 1557 | else if(length < 6) { |
AhmedPlaymaker | 9:d1d79d4ee673 | 1558 | _xe = _xd; |
AhmedPlaymaker | 9:d1d79d4ee673 | 1559 | } |
AhmedPlaymaker | 9:d1d79d4ee673 | 1560 | else if(length < 7) { |
AhmedPlaymaker | 9:d1d79d4ee673 | 1561 | _xf = _xe; |
AhmedPlaymaker | 9:d1d79d4ee673 | 1562 | } |
AhmedPlaymaker | 9:d1d79d4ee673 | 1563 | else if(length < 8) { |
AhmedPlaymaker | 9:d1d79d4ee673 | 1564 | _xg = _xf; |
AhmedPlaymaker | 9:d1d79d4ee673 | 1565 | } |
AhmedPlaymaker | 9:d1d79d4ee673 | 1566 | else if(length < 9) { |
AhmedPlaymaker | 9:d1d79d4ee673 | 1567 | _xh = _xg; |
AhmedPlaymaker | 9:d1d79d4ee673 | 1568 | } |
AhmedPlaymaker | 9:d1d79d4ee673 | 1569 | else if(length < 10) { |
AhmedPlaymaker | 9:d1d79d4ee673 | 1570 | _xi = _xh; |
AhmedPlaymaker | 9:d1d79d4ee673 | 1571 | } |
AhmedPlaymaker | 18:b391caa5754c | 1572 | else if(length < 11) { |
AhmedPlaymaker | 9:d1d79d4ee673 | 1573 | _xj = _xi; |
AhmedPlaymaker | 9:d1d79d4ee673 | 1574 | } |
AhmedPlaymaker | 9:d1d79d4ee673 | 1575 | else if(length < 12) { |
AhmedPlaymaker | 9:d1d79d4ee673 | 1576 | _xk = _xj; |
AhmedPlaymaker | 9:d1d79d4ee673 | 1577 | } |
AhmedPlaymaker | 9:d1d79d4ee673 | 1578 | else if(length < 13) { |
AhmedPlaymaker | 9:d1d79d4ee673 | 1579 | _xl = _xk; |
AhmedPlaymaker | 9:d1d79d4ee673 | 1580 | } |
AhmedPlaymaker | 9:d1d79d4ee673 | 1581 | else if(length < 14) { |
AhmedPlaymaker | 9:d1d79d4ee673 | 1582 | _xm = _xl; |
AhmedPlaymaker | 9:d1d79d4ee673 | 1583 | } |
AhmedPlaymaker | 9:d1d79d4ee673 | 1584 | else if(length < 15) { |
AhmedPlaymaker | 9:d1d79d4ee673 | 1585 | _xn = _xm; |
AhmedPlaymaker | 9:d1d79d4ee673 | 1586 | } |
AhmedPlaymaker | 9:d1d79d4ee673 | 1587 | |
AhmedPlaymaker | 7:48ba87cd79b5 | 1588 | //Limits set so that the sprite does not travel off the screen. |
AhmedPlaymaker | 7:48ba87cd79b5 | 1589 | if (_y <= 0) { |
AhmedPlaymaker | 7:48ba87cd79b5 | 1590 | _y = 0; |
AhmedPlaymaker | 7:48ba87cd79b5 | 1591 | } |
AhmedPlaymaker | 7:48ba87cd79b5 | 1592 | if (_x <= 0) { |
AhmedPlaymaker | 7:48ba87cd79b5 | 1593 | _x = 0; |
AhmedPlaymaker | 7:48ba87cd79b5 | 1594 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1595 | if (_xa <= 0) { |
AhmedPlaymaker | 8:890b986b16a4 | 1596 | _xa = 0; |
AhmedPlaymaker | 8:890b986b16a4 | 1597 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1598 | if (_xb <= 0) { |
AhmedPlaymaker | 8:890b986b16a4 | 1599 | _xb = 0; |
AhmedPlaymaker | 8:890b986b16a4 | 1600 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1601 | if (_xc <= 0) { |
AhmedPlaymaker | 8:890b986b16a4 | 1602 | _xc = 0; |
AhmedPlaymaker | 8:890b986b16a4 | 1603 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1604 | if (_xd <= 0) { |
AhmedPlaymaker | 8:890b986b16a4 | 1605 | _xd = 0; |
AhmedPlaymaker | 8:890b986b16a4 | 1606 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1607 | if (_xe <= 0) { |
AhmedPlaymaker | 8:890b986b16a4 | 1608 | _xe = 0; |
AhmedPlaymaker | 8:890b986b16a4 | 1609 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1610 | if (_xf <= 0) { |
AhmedPlaymaker | 8:890b986b16a4 | 1611 | _xf = 0; |
AhmedPlaymaker | 8:890b986b16a4 | 1612 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1613 | if (_xg <= 0) { |
AhmedPlaymaker | 8:890b986b16a4 | 1614 | _xg = 0; |
AhmedPlaymaker | 8:890b986b16a4 | 1615 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1616 | if (_xh <= 0) { |
AhmedPlaymaker | 8:890b986b16a4 | 1617 | _xh = 0; |
AhmedPlaymaker | 8:890b986b16a4 | 1618 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1619 | if (_xi <= 0) { |
AhmedPlaymaker | 8:890b986b16a4 | 1620 | _xi = 0; |
AhmedPlaymaker | 8:890b986b16a4 | 1621 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1622 | if (_xj <= 0) { |
AhmedPlaymaker | 8:890b986b16a4 | 1623 | _xj = 0; |
AhmedPlaymaker | 8:890b986b16a4 | 1624 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1625 | if (_xk <= 0) { |
AhmedPlaymaker | 8:890b986b16a4 | 1626 | _xk = 0; |
AhmedPlaymaker | 8:890b986b16a4 | 1627 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1628 | if (_xl <= 0) { |
AhmedPlaymaker | 8:890b986b16a4 | 1629 | _xl = 0; |
AhmedPlaymaker | 8:890b986b16a4 | 1630 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1631 | if (_xm <= 0) { |
AhmedPlaymaker | 8:890b986b16a4 | 1632 | _xm = 0; |
AhmedPlaymaker | 8:890b986b16a4 | 1633 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1634 | if (_xn <= 0) { |
AhmedPlaymaker | 8:890b986b16a4 | 1635 | _xn = 0; |
AhmedPlaymaker | 7:48ba87cd79b5 | 1636 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1637 | if (_x > 81) { |
AhmedPlaymaker | 8:890b986b16a4 | 1638 | _x = 81; |
AhmedPlaymaker | 8:890b986b16a4 | 1639 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1640 | if (_xa > 81) { |
AhmedPlaymaker | 8:890b986b16a4 | 1641 | _xa = 81; |
AhmedPlaymaker | 8:890b986b16a4 | 1642 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1643 | if (_xb > 81) { |
AhmedPlaymaker | 8:890b986b16a4 | 1644 | _xb = 81; |
AhmedPlaymaker | 8:890b986b16a4 | 1645 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1646 | if (_xc > 81) { |
AhmedPlaymaker | 8:890b986b16a4 | 1647 | _xc = 81; |
AhmedPlaymaker | 8:890b986b16a4 | 1648 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1649 | if (_xd > 81) { |
AhmedPlaymaker | 8:890b986b16a4 | 1650 | _xd = 81; |
AhmedPlaymaker | 8:890b986b16a4 | 1651 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1652 | if (_xe > 81) { |
AhmedPlaymaker | 8:890b986b16a4 | 1653 | _xe = 81; |
AhmedPlaymaker | 8:890b986b16a4 | 1654 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1655 | if (_xf > 81) { |
AhmedPlaymaker | 8:890b986b16a4 | 1656 | _xf = 81; |
AhmedPlaymaker | 7:48ba87cd79b5 | 1657 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1658 | if (_xg > 81) { |
AhmedPlaymaker | 8:890b986b16a4 | 1659 | _xg = 81; |
AhmedPlaymaker | 8:890b986b16a4 | 1660 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1661 | if (_xh > 81) { |
AhmedPlaymaker | 8:890b986b16a4 | 1662 | _xh = 81; |
AhmedPlaymaker | 8:890b986b16a4 | 1663 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1664 | if (_xi > 81) { |
AhmedPlaymaker | 8:890b986b16a4 | 1665 | _xi = 81; |
AhmedPlaymaker | 8:890b986b16a4 | 1666 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1667 | if (_xj > 81) { |
AhmedPlaymaker | 8:890b986b16a4 | 1668 | _xj = 81; |
AhmedPlaymaker | 8:890b986b16a4 | 1669 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1670 | if (_xk > 81) { |
AhmedPlaymaker | 8:890b986b16a4 | 1671 | _xk = 81; |
AhmedPlaymaker | 8:890b986b16a4 | 1672 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1673 | if (_xl > 81) { |
AhmedPlaymaker | 8:890b986b16a4 | 1674 | _xl = 81; |
AhmedPlaymaker | 8:890b986b16a4 | 1675 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1676 | if (_xm > 81) { |
AhmedPlaymaker | 8:890b986b16a4 | 1677 | _xm = 81; |
AhmedPlaymaker | 8:890b986b16a4 | 1678 | } |
AhmedPlaymaker | 8:890b986b16a4 | 1679 | if (_xn > 81) { |
AhmedPlaymaker | 8:890b986b16a4 | 1680 | _xn = 81; |
AhmedPlaymaker | 8:890b986b16a4 | 1681 | } |
AhmedPlaymaker | 7:48ba87cd79b5 | 1682 | } |
AhmedPlaymaker | 7:48ba87cd79b5 | 1683 |