diff --git a/scenes/engine/EC/EC.h b/scenes/engine/EC/EC.h index 916eeec..da66e26 100644 --- a/scenes/engine/EC/EC.h +++ b/scenes/engine/EC/EC.h @@ -108,13 +108,13 @@ typedef struct _CContainer_t { typedef struct _CHitBoxes_t { Rectangle boxes[2]; uint8_t n_boxes; - bool strong; + uint8_t atk; } CHitBoxes_t; typedef struct _CHurtbox_t { Vector2 offset; Vector2 size; - bool fragile; + uint8_t def; } CHurtbox_t; // Credits to bedroomcoders.co.uk for this diff --git a/scenes/game_systems.c b/scenes/game_systems.c index 60ffbb0..358df74 100644 --- a/scenes/game_systems.c +++ b/scenes/game_systems.c @@ -1386,6 +1386,7 @@ void hitbox_update_system(Scene_t* scene) if (p_other_hurtbox == NULL) continue; CTransform_t* p_other_ct = get_component(p_other_ent, CTRANSFORM_COMP_T); Vector2 hurtbox_pos = Vector2Add(p_other_ct->position, p_other_hurtbox->offset); + if (p_hitbox->atk <= p_other_hurtbox->def) continue; Vector2 overlap; if ( @@ -1395,14 +1396,12 @@ void hitbox_update_system(Scene_t* scene) ) ) { - if (!p_other_hurtbox->fragile) continue; //if (p_other_ent->m_tag == CRATES_ENT_TAG) { CBBox_t* p_bbox = get_component(p_ent, CBBOX_COMP_T); CPlayerState_t* p_pstate = get_component(p_ent, CPLAYERSTATE_T); if ( - // TODO: Check Material of the crates p_ctransform->position.y + p_bbox->size.y <= p_other_ct->position.y ) { diff --git a/scenes/items_ent.c b/scenes/items_ent.c index 9be2061..622759a 100644 --- a/scenes/items_ent.c +++ b/scenes/items_ent.c @@ -16,7 +16,7 @@ Entity_t* create_crate(EntityManager_t* ent_manager, Assets_t* assets, bool meta add_component(p_crate, CTILECOORD_COMP_T); CHurtbox_t* p_hurtbox = add_component(p_crate, CHURTBOX_T); p_hurtbox->size = p_bbox->size; - p_hurtbox->fragile = !metal; + p_hurtbox->def = metal ? 2 : 1; return p_crate; } @@ -37,6 +37,6 @@ Entity_t* create_boulder(EntityManager_t* ent_manager, Assets_t* assets) p_cmove->move_speed = 8; CHurtbox_t* p_hurtbox = add_component(p_boulder, CHURTBOX_T); p_hurtbox->size = p_bbox->size; - p_hurtbox->fragile = false; + p_hurtbox->def = 2; return p_boulder; } diff --git a/scenes/player_ent.c b/scenes/player_ent.c index 0fa5c0d..27f615d 100644 --- a/scenes/player_ent.c +++ b/scenes/player_ent.c @@ -83,6 +83,7 @@ Entity_t* create_player(EntityManager_t* ent_manager, Assets_t* assets) .width = p_bbox->size.x + 2, .height = p_bbox->size.y - 1, }; + p_hitbox->atk = 2; CSprite_t* p_cspr = add_component(p_ent, CSPRITE_T); p_cspr->sprites = player_sprite_map; p_cspr->transition_func = &player_sprite_transition_func;