Compare commits
6 Commits
f94ecedc7d
...
f8277b304c
Author | SHA1 | Date |
---|---|---|
|
f8277b304c | |
|
9a9f77c7b2 | |
|
dbf5b30366 | |
|
637319cfd0 | |
|
ec9e21dc8a | |
|
799941ed80 |
|
@ -8,10 +8,11 @@ set(RAYLIB_DIR /usr/local/lib CACHE FILEPATH "directory to Raylib")
|
||||||
set(LIBZSTD_DIR /usr/local/lib CACHE FILEPATH "directory to zstd")
|
set(LIBZSTD_DIR /usr/local/lib CACHE FILEPATH "directory to zstd")
|
||||||
|
|
||||||
if (EMSCRIPTEN)
|
if (EMSCRIPTEN)
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -s USE_GLFW=3 -s ASSERTIONS=1 -s WASM=1 -s ASYNCIFY")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DPLATFORM_WEB")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DPLATFORM_WEB")
|
||||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s USE_GLFW=3 -s ASSERTIONS=1 -s WASM=1 -s ASYNCIFY")
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s USE_GLFW=3 -s ASSERTIONS=1 -s WASM=1 -s ASYNCIFY -s TOTAL_MEMORY=16777216 -s TOTAL_STACK=1048576 --preload-file ./res ")
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s USE_GLFW=3 -s ASSERTIONS=1 -s WASM=1 -s ASYNCIFY")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||||
|
|
||||||
set(CMAKE_EXECUTABLE_SUFFIX ".html")
|
set(CMAKE_EXECUTABLE_SUFFIX ".html")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
@ -25,7 +26,9 @@ set(GAME_LIBS
|
||||||
|
|
||||||
add_subdirectory(engine)
|
add_subdirectory(engine)
|
||||||
add_subdirectory(scenes)
|
add_subdirectory(scenes)
|
||||||
|
if (NOT EMSCRIPTEN)
|
||||||
add_subdirectory(res)
|
add_subdirectory(res)
|
||||||
|
endif ()
|
||||||
|
|
||||||
add_executable(${PROJECT_NAME}
|
add_executable(${PROJECT_NAME}
|
||||||
main.c
|
main.c
|
||||||
|
|
|
@ -136,7 +136,7 @@ bool is_emitter_handle_alive(ParticleSystem_t* system, EmitterHandle handle)
|
||||||
EmitterHandle play_particle_emitter(ParticleSystem_t* system, const ParticleEmitter_t* in_emitter)
|
EmitterHandle play_particle_emitter(ParticleSystem_t* system, const ParticleEmitter_t* in_emitter)
|
||||||
{
|
{
|
||||||
EmitterHandle idx = load_in_particle_emitter(system, in_emitter);
|
EmitterHandle idx = load_in_particle_emitter(system, in_emitter);
|
||||||
if (idx == 0) return 0 ;
|
if (idx == 0) return 0;
|
||||||
|
|
||||||
play_emitter_handle(system, idx);
|
play_emitter_handle(system, idx);
|
||||||
return idx;
|
return idx;
|
||||||
|
@ -181,23 +181,27 @@ void update_particle_system(ParticleSystem_t* system)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
emitter->particles[i].spawned = true;
|
emitter->particles[i].spawned = true;
|
||||||
|
spawn_particle(emitter, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!emitter->particles[i].alive)
|
if (emitter->particles[i].spawned)
|
||||||
{
|
{
|
||||||
if (!emitter->active)
|
if (!emitter->particles[i].alive)
|
||||||
{
|
{
|
||||||
inactive_count++;
|
if (!emitter->active)
|
||||||
}
|
{
|
||||||
else if (emitter->config->one_shot)
|
inactive_count++;
|
||||||
{
|
}
|
||||||
inactive_count++;
|
else if (emitter->config->one_shot)
|
||||||
}
|
{
|
||||||
else if (emitter->particles[i].spawned)
|
inactive_count++;
|
||||||
{
|
}
|
||||||
// If not one shot, immediately revive the particle
|
else
|
||||||
spawn_particle(emitter, i);
|
{
|
||||||
|
// If not one shot, immediately revive the particle
|
||||||
|
spawn_particle(emitter, i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
8
main.c
8
main.c
|
@ -41,6 +41,14 @@ int main(void)
|
||||||
load_sfx(&engine, "snd_wdrop", WATER_IN_SFX);
|
load_sfx(&engine, "snd_wdrop", WATER_IN_SFX);
|
||||||
load_sfx(&engine, "snd_bland", BOULDER_LAND_SFX);
|
load_sfx(&engine, "snd_bland", BOULDER_LAND_SFX);
|
||||||
load_sfx(&engine, "snd_bubble", BUBBLE_SFX);
|
load_sfx(&engine, "snd_bubble", BUBBLE_SFX);
|
||||||
|
load_sfx(&engine, "snd_mdestroy", METAL_DESTROY_SFX);
|
||||||
|
load_sfx(&engine, "snd_wdestroy", WOOD_DESTROY_SFX);
|
||||||
|
load_sfx(&engine, "snd_cland", WOOD_LAND_SFX);
|
||||||
|
load_sfx(&engine, "snd_explsn", EXPLOSION_SFX);
|
||||||
|
load_sfx(&engine, "snd_coin", COIN_SFX);
|
||||||
|
load_sfx(&engine, "snd_arrhit", ARROW_DESTROY_SFX);
|
||||||
|
load_sfx(&engine, "snd_launch", ARROW_RELEASE_SFX);
|
||||||
|
load_sfx(&engine, "snd_launch", BOMB_RELEASE_SFX);
|
||||||
|
|
||||||
LevelScene_t sandbox_scene;
|
LevelScene_t sandbox_scene;
|
||||||
sandbox_scene.scene.engine = &engine;
|
sandbox_scene.scene.engine = &engine;
|
||||||
|
|
|
@ -26,6 +26,7 @@ void update_loop(void)
|
||||||
update_entity_manager(&scene->ent_manager);
|
update_entity_manager(&scene->ent_manager);
|
||||||
// This is needed to advance time delta
|
// This is needed to advance time delta
|
||||||
render_scene(scene);
|
render_scene(scene);
|
||||||
|
update_sfx_list(&engine);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
|
|
|
@ -126,16 +126,14 @@ static void level_scene_render_func(Scene_t* scene)
|
||||||
const int gui_x = data->game_rec.x + data->game_rec.width + 10;
|
const int gui_x = data->game_rec.x + data->game_rec.width + 10;
|
||||||
int gui_y = 15;
|
int gui_y = 15;
|
||||||
|
|
||||||
#if !defined(PLATFORM_WEB)
|
|
||||||
sc_map_foreach_value(&scene->ent_manager.entities_map[PLAYER_ENT_TAG], p_ent)
|
sc_map_foreach_value(&scene->ent_manager.entities_map[PLAYER_ENT_TAG], p_ent)
|
||||||
{
|
{
|
||||||
|
#if !defined(PLATFORM_WEB)
|
||||||
CTransform_t* p_ct = get_component(p_ent, CTRANSFORM_COMP_T);
|
CTransform_t* p_ct = get_component(p_ent, CTRANSFORM_COMP_T);
|
||||||
CJump_t* p_cjump = get_component(p_ent, CJUMP_COMP_T);
|
CJump_t* p_cjump = get_component(p_ent, CJUMP_COMP_T);
|
||||||
CPlayerState_t* p_pstate = get_component(p_ent, CPLAYERSTATE_T);
|
CPlayerState_t* p_pstate = get_component(p_ent, CPLAYERSTATE_T);
|
||||||
CMovementState_t* p_mstate = get_component(p_ent, CMOVEMENTSTATE_T);
|
CMovementState_t* p_mstate = get_component(p_ent, CMOVEMENTSTATE_T);
|
||||||
|
|
||||||
CAirTimer_t* p_air = get_component(p_ent, CAIRTIMER_T);
|
|
||||||
|
|
||||||
sprintf(buffer, "Pos: %.3f\n %.3f", p_ct->position.x, p_ct->position.y);
|
sprintf(buffer, "Pos: %.3f\n %.3f", p_ct->position.x, p_ct->position.y);
|
||||||
DrawText(buffer, gui_x, gui_y, 12, BLACK);
|
DrawText(buffer, gui_x, gui_y, 12, BLACK);
|
||||||
sprintf(buffer, "Vel: %.3f\n %.3f", p_ct->velocity.x, p_ct->velocity.y);
|
sprintf(buffer, "Vel: %.3f\n %.3f", p_ct->velocity.x, p_ct->velocity.y);
|
||||||
|
@ -155,6 +153,9 @@ static void level_scene_render_func(Scene_t* scene)
|
||||||
DrawText(buffer, gui_x, gui_y, 12, BLACK);
|
DrawText(buffer, gui_x, gui_y, 12, BLACK);
|
||||||
gui_y += 30;
|
gui_y += 30;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
CAirTimer_t* p_air = get_component(p_ent, CAIRTIMER_T);
|
||||||
|
|
||||||
Vector2 air_pos = {data->game_rec.x + data->game_rec.width - 16, data->game_rec.y + data->game_rec.height - 16};
|
Vector2 air_pos = {data->game_rec.x + data->game_rec.width - 16, data->game_rec.y + data->game_rec.height - 16};
|
||||||
for (uint8_t i = 0; i < p_air->curr_count; i++)
|
for (uint8_t i = 0; i < p_air->curr_count; i++)
|
||||||
{
|
{
|
||||||
|
@ -162,7 +163,6 @@ static void level_scene_render_func(Scene_t* scene)
|
||||||
air_pos.x -= 32;
|
air_pos.x -= 32;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
//sprintf(buffer, "Spawn Entity: %s", get_spawn_selection_string(current_spawn_selection));
|
//sprintf(buffer, "Spawn Entity: %s", get_spawn_selection_string(current_spawn_selection));
|
||||||
//DrawText(buffer, gui_x, 240, 12, BLACK);
|
//DrawText(buffer, gui_x, 240, 12, BLACK);
|
||||||
sprintf(buffer, "Number of Entities: %u", sc_map_size_64v(&scene->ent_manager.entities));
|
sprintf(buffer, "Number of Entities: %u", sc_map_size_64v(&scene->ent_manager.entities));
|
||||||
|
@ -431,6 +431,9 @@ 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);
|
DrawCircleV(p_ct->position, tilemap.tile_size >> 1, (data->coins.current < data->coins.total)? RED : GREEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
draw_particle_system(&scene->part_sys);
|
||||||
|
|
||||||
|
// Draw water tile
|
||||||
for (int tile_y = min.y; tile_y < max.y; tile_y++)
|
for (int tile_y = min.y; tile_y < max.y; tile_y++)
|
||||||
{
|
{
|
||||||
for (int tile_x = min.x; tile_x < max.x; tile_x++)
|
for (int tile_x = min.x; tile_x < max.x; tile_x++)
|
||||||
|
@ -440,7 +443,6 @@ static void render_editor_game_scene(Scene_t* scene)
|
||||||
int y = tile_y * TILE_SIZE;
|
int y = tile_y * TILE_SIZE;
|
||||||
|
|
||||||
uint32_t water_height = tilemap.tiles[i].water_level * WATER_BBOX_STEP;
|
uint32_t water_height = tilemap.tiles[i].water_level * WATER_BBOX_STEP;
|
||||||
// Draw water tile
|
|
||||||
Color water_colour = ColorAlpha(BLUE, 0.5);
|
Color water_colour = ColorAlpha(BLUE, 0.5);
|
||||||
DrawRectangle(
|
DrawRectangle(
|
||||||
x,
|
x,
|
||||||
|
@ -461,7 +463,6 @@ static void render_editor_game_scene(Scene_t* scene)
|
||||||
DrawCircle(x+16, y+16, 8, ColorAlpha(BLUE, 0.6));
|
DrawCircle(x+16, y+16, 8, ColorAlpha(BLUE, 0.6));
|
||||||
}
|
}
|
||||||
|
|
||||||
draw_particle_system(&scene->part_sys);
|
|
||||||
|
|
||||||
if (data->show_grid)
|
if (data->show_grid)
|
||||||
{
|
{
|
||||||
|
|
|
@ -191,22 +191,11 @@ static void render_regular_game_scene(Scene_t* scene)
|
||||||
DrawLineEx((Vector2){x + TILE_SIZE / 2, bot_line}, (Vector2){x + TILE_SIZE, bot_line}, SURFACE_THICKNESS, ColorAlpha(BLUE, 0.7));
|
DrawLineEx((Vector2){x + TILE_SIZE / 2, bot_line}, (Vector2){x + TILE_SIZE, bot_line}, SURFACE_THICKNESS, ColorAlpha(BLUE, 0.7));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Draw water tile
|
if (tilemap.tiles[i].max_water_level < MAX_WATER_LEVEL)
|
||||||
uint32_t water_height = tilemap.tiles[i].water_level * WATER_BBOX_STEP;
|
{
|
||||||
// Draw water tile
|
DrawRectangleLinesEx((Rectangle){x, y, TILE_SIZE, TILE_SIZE}, 2.0, ColorAlpha(BLUE, 0.5));
|
||||||
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));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -322,6 +311,7 @@ static void render_regular_game_scene(Scene_t* scene)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sc_map_foreach_value(&scene->ent_manager.entities_map[DYNMEM_ENT_TAG], p_ent)
|
sc_map_foreach_value(&scene->ent_manager.entities_map[DYNMEM_ENT_TAG], p_ent)
|
||||||
{
|
{
|
||||||
CWaterRunner_t* p_runner = get_component(p_ent, CWATERRUNNER_T);
|
CWaterRunner_t* p_runner = get_component(p_ent, CWATERRUNNER_T);
|
||||||
|
@ -332,6 +322,27 @@ static void render_regular_game_scene(Scene_t* scene)
|
||||||
}
|
}
|
||||||
draw_particle_system(&scene->part_sys);
|
draw_particle_system(&scene->part_sys);
|
||||||
|
|
||||||
|
// Draw water tile
|
||||||
|
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;
|
||||||
|
Color water_colour = ColorAlpha(BLUE, 0.5);
|
||||||
|
DrawRectangle(
|
||||||
|
x,
|
||||||
|
y + (TILE_SIZE - water_height),
|
||||||
|
TILE_SIZE,
|
||||||
|
water_height,
|
||||||
|
water_colour
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Draw Border
|
// Draw Border
|
||||||
DrawLine(0, 0, 0, tilemap.height * tilemap.tile_size, BLACK);
|
DrawLine(0, 0, 0, tilemap.height * tilemap.tile_size, BLACK);
|
||||||
DrawLine(0, 0, tilemap.width * TILE_SIZE, 0, BLACK);
|
DrawLine(0, 0, tilemap.width * TILE_SIZE, 0, BLACK);
|
||||||
|
|
|
@ -65,6 +65,7 @@ static inline void destroy_tile(LevelSceneData_t* lvl_data, unsigned int tile_id
|
||||||
.n_particles = 5,
|
.n_particles = 5,
|
||||||
.user_data = lvl_data,
|
.user_data = lvl_data,
|
||||||
.update_func = &simple_particle_system_update,
|
.update_func = &simple_particle_system_update,
|
||||||
|
.emitter_update_func = NULL,
|
||||||
};
|
};
|
||||||
play_particle_emitter(&scene->part_sys, &emitter);
|
play_particle_emitter(&scene->part_sys, &emitter);
|
||||||
}
|
}
|
||||||
|
@ -250,6 +251,7 @@ void destroy_entity(Scene_t* scene, TileGrid_t* tilemap, Entity_t* p_ent)
|
||||||
.n_particles = 5,
|
.n_particles = 5,
|
||||||
.user_data = &(CONTAINER_OF(scene, LevelScene_t, scene)->data),
|
.user_data = &(CONTAINER_OF(scene, LevelScene_t, scene)->data),
|
||||||
.update_func = &simple_particle_system_update,
|
.update_func = &simple_particle_system_update,
|
||||||
|
.emitter_update_func = NULL,
|
||||||
};
|
};
|
||||||
play_particle_emitter(&scene->part_sys, &emitter);
|
play_particle_emitter(&scene->part_sys, &emitter);
|
||||||
}
|
}
|
||||||
|
@ -265,6 +267,7 @@ void destroy_entity(Scene_t* scene, TileGrid_t* tilemap, Entity_t* p_ent)
|
||||||
.n_particles = 5,
|
.n_particles = 5,
|
||||||
.user_data = &(CONTAINER_OF(scene, LevelScene_t, scene)->data),
|
.user_data = &(CONTAINER_OF(scene, LevelScene_t, scene)->data),
|
||||||
.update_func = &simple_particle_system_update,
|
.update_func = &simple_particle_system_update,
|
||||||
|
.emitter_update_func = NULL,
|
||||||
};
|
};
|
||||||
play_particle_emitter(&scene->part_sys, &emitter);
|
play_particle_emitter(&scene->part_sys, &emitter);
|
||||||
}
|
}
|
||||||
|
@ -278,8 +281,21 @@ void destroy_entity(Scene_t* scene, TileGrid_t* tilemap, Entity_t* p_ent)
|
||||||
.n_particles = 5,
|
.n_particles = 5,
|
||||||
.user_data = &(CONTAINER_OF(scene, LevelScene_t, scene)->data),
|
.user_data = &(CONTAINER_OF(scene, LevelScene_t, scene)->data),
|
||||||
.update_func = &simple_particle_system_update,
|
.update_func = &simple_particle_system_update,
|
||||||
|
.emitter_update_func = NULL,
|
||||||
};
|
};
|
||||||
play_particle_emitter(&scene->part_sys, &emitter);
|
play_particle_emitter(&scene->part_sys, &emitter);
|
||||||
|
|
||||||
|
ParticleEmitter_t emitter2 = {
|
||||||
|
.spr = get_sprite(&scene->engine->assets, "p_coin"),
|
||||||
|
.config = get_emitter_conf(&scene->engine->assets, "pe_single"),
|
||||||
|
.position = p_ctransform->position,
|
||||||
|
.n_particles = 1,
|
||||||
|
.user_data = &(CONTAINER_OF(scene, LevelScene_t, scene)->data),
|
||||||
|
.update_func = &simple_particle_system_update,
|
||||||
|
.emitter_update_func = NULL,
|
||||||
|
};
|
||||||
|
play_particle_emitter(&scene->part_sys, &emitter2);
|
||||||
|
|
||||||
play_sfx(scene->engine, COIN_SFX);
|
play_sfx(scene->engine, COIN_SFX);
|
||||||
}
|
}
|
||||||
else if (p_ent->m_tag == ARROW_ENT_TAG)
|
else if (p_ent->m_tag == ARROW_ENT_TAG)
|
||||||
|
@ -292,6 +308,7 @@ void destroy_entity(Scene_t* scene, TileGrid_t* tilemap, Entity_t* p_ent)
|
||||||
.n_particles = 2,
|
.n_particles = 2,
|
||||||
.user_data = &(CONTAINER_OF(scene, LevelScene_t, scene)->data),
|
.user_data = &(CONTAINER_OF(scene, LevelScene_t, scene)->data),
|
||||||
.update_func = &simple_particle_system_update,
|
.update_func = &simple_particle_system_update,
|
||||||
|
.emitter_update_func = NULL,
|
||||||
};
|
};
|
||||||
play_particle_emitter(&scene->part_sys, &emitter);
|
play_particle_emitter(&scene->part_sys, &emitter);
|
||||||
play_sfx(scene->engine, ARROW_DESTROY_SFX);
|
play_sfx(scene->engine, ARROW_DESTROY_SFX);
|
||||||
|
@ -1484,10 +1501,13 @@ void state_transition_update_system(Scene_t* scene)
|
||||||
{
|
{
|
||||||
if (!is_emitter_handle_alive(&scene->part_sys, p_emitter->handle))
|
if (!is_emitter_handle_alive(&scene->part_sys, p_emitter->handle))
|
||||||
{
|
{
|
||||||
|
Vector2 new_pos = p_ctransform->position;
|
||||||
|
new_pos.y += p_bbox->half_size.y;
|
||||||
|
|
||||||
ParticleEmitter_t emitter = {
|
ParticleEmitter_t emitter = {
|
||||||
.spr = get_sprite(&scene->engine->assets, "p_water"),
|
.spr = get_sprite(&scene->engine->assets, "p_water"),
|
||||||
.config = get_emitter_conf(&scene->engine->assets, "pe_bubbling"),
|
.config = get_emitter_conf(&scene->engine->assets, "pe_bubbling"),
|
||||||
.position = p_ctransform->position,
|
.position = new_pos,
|
||||||
.n_particles = 5,
|
.n_particles = 5,
|
||||||
.user_data = &(CONTAINER_OF(scene, LevelScene_t, scene)->data),
|
.user_data = &(CONTAINER_OF(scene, LevelScene_t, scene)->data),
|
||||||
.update_func = &floating_particle_system_update,
|
.update_func = &floating_particle_system_update,
|
||||||
|
@ -1513,9 +1533,11 @@ void update_entity_emitter_system(Scene_t* scene)
|
||||||
Entity_t* p_ent = get_entity(&scene->ent_manager, ent_idx);
|
Entity_t* p_ent = get_entity(&scene->ent_manager, ent_idx);
|
||||||
CTransform_t* p_ctransform = get_component(p_ent, CTRANSFORM_COMP_T);
|
CTransform_t* p_ctransform = get_component(p_ent, CTRANSFORM_COMP_T);
|
||||||
CBBox_t* p_bbox = get_component(p_ent, CBBOX_COMP_T);
|
CBBox_t* p_bbox = get_component(p_ent, CBBOX_COMP_T);
|
||||||
|
Vector2 new_pos = p_ctransform->position;
|
||||||
|
new_pos.y += p_bbox->half_size.y;
|
||||||
if (is_emitter_handle_alive(&scene->part_sys, p_emitter->handle))
|
if (is_emitter_handle_alive(&scene->part_sys, p_emitter->handle))
|
||||||
{
|
{
|
||||||
update_emitter_handle_position(&scene->part_sys, p_emitter->handle, p_ctransform->position);
|
update_emitter_handle_position(&scene->part_sys, p_emitter->handle, new_pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1944,6 +1966,16 @@ void airtimer_update_system(Scene_t* scene)
|
||||||
{
|
{
|
||||||
p_air->curr_count--;
|
p_air->curr_count--;
|
||||||
p_air->curr_ftimer = p_air->max_ftimer;
|
p_air->curr_ftimer = p_air->max_ftimer;
|
||||||
|
ParticleEmitter_t emitter = {
|
||||||
|
.spr = get_sprite(&scene->engine->assets, "p_bigbubble"),
|
||||||
|
.config = get_emitter_conf(&scene->engine->assets, "pe_slow"),
|
||||||
|
.position = p_ctransform->position,
|
||||||
|
.n_particles = 1,
|
||||||
|
.user_data = &(CONTAINER_OF(scene, LevelScene_t, scene)->data),
|
||||||
|
.update_func = &floating_particle_system_update,
|
||||||
|
.emitter_update_func = NULL,
|
||||||
|
};
|
||||||
|
play_particle_emitter(&scene->part_sys, &emitter);
|
||||||
play_sfx(scene->engine, BUBBLE_SFX);
|
play_sfx(scene->engine, BUBBLE_SFX);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -2179,7 +2211,7 @@ void simple_particle_system_update(Particle_t* part, void* user_data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void floating_particle_system_update(Particle_t* part, void* user_data)
|
void simple_float_particle_system_update(Particle_t* part, void* user_data)
|
||||||
{
|
{
|
||||||
LevelSceneData_t* lvl_data = (LevelSceneData_t*)user_data;
|
LevelSceneData_t* lvl_data = (LevelSceneData_t*)user_data;
|
||||||
TileGrid_t tilemap = lvl_data->tilemap;
|
TileGrid_t tilemap = lvl_data->tilemap;
|
||||||
|
@ -2205,8 +2237,21 @@ void floating_particle_system_update(Particle_t* part, void* user_data)
|
||||||
{
|
{
|
||||||
part->timer = 0;
|
part->timer = 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void floating_particle_system_update(Particle_t* part, void* user_data)
|
||||||
|
{
|
||||||
|
simple_float_particle_system_update(part, user_data);
|
||||||
|
|
||||||
|
LevelSceneData_t* lvl_data = (LevelSceneData_t*)user_data;
|
||||||
|
TileGrid_t tilemap = lvl_data->tilemap;
|
||||||
|
|
||||||
|
Vector2 center = Vector2AddValue(
|
||||||
|
part->position,
|
||||||
|
part->size / 2
|
||||||
|
);
|
||||||
center.y = part->position.y;
|
center.y = part->position.y;
|
||||||
|
|
||||||
if (!is_point_in_water(center, tilemap))
|
if (!is_point_in_water(center, tilemap))
|
||||||
{
|
{
|
||||||
part->timer = 0;
|
part->timer = 0;
|
||||||
|
|
Loading…
Reference in New Issue