Make player hitbox bigger

scene_man
En Yi 2023-11-22 21:41:43 +08:00
parent 96d389a69a
commit d62b862ebe
2 changed files with 10 additions and 11 deletions

View File

@ -581,9 +581,8 @@ void player_bbox_update_system(Scene_t* scene)
}
CHitBoxes_t* p_hitbox = get_component(p_player, CHITBOXES_T);
p_hitbox->boxes[0].height = p_bbox->size.y + 2;
//p_hitbox->boxes[1].y = p_bbox->size.y / 4;
p_hitbox->boxes[1].height = p_bbox->size.y - 1;
p_hitbox->boxes[0].height = p_bbox->size.y + 4;
p_hitbox->boxes[1].height = p_bbox->size.y;
CHurtbox_t* p_hurtbox = get_component(p_player, CHURTBOX_T);
p_hurtbox->size = p_bbox->size;
}
@ -1592,8 +1591,8 @@ void hitbox_update_system(Scene_t* scene)
unsigned int tile_x1 = (hitbox_pos.x) / TILE_SIZE;
unsigned int tile_y1 = (hitbox_pos.y) / TILE_SIZE;
unsigned int tile_x2 = (hitbox_pos.x + p_hitbox->boxes[i].width - 1) / TILE_SIZE;
unsigned int tile_y2 = (hitbox_pos.y + p_hitbox->boxes[i].height - 1) / TILE_SIZE;
unsigned int tile_x2 = (hitbox_pos.x + p_hitbox->boxes[i].width) / TILE_SIZE;
unsigned int tile_y2 = (hitbox_pos.y + p_hitbox->boxes[i].height) / TILE_SIZE;
tile_x2 = (tile_x2 >= tilemap.width) ? tilemap.width - 1 : tile_x2;
tile_y2 = (tile_y2 >= tilemap.height) ? tilemap.width - 1 : tile_y2;

View File

@ -81,15 +81,15 @@ Entity_t* create_player(EntityManager_t* ent_manager)
p_hitbox->n_boxes = 2;
p_hitbox->boxes[0] = (Rectangle) {
.x = 0,
.y = -1,
.width = p_bbox->size.x - 1,
.height = p_bbox->size.y + 2,
.y = -2,
.width = p_bbox->size.x,
.height = p_bbox->size.y + 4,
};
p_hitbox->boxes[1] = (Rectangle) {
.x = -1,
.x = -2,
.y = 0,
.width = p_bbox->size.x + 2,
.height = p_bbox->size.y - 1,
.width = p_bbox->size.x + 4,
.height = p_bbox->size.y,
};
p_hitbox->atk = 2;
CHurtbox_t* p_hurtbox = add_component(p_ent, CHURTBOX_T);