Jirat Nakarit
/
project_ShipDot
Jirat
Fork of project by
main.cpp@22:5bc894988f11, 2016-12-04 (annotated)
- Committer:
- dragondrunk
- Date:
- Sun Dec 04 05:02:03 2016 +0000
- Revision:
- 22:5bc894988f11
- Parent:
- 21:d76aa19984be
- Child:
- 23:66a401850f2e
add dotmatrix display (only place ship)
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" |
dragondrunk | 22:5bc894988f11 | 5 | #include "ColorMbed.h" |
gunpuen2 | 0:a8e057156263 | 6 | |
gunpuen2 | 0:a8e057156263 | 7 | // Initail I/O. |
dragondrunk | 22:5bc894988f11 | 8 | AnalogIn VRx(A0); |
dragondrunk | 22:5bc894988f11 | 9 | AnalogIn VRy(A1); |
dragondrunk | 22:5bc894988f11 | 10 | DigitalIn Button(PA_4); |
dragondrunk | 22:5bc894988f11 | 11 | Serial bt(PA_15, PB_7); |
dragondrunk | 22:5bc894988f11 | 12 | ColorMbed dotmatrix; |
gunpuen2 | 0:a8e057156263 | 13 | |
gunpuen2 | 0:a8e057156263 | 14 | // Initial function. |
gunpuen2 | 4:8a86bacddcac | 15 | char posit2char(int posit); |
gunpuen2 | 0:a8e057156263 | 16 | char check_joys(int jx,int jy); |
gunpuen2 | 4:8a86bacddcac | 17 | int char2posit(char cha); |
gunpuen2 | 7:e35ba3ddb9af | 18 | int IamWin(); |
gunpuen2 | 15:5902cf545449 | 19 | int protect_ship(int head_position,int ship_type); |
gunpuen2 | 7:e35ba3ddb9af | 20 | int TellUrEnemy_uWin(); |
gunpuen2 | 0:a8e057156263 | 21 | int check_joys_int(int jx,int jy); |
gunpuen2 | 0:a8e057156263 | 22 | int check_correctPosition(int X,int Y); |
gunpuen2 | 15:5902cf545449 | 23 | int get_ship_platform(int input_position,int ship_type); |
gunpuen2 | 6:7f99124272d9 | 24 | void atk_enemy(); |
gunpuen2 | 6:7f99124272d9 | 25 | void enemy_atk(); |
gunpuen2 | 0:a8e057156263 | 26 | void check_ready(); |
gunpuen2 | 16:3fac68a7fd7c | 27 | void mark_ship_destroyed(); |
gunpuen2 | 16:3fac68a7fd7c | 28 | void Select_Position(char M); |
gunpuen2 | 16:3fac68a7fd7c | 29 | void get_atk_platform(int atkpos); |
gunpuen2 | 16:3fac68a7fd7c | 30 | void check_end(); |
gunpuen2 | 16:3fac68a7fd7c | 31 | //inessential |
gunpuen2 | 7:e35ba3ddb9af | 32 | void print_ship_destroyed(); |
gunpuen2 | 6:7f99124272d9 | 33 | void print_enemy_platform(); |
gunpuen2 | 6:7f99124272d9 | 34 | void print_ship_platform(); |
gunpuen2 | 6:7f99124272d9 | 35 | void print_atk_platform(); |
gunpuen2 | 0:a8e057156263 | 36 | |
gunpuen2 | 7:e35ba3ddb9af | 37 | // Setting |
dragondrunk | 22:5bc894988f11 | 38 | int ifUrJirat = 0; |
gunpuen2 | 0:a8e057156263 | 39 | // Initial variable. |
gunpuen2 | 2:d93832fe8deb | 40 | int check_ship_underATK = 0; |
gunpuen2 | 0:a8e057156263 | 41 | int select_Position = 0; |
gunpuen2 | 0:a8e057156263 | 42 | int ATKposition = 0; |
gunpuen2 | 1:6157c77da3d5 | 43 | int enemy_ready = 0; |
gunpuen2 | 2:d93832fe8deb | 44 | int check_ship1 = 0; |
gunpuen2 | 2:d93832fe8deb | 45 | int check_ship2 = 0; |
gunpuen2 | 17:aeb7cbfb8640 | 46 | int iShipType = 0; |
gunpuen2 | 0:a8e057156263 | 47 | int iWaitATK = 0; |
gunpuen2 | 19:d78586719868 | 48 | int check_win = 0; |
gunpuen2 | 0:a8e057156263 | 49 | int state = 0; |
gunpuen2 | 2:d93832fe8deb | 50 | int ship_SelectType[8] = {4,3,2,2,1,1,1,1}; |
gunpuen2 | 6:7f99124272d9 | 51 | int enemy_platform[8][8] = {{0}}; |
gunpuen2 | 4:8a86bacddcac | 52 | int ship_platform[8][8] = {{0}}; //______________________________________________This is ship area. |
gunpuen2 | 1:6157c77da3d5 | 53 | int atk_platform[8][8] = {{0}}; |
gunpuen2 | 10:b8d45f9b00bf | 54 | int ship_underATK[15] = {9,9,9,9,9,9,9,9,9,9,9,9,9,9,9}; |
gunpuen2 | 2:d93832fe8deb | 55 | int ship_destroyed[8] = {0}; |
gunpuen2 | 0:a8e057156263 | 56 | int ship4[4] = {0}; |
gunpuen2 | 0:a8e057156263 | 57 | int ship3[3] = {0}; |
gunpuen2 | 0:a8e057156263 | 58 | int ship2[2][2] = {{0}}; |
gunpuen2 | 0:a8e057156263 | 59 | int ship1[4] = {0}; |
gunpuen2 | 0:a8e057156263 | 60 | |
dragondrunk | 22:5bc894988f11 | 61 | //fuction nasrun |
dragondrunk | 22:5bc894988f11 | 62 | int return_position[8][8] ; |
dragondrunk | 22:5bc894988f11 | 63 | int for_hex = 0; |
dragondrunk | 22:5bc894988f11 | 64 | int ch_post[8][8] = {{1,1,1,1,1,1,1,1}, |
dragondrunk | 22:5bc894988f11 | 65 | {1,1,1,1,1,1,1,1}, |
dragondrunk | 22:5bc894988f11 | 66 | {1,1,1,1,1,1,1,1}, |
dragondrunk | 22:5bc894988f11 | 67 | {1,1,1,1,1,1,1,1}, |
dragondrunk | 22:5bc894988f11 | 68 | {1,1,1,1,1,1,1,1}, |
dragondrunk | 22:5bc894988f11 | 69 | {1,1,1,1,1,1,1,1}, |
dragondrunk | 22:5bc894988f11 | 70 | {1,1,1,1,1,1,1,1}, |
dragondrunk | 22:5bc894988f11 | 71 | {1,1,1,1,1,1,1,1}}; |
dragondrunk | 22:5bc894988f11 | 72 | int return_hex[8]; |
dragondrunk | 22:5bc894988f11 | 73 | |
dragondrunk | 22:5bc894988f11 | 74 | int display_battle[8][8][3] = {0}; |
dragondrunk | 22:5bc894988f11 | 75 | |
dragondrunk | 22:5bc894988f11 | 76 | int _temppic[8] = {0x01,0x01,0x01,0x01,0,0,0,0}; |
dragondrunk | 22:5bc894988f11 | 77 | |
dragondrunk | 22:5bc894988f11 | 78 | int temppic2[8] = {0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; |
dragondrunk | 22:5bc894988f11 | 79 | int temppic3[3][8] = {{0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00},{0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00},{0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}; |
dragondrunk | 22:5bc894988f11 | 80 | int temppic4[8] = {0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; |
dragondrunk | 22:5bc894988f11 | 81 | int forshift[8] = {0}; |
dragondrunk | 22:5bc894988f11 | 82 | int pic[8] = {0}; |
dragondrunk | 22:5bc894988f11 | 83 | |
dragondrunk | 22:5bc894988f11 | 84 | int i,j; |
dragondrunk | 22:5bc894988f11 | 85 | int check_boat3=0; |
dragondrunk | 22:5bc894988f11 | 86 | int check_hex=0; |
dragondrunk | 22:5bc894988f11 | 87 | |
dragondrunk | 22:5bc894988f11 | 88 | |
dragondrunk | 22:5bc894988f11 | 89 | void hex_to_array(int* ar){ |
dragondrunk | 22:5bc894988f11 | 90 | int i; |
dragondrunk | 22:5bc894988f11 | 91 | int j; |
dragondrunk | 22:5bc894988f11 | 92 | int temp; |
dragondrunk | 22:5bc894988f11 | 93 | for(i = 0;i<8;i++){ |
dragondrunk | 22:5bc894988f11 | 94 | temp = ar[i]; |
dragondrunk | 22:5bc894988f11 | 95 | for(j = 0;j<8;j++){ |
dragondrunk | 22:5bc894988f11 | 96 | if(0x80 & temp){ |
dragondrunk | 22:5bc894988f11 | 97 | return_position[i][j] = 1; |
dragondrunk | 22:5bc894988f11 | 98 | } |
dragondrunk | 22:5bc894988f11 | 99 | else{ |
dragondrunk | 22:5bc894988f11 | 100 | return_position[i][j] = 0; |
dragondrunk | 22:5bc894988f11 | 101 | } |
dragondrunk | 22:5bc894988f11 | 102 | temp = temp << 1; |
dragondrunk | 22:5bc894988f11 | 103 | } |
dragondrunk | 22:5bc894988f11 | 104 | } |
dragondrunk | 22:5bc894988f11 | 105 | } |
dragondrunk | 22:5bc894988f11 | 106 | |
dragondrunk | 22:5bc894988f11 | 107 | void ch_same_position(int ar1[8][8],int ar2[8][8]){ |
dragondrunk | 22:5bc894988f11 | 108 | int i; |
dragondrunk | 22:5bc894988f11 | 109 | int j; |
dragondrunk | 22:5bc894988f11 | 110 | for(i = 0;i<8;i++){ |
dragondrunk | 22:5bc894988f11 | 111 | for(j = 0;j<8;j++){ |
dragondrunk | 22:5bc894988f11 | 112 | if(ar1[i][j] == 1 && ar2[i][j] == 1){ |
dragondrunk | 22:5bc894988f11 | 113 | ch_post[i][j] = 1; |
dragondrunk | 22:5bc894988f11 | 114 | } |
dragondrunk | 22:5bc894988f11 | 115 | else{ |
dragondrunk | 22:5bc894988f11 | 116 | ch_post[i][j] = 0; |
dragondrunk | 22:5bc894988f11 | 117 | } |
dragondrunk | 22:5bc894988f11 | 118 | } |
dragondrunk | 22:5bc894988f11 | 119 | } |
dragondrunk | 22:5bc894988f11 | 120 | |
dragondrunk | 22:5bc894988f11 | 121 | } |
dragondrunk | 22:5bc894988f11 | 122 | |
dragondrunk | 22:5bc894988f11 | 123 | void discard_same_position(int ar1[8][8],int ar2[8][8]){ |
dragondrunk | 22:5bc894988f11 | 124 | int i; |
dragondrunk | 22:5bc894988f11 | 125 | int j; |
dragondrunk | 22:5bc894988f11 | 126 | for(i = 0;i<8;i++){ |
dragondrunk | 22:5bc894988f11 | 127 | for(j = 0;j<8;j++){ |
dragondrunk | 22:5bc894988f11 | 128 | if(ar1[i][j] == ch_post[i][j] && ar2[i][j] == ch_post[i][j] ){ |
dragondrunk | 22:5bc894988f11 | 129 | ar1[i][j] = 0; |
dragondrunk | 22:5bc894988f11 | 130 | ar2[i][j] = 0; |
dragondrunk | 22:5bc894988f11 | 131 | } |
dragondrunk | 22:5bc894988f11 | 132 | } |
dragondrunk | 22:5bc894988f11 | 133 | } |
dragondrunk | 22:5bc894988f11 | 134 | } |
dragondrunk | 22:5bc894988f11 | 135 | |
dragondrunk | 22:5bc894988f11 | 136 | |
dragondrunk | 22:5bc894988f11 | 137 | int _power(int number , int power){ |
dragondrunk | 22:5bc894988f11 | 138 | int i = 0; |
dragondrunk | 22:5bc894988f11 | 139 | int number1 = number; |
dragondrunk | 22:5bc894988f11 | 140 | if(power == 0){return 1;} |
dragondrunk | 22:5bc894988f11 | 141 | for(i = 1 ; i <= power ; i++ ){ |
dragondrunk | 22:5bc894988f11 | 142 | if(power == 1){return number;} |
dragondrunk | 22:5bc894988f11 | 143 | if(i == 1){number = number * 1;} |
dragondrunk | 22:5bc894988f11 | 144 | else{number1 = number1 * number;} |
dragondrunk | 22:5bc894988f11 | 145 | } |
dragondrunk | 22:5bc894988f11 | 146 | return number1; |
dragondrunk | 22:5bc894988f11 | 147 | } |
dragondrunk | 22:5bc894988f11 | 148 | |
dragondrunk | 22:5bc894988f11 | 149 | |
dragondrunk | 22:5bc894988f11 | 150 | void array_to_hex(int ar1[8][8]){ |
dragondrunk | 22:5bc894988f11 | 151 | int prompt; |
dragondrunk | 22:5bc894988f11 | 152 | int i; |
dragondrunk | 22:5bc894988f11 | 153 | int j; |
dragondrunk | 22:5bc894988f11 | 154 | for(i = 0;i<8;i++){ |
dragondrunk | 22:5bc894988f11 | 155 | for(j = 0;j<8;j++){ |
dragondrunk | 22:5bc894988f11 | 156 | prompt = _power(2,7-j); |
dragondrunk | 22:5bc894988f11 | 157 | if(ar1[i][j] == 1){ |
dragondrunk | 22:5bc894988f11 | 158 | for_hex = for_hex + prompt; |
dragondrunk | 22:5bc894988f11 | 159 | } |
dragondrunk | 22:5bc894988f11 | 160 | else{ |
dragondrunk | 22:5bc894988f11 | 161 | for_hex = for_hex + 0; |
dragondrunk | 22:5bc894988f11 | 162 | } |
dragondrunk | 22:5bc894988f11 | 163 | } |
dragondrunk | 22:5bc894988f11 | 164 | return_hex[i] = for_hex; |
dragondrunk | 22:5bc894988f11 | 165 | prompt = 0; |
dragondrunk | 22:5bc894988f11 | 166 | for_hex = 0; |
dragondrunk | 22:5bc894988f11 | 167 | } |
dragondrunk | 22:5bc894988f11 | 168 | } |
dragondrunk | 22:5bc894988f11 | 169 | |
dragondrunk | 22:5bc894988f11 | 170 | void place_ship3(char dir){ |
dragondrunk | 22:5bc894988f11 | 171 | int post1[8][8] = {0}; |
dragondrunk | 22:5bc894988f11 | 172 | int post2[8][8] = {0}; |
dragondrunk | 22:5bc894988f11 | 173 | int hex_post1[8] = {0}; |
dragondrunk | 22:5bc894988f11 | 174 | int hex_post2[8] = {0}; |
dragondrunk | 22:5bc894988f11 | 175 | int hex_post_cut[8] = {0}; |
dragondrunk | 22:5bc894988f11 | 176 | int get_same_position[8][8]; |
dragondrunk | 22:5bc894988f11 | 177 | int wow=0; |
dragondrunk | 22:5bc894988f11 | 178 | |
dragondrunk | 22:5bc894988f11 | 179 | if(dir == 'w'&& temppic2[0] == 0){ |
dragondrunk | 22:5bc894988f11 | 180 | printf("w\n"); |
dragondrunk | 22:5bc894988f11 | 181 | for(j=0;j<8;j++){ |
dragondrunk | 22:5bc894988f11 | 182 | if(j == 7){ |
dragondrunk | 22:5bc894988f11 | 183 | forshift[7] = 0; |
dragondrunk | 22:5bc894988f11 | 184 | } |
dragondrunk | 22:5bc894988f11 | 185 | else{ |
dragondrunk | 22:5bc894988f11 | 186 | forshift[j] = temppic2[j+1]; |
dragondrunk | 22:5bc894988f11 | 187 | } |
dragondrunk | 22:5bc894988f11 | 188 | } |
dragondrunk | 22:5bc894988f11 | 189 | for(j=0;j<8;j++){ |
dragondrunk | 22:5bc894988f11 | 190 | temppic2[j] = forshift[j]; |
dragondrunk | 22:5bc894988f11 | 191 | _temppic[j] = temppic2[j]; |
dragondrunk | 22:5bc894988f11 | 192 | } |
dragondrunk | 22:5bc894988f11 | 193 | // begin to compare and combine two frame |
dragondrunk | 22:5bc894988f11 | 194 | hex_to_array(_temppic); |
dragondrunk | 22:5bc894988f11 | 195 | for(i = 0;i<8;i++){ |
dragondrunk | 22:5bc894988f11 | 196 | for(j = 0;j<8;j++){ |
dragondrunk | 22:5bc894988f11 | 197 | post1[i][j] = return_position[i][j]; |
dragondrunk | 22:5bc894988f11 | 198 | } |
dragondrunk | 22:5bc894988f11 | 199 | } |
dragondrunk | 22:5bc894988f11 | 200 | hex_to_array(pic); |
dragondrunk | 22:5bc894988f11 | 201 | for(i = 0;i<8;i++){ |
dragondrunk | 22:5bc894988f11 | 202 | for(j = 0;j<8;j++){ |
dragondrunk | 22:5bc894988f11 | 203 | post2[i][j] = return_position[i][j]; |
dragondrunk | 22:5bc894988f11 | 204 | } |
dragondrunk | 22:5bc894988f11 | 205 | } |
dragondrunk | 22:5bc894988f11 | 206 | |
dragondrunk | 22:5bc894988f11 | 207 | // begin to check boypeacemaker |
dragondrunk | 22:5bc894988f11 | 208 | ch_same_position(post1,post2); |
dragondrunk | 22:5bc894988f11 | 209 | for(i=0;i<8;i++){ |
dragondrunk | 22:5bc894988f11 | 210 | for(j=0;j<8;j++){ |
dragondrunk | 22:5bc894988f11 | 211 | get_same_position[i][j] = ch_post[i][j]; |
dragondrunk | 22:5bc894988f11 | 212 | if(get_same_position[i][j] == 1){ |
dragondrunk | 22:5bc894988f11 | 213 | wow = 1; |
dragondrunk | 22:5bc894988f11 | 214 | } |
dragondrunk | 22:5bc894988f11 | 215 | } |
dragondrunk | 22:5bc894988f11 | 216 | } |
dragondrunk | 22:5bc894988f11 | 217 | if(wow == 0){ |
dragondrunk | 22:5bc894988f11 | 218 | for(i=0;i<8;i++){_temppic[i] = temppic2[i]+pic[i];} |
dragondrunk | 22:5bc894988f11 | 219 | } |
dragondrunk | 22:5bc894988f11 | 220 | else{ |
dragondrunk | 22:5bc894988f11 | 221 | discard_same_position(post1,post2); |
dragondrunk | 22:5bc894988f11 | 222 | array_to_hex(post1); |
dragondrunk | 22:5bc894988f11 | 223 | for(i = 0;i<8;i++){ |
dragondrunk | 22:5bc894988f11 | 224 | hex_post1[i] = return_hex[i]; |
dragondrunk | 22:5bc894988f11 | 225 | } |
dragondrunk | 22:5bc894988f11 | 226 | array_to_hex(post2); |
dragondrunk | 22:5bc894988f11 | 227 | for(i = 0;i<8;i++){ |
dragondrunk | 22:5bc894988f11 | 228 | hex_post2[i] = return_hex[i]; |
dragondrunk | 22:5bc894988f11 | 229 | } |
dragondrunk | 22:5bc894988f11 | 230 | array_to_hex(get_same_position); |
dragondrunk | 22:5bc894988f11 | 231 | for(i = 0;i<8;i++){ |
dragondrunk | 22:5bc894988f11 | 232 | hex_post_cut[i] = return_hex[i]; |
dragondrunk | 22:5bc894988f11 | 233 | } |
dragondrunk | 22:5bc894988f11 | 234 | for(i = 0;i<8;i++){ |
dragondrunk | 22:5bc894988f11 | 235 | _temppic[i] = hex_post1[i] + hex_post2[i] + hex_post_cut[i]; |
dragondrunk | 22:5bc894988f11 | 236 | } |
dragondrunk | 22:5bc894988f11 | 237 | } |
dragondrunk | 22:5bc894988f11 | 238 | } |
dragondrunk | 22:5bc894988f11 | 239 | if(dir == 'a'){ |
dragondrunk | 22:5bc894988f11 | 240 | printf("a\n"); |
dragondrunk | 22:5bc894988f11 | 241 | |
dragondrunk | 22:5bc894988f11 | 242 | for(i=0;i<8;i++){ |
dragondrunk | 22:5bc894988f11 | 243 | if(temppic2[i] == 0xe0){ |
dragondrunk | 22:5bc894988f11 | 244 | check_boat3 = 1; |
dragondrunk | 22:5bc894988f11 | 245 | } |
dragondrunk | 22:5bc894988f11 | 246 | } |
dragondrunk | 22:5bc894988f11 | 247 | if(check_boat3 == 0){ |
dragondrunk | 22:5bc894988f11 | 248 | for(j=0;j<8;j++){ |
dragondrunk | 22:5bc894988f11 | 249 | if(temppic2[j] != 0){ |
dragondrunk | 22:5bc894988f11 | 250 | temppic2[j] = temppic2[j]*2; |
dragondrunk | 22:5bc894988f11 | 251 | } |
dragondrunk | 22:5bc894988f11 | 252 | else{ |
dragondrunk | 22:5bc894988f11 | 253 | temppic2[j] = 0; |
dragondrunk | 22:5bc894988f11 | 254 | } |
dragondrunk | 22:5bc894988f11 | 255 | _temppic[j] = temppic2[j]; |
dragondrunk | 22:5bc894988f11 | 256 | } |
dragondrunk | 22:5bc894988f11 | 257 | // begin to compare and combine two frame |
dragondrunk | 22:5bc894988f11 | 258 | hex_to_array(_temppic); |
dragondrunk | 22:5bc894988f11 | 259 | for(i = 0;i<8;i++){ |
dragondrunk | 22:5bc894988f11 | 260 | for(j = 0;j<8;j++){ |
dragondrunk | 22:5bc894988f11 | 261 | post1[i][j] = return_position[i][j]; |
dragondrunk | 22:5bc894988f11 | 262 | } |
dragondrunk | 22:5bc894988f11 | 263 | } |
dragondrunk | 22:5bc894988f11 | 264 | hex_to_array(pic); |
dragondrunk | 22:5bc894988f11 | 265 | for(i = 0;i<8;i++){ |
dragondrunk | 22:5bc894988f11 | 266 | for(j = 0;j<8;j++){ |
dragondrunk | 22:5bc894988f11 | 267 | post2[i][j] = return_position[i][j]; |
dragondrunk | 22:5bc894988f11 | 268 | } |
dragondrunk | 22:5bc894988f11 | 269 | } |
dragondrunk | 22:5bc894988f11 | 270 | |
dragondrunk | 22:5bc894988f11 | 271 | // begin to check boypeacemaker |
dragondrunk | 22:5bc894988f11 | 272 | ch_same_position(post1,post2); |
dragondrunk | 22:5bc894988f11 | 273 | for(i=0;i<8;i++){ |
dragondrunk | 22:5bc894988f11 | 274 | for(j=0;j<8;j++){ |
dragondrunk | 22:5bc894988f11 | 275 | get_same_position[i][j] = ch_post[i][j]; |
dragondrunk | 22:5bc894988f11 | 276 | if(get_same_position[i][j] == 1){ |
dragondrunk | 22:5bc894988f11 | 277 | wow = 1; |
dragondrunk | 22:5bc894988f11 | 278 | } |
dragondrunk | 22:5bc894988f11 | 279 | } |
dragondrunk | 22:5bc894988f11 | 280 | } |
dragondrunk | 22:5bc894988f11 | 281 | if(wow == 0){ |
dragondrunk | 22:5bc894988f11 | 282 | for(i=0;i<8;i++){_temppic[i] = temppic2[i]+pic[i];} |
dragondrunk | 22:5bc894988f11 | 283 | } |
dragondrunk | 22:5bc894988f11 | 284 | else{ |
dragondrunk | 22:5bc894988f11 | 285 | discard_same_position(post1,post2); |
dragondrunk | 22:5bc894988f11 | 286 | array_to_hex(post1); |
dragondrunk | 22:5bc894988f11 | 287 | for(i = 0;i<8;i++){ |
dragondrunk | 22:5bc894988f11 | 288 | hex_post1[i] = return_hex[i]; |
dragondrunk | 22:5bc894988f11 | 289 | } |
dragondrunk | 22:5bc894988f11 | 290 | array_to_hex(post2); |
dragondrunk | 22:5bc894988f11 | 291 | for(i = 0;i<8;i++){ |
dragondrunk | 22:5bc894988f11 | 292 | hex_post2[i] = return_hex[i]; |
dragondrunk | 22:5bc894988f11 | 293 | } |
dragondrunk | 22:5bc894988f11 | 294 | array_to_hex(get_same_position); |
dragondrunk | 22:5bc894988f11 | 295 | for(i = 0;i<8;i++){ |
dragondrunk | 22:5bc894988f11 | 296 | hex_post_cut[i] = return_hex[i]; |
dragondrunk | 22:5bc894988f11 | 297 | } |
dragondrunk | 22:5bc894988f11 | 298 | for(i = 0;i<8;i++){ |
dragondrunk | 22:5bc894988f11 | 299 | _temppic[i] = hex_post1[i] + hex_post2[i] + hex_post_cut[i]; |
dragondrunk | 22:5bc894988f11 | 300 | } |
dragondrunk | 22:5bc894988f11 | 301 | } |
dragondrunk | 22:5bc894988f11 | 302 | } |
dragondrunk | 22:5bc894988f11 | 303 | check_boat3 = 0; |
dragondrunk | 22:5bc894988f11 | 304 | } |
dragondrunk | 22:5bc894988f11 | 305 | if(dir == 'd'){ |
dragondrunk | 22:5bc894988f11 | 306 | printf("d\n"); |
dragondrunk | 22:5bc894988f11 | 307 | for(i=0;i<8;i++){ |
dragondrunk | 22:5bc894988f11 | 308 | if(temppic2[i] == 0x07){ |
dragondrunk | 22:5bc894988f11 | 309 | check_boat3 = 1; |
dragondrunk | 22:5bc894988f11 | 310 | } |
dragondrunk | 22:5bc894988f11 | 311 | } |
dragondrunk | 22:5bc894988f11 | 312 | if(check_boat3 == 0){ |
dragondrunk | 22:5bc894988f11 | 313 | for(j=0;j<8;j++){ |
dragondrunk | 22:5bc894988f11 | 314 | if(temppic2[j] != 0){ |
dragondrunk | 22:5bc894988f11 | 315 | temppic2[j] = temppic2[j]/2; |
dragondrunk | 22:5bc894988f11 | 316 | } |
dragondrunk | 22:5bc894988f11 | 317 | else{ |
dragondrunk | 22:5bc894988f11 | 318 | temppic2[j] = 0; |
dragondrunk | 22:5bc894988f11 | 319 | } |
dragondrunk | 22:5bc894988f11 | 320 | _temppic[j] = temppic2[j]; |
dragondrunk | 22:5bc894988f11 | 321 | } |
dragondrunk | 22:5bc894988f11 | 322 | // begin to compare and combine two frame |
dragondrunk | 22:5bc894988f11 | 323 | hex_to_array(_temppic); |
dragondrunk | 22:5bc894988f11 | 324 | for(i = 0;i<8;i++){ |
dragondrunk | 22:5bc894988f11 | 325 | for(j = 0;j<8;j++){ |
dragondrunk | 22:5bc894988f11 | 326 | post1[i][j] = return_position[i][j]; |
dragondrunk | 22:5bc894988f11 | 327 | } |
dragondrunk | 22:5bc894988f11 | 328 | } |
dragondrunk | 22:5bc894988f11 | 329 | hex_to_array(pic); |
dragondrunk | 22:5bc894988f11 | 330 | for(i = 0;i<8;i++){ |
dragondrunk | 22:5bc894988f11 | 331 | for(j = 0;j<8;j++){ |
dragondrunk | 22:5bc894988f11 | 332 | post2[i][j] = return_position[i][j]; |
dragondrunk | 22:5bc894988f11 | 333 | } |
dragondrunk | 22:5bc894988f11 | 334 | } |
dragondrunk | 22:5bc894988f11 | 335 | |
dragondrunk | 22:5bc894988f11 | 336 | // begin to check boypeacemaker |
dragondrunk | 22:5bc894988f11 | 337 | ch_same_position(post1,post2); |
dragondrunk | 22:5bc894988f11 | 338 | for(i=0;i<8;i++){ |
dragondrunk | 22:5bc894988f11 | 339 | for(j=0;j<8;j++){ |
dragondrunk | 22:5bc894988f11 | 340 | get_same_position[i][j] = ch_post[i][j]; |
dragondrunk | 22:5bc894988f11 | 341 | if(get_same_position[i][j] == 1){ |
dragondrunk | 22:5bc894988f11 | 342 | wow = 1; |
dragondrunk | 22:5bc894988f11 | 343 | } |
dragondrunk | 22:5bc894988f11 | 344 | } |
dragondrunk | 22:5bc894988f11 | 345 | } |
dragondrunk | 22:5bc894988f11 | 346 | if(wow == 0){ |
dragondrunk | 22:5bc894988f11 | 347 | for(i=0;i<8;i++){_temppic[i] = temppic2[i]+pic[i];} |
dragondrunk | 22:5bc894988f11 | 348 | } |
dragondrunk | 22:5bc894988f11 | 349 | else{ |
dragondrunk | 22:5bc894988f11 | 350 | discard_same_position(post1,post2); |
dragondrunk | 22:5bc894988f11 | 351 | array_to_hex(post1); |
dragondrunk | 22:5bc894988f11 | 352 | for(i = 0;i<8;i++){ |
dragondrunk | 22:5bc894988f11 | 353 | hex_post1[i] = return_hex[i]; |
dragondrunk | 22:5bc894988f11 | 354 | } |
dragondrunk | 22:5bc894988f11 | 355 | array_to_hex(post2); |
dragondrunk | 22:5bc894988f11 | 356 | for(i = 0;i<8;i++){ |
dragondrunk | 22:5bc894988f11 | 357 | hex_post2[i] = return_hex[i]; |
dragondrunk | 22:5bc894988f11 | 358 | } |
dragondrunk | 22:5bc894988f11 | 359 | array_to_hex(get_same_position); |
dragondrunk | 22:5bc894988f11 | 360 | for(i = 0;i<8;i++){ |
dragondrunk | 22:5bc894988f11 | 361 | hex_post_cut[i] = return_hex[i]; |
dragondrunk | 22:5bc894988f11 | 362 | } |
dragondrunk | 22:5bc894988f11 | 363 | for(i = 0;i<8;i++){ |
dragondrunk | 22:5bc894988f11 | 364 | _temppic[i] = hex_post1[i] + hex_post2[i] + hex_post_cut[i]; |
dragondrunk | 22:5bc894988f11 | 365 | } |
dragondrunk | 22:5bc894988f11 | 366 | } |
dragondrunk | 22:5bc894988f11 | 367 | } |
dragondrunk | 22:5bc894988f11 | 368 | check_boat3 = 0; |
dragondrunk | 22:5bc894988f11 | 369 | } |
dragondrunk | 22:5bc894988f11 | 370 | if(dir == 's' && temppic2[7] == 0){ |
dragondrunk | 22:5bc894988f11 | 371 | printf("s\n"); |
dragondrunk | 22:5bc894988f11 | 372 | for(j=0;j<8;j++){ |
dragondrunk | 22:5bc894988f11 | 373 | if(j == 0){ |
dragondrunk | 22:5bc894988f11 | 374 | forshift[0] = 0; |
dragondrunk | 22:5bc894988f11 | 375 | } |
dragondrunk | 22:5bc894988f11 | 376 | else{ |
dragondrunk | 22:5bc894988f11 | 377 | forshift[j] = temppic2[j-1]; |
dragondrunk | 22:5bc894988f11 | 378 | } |
dragondrunk | 22:5bc894988f11 | 379 | } |
dragondrunk | 22:5bc894988f11 | 380 | for(j=0;j<8;j++){ |
dragondrunk | 22:5bc894988f11 | 381 | temppic2[j] = forshift[j]; |
dragondrunk | 22:5bc894988f11 | 382 | _temppic[j] = temppic2[j]; |
dragondrunk | 22:5bc894988f11 | 383 | } |
dragondrunk | 22:5bc894988f11 | 384 | // begin to compare and combine two frame |
dragondrunk | 22:5bc894988f11 | 385 | hex_to_array(_temppic); |
dragondrunk | 22:5bc894988f11 | 386 | for(i = 0;i<8;i++){ |
dragondrunk | 22:5bc894988f11 | 387 | for(j = 0;j<8;j++){ |
dragondrunk | 22:5bc894988f11 | 388 | post1[i][j] = return_position[i][j]; |
dragondrunk | 22:5bc894988f11 | 389 | } |
dragondrunk | 22:5bc894988f11 | 390 | } |
dragondrunk | 22:5bc894988f11 | 391 | hex_to_array(pic); |
dragondrunk | 22:5bc894988f11 | 392 | for(i = 0;i<8;i++){ |
dragondrunk | 22:5bc894988f11 | 393 | for(j = 0;j<8;j++){ |
dragondrunk | 22:5bc894988f11 | 394 | post2[i][j] = return_position[i][j]; |
dragondrunk | 22:5bc894988f11 | 395 | } |
dragondrunk | 22:5bc894988f11 | 396 | } |
dragondrunk | 22:5bc894988f11 | 397 | |
dragondrunk | 22:5bc894988f11 | 398 | // begin to check boypeacemaker |
dragondrunk | 22:5bc894988f11 | 399 | ch_same_position(post1,post2); |
dragondrunk | 22:5bc894988f11 | 400 | for(i=0;i<8;i++){ |
dragondrunk | 22:5bc894988f11 | 401 | for(j=0;j<8;j++){ |
dragondrunk | 22:5bc894988f11 | 402 | get_same_position[i][j] = ch_post[i][j]; |
dragondrunk | 22:5bc894988f11 | 403 | if(get_same_position[i][j] == 1){ |
dragondrunk | 22:5bc894988f11 | 404 | wow = 1; |
dragondrunk | 22:5bc894988f11 | 405 | } |
dragondrunk | 22:5bc894988f11 | 406 | } |
dragondrunk | 22:5bc894988f11 | 407 | } |
dragondrunk | 22:5bc894988f11 | 408 | if(wow == 0){ |
dragondrunk | 22:5bc894988f11 | 409 | for(i=0;i<8;i++){_temppic[i] = temppic2[i]+pic[i];} |
dragondrunk | 22:5bc894988f11 | 410 | } |
dragondrunk | 22:5bc894988f11 | 411 | else{ |
dragondrunk | 22:5bc894988f11 | 412 | discard_same_position(post1,post2); |
dragondrunk | 22:5bc894988f11 | 413 | array_to_hex(post1); |
dragondrunk | 22:5bc894988f11 | 414 | for(i = 0;i<8;i++){ |
dragondrunk | 22:5bc894988f11 | 415 | hex_post1[i] = return_hex[i]; |
dragondrunk | 22:5bc894988f11 | 416 | } |
dragondrunk | 22:5bc894988f11 | 417 | array_to_hex(post2); |
dragondrunk | 22:5bc894988f11 | 418 | for(i = 0;i<8;i++){ |
dragondrunk | 22:5bc894988f11 | 419 | hex_post2[i] = return_hex[i]; |
dragondrunk | 22:5bc894988f11 | 420 | } |
dragondrunk | 22:5bc894988f11 | 421 | array_to_hex(get_same_position); |
dragondrunk | 22:5bc894988f11 | 422 | for(i = 0;i<8;i++){ |
dragondrunk | 22:5bc894988f11 | 423 | hex_post_cut[i] = return_hex[i]; |
dragondrunk | 22:5bc894988f11 | 424 | } |
dragondrunk | 22:5bc894988f11 | 425 | for(i = 0;i<8;i++){ |
dragondrunk | 22:5bc894988f11 | 426 | _temppic[i] = hex_post1[i] + hex_post2[i] + hex_post_cut[i]; |
dragondrunk | 22:5bc894988f11 | 427 | } |
dragondrunk | 22:5bc894988f11 | 428 | } |
dragondrunk | 22:5bc894988f11 | 429 | |
dragondrunk | 22:5bc894988f11 | 430 | } |
dragondrunk | 22:5bc894988f11 | 431 | } |
dragondrunk | 22:5bc894988f11 | 432 | // ******************************************************************** ship 2 channal ****************************************************************** |
dragondrunk | 22:5bc894988f11 | 433 | void place_ship2_4(int ship,char dir){ |
dragondrunk | 22:5bc894988f11 | 434 | |
dragondrunk | 22:5bc894988f11 | 435 | int post1[8][8] = {0}; |
dragondrunk | 22:5bc894988f11 | 436 | int post2[8][8] = {0}; |
dragondrunk | 22:5bc894988f11 | 437 | int hex_post1[8] = {0}; |
dragondrunk | 22:5bc894988f11 | 438 | int hex_post2[8] = {0}; |
dragondrunk | 22:5bc894988f11 | 439 | int hex_post_cut[8] = {0}; |
dragondrunk | 22:5bc894988f11 | 440 | int get_same_position[8][8]; |
dragondrunk | 22:5bc894988f11 | 441 | int wow=0; |
dragondrunk | 22:5bc894988f11 | 442 | |
dragondrunk | 22:5bc894988f11 | 443 | if(dir == 'w'&& temppic3[ship][0] == 0){ |
dragondrunk | 22:5bc894988f11 | 444 | printf("w\n"); |
dragondrunk | 22:5bc894988f11 | 445 | for(j=0;j<8;j++){ |
dragondrunk | 22:5bc894988f11 | 446 | if(j == 7){ |
dragondrunk | 22:5bc894988f11 | 447 | forshift[7] = 0; |
dragondrunk | 22:5bc894988f11 | 448 | } |
dragondrunk | 22:5bc894988f11 | 449 | else{ |
dragondrunk | 22:5bc894988f11 | 450 | forshift[j] = temppic3[ship][j+1]; |
dragondrunk | 22:5bc894988f11 | 451 | } |
dragondrunk | 22:5bc894988f11 | 452 | } |
dragondrunk | 22:5bc894988f11 | 453 | for(j=0;j<8;j++){ |
dragondrunk | 22:5bc894988f11 | 454 | temppic3[ship][j] = forshift[j]; |
dragondrunk | 22:5bc894988f11 | 455 | _temppic[j] = temppic3[ship][j]; |
dragondrunk | 22:5bc894988f11 | 456 | } |
dragondrunk | 22:5bc894988f11 | 457 | // begin to compare and combine two frame |
dragondrunk | 22:5bc894988f11 | 458 | hex_to_array(_temppic); |
dragondrunk | 22:5bc894988f11 | 459 | for(i = 0;i<8;i++){ |
dragondrunk | 22:5bc894988f11 | 460 | for(j = 0;j<8;j++){ |
dragondrunk | 22:5bc894988f11 | 461 | post1[i][j] = return_position[i][j]; |
dragondrunk | 22:5bc894988f11 | 462 | } |
dragondrunk | 22:5bc894988f11 | 463 | } |
dragondrunk | 22:5bc894988f11 | 464 | hex_to_array(pic); |
dragondrunk | 22:5bc894988f11 | 465 | for(i = 0;i<8;i++){ |
dragondrunk | 22:5bc894988f11 | 466 | for(j = 0;j<8;j++){ |
dragondrunk | 22:5bc894988f11 | 467 | post2[i][j] = return_position[i][j]; |
dragondrunk | 22:5bc894988f11 | 468 | } |
dragondrunk | 22:5bc894988f11 | 469 | } |
dragondrunk | 22:5bc894988f11 | 470 | |
dragondrunk | 22:5bc894988f11 | 471 | // begin to check boypeacemaker |
dragondrunk | 22:5bc894988f11 | 472 | ch_same_position(post1,post2); |
dragondrunk | 22:5bc894988f11 | 473 | for(i=0;i<8;i++){ |
dragondrunk | 22:5bc894988f11 | 474 | for(j=0;j<8;j++){ |
dragondrunk | 22:5bc894988f11 | 475 | get_same_position[i][j] = ch_post[i][j]; |
dragondrunk | 22:5bc894988f11 | 476 | if(get_same_position[i][j] == 1){ |
dragondrunk | 22:5bc894988f11 | 477 | wow = 1; |
dragondrunk | 22:5bc894988f11 | 478 | } |
dragondrunk | 22:5bc894988f11 | 479 | } |
dragondrunk | 22:5bc894988f11 | 480 | } |
dragondrunk | 22:5bc894988f11 | 481 | if(wow == 0){ |
dragondrunk | 22:5bc894988f11 | 482 | for(i=0;i<8;i++){_temppic[i] = temppic3[ship][i]+pic[i];} |
dragondrunk | 22:5bc894988f11 | 483 | } |
dragondrunk | 22:5bc894988f11 | 484 | else{ |
dragondrunk | 22:5bc894988f11 | 485 | discard_same_position(post1,post2); |
dragondrunk | 22:5bc894988f11 | 486 | array_to_hex(post1); |
dragondrunk | 22:5bc894988f11 | 487 | for(i = 0;i<8;i++){ |
dragondrunk | 22:5bc894988f11 | 488 | hex_post1[i] = return_hex[i]; |
dragondrunk | 22:5bc894988f11 | 489 | } |
dragondrunk | 22:5bc894988f11 | 490 | array_to_hex(post2); |
dragondrunk | 22:5bc894988f11 | 491 | for(i = 0;i<8;i++){ |
dragondrunk | 22:5bc894988f11 | 492 | hex_post2[i] = return_hex[i]; |
dragondrunk | 22:5bc894988f11 | 493 | } |
dragondrunk | 22:5bc894988f11 | 494 | array_to_hex(get_same_position); |
dragondrunk | 22:5bc894988f11 | 495 | for(i = 0;i<8;i++){ |
dragondrunk | 22:5bc894988f11 | 496 | hex_post_cut[i] = return_hex[i]; |
dragondrunk | 22:5bc894988f11 | 497 | } |
dragondrunk | 22:5bc894988f11 | 498 | for(i = 0;i<8;i++){ |
dragondrunk | 22:5bc894988f11 | 499 | _temppic[i] = hex_post1[i] + hex_post2[i] + hex_post_cut[i]; |
dragondrunk | 22:5bc894988f11 | 500 | } |
dragondrunk | 22:5bc894988f11 | 501 | } |
dragondrunk | 22:5bc894988f11 | 502 | |
dragondrunk | 22:5bc894988f11 | 503 | } |
dragondrunk | 22:5bc894988f11 | 504 | if(dir == 'a' && temppic3[ship][3] != 0x80 && temppic3[ship][4] != 0x80 ){ |
dragondrunk | 22:5bc894988f11 | 505 | printf("a\n"); |
dragondrunk | 22:5bc894988f11 | 506 | for(j=0;j<8;j++){ |
dragondrunk | 22:5bc894988f11 | 507 | if(temppic3[j] != 0){ |
dragondrunk | 22:5bc894988f11 | 508 | temppic3[ship][j] = temppic3[ship][j]*2; |
dragondrunk | 22:5bc894988f11 | 509 | } |
dragondrunk | 22:5bc894988f11 | 510 | else{ |
dragondrunk | 22:5bc894988f11 | 511 | temppic3[ship][j] = 0; |
dragondrunk | 22:5bc894988f11 | 512 | } |
dragondrunk | 22:5bc894988f11 | 513 | _temppic[j] = temppic3[ship][j]; |
dragondrunk | 22:5bc894988f11 | 514 | } |
dragondrunk | 22:5bc894988f11 | 515 | // begin to compare and combine two frame |
dragondrunk | 22:5bc894988f11 | 516 | hex_to_array(_temppic); |
dragondrunk | 22:5bc894988f11 | 517 | for(i = 0;i<8;i++){ |
dragondrunk | 22:5bc894988f11 | 518 | for(j = 0;j<8;j++){ |
dragondrunk | 22:5bc894988f11 | 519 | post1[i][j] = return_position[i][j]; |
dragondrunk | 22:5bc894988f11 | 520 | } |
dragondrunk | 22:5bc894988f11 | 521 | } |
dragondrunk | 22:5bc894988f11 | 522 | hex_to_array(pic); |
dragondrunk | 22:5bc894988f11 | 523 | for(i = 0;i<8;i++){ |
dragondrunk | 22:5bc894988f11 | 524 | for(j = 0;j<8;j++){ |
dragondrunk | 22:5bc894988f11 | 525 | post2[i][j] = return_position[i][j]; |
dragondrunk | 22:5bc894988f11 | 526 | } |
dragondrunk | 22:5bc894988f11 | 527 | } |
dragondrunk | 22:5bc894988f11 | 528 | |
dragondrunk | 22:5bc894988f11 | 529 | // begin to check boypeacemaker |
dragondrunk | 22:5bc894988f11 | 530 | ch_same_position(post1,post2); |
dragondrunk | 22:5bc894988f11 | 531 | for(i=0;i<8;i++){ |
dragondrunk | 22:5bc894988f11 | 532 | for(j=0;j<8;j++){ |
dragondrunk | 22:5bc894988f11 | 533 | get_same_position[i][j] = ch_post[i][j]; |
dragondrunk | 22:5bc894988f11 | 534 | if(get_same_position[i][j] == 1){ |
dragondrunk | 22:5bc894988f11 | 535 | wow = 1; |
dragondrunk | 22:5bc894988f11 | 536 | } |
dragondrunk | 22:5bc894988f11 | 537 | } |
dragondrunk | 22:5bc894988f11 | 538 | } |
dragondrunk | 22:5bc894988f11 | 539 | if(wow == 0){ |
dragondrunk | 22:5bc894988f11 | 540 | for(i=0;i<8;i++){_temppic[i] = temppic3[ship][i]+pic[i];} |
dragondrunk | 22:5bc894988f11 | 541 | } |
dragondrunk | 22:5bc894988f11 | 542 | else{ |
dragondrunk | 22:5bc894988f11 | 543 | discard_same_position(post1,post2); |
dragondrunk | 22:5bc894988f11 | 544 | array_to_hex(post1); |
dragondrunk | 22:5bc894988f11 | 545 | for(i = 0;i<8;i++){ |
dragondrunk | 22:5bc894988f11 | 546 | hex_post1[i] = return_hex[i]; |
dragondrunk | 22:5bc894988f11 | 547 | } |
dragondrunk | 22:5bc894988f11 | 548 | array_to_hex(post2); |
dragondrunk | 22:5bc894988f11 | 549 | for(i = 0;i<8;i++){ |
dragondrunk | 22:5bc894988f11 | 550 | hex_post2[i] = return_hex[i]; |
dragondrunk | 22:5bc894988f11 | 551 | } |
dragondrunk | 22:5bc894988f11 | 552 | array_to_hex(get_same_position); |
dragondrunk | 22:5bc894988f11 | 553 | for(i = 0;i<8;i++){ |
dragondrunk | 22:5bc894988f11 | 554 | hex_post_cut[i] = return_hex[i]; |
dragondrunk | 22:5bc894988f11 | 555 | } |
dragondrunk | 22:5bc894988f11 | 556 | for(i = 0;i<8;i++){ |
dragondrunk | 22:5bc894988f11 | 557 | _temppic[i] = hex_post1[i] + hex_post2[i] + hex_post_cut[i]; |
dragondrunk | 22:5bc894988f11 | 558 | } |
dragondrunk | 22:5bc894988f11 | 559 | } |
dragondrunk | 22:5bc894988f11 | 560 | |
dragondrunk | 22:5bc894988f11 | 561 | } |
dragondrunk | 22:5bc894988f11 | 562 | if(dir == 'd' && temppic3[ship][3] != 0x01 && temppic3[ship][4] != 0x01 ){ |
dragondrunk | 22:5bc894988f11 | 563 | printf("d\n"); |
dragondrunk | 22:5bc894988f11 | 564 | for(j=0;j<8;j++){ |
dragondrunk | 22:5bc894988f11 | 565 | if(temppic3[ship][j] != 0){ |
dragondrunk | 22:5bc894988f11 | 566 | temppic3[ship][j] = temppic3[ship][j]/2; |
dragondrunk | 22:5bc894988f11 | 567 | } |
dragondrunk | 22:5bc894988f11 | 568 | else{ |
dragondrunk | 22:5bc894988f11 | 569 | temppic3[ship][j] = 0; |
dragondrunk | 22:5bc894988f11 | 570 | } |
dragondrunk | 22:5bc894988f11 | 571 | _temppic[j] = temppic3[ship][j]; |
dragondrunk | 22:5bc894988f11 | 572 | } |
dragondrunk | 22:5bc894988f11 | 573 | // begin to compare and combine two frame |
dragondrunk | 22:5bc894988f11 | 574 | hex_to_array(_temppic); |
dragondrunk | 22:5bc894988f11 | 575 | for(i = 0;i<8;i++){ |
dragondrunk | 22:5bc894988f11 | 576 | for(j = 0;j<8;j++){ |
dragondrunk | 22:5bc894988f11 | 577 | post1[i][j] = return_position[i][j]; |
dragondrunk | 22:5bc894988f11 | 578 | } |
dragondrunk | 22:5bc894988f11 | 579 | } |
dragondrunk | 22:5bc894988f11 | 580 | hex_to_array(pic); |
dragondrunk | 22:5bc894988f11 | 581 | for(i = 0;i<8;i++){ |
dragondrunk | 22:5bc894988f11 | 582 | for(j = 0;j<8;j++){ |
dragondrunk | 22:5bc894988f11 | 583 | post2[i][j] = return_position[i][j]; |
dragondrunk | 22:5bc894988f11 | 584 | } |
dragondrunk | 22:5bc894988f11 | 585 | } |
dragondrunk | 22:5bc894988f11 | 586 | |
dragondrunk | 22:5bc894988f11 | 587 | // begin to check boypeacemaker |
dragondrunk | 22:5bc894988f11 | 588 | ch_same_position(post1,post2); |
dragondrunk | 22:5bc894988f11 | 589 | for(i=0;i<8;i++){ |
dragondrunk | 22:5bc894988f11 | 590 | for(j=0;j<8;j++){ |
dragondrunk | 22:5bc894988f11 | 591 | get_same_position[i][j] = ch_post[i][j]; |
dragondrunk | 22:5bc894988f11 | 592 | if(get_same_position[i][j] == 1){ |
dragondrunk | 22:5bc894988f11 | 593 | wow = 1; |
dragondrunk | 22:5bc894988f11 | 594 | } |
dragondrunk | 22:5bc894988f11 | 595 | } |
dragondrunk | 22:5bc894988f11 | 596 | } |
dragondrunk | 22:5bc894988f11 | 597 | if(wow == 0){ |
dragondrunk | 22:5bc894988f11 | 598 | for(i=0;i<8;i++){_temppic[i] = temppic3[ship][i]+pic[i];} |
dragondrunk | 22:5bc894988f11 | 599 | } |
dragondrunk | 22:5bc894988f11 | 600 | else{ |
dragondrunk | 22:5bc894988f11 | 601 | discard_same_position(post1,post2); |
dragondrunk | 22:5bc894988f11 | 602 | array_to_hex(post1); |
dragondrunk | 22:5bc894988f11 | 603 | for(i = 0;i<8;i++){ |
dragondrunk | 22:5bc894988f11 | 604 | hex_post1[i] = return_hex[i]; |
dragondrunk | 22:5bc894988f11 | 605 | } |
dragondrunk | 22:5bc894988f11 | 606 | array_to_hex(post2); |
dragondrunk | 22:5bc894988f11 | 607 | for(i = 0;i<8;i++){ |
dragondrunk | 22:5bc894988f11 | 608 | hex_post2[i] = return_hex[i]; |
dragondrunk | 22:5bc894988f11 | 609 | } |
dragondrunk | 22:5bc894988f11 | 610 | array_to_hex(get_same_position); |
dragondrunk | 22:5bc894988f11 | 611 | for(i = 0;i<8;i++){ |
dragondrunk | 22:5bc894988f11 | 612 | hex_post_cut[i] = return_hex[i]; |
dragondrunk | 22:5bc894988f11 | 613 | } |
dragondrunk | 22:5bc894988f11 | 614 | for(i = 0;i<8;i++){ |
dragondrunk | 22:5bc894988f11 | 615 | _temppic[i] = hex_post1[i] + hex_post2[i] + hex_post_cut[i]; |
dragondrunk | 22:5bc894988f11 | 616 | } |
dragondrunk | 22:5bc894988f11 | 617 | } |
dragondrunk | 22:5bc894988f11 | 618 | |
dragondrunk | 22:5bc894988f11 | 619 | } |
dragondrunk | 22:5bc894988f11 | 620 | if(dir == 's' && temppic3[ship][7] == 0){ |
dragondrunk | 22:5bc894988f11 | 621 | printf("s\n"); |
dragondrunk | 22:5bc894988f11 | 622 | for(j=0;j<8;j++){ |
dragondrunk | 22:5bc894988f11 | 623 | if(j == 0){ |
dragondrunk | 22:5bc894988f11 | 624 | forshift[0] = 0; |
dragondrunk | 22:5bc894988f11 | 625 | } |
dragondrunk | 22:5bc894988f11 | 626 | else{ |
dragondrunk | 22:5bc894988f11 | 627 | forshift[j] = temppic3[ship][j-1]; |
dragondrunk | 22:5bc894988f11 | 628 | } |
dragondrunk | 22:5bc894988f11 | 629 | } |
dragondrunk | 22:5bc894988f11 | 630 | for(j=0;j<8;j++){ |
dragondrunk | 22:5bc894988f11 | 631 | temppic3[ship][j] = forshift[j]; |
dragondrunk | 22:5bc894988f11 | 632 | _temppic[j] = temppic3[ship][j]; |
dragondrunk | 22:5bc894988f11 | 633 | } |
dragondrunk | 22:5bc894988f11 | 634 | // begin to compare and combine two frame |
dragondrunk | 22:5bc894988f11 | 635 | hex_to_array(_temppic); |
dragondrunk | 22:5bc894988f11 | 636 | for(i = 0;i<8;i++){ |
dragondrunk | 22:5bc894988f11 | 637 | for(j = 0;j<8;j++){ |
dragondrunk | 22:5bc894988f11 | 638 | post1[i][j] = return_position[i][j]; |
dragondrunk | 22:5bc894988f11 | 639 | } |
dragondrunk | 22:5bc894988f11 | 640 | } |
dragondrunk | 22:5bc894988f11 | 641 | hex_to_array(pic); |
dragondrunk | 22:5bc894988f11 | 642 | for(i = 0;i<8;i++){ |
dragondrunk | 22:5bc894988f11 | 643 | for(j = 0;j<8;j++){ |
dragondrunk | 22:5bc894988f11 | 644 | post2[i][j] = return_position[i][j]; |
dragondrunk | 22:5bc894988f11 | 645 | } |
dragondrunk | 22:5bc894988f11 | 646 | } |
dragondrunk | 22:5bc894988f11 | 647 | |
dragondrunk | 22:5bc894988f11 | 648 | // begin to check boypeacemaker |
dragondrunk | 22:5bc894988f11 | 649 | ch_same_position(post1,post2); |
dragondrunk | 22:5bc894988f11 | 650 | for(i=0;i<8;i++){ |
dragondrunk | 22:5bc894988f11 | 651 | for(j=0;j<8;j++){ |
dragondrunk | 22:5bc894988f11 | 652 | get_same_position[i][j] = ch_post[i][j]; |
dragondrunk | 22:5bc894988f11 | 653 | if(get_same_position[i][j] == 1){ |
dragondrunk | 22:5bc894988f11 | 654 | wow = 1; |
dragondrunk | 22:5bc894988f11 | 655 | } |
dragondrunk | 22:5bc894988f11 | 656 | } |
dragondrunk | 22:5bc894988f11 | 657 | } |
dragondrunk | 22:5bc894988f11 | 658 | if(wow == 0){ |
dragondrunk | 22:5bc894988f11 | 659 | for(i=0;i<8;i++){_temppic[i] = temppic3[ship][i]+pic[i];} |
dragondrunk | 22:5bc894988f11 | 660 | } |
dragondrunk | 22:5bc894988f11 | 661 | else{ |
dragondrunk | 22:5bc894988f11 | 662 | discard_same_position(post1,post2); |
dragondrunk | 22:5bc894988f11 | 663 | array_to_hex(post1); |
dragondrunk | 22:5bc894988f11 | 664 | for(i = 0;i<8;i++){ |
dragondrunk | 22:5bc894988f11 | 665 | hex_post1[i] = return_hex[i]; |
dragondrunk | 22:5bc894988f11 | 666 | } |
dragondrunk | 22:5bc894988f11 | 667 | array_to_hex(post2); |
dragondrunk | 22:5bc894988f11 | 668 | for(i = 0;i<8;i++){ |
dragondrunk | 22:5bc894988f11 | 669 | hex_post2[i] = return_hex[i]; |
dragondrunk | 22:5bc894988f11 | 670 | } |
dragondrunk | 22:5bc894988f11 | 671 | array_to_hex(get_same_position); |
dragondrunk | 22:5bc894988f11 | 672 | for(i = 0;i<8;i++){ |
dragondrunk | 22:5bc894988f11 | 673 | hex_post_cut[i] = return_hex[i]; |
dragondrunk | 22:5bc894988f11 | 674 | } |
dragondrunk | 22:5bc894988f11 | 675 | for(i = 0;i<8;i++){ |
dragondrunk | 22:5bc894988f11 | 676 | _temppic[i] = hex_post1[i] + hex_post2[i] + hex_post_cut[i]; |
dragondrunk | 22:5bc894988f11 | 677 | } |
dragondrunk | 22:5bc894988f11 | 678 | } |
dragondrunk | 22:5bc894988f11 | 679 | |
dragondrunk | 22:5bc894988f11 | 680 | } |
dragondrunk | 22:5bc894988f11 | 681 | } |
dragondrunk | 22:5bc894988f11 | 682 | |
dragondrunk | 22:5bc894988f11 | 683 | |
dragondrunk | 22:5bc894988f11 | 684 | // function Test! |
dragondrunk | 22:5bc894988f11 | 685 | |
gunpuen2 | 0:a8e057156263 | 686 | int main(){ //-------------------------------------------------------------------Main Function. |
gunpuen2 | 15:5902cf545449 | 687 | bt.baud(9600); |
gunpuen2 | 0:a8e057156263 | 688 | float Vx; |
gunpuen2 | 0:a8e057156263 | 689 | float Vy; |
gunpuen2 | 19:d78586719868 | 690 | int SW,iVxVy,iSW,n = 0; |
gunpuen2 | 18:ecef8382d41e | 691 | int uli = 0; |
gunpuen2 | 0:a8e057156263 | 692 | char m; |
dragondrunk | 22:5bc894988f11 | 693 | int rgb[3] = {10,0,0}; |
dragondrunk | 22:5bc894988f11 | 694 | int state_place_ship = 0; |
dragondrunk | 22:5bc894988f11 | 695 | dotmatrix.init(); |
gunpuen2 | 14:8abed4026326 | 696 | |
gunpuen2 | 0:a8e057156263 | 697 | while(1) { |
dragondrunk | 22:5bc894988f11 | 698 | dotmatrix.display_pic(_temppic,rgb); |
gunpuen2 | 0:a8e057156263 | 699 | if(iShipType<8){ |
gunpuen2 | 0:a8e057156263 | 700 | Vx = VRx.read() * 1024; |
gunpuen2 | 0:a8e057156263 | 701 | Vy = VRy.read() * 1024; |
gunpuen2 | 0:a8e057156263 | 702 | SW = Button.read(); |
gunpuen2 | 0:a8e057156263 | 703 | m = check_joys(Vx,Vy); |
gunpuen2 | 0:a8e057156263 | 704 | n = check_joys_int(Vx,Vy); |
gunpuen2 | 0:a8e057156263 | 705 | if(n == 1){ //_______________________________________________________ For make sure coordinate is press 1 time. |
gunpuen2 | 0:a8e057156263 | 706 | iVxVy = 0; |
gunpuen2 | 0:a8e057156263 | 707 | check_ready(); |
gunpuen2 | 0:a8e057156263 | 708 | } |
gunpuen2 | 0:a8e057156263 | 709 | if(SW == 1){ //______________________________________________________ For make sure switch is press 1 time. |
gunpuen2 | 0:a8e057156263 | 710 | iSW = 0; |
gunpuen2 | 0:a8e057156263 | 711 | check_ready(); |
gunpuen2 | 0:a8e057156263 | 712 | } |
gunpuen2 | 0:a8e057156263 | 713 | if(m!=NULL && iVxVy==0){ //__________________________________________ Get position that wait for press switch. |
gunpuen2 | 0:a8e057156263 | 714 | Select_Position(m); |
dragondrunk | 22:5bc894988f11 | 715 | if(state_place_ship == 0){ |
dragondrunk | 22:5bc894988f11 | 716 | place_ship2_4(0,m); |
dragondrunk | 22:5bc894988f11 | 717 | } |
dragondrunk | 22:5bc894988f11 | 718 | else if(state_place_ship == 1){ |
dragondrunk | 22:5bc894988f11 | 719 | place_ship3(m); |
dragondrunk | 22:5bc894988f11 | 720 | } |
dragondrunk | 22:5bc894988f11 | 721 | else if(state_place_ship == 2){ |
dragondrunk | 22:5bc894988f11 | 722 | place_ship2_4(1,m); |
dragondrunk | 22:5bc894988f11 | 723 | } |
dragondrunk | 22:5bc894988f11 | 724 | else if(state_place_ship == 3 || state_place_ship == 4){ |
dragondrunk | 22:5bc894988f11 | 725 | place_ship2_4(2,m); |
dragondrunk | 22:5bc894988f11 | 726 | } |
gunpuen2 | 15:5902cf545449 | 727 | printf("select_Position = %d\n",select_Position); |
gunpuen2 | 0:a8e057156263 | 728 | check_ready(); |
gunpuen2 | 0:a8e057156263 | 729 | iVxVy = 1; |
gunpuen2 | 3:baff75bbb78e | 730 | check_ready(); |
gunpuen2 | 0:a8e057156263 | 731 | } |
gunpuen2 | 0:a8e057156263 | 732 | if(SW==0 && iSW==0){ //______________________________________________If switch pressing by human. |
gunpuen2 | 0:a8e057156263 | 733 | printf("Wait!\n"); |
dragondrunk | 22:5bc894988f11 | 734 | |
gunpuen2 | 0:a8e057156263 | 735 | check_ready(); |
gunpuen2 | 15:5902cf545449 | 736 | if(get_ship_platform(select_Position,ship_SelectType[iShipType])==0){ //__Please read explanation in function get_ship_platform. |
gunpuen2 | 0:a8e057156263 | 737 | printf("Please input correct position\n"); |
gunpuen2 | 0:a8e057156263 | 738 | }else{ |
gunpuen2 | 0:a8e057156263 | 739 | iShipType++; |
dragondrunk | 22:5bc894988f11 | 740 | if(state_place_ship == 0){ |
dragondrunk | 22:5bc894988f11 | 741 | for(j=0;j<8;j++){ |
dragondrunk | 22:5bc894988f11 | 742 | pic[j] = temppic3[0][j]+pic[j]; |
dragondrunk | 22:5bc894988f11 | 743 | } |
dragondrunk | 22:5bc894988f11 | 744 | } |
dragondrunk | 22:5bc894988f11 | 745 | else if(state_place_ship == 1){ |
dragondrunk | 22:5bc894988f11 | 746 | for(j=0;j<8;j++){ |
dragondrunk | 22:5bc894988f11 | 747 | pic[j] = temppic2[j]+pic[j]; |
dragondrunk | 22:5bc894988f11 | 748 | } |
dragondrunk | 22:5bc894988f11 | 749 | } |
dragondrunk | 22:5bc894988f11 | 750 | else if(state_place_ship == 2 || state_place_ship == 3){ |
dragondrunk | 22:5bc894988f11 | 751 | for(j=0;j<8;j++){ |
dragondrunk | 22:5bc894988f11 | 752 | pic[j] = temppic2[j]+pic[j]; |
dragondrunk | 22:5bc894988f11 | 753 | } |
dragondrunk | 22:5bc894988f11 | 754 | } |
dragondrunk | 22:5bc894988f11 | 755 | |
dragondrunk | 22:5bc894988f11 | 756 | else if(state_place_ship == 4 || state_place_ship == 5 || state_place_ship == 6 || state_place_ship == 7){ |
dragondrunk | 22:5bc894988f11 | 757 | for(j=0;j<8;j++){ |
dragondrunk | 22:5bc894988f11 | 758 | pic[j] = temppic2[j]+pic[j]; |
dragondrunk | 22:5bc894988f11 | 759 | } |
dragondrunk | 22:5bc894988f11 | 760 | } |
dragondrunk | 22:5bc894988f11 | 761 | state_place_ship = state_place_ship + 1; |
gunpuen2 | 0:a8e057156263 | 762 | } |
gunpuen2 | 0:a8e057156263 | 763 | check_ready(); |
gunpuen2 | 0:a8e057156263 | 764 | iSW = 1; |
gunpuen2 | 6:7f99124272d9 | 765 | print_ship_platform(); |
gunpuen2 | 3:baff75bbb78e | 766 | check_ready(); |
gunpuen2 | 0:a8e057156263 | 767 | } |
gunpuen2 | 0:a8e057156263 | 768 | }else{ |
gunpuen2 | 3:baff75bbb78e | 769 | if(enemy_ready!=1){ |
gunpuen2 | 3:baff75bbb78e | 770 | printf("sent E\n"); |
gunpuen2 | 12:287c6a9560ca | 771 | while(uli<50){ |
gunpuen2 | 4:8a86bacddcac | 772 | bt.printf("E"); |
gunpuen2 | 3:baff75bbb78e | 773 | uli++; |
gunpuen2 | 3:baff75bbb78e | 774 | } |
gunpuen2 | 12:287c6a9560ca | 775 | }else{ |
gunpuen2 | 12:287c6a9560ca | 776 | bt.putc('l'); |
gunpuen2 | 3:baff75bbb78e | 777 | } |
gunpuen2 | 0:a8e057156263 | 778 | printf("\n"); |
gunpuen2 | 0:a8e057156263 | 779 | break; |
gunpuen2 | 0:a8e057156263 | 780 | } |
gunpuen2 | 0:a8e057156263 | 781 | } |
gunpuen2 | 12:287c6a9560ca | 782 | if(enemy_ready == 0){ |
gunpuen2 | 12:287c6a9560ca | 783 | printf("Wait for enemy\n"); |
gunpuen2 | 12:287c6a9560ca | 784 | while(1){if(bt.readable()){if(bt.getc()=='l'){break;}}} |
gunpuen2 | 12:287c6a9560ca | 785 | state = 0; |
gunpuen2 | 12:287c6a9560ca | 786 | }else{state = 1;} |
gunpuen2 | 19:d78586719868 | 787 | wait(5); |
gunpuen2 | 12:287c6a9560ca | 788 | while(1) { //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Play |
gunpuen2 | 1:6157c77da3d5 | 789 | if(state == 0){ |
gunpuen2 | 6:7f99124272d9 | 790 | atk_enemy(); |
gunpuen2 | 6:7f99124272d9 | 791 | printf("This is enemy_platform.\n"); |
gunpuen2 | 6:7f99124272d9 | 792 | print_enemy_platform(); |
gunpuen2 | 19:d78586719868 | 793 | state = 1; |
gunpuen2 | 0:a8e057156263 | 794 | }else{ |
gunpuen2 | 6:7f99124272d9 | 795 | enemy_atk(); |
gunpuen2 | 19:d78586719868 | 796 | if(check_win==1){ |
gunpuen2 | 19:d78586719868 | 797 | printf("BOO!! You Win!\n"); |
gunpuen2 | 19:d78586719868 | 798 | break; |
gunpuen2 | 19:d78586719868 | 799 | } |
gunpuen2 | 6:7f99124272d9 | 800 | printf("This is atk_platform.\n"); |
gunpuen2 | 6:7f99124272d9 | 801 | print_atk_platform(); |
gunpuen2 | 7:e35ba3ddb9af | 802 | printf("This is ship_destroyed. : "); |
gunpuen2 | 7:e35ba3ddb9af | 803 | print_ship_destroyed(); |
gunpuen2 | 14:8abed4026326 | 804 | if(TellUrEnemy_uWin()==1){ |
gunpuen2 | 14:8abed4026326 | 805 | while(uli<100){ |
gunpuen2 | 14:8abed4026326 | 806 | bt.putc('q'); |
gunpuen2 | 14:8abed4026326 | 807 | uli++; |
gunpuen2 | 14:8abed4026326 | 808 | } |
gunpuen2 | 19:d78586719868 | 809 | printf("BOO!! You lost!\n"); |
gunpuen2 | 7:e35ba3ddb9af | 810 | break; |
gunpuen2 | 7:e35ba3ddb9af | 811 | }else{state = 0;} |
gunpuen2 | 0:a8e057156263 | 812 | } |
gunpuen2 | 0:a8e057156263 | 813 | } |
gunpuen2 | 19:d78586719868 | 814 | while(1){printf("END\n");wait(1);} |
gunpuen2 | 0:a8e057156263 | 815 | } |
gunpuen2 | 0:a8e057156263 | 816 | |
gunpuen2 | 4:8a86bacddcac | 817 | /******************************************************************************/ |
gunpuen2 | 4:8a86bacddcac | 818 | /* */ |
gunpuen2 | 4:8a86bacddcac | 819 | /* */ |
gunpuen2 | 4:8a86bacddcac | 820 | /* Another function */ |
gunpuen2 | 4:8a86bacddcac | 821 | /* */ |
gunpuen2 | 4:8a86bacddcac | 822 | /* */ |
gunpuen2 | 4:8a86bacddcac | 823 | /******************************************************************************/ |
gunpuen2 | 0:a8e057156263 | 824 | |
gunpuen2 | 0:a8e057156263 | 825 | char check_joys(int jx,int jy){ //-----------------------------------------------Check joystick that it up,down,left or right. |
gunpuen2 | 8:a8d39b5d17ab | 826 | |
gunpuen2 | 7:e35ba3ddb9af | 827 | if(ifUrJirat==1){ |
gunpuen2 | 7:e35ba3ddb9af | 828 | if(jx < 14.0){ return 'a';} |
gunpuen2 | 7:e35ba3ddb9af | 829 | else if(jx > 1010.0){return 'd';} |
gunpuen2 | 7:e35ba3ddb9af | 830 | else if(jy < 14.0){ return 'w';} |
gunpuen2 | 7:e35ba3ddb9af | 831 | else if(jy > 1010.0){return 's';} |
gunpuen2 | 7:e35ba3ddb9af | 832 | else{return NULL;} |
gunpuen2 | 8:a8d39b5d17ab | 833 | }else{ |
gunpuen2 | 9:102af5021c6c | 834 | if(jx < 14.0){ return 'd';} |
gunpuen2 | 9:102af5021c6c | 835 | else if(jx > 1010.0){return 'a';} |
gunpuen2 | 9:102af5021c6c | 836 | else if(jy < 14.0){ return 's';} |
gunpuen2 | 9:102af5021c6c | 837 | else if(jy > 1010.0){return 'w';} |
gunpuen2 | 7:e35ba3ddb9af | 838 | else{return NULL;} |
gunpuen2 | 0:a8e057156263 | 839 | } |
gunpuen2 | 0:a8e057156263 | 840 | } |
gunpuen2 | 0:a8e057156263 | 841 | int check_joys_int(int jx,int jy){ //--------------------------------------------Check joystick that it is centre. |
gunpuen2 | 0:a8e057156263 | 842 | if(jx>=450.0&&jx<=600.0){ |
gunpuen2 | 0:a8e057156263 | 843 | if(jy>=450.0&&jy<=600.0){ |
gunpuen2 | 0:a8e057156263 | 844 | return 1; |
gunpuen2 | 0:a8e057156263 | 845 | }else{ |
gunpuen2 | 0:a8e057156263 | 846 | return 0; |
gunpuen2 | 0:a8e057156263 | 847 | } |
gunpuen2 | 0:a8e057156263 | 848 | }else{ |
gunpuen2 | 0:a8e057156263 | 849 | return 0; |
gunpuen2 | 0:a8e057156263 | 850 | } |
gunpuen2 | 0:a8e057156263 | 851 | } |
gunpuen2 | 0:a8e057156263 | 852 | void Select_Position(char M){ //-------------------------------------------------Change position of cursor (Joystick). |
gunpuen2 | 17:aeb7cbfb8640 | 853 | int protect_ships; |
gunpuen2 | 17:aeb7cbfb8640 | 854 | protect_ships = protect_ship(select_Position,ship_SelectType[iShipType]); |
gunpuen2 | 0:a8e057156263 | 855 | switch(M){ |
gunpuen2 | 0:a8e057156263 | 856 | case 'a': |
gunpuen2 | 17:aeb7cbfb8640 | 857 | if(select_Position%10!=0){ |
gunpuen2 | 17:aeb7cbfb8640 | 858 | select_Position = select_Position - 1; |
gunpuen2 | 17:aeb7cbfb8640 | 859 | } |
gunpuen2 | 0:a8e057156263 | 860 | break; |
gunpuen2 | 0:a8e057156263 | 861 | case 'd': |
gunpuen2 | 17:aeb7cbfb8640 | 862 | if(select_Position%10!=7){ |
gunpuen2 | 17:aeb7cbfb8640 | 863 | if(protect_ships==1 or protect_ships==0){ |
gunpuen2 | 17:aeb7cbfb8640 | 864 | select_Position = select_Position + 1; |
gunpuen2 | 17:aeb7cbfb8640 | 865 | }//else{ |
gunpuen2 | 17:aeb7cbfb8640 | 866 | //printf("Not allow position.\n"); |
gunpuen2 | 17:aeb7cbfb8640 | 867 | //} |
gunpuen2 | 17:aeb7cbfb8640 | 868 | } |
gunpuen2 | 0:a8e057156263 | 869 | break; |
gunpuen2 | 0:a8e057156263 | 870 | case 'w': |
gunpuen2 | 17:aeb7cbfb8640 | 871 | if(select_Position/10!=0){ |
gunpuen2 | 17:aeb7cbfb8640 | 872 | select_Position = select_Position - 10; |
gunpuen2 | 17:aeb7cbfb8640 | 873 | } |
gunpuen2 | 0:a8e057156263 | 874 | break; |
gunpuen2 | 0:a8e057156263 | 875 | case 's': |
gunpuen2 | 17:aeb7cbfb8640 | 876 | if(select_Position/10!=7){ |
gunpuen2 | 17:aeb7cbfb8640 | 877 | if(protect_ships==1 or protect_ships==2){ |
gunpuen2 | 17:aeb7cbfb8640 | 878 | select_Position = select_Position + 10; |
gunpuen2 | 17:aeb7cbfb8640 | 879 | }//else{ |
gunpuen2 | 17:aeb7cbfb8640 | 880 | //printf("Not allow position.\n"); |
gunpuen2 | 17:aeb7cbfb8640 | 881 | //} |
gunpuen2 | 17:aeb7cbfb8640 | 882 | } |
gunpuen2 | 0:a8e057156263 | 883 | break; |
gunpuen2 | 0:a8e057156263 | 884 | } |
gunpuen2 | 0:a8e057156263 | 885 | } |
gunpuen2 | 15:5902cf545449 | 886 | int protect_ship(int head_position,int ship_type){ |
gunpuen2 | 15:5902cf545449 | 887 | int x,y = 0; |
gunpuen2 | 15:5902cf545449 | 888 | y = head_position/10; |
gunpuen2 | 15:5902cf545449 | 889 | x = head_position%10; |
gunpuen2 | 17:aeb7cbfb8640 | 890 | if(ship_type==4){if((y+4)>7){return 0;}else{return 1;}} |
gunpuen2 | 17:aeb7cbfb8640 | 891 | else if(ship_type==3){if((x+3)>7){return 2;}else{return 1;}} |
gunpuen2 | 17:aeb7cbfb8640 | 892 | else if(ship_type==2){if((y+2)>7){return 0;}else{return 1;}} |
gunpuen2 | 15:5902cf545449 | 893 | else{return 1;} |
gunpuen2 | 15:5902cf545449 | 894 | } |
gunpuen2 | 15:5902cf545449 | 895 | int get_ship_platform(int input_position,int ship_type){ //-----------------------Plot ship in ship area. |
gunpuen2 | 0:a8e057156263 | 896 | int i,x,y = 0; |
gunpuen2 | 0:a8e057156263 | 897 | int error = 0; |
gunpuen2 | 0:a8e057156263 | 898 | |
gunpuen2 | 0:a8e057156263 | 899 | y = input_position/10; |
gunpuen2 | 0:a8e057156263 | 900 | x = input_position%10; |
gunpuen2 | 0:a8e057156263 | 901 | |
gunpuen2 | 0:a8e057156263 | 902 | for(i=0;i<ship_type;i++){ |
gunpuen2 | 0:a8e057156263 | 903 | if(check_correctPosition(y,x) == 1){ |
gunpuen2 | 0:a8e057156263 | 904 | if(ship_type == 4){ship4[i] = (y*10)+x;} |
gunpuen2 | 0:a8e057156263 | 905 | else if(ship_type == 3){ship3[i] = (y*10)+x;} |
gunpuen2 | 0:a8e057156263 | 906 | else if(ship_type == 2){ship2[check_ship2][i] = (y*10)+x;} |
gunpuen2 | 0:a8e057156263 | 907 | else if(ship_type == 1){ship1[check_ship1] = (y*10)+x;check_ship1++;} |
gunpuen2 | 16:3fac68a7fd7c | 908 | }else{error = 1;break;} |
gunpuen2 | 16:3fac68a7fd7c | 909 | if(ship_type%2 == 0){y++;}else{x++;} |
gunpuen2 | 0:a8e057156263 | 910 | } |
gunpuen2 | 16:3fac68a7fd7c | 911 | if(ship_type==2){check_ship2++;} |
gunpuen2 | 16:3fac68a7fd7c | 912 | if(error == 1){return 0;}else{ |
gunpuen2 | 0:a8e057156263 | 913 | y = input_position/10; |
gunpuen2 | 0:a8e057156263 | 914 | x = input_position%10; |
gunpuen2 | 0:a8e057156263 | 915 | for(i=0;i<ship_type;i++){ |
gunpuen2 | 1:6157c77da3d5 | 916 | ship_platform[y][x] = ship_type; |
gunpuen2 | 16:3fac68a7fd7c | 917 | if(ship_type%2 == 0){y++;}else{x++;} |
gunpuen2 | 0:a8e057156263 | 918 | } |
gunpuen2 | 0:a8e057156263 | 919 | return 1; |
gunpuen2 | 0:a8e057156263 | 920 | } |
gunpuen2 | 0:a8e057156263 | 921 | } |
gunpuen2 | 0:a8e057156263 | 922 | int check_correctPosition(int X,int Y){ |
gunpuen2 | 0:a8e057156263 | 923 | if(X<=7){ |
gunpuen2 | 0:a8e057156263 | 924 | if(Y<=7){ |
gunpuen2 | 16:3fac68a7fd7c | 925 | if(ship_platform[X][Y] == 0){return 1;}else{return 0;} |
gunpuen2 | 16:3fac68a7fd7c | 926 | }else{return 0;} |
gunpuen2 | 16:3fac68a7fd7c | 927 | }else{return 0;} |
gunpuen2 | 0:a8e057156263 | 928 | } |
gunpuen2 | 6:7f99124272d9 | 929 | void print_ship_platform(){ |
gunpuen2 | 0:a8e057156263 | 930 | for(int i=0;i<8;i++){ |
gunpuen2 | 0:a8e057156263 | 931 | for(int j=0;j<8;j++){ |
gunpuen2 | 1:6157c77da3d5 | 932 | printf("| %d |",ship_platform[i][j]); |
gunpuen2 | 0:a8e057156263 | 933 | } |
gunpuen2 | 0:a8e057156263 | 934 | printf("\n"); |
gunpuen2 | 0:a8e057156263 | 935 | } |
gunpuen2 | 0:a8e057156263 | 936 | } |
gunpuen2 | 6:7f99124272d9 | 937 | void print_enemy_platform(){ |
gunpuen2 | 6:7f99124272d9 | 938 | for(int i=0;i<8;i++){ |
gunpuen2 | 6:7f99124272d9 | 939 | for(int j=0;j<8;j++){ |
gunpuen2 | 6:7f99124272d9 | 940 | printf("| %d |",enemy_platform[i][j]); |
gunpuen2 | 6:7f99124272d9 | 941 | } |
gunpuen2 | 6:7f99124272d9 | 942 | printf("\n"); |
gunpuen2 | 6:7f99124272d9 | 943 | } |
gunpuen2 | 6:7f99124272d9 | 944 | } |
gunpuen2 | 6:7f99124272d9 | 945 | void print_atk_platform(){ |
gunpuen2 | 6:7f99124272d9 | 946 | for(int i=0;i<8;i++){ |
gunpuen2 | 6:7f99124272d9 | 947 | for(int j=0;j<8;j++){ |
gunpuen2 | 6:7f99124272d9 | 948 | printf("| %d |",atk_platform[i][j]); |
gunpuen2 | 6:7f99124272d9 | 949 | } |
gunpuen2 | 6:7f99124272d9 | 950 | printf("\n"); |
gunpuen2 | 6:7f99124272d9 | 951 | } |
gunpuen2 | 6:7f99124272d9 | 952 | } |
gunpuen2 | 7:e35ba3ddb9af | 953 | void print_ship_destroyed(){ |
gunpuen2 | 8:a8d39b5d17ab | 954 | printf("{"); |
gunpuen2 | 7:e35ba3ddb9af | 955 | for(int i=0;i<8;i++){ |
gunpuen2 | 7:e35ba3ddb9af | 956 | printf("%d",ship_destroyed[i]); |
gunpuen2 | 7:e35ba3ddb9af | 957 | if(i!=14){printf(",");} |
gunpuen2 | 7:e35ba3ddb9af | 958 | } |
gunpuen2 | 7:e35ba3ddb9af | 959 | printf("}\n"); |
gunpuen2 | 7:e35ba3ddb9af | 960 | } |
gunpuen2 | 0:a8e057156263 | 961 | void check_ready(){ |
gunpuen2 | 16:3fac68a7fd7c | 962 | if(bt.readable()){enemy_ready = 1;} |
gunpuen2 | 1:6157c77da3d5 | 963 | } |
gunpuen2 | 1:6157c77da3d5 | 964 | char posit2char(int posit){ |
gunpuen2 | 1:6157c77da3d5 | 965 | int as = posit+48; |
gunpuen2 | 1:6157c77da3d5 | 966 | char ch = as; |
gunpuen2 | 1:6157c77da3d5 | 967 | return ch ; |
gunpuen2 | 1:6157c77da3d5 | 968 | } |
gunpuen2 | 1:6157c77da3d5 | 969 | int char2posit(char cha){ |
gunpuen2 | 1:6157c77da3d5 | 970 | int as = cha; |
gunpuen2 | 1:6157c77da3d5 | 971 | as = as-48; |
gunpuen2 | 1:6157c77da3d5 | 972 | return as; |
gunpuen2 | 1:6157c77da3d5 | 973 | } |
gunpuen2 | 15:5902cf545449 | 974 | void get_atk_platform(int atkpos){ |
gunpuen2 | 4:8a86bacddcac | 975 | int i,j,x,y = 0; |
gunpuen2 | 1:6157c77da3d5 | 976 | |
gunpuen2 | 7:e35ba3ddb9af | 977 | x = atkpos/10; |
gunpuen2 | 7:e35ba3ddb9af | 978 | y = atkpos%10; |
gunpuen2 | 1:6157c77da3d5 | 979 | |
gunpuen2 | 2:d93832fe8deb | 980 | if(ship_platform[x][y]!=0 and atk_platform[x][y]==0){ |
gunpuen2 | 1:6157c77da3d5 | 981 | atk_platform[x][y] = ship_platform[x][y]; |
gunpuen2 | 6:7f99124272d9 | 982 | bt.putc(posit2char(atk_platform[x][y])); |
gunpuen2 | 9:102af5021c6c | 983 | ship_underATK[check_ship_underATK] = (x*10)+y; |
gunpuen2 | 2:d93832fe8deb | 984 | if(atk_platform[x][y]==4){ |
gunpuen2 | 2:d93832fe8deb | 985 | for(i=0;i<4;i++){ |
gunpuen2 | 2:d93832fe8deb | 986 | for(j=0;j<15;j++){ |
gunpuen2 | 16:3fac68a7fd7c | 987 | if(ship4[i]==ship_underATK[j]){ship_destroyed[0]++;} |
gunpuen2 | 2:d93832fe8deb | 988 | } |
gunpuen2 | 2:d93832fe8deb | 989 | } |
gunpuen2 | 2:d93832fe8deb | 990 | }else if(atk_platform[x][y]==3){ |
gunpuen2 | 2:d93832fe8deb | 991 | for(i=0;i<3;i++){ |
gunpuen2 | 2:d93832fe8deb | 992 | for(j=0;j<15;j++){ |
gunpuen2 | 16:3fac68a7fd7c | 993 | if(ship3[i]==ship_underATK[j]){ship_destroyed[1]++;} |
gunpuen2 | 2:d93832fe8deb | 994 | } |
gunpuen2 | 2:d93832fe8deb | 995 | } |
gunpuen2 | 2:d93832fe8deb | 996 | }else if(atk_platform[x][y]==2){ |
gunpuen2 | 2:d93832fe8deb | 997 | for(i=0;i<4;i++){ |
gunpuen2 | 2:d93832fe8deb | 998 | for(j=0;j<15;j++){ |
gunpuen2 | 16:3fac68a7fd7c | 999 | if(ship2[0][i]==ship_underATK[j]){ship_destroyed[2]++;} |
gunpuen2 | 16:3fac68a7fd7c | 1000 | if(ship2[1][i]==ship_underATK[j]){ship_destroyed[3]++;} |
gunpuen2 | 2:d93832fe8deb | 1001 | } |
gunpuen2 | 2:d93832fe8deb | 1002 | } |
gunpuen2 | 2:d93832fe8deb | 1003 | }else if(atk_platform[x][y]==1){ |
gunpuen2 | 2:d93832fe8deb | 1004 | for(i=0;i<4;i++){ |
gunpuen2 | 2:d93832fe8deb | 1005 | for(j=0;j<15;j++){ |
gunpuen2 | 2:d93832fe8deb | 1006 | if(ship3[i]==ship_underATK[j]){ |
gunpuen2 | 2:d93832fe8deb | 1007 | ship_destroyed[4+i]++; |
gunpuen2 | 4:8a86bacddcac | 1008 | atk_platform[x][y] = 11; |
gunpuen2 | 2:d93832fe8deb | 1009 | } |
gunpuen2 | 2:d93832fe8deb | 1010 | } |
gunpuen2 | 2:d93832fe8deb | 1011 | } |
gunpuen2 | 2:d93832fe8deb | 1012 | } |
gunpuen2 | 1:6157c77da3d5 | 1013 | }else{ |
gunpuen2 | 1:6157c77da3d5 | 1014 | atk_platform[x][y] = 8; |
gunpuen2 | 6:7f99124272d9 | 1015 | bt.putc(posit2char(atk_platform[x][y])); |
gunpuen2 | 0:a8e057156263 | 1016 | } |
gunpuen2 | 0:a8e057156263 | 1017 | } |
gunpuen2 | 4:8a86bacddcac | 1018 | void mark_ship_destroyed(){ |
gunpuen2 | 4:8a86bacddcac | 1019 | int i,j,k = 0; |
gunpuen2 | 0:a8e057156263 | 1020 | |
gunpuen2 | 11:305164107874 | 1021 | if(ship_destroyed[0]==10){ |
gunpuen2 | 4:8a86bacddcac | 1022 | for(i=0;i<8;i++){ |
gunpuen2 | 4:8a86bacddcac | 1023 | for(j=0;j<8;j++){ |
gunpuen2 | 16:3fac68a7fd7c | 1024 | if(atk_platform[i][j]==4){atk_platform[i][j] = 11;} |
gunpuen2 | 4:8a86bacddcac | 1025 | } |
gunpuen2 | 4:8a86bacddcac | 1026 | } |
gunpuen2 | 13:eee9af3b4308 | 1027 | } |
gunpuen2 | 13:eee9af3b4308 | 1028 | if(ship_destroyed[1]==6){ |
gunpuen2 | 4:8a86bacddcac | 1029 | for(i=0;i<8;i++){ |
gunpuen2 | 4:8a86bacddcac | 1030 | for(j=0;j<8;j++){ |
gunpuen2 | 16:3fac68a7fd7c | 1031 | if(atk_platform[i][j]==3){atk_platform[i][j] = 11;} |
gunpuen2 | 4:8a86bacddcac | 1032 | } |
gunpuen2 | 4:8a86bacddcac | 1033 | } |
gunpuen2 | 13:eee9af3b4308 | 1034 | } |
gunpuen2 | 13:eee9af3b4308 | 1035 | if(ship_destroyed[2]==3){ |
gunpuen2 | 4:8a86bacddcac | 1036 | for(k=0;k<2;k++){ |
gunpuen2 | 4:8a86bacddcac | 1037 | i = ship2[0][k]/10; |
gunpuen2 | 4:8a86bacddcac | 1038 | j = ship2[0][k]%10; |
gunpuen2 | 4:8a86bacddcac | 1039 | atk_platform[i][j] = 11; |
gunpuen2 | 4:8a86bacddcac | 1040 | } |
gunpuen2 | 13:eee9af3b4308 | 1041 | } |
gunpuen2 | 13:eee9af3b4308 | 1042 | if(ship_destroyed[3]==3){ |
gunpuen2 | 4:8a86bacddcac | 1043 | for(k=0;k<2;k++){ |
gunpuen2 | 4:8a86bacddcac | 1044 | i = ship2[1][k]/10; |
gunpuen2 | 4:8a86bacddcac | 1045 | j = ship2[1][k]%10; |
gunpuen2 | 4:8a86bacddcac | 1046 | atk_platform[i][j] = 11; |
gunpuen2 | 4:8a86bacddcac | 1047 | } |
gunpuen2 | 4:8a86bacddcac | 1048 | } |
gunpuen2 | 6:7f99124272d9 | 1049 | } |
gunpuen2 | 6:7f99124272d9 | 1050 | void atk_enemy(){ |
gunpuen2 | 6:7f99124272d9 | 1051 | float Vx; |
gunpuen2 | 6:7f99124272d9 | 1052 | float Vy; |
gunpuen2 | 7:e35ba3ddb9af | 1053 | int SW,iVxVy,iSW,n = 0; |
gunpuen2 | 7:e35ba3ddb9af | 1054 | int iPrintUturn = 0; |
gunpuen2 | 6:7f99124272d9 | 1055 | char m; |
gunpuen2 | 6:7f99124272d9 | 1056 | |
gunpuen2 | 14:8abed4026326 | 1057 | select_Position = 0; |
gunpuen2 | 6:7f99124272d9 | 1058 | while(1){ |
gunpuen2 | 6:7f99124272d9 | 1059 | if(iPrintUturn==0){ |
gunpuen2 | 6:7f99124272d9 | 1060 | printf("Your turn.\n"); |
gunpuen2 | 6:7f99124272d9 | 1061 | iPrintUturn = 1; |
gunpuen2 | 6:7f99124272d9 | 1062 | } |
gunpuen2 | 6:7f99124272d9 | 1063 | Vx = VRx.read() * 1024; |
gunpuen2 | 6:7f99124272d9 | 1064 | Vy = VRy.read() * 1024; |
gunpuen2 | 6:7f99124272d9 | 1065 | SW = Button.read(); |
gunpuen2 | 6:7f99124272d9 | 1066 | m = check_joys(Vx,Vy); |
gunpuen2 | 6:7f99124272d9 | 1067 | n = check_joys_int(Vx,Vy); |
gunpuen2 | 16:3fac68a7fd7c | 1068 | if(n == 1){ iVxVy = 0;} |
gunpuen2 | 6:7f99124272d9 | 1069 | if(SW == 1){ |
gunpuen2 | 6:7f99124272d9 | 1070 | iSW = 0; |
gunpuen2 | 6:7f99124272d9 | 1071 | if(bt.readable()){ |
gunpuen2 | 6:7f99124272d9 | 1072 | enemy_platform[select_Position/10][select_Position%10] = char2posit(bt.getc()); |
gunpuen2 | 6:7f99124272d9 | 1073 | break; |
gunpuen2 | 6:7f99124272d9 | 1074 | } |
gunpuen2 | 6:7f99124272d9 | 1075 | } |
gunpuen2 | 6:7f99124272d9 | 1076 | if(m!=NULL && iVxVy==0){ |
gunpuen2 | 6:7f99124272d9 | 1077 | Select_Position(m); |
gunpuen2 | 6:7f99124272d9 | 1078 | printf("select_Position = %d\n",select_Position); |
gunpuen2 | 6:7f99124272d9 | 1079 | bt.putc(posit2char(select_Position)); |
gunpuen2 | 6:7f99124272d9 | 1080 | iVxVy = 1; |
gunpuen2 | 6:7f99124272d9 | 1081 | } |
gunpuen2 | 6:7f99124272d9 | 1082 | if(SW==0 && iSW==0){ |
gunpuen2 | 6:7f99124272d9 | 1083 | bt.putc('B'); |
gunpuen2 | 6:7f99124272d9 | 1084 | printf("You attacking at position %d\n",select_Position); |
gunpuen2 | 6:7f99124272d9 | 1085 | iSW = 1; |
gunpuen2 | 6:7f99124272d9 | 1086 | } |
gunpuen2 | 6:7f99124272d9 | 1087 | } |
gunpuen2 | 6:7f99124272d9 | 1088 | } |
gunpuen2 | 6:7f99124272d9 | 1089 | void enemy_atk(){ |
gunpuen2 | 6:7f99124272d9 | 1090 | int data_fromEnemy; |
gunpuen2 | 19:d78586719868 | 1091 | char replica_data_fromEnemy; |
gunpuen2 | 6:7f99124272d9 | 1092 | printf("Wait for enemy attack.\n"); |
gunpuen2 | 13:eee9af3b4308 | 1093 | select_Position = 0; |
gunpuen2 | 6:7f99124272d9 | 1094 | while(1){ |
gunpuen2 | 6:7f99124272d9 | 1095 | if(bt.readable()){ |
gunpuen2 | 21:d76aa19984be | 1096 | replica_data_fromEnemy = bt.getc(); |
gunpuen2 | 20:4b9be9a423a8 | 1097 | if(replica_data_fromEnemy!='q' and replica_data_fromEnemy!=8){ |
gunpuen2 | 19:d78586719868 | 1098 | data_fromEnemy = char2posit(replica_data_fromEnemy); |
gunpuen2 | 19:d78586719868 | 1099 | if(data_fromEnemy!=18){ |
gunpuen2 | 19:d78586719868 | 1100 | select_Position = data_fromEnemy; |
gunpuen2 | 19:d78586719868 | 1101 | printf("enemy select_Position = %d\n",select_Position); |
gunpuen2 | 19:d78586719868 | 1102 | }else{ |
gunpuen2 | 19:d78586719868 | 1103 | ATKposition = select_Position; |
gunpuen2 | 19:d78586719868 | 1104 | break; |
gunpuen2 | 19:d78586719868 | 1105 | } |
gunpuen2 | 21:d76aa19984be | 1106 | } |
gunpuen2 | 21:d76aa19984be | 1107 | if(replica_data_fromEnemy=='q'){ |
gunpuen2 | 19:d78586719868 | 1108 | check_win = 1; |
gunpuen2 | 6:7f99124272d9 | 1109 | break; |
gunpuen2 | 6:7f99124272d9 | 1110 | } |
gunpuen2 | 6:7f99124272d9 | 1111 | } |
gunpuen2 | 6:7f99124272d9 | 1112 | } |
gunpuen2 | 19:d78586719868 | 1113 | if(check_win!=1){ |
gunpuen2 | 19:d78586719868 | 1114 | printf("Enemy attack at your area %d\n",ATKposition); |
gunpuen2 | 19:d78586719868 | 1115 | get_atk_platform(ATKposition); |
gunpuen2 | 19:d78586719868 | 1116 | check_ship_underATK++; |
gunpuen2 | 19:d78586719868 | 1117 | mark_ship_destroyed(); |
gunpuen2 | 19:d78586719868 | 1118 | } |
gunpuen2 | 7:e35ba3ddb9af | 1119 | } |
gunpuen2 | 7:e35ba3ddb9af | 1120 | int TellUrEnemy_uWin(){ |
gunpuen2 | 7:e35ba3ddb9af | 1121 | int sub_end = 0; |
gunpuen2 | 7:e35ba3ddb9af | 1122 | |
gunpuen2 | 7:e35ba3ddb9af | 1123 | for(int i=0;i<15;i++){ |
gunpuen2 | 11:305164107874 | 1124 | if(ship_underATK[i]!=9){sub_end++;} |
gunpuen2 | 7:e35ba3ddb9af | 1125 | } |
gunpuen2 | 8:a8d39b5d17ab | 1126 | if(sub_end==15){return 1;}else{return 0;} |
gunpuen2 | 7:e35ba3ddb9af | 1127 | } |
gunpuen2 | 7:e35ba3ddb9af | 1128 | int IamWin(){ |
gunpuen2 | 17:aeb7cbfb8640 | 1129 | char chare; |
gunpuen2 | 17:aeb7cbfb8640 | 1130 | if(bt.readable()){ |
gunpuen2 | 18:ecef8382d41e | 1131 | chare = bt.getc(); |
gunpuen2 | 17:aeb7cbfb8640 | 1132 | if(chare=='q'){return 1;}else{return 0;} |
gunpuen2 | 17:aeb7cbfb8640 | 1133 | }else{return 0;} |
gunpuen2 | 4:8a86bacddcac | 1134 | } |