From 5954ab076dfef18eea68d366460c1bfa56023f30 Mon Sep 17 00:00:00 2001 From: StratiX0 <jerome.hussenet@sfr.fr> Date: Wed, 3 Apr 2024 12:29:22 +0200 Subject: [PATCH] ajout "delta time" mouvement camera --- enginecustom/Positionclass.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/enginecustom/Positionclass.cpp b/enginecustom/Positionclass.cpp index ba465f4..1e66b88 100644 --- a/enginecustom/Positionclass.cpp +++ b/enginecustom/Positionclass.cpp @@ -110,8 +110,9 @@ void PositionClass::TurnRight(bool keydown) void PositionClass::TurnMouse(float deltaX, float deltaY) { + float speed = 0.1f; // The turning speed is proportional to the horizontal mouse movement - m_horizontalTurnSpeed = deltaX * 0.1f; + m_horizontalTurnSpeed = deltaX * speed; // Update the rotation using the turning speed m_rotationY += m_horizontalTurnSpeed; @@ -125,7 +126,7 @@ void PositionClass::TurnMouse(float deltaX, float deltaY) } // The turning speed is proportional to the vertical mouse movement - m_verticalTurnSpeed = deltaY * 0.1f; + m_verticalTurnSpeed = deltaY * speed; // Update the rotation using the turning speed m_rotationX += m_verticalTurnSpeed; @@ -147,7 +148,7 @@ void PositionClass::MoveCamera(bool forward, bool backward, bool left, bool righ float speed; // Set the speed of the camera. - speed = 0.1f; + speed = 2.0f * m_frameTime; // Convert degrees to radians. radiansY = m_rotationY * 0.0174532925f;