wip: add strafe_tick_rate
This commit is contained in:
parent
f41be177dc
commit
a8b829c9e5
@ -7,6 +7,7 @@ pub struct Body {
|
|||||||
pub struct PhysicsState {
|
pub struct PhysicsState {
|
||||||
pub body: Body,
|
pub body: Body,
|
||||||
pub time: TIME,
|
pub time: TIME,
|
||||||
|
pub strafe_tick_rate: TIME,
|
||||||
pub tick: u32,
|
pub tick: u32,
|
||||||
pub gravity: glam::Vec3,
|
pub gravity: glam::Vec3,
|
||||||
pub friction: f32,
|
pub friction: f32,
|
||||||
@ -61,6 +62,13 @@ impl PhysicsState {
|
|||||||
let dt=(time-self.body.time) as f64/1_000_000_000f64;
|
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)
|
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 {
|
impl crate::event::EventTrait for PhysicsState {
|
||||||
|
@ -299,6 +299,7 @@ impl strafe_client::framework::Example for Skybox {
|
|||||||
},
|
},
|
||||||
time: 0,
|
time: 0,
|
||||||
tick: 0,
|
tick: 0,
|
||||||
|
tick_rate: 100,
|
||||||
gravity: glam::Vec3::new(0.0,-100.0,0.0),
|
gravity: glam::Vec3::new(0.0,-100.0,0.0),
|
||||||
friction: 90.0,
|
friction: 90.0,
|
||||||
mv: 2.7,
|
mv: 2.7,
|
||||||
|
Loading…
Reference in New Issue
Block a user