ECE2035 class project

Dependencies:   4DGL-uLCD-SE SDFileSystem mbed wave_player

Fork of missile_command by ECE 2035 TA

Files at this revision

API Documentation at this revision

Comitter:
slin77
Date:
Mon Nov 17 20:31:36 2014 +0000
Parent:
3:fd1f794b7f5d
Child:
5:3f356592ee9c
Commit message:
add new features

Changed in this revision

main.cpp 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	Mon Nov 17 13:53:14 2014 +0000
+++ b/main.cpp	Mon Nov 17 20:31:36 2014 +0000
@@ -123,7 +123,7 @@
             uLCD.text_string(str3, 3, 5, FONT_7X8, BACKGROUND_COLOR);
             char go[] = "READY!";
             uLCD.text_string(go, 6, 6, FONT_7X8, GREEN);
-            wait(1.5);
+            playSound("/sd/wavfiles/BUZZER.wav");
             uLCD.text_string(go, 6, 6, FONT_7X8, BACKGROUND_COLOR);
             break;
         }
@@ -131,10 +131,9 @@
         
     }
     
-    
     /// 2.Begin the game loop
     while(1){
-        
+        current_player.timer++;
         char str[] = {'s', 'c', 'o', 'r', 'e', ':', '0' + current_player.score};
         char life_str[] = {'l','i','f', 'e',':', '0' + current_player.life};
         char level_str[] = {'l', 'e', 'v', 'e', 'l' ,':','0' + current_player.current_level};
@@ -150,7 +149,9 @@
         missile_generator(); /// It updates all incoming missiles on the screen
         update_explosion();
         draw_explosion();
-        
+        if (current_player.timer % 150 == 0 && current_player.life < 6) {
+            current_player.life++;
+        }
         /// 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){
@@ -178,8 +179,8 @@
         check_city_destruction();
         /// 6.Implement the code to draw a user missile
             /// -[Hint] You could see missile.cpp or missile_generator() for your reference <br>
-        if (current_player.score > 9 || (!left_pb && !right_pb)) {
-            advance_level();
+        if (current_player.score > 9 || (!left_pb && !right_pb && !fire_pb && !fouth_pb)) {
+            advance_level(); 
             //display_victory();   
         } else if(!is_any_left()) {
             current_player.life--;
@@ -227,6 +228,7 @@
 }
 
 void advance_level() {
+    current_player.timer = 0;
     current_player.current_level++;
     set_missile_speed(5 - current_player.current_level);
     set_missile_interval(10 - current_player.current_level);
@@ -297,12 +299,14 @@
     uLCD.cls();
     char str[] = "You Are Winnner";
     uLCD.text_string(str, 2, 9, FONT_7X8, WHITE);
+    playSound("/sd/wavfiles/ding_dong.wav");
 }
 
 void display_failure() {
     uLCD.cls();
     char str[] = "Game Over";
-    uLCD.text_string(str, 3, 9, FONT_7X8, WHITE); 
+    uLCD.text_string(str, 3, 9, FONT_7X8, WHITE);
+    playSound("/sd/wavfiles/ding_dong.wav");
 }
 
 
--- a/player.cpp	Mon Nov 17 13:53:14 2014 +0000
+++ b/player.cpp	Mon Nov 17 20:31:36 2014 +0000
@@ -36,8 +36,10 @@
     current_player.status = PLAYER_ACTIVE;
     current_player.score = 0;
     current_player.current_level = 0;
-    current_player.life = 5;//inital 5 hp  
-    current_player.protector_num = 3;  
+    current_player.life = 1;//inital 1 hp  
+    current_player.protector_num = 3; 
+    current_player.is_diagnoal = 0;
+    current_player.timer = 0; 
 }
 
 void update_protector() {
@@ -168,6 +170,7 @@
                      am[i].y = current_player.y;
                      am[i].speed = 5; // need to be improved
                      am[i].tick = 0;
+                     am[i].is_diagnoal = current_player.is_diagnoal;
                      current_player.am_remain--;
                      break;
                  }
--- a/player.h	Mon Nov 17 13:53:14 2014 +0000
+++ b/player.h	Mon Nov 17 20:31:36 2014 +0000
@@ -52,7 +52,10 @@
     PLAYER_STATUS status;//if he is dead
     int score;//# of interceptions 
     int protector_num;// number of protector left
-    PROTECTOR protector;  
+    PROTECTOR protector;
+    int is_diagnoal;
+    int angle;
+    int timer;  
 } PLAYER;
 /** et the information of city
     @brief x and y are the top left corner of the player drawing
@@ -74,6 +77,8 @@
     int speed;
     int tick; //anti missile's internal clock
     ANTIMISSLE_STATUS status;
+    int is_diagnoal;
+    int angle;
 }  ANTIMISSILE;
 
 typedef enum{