Matis Requis 201241242

Dependencies:   mbed

Tempest Game

Game Screen

https://os.mbed.com/media/uploads/MatisRequis/tempest_board_wiki.png The board is made of 12 columns. The Hero stays at the top of the column

Game Controls

https://os.mbed.com/media/uploads/MatisRequis/gamepad_buttons.png

To control the hero spaceship point the joystick to the column you want the hero to go to.

Press the A button to shoot a bullet in the column you are currently in.

Committer:
MatisRequis
Date:
Fri May 15 11:14:58 2020 +0000
Revision:
1:03d1c29c2f8a
Basic Files

Who changed what in which revision?

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