work on level generator
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
use ratatui::buffer::Buffer;
|
||||
use ratatui::layout::Rect;
|
||||
use ratatui::style::Color;
|
||||
use ratatui::style::{Color, Modifier, Style};
|
||||
use ratatui::widgets::{StatefulWidget, Widget};
|
||||
|
||||
use crate::game::Game;
|
||||
@@ -15,6 +15,9 @@ impl LevelWidget {
|
||||
fn set_cell(&self, buf: &mut Buffer, x: u16, y: u16, symbol: &str, fg: Color, bg: Color) {
|
||||
buf[(x, y)].set_symbol(symbol).set_bg(bg).set_fg(fg);
|
||||
}
|
||||
fn set_bold_cell(&self, buf: &mut Buffer, x: u16, y: u16, symbol: &str, fg: Color, bg: Color) {
|
||||
buf[(x, y)].set_symbol(symbol).set_bg(bg).set_fg(fg).set_style(Style::new().add_modifier(Modifier::BOLD));
|
||||
}
|
||||
}
|
||||
|
||||
impl StatefulWidget for LevelWidget {
|
||||
@@ -46,7 +49,7 @@ impl StatefulWidget for LevelWidget {
|
||||
}
|
||||
StructureElement::Wall => {
|
||||
// TODO add fancy walls with https://en.wikipedia.org/wiki/Box-drawing_characters
|
||||
self.set_cell(buf, x, y, "#", FG_BROWN, Color::Gray);
|
||||
self.set_cell(buf, x, y, "#", FG_BROWN, FG_BROWN);
|
||||
}
|
||||
StructureElement::Floor => {
|
||||
self.set_cell(buf, x, y, " ", FG_BROWN, Color::Gray);
|
||||
@@ -68,7 +71,7 @@ impl StatefulWidget for LevelWidget {
|
||||
}
|
||||
(_, _, Some(t)) => {
|
||||
let (s, c) = t.get_representation();
|
||||
self.set_cell(buf, x, y, s, c, Color::Gray);
|
||||
self.set_bold_cell(buf, x, y, s, c, Color::Gray);
|
||||
}
|
||||
(None, None, None) => {}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user