wip: add strafe_tick_rate

This commit is contained in:
Quaternions 2023-09-07 20:07:05 -07:00
parent f41be177dc
commit a8b829c9e5
2 changed files with 9 additions and 0 deletions

View File

@ -7,6 +7,7 @@ pub struct Body {
pub struct PhysicsState {
pub body: Body,
pub time: TIME,
pub strafe_tick_rate: TIME,
pub tick: u32,
pub gravity: glam::Vec3,
pub friction: f32,
@ -61,6 +62,13 @@ impl PhysicsState {
let dt=(time-self.body.time) as f64/1_000_000_000f64;
self.body.position+self.body.velocity*(dt as f32)+self.gravity*((0.5*dt*dt) as f32)
}
fn next_strafe_event(&self) -> Option<crate::event::EventStruct> {
return Some(crate::event::EventStruct{
time:self.time/self.strafe_tick_rate*self.strafe_tick_rate,//this is floor(n) I need ceil(n)+1
event:crate::event::EventEnum::StrafeTick
});
}
}
impl crate::event::EventTrait for PhysicsState {

View File

@ -299,6 +299,7 @@ impl strafe_client::framework::Example for Skybox {
},
time: 0,
tick: 0,
tick_rate: 100,
gravity: glam::Vec3::new(0.0,-100.0,0.0),
friction: 90.0,
mv: 2.7,