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: 4DGL-uLCD-SE mbed wave_player
Fork of missile_command by
Diff: missile/missile.cpp
- Revision:
- 3:7e33224a6f1d
- Parent:
- 0:532cb55d6136
--- 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
