#game-engine #clock #time #game

game_clock

Provides a clock for game (engines) that is simple to use and efficient

3 stable releases

1.1.1 Apr 11, 2021
1.1.0 Nov 17, 2020
1.0.0 Nov 17, 2020

#1679 in Game dev

Download history 8/week @ 2025-06-14 20/week @ 2025-06-21 9/week @ 2025-06-28 14/week @ 2025-07-05 24/week @ 2025-07-12 23/week @ 2025-07-19 11/week @ 2025-07-26 2/week @ 2025-08-02 4/week @ 2025-08-09 22/week @ 2025-08-16 28/week @ 2025-08-23 93/week @ 2025-08-30 57/week @ 2025-09-06 57/week @ 2025-09-13 21/week @ 2025-09-20 20/week @ 2025-09-27

170 downloads per month
Used in 3 crates

Apache-2.0

10KB
137 lines

Game Clock

Game Clock

Support an Open Source Developer! ♥️
Become a patron

Read the documentation.

Features

  • Adds a simple clock for use in games and game engines.

Usage

Add the following to you Cargo.toml file:

game_clock = "*"

Use the clock like so:

use game_clock::Time;
use std::time::Duration;
fn main() {
    let mut time = Time::default();
    time.set_fixed_time(Duration::from_secs_f64(1.0 / 20.0));

    let step = 1.0 / 60.0;
    for _ in 0..60 {
        time.advance_frame(Duration::from_secs_f64(step));
        { } // ...Run game logic, rendering, etc...
        while time.step_fixed_update() { // runs 20 times in a frame.
            { } // Run fixed frame logic (ie. physics)
        }
    }
}

Maintainer Information

  • Maintainer: Jojolepro
  • Contact: jojolepro [at] jojolepro [dot] com
  • Website: jojolepro.com
  • Patreon: patreon

No runtime deps