From 523be15ead20e23e10498cdc5949e97da7ebca23 Mon Sep 17 00:00:00 2001 From: En Yi Date: Mon, 21 Apr 2025 22:04:56 +0800 Subject: [PATCH] Fix boulder interaction on ladders Fix also collision check for general entity overlapping a tile --- scenes/game_systems.c | 6 ++++-- scenes/scene_systems.c | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/scenes/game_systems.c b/scenes/game_systems.c index 925dab0..78d0146 100644 --- a/scenes/game_systems.c +++ b/scenes/game_systems.c @@ -816,6 +816,8 @@ void tile_collision_system(Scene_t* scene) for (unsigned int tile_x = tile_x1; tile_x <= tile_x2; tile_x++) { unsigned int tile_idx = tile_y * tilemap.width + tile_x; + + // Tilemap collision check if(tilemap.tiles[tile_idx].tile_type != EMPTY_TILE) { Vector2 other; @@ -844,7 +846,7 @@ void tile_collision_system(Scene_t* scene) ); } - else + // Entity collision check { unsigned int other_ent_idx; Entity_t* p_other_ent; @@ -1246,7 +1248,7 @@ void player_pushing_system(Scene_t* scene) unsigned int tile_x = (point_to_check.x) / TILE_SIZE; unsigned int tile_y = (point_to_check.y) / TILE_SIZE; unsigned int tile_idx = tile_y * tilemap.width + tile_x; - if(tilemap.tiles[tile_idx].tile_type != EMPTY_TILE) continue; + if(!tilemap.tiles[tile_idx].moveable) continue; Entity_t* p_other_ent; sc_map_foreach_value(&tilemap.tiles[tile_idx].entities_set, p_other_ent) diff --git a/scenes/scene_systems.c b/scenes/scene_systems.c index 93a150f..75e3d61 100644 --- a/scenes/scene_systems.c +++ b/scenes/scene_systems.c @@ -411,6 +411,7 @@ void change_a_tile(TileGrid_t* tilemap, unsigned int tile_idx, TileType_t new_ty tilemap->tiles[tile_idx].moveable = ( tilemap->tiles[tile_idx].tile_type == EMPTY_TILE || tilemap->tiles[tile_idx].tile_type == SPIKES + || tilemap->tiles[tile_idx].tile_type == LADDER ); tilemap->tiles[tile_idx].def = (tilemap->tiles[tile_idx].tile_type == SOLID_TILE) ? 5: 2;