feat: ajout de la trainee (drag)

j'espere que c'est bien comme ça que ça marche
This commit is contained in:
StratiX0
2024-04-09 12:30:37 +02:00
parent b37f253c5c
commit ebccd2cf68
8 changed files with 67 additions and 15 deletions

View File

@@ -35,8 +35,29 @@ void Physics::ApplyGravity(Object* object, float frameTime)
return;
}
// Update the object position
XMVECTOR position = object->GetPosition();
position = XMVectorSetY(position, XMVectorGetY(position) + m_gravity * frameTime); // Update the Y position
object->SetPosition(position);
// Get the object velocity
XMVECTOR velocity = object->GetVelocity();
// Update the Y component of the velocity
velocity = XMVectorSetY(velocity, XMVectorGetY(velocity) + m_gravity * frameTime);
// Set the new velocity
object->SetVelocity(velocity);
}
void Physics::ApplyDrag(Object* object, float dragValue, float frameTime)
{
if (object == nullptr) // Verify if the object is not null
{
return;
}
// Get the velocity of the object
XMVECTOR velocity = object->GetVelocity();
// Calculate the new velocity
XMVECTOR newVelocity = velocity - (velocity * dragValue * frameTime);
// Update the velocity of the object
object->SetVelocity(newVelocity);
}