initialize grid function

This commit is contained in:
Baipyrus 2024-05-07 09:56:02 +02:00
parent 5b488b9716
commit fa1ffab177
2 changed files with 30 additions and 0 deletions

26
src/cell.rs Normal file
View 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
}

View File

@ -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();
}