specs_time 0.5.0

time resource for specs
Documentation

specs_time

time resource for specs

extern crate specs;
extern crate specs_time;
extern crate specs_bundler;

use std::{thread, time};

use specs_time::{Time, TimeBundle};
use specs_bundler::Bundler;
use specs::{Builder, World, DispatcherBuilder};


fn main() {
    let mut world = World::new();

    let mut dispatcher = Bundler::new(&mut world, DispatcherBuilder::new())
        .bundle(TimeBundle::<f32>::default()).unwrap()
        .build();

    for _ in 0..60 {
        dispatcher.dispatch(&mut world.res);
        thread::sleep(time::Duration::from_millis(16));
    }

    let time = &*world.read_resource::<Time<f32>>();
    assert_eq!(time.frame(), 60);
    println!("{:?}", time);
}