aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorheavydemon21 <nielsstunnebrink1@gmail.com>2024-11-27 10:38:47 +0100
committerheavydemon21 <nielsstunnebrink1@gmail.com>2024-11-27 10:38:47 +0100
commit3b433353a83c2436b69f73ca1048842d906b1147 (patch)
tree30504fff94515f943db0701f0e35a6280ae110a0 /src
parent368aeba5bcfafe445b3af5748f3798aa75003bf2 (diff)
removed most static cast because of camera sizes vec2 -> ivec2
Diffstat (limited to 'src')
-rw-r--r--src/crepe/facade/SDLContext.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/crepe/facade/SDLContext.cpp b/src/crepe/facade/SDLContext.cpp
index fca3de4..6e22316 100644
--- a/src/crepe/facade/SDLContext.cpp
+++ b/src/crepe/facade/SDLContext.cpp
@@ -116,10 +116,10 @@ SDL_Rect SDLContext::get_dst_rect(const Sprite & sprite, const vec2 & pos, const
if (sprite.width > sprite.height) {
width = sprite.width;
- height = static_cast<int>(sprite.width / sprite.aspect_ratio);
+ height = sprite.width / sprite.aspect_ratio;
} else {
height = sprite.height;
- width = static_cast<int>(sprite.height * sprite.aspect_ratio);
+ width = sprite.height * sprite.aspect_ratio;
}
cout << width << " " << height << " " << " " << sprite.aspect_ratio << endl;
@@ -179,16 +179,16 @@ void SDLContext::set_camera(const Camera & cam) {
// calculate black bars
if (screen_aspect > viewport_aspect) {
// lettorboxing
- view.h = static_cast<int>(cam.screen.y / cam.zoom);
- view.w = static_cast<int>(cam.screen.y * viewport_aspect);
- view.x = static_cast<int>(cam.screen.x - view.w) / 2;
+ view.h = cam.screen.y / cam.zoom;
+ view.w = cam.screen.y * viewport_aspect;
+ view.x = (cam.screen.x - view.w) / 2;
view.y = 0;
} else {
// pillarboxing
- view.h = static_cast<int>(cam.screen.x / viewport_aspect);
- view.w = static_cast<int>(cam.screen.x / cam.zoom);
+ view.h = cam.screen.x / viewport_aspect;
+ view.w = cam.screen.x / cam.zoom;
view.x = 0;
- view.y = static_cast<int>(cam.screen.y - view.h) / 2;
+ view.y = (cam.screen.y - view.h) / 2;
}
// set drawing area
SDL_RenderSetViewport(this->game_renderer.get(), &view);
@@ -202,8 +202,8 @@ void SDLContext::set_camera(const Camera & cam) {
SDL_Rect bg = {
.x = 0,
.y = 0,
- .w = static_cast<int>(cam.viewport.x),
- .h = static_cast<int>(cam.viewport.y),
+ .w = cam.viewport.x,
+ .h = cam.viewport.y,
};
// fill bg color
SDL_RenderFillRect(this->game_renderer.get(), &bg);