-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests/pong: Make player and ball graphics handling more generic
- Loading branch information
Showing
7 changed files
with
231 additions
and
163 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#ifndef LIBGBA_ENGINE_MAPOBJECTS_H | ||
#define LIBGBA_ENGINE_MAPOBJECTS_H | ||
|
||
#include "libgba-cpp/utils/geometry.h" | ||
namespace gba::map { | ||
|
||
/** | ||
* For bitmaps with a custom drawing routine. | ||
*/ | ||
class BitmapModeObject { | ||
using DrawFunction = | ||
void (*)(BitmapModeObject const&); | ||
|
||
public: | ||
BitmapModeObject(gba::geometry::Point const& position, gba::geometry::Size size, DrawFunction draw_function): | ||
_position{position}, | ||
_size{size}, | ||
draw_function{draw_function} { | ||
} | ||
|
||
auto draw() const -> void { | ||
draw_function(*this); | ||
} | ||
|
||
auto position() -> gba::geometry::Point& { | ||
return _position; | ||
} | ||
|
||
auto position() const -> gba::geometry::Point const& { | ||
return _position; | ||
} | ||
|
||
auto size() const -> gba::geometry::Size const& { | ||
return _size; | ||
} | ||
|
||
private: | ||
gba::geometry::Point _position; | ||
gba::geometry::Size _size; | ||
|
||
DrawFunction draw_function; | ||
}; | ||
|
||
|
||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.