From 080de0da3c8967b0d387cd1940b8351c0125861e Mon Sep 17 00:00:00 2001 From: Camden Dixie O'Brien Date: Sat, 4 Jan 2025 13:22:06 +0000 Subject: [PATCH] Use doubles instead of ints for y sorting --- game/main.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/game/main.c b/game/main.c index e94d1ad..320015a 100644 --- a/game/main.c +++ b/game/main.c @@ -144,7 +144,7 @@ typedef struct { } gamestate_t; typedef struct { - int y; + double y; entity_t *e; } y_entity_ref_t; @@ -568,17 +568,17 @@ static inline bool tile_passable(const map_t map, int x, int y) return true; } -static inline int dynentity_bottom(dynentity_t *e) +static inline double dynentity_bottom(dynentity_t *e) { - return e->pos.y + e->ext.y / 2; + return e->pos.y + (double)e->ext.y / 2.0; } -static inline int objentity_bottom(objentity_t *e) +static inline double objentity_bottom(objentity_t *e) { - return e->pos.y; + return (double)e->pos.y; } -static inline int entity_bottom(entity_t *e) +static inline double entity_bottom(entity_t *e) { switch (e->tag) { case ENTITY_DYN: @@ -602,8 +602,8 @@ static void update_drawlist(dynentity_t *e, entity_t **drawlist) // The entity is already at the end -- no update required. return; - const int y = dynentity_bottom(e); - int nexty = entity_bottom(n); + const double y = dynentity_bottom(e); + double nexty = entity_bottom(n); if (y <= nexty) // The entity is still behind the next entity -- no update // required. @@ -653,8 +653,8 @@ static void update_drawlist(dynentity_t *e, entity_t **drawlist) if (n == NULL) return; - const int y = dynentity_bottom(e); - int prevy = entity_bottom(n); + const double y = dynentity_bottom(e); + double prevy = entity_bottom(n); if (y >= prevy) return;