test functoin world
This commit is contained in:
1 parent
0eab202b00
commit
cac35a4047
2 files changed
+47
-50
No files matched your search
@@ -1,3 +1,5 @@
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use std::{
|
||||
error,
|
||||
fmt::format,
|
||||
@@ -12,6 +14,7 @@ use crossterm::{
|
||||
terminal::{Clear, ClearType, enable_raw_mode},
|
||||
};
|
||||
|
||||
use super::Agent;
|
||||
use super::TorusGrid;
|
||||
|
||||
pub enum PosCom {
|
||||
@@ -78,17 +81,28 @@ impl Render {
|
||||
ResetColor
|
||||
);
|
||||
}
|
||||
pub fn frame(&mut self, grid: &TorusGrid<bool>) {
|
||||
pub fn frame(&mut self, grid: &TorusGrid<bool>, a_grid: &TorusGrid<Option<Arc<Mutex<Agent>>>>) {
|
||||
let mut out = self.out.lock();
|
||||
_ = queue!(out, MoveTo(0, 0));
|
||||
for i in 0..self.rez.0 {
|
||||
for j in 0..self.rez.1 {
|
||||
let a = grid.get_wrap((i as i32 + self.pos.0, j as i32 + self.pos.1));
|
||||
let b = *a as u8 * 200;
|
||||
let ca: Color;
|
||||
let cg: Color;
|
||||
let a = a_grid.get_wrap((i as i32 + self.pos.0, j as i32 + self.pos.1));
|
||||
let g = grid.get_wrap((i as i32 + self.pos.0, j as i32 + self.pos.1));
|
||||
let c = *g as u8 * 200;
|
||||
cg = Color::Rgb { r: c, g: c, b: c };
|
||||
if a.is_some() {
|
||||
//c = Color::Red;
|
||||
ca = Color::Red;
|
||||
} else {
|
||||
ca = cg;
|
||||
}
|
||||
_ = queue!(
|
||||
out,
|
||||
SetBackgroundColor(Color::Rgb { r: b, g: b, b: b }),
|
||||
Print(" "),
|
||||
SetBackgroundColor(cg),
|
||||
SetForegroundColor(ca),
|
||||
Print("#"),
|
||||
ResetColor
|
||||
);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user