diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/sandbox.cpp | 5 | ||||
-rw-r--r-- | src/ui.cpp | 16 |
2 files changed, 16 insertions, 5 deletions
diff --git a/src/sandbox.cpp b/src/sandbox.cpp index 85a4850..d0d918c 100644 --- a/src/sandbox.cpp +++ b/src/sandbox.cpp @@ -35,11 +35,6 @@ Sandbox::Sandbox(int w, int h) , height{ h } // { memset(_bitmap.data(), 0xff, _bitmap.size() * sizeof(_bitmap[0])); - for (int y = 80; y <= 90; ++y) { - for (int x = 10; x <= 13; ++x) { - set_sand(x, y, Tile{ .so = Tile::SAND }); - } - } } static void simulate_sand_tile(Sandbox& self, int x, int y) { @@ -4,6 +4,14 @@ #include <imgui.h> +static void AddSand(Sandbox& sb) { + for (int y = 80; y <= 90; ++y) { + for (int x = 10; x <= 13; ++x) { + sb.set_sand(x, y, Tile{ .so = Tile::SAND }); + } + } +} + void ShowEverything() { ImGui::Begin("Sandbox"); constexpr int kWidth = 40; @@ -13,6 +21,14 @@ void ShowEverything() { static OglImage gl; sandbox.simulate_step(); gl.upload(reinterpret_cast<const char*>(sandbox._bitmap.data()), kWidth, kHeight); + + if (ImGui::Button("Reset sandbox")) { + sandbox = Sandbox(40, 100); + } + if (ImGui::Button("Add sand")) { + AddSand(sandbox); + } + constexpr float kScale = 4.0f; constexpr ImVec2 kSize(kWidth * kScale, kHeight * kScale); ImGui::Image(gl.as_imgui(), kSize, ImVec2(0, 1), ImVec2(1, 0)); |