Initial commit I think

Initial commit with just menu and sort of pause menu only
This commit is contained in:
Uttarayan Mondal
2021-01-05 03:40:51 +05:30
commit 4cc7dbce92
5 changed files with 258 additions and 0 deletions
+53
View File
@@ -0,0 +1,53 @@
extern crate rand;
enum CellType {
Snake,
Food,
Empty,
}
struct Cell {
line: i32,
col: i32,
ctype: CellType,
}
impl Default for Cell {
fn default() -> Self {
Self {
line: -1,
col: -1,
ctype: CellType::Empty,
}
}
}
enum Direction {
Up,
Down,
Left,
Right,
}
struct Snake {
length: i32,
}
struct SnakeCell {
pub line: i32,
pub col: i32,
}
impl SnakeCell {
fn next(&self, direction: Direction) -> SnakeCell {
let (dl, dc) = match direction {
Direction::Up => (-1, 0),
Direction::Down => (1, 0),
Direction::Left => (0, -1),
Direction::Right => (0, 1),
};
SnakeCell {
line: self.line + dl,
col: self.col + dc,
// ctype: self.ctype,
}
}
}