diff options
author | dec05eba <dec05eba@protonmail.com> | 2021-10-28 17:33:57 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2021-10-29 14:31:31 +0200 |
commit | 8d525bc1c3506f15a5f68672245f845cebe18eef (patch) | |
tree | 243376e2cae0be40b6870ec8fe0082845996df87 /src/graphics/Sprite.cpp | |
parent | a80bf6bb6cb8ab8c5a1430f9f9dbc214f71bdddf (diff) |
More, todo interfaces
Diffstat (limited to 'src/graphics/Sprite.cpp')
-rw-r--r-- | src/graphics/Sprite.cpp | 23 |
1 files changed, 20 insertions, 3 deletions
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&) { |