![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Helios Lyons 201239214
Dependencies: mbed
Brief
My aim for this project was to create a FRDM K64F adapted version of the classic Space Invaders by Tomohiro Nishikado. The game itself has a number of clear features to implement;
- Left to right movement for the player 'canon'
- A fixed amount of player lives
- Firing mechanics for both canon and invaders (hence collision systems)
- Random firing from remaining invaders
- Wave based combat
My own addition to these established ideas was Boss waves, featuring a single, larger sprite which fires at a faster interval than previous waves. The addition of a movement system using a basic for loop, as opposed to a velocity based system, will enhance the nostalgic feel of the game.
Gameplay
Movement is controlled with the joystick, moving the canon left or right. Fire by pressing A. Invaders spawn at set positions, but randomly fire at a set interval, which is higher for boss waves. Time is taken during each wave, and displayed at wave intervals, and if the play wins.
Controls are shown on the Gamepad below: (attribution: Craig A. Evans, ELEC2645 University of Leeds)
Diff: Invaders/Army.cpp
- Revision:
- 9:6a245c8ce08e
- Parent:
- 8:ec4199484adf
- Child:
- 10:19b250c7de5e
--- a/Invaders/Army.cpp Wed Apr 22 14:40:39 2020 +0000 +++ b/Invaders/Army.cpp Sun May 17 14:01:17 2020 +0000 @@ -1,9 +1,10 @@ #include "Army.h" #include "Invader.h" -#include "Bitmap.h" #include "mbed.h" #include "N5110.h" #include "Gamepad.h" + +#include <cstdlib> #include <vector> Army::Army() @@ -22,7 +23,7 @@ int i, n; for(i=0; i < 4; i++) { - //army[i][.setX(i); + //army[i].setX(i); for(n=0; n < 4; n++) { army[i][n].init(i+1, 1); @@ -123,7 +124,7 @@ } else { - if (right_X > 65) { // if rightmost invader is further than X = 65, change direction + if (right_X > 80) { // if rightmost invader is further than X = 65, change direction _move_left = true; if (bot_Y > 50) { // if lowest invader is below Y = 50, go up @@ -157,7 +158,17 @@ for(i=0; i < 4; i++) { for(n=0; n < 4; n++) { - //army[i][n].draw(); + //army[i][n].draw(lcd); } } } + +void Army::rand_invader() +{ + // get random coordinates for an invader + int rand(); + int rem = rand() % 5; // random column number + int rem2 = rand()% 4; // random row number + _fire_x = army[rem2][rem].get_x_pos(); // get position for random choices + _fire_y = army[rem2][rem].get_y_pos(); // used to set bullet start location +}