Améliorations du bobbing.

This commit is contained in:
Marc-Eric Martel 2021-10-08 08:38:54 -04:00
parent 7898d440df
commit b91b66878d

View File

@ -25,7 +25,7 @@ void Player::Move(bool front, bool back, bool left, bool right, bool jump, bool
static int dashtimeout = 0;
static float gametime = 0;
if (gametime <= 180) gametime += elapsedTime*10; else gametime = 0;
if (gametime <= 180.f) gametime += elapsedTime*m_topspeed/2; else gametime = 0;
if (dashtimeout > 0) {
dash = false;
@ -83,7 +83,7 @@ void Player::Move(bool front, bool back, bool left, bool right, bool jump, bool
if (dash) accWS *= accWS > 0.f ? 3.f : -1.f;
m_position.x += float(sin(yrotrad)) * elapsedTime * accWS;
m_position.z += float(-cos(yrotrad)) * elapsedTime * accWS;
m_position.y += (sin(gametime) - 0.5f) / 10.f;
m_position.y += (sin(gametime) - 0.5f) / 20.f;
}
else if (back) {
if (dbljump == 0)
@ -91,14 +91,14 @@ void Player::Move(bool front, bool back, bool left, bool right, bool jump, bool
if (dash) accWS *= accWS < 0.f? 3.f: -1.f;
m_position.x += float(-sin(yrotrad)) * elapsedTime * -accWS;
m_position.z += float(cos(yrotrad)) * elapsedTime * -accWS;
m_position.y += (sin(gametime) - 0.5f) / 10.f;
m_position.y += (sin(gametime) - 0.5f) / 20.f;
}
else if (accWS != 0) {
accWS = accWS > 0 ? accWS - elapsedTime * (m_position.y > 0.f ? 10 : 120) : accWS + elapsedTime * (m_position.y > 0.f ? 10 : 120);
m_position.x += float(sin(yrotrad)) * elapsedTime * accWS;
m_position.z += float(-cos(yrotrad)) * elapsedTime * accWS;
m_position.y += (sin(gametime) - 0.5f) / 10.f;
m_position.y += (sin(gametime) - 0.5f) / 30.f;
if (accWS < 1 && accWS > -1) accWS = 0;
}
@ -108,7 +108,7 @@ void Player::Move(bool front, bool back, bool left, bool right, bool jump, bool
if (dash) accAD *= accAD > 0.f? 3.f: -1.f;
m_position.x += float(-cos(yrotrad)) * elapsedTime * accAD;
m_position.z += float(-sin(yrotrad)) * elapsedTime * accAD;
m_position.y += (sin(gametime) - 0.5f) / 10.f;
m_position.y += (sin(gametime) - 0.5f) / 20.f;
}
else if (right) {
if (dbljump == 0)
@ -116,13 +116,13 @@ void Player::Move(bool front, bool back, bool left, bool right, bool jump, bool
if (dash) accAD *= accAD < 0.f ? 3.f : -1.f;
m_position.x += float(cos(yrotrad)) * elapsedTime * -accAD;
m_position.z += float(sin(yrotrad)) * elapsedTime * -accAD;
m_position.y += (sin(gametime) - 0.5f) / 10.f;
m_position.y += (sin(gametime) - 0.5f) / 20.f;
}
else if (accAD != 0) {
accAD = accAD > 0 ? accAD - elapsedTime * (m_position.y > 0.f ? 10 : 120) : accAD + elapsedTime * (m_position.y > 0.f ? 10 : 120);
m_position.x += float(-cos(yrotrad)) * elapsedTime * accAD;
m_position.z += float(-sin(yrotrad)) * elapsedTime * accAD;
m_position.y += (sin(gametime) - 0.5f) / 10.f;
m_position.y += (sin(gametime) - 0.5f) / 30.f;
if (accAD < 1 && accAD > -1) accAD = 0;
}