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:
Sun May 17 14:01:17 2020 +0000
Revision:
9:6a245c8ce08e
Parent:
8:ec4199484adf
Child:
10:19b250c7de5e
Helios Lyons 201239214

Who changed what in which revision?

UserRevisionLine numberNew contents of line
helioslyons 8:ec4199484adf 1 #ifndef BATTLE_H
helioslyons 8:ec4199484adf 2 #define BATTLE_H
helioslyons 8:ec4199484adf 3
helioslyons 8:ec4199484adf 4 #include "mbed.h"
helioslyons 8:ec4199484adf 5 #include "N5110.h"
helioslyons 8:ec4199484adf 6 #include "Gamepad.h"
helioslyons 8:ec4199484adf 7 #include "Canon.h"
helioslyons 8:ec4199484adf 8 #include "Invader.h"
helioslyons 8:ec4199484adf 9 #include "Army.h"
helioslyons 8:ec4199484adf 10
helioslyons 8:ec4199484adf 11 // #define SCORE_BOARD 4 (top or bottom?)
helioslyons 9:6a245c8ce08e 12 /*
helioslyons 9:6a245c8ce08e 13 InterruptIn buttonA(PTC7);
helioslyons 9:6a245c8ce08e 14 DigitalOut led1(PTA2);
helioslyons 9:6a245c8ce08e 15 volatile int g_buttonA_flag = 0;
helioslyons 9:6a245c8ce08e 16 void buttonA_isr();
helioslyons 9:6a245c8ce08e 17 */
helioslyons 8:ec4199484adf 18
helioslyons 8:ec4199484adf 19 class Battle
helioslyons 8:ec4199484adf 20 {
helioslyons 8:ec4199484adf 21
helioslyons 8:ec4199484adf 22 public:
helioslyons 8:ec4199484adf 23 Battle();
helioslyons 8:ec4199484adf 24 ~Battle();
helioslyons 8:ec4199484adf 25
helioslyons 8:ec4199484adf 26 void init(int speed);
helioslyons 9:6a245c8ce08e 27 void invader_fire();
helioslyons 9:6a245c8ce08e 28 void fire();
helioslyons 8:ec4199484adf 29 void read_input(Gamepad &pad);
helioslyons 8:ec4199484adf 30 void update(Gamepad &pad);
helioslyons 8:ec4199484adf 31 void draw(N5110 &lcd);
helioslyons 8:ec4199484adf 32
helioslyons 8:ec4199484adf 33 private:
helioslyons 8:ec4199484adf 34
helioslyons 9:6a245c8ce08e 35 void check_invader_hit(Gamepad &pad); // if invader has been hit – need to call add_invx_kill in the invader collisions
helioslyons 9:6a245c8ce08e 36 void check_canon_hit(Gamepad &pad); // if canon has been hit
helioslyons 9:6a245c8ce08e 37 //void check_kill(Gamepad &pad);
helioslyons 9:6a245c8ce08e 38 void print_scores(N5110 &lcd);
helioslyons 8:ec4199484adf 39
helioslyons 8:ec4199484adf 40 int _speed;
helioslyons 8:ec4199484adf 41 int _x;
helioslyons 9:6a245c8ce08e 42 int _interval;
helioslyons 8:ec4199484adf 43
helioslyons 8:ec4199484adf 44 Canon _canon;
helioslyons 8:ec4199484adf 45
helioslyons 8:ec4199484adf 46 Direction _d;
helioslyons 8:ec4199484adf 47 float _mag;
helioslyons 8:ec4199484adf 48
helioslyons 8:ec4199484adf 49 };
helioslyons 8:ec4199484adf 50
helioslyons 8:ec4199484adf 51 #endif