blob: f356afa5fff07ee492b0ab49e52dd16770349194 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
#include "ui.hpp"
#include "ogl.hpp"
#include "sandbox.hpp"
#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;
constexpr int kHeight = 100;
static bool running = false;
static Sandbox sandbox(40, 100);
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));
ImGui::End();
ImGui::ShowDemoWindow();
}
|