ye tian / Mbed 2 deprecated missile_command

Dependencies:   4DGL-uLCD-SE mbed wave_player

Fork of missile_command by ECE 2035 TA

Files at this revision

API Documentation at this revision

Comitter:
tianyeapply
Date:
Wed Nov 09 17:04:42 2016 +0000
Parent:
2:5e7876719560
Commit message:

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
missile/missile.cpp Show annotated file Show diff for this revision Revisions of this file
missile/missile_public.h Show annotated file Show diff for this revision Revisions of this file
player.cpp Show annotated file Show diff for this revision Revisions of this file
player.h Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Wed Nov 12 02:06:48 2014 +0000
+++ b/main.cpp	Wed Nov 09 17:04:42 2016 +0000
@@ -26,6 +26,8 @@
 #include "wave_player.h"
 #include "SDFileSystem.h"
 #include "segment_display.h"
+#include <math.h>
+#include <stdio.h>
 
 // Include header files for missile command project
 #include "globals.h"
@@ -34,7 +36,7 @@
 #include "player.h"
 
 // Platform initialization
-DigitalIn left_pb(p23); DigitalIn right_pb(p21); DigitalIn fire_pb(p22);
+DigitalIn left_pb(p23); DigitalIn right_pb(p21); DigitalIn fire_pb(p22);DigitalIn fourth_pb(p24);
 uLCD_4DGL uLCD(p28,p27,p29);
 AnalogOut DACout(p18);
 wave_player waver(&DACout);
