-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathState.h
More file actions
141 lines (96 loc) · 2.95 KB
/
State.h
File metadata and controls
141 lines (96 loc) · 2.95 KB
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#pragma once
#include "Player.h"
#include "GraphicsSettings.h"
//enum MOUSE_POSITION_STATES
//{
// MOUSE_SCREEN = 1,
// MOUSE_WINDOW,
// MOUSE_VIEW
//};
class State;
class StateData
{
public:
//Constructors and Distructor: //No distructor
// 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;
sf::Clock keyTimer;
float keyTimeMax;
float gridSize;
sf::Texture logoTexture;
sf::Sprite logoSprite;
sf::Vector2i mousePositionScreen;
sf::Vector2i mousePositionWindow;
sf::Vector2f mousePositionView;
sf::Vector2i mousePositionGrid;
sf::Font systemFont;
sf::Text mousePositionTextX;
sf::Text mousePositionTextY;
sf::Text fpsCounterText;
//Resources:
std::map<const int, sf::Texture> textures;
//TEST TEXTURES
std::map<const int, std::map<const int, sf::Texture>> playerTextures;
std::map<const int, std::map<const int, sf::Texture>> enemyTextures;
std::map<const int, std::map<const int, sf::Texture>> bossTextures;
/*
//EXAMPLE:
playerTextures[Players::PlayerOne][TextureSheets::Idle] = sf::Texture();
playerTextures[Players::PlayerOne][TextureSheets::Move] = sf::Texture();
enemyTextures[Enemies::Rat][TextureSheets::Idle] = sf::Texture();
enemyTextures[Enemies::Rat][TextureSheets::Move] = sf::Texture();
bossTextures[Enemies::Fly][TextureSheets::Idle] = sf::Texture();
bossTextures[Enemies::Fly][TextureSheets::Move] = sf::Texture();
*/
// Sound engine:
sfx::SoundEngine soundEngine;
// protected: Functions
void initKeybinds(const std::string& file_path);
void initFont(sf::Font& font, const std::string& file_path);
void initTexture(const int& index, const std::string& file_path);
void initKeyTime();
// Debug:
// Debug function.
// Initializes mouse position text.
void initMousePositionText();
void initFpsCounter();
public:
// Constructors and Destructor:
State(StateData* state_data);
virtual ~State();
// Accessors:
const bool& getQuit() const;
// Returns TRUE is key timer reaches the maximum value in seconds, otherwise returns FALSE.
const bool getKeyTime();
// Returns TRUE is key timer reaches the maximum value in seconds, otherwise returns FALSE.
const bool getKeyTime(const float key_time_max);
// Functions:
void endState();
void pauseState();
void unpauseState();
void updateMousePositionText();
void updateFpsCounter(const float& dt);
virtual void updateMousePositions(sf::View* view = nullptr);
virtual void updateInput(const float& dt) = 0;
virtual void update(const float& dt) = 0;
void renderMousePositionText(sf::RenderTarget* target);
void renderFpsCounter(sf::RenderTarget* target);
virtual void render(sf::RenderTarget* target = nullptr) = 0;
};