Add initial water cells to chunk

This commit is contained in:
Jarrod Doyle 2024-01-31 16:07:06 +00:00
parent 61538c139c
commit 9a473ee4d7
Signed by: Jayrude
GPG Key ID: 38B57B16E7C0ADF7
1 changed files with 9 additions and 1 deletions

View File

@ -74,13 +74,21 @@ pub struct Chunk {
impl Chunk {
pub fn new(width: usize, height: usize) -> Self {
Self {
let mut initial = Self {
step: 0,
width,
height,
cells: vec![Element::Air; width * height],
dirty_rect: DirtyRect::default(),
};
let max_y = height / 10;
for y in 0..=max_y {
for x in 0..width {
initial.set_cell(x, y, Element::Water);
}
}
initial
}
pub fn set_cell(&mut self, x: usize, y: usize, element: Element) {