@@ -49,19 +51,9 @@
 */
 int main()
 {   
-    // [Demo of 7-segment display]
-    // 1.Initialize the segment display
     setup_sequence();
     seg_driver_initialize();
-    // 2.show numbers
-    int i;
-    for(i=0;i<10;i++){
-        seg_driver(i);
-        wait(0.2);
-    }
-    
-    // [Demo of play sound file]
-    playSound("/sd/wavfiles/BUZZER.wav");
+// playSound("/sd/wavfiles/BUZZER.wav");
     
     /// [Example of missile command implementation]
         /// Here is a rough flow to implement the missile command: <br><br>
@@ -72,12 +64,37 @@
     left_pb.mode(PullUp);  // The variable left_pb will be zero when the pushbutton for moving the player left is pressed    
     right_pb.mode(PullUp); // The variable rightt_pb will be zero when the pushbutton for moving the player right is pressed        
     fire_pb.mode(PullUp);  //the variable fire_pb will be zero when the pushbutton for firing a missile is pressed
-    
+    fourth_pb.mode(PullUp);
+    int x=60;
+    int y=100;
+    int count=0;
+    int tem=0;
+    int num_city=4;
+    int life=3;
+    int delta=10;
+    int level=0;
+    int num_missile=0;;
+    int speed=0,interval=0,player_speed=0,pre_point=0;
+    int t=0;
+    CITY city;
+    MISSILE missile,player_missile;
     /// 2.Begin the game loop
+    int current_life;
+    current_life=life_generate(life);
+    //playSound("/sd/wavfiles/begin.wav");
+    char begin[20];
+    sprintf(begin,"%s" ,"Press PB4 To Start!");
+    uLCD.text_string(begin,0,8,3,0xFF9900);
     while(1){
-        
+        if(fourth_pb==0){t=1;
+        playSound("/sd/wavfiles/start.wav");
+        uLCD.text_string(begin,0,8,3,BACKGROUND_COLOR);
+        break;}}
+    while(t){
+        display_score(count);
+        display_level(level);
         /// 3.Example of drawing the player
-        player_draw(60,100); // draws a player at the center of the screen
+        player_draw(x,y); // draws a player at the center of the screen
         
         /// 4.Example of calling the missile API.
         missile_generator(); /// It updates all incoming missiles on the screen
@@ -85,37 +102,148 @@
         /// 5.Implement the code to get user input and update the player
             /// -[Hint] You could see city_landscape.cpp to get some ideas about how to implement your player. <br>
         if(left_pb == 0){
+            if(x<=109){
+            player_clear(x,y);
+            x=x+3;
+            player_draw(x,y);
+            }
             /// -[Hint] Implement the code to move player left <br>
         }
         if(right_pb == 0){
+            if(x>=3){
+            player_clear(x,y);
+            x=x-3;
+            player_draw(x,y);
+            }
             /// -[Hint] Implement the code to move player right <br>
         }
-        if(fire_pb == 0){
-            /// -[Hint] Implement the code to fire player-missile <br>
-            
-            // [Demo of play sound file]
-            playSound("/sd/wavfiles/BUZZER.wav");
-        }
         
-        /// 6.Implement the code to draw a user missile
-            /// -[Hint] You could see missile.cpp or missile_generator() for your reference <br>
-        
-        /// 7.Implement the code to detect the collision between missiles and cities
-            /// -[Hint] You could use city_get_info() and  missile_get_info() <br>
-            /// -[Hint] You could use missile_set_exploded() to notify the missile module that the missile was exploded. <br>
-            /// -[Hint] You need to check which city was hit by the missile, and call city_destroy() to destroy it. <br>
-            /// -[Hint] You might also check whether the missile hit the land <br>
-        
-        /// 8.Implement the code to detect a collision between player-missiles and incoming missiles
-            /// -[Hint] You could use missile_get_info() to get the position of incoming missile <br>
-            /// -[Hint] You could use missile_set_exploded() to notify the missile module that the missile was exploded. <br>
-            /// -[Hint] You might also check whether the missile hit the player <br>
-        
+        //player_missile_generator(x, y);
+        if(fire_pb == 0){
+            while( fire_pb==0){
+                }
+            //implement the code to fire player-missile <br>
+            player_missile_create(x+8, y-8.5);
+            }
+         if(fourth_pb==0&&num_missile<4){
+                    while( fourth_pb==0){
+                }
+                    use_fourth_pb();
+            }    
+            
+         if(left_pb==0&&right_pb==0){
+            speed++;interval=interval+5;
+            level++;
+            advanced_level(8-speed%8,100-interval%100);
+            }
+        player_missile_update_position();
+        int i,j,k;
+        for (i=0; i<MAX_NUM_MISSILE;i++){
+         missile=missile_get_info(i);
+         if(abs(missile.x-x)<10 &&abs(missile.y-y)<10&&missile.status==MISSILE_ACTIVE||abs(missile.x-x-10)<10 &&abs(missile.y-y)<10&&missile.status==MISSILE_ACTIVE){
+             missile_set_exploded(i);
+             life--;
+             life_reduce(current_life);
+             current_life=current_life-7;
+             
+             }
+             for(k=0;k<MAX_NUM_CITY;k++){
+                 city=city_get_info(k);
+                 if(missile.y<127-city.height){
+                    if(abs(missile.x-city.x)<10 && abs(missile.y-city.y)<10 &&missile.status==MISSILE_ACTIVE&&city.status==EXIST){
+                        missile_set_exploded(i);
+                        city_destroy(k);
+                        num_city--;
+                        uLCD.filled_circle(missile.x , missile.y , 4, 0xCCAA00);
+                         wait(0.4);
+                        circle_explosion(missile.x , missile.y);
+                        
+                        uLCD.filled_circle(missile.x , missile.y , 4, BACKGROUND_COLOR);
+                        //count=count-10;
+                        display_score(count);
+                        city_destory();
+                        
+                        
+                        }
+                        }
+                else{
+                    if(abs(missile.x-(city.x-5))<10&&missile.status==MISSILE_ACTIVE &&city.status==EXIST ||abs(missile.x-(city.x+5))<10&&missile.status==MISSILE_ACTIVE&&city.status==EXIST){
+                        uLCD.filled_circle(missile.x , missile.y , 2, 0xCCAA00);
+                        missile_set_exploded(i);
+                        city_destroy(k);
+                        num_city--;
+                        uLCD.filled_circle(missile.x , missile.y , 4, 0xCCAA00);
+                         wait(0.4);
+                        circle_explosion(missile.x , missile.y);
+                        uLCD.filled_circle(missile.x , missile.y , 4, BACKGROUND_COLOR);
+                        //count=count-10;
+                        display_score(count);
+                        city_destory();
+                        
+                        }
+                 }
+                 }
+         for(j=0; j<MAX_NUM_PLAYER_MISSILE;j++){
+             
+            player_missile=player_missile_get_info(j);
+            int radius_x=abs(missile.x-player_missile.x);
+            int radius_y=abs(player_missile.y-missile.y);
+            if(radius_x<delta &&radius_y<delta){
+                
+                //delta can change depend on current level
+                if(missile.status==MISSILE_ACTIVE &&player_missile.status==MISSILE_ACTIVE){
+                    uLCD.filled_circle(missile.x , missile.y , 2, 0xC90000);
+                    
+                    missile_set_exploded(i);
+                    player_missile_set_exploded(j);
+                    wait(0.2);
+                    uLCD.filled_circle(missile.x , missile.y , 2, BACKGROUND_COLOR);
+                    interval=interval+5;
+                    set_missile_interval(interval);
+                    count++;
+                    display_score(count);
+                    point_get();
+  
+                    
+                    }//if              
+             
+                }//if
+                
+            }//for j
+        }//for i
+       
         /// 9.Implement the code to check the end of game
             /// -[Hint] For example, if there is no more city, it should be gameover. <br>
-        
-    }
-}
+            num_missile=num_missile_avi(tem);
+            seg_driver(5-num_missile%6);
+            //||num_city==0
+            if (life==-1||num_city==0){
+                 //player_clear(x,y);
+                break;}
+        if(count%10==0 && count!=0&&count>pre_point){
+            player_set_missile_speed((8-player_speed%8));
+            char level_up[10];
+            sprintf(level_up,"%s" ,"Level up");
+            uLCD.text_string(level_up,0,8,3,0xFF9900);
+            wait(0.3);
+            
+            uLCD.text_string(level_up,0,8,3,BACKGROUND_COLOR);
+            char speed_up[10];
+            sprintf(speed_up,"%s" ,"Speed up");
+            uLCD.text_string(speed_up,0,8,3,0xFF9900);
+            wait(0.2);
+            uLCD.text_string(level_up,0,8,3,BACKGROUND_COLOR);
+            playSound("/sd/wavfiles/level.wav");
+            speed++;interval=interval+5;
+            level++;
+            advanced_level(8-speed%8,100-interval%100);
+            pre_point=count;
+            }
+    }  //while  
+    uLCD.text_char('g', 6, 2, 0xCCAA00);    uLCD.text_char('a', 7, 2, 0xCCAA00);    uLCD.text_char('m', 8, 2, 0xCCAA00); uLCD.text_char('e', 9, 2, 0xCCAA00);
+    uLCD.text_char('o', 6, 4, 0xCCAA00);uLCD.text_char('v', 7, 4, 0xCCAA00);uLCD.text_char('e', 8, 4, 0xCCAA00);uLCD.text_char('r', 9, 4, 0xCCAA00);
+playSound("/sd/wavfiles/end.wav");
+}//main
 
 // Example of implementation of your functions
 void playSound(char * wav)
