implement instruction

This commit is contained in:
Quaternions 2023-10-11 22:16:06 -07:00
parent 43a0eef5d1
commit 7309949dd0
2 changed files with 20 additions and 18 deletions

View File

@ -1,11 +1,13 @@
use crate::integer::Time;
#[derive(Debug)]
pub struct TimedInstruction<I>{
pub time: crate::physics::TIME,
pub time:Time,
pub instruction:I,
}
pub trait InstructionEmitter<I>{
fn next_instruction(&self, time_limit:crate::physics::TIME) -> Option<TimedInstruction<I>>;
fn next_instruction(&self,time_limit:Time)->Option<TimedInstruction<I>>;
}
pub trait InstructionConsumer<I>{
fn process_instruction(&mut self, instruction:TimedInstruction<I>);
@ -13,11 +15,11 @@ pub trait InstructionConsumer<I> {
//PROPER PRIVATE FIELDS!!!
pub struct InstructionCollector<I>{
time: crate::physics::TIME,
time:Time,
instruction:Option<I>,
}
impl<I> InstructionCollector<I>{
pub fn new(time:crate::physics::TIME) -> Self {
pub fn new(time:Time)->Self{
Self{
time,
instruction:None

View File

@ -496,7 +496,7 @@ impl PhysicsState {
//shitty mice are 125Hz which is 8ms so this should cover that.
//setting this to 100us still doesn't print even though it's 10x lower than the polling rate,
//so mouse events are probably not handled separately from drawing and fire right before it :(
if 10_000_000<ins.time-self.next_mouse.time{
if Time::from_millis(10)<ins.time-self.next_mouse.time{
//push an event to extrapolate no movement from
timeline.push_front(TimedInstruction{
time:last_mouse_time,