-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGame.h
95 lines (76 loc) · 1.49 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
#pragma once
#include <iostream>
#include <vector>
#include <ctime>
#include <sstream>
#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
#include <SFML/Window.hpp>
#include <SFML/Audio.hpp>
#include <SFML/Network.hpp>
/*
Class that acts like a game engine.
Wrapper class.
*/
class Game
{
private:
//Variables
//Window
sf::RenderWindow* window;
sf::VideoMode videoMode;
sf::Event ev;
//Mouse positions
sf::Vector2i mousePosWindow;
sf::Vector2f mousePosView;
//Resoueces
sf::Font font;
sf::Font fontPoints;
sf::Font fontHealth;
//Text
sf::Text uiText;
sf::Text uiTextPoints;
sf::Text uiTextHealth;
//Colors
sf::Color color;
sf::Color VeryHard;
sf::Color Hard;
sf::Color Medium;
sf::Color Easy;
sf::Color VeryEasy;
//Game logic
bool endGame;
unsigned points;
int health;
float enemySize;
float enemySpawnTimer;
float enemySpawnTimerMax;
int maxEnemies;
bool mouseHeld;
//Game objects
std::vector<sf::RectangleShape> enemies;
sf::RectangleShape enemy;
//Private functions
void InitVariables();
void InitWindow();
void InitFonts();
void InitText();
void InitEnemies();
public:
//Constructors and Distructors
Game();
virtual ~Game();
//Accessors
const bool running() const;
const bool getEndGame() const;
//Functions
void spawnEnemy();
void pollEvents();
void updateMousePositions();
void updateText();
void updateEnemies();
void update();
void renderText(sf::RenderTarget& target);
void renderEnemies(sf::RenderTarget& target);
void render();
};