Members - Reputation: 1136
Posted 07 October 2012 - 10:01 AM
My question is where do you actually add elapsed time to? Is it every single object that you move? (which sounds like something you will eventually miss) or is it only on the main loop?
[Engine] -> Game(delta) -> Player(delta) -> moveRight(delta) - > x += speed*delta;
[Engine] -> Game(delta) -> Enemy(delta) -> jump(delta) - > y -= jumpValue*delta;
[Engine] -> Game(delta) -> BackgroundManager(delta) -> moveBackgrounds(delta) - > for each(bg in bgList) bg.x -= speed*delta;
Am I thinking correctly or..?
Any interesting tutorials someone can link me to?
Start by doing what is necessary; then do what is possible; and suddenly you are doing the impossible.
Members - Reputation: 295
Posted 07 October 2012 - 03:16 PM
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 !!
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.
I hope this was helpful.
Edited by EngineProgrammer, 07 October 2012 - 03:19 PM.
Crossbones+ - Reputation: 2061
Posted 07 October 2012 - 03:32 PM
I'm a game programmer and computer science ninja !
Here's my 2D RPG-Ish Platformer Programmed in Python + Pygame, with a Custom Level Editor and Rendering System!
Here's my Custom IDE / Debugger Programmed in Pure Python and Designed from the Ground Up for Programming Education!
or Personal-Message me on here !
Members - Reputation: 344
Posted 07 October 2012 - 06:13 PM
Members - Reputation: 119
Posted 10 October 2012 - 02:21 PM
I do all these things in floatational numbers. So time becomes normalized to a second.