-
Notifications
You must be signed in to change notification settings - Fork 0
/
Game.h
66 lines (55 loc) · 1.61 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
#pragma once
#include "Entity.h"
#include "EntityManager.h"
#include <SFML/Graphics.hpp>
struct PlayerConfig
{
int SR, CR, FR, FG, FB, OR, OG, OB, OT, V;
float S;
};
struct EnemyConfig
{
int SR, CR, OR, OG, OB, OT, VMIN, VMAX, L, SI;
float SMIN, SMAX;
};
struct BulletConfig
{
int SR, CR, FR, FG, FB, OR, OG, OB, OT, V, L;
float S;
};
class Game
{
sf::RenderWindow m_window;
EntityManager m_entities; // vector of entities to maintain
sf::Font m_font;
sf::Text m_text;
PlayerConfig m_playerConfig;
EnemyConfig m_enemyConfig;
BulletConfig m_bulletConfig;
int m_score = 0;
int m_currentFrame = 0;
int m_lastEnemySpawnTime = 0;
bool m_paused = false; // whether we update game logic
bool m_running = true; // whether we continue to run the game loop
bool m_weaponAvailable = true;
int m_weaponCooldown = 120;
int m_weaponCooldownTimer = 0;
std::shared_ptr<Entity> m_player;
void init(const std::string &config); // initialize the GameState with a config file path
void setPaused(bool paused); // set the paused state of the game
void sMovement();
void sUserInput();
void sLifespan();
void sRender();
void sEnemySpawner();
void sCollision();
void spawnPlayer();
void spawnEnemy();
void spawnSmallEnemies(std::shared_ptr<Entity> entity);
void spawnBullet(std::shared_ptr<Entity> entity, const Vec2 &mousePos);
void spawnSpecialWeapon(std::shared_ptr<Entity> entity);
void PlayerBounds();
public:
Game(const std::string &config); // constructor, takes in game config
void run();
};