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