aboutsummaryrefslogtreecommitdiff
path: root/src/graphics
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2022-11-03 22:19:10 +0100
committerdec05eba <dec05eba@protonmail.com>2022-11-03 22:19:10 +0100
commita93ab69dc85a1e4898ccedcad1e59da0986acaa5 (patch)
tree4eb4ca63ae69fd5fccb60eddabaa12de169f4f23 /src/graphics
parent792dfdf5d1c7bc5a96e6d9ac540a503cb9f51ff6 (diff)
Sprite: set_size
Diffstat (limited to 'src/graphics')
-rw-r--r--src/graphics/Sprite.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/graphics/Sprite.cpp b/src/graphics/Sprite.cpp
index e6cef73..b94212e 100644
--- a/src/graphics/Sprite.cpp
+++ b/src/graphics/Sprite.cpp
@@ -42,6 +42,13 @@ namespace mgl {
sprite.scale = { scale, scale };
}
+ void Sprite::set_size(vec2f size) {
+ if(texture)
+ set_scale({ size.x / (float)texture->get_size().x, size.y / (float)texture->get_size().y });
+ else
+ set_scale({ 0.0f, 0.0f });
+ }
+
void Sprite::set_rotation(float degrees) {
mgl_sprite_set_rotation(&sprite, degrees);
}