Updated Space Invaders on the mbed. Improved upon Michael Son's "Mbed Space Invaders" at https://os.mbed.com/users/michaeljson/notebook/mbed-space-invaders/.
Dependencies: mbed wave_player mbed-rtos 4DGL-uLCD-SE SparkfunAnalogJoystick SDFileSystem LSM9DS1_Library_cal_updated
Fork of Two-PlayerSpaceInvaders by
test
Diff: missile.cpp
- Revision:
- 26:3270c6edd7d9
- Parent:
- 1:618aa2c4ca6a
--- a/missile.cpp Wed Apr 28 01:17:30 2021 +0000 +++ b/missile.cpp Wed Apr 28 03:12:39 2021 +0000 @@ -1,5 +1,6 @@ #include "missile.h" + void draw_missile_object(int blk_x, int blk_y, int missile_color, int m_width, int m_height) { uLCD.filled_rectangle(blk_x,blk_y-1,blk_x+m_width,blk_y-m_height,missile_color); @@ -31,7 +32,7 @@ } } -void update_enemy_missile_pos(missile_t *g) +void update_enemy_missile_pos(missile_t *g, int level) { if (g->missile_blk_y > 128) { @@ -41,7 +42,17 @@ if (g->status == ENEMY_MISSILE_ACTIVE) { missile_erase(g); - g->missile_blk_y = g->missile_blk_y+1; + //g->missile_blk_y = g->missile_blk_y+1; + + // higher difficulties/levels have faster enemy missiles + if (level == 1) { + g->missile_blk_y = g->missile_blk_y+1; + } else if (level == 2) { + g->missile_blk_y = g->missile_blk_y+3; + } else if (level == 3) { + g->missile_blk_y = g->missile_blk_y+6; + } + missile_show(g); } else if (g->status == ENEMY_MISSILE_EXPLODED)