mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
PlayerContoroller and LevelScreen refactoring (#806)
This commit is contained in:
parent
6bdbf5b40e
commit
cb2b901985
3 changed files with 22 additions and 22 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue