diff --git a/src/body.rs b/src/body.rs index b60c221..7c60be9 100644 --- a/src/body.rs +++ b/src/body.rs @@ -5,6 +5,8 @@ pub enum PhysicsInstruction { CollisionEnd(RelativeCollision), StrafeTick, Jump, + SetWalkTargetVelocity(glam::Vec3), + ReachWalkTargetVelocity, // Water, // Spawn( // Option, @@ -19,6 +21,13 @@ pub struct Body { pub time: TIME,//nanoseconds x xxxxD! } +pub enum MoveRestriction { + Air, + Water, + Ground, + Ladder,//multiple ladders how +} + pub struct PhysicsState { pub body: Body, pub contacts: Vec, @@ -176,41 +185,19 @@ pub type TIME = i64; const CONTROL_JUMP:u32 = 0b01000000;//temp DATA NORMALIZATION!@#$ 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_num/self.strafe_tick_den) as u32; - //the game code can run for 1 month before running out of ticks - while self.tick for PhysicsState } impl crate::instruction::InstructionConsumer for PhysicsState { - fn process_instruction(&mut self, instruction:TimedInstruction) { - // + fn process_instruction(&mut self, ins:TimedInstruction) { + //mutate position and velocity and time + self.body.advance_time(ins.time);//should this be in a separate function: self.advance_time? + match ins.instruction { + PhysicsInstruction::CollisionStart(_) => todo!(), + PhysicsInstruction::CollisionEnd(_) => todo!(), + PhysicsInstruction::StrafeTick => { + let control_dir=self.get_control_dir();//this respects your mouse interpolation settings + let d=self.body.velocity.dot(control_dir); + if d { + self.grounded=false;//do I need this? + self.body.velocity+=glam::Vec3::new(0.0,0.715588/2.0*100.0,0.0); + } + PhysicsInstruction::ReachWalkTargetVelocity => { + //precisely set velocity + self.body.velocity=self.walk_target_velocity; + } + PhysicsInstruction::SetWalkTargetVelocity(v) => { + self.walk_target_velocity=v; + //calculate acceleration yada yada + }, + } } } \ No newline at end of file