Add chunk constructor
This commit is contained in:
parent
508f7d7ad8
commit
a57b457f49
|
@ -46,14 +46,7 @@ fn setup(mut commands: Commands, mut images: ResMut<Assets<Image>>) {
|
|||
|
||||
let image_handle = images.add(image);
|
||||
|
||||
commands
|
||||
.spawn(Chunk {
|
||||
width: 256,
|
||||
height: 256,
|
||||
cells: vec![Elements::Air; 256 * 256],
|
||||
dirty_rect: DirtyRect::default(),
|
||||
})
|
||||
.insert(SpriteBundle {
|
||||
commands.spawn(Chunk::new(256, 256)).insert(SpriteBundle {
|
||||
sprite: Sprite {
|
||||
flip_y: true,
|
||||
..default()
|
||||
|
@ -73,6 +66,17 @@ pub struct Chunk {
|
|||
dirty_rect: DirtyRect,
|
||||
}
|
||||
|
||||
impl Chunk {
|
||||
pub fn new(width: usize, height: usize) -> Self {
|
||||
Self {
|
||||
width,
|
||||
height,
|
||||
cells: vec![Elements::Air; width * height],
|
||||
dirty_rect: DirtyRect::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn place_sand_system(mut chunk: Query<&mut Chunk>) {
|
||||
// We know for now there's only one chunk
|
||||
let chunk = chunk.get_single_mut();
|
||||
|
|
Loading…
Reference in New Issue