Add air pocket tile
Air pockets are just tiles with a max water level lower than the absolute maximum Also, make air pockets not reachable by water runnersscene_man
parent
7d00d348f6
commit
478dea2d9c
|
@ -17,6 +17,7 @@ enum EntitySpawnSelection {
|
||||||
TOGGLE_LADDER,
|
TOGGLE_LADDER,
|
||||||
TOGGLE_SPIKE,
|
TOGGLE_SPIKE,
|
||||||
TOGGLE_WATER,
|
TOGGLE_WATER,
|
||||||
|
TOGGLE_AIR_POCKET,
|
||||||
SPAWN_CRATE,
|
SPAWN_CRATE,
|
||||||
SPAWN_CRATE_ARROW_L,
|
SPAWN_CRATE_ARROW_L,
|
||||||
SPAWN_CRATE_ARROW_R,
|
SPAWN_CRATE_ARROW_R,
|
||||||
|
@ -27,7 +28,7 @@ enum EntitySpawnSelection {
|
||||||
SPAWN_WATER_RUNNER,
|
SPAWN_WATER_RUNNER,
|
||||||
};
|
};
|
||||||
|
|
||||||
#define MAX_SPAWN_TYPE 13
|
#define MAX_SPAWN_TYPE 14
|
||||||
static unsigned int current_spawn_selection = 0;
|
static unsigned int current_spawn_selection = 0;
|
||||||
static bool metal_toggle = false;
|
static bool metal_toggle = false;
|
||||||
|
|
||||||
|
@ -110,6 +111,10 @@ static void level_scene_render_func(Scene_t* scene)
|
||||||
water_height,
|
water_height,
|
||||||
water_colour
|
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};
|
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};
|
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 crate_colour = metal_toggle ? GRAY : BROWN;
|
||||||
const Color draw_colour[MAX_SPAWN_TYPE] = {
|
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,
|
crate_colour, crate_colour, crate_colour, crate_colour, crate_colour, crate_colour,
|
||||||
ColorAlpha(RAYWHITE, 0.5), ColorAlpha(RAYWHITE, 0.5)
|
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:
|
case SPAWN_WATER_RUNNER:
|
||||||
DrawCircleV(Vector2Add(draw_pos, half_size), half_size.x, ColorAlpha(BLUE, 0.2));
|
DrawCircleV(Vector2Add(draw_pos, half_size), half_size.x, ColorAlpha(BLUE, 0.2));
|
||||||
break;
|
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;
|
draw_pos.x += SELECTION_TILE_SIZE;
|
||||||
|
@ -412,6 +420,9 @@ static void level_scene_render_func(Scene_t* scene)
|
||||||
case SPAWN_WATER_RUNNER:
|
case SPAWN_WATER_RUNNER:
|
||||||
DrawCircleV(Vector2Add(draw_pos, half_size), half_size.x, ColorAlpha(BLUE, 0.2));
|
DrawCircleV(Vector2Add(draw_pos, half_size), half_size.x, ColorAlpha(BLUE, 0.2));
|
||||||
break;
|
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
|
// For DEBUG
|
||||||
|
@ -520,6 +531,18 @@ static void toggle_block_system(Scene_t* scene)
|
||||||
tilemap.tiles[tile_idx].water_level++;
|
tilemap.tiles[tile_idx].water_level++;
|
||||||
}
|
}
|
||||||
break;
|
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:
|
case SPAWN_CRATE:
|
||||||
spawn_crate(scene, tile_idx, metal_toggle, CONTAINER_EMPTY);
|
spawn_crate(scene, tile_idx, metal_toggle, CONTAINER_EMPTY);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include "water_flow.h"
|
#include "water_flow.h"
|
||||||
|
#include "constants.h"
|
||||||
#include "sc/queue/sc_queue.h"
|
#include "sc/queue/sc_queue.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
Entity_t* create_water_runner(EntityManager_t* ent_manager, int32_t width, int32_t height, int32_t start_tile)
|
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)
|
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 (
|
if (
|
||||||
next_tile->solid == SOLID
|
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 = curr_idx - 1;
|
||||||
next_tile = tilemap->tiles + next;
|
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;
|
next = curr_idx + 1;
|
||||||
if (next % p_crunner->bfs_tilemap.width != 0)
|
if (next % p_crunner->bfs_tilemap.width != 0)
|
||||||
{
|
{
|
||||||
next_tile = tilemap->tiles + next;
|
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)
|
if (next >= 0)
|
||||||
{
|
{
|
||||||
next_tile = tilemap->tiles + next;
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -368,7 +368,7 @@ int main(void)
|
||||||
all_tiles[i].solid = NOT_SOLID;
|
all_tiles[i].solid = NOT_SOLID;
|
||||||
all_tiles[i].tile_type = EMPTY_TILE;
|
all_tiles[i].tile_type = EMPTY_TILE;
|
||||||
all_tiles[i].moveable = true;
|
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);
|
sc_map_init_64v(&all_tiles[i].entities_set, 16, 0);
|
||||||
all_tiles[i].size = (Vector2){TILE_SIZE, TILE_SIZE};
|
all_tiles[i].size = (Vector2){TILE_SIZE, TILE_SIZE};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue