From 5bbbaa19e2b1780654dd40277ecd04ad93433b17 Mon Sep 17 00:00:00 2001 From: En Yi Date: Wed, 5 Jul 2023 23:20:16 +0800 Subject: [PATCH] Fix ladder not switching to one_way solid --- scenes/game_systems.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/scenes/game_systems.c b/scenes/game_systems.c index 153910b..2a23836 100644 --- a/scenes/game_systems.c +++ b/scenes/game_systems.c @@ -42,6 +42,7 @@ typedef struct CollideEntity { void change_a_tile(TileGrid_t* tilemap, unsigned int tile_idx, TileType_t new_type) { + TileType_t last_type = tilemap->tiles[tile_idx].tile_type; tilemap->tiles[tile_idx].tile_type = new_type; switch (new_type) @@ -78,6 +79,16 @@ void change_a_tile(TileGrid_t* tilemap, unsigned int tile_idx, TileType_t new_ty break; } + if (last_type == LADDER && new_type != LADDER) + { + int down_tile = tile_idx + tilemap->width; + if (down_tile < tilemap->n_tiles && tilemap->tiles[down_tile].tile_type == LADDER) + { + tilemap->tiles[down_tile].solid = ONE_WAY; + } + + } + if (new_type == SPIKES) { // Priority: Down, Up, Left, Right