diff examples/eclrenderer.rs @ 687:ac092b70c39a

Fix PRNG not to panic, pass it to Enemy, and initialise it with time in eclrenderer.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sat, 17 Aug 2019 13:49:31 +0200
parents cdb484115c5b
children 7ae576a418ff
line wrap: on
line diff
--- a/examples/eclrenderer.rs
+++ b/examples/eclrenderer.rs
@@ -121,8 +121,9 @@ fn main() {
         return;
     }
 
-    // TODO: seed this PRNG with a valid seed.
-    let prng = Rc::new(RefCell::new(Prng::new(0)));
+    // Get the time since January 1970 as a seed for the PRNG.
+    let time = std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).unwrap();
+    let prng = Rc::new(RefCell::new(Prng::new(time.subsec_micros() as u16)));
 
     // Create the Game god object.
     let game = Game::new(prng, rank);