Compare commits

...

3 Commits

Author SHA1 Message Date
En Yi db8849a7de Add urchin particles and update menus 2024-10-05 20:22:16 +08:00
En Yi 1382cf1370 Deal with urchin's particle effects 2024-10-05 19:18:42 +08:00
En Yi e52c9445c9 Fix crash when player finish a level
This happens because the player exit entity is removed without checking
with the tilemap, causing it to linger
2024-10-05 19:07:55 +08:00
5 changed files with 13 additions and 14 deletions

View File

@ -11,6 +11,7 @@ typedef enum EntityTag {
LEVEL_END_TAG,
DESTRUCTABLE_ENT_TAG,
DYNMEM_ENT_TAG,
URCHIN_ENT_TAG,
} EntityTag_t;
typedef enum SFXTag {

View File

@ -147,10 +147,10 @@ static void level_scene_render_func(Scene_t* scene)
selection_rec.x + current_spawn_selection * SELECTION_TILE_SIZE, selection_rec.y,
SELECTION_TILE_SIZE, SELECTION_TILE_SIZE, GREEN
);
DrawText("R to reset the map, Q/E to cycle the selection,\nF to toggle metal crates. T to toggle crate spawn behaviour\nZ to change tileset, X to toggle grid\nC to set spawn point, V to toggle free cam", selection_rec.x, selection_rec.y + selection_rec.height + 2, 14, BLACK);
DrawText("R to reset the map, Q/E to cycle the selection,\nF to toggle metal crates. T to toggle crate spawn behaviour\nZ to change tileset, X to toggle grid\nC to set spawn point, V to toggle free cam, B to toggle slowmo", selection_rec.x, selection_rec.y + selection_rec.height + 2, 14, BLACK);
draw_pos.x = game_rec.x + (MAX_SPAWN_TYPE + 1) * SELECTION_TILE_SIZE;
sprintf(buffer, "Selection: %s", get_spawn_selection_string(current_spawn_selection));
sprintf(buffer, "%s", get_spawn_selection_string(current_spawn_selection));
DrawText(buffer, draw_pos.x, draw_pos.y, 20, BLACK);
draw_pos.y += 20 + 5;
sprintf(buffer, "Crate %s on spawn", crate_activation? "active" : "inactive");
@ -1255,7 +1255,8 @@ static void at_level_complete(Scene_t* scene)
}
if (data->sm.counter >= 1)
{
do_action(scene, ACTION_NEXTLEVEL, true);
data->sm.counter = 0;
data->sm.fractional = 0;
at_level_dead(scene);
}
}
@ -1511,7 +1512,6 @@ void init_sandbox_scene(LevelScene_t* scene)
// insert level scene systems
sc_array_add(&scene->scene.systems, &update_tilemap_system);
sc_array_add(&scene->scene.systems, &player_movement_input_system);
sc_array_add(&scene->scene.systems, &player_bbox_update_system);
sc_array_add(&scene->scene.systems, &player_pushing_system);
@ -1523,7 +1523,7 @@ void init_sandbox_scene(LevelScene_t* scene)
sc_array_add(&scene->scene.systems, &boulder_destroy_wooden_tile_system);
sc_array_add(&scene->scene.systems, &update_tilemap_system);
sc_array_add(&scene->scene.systems, &tile_collision_system);
//sc_array_add(&scene->scene.systems, &update_tilemap_system);
sc_array_add(&scene->scene.systems, &update_tilemap_system);
sc_array_add(&scene->scene.systems, &hitbox_update_system);
sc_array_add(&scene->scene.systems, &player_crushing_system);
sc_array_add(&scene->scene.systems, &spike_collision_system);
@ -1566,8 +1566,8 @@ void init_sandbox_scene(LevelScene_t* scene)
sc_map_put_64(&scene->scene.action_map, KEY_Z, ACTION_SWITCH_TILESET);
sc_map_put_64(&scene->scene.action_map, KEY_X, ACTION_TOGGLE_GRID);
sc_map_put_64(&scene->scene.action_map, KEY_C, ACTION_SET_SPAWNPOINT);
sc_map_put_64(&scene->scene.action_map, KEY_U, ACTION_TOGGLE_TIMESLOW);
sc_map_put_64(&scene->scene.action_map, KEY_V, ACTION_LOOKAHEAD);
sc_map_put_64(&scene->scene.action_map, KEY_B, ACTION_TOGGLE_TIMESLOW);
sc_map_put_64(&scene->scene.action_map, MOUSE_LEFT_BUTTON, ACTION_SPAWN_TILE);
sc_map_put_64(&scene->scene.action_map, MOUSE_RIGHT_BUTTON, ACTION_REMOVE_TILE);

View File

@ -258,10 +258,10 @@ static void destroy_entity(Scene_t* scene, TileGrid_t* tilemap, Entity_t* p_ent)
play_particle_emitter(&scene->part_sys, &emitter);
play_sfx(scene->engine, ARROW_DESTROY_SFX);
}
else if (p_ent->m_tag == NO_ENT_TAG)
else if (p_ent->m_tag == URCHIN_ENT_TAG)
{
ParticleEmitter_t emitter = {
.spr = get_sprite(&scene->engine->assets, "p_spike"),
.spr = get_sprite(&scene->engine->assets, "p_urc"),
.config = get_emitter_conf(&scene->engine->assets, "pe_burst"),
.position = Vector2Add(p_ent->position, half_size),
.n_particles = 8,

View File

@ -250,7 +250,7 @@ Entity_t* create_urchin(EntityManager_t* ent_manager)
// The hit box is larger than the bbox
// Unfortunately, it's too late to incorporate the offset for the bbox component
// So, offset the hitbox instead and external reposition it.
Entity_t* p_urchin = add_entity(ent_manager, NO_ENT_TAG);
Entity_t* p_urchin = add_entity(ent_manager, URCHIN_ENT_TAG);
if (p_urchin == NULL) return NULL;
CBBox_t* p_bbox = add_component(p_urchin, CBBOX_COMP_T);

View File

@ -146,9 +146,7 @@ static unsigned int player_finish_transition_func(Entity_t* ent)
if (p_spr->current_frame == p_spr->sprites[p_spr->current_idx].sprite->frame_count - 1)
{
p_spr->pause = true;
// This entity has no special init, so it's fine to remove
// at end of animation
remove_entity(ent->manager, ent->m_id);
//remove_entity(ent->manager, ent->m_id);
}
return p_spr->current_idx;
}
@ -163,8 +161,8 @@ Entity_t* create_player_finish(EntityManager_t* ent_manager)
p_cspr->current_idx = SPR_PLAYER_ENTER;
p_cspr->transition_func = &player_finish_transition_func;
add_component(p_ent, CTILECOORD_COMP_T);
CLifeTimer_t* p_clifetimer = add_component(p_ent, CLIFETIMER_T);
p_clifetimer->life_time = 0.9f;
return p_ent;
}