about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorGriffin Smith <root@gws.fyi>2019-07-29T01·32-0400
committerGriffin Smith <root@gws.fyi>2019-07-29T01·32-0400
commitba7bec9a3e36eaf2af65677b02884172241d1b24 (patch)
tree4bdd067a2e3ba95564a9d84b409b6c3190afa4a0 /src
parent10fb09eca27991e878bee4a4c63d0ecd6b4a44b3 (diff)
Re-draw entities when you walk over them
This also required making the noodles character not actually the emoji,
since the emoji being double-width means it still gets overwritten when
you walk to the right of it (D:)
Diffstat (limited to 'src')
-rw-r--r--src/entities/character.rs2
-rw-r--r--src/entities/raws/noodles.json3
-rw-r--r--src/game.rs12
-rw-r--r--src/util/promise.rs1
4 files changed, 15 insertions, 3 deletions
diff --git a/src/entities/character.rs b/src/entities/character.rs
index b917f140e635..b2da47609670 100644
--- a/src/entities/character.rs
+++ b/src/entities/character.rs
@@ -50,6 +50,6 @@ entity!(Character);
 
 impl display::Draw for Character {
     fn do_draw(&self, out: &mut Write) -> io::Result<()> {
-        write!(out, "@{}", cursor::Left(1),)
+        write!(out, "@")
     }
 }
diff --git a/src/entities/raws/noodles.json b/src/entities/raws/noodles.json
index d4b773cac533..6e2ecded7513 100644
--- a/src/entities/raws/noodles.json
+++ b/src/entities/raws/noodles.json
@@ -2,7 +2,8 @@
   "Item": {
     "name": "noodles",
     "char": {
-      "char": "🍜"
+      "char": "n",
+      "color": "yellow"
     },
     "description": "You know exactly what kind of noodles",
     "edible_item": {
diff --git a/src/game.rs b/src/game.rs
index eee0b7c0d513..dd45b3009a37 100644
--- a/src/game.rs
+++ b/src/game.rs
@@ -227,6 +227,17 @@ impl<'a> Game<'a> {
         Ok(())
     }
 
+    /// Draw all the game entities to the screen
+    fn draw_entities_at(&mut self, pos: Position) -> io::Result<()> {
+        for entity in self.entities.at(pos) {
+            self.viewport.draw(
+                entity,
+                &self.entities.neighbor_entities(entity.position()),
+            )?;
+        }
+        Ok(())
+    }
+
     /// Draw the game entity with the given ID, if any, to the screen
     fn draw_entity(&mut self, entity_id: EntityID) -> io::Result<bool> {
         if let Some(entity) = self.entities.get(entity_id) {
@@ -438,6 +449,7 @@ impl<'a> Game<'a> {
                             self.viewport.game_cursor_position =
                                 character.position;
                             self.viewport.clear(old_pos)?;
+                            self.draw_entities_at(old_pos)?;
                             self.draw_entity(self.character_entity_id)?;
                             self.tick(
                                 self.character().speed().tiles_to_ticks(
diff --git a/src/util/promise.rs b/src/util/promise.rs
index 41f3d76e7737..63fbca1ddc18 100644
--- a/src/util/promise.rs
+++ b/src/util/promise.rs
@@ -153,7 +153,6 @@ impl<'a, Env> Promises<'a, Env> {
     }
 
     pub fn give_all(&mut self, env: &mut Env) {
-        debug!("promises: {}", self.ps.len());
         self.ps.retain(|p| !p.give(env));
     }
 }