summaryrefslogtreecommitdiffhomepage
path: root/editor/update.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2022-10-23 17:31:31 +0200
committerStanislaw Halik <sthalik@misaki.pl>2022-10-23 17:31:31 +0200
commitcce1f768e7399b838a2b865511915bdd576dbbf4 (patch)
tree4c6a8f2dc9112394fd329d56c0f628ce66b16467 /editor/update.cpp
parent6b875a0919b9932eca9ed877552c34ecb220b7d8 (diff)
a
Diffstat (limited to 'editor/update.cpp')
-rw-r--r--editor/update.cpp55
1 files changed, 55 insertions, 0 deletions
diff --git a/editor/update.cpp b/editor/update.cpp
new file mode 100644
index 00000000..ebd1881b
--- /dev/null
+++ b/editor/update.cpp
@@ -0,0 +1,55 @@
+#include "app.hpp"
+
+namespace floormat {
+
+//#define FM_NO_BINDINGS
+
+void app::make_test_chunk(chunk& c)
+{
+ constexpr auto N = TILE_MAX_DIM;
+ for (auto [x, k, pt] : c) {
+#if defined FM_NO_BINDINGS
+ const auto& atlas = floor1;
+#else
+ const auto& atlas = pt.x != pt.y && (pt.x == N/2 || pt.y == N/2) ? floor2 : floor1;
+#endif
+ x.ground_image = { atlas, k % atlas->num_tiles() };
+ }
+#ifdef FM_NO_BINDINGS
+ const auto& wall1 = floor1, wall2 = floor1;
+#endif
+ constexpr auto K = N/2;
+ c[{K, K }].wall_north = { wall1, 0 };
+ c[{K, K }].wall_west = { wall2, 0 };
+ c[{K, K+1}].wall_north = { wall1, 0 };
+ c[{K+1, K }].wall_west = { wall2, 0 };
+}
+
+void app::do_mouse_click(const global_coords pos, int button)
+{
+ if (button == SDL_BUTTON_LEFT)
+ _editor.on_click(_world, pos);
+ else
+ _editor.on_release();
+}
+
+void app::do_mouse_release(int button)
+{
+ (void)button;
+ _editor.on_release();
+}
+
+void app::do_mouse_move(global_coords pos)
+{
+ _editor.on_mouse_move(_world, pos);
+}
+
+void app::update(double dt)
+{
+ do_camera(dt);
+ draw_ui();
+ if (keys[key::quit])
+ Platform::Sdl2Application::exit(0);
+}
+
+} // namespace floormat