From 8d525bc1c3506f15a5f68672245f845cebe18eef Mon Sep 17 00:00:00 2001 From: dec05eba Date: Thu, 28 Oct 2021 17:33:57 +0200 Subject: More, todo interfaces --- src/graphics/Sprite.cpp | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'src/graphics/Sprite.cpp') diff --git a/src/graphics/Sprite.cpp b/src/graphics/Sprite.cpp index baf118e..b9066ee 100644 --- a/src/graphics/Sprite.cpp +++ b/src/graphics/Sprite.cpp @@ -6,14 +6,21 @@ extern "C" { } namespace mgl { - Sprite::Sprite(Texture &texture, vec2f position) : texture(texture) { - mgl_sprite_init(&sprite, texture.internal_texture(), position.x, position.y); + Sprite::Sprite() : Sprite(nullptr, vec2f(0.0f, 0.0f)) {} + + Sprite::Sprite(Texture *texture, vec2f position) : texture(texture) { + mgl_sprite_init(&sprite, texture ? texture->internal_texture() : nullptr, position.x, position.y); } Sprite::~Sprite() { } + void Sprite::set_texture(Texture *texture) { + this->texture = texture; + mgl_sprite_set_texture(&sprite, texture ? texture->internal_texture() : nullptr); + } + void Sprite::set_position(vec2f position) { mgl_sprite_set_position(&sprite, {position.x, position.y}); } @@ -34,12 +41,22 @@ namespace mgl { sprite.scale = { scale, scale }; } + // TODO: Implement + void Sprite::set_rotation(float degrees) { + + } + + // TODO: Implement + void Sprite::set_origin(vec2f origin) { + + } + vec2f Sprite::get_scale() const { return { sprite.scale.x, sprite.scale.y }; } const Texture* Sprite::get_texture() const { - return &texture; + return texture; } void Sprite::draw(Window&) { -- cgit v1.2.3