flood

Flood fill puzzle game for linux terminals
git clone https://git.ce9e.org/flood.git

commit
86385c2a8f6b87dfe36179ee86eda2b1c8bf8b4a
parent
4e1975a0c9dbe6816a816c69d7db2ff71beb194e
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2022-02-06 07:14
use consistent colors

Diffstat

M flood.rs 17 ++++++++++++++---

1 files changed, 14 insertions, 3 deletions


diff --git a/flood.rs b/flood.rs

@@ -59,11 +59,20 @@ fn input_num(prompt: &str, low: u8, high: u8) -> u8 {
   59    59     }
   60    60 }
   61    61 
   -1    62 fn set_color(c: u8) {
   -1    63     // use different bold values to increase contrast
   -1    64     print!("\x1b[{};{}m", match c {
   -1    65         3|4 => 0,
   -1    66         _ => 1,
   -1    67     }, 31 + c);
   -1    68 }
   -1    69 
   62    70 fn render(map: &[u8; WIDTH * HEIGHT]) {
   63    71     for y in 0..HEIGHT {
   64    72         for x in 0..WIDTH {
   65    73             let c = map[y * WIDTH + x];
   66    -1             print!("\x1b[{}m██", 31 + c);
   -1    74             set_color(c);
   -1    75             print!("██");
   67    76         }
   68    77         println!("\x1b[0m");
   69    78     }
@@ -72,9 +81,11 @@ fn render(map: &[u8; WIDTH * HEIGHT]) {
   72    81 fn render_status(step: u8) {
   73    82     print!("{}/{}", step, 32);
   74    83     // move to column
   75    -1     print!("\x1b[{}G", WIDTH * 2 - 10);
   -1    84     print!("\x1b[{}G", WIDTH * 2 - 6 * 3 + 2);
   76    85     for i in 0..6 {
   77    -1         print!("\x1b[1;{}m{} ", 31 + i, i + 1);
   -1    86         set_color(i);
   -1    87         print!("■\x1b[0m{} ", i + 1);
   -1    88 
   78    89     }
   79    90     println!("\x1b[0m");
   80    91