specs_time 0.3.6

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::SpecsBundler;
use specs::{World, DispatcherBuilder};


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

    let mut dispatcher = SpecsBundler::new(&mut world, DispatcherBuilder::new())
        .bundle(TimeBundle::<f32>::new()).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);
}