diff --git a/src/body.rs b/src/body.rs index 2e5f1fe..47e26c3 100644 --- a/src/body.rs +++ b/src/body.rs @@ -10,7 +10,8 @@ pub struct PhysicsState { pub body: Body, //pub contacts: Vec, pub time: TIME, - pub strafe_tick_period: TIME, + pub strafe_tick_num: TIME, + pub strafe_tick_den: TIME, pub tick: u32, pub mv: f32, pub walkspeed: f32, @@ -26,7 +27,7 @@ const CONTROL_JUMP:u32 = 0b01000000;//temp impl PhysicsState { //delete this, we are tickless gamers pub fn run(&mut self, time: TIME, control_dir: glam::Vec3, controls: u32){ - let target_tick = (time/self.strafe_tick_period) as u32;//100t + let target_tick = (time*self.strafe_tick_num/self.strafe_tick_den) as u32; //the game code can run for 1 month before running out of ticks while self.tick Option { return Some(EventStruct{ - time:(self.time/self.strafe_tick_period+1)*self.strafe_tick_period, + time:(self.time*self.strafe_tick_num/self.strafe_tick_den+1)*self.strafe_tick_den/self.strafe_tick_num, event:crate::event::EventEnum::StrafeTick }); } diff --git a/src/main.rs b/src/main.rs index 657e957..dc84666 100644 --- a/src/main.rs +++ b/src/main.rs @@ -299,7 +299,8 @@ impl strafe_client::framework::Example for Skybox { }, time: 0, tick: 0, - strafe_tick_period: 1_000_000_000/100,//100t + strafe_tick_num: 100,//100t + strafe_tick_den: 1_000_000_000, gravity: glam::Vec3::new(0.0,-100.0,0.0), friction: 90.0, mv: 2.7,