relise destroy walls
This commit is contained in:
1 parent
c85fcb8753
commit
05a039d88f
4 files changed
+199
-19
No files matched your search
+26
-4
@@ -3,7 +3,7 @@ use std::io::{Stdout, Write, stdout};
|
||||
use crossterm::{
|
||||
cursor::MoveTo,
|
||||
queue,
|
||||
style::Print,
|
||||
style::{Color, Print, ResetColor, SetBackgroundColor},
|
||||
terminal::{Clear, ClearType},
|
||||
};
|
||||
|
||||
@@ -37,20 +37,42 @@ impl Render {
|
||||
Ok(())
|
||||
}
|
||||
pub fn frame(&mut self, g: &Grid) -> Result<(), std::io::Error> {
|
||||
//queue!(self.out, MoveTo(0, 0))?;
|
||||
queue!(self.out, MoveTo(0, 0))?;
|
||||
for i in 0..self.rez.1 {
|
||||
for j in 0..self.rez.0 {
|
||||
let r = g.who_in((j, i));
|
||||
let r = g.who_in(&(j, i));
|
||||
let c = g.get_cursor();
|
||||
if c.0 as usize == j && c.1 as usize == i {
|
||||
queue!(self.out, SetBackgroundColor(Color::Green))?;
|
||||
} else {
|
||||
if r.who_in('t').unwrap_or(false) {
|
||||
queue!(
|
||||
self.out,
|
||||
SetBackgroundColor(Color::Red),
|
||||
//Print(" "),
|
||||
//ResetColor
|
||||
)?;
|
||||
} else {
|
||||
queue!(
|
||||
self.out,
|
||||
SetBackgroundColor(Color::Yellow),
|
||||
//Print(" "),
|
||||
//ResetColor
|
||||
)?;
|
||||
}
|
||||
}
|
||||
|
||||
if r.who_in('d').unwrap_or(false) {
|
||||
queue!(self.out, Print("_"))?;
|
||||
} else {
|
||||
queue!(self.out, Print(" "))?;
|
||||
}
|
||||
if r.who_in('d').unwrap_or(false) {
|
||||
if r.who_in('r').unwrap_or(false) {
|
||||
queue!(self.out, Print("|"))?;
|
||||
} else {
|
||||
queue!(self.out, Print(" "))?;
|
||||
}
|
||||
queue!(self.out, ResetColor)?;
|
||||
}
|
||||
queue!(self.out, Print("\r\n"))?;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user