• Create Account

### #ActualEngineProgrammer

Posted 07 October 2012 - 03:19 PM

Working with time instead of frames will give you a more synchronized game. it's also a must when you plan to go online.
Why? Assume you have 50 processes running on your computer and your enemy has 25. Your enemies game-cycle will be called twice as fast. So he will have the advantage.

You add the time to any calculation for movement, shooting, camera, etc.
m_Velocity = m_Velocity * deltaTime;
m_Position = m_Velocity; // you don't need to put a delta time here because it's using the velocity who has a delta time calculated in it.

// This is the camera you want to move:
m_Camera.moveLeft( int delta );
// Inside the method of the camera:
m_CameraPosition.x = m_CameraPosition * deltaTime;
// This means you need a method for the camera: void Tick( int deltaTime ) and store the deltaTime !!


Edit:
If you are not sure to put a delta time with a line of code you need to think on an online game.
Will the code without deltaTime have a possibility to lose synchronization? If yes, add the deltaTime.

~EngineProgrammer

### #2EngineProgrammer

Posted 07 October 2012 - 03:19 PM

Working with time instead of frames will give you a more synchronized game. it's also a must when you plan to go online.
Why? Assume you have 50 processes running on your computer and your enemy has 25. Your enemies game-cycle will be called twice as fast. So he will have the advantage.

You add the time to any calculation for movement, shooting, camera, etc.
m_Velocity = m_Velocity * deltaTime;
m_Position = m_Velocity; // you don't need to put a delta time here because it's using the velocity who has a delta time calculated in it.

// This is the camera you want to move:
m_Camera.moveLeft( int delta );
// Inside the method of the camera:
m_CameraPosition.x = m_CameraPosition * deltaTime;
// This means you need a method for the camera: void Tick( int deltaTime ) and store the deltaTime !!


Edit:
If you are not sure to put a delta time with a line of code you need to think on an online game.
Will the code without deltaTime have a possibility to lose synchronization? If yes, add the deltaTime.

~EngineProgrammer

### #1EngineProgrammer

Posted 07 October 2012 - 03:16 PM

Working with time instead of frames will give you a more synchronized game. it's also a must when you plan to go online.
Why? Assume you have 50 processes running on your computer and your enemy has 25. Your enemies game-cycle will be called twice as fast. So he will have the advantage.

You add the time to any calculation for movement, shooting, camera, etc.
m_Velocity = m_Velocity * deltaTime;
m_Position = m_Velocity; // you don't need to put a delta time here because it's using the velocity who has a delta time calculated in it.

// This is the camera you want to move:
m_Camera.moveLeft( int delta );
// Inside the method of the camera:
m_CameraPosition.x = m_CameraPosition * deltaTime;
// This means you need a method for the camera: void Tick( int deltaTime ) and store the deltaTime !!