diff --git a/src/console_render/mod.rs b/src/console_render/mod.rs index 821e728..7d0b83c 100644 --- a/src/console_render/mod.rs +++ b/src/console_render/mod.rs @@ -1,4 +1,5 @@ use std::{ + error, io::{Stdout, Write, stdout}, process::Output, }; @@ -13,7 +14,7 @@ use crossterm::{ pub struct Render { out: Stdout, rez: (usize, usize), - pos: (f32, f32), + pos: (usize, usize), } impl Render { @@ -21,13 +22,17 @@ impl Render { Render { out: stdout(), rez: (10, 10), - pos: (0.0, 0.0), + pos: (0, 0), } } - pub fn set_rez(&mut self, a: usize, b: usize) { + pub fn set_rez(&mut self, a: usize, b: usize) -> Result<(), String> { + if a == 0 || b == 0 { + return Err("Invalid resolution\n".to_string()); + } self.rez = (a, b); + Ok(()) } - pub fn set_pos(&mut self, a: f32, b: f32) { + pub fn set_pos(&mut self, a: usize, b: usize) { self.pos = (a, b); } pub fn init(&mut self) {