Test de view bobbing

This commit is contained in:
Marc-Eric Martel 2021-10-08 08:14:23 -04:00
parent 85ae544dee
commit 7898d440df

View File

@ -23,6 +23,9 @@ void Player::Move(bool front, bool back, bool left, bool right, bool jump, bool
static bool jumped = true;
static int dbljump = 0; // Peut sauter ou dasher tant que la variable est en dessous de 2.
static int dashtimeout = 0;
static float gametime = 0;
if (gametime <= 180) gametime += elapsedTime*10; else gametime = 0;
if (dashtimeout > 0) {
dash = false;
@ -80,6 +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;
}
else if (back) {
if (dbljump == 0)
@ -87,12 +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;
}
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;
if (accWS < 1 && accWS > -1) accWS = 0;
}
@ -102,6 +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;
}
else if (right) {
if (dbljump == 0)
@ -109,11 +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;
}
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;
if (accAD < 1 && accAD > -1) accAD = 0;
}
@ -122,6 +131,8 @@ void Player::Move(bool front, bool back, bool left, bool right, bool jump, bool
accWS *= 0.9f;
accAD *= 0.9f;
}
}
void Player::ApplyTransformation(Transformation& transformation, bool rel) const {