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