delta_time 1.0.5

A simple library for keeping track of the delta time in games


To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:

delta_time

A simple library for keeping track of the delta time in games.

This library will give you the delta time in a double floating point number.

Here is a small example on how to use it:

 import std.stdio;

import delta_time;

void main()
{
	bool running = true;

    int count = 0;

    // You can set the max delta two ways:

    // By a number literal:
    setMaxDelta(0.01);
    setMaxDelta(1.0/5.0);

    // Or by a FPS precision goal:
    setMaxDeltaFPS(5.0)
    
    // By default, it's 5 FPS, if the game were to drop
    // any lower than this, it will slow down the logic



    // This is the game loop
    while (running) {

        // The delta must be calculated first
        calculateDelta();

        // Do some random work as an example
        int w = 0;
        for (int i = 1; i < 2_000_000; i++) {
            w = w * i;
        }
        count++;
        if (count > 10_000) {
            running = false;
        }

        // Now we can just grab the delta anywhere in the project
        double delta = getDelta();

        writeln("The delta is: ", delta);
    }
}
Authors:
  • jordan4ibanez
Dependencies:
none
Versions:
1.0.5 2022-Aug-21
1.0.4 2022-Aug-21
1.0.3 2022-Aug-16
1.0.2 2022-Aug-05
1.0.1 2022-Aug-05
Show all 7 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 0 downloads this month

  • 64 downloads total

Score:
0.5
Short URL:
delta_time.dub.pm