1 /**
2 * @file scene_main_menu.cpp
3 * @author Frederic MARTIN [martin-frederic@users.sourceforge.net]
4 * @brief Implements E_scene_menu_principal. See scenes.h for the complete scene list
5 */
6
7
8
9
10 #include "scene_main_menu.h"
11 #include "utils.h"
12 #include "models.h"
13
14 // Instance actuelle de la classe E_scene_menu_principal. Elle est utilisée par
15 // les fonctions de CALL-BACK car elles ne peuvent pas être membre de la classe
16 E_scene_menu_principal* instance_actuelle=NULL;
17
18
19 const int POSITION_X_DES_BOUTONS=500;
20 const int POSITION_Y_DU_PREMIER_BOUTON=200;
21
22 const std::string MESSAGES_DES_CREDITS[NOMBRE_DE_MESSAGES_DES_CREDITS] =
23 {
24 "- Main programmer : -",
25 "Frederic MARTIN [martin-frederic@users.sourceforge.net]",
26 "",
27 "",
28 "- Main Testers -",
29 "Eric LE GUEVEL",
30 "Frederic MARTIN",
31 "Helene MARTIN",
32 "Jean-Baptiste ZATTARIN",
33 "Pierre GOTAB",
34 "Vincent MARTIN",
35 "Vivien BERNARD",
36 "",
37 "",
38 "- Graphics with : -",
39 "Blender",
40 "The GIMP",
41 "KolourPaint",
42 "",
43 "",
44 "- Special thanks to : -",
45 "",
46 "",
47 "Eric for his Linux tweaks",
48 "Jean-Baptiste for testing",
49 "Pierre for the camera management",
50 "Vivien for AI ideas",
51 "Vincent for blender models",
52 "Philippe Gilles for all his help",
53 "",
54 "The KDE team for doing a such great environment",
55 "",
56 "",
57 "And of course all the Linux community !",
58
59 };
60
61 //--------------------------------------------------//
62 //--------------------------------------------------//
63 // ** fonctions de CALL-BACK pour le GUI ** //
64 //--------------------------------------------------//
65 //--------------------------------------------------//
sur_bouton_un_joueur()66 void sur_bouton_un_joueur()
67 {
68 pGlobalInfos->set_mode_de_jeu(pGlobalInfos->JOUEUR_CONTRE_IA);
69 instance_actuelle->prochaine_scene(E_SCENE_JEU_PRINCIPAL);
70 }
71
sur_bouton_deux_joueurs()72 void sur_bouton_deux_joueurs()
73 {
74 pGlobalInfos->set_mode_de_jeu(pGlobalInfos->JOUEUR_CONTRE_JOUEUR);
75 instance_actuelle->prochaine_scene(E_SCENE_JEU_PRINCIPAL);
76 }
77
78
sur_bouton_credits()79 void sur_bouton_credits()
80 {
81 instance_actuelle->afficher_credits_init();
82 }
83
84
sur_bouton_quitter()85 void sur_bouton_quitter()
86 {
87 pGlobalInfos->quitter_le_jeu();
88 }
89
90
91
92
93 //--------------------------------------------------//
94 //--------------------------------------------------//
95 // ** E_scene_menu_principal ** //
96 //--------------------------------------------------//
97 //--------------------------------------------------//
E_scene_menu_principal()98 E_scene_menu_principal::E_scene_menu_principal()
99 {
100 fontTexture=NULL;
101 instance_actuelle=this;
102 }
103
~E_scene_menu_principal()104 E_scene_menu_principal::~E_scene_menu_principal()
105 {
106
107 }
108
109
110
afficher_echiquier()111 void E_scene_menu_principal::afficher_echiquier()
112 {
113
114 // matériau "gold" trouvée sur http://devernay.free.fr/cours/opengl/materials.html
115 const GLfloat material_plateau_Ka[] = {0.24725f,0.1995f,0.0745f,1.0f};
116 const GLfloat material_plateau_Kd[] = {0.75164f,0.60648f,0.22648f,1.0f};
117 const GLfloat material_plateau_Ks[] = {0.628281f,0.555802f,0.366065f,1.0f};
118 const GLfloat material_plateau_Ke[] = {0.0f,0.0f,0.0f,1.0f};
119 // matériau "green rubber" trouvée sur http://devernay.free.fr/cours/opengl/materials.html
120 const GLfloat material_table_Ka[] = {0.0f,0.05f,0.0f,1.0f};
121 const GLfloat material_table_Kd[] = {0.4f,0.5f,0.4f,1.0f};
122 const GLfloat material_table_Ks[] = {0.04f,0.7f,0.04f,1.0f};
123 const GLfloat material_table_Ke[] = {0.0f,0.0f,0.0f,1.0f};
124
125 // Positionne la caméra
126 angleCameraX+=0.0003f*pGlobalInfos->tempsEcoule();
127
128 GLfloat cameraDist = 20.0f;
129 GLfloat cameraX=cos(angleCameraX)*cos(angleCameraZ)*cameraDist+7.0f;
130 GLfloat cameraY=sin(angleCameraZ)*cameraDist;
131 GLfloat cameraZ=sin(angleCameraX)*cos(angleCameraZ)*cameraDist+7.0f;
132
133
134 // Positionne la caméra
135 gluLookAt(cameraX, cameraY, cameraZ, // coordonnées de la position de la caméra
136 7.0f, 0.0f, 7.0f, // coordonnées du centre de l'échiquier
137 0.0f, 1.0f, 0.0f); // caméra tournée selon les y
138
139 glEnable(GL_TEXTURE_2D);
140 glDisable(GL_LIGHTING);
141
142
143 glColor3f(1.0f,1.0f,1.0f);
144 damier->utiliser();
145 glCallList(liste_des_modeles+OBJ_DAMIER);
146
147 if (pGlobalInfos->get_sol_disco())
148 glColor3f(0.5f+0.5f*sin(SDL_GetTicks()/1500.0f),0.5f+0.5f*sin((10+SDL_GetTicks())/800.0f),0.5f+0.5f*sin(SDL_GetTicks()/1000.0f));
149
150 textureSol->utiliser();
151 glCallList(liste_des_modeles+OBJ_SOL);
152
153 glDisable(GL_TEXTURE_2D);
154 glEnable(GL_LIGHTING);
155
156
157 const GLfloat lightPosition1 [] = { 7.0f, 10.0f, 7.0f, 0.0f }; // position de la source de lumière
158 glLightfv(GL_LIGHT1, GL_POSITION, lightPosition1);
159
160 // affichage du plateau
161 glMaterialfv(GL_FRONT,GL_AMBIENT,material_plateau_Ka);
162 glMaterialfv(GL_FRONT,GL_DIFFUSE,material_plateau_Kd);
163 glMaterialfv(GL_FRONT,GL_SPECULAR,material_plateau_Ks);
164 glMaterialfv(GL_FRONT,GL_EMISSION,material_plateau_Ke);
165 glMaterialf(GL_FRONT,GL_SHININESS,51.2f);//51.2f = 128.0f*0.4f
166
167 glPushMatrix();
168 glTranslatef(7.0f,-0.1f,7.0f);
169 glCallList(liste_des_modeles+OBJ_PLATEAU);
170 glPopMatrix();
171
172 // affichage de la table
173 glMaterialfv(GL_FRONT,GL_AMBIENT,material_table_Ka);
174 glMaterialfv(GL_FRONT,GL_DIFFUSE,material_table_Kd);
175 glMaterialfv(GL_FRONT,GL_SPECULAR,material_table_Ks);
176 glMaterialfv(GL_FRONT,GL_EMISSION,material_table_Ke);
177 glMaterialf(GL_FRONT,GL_SHININESS,100.0f);//100.0f = 128.0f*0.78125ff
178
179 glPushMatrix();
180 glTranslatef(5.2f,-1.7f,7.1f);
181 glCallList(liste_des_modeles+OBJ_TABLE);
182 glPopMatrix();
183
184 glPushMatrix();
185 glTranslatef(6.0f,0.02f,2.0f);
186 glCallList(liste_des_modeles+OBJ_ROI);
187 glPopMatrix();
188
189 glPushMatrix();
190 glTranslatef(7.5f,0.3f,2.0f);
191 glRotatef(16.0f,0.0f,0.0f,1.0f);
192 glCallList(liste_des_modeles+OBJ_DAME);
193 glPopMatrix();
194
195 glPushMatrix();
196 glTranslatef(12.5f,0.02f,2.0f);
197 glCallList(liste_des_modeles+OBJ_PION);
198 glPopMatrix();
199
200 glPushMatrix();
201 glTranslatef(9.0f,0.02f,8.0f);
202 glCallList(liste_des_modeles+OBJ_PION);
203 glPopMatrix();
204
205 glPushMatrix();
206 glTranslatef(5.0f,0.02f,12.5f);
207 glCallList(liste_des_modeles+OBJ_PION);
208 glPopMatrix();
209
210 glPushMatrix();
211 glTranslatef(11.0f,0.02f,11.5f);
212 glCallList(liste_des_modeles+OBJ_PION);
213 glPopMatrix();
214
215 glPushMatrix();
216 glTranslatef(2.0f,0.02f,11.5f);
217 glCallList(liste_des_modeles+OBJ_TOUR);
218 glPopMatrix();
219
220 glDisable(GL_LIGHTING);
221
222 }
223
224
charger()225 bool E_scene_menu_principal::charger()
226 {
227 if (deja_charge)
228 return true;
229
230
231
232 if (charger_objets_3d()==false)
233 {
234 printf("3D object loading failed...\n");
235 return false;
236 }
237
238 textureSol = new Texture;
239 if (false==textureSol->charger(E_DONNEES_TEXTURE_SOL,true))
240 {
241 printf("Loading of :"E_DONNEES_TEXTURE_SOL" failed\n");
242 return false;
243 }
244 textureSol->SetTexParameter(GL_TEXTURE_WRAP_S,GL_REPEAT);
245 textureSol->SetTexParameter(GL_TEXTURE_WRAP_T,GL_REPEAT);
246 textureSol->SetTexParameter(GL_MODULATE,0);
247
248 damier = new Texture;
249 if (false==damier->charger(E_DONNEES_TEXTURE_DAMIER,false))
250 {
251 printf("Loading of :"E_DONNEES_TEXTURE_DAMIER" failed\n");
252 return false;
253 }
254
255 damier->SetTexParameter(GL_TEXTURE_WRAP_S,GL_CLAMP_TO_EDGE); // pour avoir une bordure "lisse" (pas de répétition sur les S)
256 damier->SetTexParameter(GL_TEXTURE_WRAP_T,GL_CLAMP_TO_EDGE); // pour avoir une bordure "lisse" (pas de répétition sur les T)
257
258 texture_bouton_un_joueur = new Texture;
259 if (false==texture_bouton_un_joueur->charger(E_DONNEES_TEXTURE_BOUTON_1_JOUEUR,false))
260 {
261 printf("Loading of :"E_DONNEES_TEXTURE_BOUTON_1_JOUEUR" failed\n");
262 return false;
263 }
264
265 texture_bouton_deux_joueurs = new Texture;
266 if (false==texture_bouton_deux_joueurs->charger(E_DONNEES_TEXTURE_BOUTON_2_JOUEURS,false))
267 {
268 printf("Loading of :"E_DONNEES_TEXTURE_BOUTON_2_JOUEURS" failed\n");
269 return false;
270 }
271
272 texture_bouton_credits = new Texture;
273 if (false==texture_bouton_credits->charger(E_DONNEES_TEXTURE_BOUTON_CREDITS,false))
274 {
275 printf("Loading of :"E_DONNEES_TEXTURE_BOUTON_CREDITS" failed\n");
276 return false;
277 }
278
279 texture_bouton_quitter = new Texture;
280 if (false==texture_bouton_quitter->charger(E_DONNEES_TEXTURE_BOUTON_QUITTER2,false))
281 {
282 printf("Loading of :"E_DONNEES_TEXTURE_BOUTON_QUITTER2" failed\n");
283 return false;
284 }
285
286 texture_blender = new Texture;
287 if (false==texture_blender->charger(E_DONNEES_TEXTURE_ICONE_BLENDER,false))
288 {
289 printf("Loading of :"E_DONNEES_TEXTURE_ICONE_BLENDER" failed\n");
290 return false;
291 }
292
293 texture_kate = new Texture;
294 if (false==texture_kate->charger(E_DONNEES_TEXTURE_ICONE_KATE,false))
295 {
296 printf("Loading of :"E_DONNEES_TEXTURE_ICONE_KATE" failed\n");
297 return false;
298 }
299
300 texture_gimp = new Texture;
301 if (false==texture_gimp->charger(E_DONNEES_TEXTURE_ICONE_GIMP,false))
302 {
303 printf("Loading of :"E_DONNEES_TEXTURE_ICONE_GIMP" failed\n");
304 return false;
305 }
306
307 texture_tux = new Texture;
308 if (false==texture_tux->charger(E_DONNEES_TEXTURE_ICONE_TUX,false))
309 {
310 printf("Loading of :"E_DONNEES_TEXTURE_ICONE_TUX" failed\n");
311 return false;
312 }
313
314 fontTexture = new Texture;
315 if (false==fontTexture->charger(E_DONNEES_TEXTURE_FONT,false))
316 {
317 printf("Loading of :"E_DONNEES_TEXTURE_FONT" failed\n");
318 return false;
319 }
320
321 titre = new Texture;
322 if (false==titre->charger(E_DONNEES_TEXTURE_TITRE,false))
323 {
324 printf("Loading of :"E_DONNEES_TEXTURE_TITRE" failed\n");
325 return false;
326 }
327
328
329 un_gui.Init(1024.0f,768.0f, fontTexture->GetId() );
330
331 liste_des_modeles=genererla_liste_des_modeles(); // Crée les display lists des pièces
332
333 glEnable(GL_LIGHTING); // activation de la lumière
334 glEnable(GL_LIGHT0);// activation de la lumière 0
335 glEnable(GL_LIGHT1);// activation de la lumière 1
336
337 // définition des paramètres pour la lumière 0
338 const GLfloat lightPosition0 [] = { 7.0f, 10.0f, 7.0f, 0.0f }; // position de la source de lumière
339 const GLfloat lightColorAmbient [] = { 0.3f, 0.3f, 0.3f, 1.0f }; // couleur ambiante
340 const GLfloat lightColorDiffuse [] = { 1.0f, 1.0f, 1.0f, 1.0f }; // couleur Diffuse
341 const GLfloat lightColorSpecular[] = { 1.0f, 1.0f, 1.0f, 1.0f }; // couleur spéculaire
342
343 glLightfv(GL_LIGHT0, GL_POSITION, lightPosition0);
344 glLightfv(GL_LIGHT0, GL_AMBIENT, lightColorAmbient);
345 glLightfv(GL_LIGHT0, GL_DIFFUSE, lightColorDiffuse);
346 glLightfv(GL_LIGHT0, GL_SPECULAR, lightColorSpecular);
347
348 glLightfv(GL_LIGHT1, GL_AMBIENT, lightColorAmbient);
349 glLightfv(GL_LIGHT1, GL_DIFFUSE, lightColorDiffuse);
350 glLightfv(GL_LIGHT1, GL_SPECULAR, lightColorSpecular);
351
352
353 bouton_un_joueur.SetPos(POSITION_X_DES_BOUTONS,POSITION_Y_DU_PREMIER_BOUTON+0);
354 bouton_un_joueur.OnClick(sur_bouton_un_joueur);
355 bouton_un_joueur.SetImage(texture_bouton_un_joueur->GetId());
356 bouton_un_joueur.SetSize(64,64);
357 un_gui.AddWidget(&bouton_un_joueur);
358
359 bouton_deux_joueurs.SetPos(POSITION_X_DES_BOUTONS,POSITION_Y_DU_PREMIER_BOUTON+130);
360 bouton_deux_joueurs.OnClick(sur_bouton_deux_joueurs);
361 bouton_deux_joueurs.SetImage(texture_bouton_deux_joueurs->GetId());
362 bouton_deux_joueurs.SetSize(64,64);
363 un_gui.AddWidget(&bouton_deux_joueurs);
364
365 bouton_credits.SetPos(POSITION_X_DES_BOUTONS,POSITION_Y_DU_PREMIER_BOUTON+260);
366 bouton_credits.OnClick(sur_bouton_credits);
367 bouton_credits.SetImage(texture_bouton_credits->GetId());
368 bouton_credits.SetSize(64,64);
369 un_gui.AddWidget(&bouton_credits);
370
371 bouton_quitter.SetPos(POSITION_X_DES_BOUTONS,POSITION_Y_DU_PREMIER_BOUTON+390);
372 bouton_quitter.OnClick(sur_bouton_quitter);
373 bouton_quitter.SetImage(texture_bouton_quitter->GetId());
374 bouton_quitter.SetSize(64,64);
375 un_gui.AddWidget(&bouton_quitter);
376
377 label_un_joueur.SetText("One player");
378 label_un_joueur.SetPos(POSITION_X_DES_BOUTONS-65,POSITION_Y_DU_PREMIER_BOUTON+60);
379 un_gui.AddWidget(&label_un_joueur);
380
381 label_deux_joueurs.SetText("Two players");
382 label_deux_joueurs.SetPos(POSITION_X_DES_BOUTONS-80,POSITION_Y_DU_PREMIER_BOUTON+190);
383 un_gui.AddWidget(&label_deux_joueurs);
384
385 label_credits.SetText("About");
386 label_credits.SetPos(POSITION_X_DES_BOUTONS-10,POSITION_Y_DU_PREMIER_BOUTON+320);
387 un_gui.AddWidget(&label_credits);
388
389 label_quitter.SetText("Quit");
390 label_quitter.SetPos(POSITION_X_DES_BOUTONS-5,POSITION_Y_DU_PREMIER_BOUTON+450);
391 un_gui.AddWidget(&label_quitter);
392
393 titre_info.SetPos(0,720);
394 titre_info.SetSize(1024,30);
395 un_gui.AddWidget(&titre_info);
396
397 numero_version.SetText("V"GAME_VERSION);
398 numero_version.SetPos(750,100);
399 un_gui.AddWidget(&numero_version);
400
401 for(int i=0;i<NOMBRE_DE_MESSAGES_DES_CREDITS;i++)
402 {
403 credits_labels[i] = new CGuiLabel(MESSAGES_DES_CREDITS[i]);
404 // Si la chaine commence par '-' alors c'est un titre et
405 // on le change de couleur
406 if (MESSAGES_DES_CREDITS[i][0]=='-')
407 credits_labels[i]->SetColor(0.0f,0.0f,1.0f);
408 // On met une très grosse largeur de manière à ce que le texte
409 // soit centré.
410 credits_labels[i]->SetSize(1024,20);
411 }
412
413 doit_afficher_credits=false;
414 doit_afficher_menu=true;
415 fade_out=true;
416 fade_in=false;
417 fade_out_valeur=1.0f;
418 fade_in_valeur=0.0f;
419 angleCameraX=1.0f;
420 angleCameraZ=0.8f;
421 scene_suivante=E_SCENE_MENU_PRINCIPAL;
422 //---------------------------//
423
424 fin_du_chargement();
425 return true;
426 }
427
decharger()428 void E_scene_menu_principal::decharger()
429 {
430 if (deja_charge==false)
431 return;
432
433 decharger_objets_3d();
434
435 delete damier;
436 damier=NULL;
437
438 delete textureSol;
439 textureSol=NULL;
440
441 for(int i=0;i<NOMBRE_DE_MESSAGES_DES_CREDITS;i++)
442 {
443 delete credits_labels[i];
444 credits_labels[i]=NULL;
445 }
446
447 un_gui.Destroy();
448
449 delete fontTexture;
450 fontTexture=NULL;
451
452 delete texture_bouton_un_joueur;
453 texture_bouton_un_joueur=NULL;
454
455 delete texture_bouton_deux_joueurs;
456 texture_bouton_deux_joueurs=NULL;
457
458 delete texture_bouton_credits;
459 texture_bouton_credits=NULL;
460
461 delete texture_bouton_quitter;
462 texture_bouton_quitter=NULL;
463
464 delete texture_blender;
465 texture_blender=NULL;
466
467 delete texture_kate;
468 texture_kate=NULL;
469
470 delete texture_gimp;
471 texture_gimp=NULL;
472
473 delete texture_tux;
474 texture_tux=NULL;
475
476 delete titre;
477 titre=NULL;
478
479 deja_charge=false;
480 }
481
actualiser()482 void E_scene_menu_principal::actualiser()
483 {
484 if (deja_charge==false)
485 {
486 if ( charger()==false )
487 {
488 printf("Loading of 'E_scene_menu_principal' failed: exiting...\n");
489 pGlobalInfos->quitter_le_jeu();
490 return;
491 }
492 }
493
494
495 afficher_echiquier();
496
497 aller_en_2d();
498
499 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
500 glEnable(GL_BLEND);
501
502 glColor4f(0.0f,0.0f,0.0f,0.55f);
503 dessiner_rectangle_plein(0,0,1024,768);
504
505 glColor3f(1.0f,1.0f,1.0f);
506 dessiner_image(10,700,64,64,texture_blender);
507 dessiner_image(80,700,64,64,texture_gimp);
508 dessiner_image(880,700,64,64,texture_kate);
509 dessiner_image(950,700,64,64,texture_tux);
510 dessiner_image(256,20,512,128,titre);
511
512
513 if (fade_in==false)
514 {
515 GLfloat largeur=(GLfloat)pGlobalInfos->largeurEcran();
516 GLfloat hauteur=(GLfloat)pGlobalInfos->hauteurEcran();
517 int x=(int) (1024.0f*pGlobalInfos->SourisX()/largeur);
518 int y=(int) (768.0f*pGlobalInfos->SourisY()/hauteur);
519
520 if (y>700)
521 {
522 if (x<80)
523 titre_info.SetText("3D models with blender");
524 else
525 if (x>=80 && x<144)
526 titre_info.SetText("Image manipulation with The GIMP");
527 else
528 if (x>=880 && x<950)
529 titre_info.SetText("Written with Kate");
530 else
531 if (x>=950)
532 titre_info.SetText("Developed with Linux");
533 else
534 titre_info.SetText("(C) 2005-2006 Frederic MARTIN");
535 }
536 else
537 titre_info.SetText("(C) 2005-2006 Frederic MARTIN");
538
539 un_gui.Update(x,y,pGlobalInfos->cliqueGaucheEnfonce());
540 }
541 else
542 un_gui.Update();
543
544 if (doit_afficher_menu)
545 afficher_menu();
546 else if (doit_afficher_credits)
547 afficher_credits();
548
549 quitter_la_2d();
550
551 }
552
553
afficher_menu_init()554 void E_scene_menu_principal::afficher_menu_init()
555 {
556 doit_afficher_credits=false;
557 doit_afficher_menu=true;
558
559 for(int i=0;i<NOMBRE_DE_MESSAGES_DES_CREDITS;i++)
560 un_gui.RemoveWidget(credits_labels[i]);
561
562 un_gui.AddWidget(&bouton_un_joueur);
563 un_gui.AddWidget(&bouton_deux_joueurs);
564 un_gui.AddWidget(&bouton_credits);
565 un_gui.AddWidget(&bouton_quitter);
566 un_gui.AddWidget(&label_un_joueur);
567 un_gui.AddWidget(&label_deux_joueurs);
568 un_gui.AddWidget(&label_credits);
569 un_gui.AddWidget(&label_quitter);
570
571 }
572
573
afficher_credits_init()574 void E_scene_menu_principal::afficher_credits_init()
575 {
576 doit_afficher_menu=false;
577 doit_afficher_credits=true;
578
579 un_gui.RemoveWidget(&bouton_un_joueur);
580 un_gui.RemoveWidget(&bouton_deux_joueurs);
581 un_gui.RemoveWidget(&bouton_credits);
582 un_gui.RemoveWidget(&bouton_quitter);
583 un_gui.RemoveWidget(&label_un_joueur);
584 un_gui.RemoveWidget(&label_deux_joueurs);
585 un_gui.RemoveWidget(&label_credits);
586 un_gui.RemoveWidget(&label_quitter);
587
588 credits_position=0;
589
590 for(int i=0;i<NOMBRE_DE_MESSAGES_DES_CREDITS;i++)
591 {
592 credits_labels[i]->SetAlpha(0.0f);//on les cache
593 un_gui.AddWidget(credits_labels[i]);
594 }
595
596 }
597
598
afficher_menu()599 void E_scene_menu_principal::afficher_menu()
600 {
601 glEnable(GL_BLEND);
602 // actualise le fade_out
603 if (fade_out)
604 {
605 glColor4f(0.0f,0.0f,0.0f,fade_out_valeur);
606 dessiner_rectangle_plein(0,0,1024,768);
607 fade_out_valeur-=pGlobalInfos->tempsEcoule()/350.0f;
608 if (fade_out_valeur<=0.0f)
609 fade_out=false;
610 }
611
612 // actualise le fade_in
613 if (fade_in)
614 {
615 glColor4f(0.0f,0.0f,0.0f,fade_in_valeur);
616 dessiner_rectangle_plein(0,0,1024,768);
617 fade_in_valeur+=pGlobalInfos->tempsEcoule()/350.0f;
618 if (fade_in_valeur>=1.0f)
619 {
620 quitter_la_2d();
621 effaceEcran();
622 SDL_Delay(100);
623 decharger();
624 pGlobalInfos->changer_de_scene(scene_suivante);
625 return;
626 }
627 }
628
629 if (scene_suivante!=E_SCENE_MENU_PRINCIPAL)
630 fade_in=true;
631
632 // si la touche ECHAP est enfoncée on quitte le jeu
633 if (pGlobalInfos->touche_est_enfonce(SDLK_ESCAPE))
634 {
635 pGlobalInfos->relacher_touches();
636 pGlobalInfos->quitter_le_jeu();
637 }
638
639 SDL_Delay(20);
640 }
641
642
afficher_credits()643 void E_scene_menu_principal::afficher_credits()
644 {
645 int hauteur_label=30;
646 int debut_fade_in=30;// Do not change 30 !
647 int debut_fade_out=450;
648
649 credits_position++;
650
651 for(int i=0;i<NOMBRE_DE_MESSAGES_DES_CREDITS;i++)
652 {
653 credits_labels[i]->SetPos(0,POSITION_Y_DU_PREMIER_BOUTON+debut_fade_out-credits_position+hauteur_label*i);
654 int y=credits_labels[i]->getY();
655 if (y>POSITION_Y_DU_PREMIER_BOUTON+debut_fade_out)
656 credits_labels[i]->SetAlpha(0.0f);
657 if (y<POSITION_Y_DU_PREMIER_BOUTON-debut_fade_in)
658 credits_labels[i]->SetAlpha(0.0f);
659 if (y>POSITION_Y_DU_PREMIER_BOUTON+debut_fade_out-debut_fade_in && y<POSITION_Y_DU_PREMIER_BOUTON+debut_fade_out)
660 credits_labels[i]->SetAlpha((POSITION_Y_DU_PREMIER_BOUTON+debut_fade_out-(float)y)/30.0f);
661 if (y>POSITION_Y_DU_PREMIER_BOUTON-debut_fade_in && y<POSITION_Y_DU_PREMIER_BOUTON)
662 credits_labels[i]->SetAlpha(1.0f-(((float)POSITION_Y_DU_PREMIER_BOUTON-(float)y)/30.0f));
663 }
664
665
666
667 if (credits_position>(debut_fade_in+debut_fade_out+hauteur_label*NOMBRE_DE_MESSAGES_DES_CREDITS))
668 afficher_menu_init();
669
670 // si la touche ECHAP est enfoncée alors on quitte les crédits
671 if (pGlobalInfos->touche_est_enfonce(SDLK_ESCAPE))
672 {
673 pGlobalInfos->relacher_touches();
674 afficher_menu_init();
675 }
676
677 SDL_Delay(25);// Limite le FPS
678
679 }
680