-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGame.h
175 lines (136 loc) · 3.76 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
//
// Created by Athos Innocenti on 30/10/2018.
//
#ifndef FLYJOYRIDE_GAME_H
#define FLYJOYRIDE_GAME_H
#include <list>
#include <string>
#include <fstream>
#include "SFML/Graphics.hpp"
#include "SFML/Audio.hpp"
#include "BlockFactory.h"
#include "EnemyFactory.h"
#include "Subject.h"
#include "Block.h"
#include "Enemy.h"
#include "Window.h"
#include "Character.h"
class Game : public Subject {
public:
Game();
~Game();
void update();
void render();
void handleText();
Window *GetWindow() { return &window; };
void shoot();
void moveBullet();
void movePlayer();
void createBullet();
void moveEnemyBullet();
void createEnemyBullet();
void collision();
void createObjects();
void moveObject();
void deleteObject();
int random(int limit);
void fireAnimation();
// funzioni getter
int getMaxY() const;
unsigned int getScore() const;
float getCreationRate() const;
unsigned int getKilled() const;
static const float getShootTime();
static const float getLevelGround();
static const float getBulletSpeed();
const sf::Vector2f &getSpeed() const;
static const float getRateIncreaser();
static const float getSpeedIncreaser();
const sf::Vector2i &getWindowSize() const;
const std::vector<sf::CircleShape> &getBullets() const;
// funzioni per observer
void setScore(unsigned int score);
void setKilled(unsigned int killed);
void notify() override;
void unsubscribe(Observer *o) override;
void subscribe(Observer *o) override;
void setAchievementString(sf::String string);
private:
std::ofstream file;
Window window;
Character player;
BlockFactory factoryB;
EnemyFactory factoryE;
std::list<Observer*> observers;
sf::Music music;
sf::Sound shootSound;
sf::Sound enemyDeadSound;
sf::Sound powerUpSound;
sf::SoundBuffer shootBuffer;
sf::SoundBuffer enemyDeadBuffer;
sf::SoundBuffer powerUpBuffer;
sf::Clock scoreClock;
sf::Clock playerClock;
sf::Clock fireClock;
sf::Clock speedClock;
sf::Clock objectClock;
sf::Clock defectClock;
sf::Clock controlPowerUp;
sf::Clock enemyClock;
sf::Vector2i windowSize;
sf::Vector2f speed;
sf::Vector2f oldSpeed;
sf::CircleShape bullet;
sf::Sprite background;
sf::Sprite fireSprite;
sf::Font font1;
sf::Font font2;
sf::Text scoreText;
sf::Text gameOver;
sf::Text achievementText;
sf::Text text;
sf::Texture backgroundTexture;
sf::Texture playerTexture1;
sf::Texture playerTexture2;
sf::Texture puPlayerTexture1;
sf::Texture puPlayerTexture2;
sf::Texture dePlayerTexture1;
sf::Texture dePlayerTexture2;
sf::Texture fireTexture1;
sf::Texture fireTexture2;
sf::Texture fEnemyTexture;
sf::Texture sEnemyTexture;
std::vector<sf::CircleShape> bullets;
std::vector<sf::CircleShape> enemyBullets;
std::vector<std::unique_ptr<Block>> blocks;
std::vector<std::unique_ptr<Enemy>> enemies;
int maxY;
int n;
int count;
int blockX;
int counter;
int textCount;
int tollerance;
float g;
float jump;
float creationRate;
bool isCreated;
bool isDefectOn;
bool isPowerUpOn;
bool speedPowerUp;
bool isEnemyCreated;
unsigned int score;
unsigned int killed;
static const int randomCreation;
static const int randomPowerUp;
static const int textSize;
static const float shootTime;
static const float bulletSpeed;
static const float rateIncreaser;
static const float speedIncreaser;
static const float levelGround;
static const unsigned int creationLimit;
static const unsigned int speedMultiplier;
static const float speedLimit;
};
#endif //FLYJOYRIDE_GAME_H