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 SDFileSystem mbed wave_player
Fork of missile_command by
Revision 5:3f356592ee9c, committed 2014-11-17
- Comitter:
- slin77
- Date:
- Mon Nov 17 21:23:02 2014 +0000
- Parent:
- 4:0dc720aa3c71
- Commit message:
- add big_shoot
Changed in this revision
--- a/main.cpp Mon Nov 17 20:31:36 2014 +0000
+++ b/main.cpp Mon Nov 17 21:23:02 2014 +0000
@@ -173,6 +173,9 @@
current_player.protector.timer = 0;
current_player.protector_num--;
}
+ if(left_pb == 0 && right_pb == 0 && fouth_pb != 0 && fire_pb != 0) {
+ big_shoot();
+ }
update_protector();
update_antimissile_positions();
check_interception();
--- a/player.cpp Mon Nov 17 20:31:36 2014 +0000
+++ b/player.cpp Mon Nov 17 21:23:02 2014 +0000
@@ -25,6 +25,7 @@
#include "uLCD_4DGL.h"
#include "globals.h"
#include "player.h"
+#include <math.h>
// Example of drawing the player
@@ -138,9 +139,9 @@
uLCD.line(x - 5, y - 3, x - 5, y + PLAYER_HEIGHT + 3, BACKGROUND_COLOR);
uLCD.line(x- 5 + PLAYER_WIDTH, y - 3, x- 5 + PLAYER_WIDTH, y + PLAYER_HEIGHT + 3, BACKGROUND_COLOR);
uLCD.line(x, y - 3, x, y + PLAYER_HEIGHT + 3, BACKGROUND_COLOR);
- if (current_player.x - PLAYER_DELTA > 0) {
+ if (current_player.x - PLAYER_DELTA > 0 && !current_player.is_diagnoal) {
current_player.x = current_player.x - PLAYER_DELTA;
- }
+ }
}
void player_move_right() {
@@ -177,6 +178,24 @@
}
}
}
+
+void big_shoot() {
+ int i, count = 0;
+ if (current_player.am_remain > 0) {
+ for(i = 0; i < current_player.max_am; i++) {
+ if (am[i].status == DEACTIVE) {
+ count++;
+ am[i].status = ACTIVE;
+ am[i].x = (current_player.x * 2 + count * 32) % 128 ;
+ am[i].y = 100;
+ am[i].speed = 5;
+ am[i].tick = 0;
+ am[i].is_diagnoal = current_player.is_diagnoal;
+ current_player.am_remain--;
+ }
+ }
+ }
+}
//update all active missiles position
void update_antimissile_positions() {
int i, rate;
--- a/player.h Mon Nov 17 20:31:36 2014 +0000 +++ b/player.h Mon Nov 17 21:23:02 2014 +0000 @@ -109,6 +109,7 @@ void update_explosion(); void draw_explosion(); void update_protector();// update protector status and draw it on the screen +void big_shoot();//shoot all remaining antimissile at random position //extern PLAYER current_player; //extern ANTIMISSILE am[5];
