Slowed things down

made the program sleep for 70 ms after every draw so it is more aesthetic to look at.
This commit is contained in:
TheLie0 2019-03-08 12:40:32 +01:00 committed by GitHub
parent 4a4edfdf51
commit 58b589af13
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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);
}
}