Skip to main content
replaced http://gamedev.stackexchange.com/ with https://gamedev.stackexchange.com/
Source Link

Some points:

  1. You should make all your movements time-dependent, more specifically depending on the timeSinceLastFrame. That way, your game will run equally fast on all computers in the sense that the possible movement distances are aligned (not in the sense that you get the same FPS, because that of course depends on the hardware specs).

    So, your movements would look something like this:

    newPosition = oldPosition * direction * speed * timeSinceLastFrame;

To now slow down the whole application, you can just decrease timeSinceLastFrame by a certain factor, resulting in slower movements of your objects.

    // At startup
    long lastTime = 0;
    long now = 0;
    long timesinceLastFrame = 0;

    // Each game loop run
    now = System.accurateTime(); // get new time
    timeSinceLastFrame = now - lastTime; // calculated time passed since the last frame, e. g. in milliseconds      
    timeSinceLastFrame *= 0.5; // to get the game to half speed
    lastTime = now; // update the value for the next loop run
  1. Backtracing in a game is difficult, because in order to do so, you need to store all user input to be able to un-do that in the correct reverse order. And this also only works if the rest of your application is completely deterministic which it is not when being based on variable (= un-deterministic since dependent on something as uncontrollable as the overall system performance at any given point in time) timestamps.

A good general overview about the discussion: fixed timestamp vs. variable timestamp (variable not in your sense that you can slow down or speed up the game, but in the sense that the time between frames is not constant), can be found in this GameDev.SE threadthis GameDev.SE thread. Another important source is this blog entry by Glen Fielder.

Some points:

  1. You should make all your movements time-dependent, more specifically depending on the timeSinceLastFrame. That way, your game will run equally fast on all computers in the sense that the possible movement distances are aligned (not in the sense that you get the same FPS, because that of course depends on the hardware specs).

    So, your movements would look something like this:

    newPosition = oldPosition * direction * speed * timeSinceLastFrame;

To now slow down the whole application, you can just decrease timeSinceLastFrame by a certain factor, resulting in slower movements of your objects.

    // At startup
    long lastTime = 0;
    long now = 0;
    long timesinceLastFrame = 0;

    // Each game loop run
    now = System.accurateTime(); // get new time
    timeSinceLastFrame = now - lastTime; // calculated time passed since the last frame, e. g. in milliseconds      
    timeSinceLastFrame *= 0.5; // to get the game to half speed
    lastTime = now; // update the value for the next loop run
  1. Backtracing in a game is difficult, because in order to do so, you need to store all user input to be able to un-do that in the correct reverse order. And this also only works if the rest of your application is completely deterministic which it is not when being based on variable (= un-deterministic since dependent on something as uncontrollable as the overall system performance at any given point in time) timestamps.

A good general overview about the discussion: fixed timestamp vs. variable timestamp (variable not in your sense that you can slow down or speed up the game, but in the sense that the time between frames is not constant), can be found in this GameDev.SE thread. Another important source is this blog entry by Glen Fielder.

Some points:

  1. You should make all your movements time-dependent, more specifically depending on the timeSinceLastFrame. That way, your game will run equally fast on all computers in the sense that the possible movement distances are aligned (not in the sense that you get the same FPS, because that of course depends on the hardware specs).

    So, your movements would look something like this:

    newPosition = oldPosition * direction * speed * timeSinceLastFrame;

To now slow down the whole application, you can just decrease timeSinceLastFrame by a certain factor, resulting in slower movements of your objects.

    // At startup
    long lastTime = 0;
    long now = 0;
    long timesinceLastFrame = 0;

    // Each game loop run
    now = System.accurateTime(); // get new time
    timeSinceLastFrame = now - lastTime; // calculated time passed since the last frame, e. g. in milliseconds      
    timeSinceLastFrame *= 0.5; // to get the game to half speed
    lastTime = now; // update the value for the next loop run
  1. Backtracing in a game is difficult, because in order to do so, you need to store all user input to be able to un-do that in the correct reverse order. And this also only works if the rest of your application is completely deterministic which it is not when being based on variable (= un-deterministic since dependent on something as uncontrollable as the overall system performance at any given point in time) timestamps.

