Jirat Nakarit
/
project_ShipDot
Jirat
Fork of project by
main.cpp@2:d93832fe8deb, 2016-12-02 (annotated)
- Committer:
- gunpuen2
- Date:
- Fri Dec 02 09:04:29 2016 +0000
- Revision:
- 2:d93832fe8deb
- Parent:
- 1:6157c77da3d5
- Child:
- 3:baff75bbb78e
Test with Joe (16:04 || 2/12/2559)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
gunpuen2 | 0:a8e057156263 | 1 | /******************************************************************************/ |
gunpuen2 | 1:6157c77da3d5 | 2 | /* This Nicleo is state 0 */ |
gunpuen2 | 0:a8e057156263 | 3 | /******************************************************************************/ |
gunpuen2 | 0:a8e057156263 | 4 | #include "mbed.h" |
gunpuen2 | 0:a8e057156263 | 5 | |
gunpuen2 | 0:a8e057156263 | 6 | // Initail I/O. |
gunpuen2 | 0:a8e057156263 | 7 | AnalogIn VRx(A2); |
gunpuen2 | 0:a8e057156263 | 8 | AnalogIn VRy(A3); |
gunpuen2 | 0:a8e057156263 | 9 | DigitalIn Button(D13); |
gunpuen2 | 0:a8e057156263 | 10 | Serial bt(PA_15, PB_7); |
gunpuen2 | 0:a8e057156263 | 11 | |
gunpuen2 | 0:a8e057156263 | 12 | // Initial function. |
gunpuen2 | 0:a8e057156263 | 13 | char check_joys(int jx,int jy); |
gunpuen2 | 0:a8e057156263 | 14 | int check_joys_int(int jx,int jy); |
gunpuen2 | 0:a8e057156263 | 15 | int check_correctPosition(int X,int Y); |
gunpuen2 | 0:a8e057156263 | 16 | int get_position(int input_position,int ship_type); |
gunpuen2 | 0:a8e057156263 | 17 | void check_ready(); |
gunpuen2 | 0:a8e057156263 | 18 | void print_metrix(); |
gunpuen2 | 0:a8e057156263 | 19 | void Select_Position(char M); |
gunpuen2 | 1:6157c77da3d5 | 20 | void getATK_position(int atkpos); |
gunpuen2 | 1:6157c77da3d5 | 21 | char posit2char(int posit); |
gunpuen2 | 1:6157c77da3d5 | 22 | int char2posit(char cha); |
gunpuen2 | 0:a8e057156263 | 23 | |
gunpuen2 | 0:a8e057156263 | 24 | // Initial variable. |
gunpuen2 | 2:d93832fe8deb | 25 | int check_ship_underATK = 0; |
gunpuen2 | 0:a8e057156263 | 26 | int select_Position = 0; |
gunpuen2 | 0:a8e057156263 | 27 | int ATKposition = 0; |
gunpuen2 | 1:6157c77da3d5 | 28 | int enemy_ready = 0; |
gunpuen2 | 1:6157c77da3d5 | 29 | int iPrintUturn = 0; |
gunpuen2 | 2:d93832fe8deb | 30 | int check_ship1 = 0; |
gunpuen2 | 2:d93832fe8deb | 31 | int check_ship2 = 0; |
gunpuen2 | 0:a8e057156263 | 32 | int iWaitATK = 0; |
gunpuen2 | 0:a8e057156263 | 33 | int state = 0; |
gunpuen2 | 2:d93832fe8deb | 34 | int ship_SelectType[8] = {4,3,2,2,1,1,1,1}; |
gunpuen2 | 1:6157c77da3d5 | 35 | int ship_platform[8][8] = {{0}}; //__________________________________________________This is ship area. |
gunpuen2 | 1:6157c77da3d5 | 36 | int atk_platform[8][8] = {{0}}; |
gunpuen2 | 2:d93832fe8deb | 37 | int ship_underATK[15] = {0}; |
gunpuen2 | 2:d93832fe8deb | 38 | int ship_destroyed[8] = {0}; |
gunpuen2 | 0:a8e057156263 | 39 | int ship4[4] = {0}; |
gunpuen2 | 0:a8e057156263 | 40 | int ship3[3] = {0}; |
gunpuen2 | 0:a8e057156263 | 41 | int ship2[2][2] = {{0}}; |
gunpuen2 | 0:a8e057156263 | 42 | int ship1[4] = {0}; |
gunpuen2 | 0:a8e057156263 | 43 | |
gunpuen2 | 0:a8e057156263 | 44 | int main(){ //-------------------------------------------------------------------Main Function. |
gunpuen2 | 0:a8e057156263 | 45 | float Vx; |
gunpuen2 | 0:a8e057156263 | 46 | float Vy; |
gunpuen2 | 0:a8e057156263 | 47 | int SW,iVxVy,iSW,n; |
gunpuen2 | 0:a8e057156263 | 48 | int iShipType = 0; |
gunpuen2 | 0:a8e057156263 | 49 | char m; |
gunpuen2 | 0:a8e057156263 | 50 | while(1) { |
gunpuen2 | 0:a8e057156263 | 51 | if(iShipType<8){ |
gunpuen2 | 0:a8e057156263 | 52 | Vx = VRx.read() * 1024; |
gunpuen2 | 0:a8e057156263 | 53 | Vy = VRy.read() * 1024; |
gunpuen2 | 0:a8e057156263 | 54 | SW = Button.read(); |
gunpuen2 | 0:a8e057156263 | 55 | m = check_joys(Vx,Vy); |
gunpuen2 | 0:a8e057156263 | 56 | n = check_joys_int(Vx,Vy); |
gunpuen2 | 0:a8e057156263 | 57 | if(n == 1){ //_______________________________________________________ For make sure coordinate is press 1 time. |
gunpuen2 | 0:a8e057156263 | 58 | iVxVy = 0; |
gunpuen2 | 0:a8e057156263 | 59 | check_ready(); |
gunpuen2 | 0:a8e057156263 | 60 | } |
gunpuen2 | 0:a8e057156263 | 61 | if(SW == 1){ //______________________________________________________ For make sure switch is press 1 time. |
gunpuen2 | 0:a8e057156263 | 62 | iSW = 0; |
gunpuen2 | 0:a8e057156263 | 63 | check_ready(); |
gunpuen2 | 0:a8e057156263 | 64 | } |
gunpuen2 | 0:a8e057156263 | 65 | if(m!=NULL && iVxVy==0){ //__________________________________________ Get position that wait for press switch. |
gunpuen2 | 0:a8e057156263 | 66 | Select_Position(m); |
gunpuen2 | 0:a8e057156263 | 67 | check_ready(); |
gunpuen2 | 0:a8e057156263 | 68 | printf("select_Position = %d\n",select_Position); |
gunpuen2 | 0:a8e057156263 | 69 | iVxVy = 1; |
gunpuen2 | 0:a8e057156263 | 70 | } |
gunpuen2 | 0:a8e057156263 | 71 | if(SW==0 && iSW==0){ //______________________________________________If switch pressing by human. |
gunpuen2 | 0:a8e057156263 | 72 | printf("Wait!\n"); |
gunpuen2 | 0:a8e057156263 | 73 | check_ready(); |
gunpuen2 | 2:d93832fe8deb | 74 | if(get_position(select_Position,ship_SelectType[iShipType])==0){ //__Please read explanation in function get_position. |
gunpuen2 | 0:a8e057156263 | 75 | printf("Please input correct position\n"); |
gunpuen2 | 0:a8e057156263 | 76 | }else{ |
gunpuen2 | 0:a8e057156263 | 77 | iShipType++; |
gunpuen2 | 0:a8e057156263 | 78 | } |
gunpuen2 | 0:a8e057156263 | 79 | check_ready(); |
gunpuen2 | 0:a8e057156263 | 80 | iSW = 1; |
gunpuen2 | 0:a8e057156263 | 81 | print_metrix(); |
gunpuen2 | 0:a8e057156263 | 82 | } |
gunpuen2 | 0:a8e057156263 | 83 | }else{ |
gunpuen2 | 1:6157c77da3d5 | 84 | if(enemy_ready!=1){bt.putc('E');} |
gunpuen2 | 0:a8e057156263 | 85 | |
gunpuen2 | 0:a8e057156263 | 86 | printf("\n"); |
gunpuen2 | 0:a8e057156263 | 87 | break; |
gunpuen2 | 0:a8e057156263 | 88 | } |
gunpuen2 | 0:a8e057156263 | 89 | } |
gunpuen2 | 0:a8e057156263 | 90 | select_Position = 0; |
gunpuen2 | 1:6157c77da3d5 | 91 | if(enemy_ready == 1){state = 1;}else{state = 0;} //__________________________Set state |
gunpuen2 | 0:a8e057156263 | 92 | while(1) { //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Play |
gunpuen2 | 1:6157c77da3d5 | 93 | if(state == 0){ |
gunpuen2 | 1:6157c77da3d5 | 94 | if(iPrintUturn==0){ |
gunpuen2 | 1:6157c77da3d5 | 95 | printf("Your turn.\n"); |
gunpuen2 | 1:6157c77da3d5 | 96 | iPrintUturn = 1; |
gunpuen2 | 1:6157c77da3d5 | 97 | } |
gunpuen2 | 0:a8e057156263 | 98 | Vx = VRx.read() * 1024; |
gunpuen2 | 0:a8e057156263 | 99 | Vy = VRy.read() * 1024; |
gunpuen2 | 0:a8e057156263 | 100 | SW = Button.read(); |
gunpuen2 | 0:a8e057156263 | 101 | m = check_joys(Vx,Vy); |
gunpuen2 | 0:a8e057156263 | 102 | n = check_joys_int(Vx,Vy); |
gunpuen2 | 0:a8e057156263 | 103 | if(n == 1){ |
gunpuen2 | 0:a8e057156263 | 104 | iVxVy = 0; |
gunpuen2 | 0:a8e057156263 | 105 | } |
gunpuen2 | 0:a8e057156263 | 106 | if(SW == 1){ |
gunpuen2 | 0:a8e057156263 | 107 | iSW = 0; |
gunpuen2 | 0:a8e057156263 | 108 | } |
gunpuen2 | 0:a8e057156263 | 109 | if(m!=NULL && iVxVy==0){ |
gunpuen2 | 0:a8e057156263 | 110 | Select_Position(m); |
gunpuen2 | 0:a8e057156263 | 111 | printf("select_Position = %d\n",select_Position); |
gunpuen2 | 0:a8e057156263 | 112 | iVxVy = 1; |
gunpuen2 | 0:a8e057156263 | 113 | } |
gunpuen2 | 0:a8e057156263 | 114 | if(SW==0 && iSW==0){ |
gunpuen2 | 1:6157c77da3d5 | 115 | bt.putc(posit2char(select_Position)); |
gunpuen2 | 1:6157c77da3d5 | 116 | printf("You attacking at position %d\n",select_Position); |
gunpuen2 | 1:6157c77da3d5 | 117 | state = 1; |
gunpuen2 | 0:a8e057156263 | 118 | iSW = 1; |
gunpuen2 | 0:a8e057156263 | 119 | } |
gunpuen2 | 0:a8e057156263 | 120 | }else{ |
gunpuen2 | 1:6157c77da3d5 | 121 | iPrintUturn = 0; |
gunpuen2 | 0:a8e057156263 | 122 | while(1){ |
gunpuen2 | 0:a8e057156263 | 123 | if(bt.readable()){ |
gunpuen2 | 0:a8e057156263 | 124 | // Wait for resive position of enemy that atk you. |
gunpuen2 | 1:6157c77da3d5 | 125 | ATKposition = char2posit(bt.getc()); |
gunpuen2 | 0:a8e057156263 | 126 | iWaitATK = 1; |
gunpuen2 | 1:6157c77da3d5 | 127 | }else{ |
gunpuen2 | 1:6157c77da3d5 | 128 | printf("Wait for enemy attack\n"); |
gunpuen2 | 0:a8e057156263 | 129 | } |
gunpuen2 | 0:a8e057156263 | 130 | if(iWaitATK==1){ |
gunpuen2 | 1:6157c77da3d5 | 131 | printf("Enemy attack at your area %d\n",ATKposition); |
gunpuen2 | 1:6157c77da3d5 | 132 | state = 0; |
gunpuen2 | 0:a8e057156263 | 133 | break; |
gunpuen2 | 0:a8e057156263 | 134 | } |
gunpuen2 | 0:a8e057156263 | 135 | } |
gunpuen2 | 0:a8e057156263 | 136 | } |
gunpuen2 | 0:a8e057156263 | 137 | } |
gunpuen2 | 0:a8e057156263 | 138 | } |
gunpuen2 | 0:a8e057156263 | 139 | |
gunpuen2 | 0:a8e057156263 | 140 | |
gunpuen2 | 0:a8e057156263 | 141 | |
gunpuen2 | 0:a8e057156263 | 142 | |
gunpuen2 | 0:a8e057156263 | 143 | |
gunpuen2 | 0:a8e057156263 | 144 | |
gunpuen2 | 0:a8e057156263 | 145 | |
gunpuen2 | 0:a8e057156263 | 146 | |
gunpuen2 | 0:a8e057156263 | 147 | |
gunpuen2 | 0:a8e057156263 | 148 | |
gunpuen2 | 0:a8e057156263 | 149 | |
gunpuen2 | 0:a8e057156263 | 150 | |
gunpuen2 | 0:a8e057156263 | 151 | |
gunpuen2 | 0:a8e057156263 | 152 | |
gunpuen2 | 0:a8e057156263 | 153 | char check_joys(int jx,int jy){ //-----------------------------------------------Check joystick that it up,down,left or right. |
gunpuen2 | 0:a8e057156263 | 154 | if(jx < 24.0){ |
gunpuen2 | 0:a8e057156263 | 155 | return 'a'; |
gunpuen2 | 0:a8e057156263 | 156 | } |
gunpuen2 | 0:a8e057156263 | 157 | else if(jx > 1000.0){ |
gunpuen2 | 0:a8e057156263 | 158 | return 'd'; |
gunpuen2 | 0:a8e057156263 | 159 | } |
gunpuen2 | 0:a8e057156263 | 160 | else if(jy < 24.0){ |
gunpuen2 | 0:a8e057156263 | 161 | return 'w'; |
gunpuen2 | 0:a8e057156263 | 162 | } |
gunpuen2 | 0:a8e057156263 | 163 | else if(jy > 1000.0){ |
gunpuen2 | 0:a8e057156263 | 164 | return 's'; |
gunpuen2 | 0:a8e057156263 | 165 | }else{ |
gunpuen2 | 0:a8e057156263 | 166 | return NULL; |
gunpuen2 | 0:a8e057156263 | 167 | } |
gunpuen2 | 0:a8e057156263 | 168 | } |
gunpuen2 | 0:a8e057156263 | 169 | int check_joys_int(int jx,int jy){ //--------------------------------------------Check joystick that it is centre. |
gunpuen2 | 0:a8e057156263 | 170 | if(jx>=450.0&&jx<=600.0){ |
gunpuen2 | 0:a8e057156263 | 171 | if(jy>=450.0&&jy<=600.0){ |
gunpuen2 | 0:a8e057156263 | 172 | return 1; |
gunpuen2 | 0:a8e057156263 | 173 | }else{ |
gunpuen2 | 0:a8e057156263 | 174 | return 0; |
gunpuen2 | 0:a8e057156263 | 175 | } |
gunpuen2 | 0:a8e057156263 | 176 | }else{ |
gunpuen2 | 0:a8e057156263 | 177 | return 0; |
gunpuen2 | 0:a8e057156263 | 178 | } |
gunpuen2 | 0:a8e057156263 | 179 | } |
gunpuen2 | 0:a8e057156263 | 180 | void Select_Position(char M){ //-------------------------------------------------Change position of cursor (Joystick). |
gunpuen2 | 0:a8e057156263 | 181 | switch(M){ |
gunpuen2 | 0:a8e057156263 | 182 | case 'a': |
gunpuen2 | 0:a8e057156263 | 183 | if(select_Position%10!=0){select_Position = select_Position - 1;} |
gunpuen2 | 0:a8e057156263 | 184 | break; |
gunpuen2 | 0:a8e057156263 | 185 | case 'd': |
gunpuen2 | 0:a8e057156263 | 186 | if(select_Position%10!=7){select_Position = select_Position + 1;} |
gunpuen2 | 0:a8e057156263 | 187 | break; |
gunpuen2 | 0:a8e057156263 | 188 | case 'w': |
gunpuen2 | 0:a8e057156263 | 189 | if(select_Position/10!=0){select_Position = select_Position - 10;} |
gunpuen2 | 0:a8e057156263 | 190 | break; |
gunpuen2 | 0:a8e057156263 | 191 | case 's': |
gunpuen2 | 0:a8e057156263 | 192 | if(select_Position/10!=7){select_Position = select_Position + 10;} |
gunpuen2 | 0:a8e057156263 | 193 | break; |
gunpuen2 | 0:a8e057156263 | 194 | } |
gunpuen2 | 0:a8e057156263 | 195 | } |
gunpuen2 | 0:a8e057156263 | 196 | int get_position(int input_position,int ship_type){ //---------------------------Plot ship in ship area. |
gunpuen2 | 0:a8e057156263 | 197 | int i,x,y = 0; |
gunpuen2 | 0:a8e057156263 | 198 | int error = 0; |
gunpuen2 | 0:a8e057156263 | 199 | |
gunpuen2 | 0:a8e057156263 | 200 | y = input_position/10; |
gunpuen2 | 0:a8e057156263 | 201 | x = input_position%10; |
gunpuen2 | 0:a8e057156263 | 202 | |
gunpuen2 | 0:a8e057156263 | 203 | for(i=0;i<ship_type;i++){ |
gunpuen2 | 0:a8e057156263 | 204 | if(check_correctPosition(y,x) == 1){ |
gunpuen2 | 0:a8e057156263 | 205 | if(ship_type == 4){ship4[i] = (y*10)+x;} |
gunpuen2 | 0:a8e057156263 | 206 | else if(ship_type == 3){ship3[i] = (y*10)+x;} |
gunpuen2 | 0:a8e057156263 | 207 | else if(ship_type == 2){ship2[check_ship2][i] = (y*10)+x;} |
gunpuen2 | 0:a8e057156263 | 208 | else if(ship_type == 1){ship1[check_ship1] = (y*10)+x;check_ship1++;} |
gunpuen2 | 0:a8e057156263 | 209 | }else{ |
gunpuen2 | 0:a8e057156263 | 210 | error = 1; |
gunpuen2 | 0:a8e057156263 | 211 | break; |
gunpuen2 | 0:a8e057156263 | 212 | } |
gunpuen2 | 0:a8e057156263 | 213 | if(ship_type%2 == 0){ |
gunpuen2 | 0:a8e057156263 | 214 | y++; |
gunpuen2 | 0:a8e057156263 | 215 | }else{ |
gunpuen2 | 0:a8e057156263 | 216 | x++; |
gunpuen2 | 0:a8e057156263 | 217 | } |
gunpuen2 | 0:a8e057156263 | 218 | } |
gunpuen2 | 0:a8e057156263 | 219 | if(ship_type==2){ |
gunpuen2 | 0:a8e057156263 | 220 | check_ship2++; |
gunpuen2 | 0:a8e057156263 | 221 | } |
gunpuen2 | 0:a8e057156263 | 222 | if(error == 1){ |
gunpuen2 | 0:a8e057156263 | 223 | return 0; |
gunpuen2 | 0:a8e057156263 | 224 | }else{ |
gunpuen2 | 0:a8e057156263 | 225 | y = input_position/10; |
gunpuen2 | 0:a8e057156263 | 226 | x = input_position%10; |
gunpuen2 | 0:a8e057156263 | 227 | for(i=0;i<ship_type;i++){ |
gunpuen2 | 1:6157c77da3d5 | 228 | ship_platform[y][x] = ship_type; |
gunpuen2 | 0:a8e057156263 | 229 | if(ship_type%2 == 0){ |
gunpuen2 | 0:a8e057156263 | 230 | y++; |
gunpuen2 | 0:a8e057156263 | 231 | }else{ |
gunpuen2 | 0:a8e057156263 | 232 | x++; |
gunpuen2 | 0:a8e057156263 | 233 | } |
gunpuen2 | 0:a8e057156263 | 234 | } |
gunpuen2 | 0:a8e057156263 | 235 | return 1; |
gunpuen2 | 0:a8e057156263 | 236 | } |
gunpuen2 | 0:a8e057156263 | 237 | } |
gunpuen2 | 0:a8e057156263 | 238 | int check_correctPosition(int X,int Y){ |
gunpuen2 | 0:a8e057156263 | 239 | if(X<=7){ |
gunpuen2 | 0:a8e057156263 | 240 | if(Y<=7){ |
gunpuen2 | 1:6157c77da3d5 | 241 | if(ship_platform[X][Y] == 0){ |
gunpuen2 | 0:a8e057156263 | 242 | return 1; |
gunpuen2 | 0:a8e057156263 | 243 | }else{ |
gunpuen2 | 0:a8e057156263 | 244 | return 0; |
gunpuen2 | 0:a8e057156263 | 245 | } |
gunpuen2 | 1:6157c77da3d5 | 246 | }else{ |
gunpuen2 | 1:6157c77da3d5 | 247 | return 0; |
gunpuen2 | 0:a8e057156263 | 248 | } |
gunpuen2 | 0:a8e057156263 | 249 | }else{ |
gunpuen2 | 0:a8e057156263 | 250 | return 0; |
gunpuen2 | 0:a8e057156263 | 251 | } |
gunpuen2 | 0:a8e057156263 | 252 | } |
gunpuen2 | 0:a8e057156263 | 253 | void print_metrix(){ |
gunpuen2 | 0:a8e057156263 | 254 | for(int i=0;i<8;i++){ |
gunpuen2 | 0:a8e057156263 | 255 | for(int j=0;j<8;j++){ |
gunpuen2 | 1:6157c77da3d5 | 256 | printf("| %d |",ship_platform[i][j]); |
gunpuen2 | 0:a8e057156263 | 257 | } |
gunpuen2 | 0:a8e057156263 | 258 | printf("\n"); |
gunpuen2 | 0:a8e057156263 | 259 | } |
gunpuen2 | 0:a8e057156263 | 260 | } |
gunpuen2 | 0:a8e057156263 | 261 | void check_ready(){ |
gunpuen2 | 0:a8e057156263 | 262 | if(bt.readable()){ |
gunpuen2 | 1:6157c77da3d5 | 263 | enemy_ready = 1; |
gunpuen2 | 1:6157c77da3d5 | 264 | } |
gunpuen2 | 1:6157c77da3d5 | 265 | } |
gunpuen2 | 1:6157c77da3d5 | 266 | char posit2char(int posit){ |
gunpuen2 | 1:6157c77da3d5 | 267 | int as = posit+48; |
gunpuen2 | 1:6157c77da3d5 | 268 | char ch = as; |
gunpuen2 | 1:6157c77da3d5 | 269 | return ch ; |
gunpuen2 | 1:6157c77da3d5 | 270 | } |
gunpuen2 | 1:6157c77da3d5 | 271 | |
gunpuen2 | 1:6157c77da3d5 | 272 | int char2posit(char cha){ |
gunpuen2 | 1:6157c77da3d5 | 273 | int as = cha; |
gunpuen2 | 1:6157c77da3d5 | 274 | as = as-48; |
gunpuen2 | 1:6157c77da3d5 | 275 | return as; |
gunpuen2 | 1:6157c77da3d5 | 276 | } |
gunpuen2 | 1:6157c77da3d5 | 277 | void getATK_position(int atkpos){ |
gunpuen2 | 2:d93832fe8deb | 278 | int i,j,k,x,y = 0; |
gunpuen2 | 1:6157c77da3d5 | 279 | |
gunpuen2 | 1:6157c77da3d5 | 280 | y = atkpos/10; |
gunpuen2 | 1:6157c77da3d5 | 281 | x = atkpos%10; |
gunpuen2 | 1:6157c77da3d5 | 282 | |
gunpuen2 | 2:d93832fe8deb | 283 | if(ship_platform[x][y]!=0 and atk_platform[x][y]==0){ |
gunpuen2 | 1:6157c77da3d5 | 284 | atk_platform[x][y] = ship_platform[x][y]; |
gunpuen2 | 2:d93832fe8deb | 285 | ship_underATK[check_ship_underATK] = (y*10)+x; |
gunpuen2 | 2:d93832fe8deb | 286 | check_ship_underATK++; |
gunpuen2 | 2:d93832fe8deb | 287 | if(atk_platform[x][y]==4){ |
gunpuen2 | 2:d93832fe8deb | 288 | for(i=0;i<4;i++){ |
gunpuen2 | 2:d93832fe8deb | 289 | for(j=0;j<15;j++){ |
gunpuen2 | 2:d93832fe8deb | 290 | if(ship4[i]==ship_underATK[j]){ |
gunpuen2 | 2:d93832fe8deb | 291 | ship_destroyed[0]++; |
gunpuen2 | 2:d93832fe8deb | 292 | } |
gunpuen2 | 2:d93832fe8deb | 293 | } |
gunpuen2 | 2:d93832fe8deb | 294 | } |
gunpuen2 | 2:d93832fe8deb | 295 | }else if(atk_platform[x][y]==3){ |
gunpuen2 | 2:d93832fe8deb | 296 | for(i=0;i<3;i++){ |
gunpuen2 | 2:d93832fe8deb | 297 | for(j=0;j<15;j++){ |
gunpuen2 | 2:d93832fe8deb | 298 | if(ship3[i]==ship_underATK[j]){ |
gunpuen2 | 2:d93832fe8deb | 299 | ship_destroyed[1]++; |
gunpuen2 | 2:d93832fe8deb | 300 | } |
gunpuen2 | 2:d93832fe8deb | 301 | } |
gunpuen2 | 2:d93832fe8deb | 302 | } |
gunpuen2 | 2:d93832fe8deb | 303 | }else if(atk_platform[x][y]==2){ |
gunpuen2 | 2:d93832fe8deb | 304 | for(i=0;i<4;i++){ |
gunpuen2 | 2:d93832fe8deb | 305 | for(j=0;j<15;j++){ |
gunpuen2 | 2:d93832fe8deb | 306 | if(ship2[0][i]==ship_underATK[j]){ |
gunpuen2 | 2:d93832fe8deb | 307 | ship_destroyed[2]++; |
gunpuen2 | 2:d93832fe8deb | 308 | } |
gunpuen2 | 2:d93832fe8deb | 309 | if(ship2[1][i]==ship_underATK[j]){ |
gunpuen2 | 2:d93832fe8deb | 310 | ship_destroyed[3]++; |
gunpuen2 | 2:d93832fe8deb | 311 | } |
gunpuen2 | 2:d93832fe8deb | 312 | } |
gunpuen2 | 2:d93832fe8deb | 313 | } |
gunpuen2 | 2:d93832fe8deb | 314 | }else if(atk_platform[x][y]==1){ |
gunpuen2 | 2:d93832fe8deb | 315 | for(i=0;i<4;i++){ |
gunpuen2 | 2:d93832fe8deb | 316 | for(j=0;j<15;j++){ |
gunpuen2 | 2:d93832fe8deb | 317 | if(ship3[i]==ship_underATK[j]){ |
gunpuen2 | 2:d93832fe8deb | 318 | ship_destroyed[4+i]++; |
gunpuen2 | 2:d93832fe8deb | 319 | } |
gunpuen2 | 2:d93832fe8deb | 320 | } |
gunpuen2 | 2:d93832fe8deb | 321 | } |
gunpuen2 | 2:d93832fe8deb | 322 | } |
gunpuen2 | 1:6157c77da3d5 | 323 | }else{ |
gunpuen2 | 1:6157c77da3d5 | 324 | atk_platform[x][y] = 8; |
gunpuen2 | 0:a8e057156263 | 325 | } |
gunpuen2 | 0:a8e057156263 | 326 | } |
gunpuen2 | 0:a8e057156263 | 327 | /* |
gunpuen2 | 0:a8e057156263 | 328 | int check_when_enemyATK(int position){ |
gunpuen2 | 0:a8e057156263 | 329 | |
gunpuen2 | 0:a8e057156263 | 330 | } |
gunpuen2 | 0:a8e057156263 | 331 | */ |