2022-06-10 20:43:33 +10:00
|
|
|
#![allow(clippy::single_match)]
|
|
|
|
|
2019-07-11 08:54:54 +10:00
|
|
|
use instant::Instant;
|
|
|
|
use std::time::Duration;
|
2020-09-10 11:58:30 +10:00
|
|
|
|
|
|
|
use simple_logger::SimpleLogger;
|
2019-06-22 01:33:15 +10:00
|
|
|
use winit::{
|
|
|
|
event::{Event, StartCause, WindowEvent},
|
2022-04-10 11:32:02 +10:00
|
|
|
event_loop::EventLoop,
|
2019-06-22 01:33:15 +10:00
|
|
|
window::WindowBuilder,
|
|
|
|
};
|
2019-02-06 02:30:33 +11:00
|
|
|
|
|
|
|
fn main() {
|
2020-09-10 11:58:30 +10:00
|
|
|
SimpleLogger::new().init().unwrap();
|
2019-02-06 02:30:33 +11:00
|
|
|
let event_loop = EventLoop::new();
|
|
|
|
|
|
|
|
let _window = WindowBuilder::new()
|
|
|
|
.with_title("A fantastic window!")
|
|
|
|
.build(&event_loop)
|
|
|
|
.unwrap();
|
|
|
|
|
2019-06-20 12:06:09 +10:00
|
|
|
let timer_length = Duration::new(1, 0);
|
|
|
|
|
2019-02-06 02:30:33 +11:00
|
|
|
event_loop.run(move |event, _, control_flow| {
|
2019-11-23 11:11:04 +11:00
|
|
|
println!("{:?}", event);
|
2019-02-06 02:30:33 +11:00
|
|
|
|
|
|
|
match event {
|
2019-06-22 01:33:15 +10:00
|
|
|
Event::NewEvents(StartCause::Init) => {
|
2022-04-10 11:32:02 +10:00
|
|
|
control_flow.set_wait_until(Instant::now() + timer_length);
|
2019-06-25 02:14:55 +10:00
|
|
|
}
|
2019-06-22 01:33:15 +10:00
|
|
|
Event::NewEvents(StartCause::ResumeTimeReached { .. }) => {
|
2022-04-10 11:32:02 +10:00
|
|
|
control_flow.set_wait_until(Instant::now() + timer_length);
|
2019-02-06 02:30:33 +11:00
|
|
|
println!("\nTimer\n");
|
2019-06-25 02:14:55 +10:00
|
|
|
}
|
2019-02-06 02:30:33 +11:00
|
|
|
Event::WindowEvent {
|
|
|
|
event: WindowEvent::CloseRequested,
|
|
|
|
..
|
2022-04-10 11:32:02 +10:00
|
|
|
} => control_flow.set_exit(),
|
2019-06-22 01:33:15 +10:00
|
|
|
_ => (),
|
2019-02-06 02:30:33 +11:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|