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:
Mon May 18 18:14:35 2020 +0000
Revision:
10:19b250c7de5e
Parent:
9:6a245c8ce08e
Child:
11:1fd8fca23375
Helios Lyons 201239214

Who changed what in which revision?

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