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 May 27 15:40:47 2020 +0000
Revision:
13:1472c1637bfc
Parent:
1:a3f43007030e
Final Submission. I have read and agreed with Statement of Academic Integrity.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
helioslyons 1:a3f43007030e 1 #ifndef BITMAP_H
helioslyons 1:a3f43007030e 2 #define BITMAP_H
helioslyons 1:a3f43007030e 3
helioslyons 1:a3f43007030e 4 #include <vector>
helioslyons 1:a3f43007030e 5
helioslyons 1:a3f43007030e 6 // Forward declarations
helioslyons 1:a3f43007030e 7 class N5110;
helioslyons 1:a3f43007030e 8
helioslyons 1:a3f43007030e 9 /**
helioslyons 1:a3f43007030e 10 * @brief A black & white bitmap that can be rendered on an N5110 screen
helioslyons 1:a3f43007030e 11 * @author Alex Valavanis <a.valavanis@leeds.ac.uk>
helioslyons 1:a3f43007030e 12 *
helioslyons 1:a3f43007030e 13 * @code
helioslyons 1:a3f43007030e 14 // First declare the pixel map data using '1' for black,
helioslyons 1:a3f43007030e 15 // or '0' for white pixels
helioslyons 1:a3f43007030e 16 static int sprite_data[] = {
helioslyons 1:a3f43007030e 17 0,0,1,0,0,
helioslyons 1:a3f43007030e 18 0,1,1,1,0,
helioslyons 1:a3f43007030e 19 0,0,1,0,0,
helioslyons 1:a3f43007030e 20 0,1,1,1,0,
helioslyons 1:a3f43007030e 21 1,1,1,1,1,
helioslyons 1:a3f43007030e 22 1,1,1,1,1,
helioslyons 1:a3f43007030e 23 1,1,0,1,1,
helioslyons 1:a3f43007030e 24 1,1,0,1,1
helioslyons 1:a3f43007030e 25 };
helioslyons 1:a3f43007030e 26
helioslyons 1:a3f43007030e 27 // Instantiate the Bitmap object using the data above
helioslyons 1:a3f43007030e 28 Bitmap sprite(sprite_data, 8, 5); // Specify rows and columns in sprite
helioslyons 1:a3f43007030e 29
helioslyons 1:a3f43007030e 30 // We can render the bitmap wherever we want on the screen
helioslyons 1:a3f43007030e 31 sprite.render(lcd, 20, 6); // x and y locations for rendering
helioslyons 1:a3f43007030e 32 sprite.render(lcd, 30, 10);
helioslyons 1:a3f43007030e 33
helioslyons 1:a3f43007030e 34 // We can also print its values to the terminal
helioslyons 1:a3f43007030e 35 sprite.print();
helioslyons 1:a3f43007030e 36 * @endcode
helioslyons 1:a3f43007030e 37 */
helioslyons 1:a3f43007030e 38 class Bitmap
helioslyons 1:a3f43007030e 39 {
helioslyons 1:a3f43007030e 40 private:
helioslyons 1:a3f43007030e 41 /**
helioslyons 1:a3f43007030e 42 * @brief The contents of the drawing, with pixels stored in row-major order
helioslyons 1:a3f43007030e 43 * @details '1' represents a black pixel; '0' represents white
helioslyons 1:a3f43007030e 44 */
helioslyons 1:a3f43007030e 45 std::vector<int> _contents;
helioslyons 1:a3f43007030e 46
helioslyons 1:a3f43007030e 47 unsigned int _height; ///< The height of the drawing in pixels
helioslyons 1:a3f43007030e 48 unsigned int _width; ///< The width of the drawing in pixels
helioslyons 1:a3f43007030e 49
helioslyons 1:a3f43007030e 50 public:
helioslyons 1:a3f43007030e 51 Bitmap(int const *contents,
helioslyons 1:a3f43007030e 52 unsigned int const height,
helioslyons 1:a3f43007030e 53 unsigned int const width);
helioslyons 1:a3f43007030e 54
helioslyons 1:a3f43007030e 55 int get_pixel(unsigned int const row,
helioslyons 1:a3f43007030e 56 unsigned int const column) const;
helioslyons 1:a3f43007030e 57
helioslyons 1:a3f43007030e 58 void print() const;
helioslyons 1:a3f43007030e 59
helioslyons 1:a3f43007030e 60 void render(N5110 &lcd,
helioslyons 1:a3f43007030e 61 unsigned int const x0,
helioslyons 1:a3f43007030e 62 unsigned int const y0) const;
helioslyons 1:a3f43007030e 63 };
helioslyons 1:a3f43007030e 64
helioslyons 1:a3f43007030e 65 #endif // BITMAP_H