diff options
author | Baitinq <manuelpalenzuelamerino@gmail.com> | 2023-02-22 11:27:33 +0100 |
---|---|---|
committer | Baitinq <manuelpalenzuelamerino@gmail.com> | 2023-02-22 11:27:33 +0100 |
commit | 4280b58962a1f1218757778b8fbac943cb933c9e (patch) | |
tree | e77de90ceb6050b060da355ac200ac363db1fcd5 | |
parent | Exit the program on CtrlC (diff) | |
download | kyukai-master.tar.gz kyukai-master.tar.bz2 kyukai-master.zip |
-rw-r--r-- | src/main.rs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs index afdc1f5..59c5cb6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,7 @@ use sdl2::event::Event; use sdl2::keyboard::Keycode; use sdl2::pixels::Color; +use std::time::Duration; fn main() { let sdl_context = sdl2::init().expect("Couldn't initialize the SDL2 context!"); @@ -10,10 +11,15 @@ fn main() { ctrlc::set_handler(move || std::process::exit(1)).expect("Error setting Ctrl-C handler"); - show_screensaver(sdl_context, sdl_video); + let show_frequency = Duration::from_secs(5); + loop { + show_screensaver(&sdl_context, &sdl_video); + + ::std::thread::sleep(show_frequency); + } } -fn show_screensaver(sdl_context: sdl2::Sdl, sdl_video: sdl2::VideoSubsystem) { +fn show_screensaver(sdl_context: &sdl2::Sdl, sdl_video: &sdl2::VideoSubsystem) { let window = sdl_video .window("Kyukai", 10, 10) .fullscreen() |