Add initial water cells to chunk
This commit is contained in:
		
							parent
							
								
									61538c139c
								
							
						
					
					
						commit
						9a473ee4d7
					
				|  | @ -74,13 +74,21 @@ pub struct Chunk { | ||||||
| 
 | 
 | ||||||
| impl Chunk { | impl Chunk { | ||||||
|     pub fn new(width: usize, height: usize) -> Self { |     pub fn new(width: usize, height: usize) -> Self { | ||||||
|         Self { |         let mut initial = Self { | ||||||
|             step: 0, |             step: 0, | ||||||
|             width, |             width, | ||||||
|             height, |             height, | ||||||
|             cells: vec![Element::Air; width * height], |             cells: vec![Element::Air; width * height], | ||||||
|             dirty_rect: DirtyRect::default(), |             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) { |     pub fn set_cell(&mut self, x: usize, y: usize, element: Element) { | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue