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