Add initial water cells to chunk
This commit is contained in:
		
							parent
							
								
									61538c139c
								
							
						
					
					
						commit
						9a473ee4d7
					
				|  | @ -74,14 +74,22 @@ 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) { | ||||
|         if x >= self.width || y >= self.height { | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue