Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void PositionClass::MoveLeft(bool keydown)
- {
- float radians;
- // Update the left speed movement based on the frame time and whether the user is holding the key down or not.
- if (keydown)
- {
- m_leftSpeed += m_frameTime * 0.001f;
- if (m_leftSpeed > (m_frameTime * 0.03f))
- {
- m_leftSpeed = m_frameTime * 0.03f;
- }
- }
- else
- {
- m_leftSpeed -= m_frameTime * 0.0007f;
- if (m_leftSpeed < 0.0f)
- {
- m_leftSpeed = 0.0f;
- }
- }
- // Convert degrees to radians.
- radians = m_rotationY * 0.0174532925f;
- // Update the position.
- m_positionX -= sinf(radians + 90) * m_leftSpeed;
- m_positionZ -= cosf(radians + 90) * m_leftSpeed;
- return;
- }
- void PositionClass::MoveRight(bool keydown)
- {
- float radians;
- // Update the right speed movement based on the frame time and whether the user is holding the key down or not.
- if (keydown)
- {
- m_rightSpeed += m_frameTime * 0.001f;
- if (m_rightSpeed > (m_frameTime * 0.03f))
- {
- m_rightSpeed = m_frameTime * 0.03f;
- }
- }
- else
- {
- m_rightSpeed -= m_frameTime * 0.0007f;
- if (m_rightSpeed < 0.0f)
- {
- m_rightSpeed = 0.0f;
- }
- }
- // Convert degrees to radians.
- radians = m_rotationY * 0.0174532925f;
- // Update the position.
- m_positionX += sinf(radians + 90) * m_rightSpeed;
- m_positionZ += cosf(radians + 90) * m_rightSpeed;
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement