summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/main.rs b/src/main.rs
index 3b36b2e..c98c0ca 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -9,11 +9,11 @@ fn rand(max: i32) -> i32 {
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
struct Pos {
- row: u16,
- col: u16,
+ row: i8,
+ col: i8,
}
-fn pos(row: u16, col: u16) -> Pos {
+fn pos(row: i8, col: i8) -> Pos {
Pos { row, col }
}
@@ -52,8 +52,8 @@ struct Screen {
}
impl Screen {
- const ROWS: u16 = 25;
- const COLS: u16 = 50;
+ const ROWS: i8 = 25;
+ const COLS: i8 = 50;
fn init() -> Result<Screen, Box<dyn Error>> {
// Get current terminal attrs.
@@ -239,8 +239,8 @@ impl Fruit {
}
fn new_pos(&mut self) {
- self.pos.row = rand(i32::from(Screen::ROWS) - 4) as u16 + 2;
- self.pos.col = rand(i32::from(Screen::COLS) - 4) as u16 + 2;
+ self.pos.row = rand(i32::from(Screen::ROWS) - 4) as i8 + 2;
+ self.pos.col = rand(i32::from(Screen::COLS) - 4) as i8 + 2;
}
}