diff options
author | dec05eba <dec05eba@protonmail.com> | 2022-12-02 11:48:06 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2022-12-02 11:48:06 +0100 |
commit | e72c8d1bbd0d74dcf4a4832d0352f5f8211fc343 (patch) | |
tree | b0cbcc55d57df837c2e0607681eddf2312d1fa7f /src/graphics | |
parent | 0108af496da089dbee70ce80d778dfb5c238460b (diff) |
Sprite: add get_size, which returns the texture size and takes into account scaling
Diffstat (limited to 'src/graphics')
-rw-r--r-- | src/graphics/Sprite.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/graphics/Sprite.cpp b/src/graphics/Sprite.cpp index b94212e..461b14c 100644 --- a/src/graphics/Sprite.cpp +++ b/src/graphics/Sprite.cpp @@ -34,6 +34,13 @@ namespace mgl { return { sprite.position.x, sprite.position.y }; } + vec2f Sprite::get_size() const { + if(texture) + return get_scale() * mgl::vec2f(texture->get_size().x, texture->get_size().y); + else + return { 0.0f, 0.0f }; + } + void Sprite::set_scale(vec2f scale) { sprite.scale = { scale.x, scale.y }; } |