From 0a3b3bf177d54c68a22f061a7087d20d19488bba Mon Sep 17 00:00:00 2001 From: Iago Garrido Date: Mon, 18 Nov 2019 20:56:58 +0100 Subject: add initial ui logic --- src/state.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/state.rs') diff --git a/src/state.rs b/src/state.rs index cfda88c..2c5f16f 100644 --- a/src/state.rs +++ b/src/state.rs @@ -2,7 +2,7 @@ use crossterm::cursor::MoveTo; use crossterm::{queue, Output}; use std::io::{stdout, Write}; -use crate::entities::{Character, Entity}; +use crate::entities::{Character, Player, Entity}; use crate::tiling::{tile_to_str, TileGrid}; use crate::world::{Dungeon, Generatable, Level}; @@ -78,6 +78,17 @@ impl State { self.render_entity(&self.player) } + pub fn render_ui(&self) { + let mut sout = stdout(); + queue!( + sout, + MoveTo(0, (self.dungeon.ysize + 1) as u16), + Output(self.player.stats()) + ) + .unwrap(); + sout.flush().unwrap(); + } + pub fn current_level(&self) -> &Level { &self.dungeon.levels[self.level] } -- cgit v1.2.3