From 58b589af133482063b35519ff75c0883adde1630 Mon Sep 17 00:00:00 2001 From: TheLie0 Date: Fri, 8 Mar 2019 12:40:32 +0100 Subject: [PATCH] Slowed things down made the program sleep for 70 ms after every draw so it is more aesthetic to look at. --- src/main.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main.rs b/src/main.rs index 5a55496..12dbc12 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,18 +2,25 @@ extern crate console; extern crate rand; use console::Term; +use std::thread::sleep; +use std::time::{Duration, Instant}; fn main() { let cutoff: f32 = 0.3; + let frame_wait_time = Duration::from_millis(70); let term = Term::stdout(); let mut game = GameOfLife::new(255, 255, cutoff); game.print_to_console(&term); + let mut now = Instant::now(); + sleep(frame_wait_time); loop { game.update(); if game.print_to_console(&term) == 0 { game = GameOfLife::new(255, 255, cutoff); } + now = Instant::now(); + sleep(frame_wait_time); } }