-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameState.h
More file actions
111 lines (90 loc) · 2.46 KB
/
Copy pathGameState.h
File metadata and controls
111 lines (90 loc) · 2.46 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
#pragma once
#include "State.h"
#include "Selector.h"
#include "PauseMenu.h"
#include "Caption.h"
enum Team : uint32_t
{
White = 0,
Black,
None
};
class GameState :
public State
{
private:
sf::View view;
sf::Vector2i viewGridPosition;
sf::RenderTexture renderTexture;
sf::Sprite renderSprite;
sf::Font font;
bool buttonPressed;
bool gameOver;
uint32_t wonTeam;
// GUI
gui::Selector selector;
PauseMenu* pauseMenu;
gui::Caption textWin;
gui::Caption textLose;
// Shader
sf::Shader coreShader;
// Figures
static const uint32_t teams = 2;
static const uint32_t figures = 9;
static const size_t positions = 4;
Pawn* pawn[teams][figures];
Pawn* selectedPawn[teams];
uint32_t lastSelectedIndex[teams];
sf::Vector2f chosenPosition[teams];
std::vector<sf::Vector2f> allowedPositions[teams];
sf::Vector2f direction[teams];
sf::Vector2f directionNormalized[teams];
// Turn
uint32_t turn;
uint32_t turnLast;
sf::Clock turnTimer;
float turnTimerMax;
sf::Clock exitTimer;
float exitTimerMax;
// Map
TileMap* tileMap;
static const uint32_t tiles = 9;
std::map<const Team, Tile*[tiles]> teamTile;
// FPS counter:
sf::Text fps;
// private: Functions:
void initVariables();
void initDefferedRender();
void initView();
void initPauseMenu();
void initShaders();
void initFigures();
void initTileMap();
void initGui();
void initSound();
public:
// Constructor and Destructor:
GameState(StateData* state_data, gui::FadeScreen* fade_screen, sfx::SoundEngine* sound_engine);
virtual ~GameState();
// Functions:
void endTurn();
void switchTurn();
void updateView(const float& dt);
void updateInput(const float& dt);
void updatePlayerInput(const float& dt);
void updateInputAI(const float& dt);
void updateTimerTurn();
void updatePauseMenuButtons(const float& dt);
void uodateTileMap(const float& dt);
void updateAllowedMovement(const float& dt);
void updateAllowedMovementAI(const float& dt);
void updateGui(const float& dt);
void updateMovement(const float& dt);
void updateMovementAI(const float& dt);
void updateFigures(const float& dt);
void updateGameOver(const float& dt);
void update(const float& dt);
void renderFigures();
void renderGui(sf::RenderTarget* target);
void render(sf::RenderTarget* target = nullptr);
};