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