-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGame.h
More file actions
53 lines (46 loc) · 1.43 KB
/
Game.h
File metadata and controls
53 lines (46 loc) · 1.43 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
#pragma once
#include <iostream>
#include <string>
#include <sfml/Graphics.hpp>
#include "EntityManager.h"
#include "Entity.h"
struct PlayerConfig { int SR, CR, FR, FG, FB, OR, OG, OB, OT, V; float S; };
struct BulletConfig { int SR, CR, OR, OG, OB, OT, VMIN, VMAX, L, SI; float SMIN, SMAX; };
struct EnemyConfig { int SR, CR, FR, FG, FB, OR, OG, OB, OT, V, L; float S; };
class Game
{
sf::RenderWindow m_window;
EntityManager m_entities;
sf::Font m_font;
sf::Text m_scoreText;
sf::Text m_gameOverText;
PlayerConfig m_playerConfig;
EnemyConfig m_enemyConfig;
BulletConfig m_bulletConfig;
int m_score = 0;
int m_life = 3;
int m_currentFrame = 0;
int m_lastEnemySpawnTime = 0;
bool m_paused = false;//whether we upate game logic
bool m_running = true;//whether the game is running
bool m_gameOver = false;
std::shared_ptr<Entity> m_player;
void init(const std::string& config);//init the GameState with a config file path
void setPaused(bool paused); // pause the game
//System
void sMovement();
void sUserInput();
void sLifespan();
void sRender();
void sEnemySpawner();
void sCollision();
void restartGame();
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);
public:
Game(const std::string& config);//constructor, takes in game config
void run();
};