--- a/missile/missile.cpp	Wed Nov 12 02:06:48 2014 +0000
+++ b/missile/missile.cpp	Wed Nov 09 17:04:42 2016 +0000
@@ -21,11 +21,11 @@
  */
 
 #include "missile_private.h"
-
-MISSILE missile_record[MAX_NUM_MISSILE];
-int missile_tick=0;
-int missile_interval = 10;
-int missile_speed = 4;
+#include "city_landscape_public.h"
+MISSILE missile_record[MAX_NUM_MISSILE];//MAX_NUM_MISSILE
+int missile_tick=1;
+int missile_interval =100;
+int missile_speed = 8;
 
 // See the comments in missile_public.h
 void missile_generator(void){
@@ -76,14 +76,21 @@
 void missile_create(void){
     int i;
     for(i=0;i<MAX_NUM_MISSILE;i++){
+        //MAX_NUM_MISSILE
         if(missile_record[i].status == MISSILE_DEACTIVE){
             missile_record[i].y = 0;
             //each missile has its own tick
             missile_record[i].tick = 0;
+            //missile_record[i].tick = missile_tick;
             //set a random source for the missile
             missile_record[i].source_x = rand() % SIZE_X;
             //set a random target for the missile
+            
             missile_record[i].target_x = rand() % SIZE_X;
+            
+            missile_record[i].source_y = 0;
+            
+            //missile_record[i].target_y = SIZE_X-3;
             //the missile starts at its source
             missile_record[i].x = missile_record[i].source_x;
             missile_record[i].status = MISSILE_ACTIVE;
@@ -97,7 +104,7 @@
 void missile_update_position(void){
     int i;
     //controls how fast the missile will move
-    int rate = missile_speed * 25;
+    int rate = missile_speed * 23;
     //delta_x and delta_y account for the slope of the missile
     double delta_x,delta_y;
     for(i=0;i<MAX_NUM_MISSILE;i++){
@@ -112,6 +119,17 @@
             missile_draw(missile_record[i], MISSILE_COLOR);
             //update missile's internal tick
             missile_record[i].tick++;
+            if (missile_record[i].y>122){
+                
+                missile_draw(missile_record[i], BACKGROUND_COLOR);
+            
+            // we have done with this missile, remove it from record
+            missile_record[i].status = MISSILE_DEACTIVE;
+            //resets the missile's internal tick
+            missile_record[i].tick = 0;
+            }
+            draw_landscape();
+            
         }       
         else if(missile_record[i].status == MISSILE_EXPLODED){
             // clear the missile on the screen
--- a/missile/missile_public.h	Wed Nov 12 02:06:48 2014 +0000
+++ b/missile/missile_public.h	Wed Nov 09 17:04:42 2016 +0000
@@ -36,6 +36,8 @@
     int y;                   ///< The y-coordinate of missile current position
     double source_x;           ///< The x-coordinate of the missile's origin
     double target_x;           ///< The x-coordinate of the missile's target
+    double source_y;
+    double target_y;
     int tick;                  ///< The missile's internal tick
     MISSILE_STATUS status;   ///< The missile status, see MISSILE_STATUS
 } MISSILE;
@@ -67,4 +69,8 @@
 */
 void set_missile_interval(int interval);
 
+void missile_clear(MISSILE missile);
+void missile_update_position();
+
+
 #endif //MISSILE_PUBLIC_H
\ No newline at end of file
--- a/player.cpp	Wed Nov 12 02:06:48 2014 +0000
+++ b/player.cpp	Wed Nov 09 17:04:42 2016 +0000
@@ -1,37 +1,255 @@
-/* Gatech ECE2035 2014 FALL missile command
- * Copyright (c) 2014 Gatech ECE2035
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
+
 
 // Template of player implementation
 #include "mbed.h"
 #include "uLCD_4DGL.h"
 #include "globals.h"
 #include "player.h"
-
-// Example of drawing the player
+#include "missile_public.h"
+#include "city_landscape_public.h"
+#define pi 3.14159265
 void player_draw(int x, int y) {
-    uLCD.filled_rectangle(x, y, x+PLAYER_WIDTH, y+PLAYER_HEIGHT, PLAYER_COLOR); 
-    uLCD.filled_rectangle(x+PLAYER_DELTA, y-PLAYER_DELTA, x+PLAYER_WIDTH-PLAYER_DELTA, y+PLAYER_HEIGHT, PLAYER_COLOR);  
+    uLCD.circle(x+2,y,2,0x58C1FD);
+    uLCD.circle(x+14,y,2,0x58C1FD);
+    uLCD.rectangle(x+4, y-1.5, x+12, y+1.5, 0xECE9D8); 
+    uLCD.triangle(x+2,y-1.5, x+12, y-1.5,x+9,y-8.5,0xECE9D8);
+    //uLCD.filled_rectangle(x+PLAYER_DELTA, y-PLAYER_DELTA, x+PLAYER_WIDTH-PLAYER_DELTA, y+PLAYER_HEIGHT, PLAYER_COLOR);  
 }
-
+void player_clear(int x,int y){
+    uLCD.circle(x+2,y,2,BACKGROUND_COLOR);
+    uLCD.circle(x+14,y,2,BACKGROUND_COLOR);
+    uLCD.rectangle(x+4, y-1.5, x+12, y+1.5, BACKGROUND_COLOR); 
+    uLCD.triangle(x+2,y-1.5, x+12, y-1.5,x+9,y-8.5,BACKGROUND_COLOR);
+    //uLCD.filled_rectangle(x, y, x+PLAYER_WIDTH, y+PLAYER_HEIGHT, BACKGROUND_COLOR); 
+    //uLCD.filled_rectangle(x+PLAYER_DELTA, y-PLAYER_DELTA, x+PLAYER_WIDTH-PLAYER_DELTA, y+PLAYER_HEIGHT, BACKGROUND_COLOR);  
+    }
 // ... You need to implement your own functions for player ...
 
 
+
+
+
+
+
+
+
+
+
+MISSILE player_missile_record[MAX_NUM_PLAYER_MISSILE];
+int player_missile_tick=1;
+int player_missile_interval = 17;
+int player_missile_speed = 8;
+int num_missile=0;
+void player_missile_generator(int x, int y){
+    player_missile_tick++;
+    // only fire the missile at certain ticks
+    if((player_missile_tick % player_missile_interval)==0 || player_missile_tick==1){
+        player_missile_create(x,y);
+    }
+
+    // update the missiles and draw them
+    player_missile_update_position();
+}
+
+void player_set_missile_speed(int speed){
+    ASSERT_P(player_missile_speed>=1 && player_missile_speed<=8,ERROR_MISSILE_SPEED);
+    if(player_missile_speed>=1 && player_missile_speed<=8){  
+        player_missile_speed = speed;
+    }
+}
+
+// set missile interval (default interval is 10)
+void player_set_missile_interval(int interval){
+    ASSERT_P(player_missile_interval>=1 && player_missile_interval<=100,ERROR_MISSILE_INTERVAL);
+    if(player_missile_interval>=1 && interval<=100){
+        player_missile_interval = interval;
+    }
+}
+
+
+
+void player_missile_create(int current_x, int intcurrent_y){
+    int i;
+    for(i=0;i<MAX_NUM_PLAYER_MISSILE;i++){
+        if(player_missile_record[i].status == MISSILE_DEACTIVE){
+
+            player_missile_record[i].y = 97;
+            //each missile has its own tick
+            player_missile_record[i].tick = 0;
+            //missile_record[i].tick = missile_tick;
+            //set a random source for the missile
+            player_missile_record[i].source_x = current_x;
+            player_missile_record[i].source_y = 97;
+            //set a random target for the missile
+            player_missile_record[i].target_y = 0;
+            player_missile_record[i].target_x = current_x;
+            //player_missile_record[i].y = player_missile_record[i].source_y;
+            player_missile_record[i].status = MISSILE_ACTIVE;
+            num_missile++;
+            break;
+        }
+    }
+}
+
+
+
+
+
+
+
+
+
+
+
+void player_missile_update_position(void){
+    int i;
+    player_missile_tick++;
+    //controls how fast the missile will move
+    //int rate = player_missile_speed * 25;
+    int rate = player_missile_speed  * 25;
+    //delta_x and delta_y account for the slope of the missile
+    double delta_y;
+    for(i=0;i<MAX_NUM_PLAYER_MISSILE;i++){
+        if(player_missile_record[i].status == MISSILE_ACTIVE){
+            // update missile position
+            //delta_x = (player_missile_record[i].target_x - player_missile_record[i].source_x)/rate;
+            delta_y = -200/rate;
+            player_missile_draw(player_missile_record[i], BACKGROUND_COLOR);
+            //player_missile_record[i].x = player_missile_record[i].source_x;
+            player_missile_record[i].y = (int)(player_missile_record[i].source_y + delta_y*(player_missile_record[i].tick%rate));
+           // player_missile_record[i].y = (int)(delta_y*(player_missile_record[i].tick%rate));
+            player_missile_record[i].x = (int)(player_missile_record[i].source_x);
+            
+            // draw missile
+            player_missile_draw(player_missile_record[i], 0x508ADF);
+            player_missile_record[i].tick++;
+            //draw_landscape();
+            //update missile's internal tick
+            if (player_missile_record[i].tick==rate){
+                player_missile_record[i].status= MISSILE_DEACTIVE;
+                
+                player_missile_record[i].tick = 0;
+                num_missile--;
+                }
+            //player_missile_record[i].tick++;
+        }       
+        else if(player_missile_record[i].status == MISSILE_EXPLODED){
+            // clear the missile on the screen
+            
+            player_missile_draw(player_missile_record[i], BACKGROUND_COLOR);
+            
+            // we have done with this missile, remove it from record
+            player_missile_record[i].status = MISSILE_DEACTIVE;
+            //resets the missile's internal tick
+            player_missile_record[i].tick = 0;
+            num_missile--;
+        }
+        
+    }
+}
+
+MISSILE player_missile_get_info(int index){
+    // All interface for user should have error checking
+    ASSERT_P(index<MAX_NUM_PLAYER_MISSILE,ERROR_MISSILE_INDEX_GET_INFO);
+    
+    return player_missile_record[index];
+}
+
+
+void player_missile_set_exploded(int index){
+    // All interface for user should have error checking
+    ASSERT_P(index<MAX_NUM_PLAYER_MISSILE,ERROR_MISSILE_INDEX_UPDATE_STATUS);
+    
+    player_missile_record[index].status = MISSILE_EXPLODED;
+}
+
+
+void player_missile_draw(MISSILE player_missile, int color){
+    int init_x,init_y,current_x,current_y;
+
+    init_x = player_missile.source_x;
+    init_y = 100;
+    current_x = player_missile.x;
+    current_y = player_missile.y;
+    uLCD.line(init_x, init_y, current_x, current_y, color);
+}
+
+void life_reduce(int x){
+    uLCD.circle(x ,  5 , 3, BACKGROUND_COLOR);
+    }
+    
+int life_generate(int life){
+    int i;int x_=0;;
+    for(i=0;i<life;i++){
+        x_=5+7*i;
+    uLCD.circle( x_,  5 , 3, 0x508ADF);
+    }
+    
+    return x_;
+}
+int num_missile_avi(int x){
+    x= num_missile;
+    return x;
+    }
+void city_destory(){
+    uLCD.text_char('-', 13, 6, 0xCCAA00); 
+    uLCD.text_char('1', 14, 6, 0xCCAA00);
+     uLCD.text_char('0',15, 6, 0xCCAA00); 
+    
+    wait(0.3);
+    uLCD.text_char('-', 13, 6, BACKGROUND_COLOR); 
+    uLCD.text_char('1', 14, 6, BACKGROUND_COLOR); 
+    uLCD.text_char('0', 15, 6, BACKGROUND_COLOR); 
+    }
+void point_get(){
+    uLCD.text_char('+', 13, 6, 0xCCAA00); 
+    uLCD.text_char('1', 14, 6, 0xCCAA00); 
+    wait(0.3);
+    uLCD.text_char('-', 13, 6, BACKGROUND_COLOR); 
+    uLCD.text_char('1', 14, 6, BACKGROUND_COLOR);
+    }
+void display_score(int x){
+    char str[8];
+    sprintf(str, "%d", x);
+    uLCD.text_string(str,15,1,3,0xFF9900);
+    }
+ void advanced_level(int speed, int interval){
+    set_missile_interval(interval);
+    set_missile_speed( speed);
+    }
+void display_level(int x){
+    char str[2];
+    sprintf(str, "%d", x);
+    uLCD.text_string(str,0,3,3,0xFF9900);
+    }
+void circle_explosion(int x,int y){
+    int angle=0;
+    for(angle=0;angle<=360;angle=angle+20){
+    int delta_x=4*cos(angle*pi/180);
+    int delta_y=4*sin(angle*pi/180);
+    uLCD.filled_circle(x+delta_x-2 , y+delta_y-2 , 2, 0xECE9D8);
+    wait(0.15);
+    uLCD.filled_circle(x+delta_x-2 , y+delta_y-2 , 2, BACKGROUND_COLOR);
+                        }
+    }
+    
+    void use_fourth_pb(){
+    char str[10];
+    sprintf(str, "%s", "super bomb");
+    uLCD.text_string(str,5,3,3,0xECE9D8);
+    wait(0.25);
+    uLCD.text_string(str,5,3,3,BACKGROUND_COLOR);
+    int i;
+    MISSILE missile;
+    for(i=0;i<5;i++){
+        
+        missile=missile_get_info(i);
+        if(missile.status == MISSILE_ACTIVE){
+            
+            uLCD.filled_circle(missile.x ,missile.y, 2, 0xECE9D8);
+            wait(0.2);
+            uLCD.filled_circle(missile.x ,missile.y, 2, BACKGROUND_COLOR);
+            missile_set_exploded(i);
+            }
+    }
+    }
\ No newline at end of file
--- a/player.h	Wed Nov 12 02:06:48 2014 +0000
+++ b/player.h	Wed Nov 09 17:04:42 2016 +0000
@@ -28,14 +28,35 @@
 #define PLAYER_WIDTH   10 
 #define PLAYER_HEIGHT  3
 #define PLAYER_DELTA   3
-#define PLAYER_COLOR   0x0000FF
-
+#define PLAYER_COLOR   0x4DB849
+#include "missile_public.h"
+//#include "missile_public.h"
 
 /** Get the information of city
     @brief x and y are the top left corner of the player drawing
     @param x x-coordinate
     @param y y-coordinate
 */
+ #define MAX_NUM_PLAYER_MISSILE  5
+
 void player_draw(int x, int y);
+void player_clear(int x_clear,int y_clear);
+void player_missile_create(int x2,int y2);
+void player_missile_update_position(void);
+void player_missile_draw(MISSILE missile, int color);
+void player_missile_generator(int x1, int y1);
+MISSILE player_missile_get_info(int index);
+void player_missile_set_exploded(int index);
+void player_set_missile_speed(int speed);
+void life_reduce(int x);
+int life_generate(int life);
+int num_missile_avi(int x);
+void city_destory();
+void point_get();
+void display_score(int x);
+void advanced_level(int speed, int interval);
+void display_level(int x);
+void circle_explosion(int x,int y);
+void use_fourth_pb();
 
 #endif //PLAYER_H
\ No newline at end of file