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:
Wed Apr 22 14:40:39 2020 +0000
Revision:
8:ec4199484adf
Child:
9:6a245c8ce08e
Implementing bullet firing and storing system. Begun menu design with controller options

Who changed what in which revision?

UserRevisionLine numberNew contents of line
helioslyons 8:ec4199484adf 1 #include "Bullet.h"
helioslyons 8:ec4199484adf 2
helioslyons 8:ec4199484adf 3 Bullet::Bullet()
helioslyons 8:ec4199484adf 4 {
helioslyons 8:ec4199484adf 5
helioslyons 8:ec4199484adf 6 }
helioslyons 8:ec4199484adf 7
helioslyons 8:ec4199484adf 8 Bullet::~Bullet()
helioslyons 8:ec4199484adf 9 {
helioslyons 8:ec4199484adf 10
helioslyons 8:ec4199484adf 11 }
helioslyons 8:ec4199484adf 12
helioslyons 8:ec4199484adf 13 void Bullet::init(int x, int y, int speed, bool canon)
helioslyons 8:ec4199484adf 14 {
helioslyons 8:ec4199484adf 15 _x = x;
helioslyons 8:ec4199484adf 16 _y = y;
helioslyons 8:ec4199484adf 17
helioslyons 8:ec4199484adf 18 _canon = canon;
helioslyons 8:ec4199484adf 19
helioslyons 8:ec4199484adf 20 Direction d = S;
helioslyons 8:ec4199484adf 21
helioslyons 8:ec4199484adf 22 if (_canon == true) {
helioslyons 8:ec4199484adf 23 d = N;
helioslyons 8:ec4199484adf 24 _width = 2;
helioslyons 8:ec4199484adf 25 _height = 3;
helioslyons 8:ec4199484adf 26 }
helioslyons 8:ec4199484adf 27 else {
helioslyons 8:ec4199484adf 28 d = S;
helioslyons 8:ec4199484adf 29 _width = 2;
helioslyons 8:ec4199484adf 30 _height = 2;
helioslyons 8:ec4199484adf 31 }
helioslyons 8:ec4199484adf 32 }
helioslyons 8:ec4199484adf 33
helioslyons 8:ec4199484adf 34 void Bullet::draw(N5110 &lcd)
helioslyons 8:ec4199484adf 35 {
helioslyons 8:ec4199484adf 36 if (_canon == true) { // square bullets for players
helioslyons 8:ec4199484adf 37 lcd.drawRect(_x,_y,_width,_height,FILL_BLACK);
helioslyons 8:ec4199484adf 38 }
helioslyons 8:ec4199484adf 39 else { // round 'bombs' for aliens
helioslyons 8:ec4199484adf 40 lcd.drawCircle(_x,_y,_width,FILL_BLACK);
helioslyons 8:ec4199484adf 41 }
helioslyons 8:ec4199484adf 42 }
helioslyons 8:ec4199484adf 43
helioslyons 8:ec4199484adf 44 void Bullet::update()
helioslyons 8:ec4199484adf 45 {
helioslyons 8:ec4199484adf 46 _x += _velocity.x;
helioslyons 8:ec4199484adf 47 _y += _velocity.y;
helioslyons 8:ec4199484adf 48 }
helioslyons 8:ec4199484adf 49
helioslyons 8:ec4199484adf 50 void Bullet::set_velocity(Vector2D v)
helioslyons 8:ec4199484adf 51 {
helioslyons 8:ec4199484adf 52 _velocity.x = v.x;
helioslyons 8:ec4199484adf 53 _velocity.y = v.y;
helioslyons 8:ec4199484adf 54 }
helioslyons 8:ec4199484adf 55
helioslyons 8:ec4199484adf 56 Vector2D Bullet::get_velocity()
helioslyons 8:ec4199484adf 57 {
helioslyons 8:ec4199484adf 58 Vector2D v = {_velocity.x,_velocity.y};
helioslyons 8:ec4199484adf 59 return v;
helioslyons 8:ec4199484adf 60 }
helioslyons 8:ec4199484adf 61
helioslyons 8:ec4199484adf 62 int Bullet::get_x_pos()
helioslyons 8:ec4199484adf 63 {
helioslyons 8:ec4199484adf 64 return _x;
helioslyons 8:ec4199484adf 65 }
helioslyons 8:ec4199484adf 66
helioslyons 8:ec4199484adf 67 int Bullet::get_y_pos()
helioslyons 8:ec4199484adf 68 {
helioslyons 8:ec4199484adf 69 return _y;
helioslyons 8:ec4199484adf 70 }
helioslyons 8:ec4199484adf 71
helioslyons 8:ec4199484adf 72 /* Probably unnecessary
helioslyons 8:ec4199484adf 73 void Bullet::set_pos(int x, int y)
helioslyons 8:ec4199484adf 74 {
helioslyons 8:ec4199484adf 75 _x = x;
helioslyons 8:ec4199484adf 76 _y = y;
helioslyons 8:ec4199484adf 77 }
helioslyons 8:ec4199484adf 78 */