From f138311d2d2e0cc9ba0496d523bb46f2c1c9fb73 Mon Sep 17 00:00:00 2001 From: rtk0c Date: Wed, 20 Sep 2023 23:58:58 -0700 Subject: Copy from the PlasticSCM repo, replace vendored glm wtih conan --- source/30-game/Player.hpp | 59 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 source/30-game/Player.hpp (limited to 'source/30-game/Player.hpp') diff --git a/source/30-game/Player.hpp b/source/30-game/Player.hpp new file mode 100644 index 0000000..5a6bab7 --- /dev/null +++ b/source/30-game/Player.hpp @@ -0,0 +1,59 @@ +#pragma once + +#include "GameObject.hpp" +#include "Material.hpp" +#include "Sprite.hpp" + +#include +#include + +#define GLFW_INCLUDE_NONE +#include + +#include +#include + +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 GetKeyArray(); + std::span GetKeyStatusArray(); +}; + +class Player : public GameObject { + BRUSSEL_CLASS() + +public: + std::vector 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 GetRenderObjects() const override; + + int GetId() const { return mId; } + + void HandleKeyInput(int key, int action); + + // File is designated by player ID + bool LoadFromFile(); + bool SaveToFile(); +}; -- cgit v1.2.3-70-g09d2