Delta timing
   HOME

TheInfoList



OR:

Delta time or delta timing is a concept used amongst programmers in relation to hardware and network responsiveness. In graphics programming, the term is usually used for variably updating scenery based on the elapsed time since the game last updated, (i.e. the previous "
frame A frame is often a structural system that supports other components of a physical construction and/or steel frame that limits the construction's extent. Frame and FRAME may also refer to: Physical objects In building construction *Framing (con ...
") which will vary depending on the speed of the computer, and how much work needs to be done in the program at any given time. This also allows graphics to be calculated separately if graphics are being multi-threaded. In network programming, due to the unpredictable nature of
internet connection Internet access is the ability of individuals and organizations to connect to the Internet using computer terminals, computers, and other devices; and to access services such as email and the World Wide Web. Internet access is sold by Internet ...
s, delta timing is used in a similar way to variably update the movement information received via the
computer network A computer network is a set of computers sharing resources located on or provided by network nodes. The computers use common communication protocols over digital interconnections to communicate with each other. These interconnections are ...
, regardless of how long it took to receive the next
data packet In telecommunications and computer networking, a network packet is a formatted unit of data carried by a packet-switched network. A packet consists of control information and user data; the latter is also known as the '' payload''. Control inform ...
of movement information. It is done by calling a timer every frame per second that holds the time between now and last call in
milliseconds A millisecond (from ''milli-'' and second; symbol: ms) is a unit of time in the International System of Units (SI) equal to one thousandth (0.001 or 10−3 or 1/1000) of a second and to 1000 microseconds. A unit of 10 milliseconds may be called ...
. Thereafter the resulting number (delta time) is used to calculate how far, for instance, a
video game Video games, also known as computer games, are electronic games that involves interaction with a user interface or input device such as a joystick, controller, keyboard, or motion sensing device to generate visual feedback. This fee ...
character would have travelled during that time. This results in the character taking the same amount of real world time to move across the screen regardless of the rate of update, and whether the delay is caused by lack of processing power or a slow internet connection. In graphics programming, this avoids the gameplay slowing down or speeding up depending on the complexity of what is happening at any given time, which would make for an inconsistent, jarring experience (e.g. time slowing down the more characters walk onto the screen, or running too fast because only one character is on screen). In network programming, this keeps the game world of each computer in sync with the others, by making sure each client eventually sees the same activity at the same time, even if more time has passed since the last update for some clients than others. Big enough delays will eventually negatively affect the
gameplay Gameplay is the specific way in which players interact with a game, and in particular with video games. Gameplay is the pattern defined through the game rules, connection between player and the game, challenges and overcoming them, plot and pl ...
experience, but using Delta Time keeps the gameplay consistent so long as the computer and internet connection meet the minimum hardware requirements of the game. Delta timing is also used in motorsport. The use of delta timing in motorsport allows drivers to see how much time they've gained or lost.


Delta-timing measurement in program

Measuring time needed for check if a number is prime.


Python3

# time() is a function that will return second since epoch in float format (included millisecond) from time import time # define is_prime(x) def is_prime(x): for i in range(2,x): if (x%i)

0: print(x, 'is not prime') return print(x, 'is prime') # main program t0 = time() # start of measurement is_prime(13) # call function t1 = time() # end of measurement deltaTime = t1 - t0 print('is_prime(13) takes time:', deltaTime, 'second to execute!')


Delta-time and frame rate

Delta-time and frame rate are not always related. Video games fall into one of two categories regarding frame rate: frame rate dependent or frame rate independent. Frame rate Dependent games have a frame rate that varies based on the computer running the software. For example, if a frame rate dependent game runs at 300 frames per second (fps) on a computer with a refresh rate of 120 hertz (Hz), then it would run at 150 fps on a computer with a refresh rate of 60 Hz. A standard delta-time expression can create pause screens and intentional slow-motion effects in frame rate-dependent games. Standard delta-time formulas are seldom used for standard game-play because the delta-time between frames varies greatly depending on the refresh rate of the computer on which it is running. If a game is frame rate independent, the frame rate is preset and runs identically across all computers regardless of their specifications. Frame rate independence limits the maximum graphics quality to make the game available to more consumers. Frame rate independence is particularly popular in mobile games and games optimized for lower-end computers such as Chromebooks. In frame rate independent games, the delta-time between frames is consistent across the entire game. This standardization means that one delta-time expression can create a consistent frame rate for all users on all types of computers.


When to use delta-time

Delta-timing can excel anytime a game’s frame rate needs to be independent of its hardware. One example of this could be games that need to run on mobile devices or low-end computers. In some cases, video game developers use delta-timing to standardize the movement speed of an object on the screen. For example, if a character moves across the screen at a constant rate, delta-timing can ensure that this movement speed is consistent and does not fluctuate. Using delta-timing for movement is particularly useful for users who possess inconsistent internet or low-end computer hardware. This method can also regulate the movement of on-screen objects. One disadvantage of using delta-timing for movement is that it can be complicated for games that incorporate a wide variety of movements and movement speeds. For example, a game could have a specified walking speed and sprinting speed for all characters; however, characters may also drive cars, boats, planes, and other vehicles. If the developer wants each of these movement speeds to be different (to make the game as realistic as possible), they would need a separate delta-time expression for each movement speed (that is only assuming these movements occur at a constant rate). If the movements do not occur at a constant rate, delta-timing expressions are rendered ineffective.


See also

*
Latency (engineering) Latency, from a general point of view, is a time delay between the cause and the effect of some physical change in the system being observed. Lag, as it is known in gaming circles, refers to the latency between the input to a simulation and ...


References

Graphics Video game development {{videogame-software-stub