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.

https://os.mbed.com/media/uploads/helioslyons/screenshot_2020-05-27_at_06.12.00.png

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)

https://os.mbed.com/media/uploads/helioslyons/screenshot_2020-05-27_at_06.20.18.png

Committer:
helioslyons
Date:
Fri Apr 10 14:28:25 2020 +0000
Revision:
4:c644522ff9d9
Parent:
2:ef7f9892ba4f
Child:
10:19b250c7de5e
Started implementing Army class and grouped movement

Who changed what in which revision?

UserRevisionLine numberNew contents of line
helioslyons 2:ef7f9892ba4f 1 #ifndef CANON_H
helioslyons 2:ef7f9892ba4f 2 #define CANON_H
helioslyons 2:ef7f9892ba4f 3
helioslyons 2:ef7f9892ba4f 4 #include "mbed.h"
helioslyons 2:ef7f9892ba4f 5 #include "N5110.h"
helioslyons 2:ef7f9892ba4f 6 #include "Gamepad.h"
helioslyons 2:ef7f9892ba4f 7
helioslyons 2:ef7f9892ba4f 8 /** Canon.h
helioslyons 2:ef7f9892ba4f 9 * @brief Defines variables and methods for the Canon.
helioslyons 2:ef7f9892ba4f 10 * @author Helios A. Lyons
helioslyons 2:ef7f9892ba4f 11 * @date April, 2020
helioslyons 2:ef7f9892ba4f 12 */
helioslyons 2:ef7f9892ba4f 13
helioslyons 2:ef7f9892ba4f 14 class Canon
helioslyons 2:ef7f9892ba4f 15 {
helioslyons 2:ef7f9892ba4f 16 public:
helioslyons 2:ef7f9892ba4f 17
helioslyons 2:ef7f9892ba4f 18 Canon();
helioslyons 4:c644522ff9d9 19 ~Canon(); // destructor
helioslyons 2:ef7f9892ba4f 20
helioslyons 2:ef7f9892ba4f 21 void init(int x,int height,int width);
helioslyons 2:ef7f9892ba4f 22 void draw(N5110 &lcd);
helioslyons 2:ef7f9892ba4f 23 void update(Direction d,float mag);
helioslyons 2:ef7f9892ba4f 24 // int add_total_kills(); –– replaced by adding individual type kills
helioslyons 2:ef7f9892ba4f 25
helioslyons 2:ef7f9892ba4f 26 /** Increment Invader 1 Kills
helioslyons 2:ef7f9892ba4f 27 * @param increase kills by 1 for Invader 1
helioslyons 2:ef7f9892ba4f 28 */
helioslyons 4:c644522ff9d9 29 int add_inv1_kill(int n); // invader type 1 (first row)
helioslyons 2:ef7f9892ba4f 30
helioslyons 2:ef7f9892ba4f 31 /** Increment Invader 2 Kills
helioslyons 2:ef7f9892ba4f 32 * @param increase kills by 1 for Invader 2
helioslyons 2:ef7f9892ba4f 33 */
helioslyons 4:c644522ff9d9 34 int add_inv2_kill(int n);
helioslyons 2:ef7f9892ba4f 35
helioslyons 2:ef7f9892ba4f 36 /** Increment Invader 3 Kills
helioslyons 2:ef7f9892ba4f 37 * @param increase kills by 1 for Invader 3
helioslyons 2:ef7f9892ba4f 38 */
helioslyons 4:c644522ff9d9 39 int add_inv3_kill(int n);
helioslyons 2:ef7f9892ba4f 40
helioslyons 2:ef7f9892ba4f 41 /** Increment Boss Kills
helioslyons 2:ef7f9892ba4f 42 * @param increase kills by 1 for Boss mobs
helioslyons 2:ef7f9892ba4f 43 */
helioslyons 2:ef7f9892ba4f 44 int add_boss_kill(); // seperate for different boss levels? narrative structure?
helioslyons 2:ef7f9892ba4f 45
helioslyons 2:ef7f9892ba4f 46 /** Get total kills
helioslyons 2:ef7f9892ba4f 47 * @return total kills by adding invader subtype kills
helioslyons 2:ef7f9892ba4f 48 */
helioslyons 2:ef7f9892ba4f 49 int get_total_kill();
helioslyons 2:ef7f9892ba4f 50
helioslyons 2:ef7f9892ba4f 51 /** Get the score
helioslyons 2:ef7f9892ba4f 52 * @return current score based on current kills
helioslyons 2:ef7f9892ba4f 53 */
helioslyons 2:ef7f9892ba4f 54 int get_score();
helioslyons 2:ef7f9892ba4f 55
helioslyons 2:ef7f9892ba4f 56 /** Get the position
helioslyons 2:ef7f9892ba4f 57 * @return current Canon position based on direction
helioslyons 2:ef7f9892ba4f 58 */
helioslyons 2:ef7f9892ba4f 59 Vector2D get_pos();
helioslyons 2:ef7f9892ba4f 60
helioslyons 2:ef7f9892ba4f 61 /** Get remaining lives
helioslyons 2:ef7f9892ba4f 62 * @return current lives remaining
helioslyons 2:ef7f9892ba4f 63 */
helioslyons 2:ef7f9892ba4f 64 int get_life();
helioslyons 2:ef7f9892ba4f 65
helioslyons 2:ef7f9892ba4f 66 /** Remove a life
helioslyons 2:ef7f9892ba4f 67 * @param decrease number of lives by 1
helioslyons 2:ef7f9892ba4f 68 */
helioslyons 2:ef7f9892ba4f 69 int remove_life();
helioslyons 2:ef7f9892ba4f 70
helioslyons 2:ef7f9892ba4f 71 /** Reset lives
helioslyons 2:ef7f9892ba4f 72 * @param reset lives to 3
helioslyons 2:ef7f9892ba4f 73 */
helioslyons 2:ef7f9892ba4f 74 int reset_life();
helioslyons 2:ef7f9892ba4f 75
helioslyons 2:ef7f9892ba4f 76 private:
helioslyons 2:ef7f9892ba4f 77
helioslyons 2:ef7f9892ba4f 78 int _height;
helioslyons 2:ef7f9892ba4f 79 int _width;
helioslyons 2:ef7f9892ba4f 80 int _x;
helioslyons 2:ef7f9892ba4f 81 int _y;
helioslyons 2:ef7f9892ba4f 82 int _speed;
helioslyons 2:ef7f9892ba4f 83 int _score;
helioslyons 2:ef7f9892ba4f 84 int _inv1_kill;
helioslyons 2:ef7f9892ba4f 85 int _inv2_kill;
helioslyons 2:ef7f9892ba4f 86 int _inv3_kill;
helioslyons 2:ef7f9892ba4f 87 int _boss_kill;
helioslyons 2:ef7f9892ba4f 88 int _total_kill;
helioslyons 2:ef7f9892ba4f 89 int _life;
helioslyons 2:ef7f9892ba4f 90
helioslyons 2:ef7f9892ba4f 91 };
helioslyons 2:ef7f9892ba4f 92 #endif