From 7a670f85fc3f2d632a28b28cb8f19f1150434320 Mon Sep 17 00:00:00 2001 From: En Yi Date: Fri, 23 Jun 2023 21:52:06 +0800 Subject: [PATCH] Extend one pixel outwards for tile collision check --- scenes/game_systems.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scenes/game_systems.c b/scenes/game_systems.c index a3984c4..e0349ea 100644 --- a/scenes/game_systems.c +++ b/scenes/game_systems.c @@ -794,8 +794,8 @@ void tile_collision_system(Scene_t* scene) // exclude self // This has an extra pixel when gathering potential collision, just to avoid missing any // This is only done here, collision methods do not have this - unsigned int tile_x1 = (p_ctransform->position.x) / TILE_SIZE; - unsigned int tile_y1 = (p_ctransform->position.y) / TILE_SIZE; + unsigned int tile_x1 = (p_ctransform->position.x - 1) / TILE_SIZE; + unsigned int tile_y1 = (p_ctransform->position.y - 1) / TILE_SIZE; unsigned int tile_x2 = (p_ctransform->position.x + p_bbox->size.x) / TILE_SIZE; unsigned int tile_y2 = (p_ctransform->position.y + p_bbox->size.y) / TILE_SIZE;