-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGame.h
98 lines (82 loc) · 2.97 KB
/
Game.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
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
#ifndef GAME_H
#define GAME_H
#include <json.hpp>
#include <Thor/Resources.hpp>
#include <Thor/Animations.hpp>
#include <SFML/Graphics.hpp>
#include "Player_Action.h"
#include "Audio.h"
#include <unordered_map>
#define ANIMATOR thor::Animator<sf::RectangleShape, std::string>
using namespace sf;
using json = nlohmann::json;
class Control;
class Game
{
public:
Game(RenderWindow & _window, Audio & _audio, thor::ResourceHolder<Texture,std::string> & _textures ,
thor::ResourceHolder<Font,int> & _fonts, unsigned _offset);
void update(Time DeltaTime);
void draw(RenderTarget* target = nullptr);
void updateMouse(Vector2f position, bool F_pressed = false);
void changeSpeed(int _speed);
float getTurnTime() { return this->timeThreshold; }
void load(std::wstring logAddress);
bool setTurn(int _turn);
bool setTurn(double progress); // progress between 0 and 1
int getTurn(){return this->turn;}
int getLastTurn() { return this->totalTurns; }
void setPlaying(bool _playing);
bool getPlaying(){return playing;}
void showFullName(bool player, bool show);
protected:
private:
const sf::Color player1Theme = sf::Color(255, 176, 32);
const sf::Color player2Theme = sf::Color(0, 200, 255);
RenderWindow &window;
Audio &audio;
json json_;
thor::ResourceHolder<Texture,std::string> & textures;
RectangleShape obstacle,box,deadzone,bombMask,winnerDisplay,player[2], heart[2], playerInfo;
int rows;
int columns;
int totalTurns;
float scale;
Vector2f startPoint;
Vector2f infoSize;
const int playerInfoLeftOffset = 5;
int initialHealth;
int bombDelay;
VertexArray vertices;
VertexArray darkBackground;
sf::RenderTexture rTexture;
sf::BlendMode blendMode=sf::BlendAdd;
unsigned controlHeight;
int health[2];
int heartTextureSize;
int const fontSize=18;
int const minFontSize = 12;
Text upgrades[2], names[2], fullnames[2], extraHealth[2], winnerText;
float three_dot_width;
bool truncated[2];
bool showing_fullname[2];
int winnerIndex;
Transformable player_info_transformable[2];
int turn;
float timePassed=0;
float timeThreshold;
bool playing=false;
int speed=1;
Time end_progress = Time::Zero;
std::unordered_map<std::string,RectangleShape> shapes;
std::unordered_map<std::string,thor::FrameAnimation> animations;
std::unordered_map<std::string,ANIMATOR> animators;
float timeThresholds[4]={0,0.6,0.3,0.2};
void displayWinner(RenderTarget* target);
Vector2f getPlayerPosition(int _turn,int player);
void updatePlayer();
void updateAnimators(Time DeltaTime);
void initPlayerAnimation();
void setupTurn();
};
#endif // GAME_H