This is test version of Pokemongo game. ELEC 2645 final project.

Dependencies:   Tone

Committer:
shalwego
Date:
Thu Apr 15 15:35:12 2021 +0000
Revision:
0:819c2d6a69ac
Issue about music playing

Who changed what in which revision?

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