From 8ae999ccc8869df424dd8d7c7afef18f1def6988 Mon Sep 17 00:00:00 2001 From: En Yi Date: Sat, 18 Nov 2023 20:13:02 +0800 Subject: [PATCH] Tweak water rendering make water rendering in front of all entities --- scenes/editor_scene.c | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/scenes/editor_scene.c b/scenes/editor_scene.c index de99ea7..5449c08 100644 --- a/scenes/editor_scene.c +++ b/scenes/editor_scene.c @@ -274,17 +274,6 @@ static void render_editor_game_scene(Scene_t* scene) } } - // Draw water tile - uint32_t water_height = tilemap.tiles[i].water_level * WATER_BBOX_STEP; - // Draw water tile - Color water_colour = ColorAlpha(BLUE, 0.5); - DrawRectangle( - x, - y + (TILE_SIZE - water_height), - TILE_SIZE, - water_height, - water_colour - ); if (tilemap.tiles[i].max_water_level < MAX_WATER_LEVEL) { DrawRectangleLinesEx((Rectangle){x, y, TILE_SIZE, TILE_SIZE}, 2.0, ColorAlpha(BLUE, 0.5)); @@ -438,6 +427,27 @@ static void render_editor_game_scene(Scene_t* scene) DrawCircleV(p_ct->position, tilemap.tile_size >> 1, (data->coins.current < data->coins.total)? RED : GREEN); } + for (int tile_y = min.y; tile_y < max.y; tile_y++) + { + for (int tile_x = min.x; tile_x < max.x; tile_x++) + { + int i = tile_x + tile_y * tilemap.width; + int x = tile_x * TILE_SIZE; + int y = tile_y * TILE_SIZE; + + uint32_t water_height = tilemap.tiles[i].water_level * WATER_BBOX_STEP; + // Draw water tile + Color water_colour = ColorAlpha(BLUE, 0.5); + DrawRectangle( + x, + y + (TILE_SIZE - water_height), + TILE_SIZE, + water_height, + water_colour + ); + } + } + sc_map_foreach_value(&scene->ent_manager.entities_map[DYNMEM_ENT_TAG], p_ent) { CWaterRunner_t* p_runner = get_component(p_ent, CWATERRUNNER_T);