Started with timewarp

This commit is contained in:
Verox001 2025-05-04 14:39:39 +02:00
parent 2f7f521051
commit 69d4e8105c

View File

@ -10,8 +10,11 @@ use wgpu::util::DeviceExt;
use wgpu::{Adapter, Device, Instance, PresentMode, Queue, Surface, SurfaceCapabilities}; use wgpu::{Adapter, Device, Instance, PresentMode, Queue, Surface, SurfaceCapabilities};
use winit::application::ApplicationHandler; use winit::application::ApplicationHandler;
use winit::dpi::PhysicalSize; use winit::dpi::PhysicalSize;
use winit::event::WindowEvent; use winit::event::{ElementState, WindowEvent};
use winit::event::WindowEvent::KeyboardInput;
use winit::event_loop::{ActiveEventLoop, EventLoop}; use winit::event_loop::{ActiveEventLoop, EventLoop};
use winit::keyboard::Key;
use winit::platform::modifier_supplement::KeyEventExtModifierSupplement;
use winit::window::{Window, WindowId}; use winit::window::{Window, WindowId};
use solar_engine::{Body, Simulator}; use solar_engine::{Body, Simulator};
@ -359,6 +362,28 @@ impl<'a> State<'a> {
} }
pub fn input(&mut self, event: &WindowEvent) -> bool { pub fn input(&mut self, event: &WindowEvent) -> bool {
if let KeyboardInput { event, .. } = event {
if event.state == ElementState::Pressed {
return match event.key_without_modifiers().as_ref() {
Key::Character(".") => {
/*let mut sim = self.simulator.write().unwrap();
sim.increase_timewarp();
println!("Timewarp: {}", sim.get_timewarp());*/
true
}
Key::Character(",") => {
/*let mut sim = self.simulator.write().unwrap();
sim.decrease_timewarp();
println!("Timewarp: {}", sim.get_timewarp());*/
true
}
_ => {
false
}
}
}
}
false false
} }