2018-07-02 06:40:07 +10:00
|
|
|
extern crate crossterm;
|
|
|
|
|
|
|
|
use self::crossterm::terminal::{terminal, ClearType};
|
|
|
|
use self::crossterm::style::{Color, StyledObject, ObjectStyle };
|
|
|
|
|
2018-07-09 06:13:32 +10:00
|
|
|
use std::fmt::Debug;
|
|
|
|
use std::fmt;
|
|
|
|
|
|
|
|
#[derive(Copy, Clone,Debug)]
|
2018-07-02 06:40:07 +10:00
|
|
|
pub enum Direction
|
|
|
|
{
|
2018-07-09 06:13:32 +10:00
|
|
|
Up = 0,
|
|
|
|
Down = 1,
|
|
|
|
Left = 2,
|
|
|
|
Right = 3
|
2018-07-02 06:40:07 +10:00
|
|
|
}
|
|
|
|
|
2018-07-09 06:13:32 +10:00
|
|
|
#[derive(Copy, Clone, Debug)]
|
2018-07-02 06:40:07 +10:00
|
|
|
pub struct Position
|
|
|
|
{
|
|
|
|
pub x: usize,
|
|
|
|
pub y: usize
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Position
|
|
|
|
{
|
|
|
|
pub fn new(x: usize, y: usize) -> Position
|
|
|
|
{
|
|
|
|
Position { x, y }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Copy, Clone)]
|
|
|
|
pub struct Size
|
|
|
|
{
|
2018-07-09 06:13:32 +10:00
|
|
|
pub width: usize,
|
|
|
|
pub height: usize
|
2018-07-02 06:40:07 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Size
|
|
|
|
{
|
2018-07-09 06:13:32 +10:00
|
|
|
pub fn new(width: usize, height: usize) -> Size
|
2018-07-02 06:40:07 +10:00
|
|
|
{
|
|
|
|
Size {width,height}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-09 06:13:32 +10:00
|
|
|
pub struct Cell
|
2018-07-02 06:40:07 +10:00
|
|
|
{
|
2018-07-09 06:13:32 +10:00
|
|
|
pub position: Position,
|
|
|
|
pub color: Color,
|
|
|
|
pub look: char,
|
|
|
|
pub visited: bool
|
2018-07-02 06:40:07 +10:00
|
|
|
}
|
|
|
|
|
2018-07-09 06:13:32 +10:00
|
|
|
impl Cell
|
2018-07-02 06:40:07 +10:00
|
|
|
{
|
2018-07-09 06:13:32 +10:00
|
|
|
pub fn new(position: Position, color: Color, look: char, visited: bool) -> Cell
|
2018-07-02 06:40:07 +10:00
|
|
|
{
|
2018-07-09 06:13:32 +10:00
|
|
|
Cell { position, color, look, visited }
|
2018-07-02 06:40:07 +10:00
|
|
|
}
|
|
|
|
}
|