diff options
author | dec05eba <dec05eba@protonmail.com> | 2021-10-18 01:54:59 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2021-10-18 01:54:59 +0200 |
commit | 3e081d1669622bbc276b038ddc38ecf0600683c3 (patch) | |
tree | 0a92c34f257c75a2b26e63b0ea9da3d594e89cc8 /src/graphics/Sprite.cpp |
Initial commit with an example
Diffstat (limited to 'src/graphics/Sprite.cpp')
-rw-r--r-- | src/graphics/Sprite.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/graphics/Sprite.cpp b/src/graphics/Sprite.cpp new file mode 100644 index 0000000..ce32aa3 --- /dev/null +++ b/src/graphics/Sprite.cpp @@ -0,0 +1,28 @@ +#include "../../include/mglpp/graphics/Sprite.hpp" +#include "../../include/mglpp/graphics/Texture.hpp" + +extern "C" { +#include <mgl/mgl.h> +} + +namespace mgl { + Sprite::Sprite(Texture &texture, vec2f position) : texture(texture) { + mgl_sprite_init(&sprite, texture.internal_texture(), position.x, position.y); + } + + Sprite::~Sprite() { + + } + + void Sprite::set_position(vec2f position) { + mgl_sprite_set_position(&sprite, {position.x, position.y}); + } + + void Sprite::set_color(Color color) { + mgl_sprite_set_color(&sprite, {color.r, color.g, color.b, color.a}); + } + + void Sprite::draw(Window&) { + mgl_sprite_draw(mgl_get_context(), &sprite); + } +}
\ No newline at end of file |