diff options
Diffstat (limited to 'src/entities/character.rs')
-rw-r--r-- | src/entities/character.rs | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/entities/character.rs b/src/entities/character.rs index e40b7b988e8d..f436608ea5e7 100644 --- a/src/entities/character.rs +++ b/src/entities/character.rs @@ -1,15 +1,38 @@ +use proptest_derive::Arbitrary; +use std::io::{self, Write}; +use termion::cursor; + +use crate::display; use crate::types::{Position, Speed}; const DEFAULT_SPEED: Speed = Speed(100); +#[derive(Debug, PartialEq, Eq, Arbitrary)] pub struct Character { - position: Position, + /// The position of the character, relative to the game + pub position: Position, } impl Character { + pub fn new() -> Character { + Character { + position: Position { x: 0, y: 0 }, + } + } + pub fn speed(&self) -> Speed { Speed(100) } } positioned!(Character); + +impl display::Draw for Character { + fn do_draw<W: Write>(&self, out: &mut W) -> io::Result<()> { + write!( + out, + "@{}", + cursor::Left(1), + ) + } +} |