From 9a2b24e006be4539df3aea5011cfdc13f28ccbf8 Mon Sep 17 00:00:00 2001 From: Alex Bethel Date: Sat, 15 Jan 2022 17:53:51 -0600 Subject: [PATCH] Make text cursor follow player --- src/player.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/player.rs b/src/player.rs index bf34063..786115a 100644 --- a/src/player.rs +++ b/src/player.rs @@ -85,8 +85,6 @@ fn possible(ecs: &World, action: &MobAction) -> bool { /// Renders the state of the world onto the screen. fn render_screen(ecs: &mut World, screen: &mut Window) { - // screen.clear(); - // Draw the base level. let level = ecs.fetch::(); level.draw(screen); @@ -98,8 +96,11 @@ fn render_screen(ecs: &mut World, screen: &mut Window) { screen.mvaddch(pos.y as _, pos.x as _, render.glyph); } - // Leave the cursor at the lower-left. - screen.mv(0, 0); + // Leave the cursor on the player's position. + let plrs = ecs.read_storage::(); + let pos = ecs.read_storage::(); + let (_plr, pos) = (&plrs, &pos).join().next().unwrap(); + screen.mv(pos.y, pos.x); screen.refresh(); }