PlayerContoroller and LevelScreen refactoring (#806)

This commit is contained in:
ChancellorIkseew 2026-03-02 08:18:47 +10:00 • committed by GitHub
parent 6bdbf5b40e
commit cb2b901985
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 22 additions and 22 deletions

View file

@ -253,18 +253,18 @@ void PlayerController::onFootstep(const Hitbox& hitbox) {
}
void PlayerController::updateFootsteps(float delta) {
const float pi = glm::pi<float>();
constexpr float GLM_PI = glm::pi<float>();
auto hitbox = player.getHitbox();
if (hitbox && hitbox->grounded) {
const glm::vec3& vel = hitbox->velocity;
float f = glm::length(glm::vec2(vel.x, vel.z));
stepsTimer += delta * f * STEPS_SPEED;
if (stepsTimer >= pi) {
stepsTimer = fmod(stepsTimer, pi);
if (stepsTimer >= GLM_PI) {
stepsTimer = fmod(stepsTimer, GLM_PI);
onFootstep(*hitbox);
}
} else {
stepsTimer = pi;
stepsTimer = GLM_PI;
}
}
@ -554,6 +554,6 @@ void PlayerController::updateInteraction(const Input& inputEvents, float delta)
}
}
Player* PlayerController::getPlayer() {
return &player;
Player& PlayerController::getPlayer() {
return player;
}