-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGame.h
More file actions
80 lines (62 loc) · 1.7 KB
/
Copy pathGame.h
File metadata and controls
80 lines (62 loc) · 1.7 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
#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>
/*
author: miaf
license: MIT License
*/
//Game engine
class Game
{
private:
sf::RenderWindow* window;
sf::VideoMode videoMode;
sf::Event ev;
sf::Vector2i mousePosWindow;
sf::Vector2f mousePosView;
sf::Font font;
sf::Text uiText;
bool endGame;
unsigned points;
int health;
float enemySpawnTimer;
float enemySpawnTimerMax;
int maxEnemies;
float foodSpawnTimer;
float foodSpawnTimerMax;
int maxFoods;
bool mouseHeld;
std::vector<sf::RectangleShape> enemies;
std::vector<sf::RectangleShape> foods;
sf::RectangleShape enemy;
sf::RectangleShape food;
void initVariables();
void initWindow();
void initFonts();
void initText();
void initFood();
void initEnemies();
public:
Game();
virtual ~Game();
const bool isRunning() const;
const bool getEndGame() const;
void spawnEnemy();
void spawnFood();
void pollEvents();
void updateMousePositions();
void updateText();
void updateEnemies();
void updateFood();
void update();
void renderText(sf::RenderTarget& target);
void renderEnemies(sf::RenderTarget& target);
void renderFood(sf::RenderTarget& target);
void render();
};