From 7309949dd03dc97c88c1ef0b18647e46b3df28fd Mon Sep 17 00:00:00 2001 From: Quaternions Date: Wed, 11 Oct 2023 22:16:06 -0700 Subject: [PATCH] implement instruction --- src/instruction.rs | 36 +++++++++++++++++++----------------- src/physics.rs | 2 +- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/instruction.rs b/src/instruction.rs index 3508b93..f8880cb 100644 --- a/src/instruction.rs +++ b/src/instruction.rs @@ -1,23 +1,25 @@ +use crate::integer::Time; + #[derive(Debug)] -pub struct TimedInstruction { - pub time: crate::physics::TIME, - pub instruction: I, +pub struct TimedInstruction{ + pub time:Time, + pub instruction:I, } -pub trait InstructionEmitter { - fn next_instruction(&self, time_limit:crate::physics::TIME) -> Option>; +pub trait InstructionEmitter{ + fn next_instruction(&self,time_limit:Time)->Option>; } -pub trait InstructionConsumer { +pub trait InstructionConsumer{ fn process_instruction(&mut self, instruction:TimedInstruction); } //PROPER PRIVATE FIELDS!!! -pub struct InstructionCollector { - time: crate::physics::TIME, - instruction: Option, +pub struct InstructionCollector{ + time:Time, + instruction:Option, } -impl InstructionCollector { - pub fn new(time:crate::physics::TIME) -> Self { +impl InstructionCollector{ + pub fn new(time:Time)->Self{ Self{ time, instruction:None @@ -25,24 +27,24 @@ impl InstructionCollector { } pub fn collect(&mut self,instruction:Option>){ - match instruction { - Some(unwrap_instruction) => { + match instruction{ + Some(unwrap_instruction)=>{ if unwrap_instruction.time (), + None=>(), } } - pub fn instruction(self) -> Option> { + pub fn instruction(self)->Option>{ //STEAL INSTRUCTION AND DESTROY INSTRUCTIONCOLLECTOR - match self.instruction { + match self.instruction{ Some(instruction)=>Some(TimedInstruction{ time:self.time, instruction }), - None => None, + None=>None, } } } \ No newline at end of file diff --git a/src/physics.rs b/src/physics.rs index 881be82..7fe0033 100644 --- a/src/physics.rs +++ b/src/physics.rs @@ -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