fixed timing issue

This commit is contained in:
Skye Terran 2021-08-09 21:27:05 -07:00
parent ab1657a758
commit c90ed3fb00

View File

@ -25,7 +25,7 @@ fn main() {
// create a test physics object // create a test physics object
let mut test_object = PhysicsObject { let mut test_object = PhysicsObject {
location: [0.0, 0.0, 100.0], location: [0.0, 0.0, 100.0],
velocity: [0.0, 0.0, 0.0], velocity: [0.0, 5.0, 0.0],
gravity_enabled: true gravity_enabled: true
}; };
@ -37,20 +37,19 @@ fn main() {
if delta_time.as_millis() as u32 >= UPDATE_INTERVAL { if delta_time.as_millis() as u32 >= UPDATE_INTERVAL {
update(delta_time, &mut test_object); update(delta_time, &mut test_object);
// DEBUG
println!("Time: {}ms | test_object | Location: {:?} | Velocity: {:?}", time.as_millis(), test_object.location, test_object.velocity);
// keep track of time
time += delta_time;
// reset the delta time // reset the delta time
delta_time = Duration::new(0,0); delta_time = Duration::new(0,0);
} }
// update the time // DEBUG
delta_time += Instant::now().duration_since(start_time); println!("Time: {}s | test_object | Location: {:?} | Velocity: {:?}", time.as_millis() as f32 / 1000.0, test_object.location, test_object.velocity);
display(delta_time, &test_object); display(delta_time, &test_object);
// update the time
let end_time = Instant::now().duration_since(start_time);
delta_time += end_time;
time += end_time;
} }
} }