P9: A7,A13 battle ship 2016 J

Dependencies:   mbed

Committer:
dragondrunk
Date:
Tue Dec 06 04:04:11 2016 +0000
Revision:
0:b6fa066730db
Battle Ship Game

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dragondrunk 0:b6fa066730db 1 /******************************************************************************/
dragondrunk 0:b6fa066730db 2 /* This Nicleo is state 0 */
dragondrunk 0:b6fa066730db 3 /******************************************************************************/
dragondrunk 0:b6fa066730db 4 #include "mbed.h"
dragondrunk 0:b6fa066730db 5 #include "ColorMbed.h"
dragondrunk 0:b6fa066730db 6
dragondrunk 0:b6fa066730db 7 // Setting
dragondrunk 0:b6fa066730db 8 int ifUrJirat = 1;
dragondrunk 0:b6fa066730db 9
dragondrunk 0:b6fa066730db 10 // Initail I/O.
dragondrunk 0:b6fa066730db 11 AnalogIn VRx(A0);
dragondrunk 0:b6fa066730db 12 AnalogIn VRy(A1);
dragondrunk 0:b6fa066730db 13 DigitalIn Button(PA_4);
dragondrunk 0:b6fa066730db 14 Serial bt(PA_15, PB_7);
dragondrunk 0:b6fa066730db 15 Serial com(D1,D0);
dragondrunk 0:b6fa066730db 16 ColorMbed dotmatrix;
dragondrunk 0:b6fa066730db 17 Timer t;
dragondrunk 0:b6fa066730db 18
dragondrunk 0:b6fa066730db 19 // Initial function.
dragondrunk 0:b6fa066730db 20 char posit2char(int posit);
dragondrunk 0:b6fa066730db 21 char check_joys(int jx,int jy);
dragondrunk 0:b6fa066730db 22 int IamWin();
dragondrunk 0:b6fa066730db 23 int TellUrEnemy_uWin();
dragondrunk 0:b6fa066730db 24 int char2posit(char cha);
dragondrunk 0:b6fa066730db 25 int check_joys_int(int jx,int jy);
dragondrunk 0:b6fa066730db 26 int check_correctPosition(int X,int Y);
dragondrunk 0:b6fa066730db 27 int protect_ship(int head_position,int ship_type);
dragondrunk 0:b6fa066730db 28 int get_ship_platform(int input_position,int ship_type);
dragondrunk 0:b6fa066730db 29 void atk_enemy();
dragondrunk 0:b6fa066730db 30 void enemy_atk();
dragondrunk 0:b6fa066730db 31 void check_end();
dragondrunk 0:b6fa066730db 32 void check_ready();
dragondrunk 0:b6fa066730db 33 void mark_ship_destroyed();
dragondrunk 0:b6fa066730db 34 void Select_Position(char M,int SetOrPlay);
dragondrunk 0:b6fa066730db 35 void get_atk_platform(int atkpos);
dragondrunk 0:b6fa066730db 36 void get_ship_UShipsRdestroyed();
dragondrunk 0:b6fa066730db 37
dragondrunk 0:b6fa066730db 38 //inessential
dragondrunk 0:b6fa066730db 39 void print_ship_destroyed();
dragondrunk 0:b6fa066730db 40 void print_enemy_platform();
dragondrunk 0:b6fa066730db 41 void print_ship_platform();
dragondrunk 0:b6fa066730db 42 void print_atk_platform();
dragondrunk 0:b6fa066730db 43
dragondrunk 0:b6fa066730db 44 // Nasarun's function.
dragondrunk 0:b6fa066730db 45 int _power(int number , int power);
dragondrunk 0:b6fa066730db 46 void hex_to_array(int* ar);
dragondrunk 0:b6fa066730db 47 void place_ship3(char dir);
dragondrunk 0:b6fa066730db 48 void array_to_hex(int ar1[8][8]);
dragondrunk 0:b6fa066730db 49 void place_ship2_4(int ship,char dir);
dragondrunk 0:b6fa066730db 50 void ch_same_position(int ar1[8][8],int ar2[8][8]);
dragondrunk 0:b6fa066730db 51 void discard_same_position(int ar1[8][8],int ar2[8][8]);
dragondrunk 0:b6fa066730db 52 void hex_to_array_ship(int *hex_array); // convert hex_array to complete picture array[8][8][3]
dragondrunk 0:b6fa066730db 53
dragondrunk 0:b6fa066730db 54 // Nasrun : Fuction place bomb
dragondrunk 0:b6fa066730db 55 void plant_bomb(char dir);
dragondrunk 0:b6fa066730db 56 void set_zero();
dragondrunk 0:b6fa066730db 57 // plot color
dragondrunk 0:b6fa066730db 58 void change_orange_myship(int row,int col);
dragondrunk 0:b6fa066730db 59 void change_orange_hisship(int row,int col);
dragondrunk 0:b6fa066730db 60 void change_red_myship(int row,int col);
dragondrunk 0:b6fa066730db 61 void change_red_hisship(int row,int col);
dragondrunk 0:b6fa066730db 62 void change_green_hisship(int row,int col);
dragondrunk 0:b6fa066730db 63 void change_red_deadship(int* array_coordinate,int mode);
dragondrunk 0:b6fa066730db 64 void change_green_myship(int row,int col);
dragondrunk 0:b6fa066730db 65 void change_green_hisship(int row,int col);
dragondrunk 0:b6fa066730db 66 void display_bomb_enemy(int row,int col);
dragondrunk 0:b6fa066730db 67
dragondrunk 0:b6fa066730db 68
dragondrunk 0:b6fa066730db 69 // Initial variable.
dragondrunk 0:b6fa066730db 70 int check_ship_underATK = 0;
dragondrunk 0:b6fa066730db 71 int select_Position = 0;
dragondrunk 0:b6fa066730db 72 int ATKposition = 0;
dragondrunk 0:b6fa066730db 73 int enemy_ready = 0;
dragondrunk 0:b6fa066730db 74 int check_ship1 = 0;
dragondrunk 0:b6fa066730db 75 int check_ship2 = 0;
dragondrunk 0:b6fa066730db 76 int check_win = 0;
dragondrunk 0:b6fa066730db 77 int state = 0;
dragondrunk 0:b6fa066730db 78 //Index.
dragondrunk 0:b6fa066730db 79 int iShipType = 0;
dragondrunk 0:b6fa066730db 80 int iWaitATK = 0;
dragondrunk 0:b6fa066730db 81 int iGSU=0;
dragondrunk 0:b6fa066730db 82 int iSUSPD = 0;
dragondrunk 0:b6fa066730db 83 //Array
dragondrunk 0:b6fa066730db 84 int ship_SelectType[8] = {4,3,2,2,1,1,1,1};
dragondrunk 0:b6fa066730db 85 int enemy_platform[8][8] = {{0}};
dragondrunk 0:b6fa066730db 86 int ship_platform[8][8] = {{0}}; //______________________________________________This is ship area.
dragondrunk 0:b6fa066730db 87 int atk_platform[8][8] = {{0}};
dragondrunk 0:b6fa066730db 88 int ship_underATK[15] = {9,9,9,9,9,9,9,9,9,9,9,9,9,9,9};
dragondrunk 0:b6fa066730db 89 int ship_myShipsRdestroyed[15] = {9,9,9,9,9,9,9,9,9,9,9,9,9,9,9};
dragondrunk 0:b6fa066730db 90 int ship_UShipsRdestroyed[15] = {9,9,9,9,9,9,9,9,9,9,9,9,9,9,9};
dragondrunk 0:b6fa066730db 91 int ship_destroyed[8] = {0};
dragondrunk 0:b6fa066730db 92 int ship4[4] = {0};
dragondrunk 0:b6fa066730db 93 int ship3[3] = {0};
dragondrunk 0:b6fa066730db 94 int ship2[2][2] = {{0}};
dragondrunk 0:b6fa066730db 95 int ship1[4] = {0};
dragondrunk 0:b6fa066730db 96 //fuction nasrun
dragondrunk 0:b6fa066730db 97 int return_position[8][8] ;
dragondrunk 0:b6fa066730db 98 int for_hex = 0;
dragondrunk 0:b6fa066730db 99 int ch_post[8][8] = {{1,1,1,1,1,1,1,1},
dragondrunk 0:b6fa066730db 100 {1,1,1,1,1,1,1,1},
dragondrunk 0:b6fa066730db 101 {1,1,1,1,1,1,1,1},
dragondrunk 0:b6fa066730db 102 {1,1,1,1,1,1,1,1},
dragondrunk 0:b6fa066730db 103 {1,1,1,1,1,1,1,1},
dragondrunk 0:b6fa066730db 104 {1,1,1,1,1,1,1,1},
dragondrunk 0:b6fa066730db 105 {1,1,1,1,1,1,1,1},
dragondrunk 0:b6fa066730db 106 {1,1,1,1,1,1,1,1}};
dragondrunk 0:b6fa066730db 107 int return_hex[8];
dragondrunk 0:b6fa066730db 108 int display_battle[8][8][3] = {0};
dragondrunk 0:b6fa066730db 109 int _temppic[8] = {0x01,0x01,0x01,0x01,0,0,0,0};
dragondrunk 0:b6fa066730db 110 int temppic2[8] = {0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
dragondrunk 0:b6fa066730db 111 int temppic3[7][8] = {{0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00},{0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00},{0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00},{0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00},{0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00},{0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00},{0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00}};
dragondrunk 0:b6fa066730db 112 int temppic4[8] = {0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
dragondrunk 0:b6fa066730db 113 int forshift[8] = {0};
dragondrunk 0:b6fa066730db 114 int pic[8] = {0};
dragondrunk 0:b6fa066730db 115 int i,j;
dragondrunk 0:b6fa066730db 116 int check_boat3=0;
dragondrunk 0:b6fa066730db 117 int check_hex=0;
dragondrunk 0:b6fa066730db 118
dragondrunk 0:b6fa066730db 119
dragondrunk 0:b6fa066730db 120
dragondrunk 0:b6fa066730db 121 int ship[8][8][3] = {0}; // gen hex to ship
dragondrunk 0:b6fa066730db 122 int plot_bombed_usage[8][8][3] = {{{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0}},
dragondrunk 0:b6fa066730db 123 {{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0}},
dragondrunk 0:b6fa066730db 124 {{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0}},
dragondrunk 0:b6fa066730db 125 {{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0}},
dragondrunk 0:b6fa066730db 126 {{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0}},
dragondrunk 0:b6fa066730db 127 {{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0}},
dragondrunk 0:b6fa066730db 128 {{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0}},
dragondrunk 0:b6fa066730db 129 {{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0}}};
dragondrunk 0:b6fa066730db 130
dragondrunk 0:b6fa066730db 131 int bomb[8][8][3] = {{{100,100,90},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0}},
dragondrunk 0:b6fa066730db 132 {{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0}},
dragondrunk 0:b6fa066730db 133 {{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0}},
dragondrunk 0:b6fa066730db 134 {{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0}},
dragondrunk 0:b6fa066730db 135 {{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0}},
dragondrunk 0:b6fa066730db 136 {{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0}},
dragondrunk 0:b6fa066730db 137 {{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0}},
dragondrunk 0:b6fa066730db 138 {{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0}}};
dragondrunk 0:b6fa066730db 139
dragondrunk 0:b6fa066730db 140 int main_frame1[8][8][3] = {{{0}}}; // for show im placed bomb phase
dragondrunk 0:b6fa066730db 141 int main_frame2[8][8][3] = {{{0}}};
dragondrunk 0:b6fa066730db 142
dragondrunk 0:b6fa066730db 143 int bomb_enemy[8][8][3] = {{{0}}};
dragondrunk 0:b6fa066730db 144
dragondrunk 0:b6fa066730db 145 int zero[8][8][3] = {{{0}}};
dragondrunk 0:b6fa066730db 146 // psrameter for function plant_bomb
dragondrunk 0:b6fa066730db 147 int col = 0;
dragondrunk 0:b6fa066730db 148 int row = 0;
dragondrunk 0:b6fa066730db 149 int iCheck = 0;
dragondrunk 0:b6fa066730db 150 int temp_array[3] = {0};
dragondrunk 0:b6fa066730db 151
dragondrunk 0:b6fa066730db 152 // function Test!
dragondrunk 0:b6fa066730db 153 int main(){ //-------------------------------------------------------------------Main Function.
dragondrunk 0:b6fa066730db 154 bt.baud(9600);
dragondrunk 0:b6fa066730db 155 float Vx;
dragondrunk 0:b6fa066730db 156 float Vy;
dragondrunk 0:b6fa066730db 157 int SW,iVxVy,iSW,n = 0;
dragondrunk 0:b6fa066730db 158 int uli = 0;
dragondrunk 0:b6fa066730db 159 char m;
dragondrunk 0:b6fa066730db 160 int rgb[3] = {60,0,0};
dragondrunk 0:b6fa066730db 161 int state_place_ship = 0;
dragondrunk 0:b6fa066730db 162 dotmatrix.init();
dragondrunk 0:b6fa066730db 163
dragondrunk 0:b6fa066730db 164 int winlose[2][8] = {{0x3c,0x42,0xa5,0x81,0xa5,0x99,0x42,0x3c},{0x3c,0x42,0xa5,0x81,0x99,0xa5,0x42,0x3c}};
dragondrunk 0:b6fa066730db 165 int rgbwin[3] = {0,255,0};
dragondrunk 0:b6fa066730db 166 int rgblose[3] = {0,0,255};
dragondrunk 0:b6fa066730db 167
dragondrunk 0:b6fa066730db 168 int threetwoone[4][8] = {{0xbd,0xa1,0xa1,0xbd,0xa1,0xa1,0xbd,0x81},{0xbd,0xa1,0xa1,0xbd,0x85,0x85,0xbd,0x81},{0x99,0x9d,0x99,0x99,0x99,0x99,0xbd,0x81},{0x00,0xef,0xa1,0xad,0xa9,0xef,0x00,0x00}};
dragondrunk 0:b6fa066730db 169 int rgbtto[3] = {0};
dragondrunk 0:b6fa066730db 170
dragondrunk 0:b6fa066730db 171 int picwait[9][8] = {
dragondrunk 0:b6fa066730db 172 {0xff,0xff,0x42,0x24,0x24,0x42,0x81,0xff},
dragondrunk 0:b6fa066730db 173 {0xff,0xff,0x7e,0x24,0x24,0x42,0x81,0xff},
dragondrunk 0:b6fa066730db 174 {0xff,0xff,0x7e,0x3c,0x24,0x42,0x81,0xff},
dragondrunk 0:b6fa066730db 175 {0xff,0x81,0x7e,0x3c,0x3c,0x42,0x81,0xff},
dragondrunk 0:b6fa066730db 176 {0xff,0x81,0x42,0x3c,0x3c,0x7e,0x81,0xff},
dragondrunk 0:b6fa066730db 177 {0xff,0x81,0x42,0x24,0x3c,0x7e,0xff,0xff},
dragondrunk 0:b6fa066730db 178 {0xff,0x81,0x42,0x24,0x24,0x7e,0xff,0xff},
dragondrunk 0:b6fa066730db 179 {0xff,0x81,0x42,0x24,0x24,0x42,0xff,0xff},
dragondrunk 0:b6fa066730db 180 {0xff,0x81,0x42,0x24,0x24,0x42,0x81,0xff}};
dragondrunk 0:b6fa066730db 181 int rgbwait[3] = {0};
dragondrunk 0:b6fa066730db 182 int shiprun[19][8][8][3] = {
dragondrunk 0:b6fa066730db 183
dragondrunk 0:b6fa066730db 184 {{{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 185 {{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 186 {{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 187 {{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 188 {{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 189 {{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 190 {{200,0,0}, {200,10,0}, {200,20,0}, {200,30,0}, {200,40,0}, {200,50,0}, {200,60,0}, {200,80,0}},
dragondrunk 0:b6fa066730db 191 {{200,0,0}, {200,10,0}, {200,20,0}, {200,30,0}, {200,40,0}, {200,50,0}, {200,60,0}, {200,80,0}}},
dragondrunk 0:b6fa066730db 192
dragondrunk 0:b6fa066730db 193 {{{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 194 {{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 195 {{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 196 {{10,20,20}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 197 {{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 198 {{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 199 {{200,0,0}, {200,10,0}, {200,20,0}, {200,30,0}, {200,40,0}, {200,50,0}, {200,60,0}, {200,80,0}},
dragondrunk 0:b6fa066730db 200 {{200,0,0}, {200,10,0}, {200,20,0}, {200,30,0}, {200,40,0}, {200,50,0}, {200,60,0}, {200,80,0}}},
dragondrunk 0:b6fa066730db 201
dragondrunk 0:b6fa066730db 202
dragondrunk 0:b6fa066730db 203 {{{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 204 {{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 205 {{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 206 {{10,20,20}, {10,20,20}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 207 {{10,20,20}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 208 {{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 209 {{200,0,0}, {200,10,0}, {200,20,0}, {200,30,0}, {200,40,0}, {200,50,0}, {200,60,0}, {200,80,0}},
dragondrunk 0:b6fa066730db 210 {{200,0,0}, {200,10,0}, {200,20,0}, {200,30,0}, {200,40,0}, {200,50,0}, {200,60,0}, {200,80,0}}},
dragondrunk 0:b6fa066730db 211
dragondrunk 0:b6fa066730db 212 {{{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 213 {{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 214 {{10,20,20}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 215 {{10,20,20}, {10,20,20}, {10,20,20}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 216 {{10,20,20}, {10,20,20}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 217 {{10,20,20}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 218 {{200,0,0}, {200,10,0}, {200,20,0}, {200,30,0}, {200,40,0}, {200,50,0}, {200,60,0}, {200,80,0}},
dragondrunk 0:b6fa066730db 219 {{200,0,0}, {200,10,0}, {200,20,0}, {200,30,0}, {200,40,0}, {200,50,0}, {200,60,0}, {200,80,0}}},
dragondrunk 0:b6fa066730db 220
dragondrunk 0:b6fa066730db 221
dragondrunk 0:b6fa066730db 222 {{{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 223 {{10,20,20}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 224 {{0,0,0}, {10,20,20}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 225 {{10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 226 {{10,20,20}, {10,20,20}, {10,20,20}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 227 {{10,20,20}, {10,20,20}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 228 {{200,0,0}, {200,10,0}, {200,20,0}, {200,30,0}, {200,40,0}, {200,50,0}, {200,60,0}, {200,80,0}},
dragondrunk 0:b6fa066730db 229 {{200,0,0}, {200,10,0}, {200,20,0}, {200,30,0}, {200,40,0}, {200,50,0}, {200,60,0}, {200,80,0}}},
dragondrunk 0:b6fa066730db 230
dragondrunk 0:b6fa066730db 231
dragondrunk 0:b6fa066730db 232 {{{10,20,20}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 233 {{0,0,0}, {10,20,20}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 234 {{0,0,0}, {0,0,0}, {10,20,20}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 235 {{10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}, {0,0,0}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 236 {{10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 237 {{10,20,20}, {10,20,20}, {10,20,20}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 238 {{200,0,0}, {200,10,0}, {200,20,0}, {200,30,0}, {200,40,0}, {200,50,0}, {200,60,0}, {200,80,0}},
dragondrunk 0:b6fa066730db 239 {{200,0,0}, {200,10,0}, {200,20,0}, {200,30,0}, {200,40,0}, {200,50,0}, {200,60,0}, {200,80,0}}},
dragondrunk 0:b6fa066730db 240
dragondrunk 0:b6fa066730db 241
dragondrunk 0:b6fa066730db 242 {{{10,20,20}, {10,20,20}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 243 {{0,0,0}, {0,0,0}, {10,20,20}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 244 {{0,0,0}, {0,0,0}, {0,0,0}, {10,20,20}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 245 {{10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 246 {{10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}, {0,0,0}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 247 {{10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 248 {{200,10,0}, {200,20,0}, {200,30,0}, {200,40,0}, {200,50,0}, {200,60,0}, {200,80,0}, {200,60,0}},
dragondrunk 0:b6fa066730db 249 {{200,10,0}, {200,20,0}, {200,30,0}, {200,40,0}, {200,50,0}, {200,60,0}, {200,80,0}, {200,60,0}}},
dragondrunk 0:b6fa066730db 250
dragondrunk 0:b6fa066730db 251 {{{0,0,0}, {10,20,20}, {10,20,20}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 252 {{10,20,20}, {0,0,0}, {0,0,0}, {10,20,20}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 253 {{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {10,20,20}, {0,0,0}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 254 {{10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}, {0,0,0}},
dragondrunk 0:b6fa066730db 255 {{10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 256 {{10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}, {0,0,0}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 257 {{200,20,0}, {200,30,0}, {200,40,0}, {200,50,0}, {200,60,0}, {200,80,0}, {200,60,0}, {200,50,0}},
dragondrunk 0:b6fa066730db 258 {{200,20,0}, {200,30,0}, {200,40,0}, {200,50,0}, {200,60,0}, {200,80,0}, {200,60,0}, {200,50,0}}},
dragondrunk 0:b6fa066730db 259
dragondrunk 0:b6fa066730db 260 {{{0,0,0}, {0,0,0}, {10,20,20}, {10,20,20}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 261 {{0,0,0}, {10,20,20}, {0,0,0}, {0,0,0}, {10,20,20}, {0,0,0}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 262 {{10,20,20}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {10,20,20}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 263 {{10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}},
dragondrunk 0:b6fa066730db 264 {{10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}, {0,0,0}},
dragondrunk 0:b6fa066730db 265 {{10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 266 {{200,30,0}, {200,40,0}, {200,50,0}, {200,60,0}, {200,80,0}, {200,60,0}, {200,50,0}, {200,40,0}},
dragondrunk 0:b6fa066730db 267 {{200,30,0}, {200,40,0}, {200,50,0}, {200,60,0}, {200,80,0}, {200,60,0}, {200,50,0}, {200,40,0}}},
dragondrunk 0:b6fa066730db 268
dragondrunk 0:b6fa066730db 269
dragondrunk 0:b6fa066730db 270
dragondrunk 0:b6fa066730db 271 {{{0,0,0}, {0,0,0}, {0,0,0}, {10,20,20}, {10,20,20}, {0,0,0}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 272 {{0,0,0}, {0,0,0}, {10,20,20}, {0,0,0}, {0,0,0}, {10,20,20}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 273 {{0,0,0}, {10,20,20}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {10,20,20}, {0,0,0}},
dragondrunk 0:b6fa066730db 274 {{10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}},
dragondrunk 0:b6fa066730db 275 {{10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}},
dragondrunk 0:b6fa066730db 276 {{0,0,0}, {10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}, {0,0,0}},
dragondrunk 0:b6fa066730db 277 {{200,40,0}, {200,50,0}, {200,60,0}, {200,80,0}, {200,60,0}, {200,50,0}, {200,40,0}, {200,30,0}},
dragondrunk 0:b6fa066730db 278 {{200,40,0}, {200,50,0}, {200,60,0}, {200,80,0}, {200,60,0}, {200,50,0}, {200,40,0}, {200,30,0}}},
dragondrunk 0:b6fa066730db 279
dragondrunk 0:b6fa066730db 280
dragondrunk 0:b6fa066730db 281 {{{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {10,20,20}, {10,20,20}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 282 {{0,0,0}, {0,0,0}, {0,0,0}, {10,20,20}, {0,0,0}, {0,0,0}, {10,20,20}, {0,0,0}},
dragondrunk 0:b6fa066730db 283 {{0,0,0}, {0,0,0}, {10,20,20}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {10,20,20}},
dragondrunk 0:b6fa066730db 284 {{10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}},
dragondrunk 0:b6fa066730db 285 {{0,0,0}, {10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}},
dragondrunk 0:b6fa066730db 286 {{0,0,0}, {0,0,0}, {10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}},
dragondrunk 0:b6fa066730db 287 {{200,50,0}, {200,60,0}, {200,80,0}, {200,60,0}, {200,50,0}, {200,40,0}, {200,30,0}, {200,20,0}},
dragondrunk 0:b6fa066730db 288 {{200,50,0}, {200,60,0}, {200,80,0}, {200,60,0}, {200,50,0}, {200,40,0}, {200,30,0}, {200,20,0}}},
dragondrunk 0:b6fa066730db 289
dragondrunk 0:b6fa066730db 290 {{{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {10,20,20}, {10,20,20}, {0,0,0}},
dragondrunk 0:b6fa066730db 291 {{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {10,20,20}, {0,0,0}, {0,0,0}, {10,20,20}},
dragondrunk 0:b6fa066730db 292 {{0,0,0}, {0,0,0}, {0,0,0}, {10,20,20}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 293 {{0,0,0}, {10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}},
dragondrunk 0:b6fa066730db 294 {{0,0,0}, {0,0,0}, {10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}},
dragondrunk 0:b6fa066730db 295 {{0,0,0}, {0,0,0}, {0,0,0}, {10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}},
dragondrunk 0:b6fa066730db 296 {{200,60,0}, {200,80,0}, {200,60,0}, {200,50,0}, {200,40,0}, {200,30,0}, {200,20,0}, {200,10,0}},
dragondrunk 0:b6fa066730db 297 {{200,60,0}, {200,80,0}, {200,60,0}, {200,50,0}, {200,40,0}, {200,30,0}, {200,20,0}, {200,10,0}}},
dragondrunk 0:b6fa066730db 298
dragondrunk 0:b6fa066730db 299 {{{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {10,20,20}, {10,20,20}},
dragondrunk 0:b6fa066730db 300 {{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {10,20,20}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 301 {{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {10,20,20}, {0,0,0}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 302 {{0,0,0}, {0,0,0}, {10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}},
dragondrunk 0:b6fa066730db 303 {{0,0,0}, {0,0,0}, {0,0,0}, {10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}},
dragondrunk 0:b6fa066730db 304 {{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}},
dragondrunk 0:b6fa066730db 305 {{200,80,0}, {200,60,0}, {200,50,0}, {200,40,0}, {200,30,0}, {200,20,0}, {200,10,0}, {200,0,0}},
dragondrunk 0:b6fa066730db 306 {{200,80,0}, {200,60,0}, {200,50,0}, {200,40,0}, {200,30,0}, {200,20,0}, {200,10,0}, {200,0,0}}},
dragondrunk 0:b6fa066730db 307
dragondrunk 0:b6fa066730db 308 {{{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {10,20,20}},
dragondrunk 0:b6fa066730db 309 {{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {10,20,20}, {0,0,0}},
dragondrunk 0:b6fa066730db 310 {{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {10,20,20}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 311 {{0,0,0}, {0,0,0}, {0,0,0}, {10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}},
dragondrunk 0:b6fa066730db 312 {{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}},
dragondrunk 0:b6fa066730db 313 {{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {10,20,20}, {10,20,20}, {10,20,20}},
dragondrunk 0:b6fa066730db 314 {{200,60,0}, {200,80,0}, {200,60,0}, {200,50,0}, {200,40,0}, {200,30,0}, {200,20,0}, {200,10,0}},
dragondrunk 0:b6fa066730db 315 {{200,60,0}, {200,80,0}, {200,60,0}, {200,50,0}, {200,40,0}, {200,30,0}, {200,20,0}, {200,10,0}}},
dragondrunk 0:b6fa066730db 316
dragondrunk 0:b6fa066730db 317 {{{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 318 {{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {10,20,20}},
dragondrunk 0:b6fa066730db 319 {{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {10,20,20}, {0,0,0}},
dragondrunk 0:b6fa066730db 320 {{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {10,20,20}, {10,20,20}, {10,20,20}, {10,20,20}},
dragondrunk 0:b6fa066730db 321 {{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {10,20,20}, {10,20,20}, {10,20,20}},
dragondrunk 0:b6fa066730db 322 {{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {10,20,20}, {10,20,20}},
dragondrunk 0:b6fa066730db 323 {{200,50,0}, {200,60,0}, {200,80,0}, {200,60,0}, {200,50,0}, {200,40,0}, {200,30,0}, {200,20,0}},
dragondrunk 0:b6fa066730db 324 {{200,50,0}, {200,60,0}, {200,80,0}, {200,60,0}, {200,50,0}, {200,40,0}, {200,30,0}, {200,20,0}}},
dragondrunk 0:b6fa066730db 325
dragondrunk 0:b6fa066730db 326 {{{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 327 {{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 328 {{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {10,20,20}},
dragondrunk 0:b6fa066730db 329 {{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {10,20,20}, {10,20,20}, {10,20,20}},
dragondrunk 0:b6fa066730db 330 {{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {10,20,20}, {10,20,20}},
dragondrunk 0:b6fa066730db 331 {{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {10,20,20}},
dragondrunk 0:b6fa066730db 332 {{200,40,0}, {200,50,0}, {200,60,0}, {200,80,0}, {200,60,0}, {200,50,0}, {200,40,0}, {200,30,0}},
dragondrunk 0:b6fa066730db 333 {{200,40,0}, {200,50,0}, {200,60,0}, {200,80,0}, {200,60,0}, {200,50,0}, {200,40,0}, {200,30,0}}},
dragondrunk 0:b6fa066730db 334
dragondrunk 0:b6fa066730db 335 {{{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 336 {{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 337 {{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 338 {{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {10,20,20}, {10,20,20}},
dragondrunk 0:b6fa066730db 339 {{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {10,20,20}},
dragondrunk 0:b6fa066730db 340 {{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 341 {{200,30,0}, {200,40,0}, {200,50,0}, {200,60,0}, {200,80,0}, {200,60,0}, {200,50,0}, {200,40,0}},
dragondrunk 0:b6fa066730db 342 {{200,30,0}, {200,40,0}, {200,50,0}, {200,60,0}, {200,80,0}, {200,60,0}, {200,50,0}, {200,40,0}}},
dragondrunk 0:b6fa066730db 343
dragondrunk 0:b6fa066730db 344 {{{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 345 {{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 346 {{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 347 {{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {10,20,20}},
dragondrunk 0:b6fa066730db 348 {{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 349 {{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 350 {{200,20,0}, {200,30,0}, {200,40,0}, {200,50,0}, {200,60,0}, {200,80,0}, {200,60,0}, {200,50,0}},
dragondrunk 0:b6fa066730db 351 {{200,20,0}, {200,30,0}, {200,40,0}, {200,50,0}, {200,60,0}, {200,80,0}, {200,60,0}, {200,50,0}}},
dragondrunk 0:b6fa066730db 352
dragondrunk 0:b6fa066730db 353 {{{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 354 {{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 355 {{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 356 {{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 357 {{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 358 {{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
dragondrunk 0:b6fa066730db 359 {{200,10,0}, {200,20,0}, {200,30,0}, {200,40,0}, {200,50,0}, {200,60,0}, {200,80,0}, {200,60,0}},
dragondrunk 0:b6fa066730db 360 {{200,10,0}, {200,20,0}, {200,30,0}, {200,40,0}, {200,50,0}, {200,60,0}, {200,80,0}, {200,60,0}}},
dragondrunk 0:b6fa066730db 361 };
dragondrunk 0:b6fa066730db 362
dragondrunk 0:b6fa066730db 363 int circle[65][8] = {
dragondrunk 0:b6fa066730db 364 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
dragondrunk 0:b6fa066730db 365 {0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
dragondrunk 0:b6fa066730db 366 {0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
dragondrunk 0:b6fa066730db 367 {0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
dragondrunk 0:b6fa066730db 368 {0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
dragondrunk 0:b6fa066730db 369 {0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
dragondrunk 0:b6fa066730db 370 {0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
dragondrunk 0:b6fa066730db 371 {0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
dragondrunk 0:b6fa066730db 372 {0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
dragondrunk 0:b6fa066730db 373 {0xff,0x80,0x00,0x00,0x00,0x00,0x00,0x00},
dragondrunk 0:b6fa066730db 374 {0xff,0x80,0x80,0x00,0x00,0x00,0x00,0x00},
dragondrunk 0:b6fa066730db 375 {0xff,0x80,0x80,0x80,0x00,0x00,0x00,0x00},
dragondrunk 0:b6fa066730db 376 {0xff,0x80,0x80,0x80,0x80,0x00,0x00,0x00},
dragondrunk 0:b6fa066730db 377 {0xff,0x80,0x80,0x80,0x80,0x80,0x00,0x00},
dragondrunk 0:b6fa066730db 378 {0xff,0x80,0x80,0x80,0x80,0x80,0x80,0x00},
dragondrunk 0:b6fa066730db 379 {0xff,0x80,0x80,0x80,0x80,0x80,0x80,0x80},
dragondrunk 0:b6fa066730db 380 {0xff,0x80,0x80,0x80,0x80,0x80,0x80,0xc0},
dragondrunk 0:b6fa066730db 381 {0xff,0x80,0x80,0x80,0x80,0x80,0x80,0xe0},
dragondrunk 0:b6fa066730db 382 {0xff,0x80,0x80,0x80,0x80,0x80,0x80,0xf0},
dragondrunk 0:b6fa066730db 383 {0xff,0x80,0x80,0x80,0x80,0x80,0x80,0xf8},
dragondrunk 0:b6fa066730db 384 {0xff,0x80,0x80,0x80,0x80,0x80,0x80,0xfc},
dragondrunk 0:b6fa066730db 385 {0xff,0x80,0x80,0x80,0x80,0x80,0x80,0xfe},
dragondrunk 0:b6fa066730db 386 {0xff,0x80,0x80,0x80,0x80,0x80,0x80,0xff},
dragondrunk 0:b6fa066730db 387 {0xff,0x80,0x80,0x80,0x80,0x80,0x81,0xff},
dragondrunk 0:b6fa066730db 388 {0xff,0x80,0x80,0x80,0x80,0x81,0x81,0xff},
dragondrunk 0:b6fa066730db 389 {0xff,0x80,0x80,0x80,0x81,0x81,0x81,0xff},
dragondrunk 0:b6fa066730db 390 {0xff,0x80,0x80,0x81,0x81,0x81,0x81,0xff},
dragondrunk 0:b6fa066730db 391 {0xff,0x80,0x81,0x81,0x81,0x81,0x81,0xff},
dragondrunk 0:b6fa066730db 392 {0xff,0x81,0x81,0x81,0x81,0x81,0x81,0xff},
dragondrunk 0:b6fa066730db 393 {0xff,0x83,0x81,0x81,0x81,0x81,0x81,0xff},
dragondrunk 0:b6fa066730db 394 {0xff,0x87,0x81,0x81,0x81,0x81,0x81,0xff},
dragondrunk 0:b6fa066730db 395 {0xff,0x8f,0x81,0x81,0x81,0x81,0x81,0xff},
dragondrunk 0:b6fa066730db 396 {0xff,0x9f,0x81,0x81,0x81,0x81,0x81,0xff},
dragondrunk 0:b6fa066730db 397 {0xff,0xbf,0x81,0x81,0x81,0x81,0x81,0xff},
dragondrunk 0:b6fa066730db 398 {0xff,0xff,0x81,0x81,0x81,0x81,0x81,0xff},
dragondrunk 0:b6fa066730db 399 {0xff,0xff,0xc1,0x81,0x81,0x81,0x81,0xff},
dragondrunk 0:b6fa066730db 400 {0xff,0xff,0xc1,0xc1,0x81,0x81,0x81,0xff},
dragondrunk 0:b6fa066730db 401 {0xff,0xff,0xc1,0xc1,0xc1,0x81,0x81,0xff},
dragondrunk 0:b6fa066730db 402 {0xff,0xff,0xc1,0xc1,0xc1,0xc1,0x81,0xff},
dragondrunk 0:b6fa066730db 403 {0xff,0xff,0xc1,0xc1,0xc1,0xc1,0xc1,0xff},
dragondrunk 0:b6fa066730db 404 {0xff,0xff,0xc1,0xc1,0xc1,0xc1,0xe1,0xff},
dragondrunk 0:b6fa066730db 405 {0xff,0xff,0xc1,0xc1,0xc1,0xc1,0xf1,0xff},
dragondrunk 0:b6fa066730db 406 {0xff,0xff,0xc1,0xc1,0xc1,0xc1,0xf9,0xff},
dragondrunk 0:b6fa066730db 407 {0xff,0xff,0xc1,0xc1,0xc1,0xc1,0xfd,0xff},
dragondrunk 0:b6fa066730db 408 {0xff,0xff,0xc1,0xc1,0xc1,0xc1,0xff,0xff},
dragondrunk 0:b6fa066730db 409 {0xff,0xff,0xc1,0xc1,0xc1,0xc3,0xff,0xff},
dragondrunk 0:b6fa066730db 410 {0xff,0xff,0xc1,0xc1,0xc3,0xc3,0xff,0xff},
dragondrunk 0:b6fa066730db 411 {0xff,0xff,0xc1,0xc3,0xc3,0xc3,0xff,0xff},
dragondrunk 0:b6fa066730db 412 {0xff,0xff,0xc3,0xc3,0xc3,0xc3,0xff,0xff},
dragondrunk 0:b6fa066730db 413 {0xff,0xff,0xc7,0xc3,0xc3,0xc3,0xff,0xff},
dragondrunk 0:b6fa066730db 414 {0xff,0xff,0xcf,0xc3,0xc3,0xc3,0xff,0xff},
dragondrunk 0:b6fa066730db 415 {0xff,0xff,0xdf,0xc3,0xc3,0xc3,0xff,0xff},
dragondrunk 0:b6fa066730db 416 {0xff,0xff,0xff,0xc3,0xc3,0xc3,0xff,0xff},
dragondrunk 0:b6fa066730db 417 {0xff,0xff,0xff,0xe3,0xc3,0xc3,0xff,0xff},
dragondrunk 0:b6fa066730db 418 {0xff,0xff,0xff,0xe3,0xe3,0xc3,0xff,0xff},
dragondrunk 0:b6fa066730db 419 {0xff,0xff,0xff,0xe3,0xe3,0xe3,0xff,0xff},
dragondrunk 0:b6fa066730db 420 {0xff,0xff,0xff,0xe3,0xe3,0xf3,0xff,0xff},
dragondrunk 0:b6fa066730db 421 {0xff,0xff,0xff,0xe3,0xe3,0xfb,0xff,0xff},
dragondrunk 0:b6fa066730db 422 {0xff,0xff,0xff,0xe3,0xe3,0xff,0xff,0xff},
dragondrunk 0:b6fa066730db 423 {0xff,0xff,0xff,0xe3,0xe7,0xff,0xff,0xff},
dragondrunk 0:b6fa066730db 424 {0xff,0xff,0xff,0xe7,0xe7,0xff,0xff,0xff},
dragondrunk 0:b6fa066730db 425 {0xff,0xff,0xff,0xef,0xe7,0xff,0xff,0xff},
dragondrunk 0:b6fa066730db 426 {0xff,0xff,0xff,0xff,0xe7,0xff,0xff,0xff},
dragondrunk 0:b6fa066730db 427 {0xff,0xff,0xff,0xff,0xf7,0xff,0xff,0xff},
dragondrunk 0:b6fa066730db 428 {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff}
dragondrunk 0:b6fa066730db 429 };
dragondrunk 0:b6fa066730db 430 int rgbcircle[3] = {0};
dragondrunk 0:b6fa066730db 431 int counter = 0;
dragondrunk 0:b6fa066730db 432 int click = 0;
dragondrunk 0:b6fa066730db 433 int extwhile = 0;
dragondrunk 0:b6fa066730db 434 t.start();
dragondrunk 0:b6fa066730db 435 while(1){
dragondrunk 0:b6fa066730db 436 for( int a=0 ; a<=64 ;a++){
dragondrunk 0:b6fa066730db 437 extwhile = extwhile+1;
dragondrunk 0:b6fa066730db 438 counter = counter+10;
dragondrunk 0:b6fa066730db 439 if( counter == 60 ){
dragondrunk 0:b6fa066730db 440 click = click+1;
dragondrunk 0:b6fa066730db 441 counter=0;
dragondrunk 0:b6fa066730db 442 }
dragondrunk 0:b6fa066730db 443 if(click == 0){
dragondrunk 0:b6fa066730db 444 rgbcircle[0] = 0;
dragondrunk 0:b6fa066730db 445 rgbcircle[1] = 0;
dragondrunk 0:b6fa066730db 446 rgbcircle[2] = counter;
dragondrunk 0:b6fa066730db 447 }
dragondrunk 0:b6fa066730db 448 else if(click == 1){
dragondrunk 0:b6fa066730db 449 rgbcircle[0] = 0;
dragondrunk 0:b6fa066730db 450 rgbcircle[1] = counter;
dragondrunk 0:b6fa066730db 451 rgbcircle[2] = 60;
dragondrunk 0:b6fa066730db 452 }
dragondrunk 0:b6fa066730db 453 else if(click == 2){
dragondrunk 0:b6fa066730db 454 rgbcircle[0] = 0;
dragondrunk 0:b6fa066730db 455 rgbcircle[1] = 60;
dragondrunk 0:b6fa066730db 456 rgbcircle[2] = 60 - counter;
dragondrunk 0:b6fa066730db 457 }
dragondrunk 0:b6fa066730db 458 else if(click == 3){
dragondrunk 0:b6fa066730db 459 rgbcircle[0] = counter;
dragondrunk 0:b6fa066730db 460 rgbcircle[1] = 60;
dragondrunk 0:b6fa066730db 461 rgbcircle[2] = 0;
dragondrunk 0:b6fa066730db 462 }
dragondrunk 0:b6fa066730db 463 else if(click == 4){
dragondrunk 0:b6fa066730db 464 rgbcircle[0] = 60;
dragondrunk 0:b6fa066730db 465 rgbcircle[1] = 60 - counter;
dragondrunk 0:b6fa066730db 466 rgbcircle[2] = 0;
dragondrunk 0:b6fa066730db 467 }
dragondrunk 0:b6fa066730db 468 else if(click == 5){
dragondrunk 0:b6fa066730db 469 rgbcircle[0] = 60;
dragondrunk 0:b6fa066730db 470 rgbcircle[1] = 0;
dragondrunk 0:b6fa066730db 471 rgbcircle[2] = counter;
dragondrunk 0:b6fa066730db 472 }
dragondrunk 0:b6fa066730db 473 else if(click == 6){
dragondrunk 0:b6fa066730db 474 rgbcircle[0] = 60 - counter;
dragondrunk 0:b6fa066730db 475 rgbcircle[1] = 0;
dragondrunk 0:b6fa066730db 476 rgbcircle[2] = 60;
dragondrunk 0:b6fa066730db 477 }
dragondrunk 0:b6fa066730db 478 else if(click == 7){
dragondrunk 0:b6fa066730db 479 rgbcircle[0] = 0;
dragondrunk 0:b6fa066730db 480 rgbcircle[1] = 0;
dragondrunk 0:b6fa066730db 481 rgbcircle[2] = 60;
dragondrunk 0:b6fa066730db 482 click = 1;
dragondrunk 0:b6fa066730db 483 }
dragondrunk 0:b6fa066730db 484 wait(0.0025);
dragondrunk 0:b6fa066730db 485 if(t.read() <= 0.8){dotmatrix.display_pic(circle[a],rgbcircle);}
dragondrunk 0:b6fa066730db 486
dragondrunk 0:b6fa066730db 487 }
dragondrunk 0:b6fa066730db 488 break;
dragondrunk 0:b6fa066730db 489 }
dragondrunk 0:b6fa066730db 490 t.stop();
dragondrunk 0:b6fa066730db 491 t.reset();
dragondrunk 0:b6fa066730db 492 t.start();
dragondrunk 0:b6fa066730db 493
dragondrunk 0:b6fa066730db 494 while(1){
dragondrunk 0:b6fa066730db 495 if( t.read()<=0.2){dotmatrix.display_big_array(shiprun[0]);}
dragondrunk 0:b6fa066730db 496 else if( t.read()>0.2 && t.read()<=0.4){dotmatrix.display_big_array(shiprun[1]);}
dragondrunk 0:b6fa066730db 497 else if( t.read()>0.4 && t.read()<=0.6){dotmatrix.display_big_array(shiprun[2]);}
dragondrunk 0:b6fa066730db 498 else if( t.read()>0.6 && t.read()<=0.8){dotmatrix.display_big_array(shiprun[3]);}
dragondrunk 0:b6fa066730db 499 else if( t.read()>0.8 && t.read()<=1){dotmatrix.display_big_array(shiprun[4]);}
dragondrunk 0:b6fa066730db 500 else if( t.read()>1 && t.read()<=1.2){dotmatrix.display_big_array(shiprun[5]);}
dragondrunk 0:b6fa066730db 501 else if( t.read()>1.2 && t.read()<=1.4){dotmatrix.display_big_array(shiprun[6]);}
dragondrunk 0:b6fa066730db 502 else if( t.read()>1.2 && t.read()<=1.6){dotmatrix.display_big_array(shiprun[7]);}
dragondrunk 0:b6fa066730db 503 else if( t.read()>1.6 && t.read()<=1.8){dotmatrix.display_big_array(shiprun[8]);}
dragondrunk 0:b6fa066730db 504 else if( t.read()>1.8 && t.read()<=2){dotmatrix.display_big_array(shiprun[9]);}
dragondrunk 0:b6fa066730db 505 else if( t.read()>2 && t.read()<=2.2){dotmatrix.display_big_array(shiprun[10]);}
dragondrunk 0:b6fa066730db 506 else if( t.read()>2.2 && t.read()<=2.4){dotmatrix.display_big_array(shiprun[11]);}
dragondrunk 0:b6fa066730db 507 else if( t.read()>2.4 && t.read()<=2.6){dotmatrix.display_big_array(shiprun[12]);}
dragondrunk 0:b6fa066730db 508 else if( t.read()>2.6 && t.read()<=2.8){dotmatrix.display_big_array(shiprun[13]);}
dragondrunk 0:b6fa066730db 509 else if( t.read()>2.8 && t.read()<=3){dotmatrix.display_big_array(shiprun[14]);}
dragondrunk 0:b6fa066730db 510 else if( t.read()>3 && t.read()<=3.2){dotmatrix.display_big_array(shiprun[15]);}
dragondrunk 0:b6fa066730db 511 else if( t.read()>3.2 && t.read()<=3.4){dotmatrix.display_big_array(shiprun[16]);}
dragondrunk 0:b6fa066730db 512 else if( t.read()>3.4 && t.read()<=3.6){dotmatrix.display_big_array(shiprun[17]);}
dragondrunk 0:b6fa066730db 513 else if( t.read()>3.6 && t.read()<=3.8){dotmatrix.display_big_array(shiprun[18]);}
dragondrunk 0:b6fa066730db 514 else{break;}
dragondrunk 0:b6fa066730db 515 }
dragondrunk 0:b6fa066730db 516
dragondrunk 0:b6fa066730db 517 t.stop();
dragondrunk 0:b6fa066730db 518 t.reset();
dragondrunk 0:b6fa066730db 519 t.start();
dragondrunk 0:b6fa066730db 520
dragondrunk 0:b6fa066730db 521
dragondrunk 0:b6fa066730db 522 while(1) {
dragondrunk 0:b6fa066730db 523 if(t.read()<0.4){
dragondrunk 0:b6fa066730db 524 dotmatrix.display_pic(_temppic,rgb);
dragondrunk 0:b6fa066730db 525 }
dragondrunk 0:b6fa066730db 526 else if(t.read() > 0.4 && t.read() < 0.8){
dragondrunk 0:b6fa066730db 527 dotmatrix.display_pic(pic,rgb);
dragondrunk 0:b6fa066730db 528 }
dragondrunk 0:b6fa066730db 529 else{
dragondrunk 0:b6fa066730db 530 t.reset();
dragondrunk 0:b6fa066730db 531 }
dragondrunk 0:b6fa066730db 532 if(iShipType<8){
dragondrunk 0:b6fa066730db 533 Vx = VRx.read() * 1024;
dragondrunk 0:b6fa066730db 534 Vy = VRy.read() * 1024;
dragondrunk 0:b6fa066730db 535 SW = Button.read();
dragondrunk 0:b6fa066730db 536 m = check_joys(Vx,Vy);
dragondrunk 0:b6fa066730db 537 n = check_joys_int(Vx,Vy);
dragondrunk 0:b6fa066730db 538 if(n == 1){ //_______________________________________________________ For make sure coordinate is press 1 time.
dragondrunk 0:b6fa066730db 539 iVxVy = 0;
dragondrunk 0:b6fa066730db 540 check_ready();
dragondrunk 0:b6fa066730db 541 }
dragondrunk 0:b6fa066730db 542 if(SW == 1){ //______________________________________________________ For make sure switch is press 1 time.
dragondrunk 0:b6fa066730db 543 iSW = 0;
dragondrunk 0:b6fa066730db 544 check_ready();
dragondrunk 0:b6fa066730db 545 }
dragondrunk 0:b6fa066730db 546 if(m!=NULL && iVxVy==0){ //__________________________________________ Get position that wait for press switch.
dragondrunk 0:b6fa066730db 547 check_ready();
dragondrunk 0:b6fa066730db 548 Select_Position(m,0);
dragondrunk 0:b6fa066730db 549 if(state_place_ship == 0){
dragondrunk 0:b6fa066730db 550 place_ship2_4(0,m); // 4
dragondrunk 0:b6fa066730db 551 }
dragondrunk 0:b6fa066730db 552 else if(state_place_ship == 1){
dragondrunk 0:b6fa066730db 553 place_ship3(m); // 3
dragondrunk 0:b6fa066730db 554 }
dragondrunk 0:b6fa066730db 555 else if(state_place_ship == 2){
dragondrunk 0:b6fa066730db 556 place_ship2_4(1,m); // 2
dragondrunk 0:b6fa066730db 557 }
dragondrunk 0:b6fa066730db 558 else if(state_place_ship == 3){
dragondrunk 0:b6fa066730db 559 place_ship2_4(2,m); //2
dragondrunk 0:b6fa066730db 560 }
dragondrunk 0:b6fa066730db 561 else if(state_place_ship == 4){
dragondrunk 0:b6fa066730db 562 place_ship2_4(3,m); // 1
dragondrunk 0:b6fa066730db 563 }
dragondrunk 0:b6fa066730db 564 else if(state_place_ship == 5){
dragondrunk 0:b6fa066730db 565 place_ship2_4(4,m); // 1
dragondrunk 0:b6fa066730db 566 }
dragondrunk 0:b6fa066730db 567 else if(state_place_ship == 6){
dragondrunk 0:b6fa066730db 568 place_ship2_4(5,m); // 1
dragondrunk 0:b6fa066730db 569 }
dragondrunk 0:b6fa066730db 570 else if(state_place_ship == 7){
dragondrunk 0:b6fa066730db 571 place_ship2_4(6,m); // 1
dragondrunk 0:b6fa066730db 572 }
dragondrunk 0:b6fa066730db 573 printf("select_Position = %d\n",select_Position);
dragondrunk 0:b6fa066730db 574 check_ready();
dragondrunk 0:b6fa066730db 575 iVxVy = 1;
dragondrunk 0:b6fa066730db 576 check_ready();
dragondrunk 0:b6fa066730db 577 }
dragondrunk 0:b6fa066730db 578 if(SW==0 && iSW==0){ //______________________________________________If switch pressing by human.
dragondrunk 0:b6fa066730db 579 printf("Wait!\n");
dragondrunk 0:b6fa066730db 580
dragondrunk 0:b6fa066730db 581 check_ready();
dragondrunk 0:b6fa066730db 582 if(get_ship_platform(select_Position,ship_SelectType[iShipType])==0){ //__Please read explanation in function get_ship_platform.
dragondrunk 0:b6fa066730db 583 printf("Please input correct position\n");
dragondrunk 0:b6fa066730db 584 }else{
dragondrunk 0:b6fa066730db 585 iShipType++;
dragondrunk 0:b6fa066730db 586 if(state_place_ship == 0){
dragondrunk 0:b6fa066730db 587 for(j=0;j<8;j++){
dragondrunk 0:b6fa066730db 588 pic[j] = temppic3[0][j]+pic[j];
dragondrunk 0:b6fa066730db 589 }
dragondrunk 0:b6fa066730db 590 for(j=0;j<8;j++){
dragondrunk 0:b6fa066730db 591 _temppic[j] = temppic2[j];
dragondrunk 0:b6fa066730db 592 }
dragondrunk 0:b6fa066730db 593 }
dragondrunk 0:b6fa066730db 594 else if(state_place_ship == 1){
dragondrunk 0:b6fa066730db 595 for(j=0;j<8;j++){
dragondrunk 0:b6fa066730db 596 pic[j] = temppic2[j]+pic[j];
dragondrunk 0:b6fa066730db 597 }
dragondrunk 0:b6fa066730db 598 for(j=0;j<8;j++){
dragondrunk 0:b6fa066730db 599 _temppic[j] = temppic3[1][j];
dragondrunk 0:b6fa066730db 600 }
dragondrunk 0:b6fa066730db 601 }
dragondrunk 0:b6fa066730db 602 else if(state_place_ship == 2){
dragondrunk 0:b6fa066730db 603 for(j=0;j<8;j++){
dragondrunk 0:b6fa066730db 604 pic[j] = temppic3[1][j]+pic[j];
dragondrunk 0:b6fa066730db 605 }
dragondrunk 0:b6fa066730db 606 for(j=0;j<8;j++){
dragondrunk 0:b6fa066730db 607 _temppic[j] = temppic3[2][j];
dragondrunk 0:b6fa066730db 608 }
dragondrunk 0:b6fa066730db 609 }
dragondrunk 0:b6fa066730db 610 else if(state_place_ship == 3){
dragondrunk 0:b6fa066730db 611 for(j=0;j<8;j++){
dragondrunk 0:b6fa066730db 612 pic[j] = temppic3[2][j]+pic[j];
dragondrunk 0:b6fa066730db 613 }
dragondrunk 0:b6fa066730db 614 for(j=0;j<8;j++){
dragondrunk 0:b6fa066730db 615 _temppic[j] = temppic3[3][j];
dragondrunk 0:b6fa066730db 616 }
dragondrunk 0:b6fa066730db 617 }
dragondrunk 0:b6fa066730db 618 else if(state_place_ship == 4){
dragondrunk 0:b6fa066730db 619 for(j=0;j<8;j++){
dragondrunk 0:b6fa066730db 620 pic[j] = temppic3[3][j]+pic[j];
dragondrunk 0:b6fa066730db 621 }
dragondrunk 0:b6fa066730db 622 for(j=0;j<8;j++){
dragondrunk 0:b6fa066730db 623 _temppic[j] = temppic3[4][j];
dragondrunk 0:b6fa066730db 624 }
dragondrunk 0:b6fa066730db 625 }
dragondrunk 0:b6fa066730db 626 else if(state_place_ship == 5){
dragondrunk 0:b6fa066730db 627 for(j=0;j<8;j++){
dragondrunk 0:b6fa066730db 628 pic[j] = temppic3[4][j]+pic[j];
dragondrunk 0:b6fa066730db 629 }
dragondrunk 0:b6fa066730db 630 for(j=0;j<8;j++){
dragondrunk 0:b6fa066730db 631 _temppic[j] = temppic3[5][j];
dragondrunk 0:b6fa066730db 632 }
dragondrunk 0:b6fa066730db 633 }
dragondrunk 0:b6fa066730db 634 else if(state_place_ship == 6){
dragondrunk 0:b6fa066730db 635 for(j=0;j<8;j++){
dragondrunk 0:b6fa066730db 636 pic[j] = temppic3[5][j]+pic[j];
dragondrunk 0:b6fa066730db 637 }
dragondrunk 0:b6fa066730db 638 for(j=0;j<8;j++){
dragondrunk 0:b6fa066730db 639 _temppic[j] = temppic3[6][j];
dragondrunk 0:b6fa066730db 640 }
dragondrunk 0:b6fa066730db 641 }
dragondrunk 0:b6fa066730db 642 else if(state_place_ship == 7){
dragondrunk 0:b6fa066730db 643 for(j=0;j<8;j++){
dragondrunk 0:b6fa066730db 644 pic[j] = temppic3[6][j]+pic[j];
dragondrunk 0:b6fa066730db 645 }
dragondrunk 0:b6fa066730db 646 }
dragondrunk 0:b6fa066730db 647 state_place_ship = state_place_ship + 1;
dragondrunk 0:b6fa066730db 648 select_Position = 0;
dragondrunk 0:b6fa066730db 649 }
dragondrunk 0:b6fa066730db 650 check_ready();
dragondrunk 0:b6fa066730db 651 iSW = 1;
dragondrunk 0:b6fa066730db 652 print_ship_platform();
dragondrunk 0:b6fa066730db 653 check_ready();
dragondrunk 0:b6fa066730db 654 }
dragondrunk 0:b6fa066730db 655 }else{
dragondrunk 0:b6fa066730db 656 counter = 0;
dragondrunk 0:b6fa066730db 657 if(enemy_ready!=1){
dragondrunk 0:b6fa066730db 658 printf("sent E\n");
dragondrunk 0:b6fa066730db 659 while(uli<50){
dragondrunk 0:b6fa066730db 660 bt.printf("E");
dragondrunk 0:b6fa066730db 661 uli++;
dragondrunk 0:b6fa066730db 662 }
dragondrunk 0:b6fa066730db 663 }else{
dragondrunk 0:b6fa066730db 664 bt.putc('l');
dragondrunk 0:b6fa066730db 665 printf("sent l\n");
dragondrunk 0:b6fa066730db 666 }
dragondrunk 0:b6fa066730db 667 printf("\n");
dragondrunk 0:b6fa066730db 668 break;
dragondrunk 0:b6fa066730db 669 }
dragondrunk 0:b6fa066730db 670 }
dragondrunk 0:b6fa066730db 671 if(enemy_ready == 0){
dragondrunk 0:b6fa066730db 672 printf("Wait for enemy ready\n");
dragondrunk 0:b6fa066730db 673 t.stop();
dragondrunk 0:b6fa066730db 674 t.reset();
dragondrunk 0:b6fa066730db 675 t.start();
dragondrunk 0:b6fa066730db 676 while(1){
dragondrunk 0:b6fa066730db 677 counter = counter+1;
dragondrunk 0:b6fa066730db 678 if( counter == 60 ){
dragondrunk 0:b6fa066730db 679 click = click+1;
dragondrunk 0:b6fa066730db 680 counter=0;
dragondrunk 0:b6fa066730db 681 }
dragondrunk 0:b6fa066730db 682 if(click == 0){
dragondrunk 0:b6fa066730db 683 rgbwait[0] = 0;
dragondrunk 0:b6fa066730db 684 rgbwait[1] = 0;
dragondrunk 0:b6fa066730db 685 rgbwait[2] = counter;
dragondrunk 0:b6fa066730db 686 }
dragondrunk 0:b6fa066730db 687 else if(click == 1){
dragondrunk 0:b6fa066730db 688 rgbwait[0] = 0;
dragondrunk 0:b6fa066730db 689 rgbwait[1] = counter;
dragondrunk 0:b6fa066730db 690 rgbwait[2] = 60;
dragondrunk 0:b6fa066730db 691 }
dragondrunk 0:b6fa066730db 692 else if(click == 2){
dragondrunk 0:b6fa066730db 693 rgb[0] = 0;
dragondrunk 0:b6fa066730db 694 rgb[1] = 60;
dragondrunk 0:b6fa066730db 695 rgb[2] = 60 - counter;
dragondrunk 0:b6fa066730db 696 }
dragondrunk 0:b6fa066730db 697 else if(click == 3){
dragondrunk 0:b6fa066730db 698 rgbwait[0] = counter;
dragondrunk 0:b6fa066730db 699 rgbwait[1] = 60;
dragondrunk 0:b6fa066730db 700 rgbwait[2] = 0;
dragondrunk 0:b6fa066730db 701 }
dragondrunk 0:b6fa066730db 702 else if(click == 4){
dragondrunk 0:b6fa066730db 703 rgbwait[0] = 60;
dragondrunk 0:b6fa066730db 704 rgbwait[1] = 60 - counter;
dragondrunk 0:b6fa066730db 705 rgbwait[2] = 0;
dragondrunk 0:b6fa066730db 706 }
dragondrunk 0:b6fa066730db 707 else if(click == 5){
dragondrunk 0:b6fa066730db 708 rgbwait[0] = 60;
dragondrunk 0:b6fa066730db 709 rgbwait[1] = 0;
dragondrunk 0:b6fa066730db 710 rgbwait[2] = counter;
dragondrunk 0:b6fa066730db 711 }
dragondrunk 0:b6fa066730db 712 else if(click == 6){
dragondrunk 0:b6fa066730db 713 rgbwait[0] = 60 - counter;
dragondrunk 0:b6fa066730db 714 rgbwait[1] = 0;
dragondrunk 0:b6fa066730db 715 rgbwait[2] = 60;
dragondrunk 0:b6fa066730db 716 }
dragondrunk 0:b6fa066730db 717 else if(click == 7){
dragondrunk 0:b6fa066730db 718 rgbwait[0] = 0;
dragondrunk 0:b6fa066730db 719 rgbwait[1] = 0;
dragondrunk 0:b6fa066730db 720 rgbwait[2] = 60;
dragondrunk 0:b6fa066730db 721 click = 1;
dragondrunk 0:b6fa066730db 722 }
dragondrunk 0:b6fa066730db 723 if(t.read()<0.2){dotmatrix.display_pic(picwait[0],rgbwait);}
dragondrunk 0:b6fa066730db 724 else if(t.read()>0.2 && t.read()<=0.4){dotmatrix.display_pic(picwait[1],rgbwait);}
dragondrunk 0:b6fa066730db 725 else if(t.read()>0.4 && t.read()<=0.6){dotmatrix.display_pic(picwait[2],rgbwait);}
dragondrunk 0:b6fa066730db 726 else if(t.read()>0.6 && t.read()<=0.8){dotmatrix.display_pic(picwait[3],rgbwait);}
dragondrunk 0:b6fa066730db 727 else if(t.read()>0.8 && t.read()<=1){dotmatrix.display_pic(picwait[4],rgbwait);}
dragondrunk 0:b6fa066730db 728 else if(t.read()>1 && t.read()<=1.2){dotmatrix.display_pic(picwait[5],rgbwait);}
dragondrunk 0:b6fa066730db 729 else if(t.read()>1.2 && t.read()<=1.4){dotmatrix.display_pic(picwait[6],rgbwait);}
dragondrunk 0:b6fa066730db 730 else if(t.read()>1.4 && t.read()<=1.6){dotmatrix.display_pic(picwait[7],rgbwait);}
dragondrunk 0:b6fa066730db 731 else if(t.read()>1.6 && t.read()<=1.8){dotmatrix.display_pic(picwait[8],rgbwait);}
dragondrunk 0:b6fa066730db 732 else if(t.read()>1.8 ){t.reset();}
dragondrunk 0:b6fa066730db 733
dragondrunk 0:b6fa066730db 734 if(bt.readable()){
dragondrunk 0:b6fa066730db 735 if(bt.getc()=='l'){
dragondrunk 0:b6fa066730db 736 break;
dragondrunk 0:b6fa066730db 737 }
dragondrunk 0:b6fa066730db 738 }
dragondrunk 0:b6fa066730db 739 }
dragondrunk 0:b6fa066730db 740 state = 0;
dragondrunk 0:b6fa066730db 741 }else{state = 1;}
dragondrunk 0:b6fa066730db 742 hex_to_array_ship(pic);
dragondrunk 0:b6fa066730db 743
dragondrunk 0:b6fa066730db 744 t.stop();
dragondrunk 0:b6fa066730db 745 t.reset();
dragondrunk 0:b6fa066730db 746 t.start();
dragondrunk 0:b6fa066730db 747 while(1){
dragondrunk 0:b6fa066730db 748 counter = counter+1;
dragondrunk 0:b6fa066730db 749 if( counter == 60 ){
dragondrunk 0:b6fa066730db 750 click = click+1;
dragondrunk 0:b6fa066730db 751 counter=0;
dragondrunk 0:b6fa066730db 752 }
dragondrunk 0:b6fa066730db 753 if(click == 0){
dragondrunk 0:b6fa066730db 754 rgbtto[0] = 0;
dragondrunk 0:b6fa066730db 755 rgbtto[1] = 0;
dragondrunk 0:b6fa066730db 756 rgbtto[2] = counter;
dragondrunk 0:b6fa066730db 757 }
dragondrunk 0:b6fa066730db 758 else if(click == 1){
dragondrunk 0:b6fa066730db 759 rgbtto[0] = 0;
dragondrunk 0:b6fa066730db 760 rgbtto[1] = counter;
dragondrunk 0:b6fa066730db 761 rgbtto[2] = 60;
dragondrunk 0:b6fa066730db 762 }
dragondrunk 0:b6fa066730db 763 else if(click == 2){
dragondrunk 0:b6fa066730db 764 rgbtto[0] = 0;
dragondrunk 0:b6fa066730db 765 rgbtto[1] = 60;
dragondrunk 0:b6fa066730db 766 rgbtto[2] = 60 - counter;
dragondrunk 0:b6fa066730db 767 }
dragondrunk 0:b6fa066730db 768 else if(click == 3){
dragondrunk 0:b6fa066730db 769 rgbtto[0] = counter;
dragondrunk 0:b6fa066730db 770 rgbtto[1] = 60;
dragondrunk 0:b6fa066730db 771 rgbtto[2] = 0;
dragondrunk 0:b6fa066730db 772 }
dragondrunk 0:b6fa066730db 773 else if(click == 4){
dragondrunk 0:b6fa066730db 774 rgbtto[0] = 60;
dragondrunk 0:b6fa066730db 775 rgbtto[1] = 60 - counter;
dragondrunk 0:b6fa066730db 776 rgbtto[2] = 0;
dragondrunk 0:b6fa066730db 777 }
dragondrunk 0:b6fa066730db 778 else if(click == 5){
dragondrunk 0:b6fa066730db 779 rgbtto[0] = 60;
dragondrunk 0:b6fa066730db 780 rgbtto[1] = 0;
dragondrunk 0:b6fa066730db 781 rgbtto[2] = counter;
dragondrunk 0:b6fa066730db 782 }
dragondrunk 0:b6fa066730db 783 else if(click == 6){
dragondrunk 0:b6fa066730db 784 rgbtto[0] = 60 - counter;
dragondrunk 0:b6fa066730db 785 rgbtto[1] = 0;
dragondrunk 0:b6fa066730db 786 rgbtto[2] = 60;
dragondrunk 0:b6fa066730db 787 }
dragondrunk 0:b6fa066730db 788 else if(click == 7){
dragondrunk 0:b6fa066730db 789 rgbtto[0] = 0;
dragondrunk 0:b6fa066730db 790 rgbtto[1] = 0;
dragondrunk 0:b6fa066730db 791 rgbtto[2] = 60;
dragondrunk 0:b6fa066730db 792 click = 1;
dragondrunk 0:b6fa066730db 793 }
dragondrunk 0:b6fa066730db 794 if(t.read()<1.5){dotmatrix.display_pic(threetwoone[0],rgbtto);}
dragondrunk 0:b6fa066730db 795 else if(t.read()>1.5 && t.read()<3){dotmatrix.display_pic(threetwoone[1],rgbtto);}
dragondrunk 0:b6fa066730db 796 else if(t.read()>3 && t.read()<4.5){dotmatrix.display_pic(threetwoone[2],rgbtto);}
dragondrunk 0:b6fa066730db 797 else if(t.read()>4.5 && t.read()<6){dotmatrix.display_pic(threetwoone[3],rgb);}
dragondrunk 0:b6fa066730db 798 else{break;}
dragondrunk 0:b6fa066730db 799 }
dragondrunk 0:b6fa066730db 800
dragondrunk 0:b6fa066730db 801 t.stop();
dragondrunk 0:b6fa066730db 802 t.reset();
dragondrunk 0:b6fa066730db 803
dragondrunk 0:b6fa066730db 804 while(1) { //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Play
dragondrunk 0:b6fa066730db 805 if(state == 0){
dragondrunk 0:b6fa066730db 806 printf("Your turn.\n");
dragondrunk 0:b6fa066730db 807 atk_enemy();
dragondrunk 0:b6fa066730db 808 printf("This is enemy_platform.\n");
dragondrunk 0:b6fa066730db 809 print_enemy_platform();
dragondrunk 0:b6fa066730db 810 state = 1;
dragondrunk 0:b6fa066730db 811 }else{
dragondrunk 0:b6fa066730db 812 printf("Wait for enemy attack.\n");
dragondrunk 0:b6fa066730db 813 enemy_atk();
dragondrunk 0:b6fa066730db 814 if(check_win==1){
dragondrunk 0:b6fa066730db 815 dotmatrix.display_pic(winlose[0],rgbwin);
dragondrunk 0:b6fa066730db 816 printf("BOO!! You Win!\n");
dragondrunk 0:b6fa066730db 817 break;
dragondrunk 0:b6fa066730db 818 }
dragondrunk 0:b6fa066730db 819 printf("This is atk_platform.\n");
dragondrunk 0:b6fa066730db 820 print_atk_platform();
dragondrunk 0:b6fa066730db 821 printf("This is ship_destroyed. : ");
dragondrunk 0:b6fa066730db 822 print_ship_destroyed();
dragondrunk 0:b6fa066730db 823 if(TellUrEnemy_uWin()==1){
dragondrunk 0:b6fa066730db 824 while(uli<100){
dragondrunk 0:b6fa066730db 825 bt.putc('u');
dragondrunk 0:b6fa066730db 826 uli++;
dragondrunk 0:b6fa066730db 827 }
dragondrunk 0:b6fa066730db 828 dotmatrix.display_pic(winlose[1],rgblose);
dragondrunk 0:b6fa066730db 829 printf("BOO!! You lost!\n");
dragondrunk 0:b6fa066730db 830 break;
dragondrunk 0:b6fa066730db 831 }else{state = 0;}
dragondrunk 0:b6fa066730db 832 }
dragondrunk 0:b6fa066730db 833 }
dragondrunk 0:b6fa066730db 834 while(1){
dragondrunk 0:b6fa066730db 835 printf("END\n");
dragondrunk 0:b6fa066730db 836 if(check_win == 1){dotmatrix.display_pic(winlose[0],rgbwin);}
dragondrunk 0:b6fa066730db 837 else{dotmatrix.display_pic(winlose[1],rgblose);}
dragondrunk 0:b6fa066730db 838 }
dragondrunk 0:b6fa066730db 839
dragondrunk 0:b6fa066730db 840 }
dragondrunk 0:b6fa066730db 841
dragondrunk 0:b6fa066730db 842 /******************************************************************************/
dragondrunk 0:b6fa066730db 843 /* */
dragondrunk 0:b6fa066730db 844 /* */
dragondrunk 0:b6fa066730db 845 /* Another function */
dragondrunk 0:b6fa066730db 846 /* */
dragondrunk 0:b6fa066730db 847 /* */
dragondrunk 0:b6fa066730db 848 /******************************************************************************/
dragondrunk 0:b6fa066730db 849
dragondrunk 0:b6fa066730db 850 char check_joys(int jx,int jy){ //-----------------------------------------------Check joystick that it up,down,left or right.
dragondrunk 0:b6fa066730db 851
dragondrunk 0:b6fa066730db 852 if(ifUrJirat==1){
dragondrunk 0:b6fa066730db 853 if(jx < 14.0){ return 'a';}
dragondrunk 0:b6fa066730db 854 else if(jx > 1010.0){return 'd';}
dragondrunk 0:b6fa066730db 855 else if(jy < 14.0){ return 'w';}
dragondrunk 0:b6fa066730db 856 else if(jy > 1010.0){return 's';}
dragondrunk 0:b6fa066730db 857 else{return NULL;}
dragondrunk 0:b6fa066730db 858 }else{
dragondrunk 0:b6fa066730db 859 if(jx < 14.0){ return 'd';}
dragondrunk 0:b6fa066730db 860 else if(jx > 1010.0){return 'a';}
dragondrunk 0:b6fa066730db 861 else if(jy < 14.0){ return 's';}
dragondrunk 0:b6fa066730db 862 else if(jy > 1010.0){return 'w';}
dragondrunk 0:b6fa066730db 863 else{return NULL;}
dragondrunk 0:b6fa066730db 864 }
dragondrunk 0:b6fa066730db 865 }
dragondrunk 0:b6fa066730db 866 int check_joys_int(int jx,int jy){ //--------------------------------------------Check joystick that it is centre.
dragondrunk 0:b6fa066730db 867 if(jx>=450.0&&jx<=600.0){
dragondrunk 0:b6fa066730db 868 if(jy>=450.0&&jy<=600.0){
dragondrunk 0:b6fa066730db 869 return 1;
dragondrunk 0:b6fa066730db 870 }else{
dragondrunk 0:b6fa066730db 871 return 0;
dragondrunk 0:b6fa066730db 872 }
dragondrunk 0:b6fa066730db 873 }else{
dragondrunk 0:b6fa066730db 874 return 0;
dragondrunk 0:b6fa066730db 875 }
dragondrunk 0:b6fa066730db 876 }
dragondrunk 0:b6fa066730db 877 void Select_Position(char M,int SetOrPlay){ //-------------------------------------------------Change position of cursor (Joystick).
dragondrunk 0:b6fa066730db 878 int protect_ships;
dragondrunk 0:b6fa066730db 879 protect_ships = protect_ship(select_Position,ship_SelectType[iShipType]);
dragondrunk 0:b6fa066730db 880 switch(M){
dragondrunk 0:b6fa066730db 881 case 'a':
dragondrunk 0:b6fa066730db 882 if(select_Position%10!=0){
dragondrunk 0:b6fa066730db 883 select_Position = select_Position - 1;
dragondrunk 0:b6fa066730db 884 }
dragondrunk 0:b6fa066730db 885 break;
dragondrunk 0:b6fa066730db 886 case 'd':
dragondrunk 0:b6fa066730db 887 if(select_Position%10!=7){
dragondrunk 0:b6fa066730db 888 if(SetOrPlay==1){
dragondrunk 0:b6fa066730db 889 select_Position = select_Position + 1;
dragondrunk 0:b6fa066730db 890 }else{
dragondrunk 0:b6fa066730db 891 if(protect_ships==1 or protect_ships==0){
dragondrunk 0:b6fa066730db 892 select_Position = select_Position + 1;
dragondrunk 0:b6fa066730db 893 }
dragondrunk 0:b6fa066730db 894 }
dragondrunk 0:b6fa066730db 895 }
dragondrunk 0:b6fa066730db 896 break;
dragondrunk 0:b6fa066730db 897 case 'w':
dragondrunk 0:b6fa066730db 898 if(select_Position/10!=0){
dragondrunk 0:b6fa066730db 899 select_Position = select_Position - 10;
dragondrunk 0:b6fa066730db 900 }
dragondrunk 0:b6fa066730db 901 break;
dragondrunk 0:b6fa066730db 902 case 's':
dragondrunk 0:b6fa066730db 903 if(select_Position/10!=7){
dragondrunk 0:b6fa066730db 904 if(SetOrPlay==1){
dragondrunk 0:b6fa066730db 905 select_Position = select_Position + 10;
dragondrunk 0:b6fa066730db 906 }else{
dragondrunk 0:b6fa066730db 907 if(protect_ships==1 or protect_ships==2){
dragondrunk 0:b6fa066730db 908 select_Position = select_Position + 10;
dragondrunk 0:b6fa066730db 909 }
dragondrunk 0:b6fa066730db 910 }
dragondrunk 0:b6fa066730db 911 }
dragondrunk 0:b6fa066730db 912 break;
dragondrunk 0:b6fa066730db 913 }
dragondrunk 0:b6fa066730db 914 }
dragondrunk 0:b6fa066730db 915 int protect_ship(int head_position,int ship_type){
dragondrunk 0:b6fa066730db 916 int x,y = 0;
dragondrunk 0:b6fa066730db 917 y = head_position/10;
dragondrunk 0:b6fa066730db 918 x = head_position%10;
dragondrunk 0:b6fa066730db 919 if(ship_type==4){if((y+4)>7){return 0;}else{return 1;}}
dragondrunk 0:b6fa066730db 920 else if(ship_type==3){if((x+3)>7){return 2;}else{return 1;}}
dragondrunk 0:b6fa066730db 921 else if(ship_type==2){if((y+2)>7){return 0;}else{return 1;}}
dragondrunk 0:b6fa066730db 922 else{return 1;}
dragondrunk 0:b6fa066730db 923 }
dragondrunk 0:b6fa066730db 924 int get_ship_platform(int input_position,int ship_type){ //-----------------------Plot ship in ship area.
dragondrunk 0:b6fa066730db 925 int i,x,y = 0;
dragondrunk 0:b6fa066730db 926 int error = 0;
dragondrunk 0:b6fa066730db 927
dragondrunk 0:b6fa066730db 928 y = input_position/10;
dragondrunk 0:b6fa066730db 929 x = input_position%10;
dragondrunk 0:b6fa066730db 930
dragondrunk 0:b6fa066730db 931 for(i=0;i<ship_type;i++){
dragondrunk 0:b6fa066730db 932 if(check_correctPosition(y,x) == 1){
dragondrunk 0:b6fa066730db 933 if(ship_type == 4){ship4[i] = (y*10)+x;}
dragondrunk 0:b6fa066730db 934 else if(ship_type == 3){ship3[i] = (y*10)+x;}
dragondrunk 0:b6fa066730db 935 else if(ship_type == 2){ship2[check_ship2][i] = (y*10)+x;}
dragondrunk 0:b6fa066730db 936 else if(ship_type == 1){ship1[check_ship1] = (y*10)+x;check_ship1++;}
dragondrunk 0:b6fa066730db 937 }else{error = 1;break;}
dragondrunk 0:b6fa066730db 938 if(ship_type%2 == 0){y++;}else{x++;}
dragondrunk 0:b6fa066730db 939 }
dragondrunk 0:b6fa066730db 940 if(ship_type==2){check_ship2++;}
dragondrunk 0:b6fa066730db 941 if(error == 1){return 0;}else{
dragondrunk 0:b6fa066730db 942 y = input_position/10;
dragondrunk 0:b6fa066730db 943 x = input_position%10;
dragondrunk 0:b6fa066730db 944 for(i=0;i<ship_type;i++){
dragondrunk 0:b6fa066730db 945 if(ship_type == 2 and check_ship2==1){
dragondrunk 0:b6fa066730db 946 ship_platform[y][x] = ship_type + 3;
dragondrunk 0:b6fa066730db 947 }else{ship_platform[y][x] = ship_type;}
dragondrunk 0:b6fa066730db 948 if(ship_type%2 == 0){y++;}else{x++;}
dragondrunk 0:b6fa066730db 949 }
dragondrunk 0:b6fa066730db 950 return 1;
dragondrunk 0:b6fa066730db 951 }
dragondrunk 0:b6fa066730db 952 }
dragondrunk 0:b6fa066730db 953 int check_correctPosition(int X,int Y){
dragondrunk 0:b6fa066730db 954 if(X<=7){
dragondrunk 0:b6fa066730db 955 if(Y<=7){
dragondrunk 0:b6fa066730db 956 if(ship_platform[X][Y] == 0){return 1;}else{return 0;}
dragondrunk 0:b6fa066730db 957 }else{return 0;}
dragondrunk 0:b6fa066730db 958 }else{return 0;}
dragondrunk 0:b6fa066730db 959 }
dragondrunk 0:b6fa066730db 960 void print_ship_platform(){
dragondrunk 0:b6fa066730db 961 for(int i=0;i<8;i++){
dragondrunk 0:b6fa066730db 962 for(int j=0;j<8;j++){
dragondrunk 0:b6fa066730db 963 printf("| %d |",ship_platform[i][j]);
dragondrunk 0:b6fa066730db 964 }
dragondrunk 0:b6fa066730db 965 printf("\n");
dragondrunk 0:b6fa066730db 966 }
dragondrunk 0:b6fa066730db 967 }
dragondrunk 0:b6fa066730db 968 void print_enemy_platform(){
dragondrunk 0:b6fa066730db 969 for(int i=0;i<8;i++){
dragondrunk 0:b6fa066730db 970 for(int j=0;j<8;j++){
dragondrunk 0:b6fa066730db 971 printf("| %d |",enemy_platform[i][j]);
dragondrunk 0:b6fa066730db 972 }
dragondrunk 0:b6fa066730db 973 printf("\n");
dragondrunk 0:b6fa066730db 974 }
dragondrunk 0:b6fa066730db 975 }
dragondrunk 0:b6fa066730db 976 void print_atk_platform(){
dragondrunk 0:b6fa066730db 977 for(int i=0;i<8;i++){
dragondrunk 0:b6fa066730db 978 for(int j=0;j<8;j++){
dragondrunk 0:b6fa066730db 979 printf("| %d |",atk_platform[i][j]);
dragondrunk 0:b6fa066730db 980 }
dragondrunk 0:b6fa066730db 981 printf("\n");
dragondrunk 0:b6fa066730db 982 }
dragondrunk 0:b6fa066730db 983 }
dragondrunk 0:b6fa066730db 984 void print_ship_destroyed(){
dragondrunk 0:b6fa066730db 985 printf("{");
dragondrunk 0:b6fa066730db 986 for(int i=0;i<8;i++){
dragondrunk 0:b6fa066730db 987 printf("%d",ship_destroyed[i]);
dragondrunk 0:b6fa066730db 988 if(i!=14){printf(",");}
dragondrunk 0:b6fa066730db 989 }
dragondrunk 0:b6fa066730db 990 printf("}\n");
dragondrunk 0:b6fa066730db 991 }
dragondrunk 0:b6fa066730db 992 void check_ready(){
dragondrunk 0:b6fa066730db 993 if(bt.readable()){enemy_ready = 1;}
dragondrunk 0:b6fa066730db 994 }
dragondrunk 0:b6fa066730db 995 char posit2char(int posit){
dragondrunk 0:b6fa066730db 996 int as = posit+48;
dragondrunk 0:b6fa066730db 997 char ch = as;
dragondrunk 0:b6fa066730db 998 return ch ;
dragondrunk 0:b6fa066730db 999 }
dragondrunk 0:b6fa066730db 1000 int char2posit(char cha){
dragondrunk 0:b6fa066730db 1001 int as = cha;
dragondrunk 0:b6fa066730db 1002 as = as-48;
dragondrunk 0:b6fa066730db 1003 return as;
dragondrunk 0:b6fa066730db 1004 }
dragondrunk 0:b6fa066730db 1005 void get_atk_platform(int atkpos){
dragondrunk 0:b6fa066730db 1006 int i,j,k,x,y,error = 0;
dragondrunk 0:b6fa066730db 1007
dragondrunk 0:b6fa066730db 1008 x = atkpos/10;
dragondrunk 0:b6fa066730db 1009 y = atkpos%10;
dragondrunk 0:b6fa066730db 1010
dragondrunk 0:b6fa066730db 1011 if(ship_platform[x][y]!=0){
dragondrunk 0:b6fa066730db 1012 change_orange_myship(x,y);
dragondrunk 0:b6fa066730db 1013
dragondrunk 0:b6fa066730db 1014 if(atk_platform[x][y]==0){
dragondrunk 0:b6fa066730db 1015 atk_platform[x][y] = ship_platform[x][y];
dragondrunk 0:b6fa066730db 1016 printf("posit2char : %c\n",posit2char(atk_platform[x][y]));
dragondrunk 0:b6fa066730db 1017 bt.putc(posit2char(atk_platform[x][y]));
dragondrunk 0:b6fa066730db 1018 for(k=0;k<15;k++){
dragondrunk 0:b6fa066730db 1019 if(ship_underATK[k]==atkpos){error=1;break;}
dragondrunk 0:b6fa066730db 1020 }
dragondrunk 0:b6fa066730db 1021 if (error!=1) {
dragondrunk 0:b6fa066730db 1022 ship_underATK[check_ship_underATK] = atkpos;
dragondrunk 0:b6fa066730db 1023 check_ship_underATK++;
dragondrunk 0:b6fa066730db 1024 if(atk_platform[x][y]==4){
dragondrunk 0:b6fa066730db 1025 for(i=0;i<4;i++){
dragondrunk 0:b6fa066730db 1026 for(j=0;j<15;j++){
dragondrunk 0:b6fa066730db 1027 if(ship4[i]==ship_underATK[j]){ship_destroyed[0]++;}
dragondrunk 0:b6fa066730db 1028 }
dragondrunk 0:b6fa066730db 1029 }
dragondrunk 0:b6fa066730db 1030 }else if(atk_platform[x][y]==3){
dragondrunk 0:b6fa066730db 1031 for(i=0;i<3;i++){
dragondrunk 0:b6fa066730db 1032 for(j=0;j<15;j++){
dragondrunk 0:b6fa066730db 1033 if(ship3[i]==ship_underATK[j]){ship_destroyed[1]++;}
dragondrunk 0:b6fa066730db 1034 }
dragondrunk 0:b6fa066730db 1035 }
dragondrunk 0:b6fa066730db 1036 }else if(atk_platform[x][y]==5){
dragondrunk 0:b6fa066730db 1037 for(i=0;i<2;i++){
dragondrunk 0:b6fa066730db 1038 for(j=0;j<15;j++){
dragondrunk 0:b6fa066730db 1039 if(ship2[0][i]==ship_underATK[j]){ship_destroyed[2]++;}
dragondrunk 0:b6fa066730db 1040 }
dragondrunk 0:b6fa066730db 1041 }
dragondrunk 0:b6fa066730db 1042 }else if(atk_platform[x][y]==2){
dragondrunk 0:b6fa066730db 1043 for(i=0;i<2;i++){
dragondrunk 0:b6fa066730db 1044 for(j=0;j<15;j++){
dragondrunk 0:b6fa066730db 1045 if(ship2[1][i]==ship_underATK[j]){ship_destroyed[3]++;}
dragondrunk 0:b6fa066730db 1046 }
dragondrunk 0:b6fa066730db 1047 }
dragondrunk 0:b6fa066730db 1048 }else if(atk_platform[x][y]==1){
dragondrunk 0:b6fa066730db 1049 atk_platform[x][y] = 11;
dragondrunk 0:b6fa066730db 1050 ship_myShipsRdestroyed[iGSU] = atkpos;
dragondrunk 0:b6fa066730db 1051 for(i=0;i<4;i++){
dragondrunk 0:b6fa066730db 1052 for(j=0;j<15;j++){
dragondrunk 0:b6fa066730db 1053 if(ship3[i]==ship_underATK[j]){
dragondrunk 0:b6fa066730db 1054 ship_destroyed[4+i]++;
dragondrunk 0:b6fa066730db 1055 iGSU++;
dragondrunk 0:b6fa066730db 1056 }
dragondrunk 0:b6fa066730db 1057 }
dragondrunk 0:b6fa066730db 1058 }
dragondrunk 0:b6fa066730db 1059 }
dragondrunk 0:b6fa066730db 1060 }
dragondrunk 0:b6fa066730db 1061 }else{
dragondrunk 0:b6fa066730db 1062 printf("You repeatedly attacked.\n");
dragondrunk 0:b6fa066730db 1063 }
dragondrunk 0:b6fa066730db 1064 }else{
dragondrunk 0:b6fa066730db 1065 change_green_myship(x,y);
dragondrunk 0:b6fa066730db 1066 atk_platform[x][y] = 8;
dragondrunk 0:b6fa066730db 1067 bt.putc(posit2char(atk_platform[x][y]));
dragondrunk 0:b6fa066730db 1068 }
dragondrunk 0:b6fa066730db 1069
dragondrunk 0:b6fa066730db 1070 }
dragondrunk 0:b6fa066730db 1071 void get_ship_UShipsRdestroyed(){
dragondrunk 0:b6fa066730db 1072 int error=0;
dragondrunk 0:b6fa066730db 1073 int ship[8] = {0};
dragondrunk 0:b6fa066730db 1074 for(int k=0;k<2;k++){
dragondrunk 0:b6fa066730db 1075 for(int i=0;i<8;i++){
dragondrunk 0:b6fa066730db 1076 for(int j=0;j<8;j++){
dragondrunk 0:b6fa066730db 1077 if(enemy_platform[i][j]==4){
dragondrunk 0:b6fa066730db 1078 error=0;
dragondrunk 0:b6fa066730db 1079 if(k==0){ship[0]++;}
dragondrunk 0:b6fa066730db 1080 if(ship[4]==1){
dragondrunk 0:b6fa066730db 1081 for(int l=0;l<15;l++){
dragondrunk 0:b6fa066730db 1082 if(ship_UShipsRdestroyed[l]==(i*10)+j){error=1;break;}
dragondrunk 0:b6fa066730db 1083 }
dragondrunk 0:b6fa066730db 1084 if(error!=1){
dragondrunk 0:b6fa066730db 1085 ship_UShipsRdestroyed[iSUSPD] = (i*10)+j;
dragondrunk 0:b6fa066730db 1086 iSUSPD++;
dragondrunk 0:b6fa066730db 1087 }
dragondrunk 0:b6fa066730db 1088 }
dragondrunk 0:b6fa066730db 1089 }
dragondrunk 0:b6fa066730db 1090 else if(enemy_platform[i][j]==3){
dragondrunk 0:b6fa066730db 1091 error=0;
dragondrunk 0:b6fa066730db 1092 if(k==0){
dragondrunk 0:b6fa066730db 1093 ship[1]++;
dragondrunk 0:b6fa066730db 1094 }
dragondrunk 0:b6fa066730db 1095 if(ship[5]==1){
dragondrunk 0:b6fa066730db 1096 for(int l=0;l<15;l++){
dragondrunk 0:b6fa066730db 1097 if(ship_UShipsRdestroyed[l]==(i*10)+j){error=1;break;}
dragondrunk 0:b6fa066730db 1098 }
dragondrunk 0:b6fa066730db 1099 if(error!=1){
dragondrunk 0:b6fa066730db 1100 ship_UShipsRdestroyed[iSUSPD] = (i*10)+j;
dragondrunk 0:b6fa066730db 1101 iSUSPD++;
dragondrunk 0:b6fa066730db 1102 }
dragondrunk 0:b6fa066730db 1103 }
dragondrunk 0:b6fa066730db 1104 }
dragondrunk 0:b6fa066730db 1105 else if(enemy_platform[i][j]==2){
dragondrunk 0:b6fa066730db 1106 error=0;
dragondrunk 0:b6fa066730db 1107 if(k==0){
dragondrunk 0:b6fa066730db 1108 ship[2]++;
dragondrunk 0:b6fa066730db 1109 }
dragondrunk 0:b6fa066730db 1110 if(ship[6]==1){
dragondrunk 0:b6fa066730db 1111 for(int l=0;l<15;l++){
dragondrunk 0:b6fa066730db 1112 if(ship_UShipsRdestroyed[l]==(i*10)+j){error=1;break;}
dragondrunk 0:b6fa066730db 1113 }
dragondrunk 0:b6fa066730db 1114 if(error!=1){
dragondrunk 0:b6fa066730db 1115 ship_UShipsRdestroyed[iSUSPD] = (i*10)+j;
dragondrunk 0:b6fa066730db 1116 iSUSPD++;
dragondrunk 0:b6fa066730db 1117 }
dragondrunk 0:b6fa066730db 1118 }
dragondrunk 0:b6fa066730db 1119 }
dragondrunk 0:b6fa066730db 1120 else if(enemy_platform[i][j]==5){
dragondrunk 0:b6fa066730db 1121 error=0;
dragondrunk 0:b6fa066730db 1122 if(k==0){
dragondrunk 0:b6fa066730db 1123 ship[3]++;
dragondrunk 0:b6fa066730db 1124 }
dragondrunk 0:b6fa066730db 1125 if(ship[7]==1){
dragondrunk 0:b6fa066730db 1126 for(int l=0;l<15;l++){
dragondrunk 0:b6fa066730db 1127 if(ship_UShipsRdestroyed[l]==(i*10)+j){error=1;break;}
dragondrunk 0:b6fa066730db 1128 }
dragondrunk 0:b6fa066730db 1129 if(error!=1){
dragondrunk 0:b6fa066730db 1130 ship_UShipsRdestroyed[iSUSPD] = (i*10)+j;
dragondrunk 0:b6fa066730db 1131 iSUSPD++;
dragondrunk 0:b6fa066730db 1132 }
dragondrunk 0:b6fa066730db 1133 }
dragondrunk 0:b6fa066730db 1134 }
dragondrunk 0:b6fa066730db 1135 else if(enemy_platform[i][j]==1){
dragondrunk 0:b6fa066730db 1136 for(int l=0;l<15;l++){
dragondrunk 0:b6fa066730db 1137 if(ship_UShipsRdestroyed[l]==(i*10)+j){error=1;break;}
dragondrunk 0:b6fa066730db 1138 }
dragondrunk 0:b6fa066730db 1139 if(error!=1){
dragondrunk 0:b6fa066730db 1140 ship_UShipsRdestroyed[iSUSPD] = (i*10)+j;
dragondrunk 0:b6fa066730db 1141 iSUSPD++;
dragondrunk 0:b6fa066730db 1142 }
dragondrunk 0:b6fa066730db 1143 }
dragondrunk 0:b6fa066730db 1144 }
dragondrunk 0:b6fa066730db 1145 }
dragondrunk 0:b6fa066730db 1146 if(ship[0]==4){ship[4]=1;}
dragondrunk 0:b6fa066730db 1147 if(ship[1]==3){ship[5]=1;}
dragondrunk 0:b6fa066730db 1148 if(ship[2]==2){ship[6]=1;}
dragondrunk 0:b6fa066730db 1149 if(ship[3]==2){ship[7]=1;}
dragondrunk 0:b6fa066730db 1150 }/*
dragondrunk 0:b6fa066730db 1151 printf("ship[] : ");
dragondrunk 0:b6fa066730db 1152 for (int i=0;i<8;i++) {
dragondrunk 0:b6fa066730db 1153 printf("| %d |", ship[i]);
dragondrunk 0:b6fa066730db 1154 }
dragondrunk 0:b6fa066730db 1155 printf("\n");
dragondrunk 0:b6fa066730db 1156 for(int i=0;i<15;i++){
dragondrunk 0:b6fa066730db 1157 printf("| %d ",ship_UShipsRdestroyed[i] );
dragondrunk 0:b6fa066730db 1158 }
dragondrunk 0:b6fa066730db 1159 printf("\n");*/
dragondrunk 0:b6fa066730db 1160 }
dragondrunk 0:b6fa066730db 1161 void mark_ship_destroyed(){
dragondrunk 0:b6fa066730db 1162 int i,j,k = 0;
dragondrunk 0:b6fa066730db 1163
dragondrunk 0:b6fa066730db 1164 if(ship_destroyed[0]==10){
dragondrunk 0:b6fa066730db 1165 for(i=0;i<8;i++){
dragondrunk 0:b6fa066730db 1166 for(j=0;j<8;j++){
dragondrunk 0:b6fa066730db 1167 if(atk_platform[i][j]==4){
dragondrunk 0:b6fa066730db 1168 atk_platform[i][j] = 11;
dragondrunk 0:b6fa066730db 1169 ship_myShipsRdestroyed[iGSU] = (i*10)+j;
dragondrunk 0:b6fa066730db 1170 iGSU++;
dragondrunk 0:b6fa066730db 1171 }
dragondrunk 0:b6fa066730db 1172 }
dragondrunk 0:b6fa066730db 1173 }
dragondrunk 0:b6fa066730db 1174 }
dragondrunk 0:b6fa066730db 1175 if(ship_destroyed[1]==6){
dragondrunk 0:b6fa066730db 1176 for(i=0;i<8;i++){
dragondrunk 0:b6fa066730db 1177 for(j=0;j<8;j++){
dragondrunk 0:b6fa066730db 1178 if(atk_platform[i][j]==3){
dragondrunk 0:b6fa066730db 1179 atk_platform[i][j] = 11;
dragondrunk 0:b6fa066730db 1180 ship_myShipsRdestroyed[iGSU] = (i*10)+j;
dragondrunk 0:b6fa066730db 1181 iGSU++;
dragondrunk 0:b6fa066730db 1182 }
dragondrunk 0:b6fa066730db 1183 }
dragondrunk 0:b6fa066730db 1184 }
dragondrunk 0:b6fa066730db 1185 }
dragondrunk 0:b6fa066730db 1186 if(ship_destroyed[2]==3){
dragondrunk 0:b6fa066730db 1187 for(k=0;k<2;k++){
dragondrunk 0:b6fa066730db 1188 i = ship2[0][k]/10;
dragondrunk 0:b6fa066730db 1189 j = ship2[0][k]%10;
dragondrunk 0:b6fa066730db 1190 atk_platform[i][j] = 11;
dragondrunk 0:b6fa066730db 1191 ship_myShipsRdestroyed[iGSU] = (i*10)+j;
dragondrunk 0:b6fa066730db 1192 iGSU++;
dragondrunk 0:b6fa066730db 1193 }
dragondrunk 0:b6fa066730db 1194 }
dragondrunk 0:b6fa066730db 1195 if(ship_destroyed[3]==3){
dragondrunk 0:b6fa066730db 1196 for(k=0;k<2;k++){
dragondrunk 0:b6fa066730db 1197 i = ship2[1][k]/10;
dragondrunk 0:b6fa066730db 1198 j = ship2[1][k]%10;
dragondrunk 0:b6fa066730db 1199 atk_platform[i][j] = 11;
dragondrunk 0:b6fa066730db 1200 ship_myShipsRdestroyed[iGSU] = (i*10)+j;
dragondrunk 0:b6fa066730db 1201 iGSU++;
dragondrunk 0:b6fa066730db 1202 }
dragondrunk 0:b6fa066730db 1203 }
dragondrunk 0:b6fa066730db 1204 }
dragondrunk 0:b6fa066730db 1205 void atk_enemy(){
dragondrunk 0:b6fa066730db 1206 // comment for display : see only bomb and history of planting
dragondrunk 0:b6fa066730db 1207 float Vx;
dragondrunk 0:b6fa066730db 1208 float Vy;
dragondrunk 0:b6fa066730db 1209 int SW,iVxVy,iSW,n = 0;
dragondrunk 0:b6fa066730db 1210 char m;
dragondrunk 0:b6fa066730db 1211
dragondrunk 0:b6fa066730db 1212 select_Position = 0;
dragondrunk 0:b6fa066730db 1213 t.start();
dragondrunk 0:b6fa066730db 1214 while(1){
dragondrunk 0:b6fa066730db 1215 for(int i = 0;i<8;i++){
dragondrunk 0:b6fa066730db 1216 for (int j = 0 ;j < 8; j++) {
dragondrunk 0:b6fa066730db 1217 main_frame1[i][j][0] = plot_bombed_usage[i][j][0] + bomb[i][j][0];
dragondrunk 0:b6fa066730db 1218 main_frame1[i][j][1] = plot_bombed_usage[i][j][1] + bomb[i][j][1];
dragondrunk 0:b6fa066730db 1219 main_frame1[i][j][2] = plot_bombed_usage[i][j][2] + bomb[i][j][2];
dragondrunk 0:b6fa066730db 1220 }
dragondrunk 0:b6fa066730db 1221 }
dragondrunk 0:b6fa066730db 1222
dragondrunk 0:b6fa066730db 1223 if(t.read()<0.4){
dragondrunk 0:b6fa066730db 1224 dotmatrix.display_big_array(main_frame1);
dragondrunk 0:b6fa066730db 1225 }
dragondrunk 0:b6fa066730db 1226 else if(t.read() > 0.4 && t.read() < 0.8){
dragondrunk 0:b6fa066730db 1227 dotmatrix.display_big_array(plot_bombed_usage);
dragondrunk 0:b6fa066730db 1228 }
dragondrunk 0:b6fa066730db 1229 else{
dragondrunk 0:b6fa066730db 1230 t.reset();
dragondrunk 0:b6fa066730db 1231 }
dragondrunk 0:b6fa066730db 1232 Vx = VRx.read() * 1024;
dragondrunk 0:b6fa066730db 1233 Vy = VRy.read() * 1024;
dragondrunk 0:b6fa066730db 1234 SW = Button.read();
dragondrunk 0:b6fa066730db 1235 m = check_joys(Vx,Vy);
dragondrunk 0:b6fa066730db 1236 n = check_joys_int(Vx,Vy);
dragondrunk 0:b6fa066730db 1237 if(n == 1){ iVxVy = 0;}
dragondrunk 0:b6fa066730db 1238 if(SW == 1){
dragondrunk 0:b6fa066730db 1239 iSW = 0;
dragondrunk 0:b6fa066730db 1240 }
dragondrunk 0:b6fa066730db 1241 if(iSW == 1){
dragondrunk 0:b6fa066730db 1242 if(bt.readable()){
dragondrunk 0:b6fa066730db 1243 enemy_platform[select_Position/10][select_Position%10] = char2posit(bt.getc());
dragondrunk 0:b6fa066730db 1244 if(enemy_platform[select_Position/10][select_Position%10] == 8){
dragondrunk 0:b6fa066730db 1245 change_green_hisship(select_Position/10,select_Position%10);
dragondrunk 0:b6fa066730db 1246 }
dragondrunk 0:b6fa066730db 1247 else{
dragondrunk 0:b6fa066730db 1248 change_orange_hisship(select_Position/10,select_Position%10);
dragondrunk 0:b6fa066730db 1249 }
dragondrunk 0:b6fa066730db 1250 get_ship_UShipsRdestroyed();
dragondrunk 0:b6fa066730db 1251 change_red_deadship(ship_UShipsRdestroyed,1);
dragondrunk 0:b6fa066730db 1252 t.stop();
dragondrunk 0:b6fa066730db 1253 t.reset();
dragondrunk 0:b6fa066730db 1254 t.start();
dragondrunk 0:b6fa066730db 1255 while (1) {
dragondrunk 0:b6fa066730db 1256 if(t.read()<1){dotmatrix.display_big_array(plot_bombed_usage);}
dragondrunk 0:b6fa066730db 1257 else{break;} // try++++++++++++++++++++++++++++++++++
dragondrunk 0:b6fa066730db 1258 }
dragondrunk 0:b6fa066730db 1259 set_zero();
dragondrunk 0:b6fa066730db 1260 break;
dragondrunk 0:b6fa066730db 1261 }
dragondrunk 0:b6fa066730db 1262 }
dragondrunk 0:b6fa066730db 1263 if(m!=NULL and iVxVy==0){
dragondrunk 0:b6fa066730db 1264 Select_Position(m,1);
dragondrunk 0:b6fa066730db 1265 plant_bomb(m);
dragondrunk 0:b6fa066730db 1266 printf("select_Position = %d\n",select_Position);
dragondrunk 0:b6fa066730db 1267 bt.putc(posit2char(select_Position));
dragondrunk 0:b6fa066730db 1268 iVxVy = 1;
dragondrunk 0:b6fa066730db 1269 }
dragondrunk 0:b6fa066730db 1270 if(SW==0 && iSW==0){
dragondrunk 0:b6fa066730db 1271 bt.putc('B');
dragondrunk 0:b6fa066730db 1272 printf("You attacking at position %d\n",select_Position);
dragondrunk 0:b6fa066730db 1273 iSW = 1;
dragondrunk 0:b6fa066730db 1274 }
dragondrunk 0:b6fa066730db 1275 }
dragondrunk 0:b6fa066730db 1276 }
dragondrunk 0:b6fa066730db 1277 void enemy_atk(){
dragondrunk 0:b6fa066730db 1278 int data_fromEnemy;
dragondrunk 0:b6fa066730db 1279 char replica_data_fromEnemy;
dragondrunk 0:b6fa066730db 1280 select_Position = 0;
dragondrunk 0:b6fa066730db 1281 t.start();
dragondrunk 0:b6fa066730db 1282 while(1){
dragondrunk 0:b6fa066730db 1283 for(int i = 0;i<8;i++){
dragondrunk 0:b6fa066730db 1284 for (int j = 0 ;j < 8; j++) {
dragondrunk 0:b6fa066730db 1285 main_frame2[i][j][0] = ship[i][j][0] + bomb_enemy[i][j][0];
dragondrunk 0:b6fa066730db 1286 main_frame2[i][j][1] = ship[i][j][1] + bomb_enemy[i][j][1];
dragondrunk 0:b6fa066730db 1287 main_frame2[i][j][2] = ship[i][j][2] + bomb_enemy[i][j][2];
dragondrunk 0:b6fa066730db 1288 }
dragondrunk 0:b6fa066730db 1289 }
dragondrunk 0:b6fa066730db 1290 if(t.read()<0.4){
dragondrunk 0:b6fa066730db 1291 dotmatrix.display_big_array(main_frame2);
dragondrunk 0:b6fa066730db 1292 }
dragondrunk 0:b6fa066730db 1293 else if(t.read() > 0.4 && t.read() < 0.8){
dragondrunk 0:b6fa066730db 1294 dotmatrix.display_big_array(ship);
dragondrunk 0:b6fa066730db 1295 }
dragondrunk 0:b6fa066730db 1296 else{
dragondrunk 0:b6fa066730db 1297 t.reset();
dragondrunk 0:b6fa066730db 1298 }
dragondrunk 0:b6fa066730db 1299 if(bt.readable()){
dragondrunk 0:b6fa066730db 1300 replica_data_fromEnemy = bt.getc();
dragondrunk 0:b6fa066730db 1301 if(replica_data_fromEnemy!='u' and replica_data_fromEnemy!=8){
dragondrunk 0:b6fa066730db 1302 data_fromEnemy = char2posit(replica_data_fromEnemy);
dragondrunk 0:b6fa066730db 1303 if(data_fromEnemy != 18){
dragondrunk 0:b6fa066730db 1304 select_Position = data_fromEnemy;
dragondrunk 0:b6fa066730db 1305 display_bomb_enemy(select_Position/10,select_Position%10);
dragondrunk 0:b6fa066730db 1306 printf("enemy select_Position = %d\n",select_Position);
dragondrunk 0:b6fa066730db 1307 }else{
dragondrunk 0:b6fa066730db 1308 ATKposition = select_Position;
dragondrunk 0:b6fa066730db 1309
dragondrunk 0:b6fa066730db 1310 break;
dragondrunk 0:b6fa066730db 1311 }
dragondrunk 0:b6fa066730db 1312 }
dragondrunk 0:b6fa066730db 1313 if(replica_data_fromEnemy=='u'){
dragondrunk 0:b6fa066730db 1314 check_win = 1;
dragondrunk 0:b6fa066730db 1315 break;
dragondrunk 0:b6fa066730db 1316 }
dragondrunk 0:b6fa066730db 1317 }
dragondrunk 0:b6fa066730db 1318 }
dragondrunk 0:b6fa066730db 1319 if(check_win!=1){
dragondrunk 0:b6fa066730db 1320 printf("Enemy attack at your area %d\n",ATKposition);
dragondrunk 0:b6fa066730db 1321 get_atk_platform(ATKposition);
dragondrunk 0:b6fa066730db 1322 t.stop();
dragondrunk 0:b6fa066730db 1323 t.reset();
dragondrunk 0:b6fa066730db 1324 t.start();
dragondrunk 0:b6fa066730db 1325 while (1) {
dragondrunk 0:b6fa066730db 1326 if(t.read()<1){dotmatrix.display_big_array(ship);}
dragondrunk 0:b6fa066730db 1327 else{break;} // try++++++++++++++++++++++++++++++++++
dragondrunk 0:b6fa066730db 1328 }
dragondrunk 0:b6fa066730db 1329 mark_ship_destroyed();
dragondrunk 0:b6fa066730db 1330 change_red_deadship(ship_myShipsRdestroyed,0);
dragondrunk 0:b6fa066730db 1331 }
dragondrunk 0:b6fa066730db 1332 for (int i = 0; i < 15; i++) {
dragondrunk 0:b6fa066730db 1333 printf("! %d !", ship_underATK[i]);
dragondrunk 0:b6fa066730db 1334 }
dragondrunk 0:b6fa066730db 1335
dragondrunk 0:b6fa066730db 1336 }
dragondrunk 0:b6fa066730db 1337 int TellUrEnemy_uWin(){
dragondrunk 0:b6fa066730db 1338 int sub_end = 0;
dragondrunk 0:b6fa066730db 1339
dragondrunk 0:b6fa066730db 1340 for(int i=0;i<15;i++){
dragondrunk 0:b6fa066730db 1341 if(ship_underATK[i]!=9){sub_end++;}
dragondrunk 0:b6fa066730db 1342 }
dragondrunk 0:b6fa066730db 1343 if(sub_end==15){return 1;}else{return 0;}
dragondrunk 0:b6fa066730db 1344 }
dragondrunk 0:b6fa066730db 1345 int IamWin(){
dragondrunk 0:b6fa066730db 1346 char chare;
dragondrunk 0:b6fa066730db 1347 if(bt.readable()){
dragondrunk 0:b6fa066730db 1348 chare = bt.getc();
dragondrunk 0:b6fa066730db 1349 if(chare=='u'){return 1;}else{return 0;}
dragondrunk 0:b6fa066730db 1350 }else{return 0;}
dragondrunk 0:b6fa066730db 1351 }
dragondrunk 0:b6fa066730db 1352
dragondrunk 0:b6fa066730db 1353
dragondrunk 0:b6fa066730db 1354
dragondrunk 0:b6fa066730db 1355
dragondrunk 0:b6fa066730db 1356
dragondrunk 0:b6fa066730db 1357
dragondrunk 0:b6fa066730db 1358
dragondrunk 0:b6fa066730db 1359
dragondrunk 0:b6fa066730db 1360
dragondrunk 0:b6fa066730db 1361
dragondrunk 0:b6fa066730db 1362
dragondrunk 0:b6fa066730db 1363
dragondrunk 0:b6fa066730db 1364
dragondrunk 0:b6fa066730db 1365
dragondrunk 0:b6fa066730db 1366
dragondrunk 0:b6fa066730db 1367
dragondrunk 0:b6fa066730db 1368
dragondrunk 0:b6fa066730db 1369
dragondrunk 0:b6fa066730db 1370
dragondrunk 0:b6fa066730db 1371
dragondrunk 0:b6fa066730db 1372
dragondrunk 0:b6fa066730db 1373
dragondrunk 0:b6fa066730db 1374
dragondrunk 0:b6fa066730db 1375
dragondrunk 0:b6fa066730db 1376
dragondrunk 0:b6fa066730db 1377
dragondrunk 0:b6fa066730db 1378 // ____________________________________________________________________________________________________________________________________Nasarun's function.
dragondrunk 0:b6fa066730db 1379
dragondrunk 0:b6fa066730db 1380 void hex_to_array(int* ar){
dragondrunk 0:b6fa066730db 1381 int i;
dragondrunk 0:b6fa066730db 1382 int j;
dragondrunk 0:b6fa066730db 1383 int temp;
dragondrunk 0:b6fa066730db 1384 for(i = 0;i<8;i++){
dragondrunk 0:b6fa066730db 1385 temp = ar[i];
dragondrunk 0:b6fa066730db 1386 for(j = 0;j<8;j++){
dragondrunk 0:b6fa066730db 1387 if(0x80 & temp){
dragondrunk 0:b6fa066730db 1388 return_position[i][j] = 1;
dragondrunk 0:b6fa066730db 1389 }
dragondrunk 0:b6fa066730db 1390 else{
dragondrunk 0:b6fa066730db 1391 return_position[i][j] = 0;
dragondrunk 0:b6fa066730db 1392 }
dragondrunk 0:b6fa066730db 1393 temp = temp << 1;
dragondrunk 0:b6fa066730db 1394 }
dragondrunk 0:b6fa066730db 1395 }
dragondrunk 0:b6fa066730db 1396 }
dragondrunk 0:b6fa066730db 1397
dragondrunk 0:b6fa066730db 1398 void ch_same_position(int ar1[8][8],int ar2[8][8]){
dragondrunk 0:b6fa066730db 1399 int i;
dragondrunk 0:b6fa066730db 1400 int j;
dragondrunk 0:b6fa066730db 1401 for(i = 0;i<8;i++){
dragondrunk 0:b6fa066730db 1402 for(j = 0;j<8;j++){
dragondrunk 0:b6fa066730db 1403 if(ar1[i][j] == 1 && ar2[i][j] == 1){
dragondrunk 0:b6fa066730db 1404 ch_post[i][j] = 1;
dragondrunk 0:b6fa066730db 1405 }
dragondrunk 0:b6fa066730db 1406 else{
dragondrunk 0:b6fa066730db 1407 ch_post[i][j] = 0;
dragondrunk 0:b6fa066730db 1408 }
dragondrunk 0:b6fa066730db 1409 }
dragondrunk 0:b6fa066730db 1410 }
dragondrunk 0:b6fa066730db 1411
dragondrunk 0:b6fa066730db 1412 }
dragondrunk 0:b6fa066730db 1413
dragondrunk 0:b6fa066730db 1414 void discard_same_position(int ar1[8][8],int ar2[8][8]){
dragondrunk 0:b6fa066730db 1415 int i;
dragondrunk 0:b6fa066730db 1416 int j;
dragondrunk 0:b6fa066730db 1417 for(i = 0;i<8;i++){
dragondrunk 0:b6fa066730db 1418 for(j = 0;j<8;j++){
dragondrunk 0:b6fa066730db 1419 if(ar1[i][j] == ch_post[i][j] && ar2[i][j] == ch_post[i][j] ){
dragondrunk 0:b6fa066730db 1420 ar1[i][j] = 0;
dragondrunk 0:b6fa066730db 1421 ar2[i][j] = 0;
dragondrunk 0:b6fa066730db 1422 }
dragondrunk 0:b6fa066730db 1423 }
dragondrunk 0:b6fa066730db 1424 }
dragondrunk 0:b6fa066730db 1425 }
dragondrunk 0:b6fa066730db 1426
dragondrunk 0:b6fa066730db 1427
dragondrunk 0:b6fa066730db 1428 int _power(int number , int power){
dragondrunk 0:b6fa066730db 1429 int i = 0;
dragondrunk 0:b6fa066730db 1430 int number1 = number;
dragondrunk 0:b6fa066730db 1431 if(power == 0){return 1;}
dragondrunk 0:b6fa066730db 1432 for(i = 1 ; i <= power ; i++ ){
dragondrunk 0:b6fa066730db 1433 if(power == 1){return number;}
dragondrunk 0:b6fa066730db 1434 if(i == 1){number = number * 1;}
dragondrunk 0:b6fa066730db 1435 else{number1 = number1 * number;}
dragondrunk 0:b6fa066730db 1436 }
dragondrunk 0:b6fa066730db 1437 return number1;
dragondrunk 0:b6fa066730db 1438 }
dragondrunk 0:b6fa066730db 1439
dragondrunk 0:b6fa066730db 1440
dragondrunk 0:b6fa066730db 1441 void array_to_hex(int ar1[8][8]){
dragondrunk 0:b6fa066730db 1442 int prompt;
dragondrunk 0:b6fa066730db 1443 int i;
dragondrunk 0:b6fa066730db 1444 int j;
dragondrunk 0:b6fa066730db 1445 for(i = 0;i<8;i++){
dragondrunk 0:b6fa066730db 1446 for(j = 0;j<8;j++){
dragondrunk 0:b6fa066730db 1447 prompt = _power(2,7-j);
dragondrunk 0:b6fa066730db 1448 if(ar1[i][j] == 1){
dragondrunk 0:b6fa066730db 1449 for_hex = for_hex + prompt;
dragondrunk 0:b6fa066730db 1450 }
dragondrunk 0:b6fa066730db 1451 else{
dragondrunk 0:b6fa066730db 1452 for_hex = for_hex + 0;
dragondrunk 0:b6fa066730db 1453 }
dragondrunk 0:b6fa066730db 1454 }
dragondrunk 0:b6fa066730db 1455 return_hex[i] = for_hex;
dragondrunk 0:b6fa066730db 1456 prompt = 0;
dragondrunk 0:b6fa066730db 1457 for_hex = 0;
dragondrunk 0:b6fa066730db 1458 }
dragondrunk 0:b6fa066730db 1459 }
dragondrunk 0:b6fa066730db 1460
dragondrunk 0:b6fa066730db 1461 void place_ship3(char dir){
dragondrunk 0:b6fa066730db 1462 int post1[8][8] = {0};
dragondrunk 0:b6fa066730db 1463 int post2[8][8] = {0};
dragondrunk 0:b6fa066730db 1464 int hex_post1[8] = {0};
dragondrunk 0:b6fa066730db 1465 int hex_post2[8] = {0};
dragondrunk 0:b6fa066730db 1466 int hex_post_cut[8] = {0};
dragondrunk 0:b6fa066730db 1467 int get_same_position[8][8];
dragondrunk 0:b6fa066730db 1468 int wow=0;
dragondrunk 0:b6fa066730db 1469
dragondrunk 0:b6fa066730db 1470 if(dir == 'w'&& temppic2[0] == 0){
dragondrunk 0:b6fa066730db 1471 for(j=0;j<8;j++){
dragondrunk 0:b6fa066730db 1472 if(j == 7){
dragondrunk 0:b6fa066730db 1473 forshift[7] = 0;
dragondrunk 0:b6fa066730db 1474 }
dragondrunk 0:b6fa066730db 1475 else{
dragondrunk 0:b6fa066730db 1476 forshift[j] = temppic2[j+1];
dragondrunk 0:b6fa066730db 1477 }
dragondrunk 0:b6fa066730db 1478 }
dragondrunk 0:b6fa066730db 1479 for(j=0;j<8;j++){
dragondrunk 0:b6fa066730db 1480 temppic2[j] = forshift[j];
dragondrunk 0:b6fa066730db 1481 _temppic[j] = temppic2[j];
dragondrunk 0:b6fa066730db 1482 }
dragondrunk 0:b6fa066730db 1483 // begin to compare and combine two frame
dragondrunk 0:b6fa066730db 1484 hex_to_array(_temppic);
dragondrunk 0:b6fa066730db 1485 for(i = 0;i<8;i++){
dragondrunk 0:b6fa066730db 1486 for(j = 0;j<8;j++){
dragondrunk 0:b6fa066730db 1487 post1[i][j] = return_position[i][j];
dragondrunk 0:b6fa066730db 1488 }
dragondrunk 0:b6fa066730db 1489 }
dragondrunk 0:b6fa066730db 1490 hex_to_array(pic);
dragondrunk 0:b6fa066730db 1491 for(i = 0;i<8;i++){
dragondrunk 0:b6fa066730db 1492 for(j = 0;j<8;j++){
dragondrunk 0:b6fa066730db 1493 post2[i][j] = return_position[i][j];
dragondrunk 0:b6fa066730db 1494 }
dragondrunk 0:b6fa066730db 1495 }
dragondrunk 0:b6fa066730db 1496
dragondrunk 0:b6fa066730db 1497 // begin to check boypeacemaker
dragondrunk 0:b6fa066730db 1498 ch_same_position(post1,post2);
dragondrunk 0:b6fa066730db 1499 for(i=0;i<8;i++){
dragondrunk 0:b6fa066730db 1500 for(j=0;j<8;j++){
dragondrunk 0:b6fa066730db 1501 get_same_position[i][j] = ch_post[i][j];
dragondrunk 0:b6fa066730db 1502 if(get_same_position[i][j] == 1){
dragondrunk 0:b6fa066730db 1503 wow = 1;
dragondrunk 0:b6fa066730db 1504 }
dragondrunk 0:b6fa066730db 1505 }
dragondrunk 0:b6fa066730db 1506 }
dragondrunk 0:b6fa066730db 1507 if(wow == 0){
dragondrunk 0:b6fa066730db 1508 for(i=0;i<8;i++){_temppic[i] = temppic2[i]+pic[i];}
dragondrunk 0:b6fa066730db 1509 }
dragondrunk 0:b6fa066730db 1510 else{
dragondrunk 0:b6fa066730db 1511 discard_same_position(post1,post2);
dragondrunk 0:b6fa066730db 1512 array_to_hex(post1);
dragondrunk 0:b6fa066730db 1513 for(i = 0;i<8;i++){
dragondrunk 0:b6fa066730db 1514 hex_post1[i] = return_hex[i];
dragondrunk 0:b6fa066730db 1515 }
dragondrunk 0:b6fa066730db 1516 array_to_hex(post2);
dragondrunk 0:b6fa066730db 1517 for(i = 0;i<8;i++){
dragondrunk 0:b6fa066730db 1518 hex_post2[i] = return_hex[i];
dragondrunk 0:b6fa066730db 1519 }
dragondrunk 0:b6fa066730db 1520 array_to_hex(get_same_position);
dragondrunk 0:b6fa066730db 1521 for(i = 0;i<8;i++){
dragondrunk 0:b6fa066730db 1522 hex_post_cut[i] = return_hex[i];
dragondrunk 0:b6fa066730db 1523 }
dragondrunk 0:b6fa066730db 1524 for(i = 0;i<8;i++){
dragondrunk 0:b6fa066730db 1525 _temppic[i] = hex_post1[i] + hex_post2[i] + hex_post_cut[i];
dragondrunk 0:b6fa066730db 1526 }
dragondrunk 0:b6fa066730db 1527 }
dragondrunk 0:b6fa066730db 1528 }
dragondrunk 0:b6fa066730db 1529 if(dir == 'd'){
dragondrunk 0:b6fa066730db 1530 for(i=0;i<8;i++){
dragondrunk 0:b6fa066730db 1531 if(temppic2[i] == 0xe0){
dragondrunk 0:b6fa066730db 1532 check_boat3 = 1;
dragondrunk 0:b6fa066730db 1533 }
dragondrunk 0:b6fa066730db 1534 }
dragondrunk 0:b6fa066730db 1535 if(check_boat3 == 0){
dragondrunk 0:b6fa066730db 1536 for(j=0;j<8;j++){
dragondrunk 0:b6fa066730db 1537 if(temppic2[j] != 0){
dragondrunk 0:b6fa066730db 1538 temppic2[j] = temppic2[j]*2;
dragondrunk 0:b6fa066730db 1539 }
dragondrunk 0:b6fa066730db 1540 else{
dragondrunk 0:b6fa066730db 1541 temppic2[j] = 0;
dragondrunk 0:b6fa066730db 1542 }
dragondrunk 0:b6fa066730db 1543 _temppic[j] = temppic2[j];
dragondrunk 0:b6fa066730db 1544 }
dragondrunk 0:b6fa066730db 1545 // begin to compare and combine two frame
dragondrunk 0:b6fa066730db 1546 hex_to_array(_temppic);
dragondrunk 0:b6fa066730db 1547 for(i = 0;i<8;i++){
dragondrunk 0:b6fa066730db 1548 for(j = 0;j<8;j++){
dragondrunk 0:b6fa066730db 1549 post1[i][j] = return_position[i][j];
dragondrunk 0:b6fa066730db 1550 }
dragondrunk 0:b6fa066730db 1551 }
dragondrunk 0:b6fa066730db 1552 hex_to_array(pic);
dragondrunk 0:b6fa066730db 1553 for(i = 0;i<8;i++){
dragondrunk 0:b6fa066730db 1554 for(j = 0;j<8;j++){
dragondrunk 0:b6fa066730db 1555 post2[i][j] = return_position[i][j];
dragondrunk 0:b6fa066730db 1556 }
dragondrunk 0:b6fa066730db 1557 }
dragondrunk 0:b6fa066730db 1558
dragondrunk 0:b6fa066730db 1559 // begin to check boypeacemaker
dragondrunk 0:b6fa066730db 1560 ch_same_position(post1,post2);
dragondrunk 0:b6fa066730db 1561 for(i=0;i<8;i++){
dragondrunk 0:b6fa066730db 1562 for(j=0;j<8;j++){
dragondrunk 0:b6fa066730db 1563 get_same_position[i][j] = ch_post[i][j];
dragondrunk 0:b6fa066730db 1564 if(get_same_position[i][j] == 1){
dragondrunk 0:b6fa066730db 1565 wow = 1;
dragondrunk 0:b6fa066730db 1566 }
dragondrunk 0:b6fa066730db 1567 }
dragondrunk 0:b6fa066730db 1568 }
dragondrunk 0:b6fa066730db 1569 if(wow == 0){
dragondrunk 0:b6fa066730db 1570 for(i=0;i<8;i++){_temppic[i] = temppic2[i]+pic[i];}
dragondrunk 0:b6fa066730db 1571 }
dragondrunk 0:b6fa066730db 1572 else{
dragondrunk 0:b6fa066730db 1573 discard_same_position(post1,post2);
dragondrunk 0:b6fa066730db 1574 array_to_hex(post1);
dragondrunk 0:b6fa066730db 1575 for(i = 0;i<8;i++){
dragondrunk 0:b6fa066730db 1576 hex_post1[i] = return_hex[i];
dragondrunk 0:b6fa066730db 1577 }
dragondrunk 0:b6fa066730db 1578 array_to_hex(post2);
dragondrunk 0:b6fa066730db 1579 for(i = 0;i<8;i++){
dragondrunk 0:b6fa066730db 1580 hex_post2[i] = return_hex[i];
dragondrunk 0:b6fa066730db 1581 }
dragondrunk 0:b6fa066730db 1582 array_to_hex(get_same_position);
dragondrunk 0:b6fa066730db 1583 for(i = 0;i<8;i++){
dragondrunk 0:b6fa066730db 1584 hex_post_cut[i] = return_hex[i];
dragondrunk 0:b6fa066730db 1585 }
dragondrunk 0:b6fa066730db 1586 for(i = 0;i<8;i++){
dragondrunk 0:b6fa066730db 1587 _temppic[i] = hex_post1[i] + hex_post2[i] + hex_post_cut[i];
dragondrunk 0:b6fa066730db 1588 }
dragondrunk 0:b6fa066730db 1589 }
dragondrunk 0:b6fa066730db 1590 }
dragondrunk 0:b6fa066730db 1591 check_boat3 = 0;
dragondrunk 0:b6fa066730db 1592 }
dragondrunk 0:b6fa066730db 1593 if(dir == 'a'){
dragondrunk 0:b6fa066730db 1594 for(i=0;i<8;i++){
dragondrunk 0:b6fa066730db 1595 if(temppic2[i] == 0x07){
dragondrunk 0:b6fa066730db 1596 check_boat3 = 1;
dragondrunk 0:b6fa066730db 1597 }
dragondrunk 0:b6fa066730db 1598 }
dragondrunk 0:b6fa066730db 1599 if(check_boat3 == 0){
dragondrunk 0:b6fa066730db 1600 for(j=0;j<8;j++){
dragondrunk 0:b6fa066730db 1601 if(temppic2[j] != 0){
dragondrunk 0:b6fa066730db 1602 temppic2[j] = temppic2[j]/2;
dragondrunk 0:b6fa066730db 1603 }
dragondrunk 0:b6fa066730db 1604 else{
dragondrunk 0:b6fa066730db 1605 temppic2[j] = 0;
dragondrunk 0:b6fa066730db 1606 }
dragondrunk 0:b6fa066730db 1607 _temppic[j] = temppic2[j];
dragondrunk 0:b6fa066730db 1608 }
dragondrunk 0:b6fa066730db 1609 // begin to compare and combine two frame
dragondrunk 0:b6fa066730db 1610 hex_to_array(_temppic);
dragondrunk 0:b6fa066730db 1611 for(i = 0;i<8;i++){
dragondrunk 0:b6fa066730db 1612 for(j = 0;j<8;j++){
dragondrunk 0:b6fa066730db 1613 post1[i][j] = return_position[i][j];
dragondrunk 0:b6fa066730db 1614 }
dragondrunk 0:b6fa066730db 1615 }
dragondrunk 0:b6fa066730db 1616 hex_to_array(pic);
dragondrunk 0:b6fa066730db 1617 for(i = 0;i<8;i++){
dragondrunk 0:b6fa066730db 1618 for(j = 0;j<8;j++){
dragondrunk 0:b6fa066730db 1619 post2[i][j] = return_position[i][j];
dragondrunk 0:b6fa066730db 1620 }
dragondrunk 0:b6fa066730db 1621 }
dragondrunk 0:b6fa066730db 1622
dragondrunk 0:b6fa066730db 1623 // begin to check boypeacemaker
dragondrunk 0:b6fa066730db 1624 ch_same_position(post1,post2);
dragondrunk 0:b6fa066730db 1625 for(i=0;i<8;i++){
dragondrunk 0:b6fa066730db 1626 for(j=0;j<8;j++){
dragondrunk 0:b6fa066730db 1627 get_same_position[i][j] = ch_post[i][j];
dragondrunk 0:b6fa066730db 1628 if(get_same_position[i][j] == 1){
dragondrunk 0:b6fa066730db 1629 wow = 1;
dragondrunk 0:b6fa066730db 1630 }
dragondrunk 0:b6fa066730db 1631 }
dragondrunk 0:b6fa066730db 1632 }
dragondrunk 0:b6fa066730db 1633 if(wow == 0){
dragondrunk 0:b6fa066730db 1634 for(i=0;i<8;i++){_temppic[i] = temppic2[i]+pic[i];}
dragondrunk 0:b6fa066730db 1635 }
dragondrunk 0:b6fa066730db 1636 else{
dragondrunk 0:b6fa066730db 1637 discard_same_position(post1,post2);
dragondrunk 0:b6fa066730db 1638 array_to_hex(post1);
dragondrunk 0:b6fa066730db 1639 for(i = 0;i<8;i++){
dragondrunk 0:b6fa066730db 1640 hex_post1[i] = return_hex[i];
dragondrunk 0:b6fa066730db 1641 }
dragondrunk 0:b6fa066730db 1642 array_to_hex(post2);
dragondrunk 0:b6fa066730db 1643 for(i = 0;i<8;i++){
dragondrunk 0:b6fa066730db 1644 hex_post2[i] = return_hex[i];
dragondrunk 0:b6fa066730db 1645 }
dragondrunk 0:b6fa066730db 1646 array_to_hex(get_same_position);
dragondrunk 0:b6fa066730db 1647 for(i = 0;i<8;i++){
dragondrunk 0:b6fa066730db 1648 hex_post_cut[i] = return_hex[i];
dragondrunk 0:b6fa066730db 1649 }
dragondrunk 0:b6fa066730db 1650 for(i = 0;i<8;i++){
dragondrunk 0:b6fa066730db 1651 _temppic[i] = hex_post1[i] + hex_post2[i] + hex_post_cut[i];
dragondrunk 0:b6fa066730db 1652 }
dragondrunk 0:b6fa066730db 1653 }
dragondrunk 0:b6fa066730db 1654 }
dragondrunk 0:b6fa066730db 1655 check_boat3 = 0;
dragondrunk 0:b6fa066730db 1656 }
dragondrunk 0:b6fa066730db 1657 if(dir == 's' && temppic2[7] == 0){
dragondrunk 0:b6fa066730db 1658 for(j=0;j<8;j++){
dragondrunk 0:b6fa066730db 1659 if(j == 0){
dragondrunk 0:b6fa066730db 1660 forshift[0] = 0;
dragondrunk 0:b6fa066730db 1661 }
dragondrunk 0:b6fa066730db 1662 else{
dragondrunk 0:b6fa066730db 1663 forshift[j] = temppic2[j-1];
dragondrunk 0:b6fa066730db 1664 }
dragondrunk 0:b6fa066730db 1665 }
dragondrunk 0:b6fa066730db 1666 for(j=0;j<8;j++){
dragondrunk 0:b6fa066730db 1667 temppic2[j] = forshift[j];
dragondrunk 0:b6fa066730db 1668 _temppic[j] = temppic2[j];
dragondrunk 0:b6fa066730db 1669 }
dragondrunk 0:b6fa066730db 1670 // begin to compare and combine two frame
dragondrunk 0:b6fa066730db 1671 hex_to_array(_temppic);
dragondrunk 0:b6fa066730db 1672 for(i = 0;i<8;i++){
dragondrunk 0:b6fa066730db 1673 for(j = 0;j<8;j++){
dragondrunk 0:b6fa066730db 1674 post1[i][j] = return_position[i][j];
dragondrunk 0:b6fa066730db 1675 }
dragondrunk 0:b6fa066730db 1676 }
dragondrunk 0:b6fa066730db 1677 hex_to_array(pic);
dragondrunk 0:b6fa066730db 1678 for(i = 0;i<8;i++){
dragondrunk 0:b6fa066730db 1679 for(j = 0;j<8;j++){
dragondrunk 0:b6fa066730db 1680 post2[i][j] = return_position[i][j];
dragondrunk 0:b6fa066730db 1681 }
dragondrunk 0:b6fa066730db 1682 }
dragondrunk 0:b6fa066730db 1683
dragondrunk 0:b6fa066730db 1684 // begin to check boypeacemaker
dragondrunk 0:b6fa066730db 1685 ch_same_position(post1,post2);
dragondrunk 0:b6fa066730db 1686 for(i=0;i<8;i++){
dragondrunk 0:b6fa066730db 1687 for(j=0;j<8;j++){
dragondrunk 0:b6fa066730db 1688 get_same_position[i][j] = ch_post[i][j];
dragondrunk 0:b6fa066730db 1689 if(get_same_position[i][j] == 1){
dragondrunk 0:b6fa066730db 1690 wow = 1;
dragondrunk 0:b6fa066730db 1691 }
dragondrunk 0:b6fa066730db 1692 }
dragondrunk 0:b6fa066730db 1693 }
dragondrunk 0:b6fa066730db 1694 if(wow == 0){
dragondrunk 0:b6fa066730db 1695 for(i=0;i<8;i++){_temppic[i] = temppic2[i]+pic[i];}
dragondrunk 0:b6fa066730db 1696 }
dragondrunk 0:b6fa066730db 1697 else{
dragondrunk 0:b6fa066730db 1698 discard_same_position(post1,post2);
dragondrunk 0:b6fa066730db 1699 array_to_hex(post1);
dragondrunk 0:b6fa066730db 1700 for(i = 0;i<8;i++){
dragondrunk 0:b6fa066730db 1701 hex_post1[i] = return_hex[i];
dragondrunk 0:b6fa066730db 1702 }
dragondrunk 0:b6fa066730db 1703 array_to_hex(post2);
dragondrunk 0:b6fa066730db 1704 for(i = 0;i<8;i++){
dragondrunk 0:b6fa066730db 1705 hex_post2[i] = return_hex[i];
dragondrunk 0:b6fa066730db 1706 }
dragondrunk 0:b6fa066730db 1707 array_to_hex(get_same_position);
dragondrunk 0:b6fa066730db 1708 for(i = 0;i<8;i++){
dragondrunk 0:b6fa066730db 1709 hex_post_cut[i] = return_hex[i];
dragondrunk 0:b6fa066730db 1710 }
dragondrunk 0:b6fa066730db 1711 for(i = 0;i<8;i++){
dragondrunk 0:b6fa066730db 1712 _temppic[i] = hex_post1[i] + hex_post2[i] + hex_post_cut[i];
dragondrunk 0:b6fa066730db 1713 }
dragondrunk 0:b6fa066730db 1714 }
dragondrunk 0:b6fa066730db 1715
dragondrunk 0:b6fa066730db 1716 }
dragondrunk 0:b6fa066730db 1717 }
dragondrunk 0:b6fa066730db 1718 // ******************************************************************** ship 2 channal ******************************************************************
dragondrunk 0:b6fa066730db 1719
dragondrunk 0:b6fa066730db 1720 void place_ship2_4(int ship,char dir){
dragondrunk 0:b6fa066730db 1721
dragondrunk 0:b6fa066730db 1722 int post1[8][8] = {0};
dragondrunk 0:b6fa066730db 1723 int post2[8][8] = {0};
dragondrunk 0:b6fa066730db 1724 int hex_post1[8] = {0};
dragondrunk 0:b6fa066730db 1725 int hex_post2[8] = {0};
dragondrunk 0:b6fa066730db 1726 int hex_post_cut[8] = {0};
dragondrunk 0:b6fa066730db 1727 int get_same_position[8][8];
dragondrunk 0:b6fa066730db 1728 int wow=0;
dragondrunk 0:b6fa066730db 1729
dragondrunk 0:b6fa066730db 1730 if(dir == 'w'&& temppic3[ship][0] == 0 ){
dragondrunk 0:b6fa066730db 1731 for(j=0;j<8;j++){
dragondrunk 0:b6fa066730db 1732 if(j == 7){
dragondrunk 0:b6fa066730db 1733 forshift[7] = 0;
dragondrunk 0:b6fa066730db 1734 }
dragondrunk 0:b6fa066730db 1735 else{
dragondrunk 0:b6fa066730db 1736 forshift[j] = temppic3[ship][j+1];
dragondrunk 0:b6fa066730db 1737 }
dragondrunk 0:b6fa066730db 1738 }
dragondrunk 0:b6fa066730db 1739 for(j=0;j<8;j++){
dragondrunk 0:b6fa066730db 1740 temppic3[ship][j] = forshift[j];
dragondrunk 0:b6fa066730db 1741 _temppic[j] = temppic3[ship][j];
dragondrunk 0:b6fa066730db 1742 }
dragondrunk 0:b6fa066730db 1743 // begin to compare and combine two frame
dragondrunk 0:b6fa066730db 1744 hex_to_array(_temppic);
dragondrunk 0:b6fa066730db 1745 for(i = 0;i<8;i++){
dragondrunk 0:b6fa066730db 1746 for(j = 0;j<8;j++){
dragondrunk 0:b6fa066730db 1747 post1[i][j] = return_position[i][j];
dragondrunk 0:b6fa066730db 1748 }
dragondrunk 0:b6fa066730db 1749 }
dragondrunk 0:b6fa066730db 1750 hex_to_array(pic);
dragondrunk 0:b6fa066730db 1751 for(i = 0;i<8;i++){
dragondrunk 0:b6fa066730db 1752 for(j = 0;j<8;j++){
dragondrunk 0:b6fa066730db 1753 post2[i][j] = return_position[i][j];
dragondrunk 0:b6fa066730db 1754 }
dragondrunk 0:b6fa066730db 1755 }
dragondrunk 0:b6fa066730db 1756
dragondrunk 0:b6fa066730db 1757 // begin to check boypeacemaker
dragondrunk 0:b6fa066730db 1758 ch_same_position(post1,post2);
dragondrunk 0:b6fa066730db 1759 for(i=0;i<8;i++){
dragondrunk 0:b6fa066730db 1760 for(j=0;j<8;j++){
dragondrunk 0:b6fa066730db 1761 get_same_position[i][j] = ch_post[i][j];
dragondrunk 0:b6fa066730db 1762 if(get_same_position[i][j] == 1){
dragondrunk 0:b6fa066730db 1763 wow = 1;
dragondrunk 0:b6fa066730db 1764 }
dragondrunk 0:b6fa066730db 1765 }
dragondrunk 0:b6fa066730db 1766 }
dragondrunk 0:b6fa066730db 1767 if(wow == 0){
dragondrunk 0:b6fa066730db 1768 for(i=0;i<8;i++){_temppic[i] = temppic3[ship][i]+pic[i];}
dragondrunk 0:b6fa066730db 1769 }
dragondrunk 0:b6fa066730db 1770 else{
dragondrunk 0:b6fa066730db 1771 discard_same_position(post1,post2);
dragondrunk 0:b6fa066730db 1772 array_to_hex(post1);
dragondrunk 0:b6fa066730db 1773 for(i = 0;i<8;i++){
dragondrunk 0:b6fa066730db 1774 hex_post1[i] = return_hex[i];
dragondrunk 0:b6fa066730db 1775 }
dragondrunk 0:b6fa066730db 1776 array_to_hex(post2);
dragondrunk 0:b6fa066730db 1777 for(i = 0;i<8;i++){
dragondrunk 0:b6fa066730db 1778 hex_post2[i] = return_hex[i];
dragondrunk 0:b6fa066730db 1779 }
dragondrunk 0:b6fa066730db 1780 array_to_hex(get_same_position);
dragondrunk 0:b6fa066730db 1781 for(i = 0;i<8;i++){
dragondrunk 0:b6fa066730db 1782 hex_post_cut[i] = return_hex[i];
dragondrunk 0:b6fa066730db 1783 }
dragondrunk 0:b6fa066730db 1784 for(i = 0;i<8;i++){
dragondrunk 0:b6fa066730db 1785 _temppic[i] = hex_post1[i] + hex_post2[i] + hex_post_cut[i];
dragondrunk 0:b6fa066730db 1786 }
dragondrunk 0:b6fa066730db 1787 }
dragondrunk 0:b6fa066730db 1788
dragondrunk 0:b6fa066730db 1789 }
dragondrunk 0:b6fa066730db 1790 if(dir == 'd' && temppic3[ship][0] != 0x80 && temppic3[ship][1] != 0x80 && temppic3[ship][2] != 0x80 && temppic3[ship][3] != 0x80 && temppic3[ship][4] != 0x80 && temppic3[ship][5] != 0x80 && temppic3[ship][6] != 0x80 && temppic3[ship][7] != 0x80 ){
dragondrunk 0:b6fa066730db 1791 for(j=0;j<8;j++){
dragondrunk 0:b6fa066730db 1792 if(temppic3[j] != 0){
dragondrunk 0:b6fa066730db 1793 temppic3[ship][j] = temppic3[ship][j]*2;
dragondrunk 0:b6fa066730db 1794 }
dragondrunk 0:b6fa066730db 1795 else{
dragondrunk 0:b6fa066730db 1796 temppic3[ship][j] = 0;
dragondrunk 0:b6fa066730db 1797 }
dragondrunk 0:b6fa066730db 1798 _temppic[j] = temppic3[ship][j];
dragondrunk 0:b6fa066730db 1799 }
dragondrunk 0:b6fa066730db 1800 // begin to compare and combine two frame
dragondrunk 0:b6fa066730db 1801 hex_to_array(_temppic);
dragondrunk 0:b6fa066730db 1802 for(i = 0;i<8;i++){
dragondrunk 0:b6fa066730db 1803 for(j = 0;j<8;j++){
dragondrunk 0:b6fa066730db 1804 post1[i][j] = return_position[i][j];
dragondrunk 0:b6fa066730db 1805 }
dragondrunk 0:b6fa066730db 1806 }
dragondrunk 0:b6fa066730db 1807 hex_to_array(pic);
dragondrunk 0:b6fa066730db 1808 for(i = 0;i<8;i++){
dragondrunk 0:b6fa066730db 1809 for(j = 0;j<8;j++){
dragondrunk 0:b6fa066730db 1810 post2[i][j] = return_position[i][j];
dragondrunk 0:b6fa066730db 1811 }
dragondrunk 0:b6fa066730db 1812 }
dragondrunk 0:b6fa066730db 1813
dragondrunk 0:b6fa066730db 1814 // begin to check boypeacemaker
dragondrunk 0:b6fa066730db 1815 ch_same_position(post1,post2);
dragondrunk 0:b6fa066730db 1816 for(i=0;i<8;i++){
dragondrunk 0:b6fa066730db 1817 for(j=0;j<8;j++){
dragondrunk 0:b6fa066730db 1818 get_same_position[i][j] = ch_post[i][j];
dragondrunk 0:b6fa066730db 1819 if(get_same_position[i][j] == 1){
dragondrunk 0:b6fa066730db 1820 wow = 1;
dragondrunk 0:b6fa066730db 1821 }
dragondrunk 0:b6fa066730db 1822 }
dragondrunk 0:b6fa066730db 1823 }
dragondrunk 0:b6fa066730db 1824 if(wow == 0){
dragondrunk 0:b6fa066730db 1825 for(i=0;i<8;i++){_temppic[i] = temppic3[ship][i]+pic[i];}
dragondrunk 0:b6fa066730db 1826 }
dragondrunk 0:b6fa066730db 1827 else{
dragondrunk 0:b6fa066730db 1828 discard_same_position(post1,post2);
dragondrunk 0:b6fa066730db 1829 array_to_hex(post1);
dragondrunk 0:b6fa066730db 1830 for(i = 0;i<8;i++){
dragondrunk 0:b6fa066730db 1831 hex_post1[i] = return_hex[i];
dragondrunk 0:b6fa066730db 1832 }
dragondrunk 0:b6fa066730db 1833 array_to_hex(post2);
dragondrunk 0:b6fa066730db 1834 for(i = 0;i<8;i++){
dragondrunk 0:b6fa066730db 1835 hex_post2[i] = return_hex[i];
dragondrunk 0:b6fa066730db 1836 }
dragondrunk 0:b6fa066730db 1837 array_to_hex(get_same_position);
dragondrunk 0:b6fa066730db 1838 for(i = 0;i<8;i++){
dragondrunk 0:b6fa066730db 1839 hex_post_cut[i] = return_hex[i];
dragondrunk 0:b6fa066730db 1840 }
dragondrunk 0:b6fa066730db 1841 for(i = 0;i<8;i++){
dragondrunk 0:b6fa066730db 1842 _temppic[i] = hex_post1[i] + hex_post2[i] + hex_post_cut[i];
dragondrunk 0:b6fa066730db 1843 }
dragondrunk 0:b6fa066730db 1844 }
dragondrunk 0:b6fa066730db 1845
dragondrunk 0:b6fa066730db 1846 }
dragondrunk 0:b6fa066730db 1847 if(dir == 'a' && temppic3[ship][0] != 0x01 && temppic3[ship][1] != 0x01 && temppic3[ship][2] != 0x01 && temppic3[ship][3] != 0x01 && temppic3[ship][4] != 0x01 && temppic3[ship][5] != 0x01 && temppic3[ship][6] != 0x01 && temppic3[ship][7] != 0x01){
dragondrunk 0:b6fa066730db 1848 for(j=0;j<8;j++){
dragondrunk 0:b6fa066730db 1849 if(temppic3[ship][j] != 0){
dragondrunk 0:b6fa066730db 1850 temppic3[ship][j] = temppic3[ship][j]/2;
dragondrunk 0:b6fa066730db 1851 }
dragondrunk 0:b6fa066730db 1852 else{
dragondrunk 0:b6fa066730db 1853 temppic3[ship][j] = 0;
dragondrunk 0:b6fa066730db 1854 }
dragondrunk 0:b6fa066730db 1855 _temppic[j] = temppic3[ship][j];
dragondrunk 0:b6fa066730db 1856 }
dragondrunk 0:b6fa066730db 1857 // begin to compare and combine two frame
dragondrunk 0:b6fa066730db 1858 hex_to_array(_temppic);
dragondrunk 0:b6fa066730db 1859 for(i = 0;i<8;i++){
dragondrunk 0:b6fa066730db 1860 for(j = 0;j<8;j++){
dragondrunk 0:b6fa066730db 1861 post1[i][j] = return_position[i][j];
dragondrunk 0:b6fa066730db 1862 }
dragondrunk 0:b6fa066730db 1863 }
dragondrunk 0:b6fa066730db 1864 hex_to_array(pic);
dragondrunk 0:b6fa066730db 1865 for(i = 0;i<8;i++){
dragondrunk 0:b6fa066730db 1866 for(j = 0;j<8;j++){
dragondrunk 0:b6fa066730db 1867 post2[i][j] = return_position[i][j];
dragondrunk 0:b6fa066730db 1868 }
dragondrunk 0:b6fa066730db 1869 }
dragondrunk 0:b6fa066730db 1870
dragondrunk 0:b6fa066730db 1871 // begin to check boypeacemaker
dragondrunk 0:b6fa066730db 1872 ch_same_position(post1,post2);
dragondrunk 0:b6fa066730db 1873 for(i=0;i<8;i++){
dragondrunk 0:b6fa066730db 1874 for(j=0;j<8;j++){
dragondrunk 0:b6fa066730db 1875 get_same_position[i][j] = ch_post[i][j];
dragondrunk 0:b6fa066730db 1876 if(get_same_position[i][j] == 1){
dragondrunk 0:b6fa066730db 1877 wow = 1;
dragondrunk 0:b6fa066730db 1878 }
dragondrunk 0:b6fa066730db 1879 }
dragondrunk 0:b6fa066730db 1880 }
dragondrunk 0:b6fa066730db 1881 if(wow == 0){
dragondrunk 0:b6fa066730db 1882 for(i=0;i<8;i++){_temppic[i] = temppic3[ship][i]+pic[i];}
dragondrunk 0:b6fa066730db 1883 }
dragondrunk 0:b6fa066730db 1884 else{
dragondrunk 0:b6fa066730db 1885 discard_same_position(post1,post2);
dragondrunk 0:b6fa066730db 1886 array_to_hex(post1);
dragondrunk 0:b6fa066730db 1887 for(i = 0;i<8;i++){
dragondrunk 0:b6fa066730db 1888 hex_post1[i] = return_hex[i];
dragondrunk 0:b6fa066730db 1889 }
dragondrunk 0:b6fa066730db 1890 array_to_hex(post2);
dragondrunk 0:b6fa066730db 1891 for(i = 0;i<8;i++){
dragondrunk 0:b6fa066730db 1892 hex_post2[i] = return_hex[i];
dragondrunk 0:b6fa066730db 1893 }
dragondrunk 0:b6fa066730db 1894 array_to_hex(get_same_position);
dragondrunk 0:b6fa066730db 1895 for(i = 0;i<8;i++){
dragondrunk 0:b6fa066730db 1896 hex_post_cut[i] = return_hex[i];
dragondrunk 0:b6fa066730db 1897 }
dragondrunk 0:b6fa066730db 1898 for(i = 0;i<8;i++){
dragondrunk 0:b6fa066730db 1899 _temppic[i] = hex_post1[i] + hex_post2[i] + hex_post_cut[i];
dragondrunk 0:b6fa066730db 1900 }
dragondrunk 0:b6fa066730db 1901 }
dragondrunk 0:b6fa066730db 1902
dragondrunk 0:b6fa066730db 1903 }
dragondrunk 0:b6fa066730db 1904 if(dir == 's' && temppic3[ship][7] == 0){
dragondrunk 0:b6fa066730db 1905 for(j=0;j<8;j++){
dragondrunk 0:b6fa066730db 1906 if(j == 0){
dragondrunk 0:b6fa066730db 1907 forshift[0] = 0;
dragondrunk 0:b6fa066730db 1908 }
dragondrunk 0:b6fa066730db 1909 else{
dragondrunk 0:b6fa066730db 1910 forshift[j] = temppic3[ship][j-1];
dragondrunk 0:b6fa066730db 1911 }
dragondrunk 0:b6fa066730db 1912 }
dragondrunk 0:b6fa066730db 1913 for(j=0;j<8;j++){
dragondrunk 0:b6fa066730db 1914 temppic3[ship][j] = forshift[j];
dragondrunk 0:b6fa066730db 1915 _temppic[j] = temppic3[ship][j];
dragondrunk 0:b6fa066730db 1916 }
dragondrunk 0:b6fa066730db 1917 // begin to compare and combine two frame
dragondrunk 0:b6fa066730db 1918 hex_to_array(_temppic);
dragondrunk 0:b6fa066730db 1919 for(i = 0;i<8;i++){
dragondrunk 0:b6fa066730db 1920 for(j = 0;j<8;j++){
dragondrunk 0:b6fa066730db 1921 post1[i][j] = return_position[i][j];
dragondrunk 0:b6fa066730db 1922 }
dragondrunk 0:b6fa066730db 1923 }
dragondrunk 0:b6fa066730db 1924 hex_to_array(pic);
dragondrunk 0:b6fa066730db 1925 for(i = 0;i<8;i++){
dragondrunk 0:b6fa066730db 1926 for(j = 0;j<8;j++){
dragondrunk 0:b6fa066730db 1927 post2[i][j] = return_position[i][j];
dragondrunk 0:b6fa066730db 1928 }
dragondrunk 0:b6fa066730db 1929 }
dragondrunk 0:b6fa066730db 1930
dragondrunk 0:b6fa066730db 1931 // begin to check boypeacemaker
dragondrunk 0:b6fa066730db 1932 ch_same_position(post1,post2);
dragondrunk 0:b6fa066730db 1933 for(i=0;i<8;i++){
dragondrunk 0:b6fa066730db 1934 for(j=0;j<8;j++){
dragondrunk 0:b6fa066730db 1935 get_same_position[i][j] = ch_post[i][j];
dragondrunk 0:b6fa066730db 1936 if(get_same_position[i][j] == 1){
dragondrunk 0:b6fa066730db 1937 wow = 1;
dragondrunk 0:b6fa066730db 1938 }
dragondrunk 0:b6fa066730db 1939 }
dragondrunk 0:b6fa066730db 1940 }
dragondrunk 0:b6fa066730db 1941 if(wow == 0){
dragondrunk 0:b6fa066730db 1942 for(i=0;i<8;i++){_temppic[i] = temppic3[ship][i]+pic[i];}
dragondrunk 0:b6fa066730db 1943 }
dragondrunk 0:b6fa066730db 1944 else{
dragondrunk 0:b6fa066730db 1945 discard_same_position(post1,post2);
dragondrunk 0:b6fa066730db 1946 array_to_hex(post1);
dragondrunk 0:b6fa066730db 1947 for(i = 0;i<8;i++){
dragondrunk 0:b6fa066730db 1948 hex_post1[i] = return_hex[i];
dragondrunk 0:b6fa066730db 1949 }
dragondrunk 0:b6fa066730db 1950 array_to_hex(post2);
dragondrunk 0:b6fa066730db 1951 for(i = 0;i<8;i++){
dragondrunk 0:b6fa066730db 1952 hex_post2[i] = return_hex[i];
dragondrunk 0:b6fa066730db 1953 }
dragondrunk 0:b6fa066730db 1954 array_to_hex(get_same_position);
dragondrunk 0:b6fa066730db 1955 for(i = 0;i<8;i++){
dragondrunk 0:b6fa066730db 1956 hex_post_cut[i] = return_hex[i];
dragondrunk 0:b6fa066730db 1957 }
dragondrunk 0:b6fa066730db 1958 for(i = 0;i<8;i++){
dragondrunk 0:b6fa066730db 1959 _temppic[i] = hex_post1[i] + hex_post2[i] + hex_post_cut[i];
dragondrunk 0:b6fa066730db 1960 }
dragondrunk 0:b6fa066730db 1961 }
dragondrunk 0:b6fa066730db 1962
dragondrunk 0:b6fa066730db 1963 }
dragondrunk 0:b6fa066730db 1964 }
dragondrunk 0:b6fa066730db 1965 void hex_to_array_ship(int *hex_array){
dragondrunk 0:b6fa066730db 1966 int i,j;
dragondrunk 0:b6fa066730db 1967 int temp;
dragondrunk 0:b6fa066730db 1968 for(i = 0; i<8;i++){
dragondrunk 0:b6fa066730db 1969 temp = hex_array[i];
dragondrunk 0:b6fa066730db 1970 for(j = 0;j<8;j++){
dragondrunk 0:b6fa066730db 1971 if(temp & 0x80){
dragondrunk 0:b6fa066730db 1972 ship[i][7-j][0] = 80;
dragondrunk 0:b6fa066730db 1973 ship[i][7-j][1] = 20;
dragondrunk 0:b6fa066730db 1974 }
dragondrunk 0:b6fa066730db 1975 else{
dragondrunk 0:b6fa066730db 1976 ship[i][7-j][0] = 0;
dragondrunk 0:b6fa066730db 1977 ship[i][7-j][1] = 0;
dragondrunk 0:b6fa066730db 1978 ship[i][7-j][2] = 0;
dragondrunk 0:b6fa066730db 1979 }
dragondrunk 0:b6fa066730db 1980 temp = temp << 1;
dragondrunk 0:b6fa066730db 1981 }
dragondrunk 0:b6fa066730db 1982 }
dragondrunk 0:b6fa066730db 1983 }
dragondrunk 0:b6fa066730db 1984
dragondrunk 0:b6fa066730db 1985 void plant_bomb(char dir){
dragondrunk 0:b6fa066730db 1986
dragondrunk 0:b6fa066730db 1987 //scanf("%c",&dir);
dragondrunk 0:b6fa066730db 1988 if(dir == 'w' && row>0){
dragondrunk 0:b6fa066730db 1989 row = row - 1;
dragondrunk 0:b6fa066730db 1990 for(i=0;i<3;i++){
dragondrunk 0:b6fa066730db 1991 temp_array[i] = bomb[row][col][i];
dragondrunk 0:b6fa066730db 1992 }
dragondrunk 0:b6fa066730db 1993 for(i=0;i<3;i++){
dragondrunk 0:b6fa066730db 1994 bomb[row][col][i] = bomb[row+1][col][i];
dragondrunk 0:b6fa066730db 1995 bomb[row+1][col][i] = temp_array[i];
dragondrunk 0:b6fa066730db 1996 }
dragondrunk 0:b6fa066730db 1997 iCheck = 0;
dragondrunk 0:b6fa066730db 1998 }else if(dir == 'a' && col>0){
dragondrunk 0:b6fa066730db 1999 col = col - 1;
dragondrunk 0:b6fa066730db 2000 for(i=0;i<3;i++){
dragondrunk 0:b6fa066730db 2001 temp_array[i] = bomb[row][col][i];
dragondrunk 0:b6fa066730db 2002 }
dragondrunk 0:b6fa066730db 2003 for(i=0;i<3;i++){
dragondrunk 0:b6fa066730db 2004 bomb[row][col][i] = bomb[row][col+1][i];
dragondrunk 0:b6fa066730db 2005 bomb[row][col+1][i] = temp_array[i];
dragondrunk 0:b6fa066730db 2006 }
dragondrunk 0:b6fa066730db 2007 iCheck = 0;
dragondrunk 0:b6fa066730db 2008 }else if(dir == 's' && row<7){
dragondrunk 0:b6fa066730db 2009 row = row + 1;
dragondrunk 0:b6fa066730db 2010 for(i=0;i<3;i++){
dragondrunk 0:b6fa066730db 2011 temp_array[i] = bomb[row][col][i];
dragondrunk 0:b6fa066730db 2012 }
dragondrunk 0:b6fa066730db 2013 for(i=0;i<3;i++){
dragondrunk 0:b6fa066730db 2014 bomb[row][col][i] = bomb[row-1][col][i];
dragondrunk 0:b6fa066730db 2015 bomb[row-1][col][i] = temp_array[i];
dragondrunk 0:b6fa066730db 2016 }
dragondrunk 0:b6fa066730db 2017 iCheck = 0;
dragondrunk 0:b6fa066730db 2018 }else if(dir == 'd' && col<7){
dragondrunk 0:b6fa066730db 2019 col = col + 1;
dragondrunk 0:b6fa066730db 2020 for(i=0;i<3;i++){
dragondrunk 0:b6fa066730db 2021 temp_array[i] = bomb[row][col][i];
dragondrunk 0:b6fa066730db 2022 }
dragondrunk 0:b6fa066730db 2023 for(i=0;i<3;i++){
dragondrunk 0:b6fa066730db 2024 bomb[row][col][i] = bomb[row][col-1][i];
dragondrunk 0:b6fa066730db 2025 bomb[row][col-1][i] = temp_array[i];
dragondrunk 0:b6fa066730db 2026 }
dragondrunk 0:b6fa066730db 2027 iCheck = 0;
dragondrunk 0:b6fa066730db 2028 }
dragondrunk 0:b6fa066730db 2029 // if change state pls use set_zero
dragondrunk 0:b6fa066730db 2030 }
dragondrunk 0:b6fa066730db 2031
dragondrunk 0:b6fa066730db 2032 void set_zero(){
dragondrunk 0:b6fa066730db 2033 memcpy(bomb,zero,sizeof bomb);
dragondrunk 0:b6fa066730db 2034 bomb[0][0][0] = 20;
dragondrunk 0:b6fa066730db 2035 bomb[0][0][1] = 20;
dragondrunk 0:b6fa066730db 2036 bomb[0][0][2] = 10;
dragondrunk 0:b6fa066730db 2037 row = 0;
dragondrunk 0:b6fa066730db 2038 col = 0;
dragondrunk 0:b6fa066730db 2039 }
dragondrunk 0:b6fa066730db 2040
dragondrunk 0:b6fa066730db 2041 void change_orange_myship(int row,int col){ // change to orange
dragondrunk 0:b6fa066730db 2042 //printf("plot orange (myship) at |%d,%d| \n",row,col);
dragondrunk 0:b6fa066730db 2043 for(int i = 0; i<8;i++){
dragondrunk 0:b6fa066730db 2044 for(int j = 0;j<8;j++){
dragondrunk 0:b6fa066730db 2045 if(i == row && j == col){
dragondrunk 0:b6fa066730db 2046 ship[i][j][0] = 0; //b
dragondrunk 0:b6fa066730db 2047 ship[i][j][1] = 150; //g
dragondrunk 0:b6fa066730db 2048 ship[i][j][2] = 250; //r
dragondrunk 0:b6fa066730db 2049 }
dragondrunk 0:b6fa066730db 2050 }
dragondrunk 0:b6fa066730db 2051 }
dragondrunk 0:b6fa066730db 2052 }
dragondrunk 0:b6fa066730db 2053 void change_orange_hisship(int row,int col){ // change to orange
dragondrunk 0:b6fa066730db 2054 //printf("plot orange (enemy ship) at |%d,%d| \n",row,col);
dragondrunk 0:b6fa066730db 2055 for(int i = 0; i<8;i++){
dragondrunk 0:b6fa066730db 2056 for(int j = 0;j<8;j++){
dragondrunk 0:b6fa066730db 2057 if(i == row && j == col){
dragondrunk 0:b6fa066730db 2058 plot_bombed_usage[i][j][0] = 0; //b
dragondrunk 0:b6fa066730db 2059 plot_bombed_usage[i][j][1] = 150; //g
dragondrunk 0:b6fa066730db 2060 plot_bombed_usage[i][j][2] = 250; //r
dragondrunk 0:b6fa066730db 2061 }
dragondrunk 0:b6fa066730db 2062 }
dragondrunk 0:b6fa066730db 2063 }
dragondrunk 0:b6fa066730db 2064 }
dragondrunk 0:b6fa066730db 2065 void change_red_hisship(int row,int col){ // change to red
dragondrunk 0:b6fa066730db 2066 //printf("plot red (enemy ship) at |%d,%d| \n",row,col);
dragondrunk 0:b6fa066730db 2067 for(int i = 0; i<8;i++){
dragondrunk 0:b6fa066730db 2068 for(int j = 0;j<8;j++){
dragondrunk 0:b6fa066730db 2069 if(i == row && j == col){
dragondrunk 0:b6fa066730db 2070 plot_bombed_usage[i][j][0] = 0;
dragondrunk 0:b6fa066730db 2071 plot_bombed_usage[i][j][1] = 0;
dragondrunk 0:b6fa066730db 2072 plot_bombed_usage[i][j][2] = 200;
dragondrunk 0:b6fa066730db 2073 }
dragondrunk 0:b6fa066730db 2074 }
dragondrunk 0:b6fa066730db 2075 }
dragondrunk 0:b6fa066730db 2076 }
dragondrunk 0:b6fa066730db 2077 void change_red_myship(int row,int col){ // change to red
dragondrunk 0:b6fa066730db 2078 //printf("plot red (my ship) at |%d,%d| \n",row,col);
dragondrunk 0:b6fa066730db 2079 for(int i = 0; i<8;i++){
dragondrunk 0:b6fa066730db 2080 for(int j = 0;j<8;j++){
dragondrunk 0:b6fa066730db 2081 if(i == row && j == col){
dragondrunk 0:b6fa066730db 2082 ship[i][j][0] = 0;
dragondrunk 0:b6fa066730db 2083 ship[i][j][1] = 0;
dragondrunk 0:b6fa066730db 2084 ship[i][j][2] = 200;
dragondrunk 0:b6fa066730db 2085 }
dragondrunk 0:b6fa066730db 2086 }
dragondrunk 0:b6fa066730db 2087 }
dragondrunk 0:b6fa066730db 2088 }
dragondrunk 0:b6fa066730db 2089
dragondrunk 0:b6fa066730db 2090 void change_red_deadship(int* array_coordinate,int mode){ // change to red
dragondrunk 0:b6fa066730db 2091 int row = 0;
dragondrunk 0:b6fa066730db 2092 int col = 0;
dragondrunk 0:b6fa066730db 2093 for(int i = 0;i<15;i++){
dragondrunk 0:b6fa066730db 2094 if(array_coordinate[i] != 9){
dragondrunk 0:b6fa066730db 2095 row = array_coordinate[i] / 10;
dragondrunk 0:b6fa066730db 2096 col = array_coordinate[i] % 10;
dragondrunk 0:b6fa066730db 2097 if(mode == 0){
dragondrunk 0:b6fa066730db 2098 change_red_myship(row,col);
dragondrunk 0:b6fa066730db 2099 }
dragondrunk 0:b6fa066730db 2100 else if(mode == 1){
dragondrunk 0:b6fa066730db 2101 change_red_hisship(row,col);
dragondrunk 0:b6fa066730db 2102 }
dragondrunk 0:b6fa066730db 2103 }
dragondrunk 0:b6fa066730db 2104 }
dragondrunk 0:b6fa066730db 2105 }
dragondrunk 0:b6fa066730db 2106 void change_green_myship(int row,int col){
dragondrunk 0:b6fa066730db 2107 for(int i = 0; i<8;i++){
dragondrunk 0:b6fa066730db 2108 for(int j = 0;j<8;j++){
dragondrunk 0:b6fa066730db 2109 if(i == row && j == col){
dragondrunk 0:b6fa066730db 2110 ship[i][j][0] = 0;
dragondrunk 0:b6fa066730db 2111 ship[i][j][1] = 200;
dragondrunk 0:b6fa066730db 2112 ship[i][j][2] = 0;
dragondrunk 0:b6fa066730db 2113 }
dragondrunk 0:b6fa066730db 2114 }
dragondrunk 0:b6fa066730db 2115 }
dragondrunk 0:b6fa066730db 2116 }
dragondrunk 0:b6fa066730db 2117 void change_green_hisship(int row,int col){
dragondrunk 0:b6fa066730db 2118 for(int i = 0; i<8;i++){
dragondrunk 0:b6fa066730db 2119 for(int j = 0;j<8;j++){
dragondrunk 0:b6fa066730db 2120 if(i == row && j == col){
dragondrunk 0:b6fa066730db 2121 plot_bombed_usage[i][j][0] = 0;
dragondrunk 0:b6fa066730db 2122 plot_bombed_usage[i][j][1] = 200;
dragondrunk 0:b6fa066730db 2123 plot_bombed_usage[i][j][2] = 0;
dragondrunk 0:b6fa066730db 2124 }
dragondrunk 0:b6fa066730db 2125 }
dragondrunk 0:b6fa066730db 2126 }
dragondrunk 0:b6fa066730db 2127 }
dragondrunk 0:b6fa066730db 2128 void display_bomb_enemy(int row,int col){
dragondrunk 0:b6fa066730db 2129 int zero_array[8][8][3] = {{{0}}};
dragondrunk 0:b6fa066730db 2130 memcpy(bomb_enemy,zero_array,sizeof bomb_enemy);
dragondrunk 0:b6fa066730db 2131 for(int i = 0; i<8;i++){
dragondrunk 0:b6fa066730db 2132 for(int j = 0;j<8;j++){
dragondrunk 0:b6fa066730db 2133 if(i == row && j == col){
dragondrunk 0:b6fa066730db 2134 bomb_enemy[i][j][0] = 20;
dragondrunk 0:b6fa066730db 2135 bomb_enemy[i][j][1] = 20;
dragondrunk 0:b6fa066730db 2136 bomb_enemy[i][j][2] = 10;
dragondrunk 0:b6fa066730db 2137 }
dragondrunk 0:b6fa066730db 2138 }
dragondrunk 0:b6fa066730db 2139 }
dragondrunk 0:b6fa066730db 2140 }