MVP for a Pong game

This commit is contained in:
Hartmut Seichter 2023-07-01 22:17:41 +02:00
parent 14343e7fd0
commit e9d0de8cdd
17 changed files with 517 additions and 109 deletions

View file

@ -60,6 +60,7 @@ struct Bitmap final {
* @return reference to itself
*/
constexpr auto fill(const RGBA& color) noexcept {
change_count++;
std::fill(data.begin(), data.end(), color);
return *this;
}
@ -71,6 +72,7 @@ struct Bitmap final {
* @return reference to pixel data at position
*/
constexpr RGBA& pixel(std::integral auto x, std::integral auto y) {
change_count++;
return data[y * size.width + x];
}
@ -85,8 +87,14 @@ struct Bitmap final {
return data[y * size.width + x];
}
constexpr void force_change() noexcept
{
change_count++;
}
Size size{.width = 0, .height = 0}; //!< extent of bitmap
std::vector<RGBA> data{}; //!< data storage
std::uint64_t change_count{};
};
} // namespace paradiso