This commit is contained in:
Able 2024-09-30 09:59:03 -05:00
parent 2d8be2e1de
commit 357ef6c8e2

View file

@ -6,11 +6,18 @@ use crate::materials::EMPTY;
const WIDTH: usize = 800;
const HEIGHT: usize = 600;
pub struct Change {
x_from: usize,
x_to: usize,
y_from: usize,
y_to: usize,
}
pub struct World {
pub width: usize,
pub height: usize,
pub cells: Vec<Cell>,
changes: Vec<Change>,
}
impl World {
pub fn new() -> Self {
@ -25,6 +32,7 @@ impl World {
};
WIDTH * HEIGHT
],
changes: vec![],
}
}
}
@ -47,6 +55,20 @@ impl World {
pub fn set_xy(&mut self, x: usize, y: usize, cell: Cell) {
self.cells[xy_to_i(x, y)] = cell
}
// Collect all the changes to the world and push them into a changes vec
pub fn move_cell(&mut self, x: usize, y: usize, xto: usize, yto: usize) {
let change = Change {
x_from: x,
x_to: xto,
y_from: y,
y_to: yto,
};
self.changes.push(change);
}
// Takes the changes to the world and applies them.
pub fn commit_cells() {}
}
pub fn in_bounds(x: usize, y: usize) -> bool {