about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBaitinq <manuelpalenzuelamerino@gmail.com>2023-02-22 11:27:33 +0100
committerBaitinq <manuelpalenzuelamerino@gmail.com>2023-02-22 11:27:33 +0100
commit4280b58962a1f1218757778b8fbac943cb933c9e (patch)
treee77de90ceb6050b060da355ac200ac363db1fcd5
parentExit the program on CtrlC (diff)
downloadkyukai-master.tar.gz
kyukai-master.tar.bz2
kyukai-master.zip
Show the scrensaver on a loop HEAD master
-rw-r--r--src/main.rs10
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()