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 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439
| // Programme: GVSC, démo technique
#include <SFML/Graphics.hpp>
#include <iostream>
#include <windows.h>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <ctime>
#include "MenuPrincipal.h"
#include "Commande.h"
#include "Sauvegarde.h"
#include "Texte1.h"
#include "Vignette1.h"
using namespace std;
using namespace sf;
void MenuPrincipal()
{ int width(GetSystemMetrics(SM_CXSCREEN)); // Récupérer résolution horizontale de l'écran
int height(GetSystemMetrics(SM_CYSCREEN)); // Récupérer résolution verticale de l'écran
Font fonte; // Fonte pour le texte des menus
fonte.loadFromFile("Fontes/SuperMario256.ttf"); // Chargement d'un fichier font
Color couleur; // Couleur pour le texte des menus
couleur.r=255; couleur.g=100; couleur.b=0; couleur.a=255; // Création d'une couleur (rouge-orangé opaque)
// Témoins d'exécution (en-cours / terminé)
bool anim(true), cine(true), load(true);
// Variable pour stocker à très court terme le résultat d'un calcul
string calc1;
int calc2;
Texture textureImage[126];
int temoinChargement[126];
string caracteresEdition[76];
double facteurDilatation[14];
double facteurEntree[14];
double facteurSortie[14];
int facteurTransparence[14];
// Index de sélection (fichier de sauvegarde, ligne...)
int save(0), line(1);
// Gestion du temps temps
clock_t time1(clock()), time2; // Temps
int step(0); // Cycles écoulés
int cont(1); // Compteur de cycles
// Variables de circulation (boucle Z)
int z(100), y(0), x(0); // Etape exploitée
int z0(0), y0(0), x0(0); // Etape à exploiter après
// Variables pour contenir la valeur des commandes
double BoutonA(0.0), BoutonB(0.0), BoutonStart(0.0), FlecheHaut(0.0), FlecheBas(0.0), FlecheGauche(0.0), FlecheDroite(0.0), BoutonESC(0.0);
// Variables pour contenir nom et score des fichiers
string nom[5], score[5];
// Déclarer la fenêtre
RenderWindow window;
// Afficher la fenêtre
window.create(VideoMode(width, height), "GVSC", Style::Fullscreen);
// Création des objets
Texte1 TEXTE1_1(width, height, fonte, couleur, window);
Vignette1 VIGNETTE1_1(width, height, fonte, couleur, window);
while (z < 1000)
{ switch (z) // Boucle Z
/* 100 : INTRO
110 : ACCUEIL
120 : MAIN MENU
130 : PLAY
140 : BONUS
170 : MINI-GAMES
*/
{ case 100: // Z INTRO - chargement du contenu nécessaire au menu principal, caché par une cinématique puis, éventuellement, l'affichage de "LOADING..."
// Cinematique1 CINEMATIQUE(...);
switch (y)
{ case 0: // Y PREPARATION - effectuer le chargement, avec "load" comme témoin
load=false;
y=1; x=0; x0=1;
break;
case 1: // Y DISTRACTION - afficher la cinématique (pour cacher le chargement)
switch (x)
{ case 0: // Préparation de la cinématique
// anim=ecran.CinematiqueSet("");
x=1;
break;
case 1: // Animation de la cinématique
if (anim == true) // Chargement en-cours, cinématique terminée
{ TEXTE1_1.Set(5, "", "", "", "", "", "", "", "", "", "LOADING");
x=2;
}
else if (anim == false) // Chargement en-cours, cinématique en-cours
{ /*anim=ecran.CinematiqueAnim(step);*/
}
break;
case 2: // Affichage de "LOADING"
if (cont == 0)
{ TEXTE1_1.Set(5, "", "", "", "", "", "", "", "", "", "LOADING"); // Réécrire Texte1
cont+=step; // Incrémenter le compteur
}
else if (cont >= 15)
{ cont=0; x=3; // Réinitialiser le compteur
}
else
{ cont+=step; // Incrémenter le compteur
}
TEXTE1_1.Anim(step); // Animer Texte1
break;
case 3: // Affichage de "LOADING."
if (cont == 0)
{ TEXTE1_1.Set(5, "", "", "", "", "", "", "", "", "", "LOADING."); // Réécrire Texte1
cont+=step; // Incrémenter le compteur
}
else if (cont >= 15)
{ cont=0; x=4; // Réinitialiser le compteur
}
else
{ cont+=step; // Incrémenter le compteur
}
TEXTE1_1.Anim(step); // Animer Texte1
break;
case 4: // Affichage de "LOADING.."
if (cont == 0)
{ TEXTE1_1.Set(5, "", "", "", "", "", "", "", "", "", "LOADING.."); // Réécrire Texte1
cont+=step; // Incrémenter le compteur
}
else if (cont >= 15)
{ cont=0; x=5; // Réinitialiser le compteur
}
else
{ cont+=step; // Incrémenter le compteur
}
TEXTE1_1.Anim(step); // Animer Texte1
break;
case 5: // Affichage de "LOADING.."
if (cont == 0)
{ TEXTE1_1.Set(5, "", "", "", "", "", "", "", "", "", "LOADING..."); // Réécrire Texte1
cont+=step; // Incrémenter le compteur
}
else if (cont >= 15)
{ cont=0; x=2; // Réinitialiser le compteur
}
else
{ cont+=step; // Incrémenter le compteur
}
TEXTE1_1.Anim(step); // Animer Texte1
break;
}
y=2; // Aller à chargement
break;
case 2: // Y CHARGEMENT
switch (x0) // Chargement pour l'ensemble du menu principal
{ case 1:
if (temoinChargement[0] != 1)
{ textureImage[0].loadFromFile("ContenuGraphique/Fond_BleuDegrade.png");
temoinChargement[0]=1;
}
x0=2;
break;
case 2:
if (temoinChargement[1] != 1)
{ textureImage[1].loadFromFile("ContenuGraphique/Bandeau_TracesChat.png");
temoinChargement[1]=1;
}
x0=3;
break;
case 3:
if (temoinChargement[2] != 1)
{ textureImage[2].loadFromFile("ContenuGraphique/Bandeau_NoirFondu.png");
temoinChargement[2]=1;
}
x0=112;
break;
case 112:
if (temoinChargement[110] != 1)
{ textureImage[110].loadFromFile("ContenuGraphique/Vignette_Pacman_0.png");
temoinChargement[110]=1;
}
x0=113;
break;
case 113:
if (temoinChargement[111] != 1)
{ textureImage[111].loadFromFile("ContenuGraphique/Vignette_Pacman_1.png");
temoinChargement[111]=1;
}
x0=114;
break;
case 114:
if (temoinChargement[112] != 1)
{ textureImage[112].loadFromFile("ContenuGraphique/Vignette_Pacman_2.png");
temoinChargement[112]=1;
}
x0=115;
break;
case 115:
if (temoinChargement[113] != 1)
{ textureImage[113].loadFromFile("ContenuGraphique/Vignette_Pacman_3.png");
temoinChargement[113]=1;
}
x0=116;
break;
case 116:
if (temoinChargement[114] != 1)
{ textureImage[114].loadFromFile("ContenuGraphique/Vignette_Pacman_4.png");
temoinChargement[114]=1;
}
x0=117;
break;
case 117:
if (temoinChargement[115] != 1)
{ textureImage[115].loadFromFile("ContenuGraphique/Vignette_Pacman_5.png");
temoinChargement[115]=1;
}
x0=118;
break;
case 118:
if (temoinChargement[116] != 1)
{ textureImage[116].loadFromFile("ContenuGraphique/Vignette_Pacman_6.png");
temoinChargement[116]=1;
}
x0=119;
break;
case 119:
if (temoinChargement[117] != 1)
{ textureImage[117].loadFromFile("ContenuGraphique/Vignette_Pacman_7.png");
temoinChargement[117]=1;
}
x0=120;
break;
case 120:
if (temoinChargement[118] != 1)
{ textureImage[118].loadFromFile("ContenuGraphique/Vignette_Pacman_8.png");
temoinChargement[118]=1;
}
x0=121;
break;
case 121:
if (temoinChargement[119] != 1)
{ textureImage[119].loadFromFile("ContenuGraphique/Vignette_Pacman_9.png");
temoinChargement[119]=1;
}
x0=122;
break;
case 122:
if (temoinChargement[120] != 1)
{ textureImage[120].loadFromFile("ContenuGraphique/Vignette_Pacman_10.png");
temoinChargement[120]=1;
}
x0=123;
break;
case 123:
if (temoinChargement[121] != 1)
{ textureImage[121].loadFromFile("ContenuGraphique/Vignette_Pacman_11.png");
temoinChargement[121]=1;
}
x0=124;
break;
case 124:
if (temoinChargement[122] != 1)
{ textureImage[122].loadFromFile("ContenuGraphique/Vignette_Pacman_12.png");
temoinChargement[122]=1;
}
x0=125;
break;
case 125:
if (temoinChargement[123] != 1)
{ textureImage[123].loadFromFile("ContenuGraphique/Vignette_Pacman_13.png");
temoinChargement[123]=1;
}
x0=126;
break;
case 126:
if (temoinChargement[124] != 1)
{ textureImage[124].loadFromFile("ContenuGraphique/Vignette_Pacman_14.png");
temoinChargement[124]=1;
}
x0=127;
break;
case 127:
if (temoinChargement[125] != 1)
{ textureImage[125].loadFromFile("ContenuGraphique/Vignette_Pacman_15.png");
temoinChargement[125]=1;
}
x0=128;
break;
case 128:
if (temoinChargement[126] != 1)
{ textureImage[126].loadFromFile("ContenuGraphique/Vignette_Pacman_16.png");
temoinChargement[126]=1;
}
x0=129;
break;
case 129:
caracteresEdition[0]="A"; caracteresEdition[1]="B"; caracteresEdition[2]="C"; caracteresEdition[3]="D"; caracteresEdition[4]="E"; caracteresEdition[5]="F"; caracteresEdition[6]="G"; caracteresEdition[7]="H"; caracteresEdition[8]="I"; caracteresEdition[9]="J"; caracteresEdition[10]="K"; caracteresEdition[11]="L"; caracteresEdition[12]="M"; caracteresEdition[13]="N"; caracteresEdition[14]="O"; caracteresEdition[15]="P"; caracteresEdition[16]="Q"; caracteresEdition[17]="R"; caracteresEdition[18]="S"; caracteresEdition[19]="T"; caracteresEdition[20]="U"; caracteresEdition[21]="V"; caracteresEdition[22]="W"; caracteresEdition[23]="X"; caracteresEdition[24]="Y"; caracteresEdition[25]="Z"; caracteresEdition[26]=" "; caracteresEdition[27]="0"; caracteresEdition[28]="1"; caracteresEdition[29]="2"; caracteresEdition[30]="3"; caracteresEdition[31]="4"; caracteresEdition[32]="5"; caracteresEdition[33]="6"; caracteresEdition[34]="7"; caracteresEdition[35]="8"; caracteresEdition[36]="9"; caracteresEdition[37]="OK"; caracteresEdition[38]=" 7 8 9 OK B C D E "; caracteresEdition[39]=" 8 9 OK A C D E F "; caracteresEdition[40]=" 9 OK A B D E F G "; caracteresEdition[41]="OK A B C E F G H "; caracteresEdition[42]=" A B C D F G H I "; caracteresEdition[43]=" B C D E G H I J "; caracteresEdition[44]=" C D E F H I J K "; caracteresEdition[45]=" D E F G I J K L "; caracteresEdition[46]=" E F G H J K L M "; caracteresEdition[47]=" F G H I K L M N "; caracteresEdition[48]=" G H I J L M N O "; caracteresEdition[49]=" H I J K M N O P "; caracteresEdition[50]=" I J K L N O P Q "; caracteresEdition[51]=" J K L M O P Q R "; caracteresEdition[52]=" K L M N P Q R S "; caracteresEdition[53]=" L M N O Q R S T "; caracteresEdition[54]=" M N O P R S T U "; caracteresEdition[55]=" N O P Q S T U V "; caracteresEdition[56]=" O P Q R T U V W "; caracteresEdition[57]=" P Q R S U V W X "; caracteresEdition[58]=" Q R S T V W X Y "; caracteresEdition[59]=" R S T U W X Y Z "; caracteresEdition[60]=" S T U V X Y Z "; caracteresEdition[61]=" T U V W Y Z 0 "; caracteresEdition[62]=" U V W X Z 0 1 "; caracteresEdition[63]=" V W X Y 0 1 2 "; caracteresEdition[64]=" W X Y Z 0 1 2 3 "; caracteresEdition[65]=" X Y Z 1 2 3 4 "; caracteresEdition[66]=" Y Z 0 2 3 4 5 "; caracteresEdition[67]=" Z 0 1 3 4 5 6 "; caracteresEdition[68]=" 0 1 2 4 5 6 7 "; caracteresEdition[69]=" 0 1 2 3 5 6 7 8 "; caracteresEdition[70]=" 1 2 3 4 6 7 8 9 "; caracteresEdition[71]=" 2 3 4 5 7 8 9 OK "; caracteresEdition[72]=" 3 4 5 6 8 9 OK A "; caracteresEdition[73]=" 4 5 6 7 9 OK A B "; caracteresEdition[74]=" 5 6 7 8 OK A B C "; caracteresEdition[75]=" 6 7 8 9 A B C D ";
x0=130;
break;
case 130:
facteurDilatation[0]=1.000; facteurDilatation[1]=1.005; facteurDilatation[2]=1.026; facteurDilatation[3]=1.074; facteurDilatation[4]=1.095; facteurDilatation[5]=1.100; facteurDilatation[6]=1.100; facteurDilatation[7]=1.100; facteurDilatation[8]=1.095; facteurDilatation[9]=1.074; facteurDilatation[10]=1.026; facteurDilatation[11]=1.005; facteurDilatation[12]=1.000; facteurDilatation[13]=1.000;
x0=131;
break;
case 131:
facteurEntree[0]=width; facteurEntree[1]=width*0.996; facteurEntree[2]=width*0.978; facteurEntree[3]=width*0.939; facteurEntree[4]=width*0.870; facteurEntree[5]=width*0.762; facteurEntree[6]=width*0.606; facteurEntree[7]=width*0.394; facteurEntree[8]=width*0.238; facteurEntree[9]=width*0.130; facteurEntree[10]=width*0.061; facteurEntree[11]=width*0.022; facteurEntree[12]=width*0.004; facteurEntree[13]=0.000;
x0=132;
break;
case 132:
facteurSortie[0]=0.000; facteurSortie[1]=-width*0.004; facteurSortie[2]=-width*0.022; facteurSortie[3]=-width*0.061; facteurSortie[4]=-width*0.130; facteurSortie[5]=-width*0.238; facteurSortie[6]=-width*0.394; facteurSortie[7]=-width*0.606; facteurSortie[8]=-width*0.762; facteurSortie[9]=-width*0.870; facteurSortie[10]=-width*0.939; facteurSortie[11]=-width*0.978; facteurSortie[12]=-width*0.996; facteurSortie[13]=-width;
x0=133;
break;
case 133:
facteurTransparence[0]=0; facteurTransparence[1]=1; facteurTransparence[2]=6; facteurTransparence[3]=15; facteurTransparence[4]=33; facteurTransparence[5]=61; facteurTransparence[6]=100; facteurTransparence[7]=155; facteurTransparence[8]=194; facteurTransparence[9]=222; facteurTransparence[10]=240; facteurTransparence[11]=249; facteurTransparence[12]=254; facteurTransparence[13]=255;
x0=134;
break;
case 134:
TEXTE1_1.Cstr(facteurDilatation, facteurEntree, facteurSortie);
x0=140;
break;
case 140:
Texture tableau1[17]={textureImage[110], textureImage[111], textureImage[112], textureImage[113], textureImage[114], textureImage[115], textureImage[116], textureImage[117], textureImage[118], textureImage[119], textureImage[120], textureImage[121], textureImage[122], textureImage[123], textureImage[124], textureImage[125], textureImage[126]};
VIGNETTE1_1.Cstr(facteurDilatation, facteurEntree, facteurSortie, tableau1);
x0=0; load=true;
break;
}
if (load == true) // Chargement terminé
{ if (anim == true) // Cinématique terminée
{ z=110; y=0; x=0;
}
else if (anim == false) // Cinématique en-cours
{ BoutonA=Commande(1); BoutonStart=Commande(5);
if (BoutonA != 0.0 || BoutonStart != 0.0) // Bouton pressé
{ z=110; y=0; x=0;
}
}
}
else if (load == false) // Chargement en cours
{ if (anim == true) // Cinématique terminée
{ TEXTE1_1.Anim(step);
}
else if (anim == false) // Cinématique en-cours
{ /*anim=cinematique.Anim(step);*/
}
y=1; // Aller à distraction
}
break; // Y CHARGEMENT (fin)
}
break; // INTRO (fin)
case 110: // Z ACCUEIL
// Jouer le thème principal
// Afficher le fond d'écran principal
// Afficher "PRESS START", puis "PRESS START PLEASE"
// Jouer le MONTRER et afficher "PRESS START"
{ switch (y)
{ case 0: // Y PREPARATION
VIGNETTE1_1.Set();
VIGNETTE1_1.Cine(0);
y=1; x=0; // Passer automatiquement à l'étape suivante
break; // Y PREPARATION (fin)
case 1: // Y ECRAN 1 (PRESS START)
VIGNETTE1_1.Anim(step);
break; // ECRAN 1 (fin)
}
}
break; // ACCUEIL (fin)
}
if (load == true) // Chargement pas en cours
{ window.display(); // Afficher tout le contenu de l'écran
time2=clock(); // Réinitialiser le compteur de temps
calc2=1000*(time2-time1)/CLOCKS_PER_SEC; // Calcul du temps écoulé pendant le dernier cycle
step=1+(calc2-(calc2%33))/33; // Calculer combien de cycles de 0.033 seconde se sont écoulés
Sleep(33-(calc2%33)); // Attendre jusqu'à ce que 0.033 seconde (respectivement un multiple) se soit écoulé
time1=clock(); // Réinitialiser le compteur de temps
window.clear(); // Effacer tout le contenu de la fenêtre
BoutonESC=(Commande(18));
if (BoutonESC != 0.0) {z=1000;} // Sortie si on appuie sur ESCAPE
}
else if (load == false) // Chargement en cours
{ window.display(); // Afficher tout le contenu de l'écran
time2=clock(); // Réinitialiser le compteur de temps
calc2=1000*(time2-time1)/CLOCKS_PER_SEC; // Calcul du temps écoulé pendant le dernier cycle
if (calc2 < 0.033) // Temps de cycle maximum pas atteint
{ step=0;
time1=clock(); // Réinitialiser le compteur de temps
}
else // Temps de cycle maximum atteint
{ step=1+(calc2-(calc2%33))/33; // Calculer combien de cycles de 0.033 seconde se sont écoulés
time1=clock(); // Réinitialiser le compteur de temps
window.clear(); // Effacer tout le contenu de la fenêtre
BoutonESC=(Commande(18));
if (BoutonESC != 0.0) {z=1000;} // Sortie si on appuie sur ESCAPE
}
}
}
cout << "Fin de l'execution" << endl;
} |
Partager