View bobbing pas pire pentoute!

This commit is contained in:
Marc-Eric Martel 2021-10-08 08:46:39 -04:00
parent b91b66878d
commit 79c299a3b6

View File

@ -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) / 20.f;
m_position.y += (sin(gametime) - 0.5f) * accWS / (20.f * m_topspeed);
}
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) / 20.f;
m_position.y += (sin(gametime) - 0.5f) * accWS / (20.f * m_topspeed);
}
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) / 30.f;
m_position.y += (sin(gametime) - 0.5f) * accWS / (30.f * m_topspeed);
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) / 20.f;
if (accWS == 0.f) m_position.y += (sin(gametime) - 0.5f) * accAD / (20.f * m_topspeed);
}
else if (right) {
if (dbljump == 0)
@ -116,23 +116,21 @@ 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) / 20.f;
if (accWS == 0.f) m_position.y += (sin(gametime) - 0.5f) * accAD / (20.f * m_topspeed);
}
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) / 30.f;
if (accWS == 0.f) m_position.y += (sin(gametime) - 0.5f) * accAD / (20.f * m_topspeed);
if (accAD < 1 && accAD > -1) accAD = 0;
}
// Gestion de si le personnage va en diagonale, qu'il n'aille pas plus vite que s'il allait en ligne droite.
if ((accWS >= 0 ? accWS : -accWS + accAD >= 0 ? accAD : -accAD) > sqrtf(m_topspeed * m_topspeed + m_topspeed * m_topspeed)) {
accWS *= 0.9f;
accAD *= 0.9f;
if ((accWS >= 0.f ? accWS : -accWS + accAD >= 0.f ? accAD : -accAD) > sqrtf(m_topspeed * m_topspeed + m_topspeed * m_topspeed)) {
accWS *= 0.8f;
accAD *= 0.8f;
}
}
void Player::ApplyTransformation(Transformation& transformation, bool rel) const {