From b1c82f914f18457f9a30791b01896ea40832c2d3 Mon Sep 17 00:00:00 2001 From: JAROWMR Date: Sun, 17 Nov 2024 18:45:46 +0100 Subject: bounce --- src/crepe/facade/SDLContext.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/crepe/facade') diff --git a/src/crepe/facade/SDLContext.cpp b/src/crepe/facade/SDLContext.cpp index 274cd7a..5d22cdf 100644 --- a/src/crepe/facade/SDLContext.cpp +++ b/src/crepe/facade/SDLContext.cpp @@ -117,8 +117,8 @@ void SDLContext::draw(const Sprite & sprite, const Transform & transform, = (SDL_RendererFlip) ((SDL_FLIP_HORIZONTAL * sprite.flip.flip_x) | (SDL_FLIP_VERTICAL * sprite.flip.flip_y)); - double adjusted_x = (transform.position.x - cam.x) * cam.zoom; - double adjusted_y = (transform.position.y - cam.y) * cam.zoom; + double adjusted_x = (transform.position.x - cam.x -(sprite.sprite_rect.w/2)) * cam.zoom; + double adjusted_y = (transform.position.y - cam.y -(sprite.sprite_rect.h/2)) * cam.zoom; double adjusted_w = sprite.sprite_rect.w * transform.scale * cam.zoom; double adjusted_h = sprite.sprite_rect.h * transform.scale * cam.zoom; @@ -130,8 +130,8 @@ void SDLContext::draw(const Sprite & sprite, const Transform & transform, }; SDL_Rect dstrect = { - .x = static_cast(adjusted_x/2), - .y = static_cast(adjusted_y/2), + .x = static_cast(adjusted_x), + .y = static_cast(adjusted_y), .w = static_cast(adjusted_w), .h = static_cast(adjusted_h), }; -- cgit v1.2.3