summary refs log tree commit diff
path: root/src/Entities/Player.hpp
diff options
context:
space:
mode:
authorMel <einebeere@gmail.com>2023-08-06 04:27:07 +0200
committerMel <einebeere@gmail.com>2023-08-06 04:27:07 +0200
commit5a1b126f1f6d55226c2b5068d0c17c428fd29ba8 (patch)
tree3acc0240cd8dedd0764eeae6df04e134b04584c8 /src/Entities/Player.hpp
parente6f5f9e03f673db796f1babb308609ca2576db2f (diff)
downloadmeowcraft-5a1b126f1f6d55226c2b5068d0c17c428fd29ba8.tar.zst
meowcraft-5a1b126f1f6d55226c2b5068d0c17c428fd29ba8.zip
Create separate Player entity and add bad collision system
Diffstat (limited to 'src/Entities/Player.hpp')
-rw-r--r--src/Entities/Player.hpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/Entities/Player.hpp b/src/Entities/Player.hpp
new file mode 100644
index 0000000..86d8c90
--- /dev/null
+++ b/src/Entities/Player.hpp
@@ -0,0 +1,40 @@
+#pragma once
+
+#include "../Time.hpp"
+#include "../Transform.hpp"
+#include "../GFX/Camera.hpp"
+#include "../World/World.hpp"
+#include "../GFX/Window.hpp"
+#include "../Math/AABB.hpp"
+#include "../Math/Rotation.hpp"
+#include "../World/Position.hpp"
+
+namespace MC::Entities {
+
+class Player {
+public:
+    explicit Player(Position::World position) : m_transform(position) {}
+
+    void update(const Time& time, GFX::Window& window, GFX::Camera& camera, World::World& world);
+
+    void move(Position::WorldOffset by);
+    void move_to(Position::World to);
+
+    void rotate(Rotation by);
+    void rotate_to(Rotation to);
+
+    AABB bounds() const;
+private:
+    void update_camera_position(GFX::Camera& camera);
+
+    static Bool collides_with_terrain(Position::World new_position, World::World& world);
+
+    // Creates a bounding box where `position` is at the center of the bottom face.
+    static AABB bounding_box_for_position(Position::World position);
+
+    Transform m_transform;
+
+    static inline AABB s_bounds{{0.35, 1.8, 0.35}};
+};
+
+}