From 77d61739620466762a260894e8eef3ff809b0036 Mon Sep 17 00:00:00 2001 From: Klemen Plestenjak Date: Sun, 28 Jan 2024 17:49:32 +0100 Subject: [PATCH] Fix origin --- game/main.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/game/main.c b/game/main.c index c4b8144..d1a7c2c 100644 --- a/game/main.c +++ b/game/main.c @@ -390,9 +390,9 @@ static void renderGame(Game *game, float dt) { s[i].x, s[i].y}; DrawCircleV(p[i], 1.0f, BLUE); - Vector2 origin = {0.0f, 0.0f}; - //dst.x += origin.x - dst.width * 0.5f; - //dst.y += origin.y - dst.height * 0.5f; + Vector2 origin = {dst.width * 0.5f, dst.height}; + dst.x += origin.x; + dst.y += origin.y; if (!CheckCollisionRecs(camBounds, dst)) continue; Rectangle src = t[i].rec; @@ -427,13 +427,13 @@ static void renderGame(Game *game, float dt) { Texture2D tex = game->tileset.tiles; for (i32 i = 0; i < numDraws; i++) { DrawData draw = drawData[i]; - Vector2 pos = { - draw.dst.x, - draw.dst.y, - }; Color c = WHITE; if (draw.canHaveAlpha) { - Vec2i mapPos = bzTileMapPosToTile(map, pos); + Vector2 center = { + draw.dst.x, + draw.dst.y - draw.dst.height * 0.5f + }; + Vec2i mapPos = bzTileMapPosToTile(map, center); if (bzTileMapHasCollision(map, COLL_LAYER_TRANSPARENCY, mapPos.x, mapPos.y)) { c.a = 180; }