Imrpoved component structure
This commit is contained in:
@@ -10,6 +10,10 @@ impl Component for Velocity {
|
||||
apply_velocity(tick, self.0.x, &mut position.x);
|
||||
apply_velocity(tick, self.0.y, &mut position.y);
|
||||
}
|
||||
|
||||
fn as_any_mut(&mut self) -> &mut dyn std::any::Any {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
fn apply_velocity(tick: u16, velocity: i32, x: &mut u16) -> bool {
|
||||
|
||||
@@ -19,10 +19,11 @@ pub fn tick(engine: &Arc<Engine>) {
|
||||
}
|
||||
|
||||
pub fn key(engine: &Arc<Engine>) {
|
||||
crossterm::terminal::enable_raw_mode().unwrap();
|
||||
|
||||
engine.thread("Main.key", |engine| {
|
||||
loop {
|
||||
// Pass an event to the thread
|
||||
|
||||
engine.emit_event(crossterm::event::read().unwrap());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user