From 152580faf7e7665a04be69b4a0e0538cf39c975c Mon Sep 17 00:00:00 2001 From: rtk0c Date: Sat, 17 May 2025 17:35:11 -0700 Subject: Interactive buttons --- src/ui.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/ui.cpp') diff --git a/src/ui.cpp b/src/ui.cpp index fdb9eee..f356afa 100644 --- a/src/ui.cpp +++ b/src/ui.cpp @@ -4,6 +4,14 @@ #include +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(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)); -- cgit v1.2.3-70-g09d2