Craig Evans
/
ELEC2645_Pong2021
Pong game for ELEC1620 board.
Embed:
(wiki syntax)
Show/hide line numbers
Bitmap.h
00001 #ifndef BITMAP_H 00002 #define BITMAP_H 00003 00004 #include <vector> 00005 00006 // Forward declarations 00007 class N5110; 00008 00009 /** 00010 * @brief A black & white bitmap that can be rendered on an N5110 screen 00011 * @author Alex Valavanis <a.valavanis@leeds.ac.uk> 00012 * 00013 * @code 00014 // First declare the pixel map data using '1' for black, 00015 // or '0' for white pixels 00016 static int sprite_data[] = { 00017 0,0,1,0,0, 00018 0,1,1,1,0, 00019 0,0,1,0,0, 00020 0,1,1,1,0, 00021 1,1,1,1,1, 00022 1,1,1,1,1, 00023 1,1,0,1,1, 00024 1,1,0,1,1 00025 }; 00026 00027 // Instantiate the Bitmap object using the data above 00028 Bitmap sprite(sprite_data, 8, 5); // Specify rows and columns in sprite 00029 00030 // We can render the bitmap wherever we want on the screen 00031 sprite.render(lcd, 20, 6); // x and y locations for rendering 00032 sprite.render(lcd, 30, 10); 00033 00034 // We can also print its values to the terminal 00035 sprite.print(); 00036 * @endcode 00037 */ 00038 class Bitmap 00039 { 00040 private: 00041 /** 00042 * @brief The contents of the drawing, with pixels stored in row-major order 00043 * @details '1' represents a black pixel; '0' represents white 00044 */ 00045 std::vector<int> _contents; 00046 00047 unsigned int _height; ///< The height of the drawing in pixels 00048 unsigned int _width; ///< The width of the drawing in pixels 00049 00050 public: 00051 Bitmap(int const *contents, 00052 unsigned int const height, 00053 unsigned int const width); 00054 00055 int get_pixel (unsigned int const row, 00056 unsigned int const column) const; 00057 00058 void print() const; 00059 00060 void render(N5110 &lcd, 00061 unsigned int const x0, 00062 unsigned int const y0) const; 00063 }; 00064 00065 #endif // BITMAP_H
Generated on Thu Jul 14 2022 15:46:36 by 1.7.2