A good general overview about the discussion: fixed timestamp vs. variable timestamp (variable not in your sense that you can slow down or speed up the game, but in the sense that the time between frames is not constant), can be found in this GameDev.SE thread. Another important source is this blog entry by Glen Fielder.

added note about determinism + backtracing
Source Link
Philip Allgaier
  • 2.9k
  • 4
  • 26
  • 36

Some points:

  1. You should make all your movements time-dependent, more specifically depending on the timeSinceLastFrame. That way, your game will run equally fast on all computers in the sense that the possible movement distances are aligned (not in the sense that you get the same FPS, because that of course depends on the hardware specs).

    So, your movements would look something like this:

    newPosition = oldPosition * direction * speed * timeSinceLastFrame;

To now slow down the whole application, you can just decrease timeSinceLastFrame by a certain factor, resulting in slower movements of your objects.

    // At startup
    long lastTime = 0;
    long now = 0;
    long timesinceLastFrame = 0;

    // Each game loop run
    now = System.accurateTime(); // get new time
    timeSinceLastFrame = now - lastTime; // calculated time passed since the last frame, e. g. in milliseconds      
    timeSinceLastFrame *= 0.5; // to get the game to half speed
    lastTime = now; // update the value for the next loop run
  1. Backtracing in a game is difficult, because in order to do so, you need to store all user input to be able to un-do that in the correct reverse order as well as the time deltas for each passed frame. And this also only works if the rest of your application is completely deterministic which it is not when being based on variable (= un-deterministic since dependent on something as uncontrollable as the overall system performance at any given point in time) timestamps.

A good general overview about the discussion: fixed timestamp vs. variable timestamp (variable not in your sense that you can slow down or speed up the game, but in the sense that the time between frames is not constant), can be found in this GemDevGameDev.SE thread. Another important source is this blog entry by Glen Fielder.

Some points:

  1. You should make all your movements time-dependent, more specifically depending on the timeSinceLastFrame. That way, your game will run equally fast on all computers in the sense that the possible movement distances are aligned (not in the sense that you get the same FPS, because that of course depends on the hardware specs).

    So, your movements would look something like this:

    newPosition = oldPosition * direction * speed * timeSinceLastFrame;

To now slow down the whole application, you can just decrease timeSinceLastFrame by a certain factor, resulting in slower movements of your objects.

    // At startup
    long lastTime = 0;
    long now = 0;
    long timesinceLastFrame = 0;

    // Each game loop run
    now = System.accurateTime(); // get new time
    timeSinceLastFrame = now - lastTime; // calculated time passed since the last frame, e. g. in milliseconds      
    timeSinceLastFrame *= 0.5; // to get the game to half speed
    lastTime = now; // update the value for the next loop run
  1. Backtracing in a game is difficult, because in order to do so, you need to store all user input to be able to un-do that in the correct reverse order as well as the time deltas for each passed frame. And this also only works if the rest of your application is completely deterministic.

A good general overview about the discussion: fixed timestamp vs. variable timestamp (variable not in your sense that you can slow down or speed up the game, but in the sense that the time between frames is not constant), can be found in this GemDev.SE thread.

Some points:

  1. You should make all your movements time-dependent, more specifically depending on the timeSinceLastFrame. That way, your game will run equally fast on all computers in the sense that the possible movement distances are aligned (not in the sense that you get the same FPS, because that of course depends on the hardware specs).

    So, your movements would look something like this:

    newPosition = oldPosition * direction * speed * timeSinceLastFrame;

To now slow down the whole application, you can just decrease timeSinceLastFrame by a certain factor, resulting in slower movements of your objects.

    // At startup
    long lastTime = 0;
    long now = 0;
    long timesinceLastFrame = 0;

    // Each game loop run
    now = System.accurateTime(); // get new time
    timeSinceLastFrame = now - lastTime; // calculated time passed since the last frame, e. g. in milliseconds      
    timeSinceLastFrame *= 0.5; // to get the game to half speed
    lastTime = now; // update the value for the next loop run
  1. Backtracing in a game is difficult, because in order to do so, you need to store all user input to be able to un-do that in the correct reverse order. And this also only works if the rest of your application is completely deterministic which it is not when being based on variable (= un-deterministic since dependent on something as uncontrollable as the overall system performance at any given point in time) timestamps.

