From fa1ffab177a5af8b261328fdb17412aa83b63232 Mon Sep 17 00:00:00 2001 From: Baipyrus Date: Tue, 7 May 2024 09:56:02 +0200 Subject: [PATCH] initialize grid function --- src/cell.rs | 26 ++++++++++++++++++++++++++ src/main.rs | 4 ++++ 2 files changed, 30 insertions(+) create mode 100644 src/cell.rs diff --git a/src/cell.rs b/src/cell.rs new file mode 100644 index 0000000..695093a --- /dev/null +++ b/src/cell.rs @@ -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> { + let mut grid: Vec> = Vec::new(); + for j in 0..HEIGHT { + let mut row: Vec = Vec::new(); + for i in 0..WIDTH { + row.push(Cell { + x: i, + y: j, + state: 0, + }); + } + grid.push(row); + } + grid +} diff --git a/src/main.rs b/src/main.rs index 0dcc72d..dd23e2d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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(); }