diff options
author | Griffin Smith <root@gws.fyi> | 2019-07-06T19·32-0400 |
---|---|---|
committer | Griffin Smith <root@gws.fyi> | 2019-07-06T19·32-0400 |
commit | 78a52142d191d25a74cb2124d5cca8a69d51ba7f (patch) | |
tree | dd023a823bae6cc427e32a497bd68db85bbfab4b /src/entities/character.rs | |
parent | de081d7b1d0b791b2e61f9cde7369ea11647e0ae (diff) |
Make all drawing happen to a viewport
We now have an inner and outer viewport, and entity positions are relative to the inner one while drawing happens to the outer one.
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), + ) + } +} |