summaryrefslogtreecommitdiffhomepage
path: root/main/app.hpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2022-10-08 22:01:19 +0200
committerStanislaw Halik <sthalik@misaki.pl>2022-10-08 22:01:19 +0200
commitdf73742cdd427e68057603746864abd3d2b545c2 (patch)
treeaa3bf00f57318feafe271d504d051cda4602836f /main/app.hpp
parent4c151b5d580e6c855f05583a04fbf5e4220e11cf (diff)
a
Diffstat (limited to 'main/app.hpp')
-rw-r--r--main/app.hpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/main/app.hpp b/main/app.hpp
new file mode 100644
index 00000000..4cea0a32
--- /dev/null
+++ b/main/app.hpp
@@ -0,0 +1,53 @@
+#pragma once
+#include "tile-atlas.hpp"
+#include "chunk.hpp"
+#include "shaders/tile-shader.hpp"
+#include "src/loader.hpp"
+#include "floor-mesh.hpp"
+#include "wall-mesh.hpp"
+#include "compat/enum-bitset.hpp"
+#include <Magnum/Timeline.h>
+#include <Magnum/Platform/Sdl2Application.h>
+#include <memory>
+
+namespace Magnum::Examples {
+
+struct app final : Platform::Application
+{
+ using dpi_policy = Platform::Implementation::Sdl2DpiScalingPolicy;
+ using tile_atlas_ = std::shared_ptr<tile_atlas>;
+
+ explicit app(const Arguments& arguments);
+ virtual ~app();
+ void drawEvent() override;
+ void update(float dt);
+ void do_camera(float dt);
+ void reset_camera_offset();
+ void keyPressEvent(KeyEvent& event) override;
+ void keyReleaseEvent(KeyEvent& event) override;
+ void do_key(KeyEvent::Key k, KeyEvent::Modifiers m, bool pressed, bool repeated);
+ void draw_chunk(chunk& c);
+ void update_window_scale();
+
+ enum class key : int {
+ camera_up, camera_left, camera_right, camera_down, camera_reset,
+ quit,
+ MAX
+ };
+ chunk make_test_chunk();
+
+ tile_shader _shader;
+ tile_atlas_ floor1 = loader.tile_atlas("share/game/images/metal1.tga", {2, 2});
+ tile_atlas_ floor2 = loader.tile_atlas("share/game/images/floor1.tga", {4, 4});
+ tile_atlas_ wall1 = loader.tile_atlas("share/game/images/wood2.tga", {2, 2});
+ tile_atlas_ wall2 = loader.tile_atlas("share/game/images/wood1.tga", {2, 2});
+ chunk _chunk = make_test_chunk();
+ floor_mesh _floor_mesh;
+ wall_mesh _wall_mesh;
+
+ Vector2 camera_offset;
+ enum_bitset<key> keys;
+ Magnum::Timeline timeline;
+};
+
+} // namespace Magnum::Examples