From 3e081d1669622bbc276b038ddc38ecf0600683c3 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Mon, 18 Oct 2021 01:54:59 +0200 Subject: Initial commit with an example --- src/graphics/Sprite.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/graphics/Sprite.cpp (limited to 'src/graphics/Sprite.cpp') 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 +} + +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 -- cgit v1.2.3