comit for merge
This commit is contained in:
1 parent
9c61078414
commit
66c0bb839e
2 files changed
+32
-2
No files matched your search
@@ -78,13 +78,13 @@ impl Render {
|
|||||||
ResetColor
|
ResetColor
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
pub fn frame(&mut self, grid: &TorusGrid<i32>) {
|
pub fn frame(&mut self, grid: &TorusGrid<bool>) {
|
||||||
let mut out = self.out.lock();
|
let mut out = self.out.lock();
|
||||||
_ = queue!(out, MoveTo(0, 0));
|
_ = queue!(out, MoveTo(0, 0));
|
||||||
for i in 0..self.rez.0 {
|
for i in 0..self.rez.0 {
|
||||||
for j in 0..self.rez.1 {
|
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 a = grid.get_wrap((i as i32 + self.pos.0, j as i32 + self.pos.1));
|
||||||
let b = *a as u8;
|
let b = *a as u8 * 200;
|
||||||
_ = queue!(
|
_ = queue!(
|
||||||
out,
|
out,
|
||||||
SetBackgroundColor(Color::Rgb { r: b, g: b, b: b }),
|
SetBackgroundColor(Color::Rgb { r: b, g: b, b: b }),
|
||||||
|
|||||||
+30
@@ -1,3 +1,5 @@
|
|||||||
|
use std::{clone, sync::atomic::AtomicI32};
|
||||||
|
|
||||||
use rand::Rng;
|
use rand::Rng;
|
||||||
mod world;
|
mod world;
|
||||||
pub use world::*;
|
pub use world::*;
|
||||||
@@ -8,6 +10,30 @@ use input::*;
|
|||||||
mod console_render;
|
mod console_render;
|
||||||
use console_render::*;
|
use console_render::*;
|
||||||
|
|
||||||
|
fn init_life(g: &mut TorusGrid<bool>, size: (i32, i32)) -> &mut TorusGrid<bool> {
|
||||||
|
let mut rng = rand::thread_rng();
|
||||||
|
for i in 0..size.0 {
|
||||||
|
for j in 0..size.1 {
|
||||||
|
if let Some(a) = g.get_mut((i, j)) {
|
||||||
|
*a = rng.gen_range(0..=100) / 2 == 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
g
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
fn life(g: &mut TorusGrid<bool>, size: (i32, i32)) -> &mut TorusGrid<bool> {
|
||||||
|
let mut a = g.clone();
|
||||||
|
for i in 0..size.0 {
|
||||||
|
for j in 0..size.1 {
|
||||||
|
let mut s = 0;
|
||||||
|
let z = *a.get_wrap((i, j));
|
||||||
|
s += z as i32;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
a
|
||||||
|
}
|
||||||
|
*/
|
||||||
enum Input_type {
|
enum Input_type {
|
||||||
comand,
|
comand,
|
||||||
keybard,
|
keybard,
|
||||||
@@ -21,6 +47,7 @@ fn main() {
|
|||||||
R.set_rez(40, 80);
|
R.set_rez(40, 80);
|
||||||
|
|
||||||
let g_rez: (usize, usize) = (100, 50);
|
let g_rez: (usize, usize) = (100, 50);
|
||||||
|
/*
|
||||||
let mut grid: TorusGrid<i32> = TorusGrid::new(0, g_rez);
|
let mut grid: TorusGrid<i32> = TorusGrid::new(0, g_rez);
|
||||||
|
|
||||||
for i in 0..g_rez.0 {
|
for i in 0..g_rez.0 {
|
||||||
@@ -30,6 +57,9 @@ fn main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
let mut grid: TorusGrid<bool> = TorusGrid::new(false, g_rez);
|
||||||
|
init_life(&mut grid, (g_rez.0 as i32, g_rez.1 as i32));
|
||||||
loop {
|
loop {
|
||||||
//R.clear();
|
//R.clear();
|
||||||
R.frame(&grid);
|
R.frame(&grid);
|
||||||
|
|||||||
Reference in new issue
Block a user