No description
Find a file
2021-04-11 16:34:29 -04:00
examples rustfmt 2020-11-17 11:53:53 -05:00
src add more crate documentation, rustfmt. 2021-04-11 13:22:04 -04:00
.gitignore init 2020-09-10 16:22:10 -04:00
Cargo.toml switch license. 2021-04-11 16:34:29 -04:00
LICENSE switch to apache 2.0 license. 2021-04-11 13:16:55 -04:00
README.md change version of game_clock in readme. 2021-04-11 13:23:41 -04:00

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