From 54bf0358d6e081def6eb608bb3285760e646058f Mon Sep 17 00:00:00 2001 From: Quaternions Date: Fri, 8 Sep 2023 12:27:45 -0700 Subject: [PATCH] can't stand the idea of 10 nanoseconds less than 66 ticks per second --- src/body.rs | 9 +++++---- src/main.rs | 3 ++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/body.rs b/src/body.rs index 2e5f1fe3..47e26c39 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 657e9578..dc846669 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,