diff --git a/scenes/editor_scene.c b/scenes/editor_scene.c index c4cc90c..e824521 100644 --- a/scenes/editor_scene.c +++ b/scenes/editor_scene.c @@ -17,6 +17,7 @@ enum EntitySpawnSelection { TOGGLE_LADDER, TOGGLE_SPIKE, TOGGLE_WATER, + TOGGLE_AIR_POCKET, SPAWN_CRATE, SPAWN_CRATE_ARROW_L, SPAWN_CRATE_ARROW_R, @@ -27,7 +28,7 @@ enum EntitySpawnSelection { SPAWN_WATER_RUNNER, }; -#define MAX_SPAWN_TYPE 13 +#define MAX_SPAWN_TYPE 14 static unsigned int current_spawn_selection = 0; static bool metal_toggle = false; @@ -110,6 +111,10 @@ static void level_scene_render_func(Scene_t* scene) 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)); + } } char buffer[64] = {0}; @@ -290,7 +295,7 @@ static void level_scene_render_func(Scene_t* scene) Vector2 draw_pos = {data->game_rec.x, data->game_rec.y + data->game_rec.height + SELECTION_GAP}; const Color crate_colour = metal_toggle ? GRAY : BROWN; const Color draw_colour[MAX_SPAWN_TYPE] = { - BLACK, MAROON, ORANGE, ColorAlpha(RAYWHITE, 0.5), ColorAlpha(BLUE, 0.5), + BLACK, MAROON, ORANGE, ColorAlpha(RAYWHITE, 0.5), ColorAlpha(BLUE, 0.5), ColorAlpha(RAYWHITE, 0.5), crate_colour, crate_colour, crate_colour, crate_colour, crate_colour, crate_colour, ColorAlpha(RAYWHITE, 0.5), ColorAlpha(RAYWHITE, 0.5) }; @@ -350,6 +355,9 @@ static void level_scene_render_func(Scene_t* scene) case SPAWN_WATER_RUNNER: DrawCircleV(Vector2Add(draw_pos, half_size), half_size.x, ColorAlpha(BLUE, 0.2)); break; + case TOGGLE_AIR_POCKET: + DrawRectangleLinesEx((Rectangle){draw_pos.x, draw_pos.y, SELECTION_TILE_SIZE, SELECTION_TILE_SIZE}, 2.0, ColorAlpha(BLUE, 0.5)); + break; } } draw_pos.x += SELECTION_TILE_SIZE; @@ -412,6 +420,9 @@ static void level_scene_render_func(Scene_t* scene) case SPAWN_WATER_RUNNER: DrawCircleV(Vector2Add(draw_pos, half_size), half_size.x, ColorAlpha(BLUE, 0.2)); break; + case TOGGLE_AIR_POCKET: + DrawRectangleLinesEx((Rectangle){draw_pos.x, draw_pos.y, SELECTION_TILE_SIZE, SELECTION_TILE_SIZE}, 2.0, ColorAlpha(BLUE, 0.5)); + break; } // For DEBUG @@ -520,6 +531,18 @@ static void toggle_block_system(Scene_t* scene) tilemap.tiles[tile_idx].water_level++; } break; + case TOGGLE_AIR_POCKET: + new_type = tilemap.tiles[tile_idx].tile_type; + if (tilemap.tiles[tile_idx].max_water_level < MAX_WATER_LEVEL) + { + tilemap.tiles[tile_idx].max_water_level = MAX_WATER_LEVEL; + } + else + { + tilemap.tiles[tile_idx].max_water_level = 0; + tilemap.tiles[tile_idx].water_level = 0; + } + break; case SPAWN_CRATE: spawn_crate(scene, tile_idx, metal_toggle, CONTAINER_EMPTY); break; diff --git a/scenes/water_flow.c b/scenes/water_flow.c index e658e7d..e8b435f 100644 --- a/scenes/water_flow.c +++ b/scenes/water_flow.c @@ -1,4 +1,5 @@ #include "water_flow.h" +#include "constants.h" #include "sc/queue/sc_queue.h" #include Entity_t* create_water_runner(EntityManager_t* ent_manager, int32_t width, int32_t height, int32_t start_tile) @@ -80,7 +81,7 @@ static void runner_BFS(const TileGrid_t* tilemap, CWaterRunner_t* p_crunner, int if (next < p_crunner->bfs_tilemap.len) { - to_go[0] = next_tile->solid != SOLID; + to_go[0] = (next_tile->solid != SOLID && next_tile->max_water_level == MAX_WATER_LEVEL); if ( next_tile->solid == SOLID @@ -92,13 +93,13 @@ static void runner_BFS(const TileGrid_t* tilemap, CWaterRunner_t* p_crunner, int { next = curr_idx - 1; next_tile = tilemap->tiles + next; - to_go[1] = next_tile->solid != SOLID; + to_go[1] = (next_tile->solid != SOLID && next_tile->max_water_level == MAX_WATER_LEVEL); } next = curr_idx + 1; if (next % p_crunner->bfs_tilemap.width != 0) { next_tile = tilemap->tiles + next; - to_go[2] = next_tile->solid != SOLID; + to_go[2] = (next_tile->solid != SOLID && next_tile->max_water_level == MAX_WATER_LEVEL); } } } @@ -110,7 +111,7 @@ static void runner_BFS(const TileGrid_t* tilemap, CWaterRunner_t* p_crunner, int if (next >= 0) { next_tile = tilemap->tiles + next; - to_go[3] = next_tile->solid != SOLID; + to_go[3] = (next_tile->solid != SOLID && next_tile->max_water_level == MAX_WATER_LEVEL); } } diff --git a/water_test.c b/water_test.c index 35bd3b2..62481d9 100644 --- a/water_test.c +++ b/water_test.c @@ -368,7 +368,7 @@ int main(void) all_tiles[i].solid = NOT_SOLID; all_tiles[i].tile_type = EMPTY_TILE; all_tiles[i].moveable = true; - all_tiles[i].max_water_level = 3; + all_tiles[i].max_water_level = 4; sc_map_init_64v(&all_tiles[i].entities_set, 16, 0); all_tiles[i].size = (Vector2){TILE_SIZE, TILE_SIZE}; }