Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Cricket/Cricket.cpp@16:da0808d55de0, 2019-04-27 (annotated)
- Committer:
- shahidsajid
- Date:
- Sat Apr 27 11:45:11 2019 +0000
- Revision:
- 16:da0808d55de0
- Parent:
- 15:81a3aaf52647
Created A game over function
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
shahidsajid | 10:6c6e09023942 | 1 | #include "Cricket.h" |
shahidsajid | 10:6c6e09023942 | 2 | |
shahidsajid | 10:6c6e09023942 | 3 | |
shahidsajid | 10:6c6e09023942 | 4 | Cricket::Cricket() |
shahidsajid | 10:6c6e09023942 | 5 | { |
shahidsajid | 10:6c6e09023942 | 6 | |
shahidsajid | 10:6c6e09023942 | 7 | } |
shahidsajid | 10:6c6e09023942 | 8 | |
shahidsajid | 10:6c6e09023942 | 9 | Cricket::~Cricket() |
shahidsajid | 10:6c6e09023942 | 10 | { |
shahidsajid | 10:6c6e09023942 | 11 | |
shahidsajid | 10:6c6e09023942 | 12 | } |
shahidsajid | 10:6c6e09023942 | 13 | |
shahidsajid | 10:6c6e09023942 | 14 | void Cricket::init() |
shahidsajid | 10:6c6e09023942 | 15 | { |
shahidsajid | 10:6c6e09023942 | 16 | bat.init(4,5); |
shahidsajid | 10:6c6e09023942 | 17 | ball.init(2,3); |
shahidsajid | 14:122eaa3b7a50 | 18 | scoreboard.init(); |
shahidsajid | 12:954da4f4e565 | 19 | //float f; |
shahidsajid | 14:122eaa3b7a50 | 20 | new_round=1; |
shahidsajid | 12:954da4f4e565 | 21 | direction_set=0; |
shahidsajid | 12:954da4f4e565 | 22 | fieldersCount=0; |
shahidsajid | 12:954da4f4e565 | 23 | init_field_counter=0; |
shahidsajid | 12:954da4f4e565 | 24 | init_positions(); |
shahidsajid | 12:954da4f4e565 | 25 | fielder_no=-1; |
shahidsajid | 12:954da4f4e565 | 26 | check_bowled=0; |
shahidsajid | 15:81a3aaf52647 | 27 | check_hit=0; |
shahidsajid | 15:81a3aaf52647 | 28 | loft_check=0; |
shahidsajid | 13:924891519a95 | 29 | outfield_fielder=-1; |
shahidsajid | 15:81a3aaf52647 | 30 | check_update=-1; |
shahidsajid | 13:924891519a95 | 31 | } |
shahidsajid | 13:924891519a95 | 32 | void Cricket::reset(){ |
shahidsajid | 14:122eaa3b7a50 | 33 | ball.reset(); |
shahidsajid | 14:122eaa3b7a50 | 34 | bat.reset(); |
shahidsajid | 14:122eaa3b7a50 | 35 | new_round=0; |
shahidsajid | 13:924891519a95 | 36 | direction_set=0; |
shahidsajid | 13:924891519a95 | 37 | fieldersCount=0; |
shahidsajid | 15:81a3aaf52647 | 38 | loft_check=0; |
shahidsajid | 15:81a3aaf52647 | 39 | check_hit=0; |
shahidsajid | 15:81a3aaf52647 | 40 | ballHit=0; |
shahidsajid | 13:924891519a95 | 41 | init_field_counter=0; |
shahidsajid | 13:924891519a95 | 42 | init_positions(); |
shahidsajid | 13:924891519a95 | 43 | fielder_no=-1; |
shahidsajid | 13:924891519a95 | 44 | check_bowled=0; |
shahidsajid | 14:122eaa3b7a50 | 45 | outfield_fielder=-1; |
shahidsajid | 15:81a3aaf52647 | 46 | check_update=-1; |
shahidsajid | 13:924891519a95 | 47 | |
shahidsajid | 10:6c6e09023942 | 48 | } |
shahidsajid | 11:f481ec642cc5 | 49 | void Cricket::game(N5110 &lcd,Gamepad &pad){ |
shahidsajid | 14:122eaa3b7a50 | 50 | if (new_round==1){ |
shahidsajid | 15:81a3aaf52647 | 51 | pad.leds_off(); |
shahidsajid | 14:122eaa3b7a50 | 52 | reset(); |
shahidsajid | 10:6c6e09023942 | 53 | set_field(lcd); |
shahidsajid | 11:f481ec642cc5 | 54 | play_game(lcd,pad); |
shahidsajid | 14:122eaa3b7a50 | 55 | new_round=0; |
shahidsajid | 13:924891519a95 | 56 | } |
shahidsajid | 13:924891519a95 | 57 | else |
shahidsajid | 13:924891519a95 | 58 | { |
shahidsajid | 13:924891519a95 | 59 | play_game(lcd,pad); |
shahidsajid | 13:924891519a95 | 60 | } |
shahidsajid | 12:954da4f4e565 | 61 | |
shahidsajid | 10:6c6e09023942 | 62 | |
shahidsajid | 10:6c6e09023942 | 63 | } |
shahidsajid | 12:954da4f4e565 | 64 | void Cricket::init_positions(){ |
shahidsajid | 15:81a3aaf52647 | 65 | set_init_positions(42,1,N,1); |
shahidsajid | 15:81a3aaf52647 | 66 | set_init_positions(84,30,E,2); |
shahidsajid | 15:81a3aaf52647 | 67 | set_init_positions(0,30,W,3); |
shahidsajid | 15:81a3aaf52647 | 68 | set_init_positions(2,44,SW,4); |
shahidsajid | 15:81a3aaf52647 | 69 | set_init_positions(0,2,NW,5); |
shahidsajid | 15:81a3aaf52647 | 70 | set_init_positions(84,1,NE,6); |
shahidsajid | 15:81a3aaf52647 | 71 | set_init_positions(60,44,SE,7); |
shahidsajid | 12:954da4f4e565 | 72 | } |
shahidsajid | 12:954da4f4e565 | 73 | void Cricket::set_init_positions(int x,int y, Direction direction,int no){ |
shahidsajid | 12:954da4f4e565 | 74 | positions[init_field_counter].x=x; |
shahidsajid | 12:954da4f4e565 | 75 | positions[init_field_counter].y=y; |
shahidsajid | 12:954da4f4e565 | 76 | positions[init_field_counter].dir=direction; |
shahidsajid | 12:954da4f4e565 | 77 | positions[init_field_counter].no=no; |
shahidsajid | 12:954da4f4e565 | 78 | init_field_counter++; |
shahidsajid | 12:954da4f4e565 | 79 | } |
shahidsajid | 11:f481ec642cc5 | 80 | void Cricket::play_game(N5110 &lcd,Gamepad &pad){ |
shahidsajid | 15:81a3aaf52647 | 81 | check_hit=bat.get_hitBall(); |
shahidsajid | 15:81a3aaf52647 | 82 | loft_check=bat.get_loft_ball(); |
shahidsajid | 12:954da4f4e565 | 83 | Direction dir=pad.get_direction(); |
shahidsajid | 12:954da4f4e565 | 84 | if (check_bowled!=1){ |
shahidsajid | 15:81a3aaf52647 | 85 | check_bowled=ball.ball_start(pad); |
shahidsajid | 12:954da4f4e565 | 86 | } |
shahidsajid | 12:954da4f4e565 | 87 | else{ |
shahidsajid | 15:81a3aaf52647 | 88 | update_game(check_hit, loft_check, dir,pad); |
shahidsajid | 12:954da4f4e565 | 89 | } |
shahidsajid | 11:f481ec642cc5 | 90 | } |
shahidsajid | 15:81a3aaf52647 | 91 | void Cricket::update_game(int checkHit,int loft_check, Direction dir,Gamepad &pad){ |
shahidsajid | 13:924891519a95 | 92 | set_ball_direction(dir); |
shahidsajid | 13:924891519a95 | 93 | int fielder_check=check_fielder(ball_direction); |
shahidsajid | 15:81a3aaf52647 | 94 | if (checkHit!=1) |
shahidsajid | 15:81a3aaf52647 | 95 | batsman_out("bowled",pad); |
shahidsajid | 15:81a3aaf52647 | 96 | if(direction_set==1 && checkHit==1){ |
shahidsajid | 13:924891519a95 | 97 | if (fielder_check!=-1){ |
shahidsajid | 15:81a3aaf52647 | 98 | int check_update=ball.update_ball(field[fielder_check].x,field[fielder_check].y); |
shahidsajid | 15:81a3aaf52647 | 99 | printf("Location x %i y %i\n",field[fielder_check].x,field[fielder_check].y); |
shahidsajid | 15:81a3aaf52647 | 100 | if (loft_check==1){ |
shahidsajid | 15:81a3aaf52647 | 101 | if (check_update==1) |
shahidsajid | 15:81a3aaf52647 | 102 | batsman_out("Caught",pad); |
shahidsajid | 13:924891519a95 | 103 | } |
shahidsajid | 15:81a3aaf52647 | 104 | else |
shahidsajid | 15:81a3aaf52647 | 105 | update_scoreboard(check_update,field[fielder_check].position+1,pad); |
shahidsajid | 13:924891519a95 | 106 | } |
shahidsajid | 13:924891519a95 | 107 | if (fielder_check==-1){ |
shahidsajid | 14:122eaa3b7a50 | 108 | check_update=ball.update_ball(positions[fielder_no].x,positions[fielder_no].y); |
shahidsajid | 15:81a3aaf52647 | 109 | |
shahidsajid | 15:81a3aaf52647 | 110 | // /printf("location x %i y %i\n update %i\n",positions[fielder_no].x,positions[fielder_no].y,check_update); |
shahidsajid | 15:81a3aaf52647 | 111 | printf("update %i\n",check_update); |
shahidsajid | 15:81a3aaf52647 | 112 | if (loft_check==1) |
shahidsajid | 15:81a3aaf52647 | 113 | update_scoreboard(check_update,6,pad); |
shahidsajid | 15:81a3aaf52647 | 114 | else |
shahidsajid | 15:81a3aaf52647 | 115 | update_scoreboard(check_update,4,pad); |
shahidsajid | 13:924891519a95 | 116 | } |
shahidsajid | 15:81a3aaf52647 | 117 | } |
shahidsajid | 15:81a3aaf52647 | 118 | } |
shahidsajid | 15:81a3aaf52647 | 119 | void Cricket::update_scoreboard(int checkUpdate, int runs,Gamepad &pad){ |
shahidsajid | 15:81a3aaf52647 | 120 | printf("enter check"); |
shahidsajid | 15:81a3aaf52647 | 121 | if (checkUpdate==1){ |
shahidsajid | 15:81a3aaf52647 | 122 | scoreboard.update_score(runs); |
shahidsajid | 15:81a3aaf52647 | 123 | pad.led(3,1.0); |
shahidsajid | 15:81a3aaf52647 | 124 | wait(0.5); |
shahidsajid | 14:122eaa3b7a50 | 125 | new_round=1; |
shahidsajid | 14:122eaa3b7a50 | 126 | } |
shahidsajid | 13:924891519a95 | 127 | } |
shahidsajid | 15:81a3aaf52647 | 128 | void Cricket::batsman_out(string message,Gamepad &pad){ |
shahidsajid | 15:81a3aaf52647 | 129 | scoreboard.reset(); |
shahidsajid | 15:81a3aaf52647 | 130 | new_round=1; |
shahidsajid | 15:81a3aaf52647 | 131 | pad.led(1,1.0); |
shahidsajid | 16:da0808d55de0 | 132 | //pad.tone(750.0,0.5); |
shahidsajid | 15:81a3aaf52647 | 133 | wait(2); |
shahidsajid | 15:81a3aaf52647 | 134 | } |
shahidsajid | 13:924891519a95 | 135 | void Cricket::draw(N5110 &lcd){ |
shahidsajid | 13:924891519a95 | 136 | lcd.drawCircle((WIDTH/2),HEIGHT/2,23,FILL_TRANSPARENT); |
shahidsajid | 13:924891519a95 | 137 | lcd.drawRect(37,11,12,30,FILL_TRANSPARENT); |
shahidsajid | 13:924891519a95 | 138 | ball.draw(lcd); |
shahidsajid | 13:924891519a95 | 139 | draw_field(lcd); |
shahidsajid | 13:924891519a95 | 140 | bat.draw(lcd); |
shahidsajid | 14:122eaa3b7a50 | 141 | scoreboard.draw(lcd); |
shahidsajid | 13:924891519a95 | 142 | } |
shahidsajid | 13:924891519a95 | 143 | void Cricket::set_ball_direction(Direction dir){ |
shahidsajid | 13:924891519a95 | 144 | if (direction_set!=1){ |
shahidsajid | 15:81a3aaf52647 | 145 | for (int i=0;i<init_field_counter+1;i++){ |
shahidsajid | 12:954da4f4e565 | 146 | if(dir==positions[i].dir){ |
shahidsajid | 12:954da4f4e565 | 147 | ball_direction=dir; |
shahidsajid | 15:81a3aaf52647 | 148 | printf(" BALL DIRECTION %i x %i y %i \n",positions[i].no,positions[i].x,positions[i].y); |
shahidsajid | 12:954da4f4e565 | 149 | fielder_no=i; |
shahidsajid | 12:954da4f4e565 | 150 | direction_set=1; |
shahidsajid | 12:954da4f4e565 | 151 | break; |
shahidsajid | 12:954da4f4e565 | 152 | } |
shahidsajid | 12:954da4f4e565 | 153 | } |
shahidsajid | 12:954da4f4e565 | 154 | } |
shahidsajid | 13:924891519a95 | 155 | } |
shahidsajid | 13:924891519a95 | 156 | int Cricket::check_fielder(Direction dir){ |
shahidsajid | 13:924891519a95 | 157 | Vector2D p; |
shahidsajid | 15:81a3aaf52647 | 158 | //if (dir==N){ |
shahidsajid | 15:81a3aaf52647 | 159 | // return -1; |
shahidsajid | 15:81a3aaf52647 | 160 | // } |
shahidsajid | 15:81a3aaf52647 | 161 | for (int i=0;i<8;i++){ |
shahidsajid | 13:924891519a95 | 162 | if(dir == field[i].dir){ |
shahidsajid | 13:924891519a95 | 163 | return i; |
shahidsajid | 13:924891519a95 | 164 | } |
shahidsajid | 13:924891519a95 | 165 | } |
shahidsajid | 13:924891519a95 | 166 | return -1; |
shahidsajid | 10:6c6e09023942 | 167 | } |
shahidsajid | 10:6c6e09023942 | 168 | void Cricket::draw_field(N5110 &lcd){ |
shahidsajid | 13:924891519a95 | 169 | lcd.drawCircle(field[0].x,field[0].y,2,FILL_TRANSPARENT); |
shahidsajid | 13:924891519a95 | 170 | lcd.drawCircle(field[1].x,field[1].y,2,FILL_TRANSPARENT); |
shahidsajid | 13:924891519a95 | 171 | lcd.drawCircle(field[2].x,field[2].y,2,FILL_TRANSPARENT); |
shahidsajid | 13:924891519a95 | 172 | lcd.drawCircle(field[3].x,field[3].y,2,FILL_TRANSPARENT); |
shahidsajid | 14:122eaa3b7a50 | 173 | lcd.drawCircle(field[4].x,field[4].y,2,FILL_TRANSPARENT); |
shahidsajid | 10:6c6e09023942 | 174 | } |
shahidsajid | 10:6c6e09023942 | 175 | void Cricket::set_field(N5110 &lcd){ |
shahidsajid | 10:6c6e09023942 | 176 | int d=0; |
shahidsajid | 10:6c6e09023942 | 177 | int pos=0; |
shahidsajid | 10:6c6e09023942 | 178 | int i=0; |
shahidsajid | 10:6c6e09023942 | 179 | int continueCount=0; |
shahidsajid | 10:6c6e09023942 | 180 | srand(time(NULL)); |
shahidsajid | 10:6c6e09023942 | 181 | while (fieldersCount!=5){ |
shahidsajid | 10:6c6e09023942 | 182 | d = 1+ rand() % 6; |
shahidsajid | 10:6c6e09023942 | 183 | pos=rand()%2; |
shahidsajid | 10:6c6e09023942 | 184 | for (int j=0;j<10;j++){ |
shahidsajid | 10:6c6e09023942 | 185 | if (fieldNumbers[j]==d){ |
shahidsajid | 10:6c6e09023942 | 186 | continueCount=1; |
shahidsajid | 10:6c6e09023942 | 187 | } |
shahidsajid | 10:6c6e09023942 | 188 | } |
shahidsajid | 10:6c6e09023942 | 189 | if (continueCount==1){ |
shahidsajid | 10:6c6e09023942 | 190 | continueCount=0; |
shahidsajid | 10:6c6e09023942 | 191 | continue; |
shahidsajid | 10:6c6e09023942 | 192 | } |
shahidsajid | 10:6c6e09023942 | 193 | if (d==1){ //NW |
shahidsajid | 10:6c6e09023942 | 194 | if (pos==1){ |
shahidsajid | 10:6c6e09023942 | 195 | field[i].dir=NW; |
shahidsajid | 10:6c6e09023942 | 196 | field[i].x=30; |
shahidsajid | 10:6c6e09023942 | 197 | field[i].y=9; |
shahidsajid | 10:6c6e09023942 | 198 | field[i].position=1; |
shahidsajid | 10:6c6e09023942 | 199 | fieldNumbers[i]=d; |
shahidsajid | 10:6c6e09023942 | 200 | i++; |
shahidsajid | 10:6c6e09023942 | 201 | fieldersCount++; |
shahidsajid | 10:6c6e09023942 | 202 | } |
shahidsajid | 10:6c6e09023942 | 203 | else{ |
shahidsajid | 10:6c6e09023942 | 204 | field[i].dir=NW; |
shahidsajid | 10:6c6e09023942 | 205 | field[i].x=25; |
shahidsajid | 10:6c6e09023942 | 206 | field[i].y=2; |
shahidsajid | 10:6c6e09023942 | 207 | field[i].position=0; |
shahidsajid | 10:6c6e09023942 | 208 | fieldNumbers[i]=d; |
shahidsajid | 10:6c6e09023942 | 209 | i++; |
shahidsajid | 10:6c6e09023942 | 210 | fieldersCount++; |
shahidsajid | 10:6c6e09023942 | 211 | } |
shahidsajid | 10:6c6e09023942 | 212 | } |
shahidsajid | 10:6c6e09023942 | 213 | |
shahidsajid | 10:6c6e09023942 | 214 | |
shahidsajid | 10:6c6e09023942 | 215 | if (d==2){ //NE |
shahidsajid | 10:6c6e09023942 | 216 | if (pos==1){ |
shahidsajid | 10:6c6e09023942 | 217 | field[i].dir=NE; |
shahidsajid | 10:6c6e09023942 | 218 | field[i].x=55; |
shahidsajid | 10:6c6e09023942 | 219 | field[i].y=9; |
shahidsajid | 10:6c6e09023942 | 220 | field[i].position=1; |
shahidsajid | 10:6c6e09023942 | 221 | fieldNumbers[i]=d; |
shahidsajid | 10:6c6e09023942 | 222 | i++; |
shahidsajid | 10:6c6e09023942 | 223 | fieldersCount++; |
shahidsajid | 10:6c6e09023942 | 224 | } |
shahidsajid | 10:6c6e09023942 | 225 | else{ |
shahidsajid | 10:6c6e09023942 | 226 | field[i].dir=NE; |
shahidsajid | 10:6c6e09023942 | 227 | field[i].x=65; |
shahidsajid | 10:6c6e09023942 | 228 | field[i].y=2; |
shahidsajid | 10:6c6e09023942 | 229 | field[i].position=0; |
shahidsajid | 10:6c6e09023942 | 230 | fieldNumbers[i]=d; |
shahidsajid | 10:6c6e09023942 | 231 | i++; |
shahidsajid | 10:6c6e09023942 | 232 | fieldersCount++; |
shahidsajid | 10:6c6e09023942 | 233 | } |
shahidsajid | 10:6c6e09023942 | 234 | } |
shahidsajid | 10:6c6e09023942 | 235 | |
shahidsajid | 10:6c6e09023942 | 236 | |
shahidsajid | 10:6c6e09023942 | 237 | if (d==3){ //SW |
shahidsajid | 10:6c6e09023942 | 238 | if (pos==1){ |
shahidsajid | 10:6c6e09023942 | 239 | field[i].dir=SW; |
shahidsajid | 10:6c6e09023942 | 240 | field[i].x=33; |
shahidsajid | 10:6c6e09023942 | 241 | field[i].y=40; |
shahidsajid | 10:6c6e09023942 | 242 | field[i].position=1; |
shahidsajid | 10:6c6e09023942 | 243 | fieldNumbers[i]=d; |
shahidsajid | 10:6c6e09023942 | 244 | i++; |
shahidsajid | 10:6c6e09023942 | 245 | fieldersCount++; |
shahidsajid | 10:6c6e09023942 | 246 | } |
shahidsajid | 10:6c6e09023942 | 247 | |
shahidsajid | 10:6c6e09023942 | 248 | else{ |
shahidsajid | 10:6c6e09023942 | 249 | field[i].dir=SW; |
shahidsajid | 10:6c6e09023942 | 250 | field[i].x=25; |
shahidsajid | 10:6c6e09023942 | 251 | field[i].y=44; |
shahidsajid | 10:6c6e09023942 | 252 | field[i].position=0; |
shahidsajid | 10:6c6e09023942 | 253 | fieldNumbers[i]=d; |
shahidsajid | 10:6c6e09023942 | 254 | i++; |
shahidsajid | 10:6c6e09023942 | 255 | fieldersCount++; |
shahidsajid | 10:6c6e09023942 | 256 | } |
shahidsajid | 10:6c6e09023942 | 257 | } |
shahidsajid | 10:6c6e09023942 | 258 | |
shahidsajid | 10:6c6e09023942 | 259 | if (d==4){ //SE |
shahidsajid | 10:6c6e09023942 | 260 | if (pos==1){ |
shahidsajid | 10:6c6e09023942 | 261 | field[i].dir=SE; |
shahidsajid | 10:6c6e09023942 | 262 | field[i].x=55; |
shahidsajid | 10:6c6e09023942 | 263 | field[i].y=40; |
shahidsajid | 10:6c6e09023942 | 264 | field[i].position=1; |
shahidsajid | 10:6c6e09023942 | 265 | fieldNumbers[i]=d; |
shahidsajid | 10:6c6e09023942 | 266 | i++; |
shahidsajid | 10:6c6e09023942 | 267 | fieldersCount++; |
shahidsajid | 10:6c6e09023942 | 268 | } |
shahidsajid | 10:6c6e09023942 | 269 | else{ |
shahidsajid | 10:6c6e09023942 | 270 | field[i].dir=SE; |
shahidsajid | 10:6c6e09023942 | 271 | field[i].x=65; |
shahidsajid | 10:6c6e09023942 | 272 | field[i].y=44; |
shahidsajid | 10:6c6e09023942 | 273 | field[i].position=0; |
shahidsajid | 10:6c6e09023942 | 274 | fieldNumbers[i]=d; |
shahidsajid | 10:6c6e09023942 | 275 | i++; |
shahidsajid | 10:6c6e09023942 | 276 | fieldersCount++; |
shahidsajid | 10:6c6e09023942 | 277 | } |
shahidsajid | 10:6c6e09023942 | 278 | } |
shahidsajid | 10:6c6e09023942 | 279 | |
shahidsajid | 10:6c6e09023942 | 280 | if (d==5){ //W |
shahidsajid | 10:6c6e09023942 | 281 | if (pos==1){ |
shahidsajid | 10:6c6e09023942 | 282 | field[i].dir=W; |
shahidsajid | 10:6c6e09023942 | 283 | field[i].x=3; |
shahidsajid | 15:81a3aaf52647 | 284 | field[i].y=30; |
shahidsajid | 10:6c6e09023942 | 285 | field[i].position=1; |
shahidsajid | 10:6c6e09023942 | 286 | fieldNumbers[i]=d; |
shahidsajid | 10:6c6e09023942 | 287 | i++; |
shahidsajid | 10:6c6e09023942 | 288 | fieldersCount++; |
shahidsajid | 10:6c6e09023942 | 289 | } |
shahidsajid | 10:6c6e09023942 | 290 | else{ |
shahidsajid | 10:6c6e09023942 | 291 | field[i].dir=W; |
shahidsajid | 10:6c6e09023942 | 292 | field[i].x=25; |
shahidsajid | 15:81a3aaf52647 | 293 | field[i].y=30; |
shahidsajid | 10:6c6e09023942 | 294 | field[i].position=0; |
shahidsajid | 10:6c6e09023942 | 295 | fieldNumbers[i]=d; |
shahidsajid | 10:6c6e09023942 | 296 | i++; |
shahidsajid | 10:6c6e09023942 | 297 | fieldersCount++; |
shahidsajid | 10:6c6e09023942 | 298 | } |
shahidsajid | 13:924891519a95 | 299 | } |
shahidsajid | 10:6c6e09023942 | 300 | if (d==6){ //W |
shahidsajid | 10:6c6e09023942 | 301 | if (pos==1){ |
shahidsajid | 10:6c6e09023942 | 302 | field[i].dir=E; |
shahidsajid | 10:6c6e09023942 | 303 | field[i].x=80; |
shahidsajid | 15:81a3aaf52647 | 304 | field[i].y=30; |
shahidsajid | 10:6c6e09023942 | 305 | field[i].position=1; |
shahidsajid | 10:6c6e09023942 | 306 | fieldNumbers[i]=d; |
shahidsajid | 10:6c6e09023942 | 307 | i++; |
shahidsajid | 10:6c6e09023942 | 308 | fieldersCount++; |
shahidsajid | 10:6c6e09023942 | 309 | } |
shahidsajid | 10:6c6e09023942 | 310 | else{ |
shahidsajid | 10:6c6e09023942 | 311 | field[i].dir=E; |
shahidsajid | 15:81a3aaf52647 | 312 | field[i].x=60; |
shahidsajid | 15:81a3aaf52647 | 313 | field[i].y=30; |
shahidsajid | 15:81a3aaf52647 | 314 | field[i].position=0; |
shahidsajid | 10:6c6e09023942 | 315 | fieldNumbers[i]=d; |
shahidsajid | 10:6c6e09023942 | 316 | i++; |
shahidsajid | 10:6c6e09023942 | 317 | fieldersCount++; |
shahidsajid | 13:924891519a95 | 318 | } |
shahidsajid | 10:6c6e09023942 | 319 | } |
shahidsajid | 10:6c6e09023942 | 320 | } |
shahidsajid | 10:6c6e09023942 | 321 | |
shahidsajid | 10:6c6e09023942 | 322 | |
shahidsajid | 10:6c6e09023942 | 323 | } |