diff options
author | heavydemon21 <nielsstunnebrink1@gmail.com> | 2024-12-11 14:36:44 +0100 |
---|---|---|
committer | heavydemon21 <nielsstunnebrink1@gmail.com> | 2024-12-11 14:36:44 +0100 |
commit | 2bcd6ece912ab0a140f9d925718e8787879d1ed7 (patch) | |
tree | ea13906ba7afcd519579639b3b2d620628151fe1 /src/crepe/facade/SDLContext.cpp | |
parent | e6a5bb579d0969245f34119ef2489f47039c523e (diff) |
adjusted aspect ratio
Diffstat (limited to 'src/crepe/facade/SDLContext.cpp')
-rw-r--r-- | src/crepe/facade/SDLContext.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/crepe/facade/SDLContext.cpp b/src/crepe/facade/SDLContext.cpp index a0d7f04..0566ecf 100644 --- a/src/crepe/facade/SDLContext.cpp +++ b/src/crepe/facade/SDLContext.cpp @@ -233,12 +233,14 @@ SDL_FRect SDLContext::get_dst_rect(const DestinationRectangleData & ctx) const { const Sprite::Data & data = ctx.sprite.data; + float aspect_ratio = (ctx.sprite.aspect_ratio == 0) ? ctx.texture.get_ratio() : ctx.sprite.aspect_ratio; + vec2 size = data.size; if (data.size.x == 0 && data.size.y != 0) { - size.x = data.size.y * ctx.texture.get_ratio(); + size.x = data.size.y * aspect_ratio; } if (data.size.y == 0 && data.size.x != 0) { - size.y = data.size.x / ctx.texture.get_ratio(); + size.y = data.size.x / aspect_ratio; } const CameraValues & cam = ctx.cam; @@ -273,7 +275,6 @@ void SDLContext::draw(const RenderContext & ctx) { .img_scale = ctx.scale, }); - cout << srcrect->w << " " << srcrect->h << " " << srcrect->x << " " << srcrect->y << endl; double angle = ctx.angle + data.angle_offset; this->set_color_texture(ctx.texture, ctx.sprite.data.color); |