mirror of
https://gitlab1.ptb.de/waltem01/Matrix
synced 2024-09-11 07:39:42 +00:00
initialize grid function
This commit is contained in:
parent
5b488b9716
commit
fa1ffab177
26
src/cell.rs
Normal file
26
src/cell.rs
Normal file
|
@ -0,0 +1,26 @@
|
|||
use crate::BRIGHTNESS;
|
||||
use crate::HEIGHT;
|
||||
use crate::Q;
|
||||
use crate::WIDTH;
|
||||
|
||||
pub struct Cell {
|
||||
pub x: u32,
|
||||
pub y: u32,
|
||||
pub state: u32,
|
||||
}
|
||||
|
||||
pub fn init_grid() -> Vec<Vec<Cell>> {
|
||||
let mut grid: Vec<Vec<Cell>> = Vec::new();
|
||||
for j in 0..HEIGHT {
|
||||
let mut row: Vec<Cell> = Vec::new();
|
||||
for i in 0..WIDTH {
|
||||
row.push(Cell {
|
||||
x: i,
|
||||
y: j,
|
||||
state: 0,
|
||||
});
|
||||
}
|
||||
grid.push(row);
|
||||
}
|
||||
grid
|
||||
}
|
|
@ -7,6 +7,10 @@ pub const K2: u32 = 3;
|
|||
pub const G: u32 = 35;
|
||||
pub const Q: u32 = 100;
|
||||
|
||||
mod cell;
|
||||
use cell::*;
|
||||
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
let grid = init_grid();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user