From 8d9494354704a099997a401bebeb3bcb73fa1e65 Mon Sep 17 00:00:00 2001 From: En Yi Date: Tue, 28 Feb 2023 20:56:54 +0800 Subject: [PATCH] (Temporary) Fix corner collision issue Changelog: - When player move diagonally into a corner, collision is missing. This is because collision is resolved one-by-one and will not move the player if the new position still causes collision. In this literal corner case, player will not be moved as the player collide with both solids and resolving in either direction would still result in collision in the new position, unless both is resolved at the same time. Temporary 'fix' this by not checking the new position. No real idea on how to solve this for now. --- engine/game_systems.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/engine/game_systems.c b/engine/game_systems.c index a29ebd3..8bc67b8 100644 --- a/engine/game_systems.c +++ b/engine/game_systems.c @@ -140,7 +140,8 @@ static bool check_collision_and_move(EntityManager_t* p_manager, TileGrid_t* til // Resolve collision via moving player by the overlap amount only if other is solid // also check for empty to prevent creating new collision. Not fool-proof, but good enough - if (other_solid && !check_collision_at(ent_idx, p_ct->position, sz, tilemap, offset, p_manager)) + //if (other_solid && !check_collision_at(ent_idx, p_ct->position, sz, tilemap, offset, p_manager)) + if (other_solid) { p_ct->position = Vector2Add(p_ct->position, offset); if (dir_to_move == 0)