Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Fork of project_ShipDot by
Diff: main.cpp
- Revision:
- 28:163296348881
- Parent:
- 27:4f2640e5bf10
- Child:
- 29:e04e098aa9ba
diff -r 4f2640e5bf10 -r 163296348881 main.cpp
--- a/main.cpp Mon Dec 05 06:04:25 2016 +0000
+++ b/main.cpp Mon Dec 05 09:01:58 2016 +0000
@@ -399,7 +399,9 @@
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 and check_ship2==1){
+ ship_platform[y][x] = ship_type + 3;
+ }else{ship_platform[y][x] = ship_type;}
if(ship_type%2 == 0){y++;}else{x++;}
}
return 1;
@@ -445,7 +447,7 @@
printf("}\n");
}
void check_ready(){
- if(bt.readable()){printf("%c\n",bt.getc());enemy_ready = 1;}
+ if(bt.readable()){enemy_ready = 1;}
}
char posit2char(int posit){
int as = posit+48;
@@ -463,9 +465,53 @@
x = atkpos/10;
y = atkpos%10;
- if(ship_platform[x][y]!=0 and atk_platform[x][y]==0){
+ if(ship_platform[x][y]!=0){
+ if(atk_platform[x][y]==0){
+ atk_platform[x][y] = ship_platform[x][y];
+ printf("posit2char : %c\n",posit2char(atk_platform[x][y]));
+ bt.putc(posit2char(atk_platform[x][y]));
+ ship_underATK[check_ship_underATK] = atkpos;
+ 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]++;}
+ }
+ }
+ }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]++;}
+ }
+ }
+ }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]++;}
+ }
+ }
+ }else if(atk_platform[x][y]==1){
+ for(i=0;i<4;i++){
+ for(j=0;j<15;j++){
+ if(ship3[i]==ship_underATK[j]){
+ ship_destroyed[4+i]++;
+ atk_platform[x][y] = 11;
+ }
+ }
+ }
+ }
+ }else{
+ printf("You repeatedly attacked.\n");
+ }
+ }else{
+ atk_platform[x][y] = 8;
+ bt.putc(posit2char(atk_platform[x][y]));
+ }
+
+ /*
+ if(ship_platform[x][y]!=0 atk_platform[x][y]==0){
atk_platform[x][y] = ship_platform[x][y];
- bt.putc(posit2char(atk_platform[x][y]));
+ bt.putc(posit2char(atk_pla02tform[x][y]));
ship_underATK[check_ship_underATK] = (x*10)+y;
if(atk_platform[x][y]==4){
for(i=0;i<4;i++){
@@ -496,14 +542,14 @@
}
}
}
+ }
+ if(atk_platform[x][y]!=0){
+ printf("You repeatedly attacked.\n");
}else{
- if(atk_platform[x][y]!=0){
- printf("You repeatedly attacked.\n");
- }else{
- atk_platform[x][y] = 8;
- bt.putc(posit2char(atk_platform[x][y]));
- }
+ atk_platform[x][y] = 8;
+ bt.putc(posit2char(atk_platform[x][y]));
}
+ */
}
void mark_ship_destroyed(){
int i,j,k = 0;
@@ -588,7 +634,6 @@
printf("enemy select_Position = %d\n",select_Position);
}else{
ATKposition = select_Position;
- //bt.putc(posit2char(ATKposition));
break;
}
}
@@ -646,7 +691,7 @@
-// ______________________________________________________________________________Nasarun's function.
+// ____________________________________________________________________________________________________________________________________Nasarun's function.
void hex_to_array(int* ar){
int i;
