From 5eff48b449d066e4c4f585a75f8545b606696972 Mon Sep 17 00:00:00 2001 From: Camden Dixie O'Brien Date: Sat, 4 Jan 2025 16:11:07 +0000 Subject: [PATCH] Use object bounding box for y sorting --- game/main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/game/main.c b/game/main.c index 639c5c8..433c0e7 100644 --- a/game/main.c +++ b/game/main.c @@ -623,14 +623,14 @@ static inline bool tile_passable(const map_t map, int x, int y) return true; } -static inline double dynentity_bottom(dynentity_t *e) +static inline double dynentity_bottom(const dynentity_t *e) { return e->pos.y + e->bbox.off.y + e->bbox.ext.y; } -static inline double objentity_bottom(objentity_t *e) +static inline double objentity_bottom(const objentity_t *e) { - return (double)e->pos.y; + return (double)e->pos.y + e->bbox.off.y + e->bbox.ext.y; } static inline double entity_bottom(entity_t *e) @@ -897,7 +897,7 @@ static void render_objentity( SDL_Rect src = type->src; src.x += type->src.w * ((t / BASEANIMPERIOD) % type->animframes); const int x = rint(SCALE * (obj->pos.x - state->vpos.x)); - const int y = rint(SCALE * (obj->pos.y - state->vpos.y - type->src.h)); + const int y = rint(SCALE * (obj->pos.y - state->vpos.y)); SDL_Rect dest = { .x = x, .y = y,