about summary refs log tree commit diff
path: root/src/game.rs
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/game.rs
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/game.rs')
-rw-r--r--src/game.rs12
1 files changed, 12 insertions, 0 deletions
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(