From 3ee14d5f47d4837ae6d7b88b5514d0215c5e47ba Mon Sep 17 00:00:00 2001 From: En Yi Date: Thu, 22 Jun 2023 22:44:07 +0800 Subject: [PATCH] Add bbox check even for solid tile --- scenes/game_systems.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/scenes/game_systems.c b/scenes/game_systems.c index 9d73752..d14013d 100644 --- a/scenes/game_systems.c +++ b/scenes/game_systems.c @@ -51,9 +51,22 @@ static uint8_t check_collision(const CollideEntity_t* ent, TileGrid_t* grid, boo { if (tile_x >= grid->width) return 0; unsigned int tile_idx = tile_y*grid->width + tile_x; - if (grid->tiles[tile_idx].solid == SOLID) return 1; Vector2 overlap; + if (grid->tiles[tile_idx].solid == SOLID) + { + if (find_AABB_overlap( + (Vector2){ent->bbox.x, ent->bbox.y}, + (Vector2){ent->bbox.width, ent->bbox.height}, + (Vector2){tile_x * TILE_SIZE + grid->tiles[tile_idx].offset.x, tile_y * TILE_SIZE + grid->tiles[tile_idx].offset.y}, + grid->tiles[tile_idx].size, + &overlap + )) + { + return 1; + } + } + if (check_oneway && grid->tiles[tile_idx].solid == ONE_WAY) { find_AABB_overlap(