-
Notifications
You must be signed in to change notification settings - Fork 0
/
Game.h
93 lines (79 loc) · 1.66 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
#include<iostream>
#include <SFML/Graphics.hpp>
#include<SFML/Audio.hpp>
#include<vector>
#include<ctime>
#include<sstream>
/*
* class that acts as the game engine
* wrapper class...
*/
#pragma once
class Game
{
private:
//private variables
// window
// Existing member variables...
sf::Texture asteroidTexture;
std::vector<sf::Sprite> asteroids;
sf::RenderWindow *window;
sf::Event ev;
sf::VideoMode videomode;
sf::Texture backgroundTexture;
sf::Sprite backgroundSprite;
//resources
sf::Font font;
//Text
sf::Text uiText;
sf::Text gameOverText;
sf::Text tryagainText;
//Mouse Positions
sf::Vector2i mousePosWindow;
sf::Vector2f mousePosView;
//View
sf::View backgroundView;
sf::Sprite backgroundSprite1;
sf::Sprite backgroundSprite2;
//audio
sf::SoundBuffer asteroidClickBuffer;
sf::Sound asteroidClickSound;
// ... other private members ...
// Game Logic
bool endgame;
unsigned points;
int health;
float enemySpawnTimer;
float enemySpawnTimerMax;
int maxEnemies;
bool MouseHold;
float backgroundVelocity;
//Game objects
std::vector<sf::RectangleShape> enemies;
sf::RectangleShape enemy;
//privte functions
void initVariables();
void initWindow();
void initFonts();
void inittext();
void initEnemies();
void initBackground();
void initAudio();
public:
// constructors and destructors
Game();
virtual ~Game();
// accessors
const bool running() const;
const bool getEndgame() const;
//Functions
void spawnEnemy();
void PollEvents();
void UpdateMousePos();
void updateText();
void UpdateEnemies();
void Update();
void renderText(sf:: RenderTarget& target);
void RenderEnemies(sf::RenderTarget& target);
void Render();
};