Nasrun

Dependencies:   mbed

Fork of project_ShipDot by Jirat Nakarit

Files at this revision

API Documentation at this revision

Comitter:
dragondrunk
Date:
Sun Dec 04 14:53:32 2016 +0000
Parent:
23:66a401850f2e
Commit message:
Nasrun;

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Sun Dec 04 09:07:54 2016 +0000
+++ b/main.cpp	Sun Dec 04 14:53:32 2016 +0000
@@ -13,6 +13,7 @@
 DigitalIn Button(PA_4);
 Serial bt(PA_15, PB_7);
 ColorMbed dotmatrix;
+Timer t;
 
 // Initial function.
 char posit2char(int posit);
@@ -102,9 +103,17 @@
     int rgb[3] = {60,0,0};
     int state_place_ship = 0;
     dotmatrix.init();
-    
+    t.start();
     while(1) {
-        dotmatrix.display_pic(_temppic,rgb);
+        if(t.read()<0.4){
+            dotmatrix.display_pic(_temppic,rgb);
+        }
+        else if(t.read() > 0.4 && t.read() < 0.8){
+            dotmatrix.display_pic(pic,rgb);
+        }
+        else{
+            t.reset();    
+        }
         if(iShipType<8){
             Vx = VRx.read() * 1024;
             Vy = VRy.read() * 1024;
@@ -163,42 +172,63 @@
                             printf("state_place_ship == 0 ++\n");
                             pic[j] = temppic3[0][j]+pic[j];
                         }
+                        for(j=0;j<8;j++){
+                            _temppic[j] = temppic2[j]+pic[j];
+                        }
                     }
                     else if(state_place_ship == 1){
                         for(j=0;j<8;j++){
                             printf("state_place_ship == 1 ++\n");
                             pic[j] = temppic2[j]+pic[j];
                         }
+                        for(j=0;j<8;j++){
+                            _temppic[j] = temppic3[1][j]+pic[j];
+                        }
                     }
                     else if(state_place_ship == 2){
                         for(j=0;j<8;j++){
                             printf("state_place_ship == 2 ++\n");
                             pic[j] = temppic3[1][j]+pic[j];
                         }
+                        for(j=0;j<8;j++){
+                            _temppic[j] = temppic3[2][j]+pic[j];;   
+                        }
                     }
                     else if(state_place_ship == 3){
                         for(j=0;j<8;j++){
                             printf("state_place_ship == 3 ++\n");
                             pic[j] = temppic3[2][j]+pic[j];
                         }
+                        for(j=0;j<8;j++){
+                            _temppic[j] = temppic3[3][j]+pic[j];;   
+                        }
                     }
                     else if(state_place_ship == 4){
                         for(j=0;j<8;j++){
                             printf("state_place_ship == 4 ++\n");
                             pic[j] = temppic3[3][j]+pic[j];
                         }
+                        for(j=0;j<8;j++){
+                            _temppic[j] = temppic3[4][j]+pic[j];;   
+                        }
                     }
                     else if(state_place_ship == 5){
                         for(j=0;j<8;j++){
                             printf("state_place_ship == 5 ++\n");
                             pic[j] = temppic3[4][j]+pic[j];
                         }
+                        for(j=0;j<8;j++){
+                            _temppic[j] = temppic3[5][j]+pic[j];;   
+                        }
                     }
                     else if(state_place_ship == 6){
                         for(j=0;j<8;j++){
                             printf("state_place_ship == 6 ++\n");
                             pic[j] = temppic3[5][j]+pic[j];
                         }
+                        for(j=0;j<8;j++){
+                            _temppic[j] = temppic3[6][j]+pic[j];;   
+                        }
                     }
                     else if(state_place_ship == 7){
                         for(j=0;j<8;j++){
@@ -236,6 +266,7 @@
     wait(5);
     while(1) { //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Play
         if(state == 0){
+            
             atk_enemy();
             printf("This is enemy_platform.\n");
             print_enemy_platform();
@@ -499,6 +530,7 @@
     }
 }
 void atk_enemy(){
+    // comment for display : see only bomb and history of planting
     float Vx;
     float Vy;
     int SW,iVxVy,iSW,n = 0;
@@ -941,7 +973,7 @@
     int get_same_position[8][8];
     int wow=0;
 
-    if(dir == 'w'&& temppic3[ship][0] == 0){
+    if(dir == 'w'&& temppic3[ship][0] == 0 ){
         printf("w\n");
         for(j=0;j<8;j++){
             if(j == 7){
@@ -1002,7 +1034,7 @@
         }
 
     }
-    if(dir == 'd' && temppic3[ship][3] != 0x80 && temppic3[ship][4] != 0x80 ){
+    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 ){
         printf("d\n");
         for(j=0;j<8;j++){
             if(temppic3[j] != 0){
@@ -1060,7 +1092,7 @@
         }
 
     }
-    if(dir == 'a' && temppic3[ship][3] != 0x01 && temppic3[ship][4] != 0x01 ){
+    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){
         printf("a\n");
         for(j=0;j<8;j++){
             if(temppic3[ship][j] != 0){