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@17:b2b651acffae, 2019-04-27 (annotated)
- Committer:
- shahidsajid
- Date:
- Sat Apr 27 14:09:21 2019 +0000
- Revision:
- 17:b2b651acffae
- Parent:
- 15:81a3aaf52647
created a Batting target method and ball_count method
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 | 17:b2b651acffae | 19 | _ball_limit=3; |
shahidsajid | 12:954da4f4e565 | 20 | //float f; |
shahidsajid | 14:122eaa3b7a50 | 21 | new_round=1; |
shahidsajid | 12:954da4f4e565 | 22 | direction_set=0; |
shahidsajid | 12:954da4f4e565 | 23 | fieldersCount=0; |
shahidsajid | 12:954da4f4e565 | 24 | init_field_counter=0; |
shahidsajid | 12:954da4f4e565 | 25 | init_positions(); |
shahidsajid | 17:b2b651acffae | 26 | new_game=1; |
shahidsajid | 12:954da4f4e565 | 27 | fielder_no=-1; |
shahidsajid | 12:954da4f4e565 | 28 | check_bowled=0; |
shahidsajid | 15:81a3aaf52647 | 29 | check_hit=0; |
shahidsajid | 15:81a3aaf52647 | 30 | loft_check=0; |
shahidsajid | 13:924891519a95 | 31 | outfield_fielder=-1; |
shahidsajid | 15:81a3aaf52647 | 32 | check_update=-1; |
shahidsajid | 13:924891519a95 | 33 | } |
shahidsajid | 13:924891519a95 | 34 | void Cricket::reset(){ |
shahidsajid | 14:122eaa3b7a50 | 35 | ball.reset(); |
shahidsajid | 14:122eaa3b7a50 | 36 | bat.reset(); |
shahidsajid | 14:122eaa3b7a50 | 37 | new_round=0; |
shahidsajid | 13:924891519a95 | 38 | direction_set=0; |
shahidsajid | 13:924891519a95 | 39 | fieldersCount=0; |
shahidsajid | 15:81a3aaf52647 | 40 | loft_check=0; |
shahidsajid | 15:81a3aaf52647 | 41 | check_hit=0; |
shahidsajid | 15:81a3aaf52647 | 42 | ballHit=0; |
shahidsajid | 13:924891519a95 | 43 | init_field_counter=0; |
shahidsajid | 13:924891519a95 | 44 | init_positions(); |
shahidsajid | 13:924891519a95 | 45 | fielder_no=-1; |
shahidsajid | 13:924891519a95 | 46 | check_bowled=0; |
shahidsajid | 14:122eaa3b7a50 | 47 | outfield_fielder=-1; |
shahidsajid | 15:81a3aaf52647 | 48 | check_update=-1; |
shahidsajid | 13:924891519a95 | 49 | |
shahidsajid | 10:6c6e09023942 | 50 | } |
shahidsajid | 11:f481ec642cc5 | 51 | void Cricket::game(N5110 &lcd,Gamepad &pad){ |
shahidsajid | 17:b2b651acffae | 52 | if (new_game==1){ |
shahidsajid | 17:b2b651acffae | 53 | //bat.first_menu(lcd); |
shahidsajid | 17:b2b651acffae | 54 | //bat.second_menu(lcd); |
shahidsajid | 17:b2b651acffae | 55 | new_game=0; |
shahidsajid | 17:b2b651acffae | 56 | scoreboard.generate_target(); |
shahidsajid | 17:b2b651acffae | 57 | } |
shahidsajid | 14:122eaa3b7a50 | 58 | if (new_round==1){ |
shahidsajid | 15:81a3aaf52647 | 59 | pad.leds_off(); |
shahidsajid | 17:b2b651acffae | 60 | check_victory(lcd); |
shahidsajid | 17:b2b651acffae | 61 | check_ball_count(lcd); |
shahidsajid | 14:122eaa3b7a50 | 62 | reset(); |
shahidsajid | 10:6c6e09023942 | 63 | set_field(lcd); |
shahidsajid | 11:f481ec642cc5 | 64 | play_game(lcd,pad); |
shahidsajid | 14:122eaa3b7a50 | 65 | new_round=0; |
shahidsajid | 13:924891519a95 | 66 | } |
shahidsajid | 13:924891519a95 | 67 | else |
shahidsajid | 13:924891519a95 | 68 | { |
shahidsajid | 17:b2b651acffae | 69 | check_victory(lcd); |
shahidsajid | 17:b2b651acffae | 70 | check_ball_count(lcd); |
shahidsajid | 13:924891519a95 | 71 | play_game(lcd,pad); |
shahidsajid | 13:924891519a95 | 72 | } |
shahidsajid | 17:b2b651acffae | 73 | |
shahidsajid | 10:6c6e09023942 | 74 | } |
shahidsajid | 12:954da4f4e565 | 75 | void Cricket::init_positions(){ |
shahidsajid | 15:81a3aaf52647 | 76 | set_init_positions(42,1,N,1); |
shahidsajid | 15:81a3aaf52647 | 77 | set_init_positions(84,30,E,2); |
shahidsajid | 15:81a3aaf52647 | 78 | set_init_positions(0,30,W,3); |
shahidsajid | 15:81a3aaf52647 | 79 | set_init_positions(2,44,SW,4); |
shahidsajid | 15:81a3aaf52647 | 80 | set_init_positions(0,2,NW,5); |
shahidsajid | 15:81a3aaf52647 | 81 | set_init_positions(84,1,NE,6); |
shahidsajid | 15:81a3aaf52647 | 82 | set_init_positions(60,44,SE,7); |
shahidsajid | 12:954da4f4e565 | 83 | } |
shahidsajid | 12:954da4f4e565 | 84 | void Cricket::set_init_positions(int x,int y, Direction direction,int no){ |
shahidsajid | 12:954da4f4e565 | 85 | positions[init_field_counter].x=x; |
shahidsajid | 12:954da4f4e565 | 86 | positions[init_field_counter].y=y; |
shahidsajid | 12:954da4f4e565 | 87 | positions[init_field_counter].dir=direction; |
shahidsajid | 12:954da4f4e565 | 88 | positions[init_field_counter].no=no; |
shahidsajid | 12:954da4f4e565 | 89 | init_field_counter++; |
shahidsajid | 12:954da4f4e565 | 90 | } |
shahidsajid | 11:f481ec642cc5 | 91 | void Cricket::play_game(N5110 &lcd,Gamepad &pad){ |
shahidsajid | 15:81a3aaf52647 | 92 | check_hit=bat.get_hitBall(); |
shahidsajid | 15:81a3aaf52647 | 93 | loft_check=bat.get_loft_ball(); |
shahidsajid | 12:954da4f4e565 | 94 | Direction dir=pad.get_direction(); |
shahidsajid | 12:954da4f4e565 | 95 | if (check_bowled!=1){ |
shahidsajid | 15:81a3aaf52647 | 96 | check_bowled=ball.ball_start(pad); |
shahidsajid | 12:954da4f4e565 | 97 | } |
shahidsajid | 12:954da4f4e565 | 98 | else{ |
shahidsajid | 15:81a3aaf52647 | 99 | update_game(check_hit, loft_check, dir,pad); |
shahidsajid | 12:954da4f4e565 | 100 | } |
shahidsajid | 11:f481ec642cc5 | 101 | } |
shahidsajid | 15:81a3aaf52647 | 102 | void Cricket::update_game(int checkHit,int loft_check, Direction dir,Gamepad &pad){ |
shahidsajid | 13:924891519a95 | 103 | set_ball_direction(dir); |
shahidsajid | 13:924891519a95 | 104 | int fielder_check=check_fielder(ball_direction); |
shahidsajid | 15:81a3aaf52647 | 105 | if (checkHit!=1) |
shahidsajid | 15:81a3aaf52647 | 106 | batsman_out("bowled",pad); |
shahidsajid | 15:81a3aaf52647 | 107 | if(direction_set==1 && checkHit==1){ |
shahidsajid | 13:924891519a95 | 108 | if (fielder_check!=-1){ |
shahidsajid | 15:81a3aaf52647 | 109 | int check_update=ball.update_ball(field[fielder_check].x,field[fielder_check].y); |
shahidsajid | 15:81a3aaf52647 | 110 | printf("Location x %i y %i\n",field[fielder_check].x,field[fielder_check].y); |
shahidsajid | 15:81a3aaf52647 | 111 | if (loft_check==1){ |
shahidsajid | 15:81a3aaf52647 | 112 | if (check_update==1) |
shahidsajid | 15:81a3aaf52647 | 113 | batsman_out("Caught",pad); |
shahidsajid | 13:924891519a95 | 114 | } |
shahidsajid | 15:81a3aaf52647 | 115 | else |
shahidsajid | 15:81a3aaf52647 | 116 | update_scoreboard(check_update,field[fielder_check].position+1,pad); |
shahidsajid | 13:924891519a95 | 117 | } |
shahidsajid | 13:924891519a95 | 118 | if (fielder_check==-1){ |
shahidsajid | 14:122eaa3b7a50 | 119 | check_update=ball.update_ball(positions[fielder_no].x,positions[fielder_no].y); |
shahidsajid | 15:81a3aaf52647 | 120 | |
shahidsajid | 15:81a3aaf52647 | 121 | // /printf("location x %i y %i\n update %i\n",positions[fielder_no].x,positions[fielder_no].y,check_update); |
shahidsajid | 15:81a3aaf52647 | 122 | printf("update %i\n",check_update); |
shahidsajid | 15:81a3aaf52647 | 123 | if (loft_check==1) |
shahidsajid | 15:81a3aaf52647 | 124 | update_scoreboard(check_update,6,pad); |
shahidsajid | 15:81a3aaf52647 | 125 | else |
shahidsajid | 15:81a3aaf52647 | 126 | update_scoreboard(check_update,4,pad); |
shahidsajid | 13:924891519a95 | 127 | } |
shahidsajid | 15:81a3aaf52647 | 128 | } |
shahidsajid | 15:81a3aaf52647 | 129 | } |
shahidsajid | 17:b2b651acffae | 130 | void Cricket::check_ball_count(N5110 &lcd){ |
shahidsajid | 17:b2b651acffae | 131 | int count=ball.get_ball_count(); |
shahidsajid | 17:b2b651acffae | 132 | if (count>_ball_limit){ |
shahidsajid | 17:b2b651acffae | 133 | bat.game_over_menu(lcd,1); |
shahidsajid | 17:b2b651acffae | 134 | } |
shahidsajid | 17:b2b651acffae | 135 | } |
shahidsajid | 15:81a3aaf52647 | 136 | void Cricket::update_scoreboard(int checkUpdate, int runs,Gamepad &pad){ |
shahidsajid | 15:81a3aaf52647 | 137 | printf("enter check"); |
shahidsajid | 15:81a3aaf52647 | 138 | if (checkUpdate==1){ |
shahidsajid | 15:81a3aaf52647 | 139 | scoreboard.update_score(runs); |
shahidsajid | 15:81a3aaf52647 | 140 | pad.led(3,1.0); |
shahidsajid | 15:81a3aaf52647 | 141 | wait(0.5); |
shahidsajid | 14:122eaa3b7a50 | 142 | new_round=1; |
shahidsajid | 14:122eaa3b7a50 | 143 | } |
shahidsajid | 13:924891519a95 | 144 | } |
shahidsajid | 15:81a3aaf52647 | 145 | void Cricket::batsman_out(string message,Gamepad &pad){ |
shahidsajid | 15:81a3aaf52647 | 146 | scoreboard.reset(); |
shahidsajid | 15:81a3aaf52647 | 147 | new_round=1; |
shahidsajid | 15:81a3aaf52647 | 148 | pad.led(1,1.0); |
shahidsajid | 17:b2b651acffae | 149 | //pad.tone(750.0,0.5); |
shahidsajid | 15:81a3aaf52647 | 150 | wait(2); |
shahidsajid | 15:81a3aaf52647 | 151 | } |
shahidsajid | 13:924891519a95 | 152 | void Cricket::draw(N5110 &lcd){ |
shahidsajid | 13:924891519a95 | 153 | lcd.drawCircle((WIDTH/2),HEIGHT/2,23,FILL_TRANSPARENT); |
shahidsajid | 13:924891519a95 | 154 | lcd.drawRect(37,11,12,30,FILL_TRANSPARENT); |
shahidsajid | 13:924891519a95 | 155 | ball.draw(lcd); |
shahidsajid | 13:924891519a95 | 156 | draw_field(lcd); |
shahidsajid | 13:924891519a95 | 157 | bat.draw(lcd); |
shahidsajid | 14:122eaa3b7a50 | 158 | scoreboard.draw(lcd); |
shahidsajid | 13:924891519a95 | 159 | } |
shahidsajid | 17:b2b651acffae | 160 | void Cricket::check_victory(N5110 &lcd){ |
shahidsajid | 17:b2b651acffae | 161 | bool _victory_check=scoreboard.compare_target(); |
shahidsajid | 17:b2b651acffae | 162 | if (_victory_check==true){ |
shahidsajid | 17:b2b651acffae | 163 | bat.victory_menu(lcd); |
shahidsajid | 17:b2b651acffae | 164 | } |
shahidsajid | 17:b2b651acffae | 165 | } |
shahidsajid | 13:924891519a95 | 166 | void Cricket::set_ball_direction(Direction dir){ |
shahidsajid | 13:924891519a95 | 167 | if (direction_set!=1){ |
shahidsajid | 15:81a3aaf52647 | 168 | for (int i=0;i<init_field_counter+1;i++){ |
shahidsajid | 12:954da4f4e565 | 169 | if(dir==positions[i].dir){ |
shahidsajid | 12:954da4f4e565 | 170 | ball_direction=dir; |
shahidsajid | 15:81a3aaf52647 | 171 | printf(" BALL DIRECTION %i x %i y %i \n",positions[i].no,positions[i].x,positions[i].y); |
shahidsajid | 12:954da4f4e565 | 172 | fielder_no=i; |
shahidsajid | 12:954da4f4e565 | 173 | direction_set=1; |
shahidsajid | 12:954da4f4e565 | 174 | break; |
shahidsajid | 12:954da4f4e565 | 175 | } |
shahidsajid | 12:954da4f4e565 | 176 | } |
shahidsajid | 12:954da4f4e565 | 177 | } |
shahidsajid | 13:924891519a95 | 178 | } |
shahidsajid | 13:924891519a95 | 179 | int Cricket::check_fielder(Direction dir){ |
shahidsajid | 13:924891519a95 | 180 | Vector2D p; |
shahidsajid | 15:81a3aaf52647 | 181 | //if (dir==N){ |
shahidsajid | 15:81a3aaf52647 | 182 | // return -1; |
shahidsajid | 15:81a3aaf52647 | 183 | // } |
shahidsajid | 15:81a3aaf52647 | 184 | for (int i=0;i<8;i++){ |
shahidsajid | 13:924891519a95 | 185 | if(dir == field[i].dir){ |
shahidsajid | 13:924891519a95 | 186 | return i; |
shahidsajid | 13:924891519a95 | 187 | } |
shahidsajid | 13:924891519a95 | 188 | } |
shahidsajid | 13:924891519a95 | 189 | return -1; |
shahidsajid | 10:6c6e09023942 | 190 | } |
shahidsajid | 10:6c6e09023942 | 191 | void Cricket::draw_field(N5110 &lcd){ |
shahidsajid | 13:924891519a95 | 192 | lcd.drawCircle(field[0].x,field[0].y,2,FILL_TRANSPARENT); |
shahidsajid | 13:924891519a95 | 193 | lcd.drawCircle(field[1].x,field[1].y,2,FILL_TRANSPARENT); |
shahidsajid | 13:924891519a95 | 194 | lcd.drawCircle(field[2].x,field[2].y,2,FILL_TRANSPARENT); |
shahidsajid | 13:924891519a95 | 195 | lcd.drawCircle(field[3].x,field[3].y,2,FILL_TRANSPARENT); |
shahidsajid | 14:122eaa3b7a50 | 196 | lcd.drawCircle(field[4].x,field[4].y,2,FILL_TRANSPARENT); |
shahidsajid | 10:6c6e09023942 | 197 | } |
shahidsajid | 10:6c6e09023942 | 198 | void Cricket::set_field(N5110 &lcd){ |
shahidsajid | 10:6c6e09023942 | 199 | int d=0; |
shahidsajid | 10:6c6e09023942 | 200 | int pos=0; |
shahidsajid | 10:6c6e09023942 | 201 | int i=0; |
shahidsajid | 10:6c6e09023942 | 202 | int continueCount=0; |
shahidsajid | 10:6c6e09023942 | 203 | srand(time(NULL)); |
shahidsajid | 10:6c6e09023942 | 204 | while (fieldersCount!=5){ |
shahidsajid | 10:6c6e09023942 | 205 | d = 1+ rand() % 6; |
shahidsajid | 10:6c6e09023942 | 206 | pos=rand()%2; |
shahidsajid | 10:6c6e09023942 | 207 | for (int j=0;j<10;j++){ |
shahidsajid | 10:6c6e09023942 | 208 | if (fieldNumbers[j]==d){ |
shahidsajid | 10:6c6e09023942 | 209 | continueCount=1; |
shahidsajid | 10:6c6e09023942 | 210 | } |
shahidsajid | 10:6c6e09023942 | 211 | } |
shahidsajid | 10:6c6e09023942 | 212 | if (continueCount==1){ |
shahidsajid | 10:6c6e09023942 | 213 | continueCount=0; |
shahidsajid | 10:6c6e09023942 | 214 | continue; |
shahidsajid | 10:6c6e09023942 | 215 | } |
shahidsajid | 10:6c6e09023942 | 216 | if (d==1){ //NW |
shahidsajid | 10:6c6e09023942 | 217 | if (pos==1){ |
shahidsajid | 10:6c6e09023942 | 218 | field[i].dir=NW; |
shahidsajid | 10:6c6e09023942 | 219 | field[i].x=30; |
shahidsajid | 10:6c6e09023942 | 220 | field[i].y=9; |
shahidsajid | 10:6c6e09023942 | 221 | field[i].position=1; |
shahidsajid | 10:6c6e09023942 | 222 | fieldNumbers[i]=d; |
shahidsajid | 10:6c6e09023942 | 223 | i++; |
shahidsajid | 10:6c6e09023942 | 224 | fieldersCount++; |
shahidsajid | 10:6c6e09023942 | 225 | } |
shahidsajid | 10:6c6e09023942 | 226 | else{ |
shahidsajid | 10:6c6e09023942 | 227 | field[i].dir=NW; |
shahidsajid | 10:6c6e09023942 | 228 | field[i].x=25; |
shahidsajid | 10:6c6e09023942 | 229 | field[i].y=2; |
shahidsajid | 10:6c6e09023942 | 230 | field[i].position=0; |
shahidsajid | 10:6c6e09023942 | 231 | fieldNumbers[i]=d; |
shahidsajid | 10:6c6e09023942 | 232 | i++; |
shahidsajid | 10:6c6e09023942 | 233 | fieldersCount++; |
shahidsajid | 10:6c6e09023942 | 234 | } |
shahidsajid | 10:6c6e09023942 | 235 | } |
shahidsajid | 10:6c6e09023942 | 236 | |
shahidsajid | 10:6c6e09023942 | 237 | |
shahidsajid | 10:6c6e09023942 | 238 | if (d==2){ //NE |
shahidsajid | 10:6c6e09023942 | 239 | if (pos==1){ |
shahidsajid | 10:6c6e09023942 | 240 | field[i].dir=NE; |
shahidsajid | 10:6c6e09023942 | 241 | field[i].x=55; |
shahidsajid | 10:6c6e09023942 | 242 | field[i].y=9; |
shahidsajid | 10:6c6e09023942 | 243 | field[i].position=1; |
shahidsajid | 10:6c6e09023942 | 244 | fieldNumbers[i]=d; |
shahidsajid | 10:6c6e09023942 | 245 | i++; |
shahidsajid | 10:6c6e09023942 | 246 | fieldersCount++; |
shahidsajid | 10:6c6e09023942 | 247 | } |
shahidsajid | 10:6c6e09023942 | 248 | else{ |
shahidsajid | 10:6c6e09023942 | 249 | field[i].dir=NE; |
shahidsajid | 10:6c6e09023942 | 250 | field[i].x=65; |
shahidsajid | 10:6c6e09023942 | 251 | field[i].y=2; |
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 | |
shahidsajid | 10:6c6e09023942 | 260 | if (d==3){ //SW |
shahidsajid | 10:6c6e09023942 | 261 | if (pos==1){ |
shahidsajid | 10:6c6e09023942 | 262 | field[i].dir=SW; |
shahidsajid | 10:6c6e09023942 | 263 | field[i].x=33; |
shahidsajid | 10:6c6e09023942 | 264 | field[i].y=40; |
shahidsajid | 10:6c6e09023942 | 265 | field[i].position=1; |
shahidsajid | 10:6c6e09023942 | 266 | fieldNumbers[i]=d; |
shahidsajid | 10:6c6e09023942 | 267 | i++; |
shahidsajid | 10:6c6e09023942 | 268 | fieldersCount++; |
shahidsajid | 10:6c6e09023942 | 269 | } |
shahidsajid | 10:6c6e09023942 | 270 | |
shahidsajid | 10:6c6e09023942 | 271 | else{ |
shahidsajid | 10:6c6e09023942 | 272 | field[i].dir=SW; |
shahidsajid | 10:6c6e09023942 | 273 | field[i].x=25; |
shahidsajid | 10:6c6e09023942 | 274 | field[i].y=44; |
shahidsajid | 10:6c6e09023942 | 275 | field[i].position=0; |
shahidsajid | 10:6c6e09023942 | 276 | fieldNumbers[i]=d; |
shahidsajid | 10:6c6e09023942 | 277 | i++; |
shahidsajid | 10:6c6e09023942 | 278 | fieldersCount++; |
shahidsajid | 10:6c6e09023942 | 279 | } |
shahidsajid | 10:6c6e09023942 | 280 | } |
shahidsajid | 10:6c6e09023942 | 281 | |
shahidsajid | 10:6c6e09023942 | 282 | if (d==4){ //SE |
shahidsajid | 10:6c6e09023942 | 283 | if (pos==1){ |
shahidsajid | 10:6c6e09023942 | 284 | field[i].dir=SE; |
shahidsajid | 10:6c6e09023942 | 285 | field[i].x=55; |
shahidsajid | 10:6c6e09023942 | 286 | field[i].y=40; |
shahidsajid | 10:6c6e09023942 | 287 | field[i].position=1; |
shahidsajid | 10:6c6e09023942 | 288 | fieldNumbers[i]=d; |
shahidsajid | 10:6c6e09023942 | 289 | i++; |
shahidsajid | 10:6c6e09023942 | 290 | fieldersCount++; |
shahidsajid | 10:6c6e09023942 | 291 | } |
shahidsajid | 10:6c6e09023942 | 292 | else{ |
shahidsajid | 10:6c6e09023942 | 293 | field[i].dir=SE; |
shahidsajid | 10:6c6e09023942 | 294 | field[i].x=65; |
shahidsajid | 10:6c6e09023942 | 295 | field[i].y=44; |
shahidsajid | 10:6c6e09023942 | 296 | field[i].position=0; |
shahidsajid | 10:6c6e09023942 | 297 | fieldNumbers[i]=d; |
shahidsajid | 10:6c6e09023942 | 298 | i++; |
shahidsajid | 10:6c6e09023942 | 299 | fieldersCount++; |
shahidsajid | 10:6c6e09023942 | 300 | } |
shahidsajid | 10:6c6e09023942 | 301 | } |
shahidsajid | 10:6c6e09023942 | 302 | |
shahidsajid | 10:6c6e09023942 | 303 | if (d==5){ //W |
shahidsajid | 10:6c6e09023942 | 304 | if (pos==1){ |
shahidsajid | 10:6c6e09023942 | 305 | field[i].dir=W; |
shahidsajid | 10:6c6e09023942 | 306 | field[i].x=3; |
shahidsajid | 15:81a3aaf52647 | 307 | field[i].y=30; |
shahidsajid | 10:6c6e09023942 | 308 | field[i].position=1; |
shahidsajid | 10:6c6e09023942 | 309 | fieldNumbers[i]=d; |
shahidsajid | 10:6c6e09023942 | 310 | i++; |
shahidsajid | 10:6c6e09023942 | 311 | fieldersCount++; |
shahidsajid | 10:6c6e09023942 | 312 | } |
shahidsajid | 10:6c6e09023942 | 313 | else{ |
shahidsajid | 10:6c6e09023942 | 314 | field[i].dir=W; |
shahidsajid | 10:6c6e09023942 | 315 | field[i].x=25; |
shahidsajid | 15:81a3aaf52647 | 316 | field[i].y=30; |
shahidsajid | 10:6c6e09023942 | 317 | field[i].position=0; |
shahidsajid | 10:6c6e09023942 | 318 | fieldNumbers[i]=d; |
shahidsajid | 10:6c6e09023942 | 319 | i++; |
shahidsajid | 10:6c6e09023942 | 320 | fieldersCount++; |
shahidsajid | 10:6c6e09023942 | 321 | } |
shahidsajid | 13:924891519a95 | 322 | } |
shahidsajid | 10:6c6e09023942 | 323 | if (d==6){ //W |
shahidsajid | 10:6c6e09023942 | 324 | if (pos==1){ |
shahidsajid | 10:6c6e09023942 | 325 | field[i].dir=E; |
shahidsajid | 10:6c6e09023942 | 326 | field[i].x=80; |
shahidsajid | 15:81a3aaf52647 | 327 | field[i].y=30; |
shahidsajid | 10:6c6e09023942 | 328 | field[i].position=1; |
shahidsajid | 10:6c6e09023942 | 329 | fieldNumbers[i]=d; |
shahidsajid | 10:6c6e09023942 | 330 | i++; |
shahidsajid | 10:6c6e09023942 | 331 | fieldersCount++; |
shahidsajid | 10:6c6e09023942 | 332 | } |
shahidsajid | 10:6c6e09023942 | 333 | else{ |
shahidsajid | 10:6c6e09023942 | 334 | field[i].dir=E; |
shahidsajid | 15:81a3aaf52647 | 335 | field[i].x=60; |
shahidsajid | 15:81a3aaf52647 | 336 | field[i].y=30; |
shahidsajid | 15:81a3aaf52647 | 337 | field[i].position=0; |
shahidsajid | 10:6c6e09023942 | 338 | fieldNumbers[i]=d; |
shahidsajid | 10:6c6e09023942 | 339 | i++; |
shahidsajid | 10:6c6e09023942 | 340 | fieldersCount++; |
shahidsajid | 13:924891519a95 | 341 | } |
shahidsajid | 10:6c6e09023942 | 342 | } |
shahidsajid | 10:6c6e09023942 | 343 | } |
shahidsajid | 10:6c6e09023942 | 344 | |
shahidsajid | 10:6c6e09023942 | 345 | |
shahidsajid | 10:6c6e09023942 | 346 | } |