Skip to content

Commit

Permalink
status bar glitch fix
Browse files Browse the repository at this point in the history
  • Loading branch information
PonasKovas committed Sep 1, 2019
1 parent d37ebb0 commit 249628d
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ impl Game {
// Clear terminal screen
print!("\x1b[H");

let real_terminal_size = if let Some((w, h)) = term_size::dimensions() {
(w as u16, h as u16)
} else {
(40, 10)
};

let right_side_padding = &" ".repeat((real_terminal_size.0 - terminal_size.0 * 2) as usize);

// Draw the frame
let mut frame = Vec::<u8>::new();

Expand All @@ -102,15 +110,9 @@ impl Game {
frame.extend_from_slice(b" ");
}
}
frame.extend_from_slice(b"\r\n");
frame.extend_from_slice(right_side_padding.as_bytes());
}

let real_terminal_size = if let Some((w, h)) = term_size::dimensions() {
(w as u16, h as u16)
} else {
(40, 10)
};

// Add the status line at the bottom
let status_text = format!("Score: {}", self.score);
frame.extend_from_slice(b"\x1b[104m\x1b[30m");
Expand Down

0 comments on commit 249628d

Please sign in to comment.