-
Notifications
You must be signed in to change notification settings - Fork 0
/
TitleScreen.cpp
347 lines (307 loc) · 16.2 KB
/
TitleScreen.cpp
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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
#include "TitleScreen.h"
TitleScreen::TitleScreen(sf::Font* fontTitre, sf::Font* fontPixel, sf::RenderWindow* window) {
this->titre = new sf::Text();
this->titre->setCharacterSize(80);
this->titre->setFillColor(sf::Color::Yellow);
this->titre->setFont(*fontTitre);
this->titre->setString("FAR WEST");
sf::FloatRect titreRect = this->titre->getLocalBounds();
this->titre->setOrigin(titreRect.left + titreRect.width / 2.0f,
titreRect.top + titreRect.height / 2.0f);
this->titre->setPosition(sf::Vector2f(window->getSize().x / 2.0f, window->getSize().y / 2.8f));
this->credits = new sf::Text;
this->credits->setFont(*fontPixel);
this->credits->setCharacterSize(30);
this->credits->setFillColor(sf::Color::Red);
this->credits->setString("ANTOINE DEYRIS VOUS PRESENTE");
sf::FloatRect creditsRect = this->credits->getLocalBounds();
this->credits->setOrigin(creditsRect.left + creditsRect.width / 2.0f,
creditsRect.top + creditsRect.height / 2.0f);
this->credits->setPosition(sf::Vector2f(window->getSize().x / 2.0f, window->getSize().y / 6.0f));
this->version = new sf::Text;
this->version->setFont(*fontPixel);
this->version->setCharacterSize(25);
this->version->setFillColor(sf::Color::White);
this->version->setString("version BETA");
sf::FloatRect verRect = this->version->getLocalBounds();
this->version->setOrigin(verRect.left + verRect.width / 2.0f,
verRect.top + verRect.height / 2.0f);
this->version->setPosition(sf::Vector2f(window->getSize().x / 2.0f, window->getSize().y / 2.0f));
this->trigger = new sf::Text;
this->trigger->setFont(*fontPixel);
this->trigger->setCharacterSize(35);
this->trigger->setFillColor(sf::Color::Yellow);
this->trigger->setString("APPUYEZ SUR [ESPACE] POUR COMMENCER\n OU SUR [R] POUR LIRE LES REGLES");
sf::FloatRect textRect = this->trigger->getLocalBounds();
this->trigger->setOrigin(textRect.left + textRect.width / 2.0f,
textRect.top + textRect.height / 2.0f);
this->trigger->setPosition(sf::Vector2f(window->getSize().x / 2.0f, 5 * (window->getSize().y / 6.0f)));
this->aide = new sf::Text();
this->wait = new sf::Text();
//this->tip = new sf::Text();
this->fin = new sf::Text();
}
void TitleScreen::afficherTitre(sf::RenderWindow* window, sf::Font* fontTitre, sf::Font* fontPixel) {
this->titre->setFont(*fontTitre);
this->version->setFont(*fontPixel);
this->trigger->setFont(*fontPixel);
this->credits->setFont(*fontPixel);
window->draw(*this->titre);
window->draw(*this->trigger);
window->draw(*this->credits);
window->draw(*this->version);
}
void TitleScreen::afficherAide(sf::RenderWindow* window, sf::Font* fontTitre, sf::Font* fontPixel) {
this->aide->setCharacterSize(40);
this->aide->setFillColor(sf::Color::Red);
this->aide->setFont(*fontPixel);
this->aide->setString("Bienvenue dans");
sf::FloatRect aideRect = this->aide->getLocalBounds();
this->aide->setOrigin(aideRect.left + aideRect.width / 2.0f,
aideRect.top + aideRect.height / 2.0f);
this->aide->setPosition(sf::Vector2f(window->getSize().x / 2.0f, 35.0));
window->draw(*this->aide);
this->aide->setCharacterSize(40);
this->aide->setFillColor(sf::Color::Yellow);
this->aide->setFont(*fontTitre);
this->aide->setString("Far West");
aideRect = this->aide->getLocalBounds();
this->aide->setOrigin(aideRect.left + aideRect.width / 2.0f,
aideRect.top + aideRect.height / 2.0f);
this->aide->setPosition(sf::Vector2f(window->getSize().x / 2.0f, 100.0));
window->draw(*this->aide);
this->aide->setCharacterSize(25);
this->aide->setFillColor(sf::Color::Yellow);
this->aide->setFont(*fontPixel);
this->aide->setString(" Votre but est de sortir d'une ville immense perdue en plein\nFar West ! Mais de nombreux obstacles vous barreront la route !\n\nVous partez du sud de la ville et vous devez sortir par le nord.\n Si vous sortez par l'ouest, vous reviendrez par l'est\n et inversement.");
aideRect = this->aide->getLocalBounds();
this->aide->setOrigin(aideRect.left + aideRect.width / 2.0f,
aideRect.top + aideRect.height / 2.0f);
this->aide->setPosition(sf::Vector2f(window->getSize().x / 2.0f, 230.0));
window->draw(*this->aide);
this->aide->setCharacterSize(30);
this->aide->setFillColor(sf::Color::Red);
this->aide->setFont(*fontPixel);
this->aide->setString("Le Soleil vous indiquera toujours le sud.");
aideRect = this->aide->getLocalBounds();
this->aide->setOrigin(aideRect.left + aideRect.width / 2.0f,
aideRect.top + aideRect.height / 2.0f);
this->aide->setPosition(sf::Vector2f(window->getSize().x / 2.0f, 345.0));
window->draw(*this->aide);
this->aide->setCharacterSize(25);
this->aide->setFillColor(sf::Color::Yellow);
this->aide->setFont(*fontPixel);
this->aide->setString("Vous perdez la partie si :");
aideRect = this->aide->getLocalBounds();
this->aide->setOrigin(aideRect.left + aideRect.width / 2.0f,
aideRect.top + aideRect.height / 2.0f);
this->aide->setPosition(sf::Vector2f(window->getSize().x / 2.0f, 410.0));
window->draw(*this->aide);
this->aide->setCharacterSize(30);
this->aide->setFillColor(sf::Color::Red);
this->aide->setFont(*fontPixel);
this->aide->setString("-> Vous n'avez plus de vie\n-> Vous n'avez plus d'argent pour payer\n-> Vous ressortez de la ville par le sud\n-> Vous atteignez les 200 jours");
aideRect = this->aide->getLocalBounds();
this->aide->setOrigin(aideRect.left + aideRect.width / 2.0f, aideRect.top);
this->aide->setPosition(sf::Vector2f(window->getSize().x / 2.0f, 430.0));
window->draw(*this->aide);
this->aide->setCharacterSize(25);
this->aide->setFillColor(sf::Color::Yellow);
this->aide->setFont(*fontPixel);
this->aide->setString("Vous gagnez la partie si :");
aideRect = this->aide->getLocalBounds();
this->aide->setOrigin(aideRect.left + aideRect.width / 2.0f,
aideRect.top + aideRect.height / 2.0f);
this->aide->setPosition(sf::Vector2f(window->getSize().x / 2.0f, 580.0));
window->draw(*this->aide);
this->aide->setCharacterSize(30);
this->aide->setFillColor(sf::Color::Green);
this->aide->setFont(*fontPixel);
this->aide->setString("-> Vous ressortez de la ville par le nord");
aideRect = this->aide->getLocalBounds();
this->aide->setOrigin(aideRect.left + aideRect.width / 2.0f, aideRect.top);
this->aide->setPosition(sf::Vector2f(window->getSize().x / 2.0f, 600.0));
window->draw(*this->aide);
this->aide->setCharacterSize(30);
this->aide->setFillColor(sf::Color::Yellow);
this->aide->setFont(*fontPixel);
this->aide->setString("Appuyez sur [ESPACE] pour revenir a l'ecran titre");
aideRect = this->aide->getLocalBounds();
this->aide->setOrigin(aideRect.left + aideRect.width / 2.0f, aideRect.top);
this->aide->setPosition(sf::Vector2f(window->getSize().x / 2.0f, 690.0));
window->draw(*this->aide);
}
void TitleScreen::afficherWait(sf::RenderWindow* window, sf::Font* fontPixel) {
aide->setCharacterSize(60);
aide->setFillColor(sf::Color::Yellow);
aide->setFont(*fontPixel);
this->aide->setString("VEUILLEZ PATIENTER...\n LA VILLE SE GENERE!");
sf::FloatRect aideRect = this->aide->getLocalBounds();
this->aide->setOrigin(aideRect.left + aideRect.width / 2.0f,
aideRect.top + aideRect.height / 2.0f);
this->aide->setPosition(sf::Vector2f(window->getSize().x / 2.0f, window->getSize().y / 2.0f));
window->draw(*this->aide);
}
void TitleScreen::afficherFin(Joueur* leJoueur, sf::RenderWindow* window, sf::Font* fontPixel, sf::Font* fontTitre) {
sf::FloatRect finRect;
while (!sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Space))
{
sf::Event evnt;
while (window->pollEvent(evnt))
{
switch (evnt.type)
{
case sf::Event::Closed:
window->close();
break;
}
}
window->clear();
this->fin->setCharacterSize(80);
this->fin->setFont(*fontPixel);
if (leJoueur->getFin() != 1) {
this->fin->setFillColor(sf::Color::Red);
this->fin->setString("VOUS AVEZ PERDU !");
}
else {
this->fin->setFillColor(sf::Color::Green);
this->fin->setString("VICTOIRE !!");
}
finRect = this->fin->getLocalBounds();
this->fin->setOrigin(finRect.left + finRect.width / 2.0f, finRect.top);
this->fin->setPosition(sf::Vector2f(window->getSize().x / 2.0f, 100.0));
window->draw(*this->fin);
this->fin->setCharacterSize(40);
this->fin->setFont(*fontPixel);
this->fin->setFillColor(sf::Color::Yellow);
if (leJoueur->getFin() == 1) {
this->fin->setString(" Vous vous en êtes enfin sorti !\n Et ce en " + to_string(leJoueur->getJours()) + " jours !\n\nEssayez de faire mieux lorsque vous\n repasserez par ici !");
}
else if (leJoueur->getFin() == 2) {
this->fin->setString("Vous êtes ressortis par le sud !\n\n Vous n'avez aucun sens\n de l'orientation !");
}
else if (leJoueur->getFin() == 3) {
this->fin->setString(" Vous êtes mort\n troué comme du gruyère périmé !\n\n Essayez d'avoir des balles dans\nvotre revolver la prochaine fois !");
}
else if (leJoueur->getFin() == 4) {
this->fin->setString("Vous finissez vôtre misérable\n vie au pénitencier\n à casser des cailloux\n toute la journée !");
}
else if (leJoueur->getFin() == 5) {
this->fin->setString("Cela fait maintenant 200 jours\n que vous tournez en rond.\n\n Vous vous écroulez par terre\nde fatigue et de depression...");
}
finRect = this->fin->getLocalBounds();
this->fin->setOrigin(finRect.left + finRect.width / 2.0f, finRect.top);
this->fin->setPosition(sf::Vector2f(window->getSize().x / 2.0f, 300.0));
window->draw(*this->fin);
this->fin->setCharacterSize(30);
this->fin->setString("Appuyez sur [ESPACE] pour continuer");
finRect = this->fin->getLocalBounds();
this->fin->setOrigin(finRect.left + finRect.width / 2.0f, finRect.top);
this->fin->setPosition(sf::Vector2f(window->getSize().x / 2.0f, 680.0));
window->draw(*this->fin);
window->display();
}
}
void TitleScreen::afficherCredits(sf::RenderWindow* window, sf::Font* fontTitre, sf::Font* fontPixel, sf::Font* fontLogo) {
while (!sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Space)) {
window->clear();
sf::Event evnt;
while (window->pollEvent(evnt))
{
switch (evnt.type)
{
case sf::Event::Closed:
window->close();
break;
}
}
this->credits->setCharacterSize(40);
this->credits->setFillColor(sf::Color::Red);
this->credits->setFont(*fontPixel);
this->credits->setString("Merci d'avoir joué à");
sf::FloatRect creditsRect = this->credits->getLocalBounds();
this->credits->setOrigin(creditsRect.left + creditsRect.width / 2.0f,
creditsRect.top + creditsRect.height / 2.0f);
this->credits->setPosition(sf::Vector2f(window->getSize().x / 2.0f, 35.0));
window->draw(*this->credits);
this->credits->setCharacterSize(40);
this->credits->setFillColor(sf::Color::Yellow);
this->credits->setFont(*fontTitre);
this->credits->setString("Far West");
creditsRect = this->credits->getLocalBounds();
this->credits->setOrigin(creditsRect.left + creditsRect.width / 2.0f,
creditsRect.top + creditsRect.height / 2.0f);
this->credits->setPosition(sf::Vector2f(window->getSize().x / 2.0f, 100.0));
window->draw(*this->credits);
this->credits->setCharacterSize(25);
this->credits->setFillColor(sf::Color::Yellow);
this->credits->setFont(*fontPixel);
this->credits->setString("Far West est un jeu original créé et imaginé par Antoine Deyris.\n Il a été développé en 7 jours dans le cadre du projet C++\n de fin de première année à l'EPSI Nantes.");
creditsRect = this->credits->getLocalBounds();
this->credits->setOrigin(creditsRect.left + creditsRect.width / 2.0f,
creditsRect.top + creditsRect.height / 2.0f);
this->credits->setPosition(sf::Vector2f(window->getSize().x / 2.0f, 190.0));
window->draw(*this->credits);
this->credits->setCharacterSize(30);
this->credits->setFillColor(sf::Color::Yellow);
this->credits->setFont(*fontPixel);
this->credits->setString("Far West est fortement inspiré du jeu");
creditsRect = this->credits->getLocalBounds();
this->credits->setOrigin(creditsRect.left + creditsRect.width / 2.0f,
creditsRect.top + creditsRect.height / 2.0f);
this->credits->setPosition(sf::Vector2f(window->getSize().x / 2.0f, 285.0));
window->draw(*this->credits);
this->credits->setCharacterSize(40);
this->credits->setFillColor(sf::Color::Red);
this->credits->setFont(*fontPixel);
this->credits->setString("La Ville Infernale");
creditsRect = this->credits->getLocalBounds();
this->credits->setOrigin(creditsRect.left + creditsRect.width / 2.0f,
creditsRect.top + creditsRect.height / 2.0f);
this->credits->setPosition(sf::Vector2f(window->getSize().x / 2.0f, 325.0));
window->draw(*this->credits);
this->credits->setCharacterSize(30);
this->credits->setFillColor(sf::Color::Yellow);
this->credits->setFont(*fontPixel);
this->credits->setString("sorti sur Amstrad CPC en 1985.");
creditsRect = this->credits->getLocalBounds();
this->credits->setOrigin(creditsRect.left + creditsRect.width / 2.0f,
creditsRect.top + creditsRect.height / 2.0f);
this->credits->setPosition(sf::Vector2f(window->getSize().x / 2.0f, 362.0));
window->draw(*this->credits);
this->credits->setCharacterSize(30);
this->credits->setFillColor(sf::Color::Red);
this->credits->setFont(*fontPixel);
this->credits->setString("Remerciements spéciaux :");
creditsRect = this->credits->getLocalBounds();
this->credits->setOrigin(creditsRect.left + creditsRect.width / 2.0f,
creditsRect.top + creditsRect.height / 2.0f);
this->credits->setPosition(sf::Vector2f(window->getSize().x / 2.0f, 450.0));
window->draw(*this->credits);
this->credits->setCharacterSize(30);
this->credits->setFillColor(sf::Color::Yellow);
this->credits->setFont(*fontPixel);
this->credits->setString(" Jean Gautier (Alpha tester)\n Bartho (Alpha tester)\nL'Auberge (Soutient moral & Alpha testers)");
creditsRect = this->credits->getLocalBounds();
this->credits->setOrigin(creditsRect.left + creditsRect.width / 2.0f, creditsRect.top);
this->credits->setPosition(sf::Vector2f(window->getSize().x / 2.0f, 480.0));
window->draw(*this->credits);
this->credits->setCharacterSize(30);
this->credits->setFillColor(sf::Color::Red);
this->credits->setFont(*fontPixel);
this->credits->setString("Et de manière générale à tous ceux qui ont soutenu\n de près ou de loin le projet !");
creditsRect = this->credits->getLocalBounds();
this->credits->setOrigin(creditsRect.left + creditsRect.width / 2.0f, creditsRect.top);
this->credits->setPosition(sf::Vector2f(window->getSize().x / 2.0f, 590.0));
window->draw(*this->credits);
this->credits->setCharacterSize(30);
this->credits->setFillColor(sf::Color::Yellow);
this->credits->setFont(*fontPixel);
this->credits->setString("Appuyez sur [ESPACE] pour quitter le jeu");
creditsRect = this->credits->getLocalBounds();
this->credits->setOrigin(creditsRect.left + creditsRect.width / 2.0f, creditsRect.top);
this->credits->setPosition(sf::Vector2f(window->getSize().x / 2.0f, 700.0));
window->draw(*this->credits);
window->display();
}
}