diff options
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..a7b3e59 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,31 @@ +pub mod display; +pub mod game; + +use game::{Board, Dir::*, Pos}; + +fn main() { + let mut rng = rand::thread_rng(); + let getch = getch::Getch::new(); + let board = Board::new(Pos::new(4, 4)); + + board.spawn(&mut rng); + clearscreen::clear().unwrap(); + print!("{board}"); + + while let Ok(ch) = getch.getch() { + if !board.step(match ch { + b'w' => Up, + b'a' => Left, + b's' => Down, + b'd' => Right, + b'q' => break, + _ => continue, + }) { + continue; + } + + board.spawn(&mut rng); + clearscreen::clear().unwrap(); + print!("{board}"); + } +} |