Skip to content

Commit

Permalink
suiro: Fix print
Browse files Browse the repository at this point in the history
  • Loading branch information
bouzuya committed Jun 24, 2022
1 parent 4b90572 commit dd81c95
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions suiro/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ fn print(stdout: &mut StdoutLock, game: &Game) -> anyhow::Result<()> {
})
.collect::<String>()
)?;

stdout.flush()?;
Ok(())
}

Expand Down Expand Up @@ -244,19 +246,16 @@ fn main() -> anyhow::Result<()> {
let size = Size::new(16, 16).map_err(map::Error::from)?;
Map::gen(size)
})?;
let mut game = Game::new(map)?;

let stdout = io::stdout().lock();
let stdin = io::stdin().lock();
let mut stdout = stdout.into_raw_mode().unwrap();

write!(stdout, "{}", termion::clear::All)?;
write!(stdout, "{}", termion::cursor::Hide)?;
write!(stdout, "{}", termion::cursor::Goto(1, 1))?;

let mut game = Game::new(map)?;

print(&mut stdout, &game)?;
stdout.flush()?;

for key in stdin.keys() {
use termion::event::Key::*;
Expand All @@ -270,7 +269,6 @@ fn main() -> anyhow::Result<()> {
_ => {}
}
print(&mut stdout, &game)?;
stdout.flush()?;
}

write!(stdout, "{}", termion::cursor::Show)?;
Expand Down

0 comments on commit dd81c95

Please sign in to comment.