aboutsummaryrefslogtreecommitdiff
path: root/src/ui.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui.cpp')
-rw-r--r--src/ui.cpp16
1 files changed, 16 insertions, 0 deletions
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 <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));