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