Fix crawlspace death glitch

main
En Yi 2024-12-08 15:38:51 +08:00
parent a123e59c82
commit 518c2def93
1 changed files with 10 additions and 5 deletions

View File

@ -552,11 +552,16 @@ void player_bbox_update_system(Scene_t* scene)
} }
} }
Vector2 point_to_check = Vector2Add(p_player->position, offset);
// As long as the change in hitbox is less than a tile size, if (
// it should be fine check_collision_at(
set_bbox(p_bbox, new_bbox.x, new_bbox.y); p_player, point_to_check, new_bbox, &tilemap
p_player->position = Vector2Add(p_player->position, offset); ) != 1
)
{
set_bbox(p_bbox, new_bbox.x, new_bbox.y);
p_player->position = Vector2Add(p_player->position, offset);
}
CHitBoxes_t* p_hitbox = get_component(p_player, CHITBOXES_T); CHitBoxes_t* p_hitbox = get_component(p_player, CHITBOXES_T);
p_hitbox->boxes[0].height = p_bbox->size.y + 4; p_hitbox->boxes[0].height = p_bbox->size.y + 4;