From 743220235c9db58f9b1e21dd60462bb78272627b Mon Sep 17 00:00:00 2001 From: Jeromos Kovacs Date: Sun, 25 Feb 2024 15:17:09 +0100 Subject: [PATCH] fix(shapes): changed banana_spark to acorn as it's more interesting --- src/lib.rs | 4 +++- src/main.rs | 27 +-------------------------- src/shapes.rs | 6 +++--- 3 files changed, 7 insertions(+), 30 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index f4ba37f..d05027d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -9,6 +9,8 @@ pub const HELP: &str = r#"Blocking poll() & non-blocking read() - `j`, `k`: decreasing, increasing speed - press Space to pause, play - hit `n` to switch to next shape + - if you want to restart, push `r` + - to reset everything to starting phase, hit `R` - and now, press Enter to continue "#; @@ -238,7 +240,7 @@ pub fn get_shape(wh: u32, i: usize) -> Result { 6 => Universe::from_figur(wh, &shapes::bonk_tie()), - 7 => Universe::from_figur(wh, &shapes::banana_spark()), + 7 => Universe::from_figur(wh, &shapes::acorn()), _ => Err(ShapeError::OutOfRange), } diff --git a/src/main.rs b/src/main.rs index c52dc61..b94b535 100644 --- a/src/main.rs +++ b/src/main.rs @@ -52,47 +52,22 @@ fn print_events() -> io::Result<()> { println!("Quitting...\r"); break; } else if kmaps::slower().contains(&event) { - // if poll_t < Duration::from_millis(40) { - // poll_t = poll_t - // .checked_add(Duration::from_millis(1)) - // .unwrap_or(DEFAULT_DUR); - // } else { - // poll_t = poll_t - // .checked_add(Duration::from_millis(10)) - // .unwrap_or(DEFAULT_DUR); - // } if !paused { slower(&mut poll_t, false); } - // queue!(io::stdout(), Print("Poll time is now"))?; println!("poll time is now: {:?}\r", poll_t); } else if kmaps::faster().contains(&event) { - // if poll_t < Duration::from_millis(40) { - // poll_t = poll_t - // .checked_sub(Duration::from_millis(1)) - // .unwrap_or(DEFAULT_DUR); - // } else { - // poll_t = poll_t - // .checked_sub(Duration::from_millis(10)) - // .unwrap_or(DEFAULT_DUR); - // } if !paused { faster(&mut poll_t, false); } println!("poll time is now: {:?}\r", poll_t); } else if kmaps::slower_big().contains(&event) { - // poll_t = poll_t - // .checked_add(Duration::from_millis(100)) - // .unwrap_or(Duration::from_millis(400)); if !paused { slower(&mut poll_t, true); } println!("poll time is now: {:?}\r", poll_t); } else if kmaps::faster_big().contains(&event) { - // poll_t = poll_t - // .checked_sub(Duration::from_millis(100)) - // .unwrap_or(Duration::from_millis(400)); if !paused { faster(&mut poll_t, true); } @@ -144,9 +119,9 @@ fn print_events() -> io::Result<()> { } } else { // Timeout expired, updating life state - universe.tick(); execute!(io::stdout(), MoveTo(0, 0), Clear(ClearType::FromCursorDown))?; println!("{}", universe); + universe.tick(); } } diff --git a/src/shapes.rs b/src/shapes.rs index a9a01cf..c1e77d4 100644 --- a/src/shapes.rs +++ b/src/shapes.rs @@ -90,9 +90,9 @@ pub fn bonk_tie() -> Vec { .to_vec() } -/// 2×3 -pub fn banana_spark() -> Vec { - ["#_".into(), "_#".into(), "_#".into()].to_vec() +/// 7×3 +pub fn acorn() -> Vec { + ["_#_____".into(), "___#___".into(), "##__###".into()].to_vec() } pub fn rand(width: u32, height: u32) -> Universe {