Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of project by
Diff: main.cpp
- Revision:
- 16:3fac68a7fd7c
- Parent:
- 15:5902cf545449
- Child:
- 17:aeb7cbfb8640
--- a/main.cpp Sat Dec 03 11:58:15 2016 +0000 +++ b/main.cpp Sat Dec 03 12:04:22 2016 +0000 @@ -22,14 +22,15 @@ void atk_enemy(); void enemy_atk(); void check_ready(); +void mark_ship_destroyed(); +void Select_Position(char M); +void get_atk_platform(int atkpos); +void check_end(); +//inessential void print_ship_destroyed(); void print_enemy_platform(); void print_ship_platform(); void print_atk_platform(); -void mark_ship_destroyed(); -void Select_Position(char M); -void get_atk_platform(int atkpos); -void check_end(); // Setting int ifUrJirat = 1; @@ -219,31 +220,16 @@ else if(ship_type == 3){ship3[i] = (y*10)+x;} else if(ship_type == 2){ship2[check_ship2][i] = (y*10)+x;} else if(ship_type == 1){ship1[check_ship1] = (y*10)+x;check_ship1++;} - }else{ - error = 1; - break; - } - if(ship_type%2 == 0){ - y++; - }else{ - x++; - } + }else{error = 1;break;} + if(ship_type%2 == 0){y++;}else{x++;} } - if(ship_type==2){ - check_ship2++; - } - if(error == 1){ - return 0; - }else{ + if(ship_type==2){check_ship2++;} + if(error == 1){return 0;}else{ y = input_position/10; x = input_position%10; for(i=0;i<ship_type;i++){ ship_platform[y][x] = ship_type; - if(ship_type%2 == 0){ - y++; - }else{ - x++; - } + if(ship_type%2 == 0){y++;}else{x++;} } return 1; } @@ -251,17 +237,9 @@ int check_correctPosition(int X,int Y){ if(X<=7){ if(Y<=7){ - if(ship_platform[X][Y] == 0){ - return 1; - }else{ - return 0; - } - }else{ - return 0; - } - }else{ - return 0; - } + if(ship_platform[X][Y] == 0){return 1;}else{return 0;} + }else{return 0;} + }else{return 0;} } void print_ship_platform(){ for(int i=0;i<8;i++){ @@ -296,9 +274,7 @@ printf("}\n"); } void check_ready(){ - if(bt.readable()){ - enemy_ready = 1; - } + if(bt.readable()){enemy_ready = 1;} } char posit2char(int posit){ int as = posit+48; @@ -324,28 +300,20 @@ if(atk_platform[x][y]==4){ for(i=0;i<4;i++){ for(j=0;j<15;j++){ - if(ship4[i]==ship_underATK[j]){ - ship_destroyed[0]++; - } + if(ship4[i]==ship_underATK[j]){ship_destroyed[0]++;} } } }else if(atk_platform[x][y]==3){ for(i=0;i<3;i++){ for(j=0;j<15;j++){ - if(ship3[i]==ship_underATK[j]){ - ship_destroyed[1]++; - } + if(ship3[i]==ship_underATK[j]){ship_destroyed[1]++;} } } }else if(atk_platform[x][y]==2){ for(i=0;i<4;i++){ for(j=0;j<15;j++){ - if(ship2[0][i]==ship_underATK[j]){ - ship_destroyed[2]++; - } - if(ship2[1][i]==ship_underATK[j]){ - ship_destroyed[3]++; - } + if(ship2[0][i]==ship_underATK[j]){ship_destroyed[2]++;} + if(ship2[1][i]==ship_underATK[j]){ship_destroyed[3]++;} } } }else if(atk_platform[x][y]==1){ @@ -369,18 +337,14 @@ if(ship_destroyed[0]==10){ for(i=0;i<8;i++){ for(j=0;j<8;j++){ - if(atk_platform[i][j]==4){ - atk_platform[i][j] = 11; - } + if(atk_platform[i][j]==4){atk_platform[i][j] = 11;} } } } if(ship_destroyed[1]==6){ for(i=0;i<8;i++){ for(j=0;j<8;j++){ - if(atk_platform[i][j]==3){ - atk_platform[i][j] = 11; - } + if(atk_platform[i][j]==3){atk_platform[i][j] = 11;} } } } @@ -417,9 +381,7 @@ SW = Button.read(); m = check_joys(Vx,Vy); n = check_joys_int(Vx,Vy); - if(n == 1){ - iVxVy = 0; - } + if(n == 1){ iVxVy = 0;} if(SW == 1){ iSW = 0; if(bt.readable()){