diff --git a/scenes/editor_scene.c b/scenes/editor_scene.c index a54aa6f..a268816 100644 --- a/scenes/editor_scene.c +++ b/scenes/editor_scene.c @@ -397,6 +397,7 @@ static void render_editor_game_scene(Scene_t* scene) Color colour; switch(p_ent->m_tag) { + case NO_ENT_TAG: case PLAYER_ENT_TAG: colour = RED; break; @@ -849,8 +850,11 @@ static void toggle_block_system(Scene_t* scene, ActionType_t action, bool presse Entity_t* p_ent = create_urchin(&scene->ent_manager); if (p_ent != NULL) { - p_ent->position.x = (tile_idx % tilemap.width) * tilemap.tile_size; - p_ent->position.y = (tile_idx / tilemap.width) * tilemap.tile_size; + CBBox_t* p_bbox = get_component(p_ent, CBBOX_COMP_T); + p_ent->position.x = (tile_idx % tilemap.width) * tilemap.tile_size + + (tilemap.tile_size >> 1) - p_bbox->half_size.x; + p_ent->position.y = (tile_idx / tilemap.width) * tilemap.tile_size + + (tilemap.tile_size >> 1) - p_bbox->half_size.y; CTransform_t* p_ct = get_component(p_ent, CTRANSFORM_COMP_T); p_ct->velocity = Vector2Scale(urchin_spawn_vec, URCHIN_VELOCITY_SCALE); } diff --git a/scenes/game_systems.c b/scenes/game_systems.c index a0e6fc9..7a644dd 100644 --- a/scenes/game_systems.c +++ b/scenes/game_systems.c @@ -1,3 +1,4 @@ +#include "assets_tag.h" #ifdef TRACY_ENABLE #include "tracy/TracyC.h" #endif @@ -257,6 +258,19 @@ 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) + { + ParticleEmitter_t emitter = { + .spr = get_sprite(&scene->engine->assets, "p_spike"), + .config = get_emitter_conf(&scene->engine->assets, "pe_burst"), + .position = Vector2Add(p_ent->position, half_size), + .n_particles = 8, + .user_data = CONTAINER_OF(scene, LevelScene_t, scene), + .update_func = &simple_particle_system_update, + .emitter_update_func = NULL, + }; + play_particle_emitter(&scene->part_sys, &emitter); + } clear_an_entity(scene, tilemap, p_ent); } diff --git a/scenes/items_ent.c b/scenes/items_ent.c index 6979c82..f0ee61a 100644 --- a/scenes/items_ent.c +++ b/scenes/items_ent.c @@ -247,11 +247,14 @@ Entity_t* create_explosion(EntityManager_t* ent_manager) 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); if (p_urchin == NULL) return NULL; CBBox_t* p_bbox = add_component(p_urchin, CBBOX_COMP_T); - set_bbox(p_bbox, TILE_SIZE, TILE_SIZE); + set_bbox(p_bbox, TILE_SIZE-2, TILE_SIZE-2); CTransform_t* p_ctransform = add_component(p_urchin, CTRANSFORM_COMP_T); p_ctransform->movement_mode = KINEMATIC_MOVEMENT; @@ -267,7 +270,7 @@ Entity_t* create_urchin(EntityManager_t* ent_manager) CHitBoxes_t* p_hitbox = add_component(p_urchin, CHITBOXES_T); p_hitbox->n_boxes = 1; - p_hitbox->boxes[0] = (Rectangle){3, 3, 26, 26}; + p_hitbox->boxes[0] = (Rectangle) {-1,-1,TILE_SIZE,TILE_SIZE}; p_hitbox->atk = 2; CSprite_t* p_cspr = add_component(p_urchin, CSPRITE_T); @@ -287,7 +290,7 @@ Entity_t* create_chest(EntityManager_t* ent_manager) CBBox_t* p_bbox = add_component(p_chest, CBBOX_COMP_T); set_bbox(p_bbox, TILE_SIZE, TILE_SIZE); p_bbox->solid = true; - p_bbox->fragile = true; + p_bbox->fragile = false; CTransform_t* p_ctransform = add_component(p_chest, CTRANSFORM_COMP_T); p_ctransform->grav_delay = 0.3f;