From d0286486b5fddcfb32dcd1f3010aef5368ee678e Mon Sep 17 00:00:00 2001 From: heavydemon21 Date: Wed, 18 Dec 2024 19:17:38 +0100 Subject: rendering met absoluut position util functie, particle ben ik nog jaro aan het overleggen dus er die werkt niet goed --- src/crepe/facade/SDLContext.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/crepe/facade') diff --git a/src/crepe/facade/SDLContext.cpp b/src/crepe/facade/SDLContext.cpp index f350250..d352adc 100644 --- a/src/crepe/facade/SDLContext.cpp +++ b/src/crepe/facade/SDLContext.cpp @@ -28,6 +28,7 @@ #include "SDLContext.h" #include "Texture.h" #include "types.h" +#include "util/AbsoluutPosition.h" using namespace crepe; using namespace std; @@ -148,8 +149,7 @@ SDL_FRect SDLContext::get_dst_rect(const DestinationRectangleData & ctx) const { } size *= cam_aux_data.render_scale * ctx.img_scale * data.scale_offset; - vec2 screen_pos = (ctx.pos + data.position_offset - cam_aux_data.cam_pos - + (cam_aux_data.zoomed_viewport) / 2) + vec2 screen_pos = (ctx.pos - cam_aux_data.cam_pos + (cam_aux_data.zoomed_viewport) / 2) * cam_aux_data.render_scale - size / 2 + cam_aux_data.bar_size; @@ -195,7 +195,7 @@ void SDLContext::draw_text(const RenderText & data) { const Text & text = data.text; const Font & font = data.font; - const Transform & transform = data.transform; + vec2 absoluut_pos = AbsoluutPosition::get_position(data.transform, data.text.offset); std::unique_ptr> font_surface; std::unique_ptr> font_texture; @@ -220,8 +220,8 @@ void SDLContext::draw_text(const RenderText & data) { font_texture = {tmp_font_texture, [](SDL_Texture * texture) { SDL_DestroyTexture(texture); }}; - vec2 size = text.dimensions * cam_aux_data.render_scale * transform.scale; - vec2 screen_pos = (transform.position + text.offset - cam_aux_data.cam_pos + vec2 size = text.dimensions * cam_aux_data.render_scale * data.transform.scale; + vec2 screen_pos = (absoluut_pos + text.offset - cam_aux_data.cam_pos + (cam_aux_data.zoomed_viewport) / 2) * cam_aux_data.render_scale - size / 2 + cam_aux_data.bar_size; @@ -233,8 +233,8 @@ void SDLContext::draw_text(const RenderText & data) { .h = size.y, }; - SDL_RenderCopyExF(this->game_renderer.get(), font_texture.get(), NULL, &dstrect, transform.rotation, NULL, - SDL_FLIP_NONE); + SDL_RenderCopyExF(this->game_renderer.get(), font_texture.get(), NULL, &dstrect, + data.transform.rotation, NULL, SDL_FLIP_NONE); } void SDLContext::update_camera_view(const Camera & cam, const vec2 & new_pos) { -- cgit v1.2.3