A good general overview about the discussion: fixed timestamp vs. variable timestamp (variable not in your sense that you can slow down or speed up the game, but in the sense that the time between frames is not constant), can be found in this GameDev.SE thread. Another important source is this blog entry by Glen Fielder.

added 31 characters in body
Source Link
Philip Allgaier
  • 2.9k
  • 4
  • 26
  • 36

Some points:

  1. You should make all your movements time-dependent, more specifically depending on the timeSinceLastFrame. That way, your game will run equally fast on all computers in the sense that the possible movement distances are aligned (not in the sense that you get the same FPS, because that of course depends on the hardware specs).

    So, your movements would look something like this:

    newPosition = oldPosition * direction * speed * timeSinceLastFrame;

To now slow down the whole application, you can just decrease timeSinceLastFrame by a certain factor, resulting in slower movements of your objects.

    // At startup
    long lastTime = 0;
    long now = 0;
    long timesinceLastFrame = 0;

    // Each game loop run
    now = System.accurateTime(); // get new time
    timeSinceLastFrame = now - lastTime; // calculated time passed since the last frame, e. g. in milliseconds      
    timeSinceLastFrame *= 0.5; // to get the game to half speed
    lastTime = now; // update the value for the next loop run
  1. Backtracing in a game is difficult, because in order to do so, you need to store all user input to be able to un-do that in the correct reverse order as well as the time deltas for each passed frame. And this also only works if the rest of your application is completely deterministic.

A good general overview about the discussion: fixed timestamp vs. variable timestamp (variable not in your sense that you can slow down or speed up the game, but in the sense that the time between frames is not constant), can be found in this GemDev.SE thread.

Some points:

  1. You should make all your movements time-dependent, more specifically depending on the timeSinceLastFrame. That way, your game will run equally fast on all computers in the sense that the possible movement distances are aligned (not in the sense that you get the same FPS, because that of course depends on the hardware specs).

    So, your movements would look something like this:

    newPosition = oldPosition * direction * speed * timeSinceLastFrame;

To now slow down the whole application, you can just decrease timeSinceLastFrame by a certain factor, resulting in slower movements of your objects.

    // At startup
    long lastTime = 0;
    long now = 0;
    long timesinceLastFrame = 0;

    // Each game loop run
    now = System.accurateTime(); // get new time
    timeSinceLastFrame = now - lastTime; // calculated time passed since the last frame, e. g. in milliseconds      
    timeSinceLastFrame *= 0.5; // to get the game to half speed
    lastTime = now; // update the value for the next loop run
  1. Backtracing in a game is difficult, because in order to do so, you need to store all user input to be able to un-do that in the correct reverse order. And this also only works if the rest of your application is completely deterministic.

Some points:

  1. You should make all your movements time-dependent, more specifically depending on the timeSinceLastFrame. That way, your game will run equally fast on all computers in the sense that the possible movement distances are aligned (not in the sense that you get the same FPS, because that of course depends on the hardware specs).

    So, your movements would look something like this:

    newPosition = oldPosition * direction * speed * timeSinceLastFrame;

To now slow down the whole application, you can just decrease timeSinceLastFrame by a certain factor, resulting in slower movements of your objects.

    // At startup
    long lastTime = 0;
    long now = 0;
    long timesinceLastFrame = 0;

    // Each game loop run
    now = System.accurateTime(); // get new time
    timeSinceLastFrame = now - lastTime; // calculated time passed since the last frame, e. g. in milliseconds      
    timeSinceLastFrame *= 0.5; // to get the game to half speed
    lastTime = now; // update the value for the next loop run
  1. Backtracing in a game is difficult, because in order to do so, you need to store all user input to be able to un-do that in the correct reverse order as well as the time deltas for each passed frame. And this also only works if the rest of your application is completely deterministic.

A good general overview about the discussion: fixed timestamp vs. variable timestamp (variable not in your sense that you can slow down or speed up the game, but in the sense that the time between frames is not constant), can be found in this GemDev.SE thread.

added 31 characters in body
Source Link
Philip Allgaier
  • 2.9k
  • 4
  • 26
  • 36
Loading
Source Link
Philip Allgaier
  • 2.9k
  • 4
  • 26
  • 36
Loading