about summary refs log tree commit diff
path: root/src/entities/character.rs
diff options
context:
space:
mode:
authorGriffin Smith <root@gws.fyi>2019-07-09T00·58-0400
committerGriffin Smith <root@gws.fyi>2019-07-09T00·58-0400
commit5af2429ecb5742383cf0798ce23682d316bdb24d (patch)
tree0fba959d9a5bce5c749c8529b3f2ea7b557c5767 /src/entities/character.rs
parent20f1ccb4600b88ac01768e912e6d5837534ca852 (diff)
Implement a global map of entities
Implement a global map of entities, which allows referencing by either
position or ID and updating the positions of existent entities, and put
the character in there.
Diffstat (limited to 'src/entities/character.rs')
-rw-r--r--src/entities/character.rs19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/entities/character.rs b/src/entities/character.rs
index f436608ea5e7..fb5a89591c95 100644
--- a/src/entities/character.rs
+++ b/src/entities/character.rs
@@ -1,13 +1,13 @@
+use crate::display;
+use crate::entities::Entity;
+use crate::types::{Position, Speed};
 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)]
+#[derive(Debug, PartialEq, Eq, Arbitrary, Clone)]
 pub struct Character {
     /// The position of the character, relative to the game
     pub position: Position,
@@ -26,13 +26,12 @@ impl Character {
 }
 
 positioned!(Character);
+positioned_mut!(Character);
+
+impl Entity for Character {}
 
 impl display::Draw for Character {
-    fn do_draw<W: Write>(&self, out: &mut W) -> io::Result<()> {
-        write!(
-            out,
-            "@{}",
-            cursor::Left(1),
-        )
+    fn do_draw(&self, out: &mut Write) -> io::Result<()> {
+        write!(out, "@{}", cursor::Left(1),)
     }
 }