diff options
-rw-r--r-- | src/sandbox.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/sandbox.cpp b/src/sandbox.cpp index 27cd654..ccfde52 100644 --- a/src/sandbox.cpp +++ b/src/sandbox.cpp @@ -28,7 +28,7 @@ Sandbox::Sandbox(int w, int h) , height{ h } // { memset(_bitmap.data(), 0xff, _bitmap.size() * sizeof(_bitmap[0])); - set_sand(10, 10, Tile{ .so = Tile::SAND }); + set_sand(10, 80, Tile{ .so = Tile::SAND }); } static void simulate_sand_tile(Sandbox& self, int x, int y) { @@ -50,7 +50,7 @@ static void simulate_sand_tile(Sandbox& self, int x, int y) { self.set_sand(x, y, below); self.set_sand(x, y - 1, at0); } else { - Pt loc1[]{ Pt(x - 1, y + 1), Pt(x + 1, y + 1) }; + Pt loc1[]{ Pt(x - 1, y - 1), Pt(x + 1, y - 1) }; auto bound = 2; auto which = self._pcg.next_u32(bound); for (int i = 0; i < bound; ++i) { @@ -85,8 +85,9 @@ static void simulate_sand_tile(Sandbox& self, int x, int y) { } void Sandbox::simulate_step() { - _x = _y = 0; - for (; _y < height; ++_y) { + _x = 0; + _y = height ; + for (; _y >= 0; --_y) { for (; _x < width; ++_x) { simulate_sand_tile(*this, _x, _y); } @@ -105,7 +106,7 @@ void Sandbox::set_sand(int x, int y, Tile sand) { auto& target = _a[y * width + x]; target = sand; // Set update bit if the target is after cursor - if (y > _y || x > _x) + if (y < _y || x > _x) target.updated = true; _bitmap[y * width + x] = sand.get_color(); } |