feat: debut de la physique, ajout de la gravite

This commit is contained in:
StratiX0
2024-04-08 17:16:48 +02:00
parent c21a66f386
commit 6eb50bf29f
7 changed files with 87 additions and 9 deletions

32
enginecustom/physics.cpp Normal file
View File

@@ -0,0 +1,32 @@
#include "physics.h"
Physics::Physics()
{
m_gravity = -9.81f;
}
Physics::Physics(const Physics& other)
{
m_gravity = other.m_gravity; // Copy gravity value from the other object
}
Physics::~Physics()
{
}
float Physics::GetGravity() // Changed the method to return the gravity value
{
return m_gravity;
}
void Physics::ApplyGravity(Object* object, float frameTime)
{
// Update the position of the object by adding the change in position due to gravity.
XMVECTOR position = object->GetPosition(); // Get the current position
position = XMVectorSetY(position, XMVectorGetY(position) + m_gravity * frameTime); // Update the y value
object->SetPosition(position); // Set the updated position
return;
}