Skip to content

Commit

Permalink
fix(shapes): changed banana_spark to acorn as it's more interesting
Browse files Browse the repository at this point in the history
  • Loading branch information
JeromeSchmied committed Feb 25, 2024
1 parent de67f05 commit 7432202
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 30 deletions.
4 changes: 3 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
"#;

Expand Down Expand Up @@ -238,7 +240,7 @@ pub fn get_shape(wh: u32, i: usize) -> Result<Universe, ShapeError> {

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),
}
Expand Down
27 changes: 1 addition & 26 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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();
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/shapes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ pub fn bonk_tie() -> Vec<String> {
.to_vec()
}

/// 2×3
pub fn banana_spark() -> Vec<String> {
["#_".into(), "_#".into(), "_#".into()].to_vec()
/// 7×3
pub fn acorn() -> Vec<String> {
["_#_____".into(), "___#___".into(), "##__###".into()].to_vec()
}

pub fn rand(width: u32, height: u32) -> Universe {
Expand Down

0 comments on commit 7432202

Please sign in to comment.