This commit is contained in:
MarcEricMartel
2023-12-18 11:10:10 -05:00
parent 2c346139d5
commit 9a669acd9c
5 changed files with 140 additions and 45 deletions

View File

@@ -124,7 +124,6 @@ Player::Sound Player::ApplyPhysics(Vector3f input, World* world, float elapsedTi
bt2 = world->BlockAt(GetPosition().x + input.x, GetPosition().y - 0.9f, GetPosition().z);
bt3 = world->BlockAt(GetPosition().x + input.x, GetPosition().y - 1.7f, GetPosition().z);
if (bt1 != BTYPE_AIR || bt2 != BTYPE_AIR || bt3 != BTYPE_AIR) {
//input.x = m_velocity.x = 0;
m_velocity.y += .04f;
m_velocity.z *= .5f;
m_velocity.x *= .5f;
@@ -134,50 +133,17 @@ Player::Sound Player::ApplyPhysics(Vector3f input, World* world, float elapsedTi
bt2 = world->BlockAt(GetPosition().x, GetPosition().y - 0.9f, GetPosition().z + input.z);
bt3 = world->BlockAt(GetPosition().x, GetPosition().y - 1.7f, GetPosition().z + input.z);
if (bt1 != BTYPE_AIR || bt2 != BTYPE_AIR || bt3 != BTYPE_AIR) {
//input.z = m_velocity.z = 0;
m_velocity.y += .04f;
m_velocity.z *= .5f;
m_velocity.x *= .5f;
}
//bt1 = world->BlockAt(GetPosition().x + input.x, GetPosition().y, GetPosition().z);
//bt2 = world->BlockAt(GetPosition().x + input.x, GetPosition().y - 0.9f, GetPosition().z);
//bt3 = world->BlockAt(GetPosition().x + input.x, GetPosition().y - 1.7f, GetPosition().z);
//if (bt1 == BTYPE_AIR && bt2 != BTYPE_AIR && bt3 != BTYPE_AIR) {
// if (input.x > 0)
// input.x = m_velocity.x = 0.5f;
// else
// input.x = m_velocity.x = -0.5f;
// m_velocity.y = 0.3;
// m_velocity.z *= .5f;
//}
//else if (bt1 != BTYPE_AIR || bt2 != BTYPE_AIR || bt3 != BTYPE_AIR) {
// input.x = m_velocity.x = 0;
// m_velocity.z *= .5f;
//}
//bt1 = world->BlockAt(GetPosition().x, GetPosition().y, GetPosition().z + input.z);
//bt2 = world->BlockAt(GetPosition().x, GetPosition().y - 0.9f, GetPosition().z + input.z);
//bt3 = world->BlockAt(GetPosition().x, GetPosition().y - 1.7f, GetPosition().z + input.z);
//if (bt1 == BTYPE_AIR && bt2 != BTYPE_AIR && bt3 != BTYPE_AIR) {
// if (input.z > 0)
// input.z = m_velocity.z = 0.5f;
// else
// input.z = m_velocity.z = -0.5f;
// m_velocity.y = 0.3;
// m_velocity.x *= .5f;
//}
//else if (bt1 != BTYPE_AIR || bt2 != BTYPE_AIR || bt3 != BTYPE_AIR) {
// input.z = m_velocity.z = 0;
// m_velocity.x *= .5f;
//}
/* Fin gestion de collisions */
/* Gestion de la friction */
if (!m_airborne) {
m_velocity.x += input.x * 2.f * elapsedTime;
m_velocity.z += input.z * 2.f * elapsedTime;
m_velocity.x += input.x * (boostspeed ? 2.5f : 2.f) * elapsedTime;
m_velocity.z += input.z * (boostspeed ? 2.5f : 2.f) * elapsedTime;
if (input.x == 0.f)
m_velocity.x *= .8f;
@@ -195,7 +161,7 @@ Player::Sound Player::ApplyPhysics(Vector3f input, World* world, float elapsedTi
/* Fin gestion de la friction */
float vy = m_velocity.y;
m_velocity.y = 1.f; // Padding pour limiter le x et z lors du Normalize().
m_velocity.y = boostspeed ? 0.f: 1.f; // Padding pour limiter le x et z lors du Normalize().
if (m_velocity.Length() >= 1.f) m_velocity.Normalize(); // Limiteur de vitesse en x/z.
m_velocity.y = 0;
if (m_velocity.Length() < .005f) m_velocity.Zero(); // Threshold en x/z.