aboutsummaryrefslogtreecommitdiff
path: root/source/30-game/Player.hpp
diff options
context:
space:
mode:
authorrtk0c <[email protected]>2022-05-30 17:03:20 -0700
committerrtk0c <[email protected]>2022-05-30 17:03:20 -0700
commite66286ebe30afc9acc4531fc2bea29b7fb924f93 (patch)
treefa6b76554c3eb88bc8f088fbab68e20c40118ca7 /source/30-game/Player.hpp
parent366ef5a5450c6e0e680c924c3454943a9ae9814d (diff)
Changeset: 56 Buildsystem cleanup: change to layered structure for different targets
Diffstat (limited to 'source/30-game/Player.hpp')
-rw-r--r--source/30-game/Player.hpp55
1 files changed, 55 insertions, 0 deletions
diff --git a/source/30-game/Player.hpp b/source/30-game/Player.hpp
new file mode 100644
index 0000000..d003a25
--- /dev/null
+++ b/source/30-game/Player.hpp
@@ -0,0 +1,55 @@
+#pragma once
+
+#include "GameObject.hpp"
+#include "Material.hpp"
+#include "RcPtr.hpp"
+#include "Sprite.hpp"
+
+#define GLFW_INCLUDE_NONE
+#include <GLFW/glfw3.h>
+
+#include <span>
+#include <vector>
+
+struct PlayerKeyBinds {
+ int keyLeft = GLFW_KEY_A;
+ int keyRight = GLFW_KEY_D;
+ int keyJump = GLFW_KEY_SPACE;
+ int keyAttack = GLFW_KEY_J;
+
+ bool pressedLeft = 0;
+ bool pressedRight = 0;
+ bool pressedJump = 0;
+ bool pressedAttack = 0;
+
+ std::span<int> GetKeyArray();
+ std::span<bool> GetKeyStatusArray();
+};
+
+class Player : public GameObject {
+public:
+ std::vector<GLFWkeyboard*> boundKeyboards;
+ PlayerKeyBinds keybinds;
+ Sprite sprite;
+ RenderObject renderObject;
+ int mId;
+
+public:
+ Player(GameWorld* world, int id);
+
+ virtual void Awaken() override;
+ virtual void Resleep() override;
+ virtual void Update() override;
+
+ Material* GetMaterial() const;
+ void SetMaterial(Material* material);
+ virtual std::span<const RenderObject> GetRenderObjects() const override;
+
+ int GetId() const { return mId; }
+
+ void HandleKeyInput(int key, int action);
+
+ // File is designated by player ID
+ bool LoadFromFile();
+ bool SaveToFile();
+};