aboutsummaryrefslogtreecommitdiff
path: root/source/Player.hpp
blob: db8be33f5f182ed89e4572eab338b2a77d3b3e6c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#pragma once

#include "GameObject.hpp"
#include "GameObjectTypeTag.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 PlayerVisual {
public:
};

class Player : public GameObject {
public:
	std::vector<GLFWkeyboard*> boundKeyboards;
	PlayerKeyBinds keybinds;
	PlayerVisual visuals;
	int mId;

public:
	Player(GameWorld* world, int id);

	virtual Tags::GameObjectType GetTypeTag() const override { return Tags::GOT_Player; }

	virtual void Awaken() override;
	virtual void Resleep() override;
	virtual void Update() override;

	int GetId() const { return mId; }

	void HandleKeyInput(int key, int action);

	// File is designated by player ID
	bool LoadFromFile();
	bool SaveToFile();
};