forked from StrafesNET/strafe-client
Print Only Horizontal Velocity
The Speed function is unnecessary I forgot to remove it
This commit is contained in:
parent
2cef79da1d
commit
f07d9f968e
@ -1,6 +1,8 @@
|
|||||||
use crate::physics::{MouseState,PhysicsInputInstruction};
|
use crate::physics::{MouseState,PhysicsInputInstruction};
|
||||||
use strafesnet_common::integer::Time;
|
use strafesnet_common::integer::Time;
|
||||||
use strafesnet_common::instruction::{TimedInstruction,InstructionConsumer};
|
use strafesnet_common::instruction::{TimedInstruction,InstructionConsumer};
|
||||||
|
use strafesnet_common::integer::{self,Planar64,Planar64Vec3,Planar64Mat3,Angle32,Ratio64,Ratio64Vec2};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum InputInstruction {
|
pub enum InputInstruction {
|
||||||
MoveMouse(glam::IVec2),
|
MoveMouse(glam::IVec2),
|
||||||
@ -23,10 +25,35 @@ pub enum Instruction{
|
|||||||
//Graphics(crate::graphics_worker::Instruction),
|
//Graphics(crate::graphics_worker::Instruction),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub struct Speed{
|
||||||
|
pub player_vel:Planar64Vec3,
|
||||||
|
pub time:Time
|
||||||
|
}
|
||||||
|
|
||||||
|
impl std::ops::Neg for Speed{
|
||||||
|
type Output=Self;
|
||||||
|
fn neg(self)->Self::Output{
|
||||||
|
Self{
|
||||||
|
player_vel:self.player_vel,
|
||||||
|
time:self.time
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Speed{
|
||||||
|
pub fn new(player_vel:Planar64Vec3,time:Time)->Self{
|
||||||
|
Self{
|
||||||
|
player_vel,
|
||||||
|
time,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
pub fn new(mut physics:crate::physics::PhysicsState,mut graphics_worker:crate::compat_worker::INWorker<crate::graphics_worker::Instruction>)->crate::compat_worker::QNWorker<TimedInstruction<Instruction>>{
|
pub fn new(mut physics:crate::physics::PhysicsState,mut graphics_worker:crate::compat_worker::INWorker<crate::graphics_worker::Instruction>)->crate::compat_worker::QNWorker<TimedInstruction<Instruction>>{
|
||||||
let mut mouse_blocking=true;
|
let mut mouse_blocking=true;
|
||||||
let mut last_mouse_time=physics.next_mouse.time;
|
let mut last_mouse_time=physics.next_mouse.time;
|
||||||
let mut timeline=std::collections::VecDeque::new();
|
let mut timeline=std::collections::VecDeque::new();
|
||||||
|
let mut next_velocity_print=std::time::Instant::now();
|
||||||
|
let mut player_vel = physics.body.velocity.length();
|
||||||
crate::compat_worker::QNWorker::new(move |ins:TimedInstruction<Instruction>|{
|
crate::compat_worker::QNWorker::new(move |ins:TimedInstruction<Instruction>|{
|
||||||
if if let Some(phys_input)=match &ins.instruction{
|
if if let Some(phys_input)=match &ins.instruction{
|
||||||
Instruction::Input(input_instruction)=>match input_instruction{
|
Instruction::Input(input_instruction)=>match input_instruction{
|
||||||
@ -110,6 +137,11 @@ pub enum Instruction{
|
|||||||
instruction:crate::physics::PhysicsInstruction::Input(instruction.instruction),
|
instruction:crate::physics::PhysicsInstruction::Input(instruction.instruction),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
//some random print stuff
|
||||||
|
if 3.0/5.0<next_velocity_print.elapsed().as_secs_f64(){
|
||||||
|
next_velocity_print=next_velocity_print+std::time::Duration::from_secs_f64(1.0/30.0);
|
||||||
|
println!("velocity: {} u/s", (Planar64Vec3::new(physics.body.velocity.x(), Planar64::int(0), physics.body.velocity.z())).length()*(Planar64::int(130)/9));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
match ins.instruction{
|
match ins.instruction{
|
||||||
Instruction::Render=>{
|
Instruction::Render=>{
|
||||||
|
Loading…
Reference in New Issue
Block a user