-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathState.h
71 lines (54 loc) · 1.33 KB
/
State.h
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#pragma once
#include "Player.h"
#include "GraphicsSettings.h"
class Player;
class GraphicsSettings;
class State;
class StateData {
public:
StateData();
// Variables
float gridSize;
sf::RenderWindow* window;
GraphicsSettings* gfxSettings;
std::map<std::string, int>* supportedKeys;
std::stack<State*>* states;
};
class State
{
private:
protected:
StateData* stateData;
std::stack<State*>* states;
sf::RenderWindow* window;
std::map<std::string, int>* supportedKeys;
std::map<std::string, int> keybinds;
bool quit;
bool paused;
float keytime;
float keytimeMax;
float gridSize;
sf::Vector2i mousePosScreen;
sf::Vector2i mousePosWindow;
sf::Vector2f mousePosView;
sf::Vector2i mousePosGrid;
// Resources
std::map<std::string, sf::Texture> textures;
// Functions
virtual void initKeybinds() = 0;
public:
State(StateData* state_data);
virtual ~State();
// Accessors
const bool& getQuit() const;
const bool getKeytime();
// Functions
void endState();
void pauseState();
void unpauseState();
virtual void updateMousePositions(sf::View* view = NULL);
virtual void updateKeytime(const float& dt);
virtual void updateInput(const float& dt) = 0;
virtual void update(const float& dt) = 0;
virtual void render(sf::RenderTarget* target = NULL) = 0;
};