2 Copyright (C) 2003, 2010 - Wolfire Games
4 This file is part of Lugaru.
6 Lugaru is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; either version 2
9 of the License, or (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 See the GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 #include "openal_wrapper.h"
33 extern int environment;
34 extern float texscale;
36 extern Terrain terrain;
37 //extern Sprites sprites;
38 extern float multiplier;
40 extern float viewdistance;
41 extern float fadestart;
42 extern float screenwidth,screenheight;
43 extern int kTextureSize;
44 extern FRUSTUM frustum;
46 extern Objects objects;
48 extern float usermousesensitivity;
50 extern float camerashake;
52 extern float slomodelay;
53 extern bool ismotionblur;
55 extern float blackout;
56 extern bool damageeffects;
58 extern bool texttoggle;
59 extern float blurness;
60 extern float targetblurness;
61 extern float playerdist;
62 extern bool cellophane;
64 extern float flashamount,flashr,flashg,flashb;
65 extern int flashdelay;
67 extern float motionbluramount;
69 extern bool alwaysblur;
71 extern bool tilt2weird;
72 extern bool tiltweird;
74 extern bool proportionweird;
75 extern bool vertexweird[6];
76 extern bool velocityblur;
77 extern bool debugmode;
79 extern int oldmainmenu;
80 extern int bloodtoggle;
81 extern int difficulty;
84 //extern int texdetail;
85 extern float texdetail;
86 extern bool musictoggle;
87 extern int tutoriallevel;
88 extern float smoketex;
89 extern float tutorialstagetime;
90 extern float tutorialmaxtime;
91 extern int tutorialstage;
92 extern bool againbonus;
93 extern float damagedealt;
94 extern bool invertmouse;
96 extern int numhotspots;
97 extern int killhotspot;
98 extern XYZ hotspot[40];
99 extern int hotspottype[40];
100 extern float hotspotsize[40];
101 extern char hotspottext[40][256];
102 extern int currenthotspot;;
104 extern bool campaign;
105 extern bool winfreeze;
107 extern float menupulse;
109 extern bool gamestart;
111 extern bool gamestarted;
113 extern bool showdamagebar;
116 normalmode, motionblurmode, radialzoommode,
117 realmotionblurmode, doublevisionmode, glowmode,
120 void Game::flash() { // shouldn't be that way, these should be attributes and Person class should not change rendering.
127 /*********************> DrawGLScene() <*****/
128 int Game::DrawGLScene(StereoSide side)
130 static float texcoordwidth,texcoordheight;
131 static float texviewwidth, texviewheight;
133 static GLubyte color;
134 static XYZ checkpoint;
135 static float tempmult;
137 static char string[256]="";
138 static char string2[256]="";
139 static char string3[256]="";
141 if ( stereomode == stereoAnaglyph ) {
143 case stereoLeft: glColorMask( 0.0, 1.0, 1.0, 1.0 ); break;
144 case stereoRight: glColorMask( 1.0, 0.0, 0.0, 1.0 ); break;
147 glColorMask( 1.0, 1.0, 1.0, 1.0 );
149 if ( stereomode == stereoHorizontalInterlaced || stereomode == stereoVerticalInterlaced ) {
150 glStencilFunc(side == stereoLeft ? GL_NOTEQUAL : GL_EQUAL, 0x01, 0x01);
154 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)){
161 numboundaries=mapradius*2;
162 if(numboundaries>360)numboundaries=360;
163 for(i=0;i<numboundaries;i++){
166 boundary[i]=mapcenter+DoRotation(boundary[i]*mapradius,0,i*(360/((float)(numboundaries))),0);
175 olddrawmode=drawmode;
176 if(ismotionblur&&!loading){
177 if((findLengthfast(&player[0].velocity)>200)&&velocityblur&&!cameramode){
178 drawmode=motionblurmode;
179 motionbluramount=200/(findLengthfast(&player[0].velocity));
182 if(player[0].damage-player[0].superpermanentdamage>(player[0].damagetolerance-player[0].superpermanentdamage)*1/2&&damageeffects&&!cameramode){
183 drawmode=doublevisionmode;
190 drawmode=motionblurmode;
192 slomodelay-=multiplier;
198 if((!changed&&!slomo)||loading){
200 if(ismotionblur&&(/*fps>100||*/alwaysblur)){
201 if(olddrawmode!=realmotionblurmode)
205 drawmode=realmotionblurmode;
206 }else if(olddrawmode==realmotionblurmode)
212 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted))
214 if((freeze||winfreeze)&&ismotionblur&&!mainmenu)
215 drawmode=radialzoommode;
217 if(winfreeze||mainmenu)drawmode=normalmode;
220 if(drawmode==glowmode){
225 DSpContext_FadeGamma(NULL,200,&color2);
230 drawtoggle=1-drawtoggle;
233 texviewwidth=kTextureSize;
234 if(texviewwidth>screenwidth)
235 texviewwidth=screenwidth;
236 texviewheight=kTextureSize;
237 if(texviewheight>screenheight)
238 texviewheight=screenheight;
240 texcoordwidth=screenwidth/kTextureSize;
241 texcoordheight=screenheight/kTextureSize;
248 glDrawBuffer(GL_BACK);
249 glReadBuffer(GL_BACK);
252 static XYZ terrainlight;
253 static float distance;
254 if(drawmode==normalmode)
255 ReSizeGLScene(90,.1f);
256 if(drawmode!=normalmode)
257 glViewport(0,0,texviewwidth,texviewheight);
258 glDepthFunc(GL_LEQUAL);
260 glAlphaFunc(GL_GREATER, 0.0001f);
261 glEnable(GL_ALPHA_TEST);
262 glClearColor(0.25f, 0.25f, 0.25f, 1.0f);
263 glClear(GL_DEPTH_BUFFER_BIT);
265 glMatrixMode (GL_MODELVIEW);
266 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
269 // Move the camera for the current eye's point of view.
270 // Reverse the movement if we're reversing stereo
271 glTranslatef((stereoseparation/2) * side * (stereoreverse ? -1 : 1), 0, 0);
274 if(!cameramode&&!freeze&&!winfreeze){
276 glRotatef(float(Random()%100)/10*camerashake/*+(woozy*woozy)/10*/,0,0,1);
278 glRotatef(rotation2+sin(woozy/2)*(player[0].damage/player[0].damagetolerance)*5,1,0,0);
279 glRotatef(rotation+sin(woozy)*(player[0].damage/player[0].damagetolerance)*5,0,1,0);
281 if(cameramode||freeze||winfreeze){
282 glRotatef(rotation2,1,0,0);
283 glRotatef(rotation,0,1,0);
286 if(environment==desertenvironment){
287 glRotatef((float)(abs(Random()%100))/3000-1,1,0,0);
288 glRotatef((float)(abs(Random()%100))/3000-1,0,1,0);
290 SetUpLight(&light,0);
293 //heat blur effect in desert
294 if(abs(blurness-targetblurness)<multiplier*10||abs(blurness-targetblurness)>2){
295 blurness=targetblurness;
296 targetblurness=(float)(abs(Random()%100))/40;
298 if(blurness<targetblurness)
299 blurness+=multiplier*5;
301 blurness-=multiplier*5;
303 if(environment==desertenvironment&&detail==2)
304 glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, blurness+.4 );
305 if(environment==desertenvironment){
306 glRotatef((float)(abs(Random()%100))/1000,1,0,0);
307 glRotatef((float)(abs(Random()%100))/1000,0,1,0);
310 glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0);
312 glTranslatef(-viewer.x,-viewer.y,-viewer.z);
313 frustum.GetFrustum();
315 //make shadow decals on terrain and objects
317 static float size,opacity,rotation;
319 for(k=0;k<numplayers;k++){
320 if(!player[k].skeleton.free&&player[k].playerdetail&&player[k].howactive<typesleeping)
321 if(frustum.SphereInFrustum(player[k].coords.x,player[k].coords.y+player[k].scale*3,player[k].coords.z,player[k].scale*7)&&player[k].occluded<25)
322 for(i=0;i<player[k].skeleton.num_joints;i++){
323 if(player[k].skeleton.joints[i].label==leftknee||player[k].skeleton.joints[i].label==rightknee||player[k].skeleton.joints[i].label==groin){
324 point=DoRotation(player[k].skeleton.joints[i].position,0,player[k].rotation,0)*player[k].scale+player[k].coords;
326 opacity=.4-player[k].skeleton.joints[i].position.y*player[k].scale/5-(player[k].coords.y-terrain.getHeight(player[k].coords.x,player[k].coords.z))/10;
327 if(k!=0&&tutoriallevel==1){
328 opacity=.2+.2*sin(smoketex*6+i)-player[k].skeleton.joints[i].position.y*player[k].scale/5-(player[k].coords.y-terrain.getHeight(player[k].coords.x,player[k].coords.z))/10;
330 terrain.MakeDecal(shadowdecal,point,size,opacity,rotation);
331 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
332 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
333 if(objects.position[j].y<player[k].coords.y||objects.type[j]==tunneltype||objects.type[j]==weirdtype){
334 point=DoRotation(DoRotation(player[k].skeleton.joints[i].position,0,player[k].rotation,0)*player[k].scale+player[k].coords-objects.position[j],0,-objects.rotation[j],0);
337 if(k!=0&&tutoriallevel==1){
338 opacity=.2+.2*sin(smoketex*6+i);
340 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
345 if((player[k].skeleton.free||player[k].howactive>=typesleeping)&&player[k].playerdetail)
346 if(frustum.SphereInFrustum(player[k].coords.x,player[k].coords.y,player[k].coords.z,player[k].scale*5)&&player[k].occluded<25)
347 for(i=0;i<player[k].skeleton.num_joints;i++){
348 if(player[k].skeleton.joints[i].label==leftknee||player[k].skeleton.joints[i].label==rightknee||player[k].skeleton.joints[i].label==groin||player[k].skeleton.joints[i].label==leftelbow||player[k].skeleton.joints[i].label==rightelbow||player[k].skeleton.joints[i].label==neck){
349 if(player[k].skeleton.free)
350 point=player[k].skeleton.joints[i].position*player[k].scale+player[k].coords;
352 point=DoRotation(player[k].skeleton.joints[i].position,0,player[k].rotation,0)*player[k].scale+player[k].coords;
354 opacity=.4-player[k].skeleton.joints[i].position.y*player[k].scale/5-(player[k].coords.y-terrain.getHeight(player[k].coords.x,player[k].coords.z))/5;
355 if(k!=0&&tutoriallevel==1){
356 opacity=.2+.2*sin(smoketex*6+i)-player[k].skeleton.joints[i].position.y*player[k].scale/5-(player[k].coords.y-terrain.getHeight(player[k].coords.x,player[k].coords.z))/10;
358 terrain.MakeDecal(shadowdecal,point,size,opacity*.7,rotation);
359 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
360 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
361 if(objects.position[j].y<player[k].coords.y||objects.type[j]==tunneltype||objects.type[j]==weirdtype){
362 if(player[k].skeleton.free)point=DoRotation(player[k].skeleton.joints[i].position*player[k].scale+player[k].coords-objects.position[j],0,-objects.rotation[j],0);
363 else point=DoRotation(DoRotation(player[k].skeleton.joints[i].position,0,player[k].rotation,0)*player[k].scale+player[k].coords-objects.position[j],0,-objects.rotation[j],0);
366 if(k!=0&&tutoriallevel==1){
367 opacity=.2+.2*sin(smoketex*6+i);
369 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
375 if(!player[k].playerdetail)
376 if(frustum.SphereInFrustum(player[k].coords.x,player[k].coords.y,player[k].coords.z,player[k].scale*5)){
377 point=player[k].coords;
379 opacity=.4-(player[k].coords.y-terrain.getHeight(player[k].coords.x,player[k].coords.z))/5;
380 terrain.MakeDecal(shadowdecal,point,size,opacity*.7,rotation);
381 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
382 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
383 point=DoRotation(player[k].coords-objects.position[j],0,-objects.rotation[j],0);
386 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
392 glEnable(GL_TEXTURE_2D);
394 glEnable(GL_DEPTH_TEST);
395 glEnable(GL_CULL_FACE);
397 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
398 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
399 glBindTexture( GL_TEXTURE_2D, terraintexture);
401 glBindTexture( GL_TEXTURE_2D, terraintexture2);
403 //glBindTexture( GL_TEXTURE_2D, terraintexture3);
404 //glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
407 terrain.drawdecals();
410 glEnable(GL_CULL_FACE);
411 glEnable(GL_LIGHTING);
413 glEnable(GL_TEXTURE_2D);
416 glEnable(GL_COLOR_MATERIAL);
431 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
432 glEnable(GL_CULL_FACE);
433 glCullFace(GL_FRONT);
435 for(k=0;k<numplayers;k++){
436 if(k==0||tutoriallevel!=1){
438 glEnable(GL_LIGHTING);
439 terrainlight=terrain.getLighting(player[k].coords.x,player[k].coords.z);
440 distance=findDistancefast(&viewer,&player[k].coords);
441 distance=(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance;
442 glColor4f(terrainlight.x,terrainlight.y,terrainlight.z,distance);
446 checkpoint=DoRotation(player[k].skeleton.joints[abs(Random()%player[k].skeleton.num_joints)].position,0,player[k].rotation,0)*player[k].scale+player[k].coords;
448 if(!player[k].occluded==0)
449 i=checkcollide(viewer,checkpoint,player[k].lastoccluded);
450 if(i==-1||player[k].occluded==0)
451 i=checkcollide(viewer,checkpoint);
453 player[k].occluded+=1;
454 player[k].lastoccluded=i;
456 player[k].occluded=0;
457 if(player[k].occluded<25)
458 player[k].DrawSkeleton();
464 if(!cameramode&&musictype==stream_fighttheme)
465 playerdist=findDistancefastflat(&player[0].coords,&viewer);
470 glEnable(GL_TEXTURE_2D);
476 if(frustum.SphereInFrustum(realhawkcoords.x+hawk.boundingspherecenter.x,realhawkcoords.y+hawk.boundingspherecenter.y,realhawkcoords.z+hawk.boundingspherecenter.z,2)){
477 glAlphaFunc(GL_GREATER, 0.0001f);
479 glDisable(GL_CULL_FACE);
480 glDisable(GL_LIGHTING);
482 glTranslatef(hawkcoords.x,hawkcoords.y,hawkcoords.z);
483 glRotatef(hawkrotation,0,1,0);
484 glTranslatef(25,0,0);
485 distance=findDistancefast(&viewer,&realhawkcoords)*1.2;
486 glColor4f(light.color[0],light.color[1],light.color[2],(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance);
487 if((viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance>1)
488 glColor4f(light.color[0],light.color[1],light.color[2],1);
489 if((viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance>0)
490 hawk.drawdifftex(hawktexture);
494 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
495 glEnable(GL_CULL_FACE);
496 glCullFace(GL_FRONT);
498 for(k=0;k<numplayers;k++){
499 if(!(k==0||tutoriallevel!=1)){
501 glEnable(GL_LIGHTING);
502 terrainlight=terrain.getLighting(player[k].coords.x,player[k].coords.z);
503 distance=findDistancefast(&viewer,&player[k].coords);
504 distance=(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance;
505 glColor4f(terrainlight.x,terrainlight.y,terrainlight.z,distance);
509 checkpoint=DoRotation(player[k].skeleton.joints[abs(Random()%player[k].skeleton.num_joints)].position,0,player[k].rotation,0)*player[k].scale+player[k].coords;
511 if(!player[k].occluded==0)
512 i=checkcollide(viewer,checkpoint,player[k].lastoccluded);
513 if(i==-1||player[k].occluded==0)
514 i=checkcollide(viewer,checkpoint);
516 player[k].occluded+=1;
517 player[k].lastoccluded=i;
519 player[k].occluded=0;
520 if(player[k].occluded<25)
521 player[k].DrawSkeleton();
527 glEnable(GL_TEXTURE_2D);
532 glDisable(GL_COLOR_MATERIAL);
534 glDisable(GL_LIGHTING);
535 glDisable(GL_TEXTURE_2D);
541 //waypoints, pathpoints in editor
544 glDisable(GL_LIGHTING);
545 glDisable(GL_TEXTURE_2D);
546 glDisable(GL_COLOR_MATERIAL);
549 for(k=0;k<numplayers;k++){
550 if(player[k].numwaypoints>1){
551 glBegin(GL_LINE_LOOP);
552 for(i=0;i<player[k].numwaypoints;i++){
553 glVertex3f(player[k].waypoints[i].x,player[k].waypoints[i].y+.5,player[k].waypoints[i].z);
562 for(k=0;k<numpathpoints;k++){
563 if(numpathpointconnect[k]){
564 for(i=0;i<numpathpointconnect[k];i++){
565 glBegin(GL_LINE_LOOP);
566 glVertex3f(pathpoint[k].x,pathpoint[k].y+.5,pathpoint[k].z);
567 glVertex3f(pathpoint[pathpointconnect[k][i]].x,pathpoint[pathpointconnect[k][i]].y+.5,pathpoint[pathpointconnect[k][i]].z);
575 glVertex3f(pathpoint[pathpointselected].x,pathpoint[pathpointselected].y+.5,pathpoint[pathpointselected].z);
582 glEnable(GL_TEXTURE_2D);
583 glColor4f(.5,.5,.5,1);
585 sprintf (string, " ",(int)(fps));
586 text.glPrint(10,30,string,0,.8,screenwidth,screenheight);
589 if(bonus>0&&bonustime<1&&!winfreeze&&indialogue==-1/*bonustime<4*/){
590 const char *bonus_name;
591 if (bonus < bonus_count)
592 bonus_name = bonus_names[bonus];
594 bonus_name = "Excellent!"; // When does this happen?
596 glColor4f(0,0,0,1-bonustime);
597 text.glPrintOutline(1024/2-10*strlen(bonus_name)-4,768/16-4+768*4/5,bonus_name,1,2.5,1024,768);
598 glColor4f(1,0,0,1-bonustime);
599 text.glPrint(1024/2-10*strlen(bonus_name),768/16+768*4/5,bonus_name,1,2,1024,768);
601 sprintf (string, "%d",(int)bonusvalue);
602 glColor4f(0,0,0,1-bonustime);
603 text.glPrintOutline(1024/2-10*strlen(string)-4,768/16-4-20+768*4/5,string,1,2.5*.8,1024,768);
604 glColor4f(1,0,0,1-bonustime);
605 text.glPrint(1024/2-10*strlen(string),768/16-20+768*4/5,string,1,2*.8,1024,768);
606 glColor4f(.5,.5,.5,1);
609 if(tutoriallevel==1){
610 tutorialopac=tutorialmaxtime-tutorialstagetime;
611 if(tutorialopac>1)tutorialopac=1;
612 if(tutorialopac<0)tutorialopac=0;
614 sprintf (string, " ");
615 sprintf (string2, " ");
616 sprintf (string3, " ");
617 if(tutorialstage==0){
618 sprintf (string, " ");
619 sprintf (string2, " ");
620 sprintf (string3, " ");
622 if(tutorialstage==1){
623 sprintf (string, "Welcome to the Lugaru training level!");
624 sprintf (string2, " ");
625 sprintf (string3, " ");
627 if(tutorialstage==2){
628 sprintf (string, "BASIC MOVEMENT:");
629 sprintf (string2, " ");
630 sprintf (string3, " ");
632 if(tutorialstage==3){
633 sprintf (string, "You can move the mouse to rotate the camera.");
634 sprintf (string2, " ");
635 sprintf (string3, " ");
637 if(tutorialstage==4){
638 sprintf (string, "Try using the %s, %s, %s and %s keys to move around.",Input::keyToChar(forwardkey),Input::keyToChar(leftkey),Input::keyToChar(backkey),Input::keyToChar(rightkey));
639 sprintf (string2, "All movement is relative to the camera.");
640 sprintf (string3, " ");
642 if(tutorialstage==5){
643 sprintf (string, "Please press %s to jump.",Input::keyToChar(jumpkey));
644 sprintf (string2, "You can hold it longer to jump higher.");
645 sprintf (string3, " ");
647 if(tutorialstage==6){
648 sprintf (string, "You can press %s to crouch.",Input::keyToChar(crouchkey));
649 sprintf (string2, "You can jump higher from a crouching position.");
650 sprintf (string3, " ");
652 if(tutorialstage==7){
653 sprintf (string, "While running, you can press %s to roll.",Input::keyToChar(crouchkey));
654 sprintf (string2, " ");
655 sprintf (string3, " ");
657 if(tutorialstage==8){
658 sprintf (string, "While crouching, you can sneak around silently");
659 sprintf (string2, "using the movement keys.");
660 sprintf (string3, " ");
662 if(tutorialstage==9){
663 sprintf (string, "Release the crouch key while sneaking and hold the movement keys");
664 sprintf (string2, "to run animal-style.");
665 sprintf (string3, " ");
667 if(tutorialstage==10){
668 sprintf (string, "ADVANCED MOVEMENT:");
669 sprintf (string2, " ");
670 sprintf (string3, " ");
672 if(tutorialstage==11){
673 sprintf (string, "When you jump at a wall, you can hold %s again",Input::keyToChar(jumpkey));
674 sprintf (string2, "during impact to perform a walljump.");
675 sprintf (string3, "Be sure to use the movement keys to press against the wall");
677 if(tutorialstage==12){
678 sprintf (string, "While in the air, you can press crouch to flip.",Input::keyToChar(jumpkey));
679 sprintf (string2, "Walljumps and flips confuse enemies and give you more control.");
680 sprintf (string3, " ");
682 if(tutorialstage==13){
683 sprintf (string, "BASIC COMBAT:");
684 sprintf (string2, " ");
685 sprintf (string3, " ");
687 if(tutorialstage==14){
688 sprintf (string, "There is now an imaginary enemy");
689 sprintf (string2, "in the middle of the training area.");
690 sprintf (string3, " ");
692 if(tutorialstage==15){
693 if(attackkey==MOUSEBUTTON1)sprintf (string, "Click to attack when you are near an enemy.");
694 else sprintf (string, "Press %s to attack when you are near an enemy.",Input::keyToChar(attackkey));
695 sprintf (string2, "You can punch by standing still near an enemy and attacking.");
696 sprintf (string3, " ");
698 if(tutorialstage==16){
699 sprintf (string, "If you are close, you will perform a weak punch.");
700 sprintf (string2, "The weak punch is excellent for starting attack combinations.");
701 sprintf (string3, " ");
703 if(tutorialstage==17){
704 sprintf (string, "Attacking while running results in a spin kick.");
705 sprintf (string2, "This is one of your most powerful ground attacks.");
706 sprintf (string3, " ");
708 if(tutorialstage==18){
709 sprintf (string, "Sweep the enemy's legs out by attacking while crouched.");
710 sprintf (string2, "This is a very fast attack, and easy to follow up.");
711 sprintf (string3, " ");
713 if(tutorialstage==19){
714 sprintf (string, "When an enemy is on the ground, you can deal some extra");
715 sprintf (string2, "damage by running up and drop-kicking him.");
716 sprintf (string3, "(Try knocking them down with a sweep first)");
718 if(tutorialstage==20){
719 sprintf (string, "Your most powerful individual attack is the rabbit kick.");
720 if(attackkey==MOUSEBUTTON1)sprintf (string2, "Run at the enemy while holding the mouse button, and press");
721 else sprintf (string2, "Run at the enemy while holding %s, and press", Input::keyToChar(attackkey));
722 sprintf (string3, "the jump key (%s) to attack.",Input::keyToChar(jumpkey));
724 if(tutorialstage==21){
725 sprintf (string, "This attack is devastating if timed correctly.");
726 sprintf (string2, "Even if timed incorrectly, it will knock the enemy over.");
727 if(againbonus)sprintf (string3, "Try rabbit-kicking the imaginary enemy again.");
728 else sprintf (string3, "Try rabbit-kicking the imaginary enemy.");
730 if(tutorialstage==22){
731 sprintf (string, "If you sneak behind an enemy unnoticed, you can kill");
732 sprintf (string2, "him instantly. Move close behind this enemy");
733 sprintf (string3, "and attack.");
735 if(tutorialstage==23){
736 sprintf (string, "Another important attack is the wall kick. When an enemy");
737 sprintf (string2, "is near a wall, perform a walljump nearby and hold");
738 sprintf (string3, "the attack key during impact with the wall.");
740 if(tutorialstage==24){
741 sprintf (string, "You can tackle enemies by running at them animal-style");
742 if(attackkey==MOUSEBUTTON1)sprintf (string2, "and pressing jump (%s) or attack(mouse button).",Input::keyToChar(jumpkey));
743 else sprintf (string2, "and pressing jump (%s) or attack(%s).",Input::keyToChar(jumpkey),Input::keyToChar(attackkey));
744 sprintf (string3, "This is especially useful when they are running away.");
746 if(tutorialstage==25){
747 sprintf (string, "Dodge by pressing back and attack. Dodging is essential");
748 sprintf (string2, "against enemies with swords or other long weapons.");
749 sprintf (string3, " ");
751 if(tutorialstage==26){
752 sprintf (string, "REVERSALS AND COUNTER-REVERSALS");
753 sprintf (string2, " ");
754 sprintf (string3, " ");
756 if(tutorialstage==27){
757 sprintf (string, "The enemy can now reverse your attacks.");
758 sprintf (string2, " ");
759 sprintf (string3, " ");
761 if(tutorialstage==28){
762 sprintf (string, "If you attack, you will notice that the enemy now sometimes");
763 sprintf (string2, "catches your attack and uses it against you. Hold");
764 sprintf (string3, "crouch (%s) after attacking to escape from reversals.",Input::keyToChar(crouchkey));
766 if(tutorialstage==29){
767 sprintf (string, "Try escaping from two more reversals in a row.");
768 sprintf (string2, " ");
769 sprintf (string3, " ");
771 if(tutorialstage==30){
772 sprintf (string, "Good!");
773 sprintf (string2, " ");
774 sprintf (string3, " ");
776 if(tutorialstage==31){
777 sprintf (string, "To reverse an attack, you must tap crouch (%s) during the",Input::keyToChar(crouchkey));
778 sprintf (string2, "enemy's attack. You must also be close to the enemy;");
779 sprintf (string3, "this is especially important against armed opponents.");
781 if(tutorialstage==32){
782 sprintf (string, "The enemy can attack in %d seconds.", (int)(tutorialmaxtime-tutorialstagetime));
783 sprintf (string2, "This imaginary opponents attacks will be highlighted");
784 sprintf (string3, "to make this easier.");
786 if(tutorialstage==33){
787 sprintf (string, "Reverse three enemy attacks!");
788 sprintf (string2, " ");
789 sprintf (string3, " ");
791 if(tutorialstage==34){
792 sprintf (string, "Reverse two more enemy attacks!");
793 sprintf (string2, " ");
794 sprintf (string3, " ");
796 if(tutorialstage==35){
797 sprintf (string, "Reverse one more enemy attack!");
798 sprintf (string2, " ");
799 sprintf (string3, " ");
801 if(tutorialstage==36){
802 sprintf (string, "Excellent!");
803 sprintf (string2, " ");
804 sprintf (string3, " ");
806 if(tutorialstage==37){
807 sprintf (string, "Now spar with the enemy for %d more seconds.", (int)(tutorialmaxtime-tutorialstagetime));
808 sprintf (string2, "Damage dealt: %d",(int)damagedealt);
809 sprintf (string3, "Damage taken: %d.",(int)damagetaken);
811 if(tutorialstage==38){
812 sprintf (string, "WEAPONS:");
813 sprintf (string2, " ");
814 sprintf (string3, " ");
816 if(tutorialstage==39){
817 sprintf (string, "There is now an imaginary knife");
818 sprintf (string2, "in the center of the training area.");
819 sprintf (string3, " ");
821 if(tutorialstage==40){
822 sprintf (string, "Stand, roll or handspring over the knife");
823 sprintf (string2, "while pressing %s to pick it up.",Input::keyToChar(throwkey));
824 sprintf (string3, "You can crouch and press the same key to drop it again.");
826 if(tutorialstage==41){
827 sprintf (string, "You can equip and unequip weapons using the %s key.",Input::keyToChar(drawkey));
828 sprintf (string2, "Sometimes it is best to keep them unequipped to");
829 sprintf (string3, "prevent enemies from taking them. ");
831 if(tutorialstage==42){
832 sprintf (string, "The knife is the smallest weapon and the least encumbering.");
833 sprintf (string2, "You can equip or unequip it while standing, crouching,");
834 sprintf (string3, "running or flipping.");
836 if(tutorialstage==43){
837 sprintf (string, "You perform weapon attacks the same way as unarmed attacks,");
838 sprintf (string2, "but sharp weapons cause permanent damage, instead of the");
839 sprintf (string3, "temporary trauma from blunt weapons, fists and feet.");
841 if(tutorialstage==44){
842 sprintf (string, "The enemy now has your knife!");
843 sprintf (string2, "Please reverse two of his knife attacks.");
844 sprintf (string3, " ");
846 if(tutorialstage==45){
847 sprintf (string, "Please reverse one more of his knife attacks.");
848 sprintf (string2, " ");
849 sprintf (string3, " ");
851 if(tutorialstage==46){
852 sprintf (string, "Now he has a sword!");
853 sprintf (string2, "The sword has longer reach than your arms, so you");
854 sprintf (string3, "must move close to reverse the sword slash.");
856 if(tutorialstage==47){
857 sprintf (string, "Long weapons like the sword and staff are also useful for defense;");
858 sprintf (string2, "you can parry enemy weapon attacks by pressing the attack key");
859 sprintf (string3, "at the right time. Please try parrying the enemy's attacks!");
861 if(tutorialstage==48){
862 sprintf (string, "The staff is like the sword, but has two main attacks.");
863 sprintf (string2, "The standing smash is fast and effective, and the running");
864 sprintf (string3, "spin smash is slower and more powerful.");
866 if(tutorialstage==49){
867 sprintf (string, "When facing an enemy, you can throw the knife with %s.",Input::keyToChar(throwkey));
868 sprintf (string2, "It is possible to throw the knife while flipping,");
869 sprintf (string3, "but it is very inaccurate.");
871 if(tutorialstage==50){
872 sprintf (string, "You now know everything you can learn from training.");
873 sprintf (string2, "Everything else you must learn from experience!");
874 sprintf (string3, " ");
876 if(tutorialstage==51){
877 sprintf (string, "Walk out of the training area to return to the main menu.");
878 sprintf (string2, " ");
879 sprintf (string3, " ");
882 glColor4f(0,0,0,tutorialopac);
883 text.glPrintOutline(screenwidth/2-7.6*strlen(string)*screenwidth/1024-4,screenheight/16-4+screenheight*4/5,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight);
884 text.glPrintOutline(screenwidth/2-7.6*strlen(string2)*screenwidth/1024-4,screenheight/16-4+screenheight*4/5-20*screenwidth/1024,string2,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight);
885 text.glPrintOutline(screenwidth/2-7.6*strlen(string3)*screenwidth/1024-4,screenheight/16-4+screenheight*4/5-40*screenwidth/1024,string3,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight);
886 glColor4f(1,1,1,tutorialopac);
887 text.glPrint(screenwidth/2-7.6*strlen(string)*screenwidth/1024,screenheight/16+screenheight*4/5,string,1,1.5*screenwidth/1024,screenwidth,screenheight);
888 text.glPrint(screenwidth/2-7.6*strlen(string2)*screenwidth/1024,screenheight/16+screenheight*4/5-20*screenwidth/1024,string2,1,1.5*screenwidth/1024,screenwidth,screenheight);
889 text.glPrint(screenwidth/2-7.6*strlen(string3)*screenwidth/1024,screenheight/16+screenheight*4/5-40*screenwidth/1024,string3,1,1.5*screenwidth/1024,screenwidth,screenheight);
891 sprintf (string, "Press 'tab' to skip to the next item.",Input::keyToChar(jumpkey));
892 sprintf (string2, "Press escape at any time to");
893 sprintf (string3, "pause or exit the tutorial.");
896 text.glPrintOutline(screenwidth/2-7.6*strlen(string)*screenwidth/1024*.8-4,0-4+screenheight*1/10,string,1,1.5*1.25*screenwidth/1024*.8,screenwidth,screenheight);
897 text.glPrintOutline(screenwidth/2-7.6*strlen(string2)*screenwidth/1024*.8-4,0-4+screenheight*1/10-20*.8*screenwidth/1024,string2,1,1.5*1.25*screenwidth/1024*.8,screenwidth,screenheight);
898 text.glPrintOutline(screenwidth/2-7.6*strlen(string3)*screenwidth/1024*.8-4,0-4+screenheight*1/10-40*.8*screenwidth/1024,string3,1,1.5*1.25*screenwidth/1024*.8,screenwidth,screenheight);
899 glColor4f(0.5,0.5,0.5,1);
900 text.glPrint(screenwidth/2-7.6*strlen(string)*screenwidth/1024*.8,0+screenheight*1/10,string,1,1.5*screenwidth/1024*.8,screenwidth,screenheight);
901 text.glPrint(screenwidth/2-7.6*strlen(string2)*screenwidth/1024*.8,0+screenheight*1/10-20*.8*screenwidth/1024,string2,1,1.5*screenwidth/1024*.8,screenwidth,screenheight);
902 text.glPrint(screenwidth/2-7.6*strlen(string3)*screenwidth/1024*.8,0+screenheight*1/10-40*.8*screenwidth/1024,string3,1,1.5*screenwidth/1024*.8,screenwidth,screenheight);
906 if(numhotspots&&(bonustime>=1||bonus<=0||bonustime<0)&&!tutoriallevel){
908 float closestdist=-1;
910 closest=currenthotspot;
911 for(i=0;i<numhotspots;i++){
912 distance=findDistancefast(&player[0].coords,&hotspot[i]);
913 if(closestdist==-1||distance<closestdist){
914 if(findDistancefast(&player[0].coords,&hotspot[i])<hotspotsize[i]&&((hotspottype[i]<=10&&hotspottype[i]>=0)||(hotspottype[i]<=40&&hotspottype[i]>=20))){
915 closestdist=distance;
921 currenthotspot=closest;
922 if(currenthotspot!=-1){
923 if(hotspottype[closest]<=10){
924 if(findDistancefast(&player[0].coords,&hotspot[closest])<hotspotsize[closest])
927 tutorialopac=tutorialmaxtime-tutorialstagetime;
928 if(tutorialopac>1)tutorialopac=1;
929 if(tutorialopac<0)tutorialopac=0;
931 sprintf (string, "%s", hotspottext[closest]);
938 if(string[i]=='\n'||string[i]>'z'||string[i]<' '||string[i]=='\0'){
939 glColor4f(0,0,0,tutorialopac);
940 text.glPrintOutline(screenwidth/2-7.6*(i-lastline)*screenwidth/1024-4,screenheight/16-4+screenheight*4/5-20*screenwidth/1024*line,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight,lastline,i);
941 glColor4f(1,1,1,tutorialopac);
942 text.glPrint(screenwidth/2-7.6*(i-lastline)*screenwidth/1024,screenheight/16+screenheight*4/5-20*screenwidth/1024*line,string,1,1.5*screenwidth/1024,screenwidth,screenheight,lastline,i);
945 if(string[i]=='\0')done=1;
950 } else if (hotspottype[closest]>=20&&dialoguegonethrough[hotspottype[closest]-20]==0){
951 whichdialogue=hotspottype[closest]-20;
952 for(j=0;j<numdialogueboxes[whichdialogue];j++){
953 player[participantfocus[whichdialogue][j]].coords=participantlocation[whichdialogue][participantfocus[whichdialogue][j]];
954 player[participantfocus[whichdialogue][j]].rotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
955 player[participantfocus[whichdialogue][j]].targetrotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
956 player[participantfocus[whichdialogue][j]].velocity=0;
957 player[participantfocus[whichdialogue][j]].targetanimation=player[participantfocus[whichdialogue][j]].getIdle();
958 player[participantfocus[whichdialogue][j]].targetframe=0;
962 dialoguegonethrough[whichdialogue]++;
963 if(dialogueboxsound[whichdialogue][indialogue]!=0){
965 if(dialogueboxsound[whichdialogue][indialogue]==1)whichsoundplay=rabbitchitter;
966 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
967 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
968 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
969 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
970 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
971 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
972 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
973 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
974 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
975 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
976 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
977 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
978 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
979 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
980 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
981 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
982 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
983 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
984 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
985 emit_sound_at(whichsoundplay, player[participantfocus[whichdialogue][indialogue]].coords);
991 if(indialogue!=-1&&!mainmenu){
992 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
993 glDisable(GL_CULL_FACE);
994 glDisable(GL_LIGHTING);
995 glDisable(GL_TEXTURE_2D);
997 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
998 glPushMatrix(); // Store The Projection Matrix
999 glLoadIdentity(); // Reset The Projection Matrix
1000 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1001 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1002 glPushMatrix(); // Store The Modelview Matrix
1003 glLoadIdentity(); // Reset The Modelview Matrix
1004 if(dialogueboxlocation[whichdialogue][indialogue]==1)glTranslatef(0,screenheight*3/4,0);
1005 glScalef(screenwidth,screenheight/4,1);
1006 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1009 glColor4f(dialogueboxcolor[whichdialogue][indialogue][0],dialogueboxcolor[whichdialogue][indialogue][1],dialogueboxcolor[whichdialogue][indialogue][2],0.7);
1011 glVertex3f(0, 0, 0.0f);
1012 glVertex3f(1, 0, 0.0f);
1013 glVertex3f(1, 1, 0.0f);
1014 glVertex3f(0, 1, 0.0f);
1016 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1017 glPopMatrix(); // Restore The Old Projection Matrix
1018 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1019 glPopMatrix(); // Restore The Old Projection Matrix
1020 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1021 glEnable(GL_CULL_FACE);
1022 glDisable(GL_BLEND);
1024 glEnable(GL_TEXTURE_2D);
1031 startx=screenwidth*1/5;
1032 if(dialogueboxlocation[whichdialogue][indialogue]==1)
1033 starty=screenheight/16+screenheight*4/5;
1034 if(dialogueboxlocation[whichdialogue][indialogue]==2)
1035 starty=screenheight*1/5-screenheight/16;
1044 for(i=0;i<(int)strlen(dialoguename[whichdialogue][indialogue]);i++){
1045 tempname[tempnum]=dialoguename[whichdialogue][indialogue][i];
1047 if(dialoguename[whichdialogue][indialogue][i]=='#'||dialoguename[whichdialogue][indialogue][i]=='\0')goodchar=0;
1051 tempname[tempnum]='\0';
1054 sprintf (string, "%s: ", tempname);
1056 if(dialogueboxcolor[whichdialogue][indialogue][0]+dialogueboxcolor[whichdialogue][indialogue][1]+dialogueboxcolor[whichdialogue][indialogue][2]<1.5){
1057 glColor4f(0,0,0,tutorialopac);
1058 text.glPrintOutline(startx-2*7.6*strlen(string)*screenwidth/1024-4,starty-4,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight);
1059 glColor4f(0.7,0.7,0.7,tutorialopac);
1060 text.glPrint(startx-2*7.6*strlen(string)*screenwidth/1024,starty,string,1,1.5*screenwidth/1024,screenwidth,screenheight);
1064 glColor4f(0,0,0,tutorialopac);
1065 text.glPrintOutline(startx-2*7.6*strlen(string)*screenwidth/1024-4,starty-4,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight);
1069 for(i=0;i<(int)strlen(dialoguetext[whichdialogue][indialogue])+1;i++){
1070 tempname[tempnum]=dialoguetext[whichdialogue][indialogue][i];
1071 if(dialoguetext[whichdialogue][indialogue][i]!='#')tempnum++;
1074 sprintf (string, "%s", tempname);
1081 if(string[i]=='\n'||string[i]>'z'||string[i]<' '||string[i]=='\0'){
1082 if(dialogueboxcolor[whichdialogue][indialogue][0]+dialogueboxcolor[whichdialogue][indialogue][1]+dialogueboxcolor[whichdialogue][indialogue][2]<1.5){
1083 glColor4f(0,0,0,tutorialopac);
1084 text.glPrintOutline(startx/*-7.6*(i-lastline)*screenwidth/1024*/-4,starty-4-20*screenwidth/1024*line,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight,lastline,i);
1085 glColor4f(1,1,1,tutorialopac);
1086 text.glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/,starty-20*screenwidth/1024*line,string,1,1.5*screenwidth/1024,screenwidth,screenheight,lastline,i);
1090 glColor4f(0,0,0,tutorialopac);
1091 text.glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/,starty-20*screenwidth/1024*line,string,1,1.5*screenwidth/1024,screenwidth,screenheight,lastline,i);
1095 if(string[i]=='\0')done=1;
1102 if(!tutoriallevel&&!winfreeze&&indialogue==-1&&!mainmenu){
1105 sprintf (string, "Score: %d", (int)accountactive->getCampaignScore());
1107 sprintf (string, "Score: %d", (int)accountactive->getCampaignScore()+(int)bonustotal);
1109 if(!campaign)sprintf (string, "Score: %d", (int)bonustotal);
1111 text.glPrintOutline(1024/40-4,768/16-4+768*14/16,string,1,1.5*1.25,1024,768);
1113 text.glPrint(1024/40,768/16+768*14/16,string,1,1.5,1024,768);
1115 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1116 glDisable(GL_CULL_FACE);
1117 glDisable(GL_LIGHTING);
1118 glDisable(GL_TEXTURE_2D);
1120 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1121 glPushMatrix(); // Store The Projection Matrix
1122 glLoadIdentity(); // Reset The Projection Matrix
1123 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1124 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1125 glPushMatrix(); // Store The Modelview Matrix
1126 glLoadIdentity(); // Reset The Modelview Matrix
1127 glTranslatef(15,screenheight*17.5/20,0);
1128 glScalef(screenwidth/3+20,screenheight/20,1);
1129 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1131 glColor4f(0.0,0.4,0.0,0.7);
1132 float bar=((float)player[0].damage)/player[0].damagetolerance;
1134 glVertex3f((bar<1?bar:1),0,0.0f);
1135 glVertex3f(1,0,0.0f);
1136 glVertex3f(1,1,0.0f);
1137 glVertex3f((bar<1?bar:1),1,0.0f);
1139 glColor4f(0.1,0.0,0.0,1);
1140 bar = ((float)player[0].bloodloss)/player[0].damagetolerance;
1142 glVertex3f(0,0,0.0f);
1143 glVertex3f((bar<1?bar:1),0,0.0f);
1144 glVertex3f((bar<1?bar:1),1,0.0f);
1145 glVertex3f(0,1,0.0f);
1147 glColor4f(0.4,0.0,0.0,0.7);
1148 bar = ((float)player[0].damage)/player[0].damagetolerance;
1150 glVertex3f(0,0,0.0f);
1151 glVertex3f((bar<1?bar:1),0,0.0f);
1152 glVertex3f((bar<1?bar:1),1,0.0f);
1153 glVertex3f(0,1,0.0f);
1155 glColor4f(0.4,0.0,0.0,0.7);
1156 bar = ((float)player[0].permanentdamage)/player[0].damagetolerance;
1158 glVertex3f(0,0,0.0f);
1159 glVertex3f((bar<1?bar:1),0,0.0f);
1160 glVertex3f((bar<1?bar:1),1,0.0f);
1161 glVertex3f(0,1,0.0f);
1163 glColor4f(0.4,0.0,0.0,0.7);
1164 bar = ((float)player[0].superpermanentdamage)/player[0].damagetolerance;
1166 glVertex3f(0,0,0.0f);
1167 glVertex3f((bar<1?bar:1),0,0.0f);
1168 glVertex3f((bar<1?bar:1),1,0.0f);
1169 glVertex3f(0,1,0.0f);
1171 glColor4f(0.0,0.0,0.0,0.7);
1173 glBegin(GL_LINE_STRIP);
1174 glVertex3f(0,0,0.0f);
1175 glVertex3f(1,0,0.0f);
1176 glVertex3f(1,1,0.0f);
1177 glVertex3f(0,1,0.0f);
1178 glVertex3f(0,0,0.0f);
1181 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1182 glPopMatrix(); // Restore The Old Projection Matrix
1183 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1184 glPopMatrix(); // Restore The Old Projection Matrix
1185 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1186 glEnable(GL_CULL_FACE);
1187 glDisable(GL_BLEND);
1189 glEnable(GL_TEXTURE_2D);
1191 // writing the numbers :
1192 sprintf (string, "Damages : %d/%d (%d)",(int)(player[0].damage),(int)(player[0].damagetolerance),(int)(player[0].bloodloss));
1194 text.glPrintOutline(1024/40-4,768/16-4+768*14/16-40,string,1,1.5*1.25,1024,768);
1196 text.glPrint(1024/40,768/16+768*14/16-40,string,1,1.5,1024,768);
1200 glColor4f(.5,.5,.5,1);
1203 if((texttoggle||editorenabled)&&debugmode&&!mainmenu){
1204 sprintf (string, "The framespersecond is %d.",(int)(fps));
1205 text.glPrint(10,30,string,0,.8,1024,768);
1207 sprintf (string, "Name: %s", registrationname);
1208 text.glPrint(10,260,string,0,.8,1024,768);
1212 sprintf (string, "Map editor enabled.");
1214 sprintf (string, "Map editor disabled.");
1215 text.glPrint(10,60,string,0,.8,1024,768);
1217 sprintf (string, "Object size: %f",editorsize);
1218 text.glPrint(10,75,string,0,.8,1024,768);
1219 if(editorrotation>=0)sprintf (string, "Object rotation: %f",editorrotation);
1220 else sprintf (string, "Object rotation: Random");
1221 text.glPrint(10,90,string,0,.8,1024,768);
1222 if(editorrotation2>=0)sprintf (string, "Object rotation2: %f",editorrotation2);
1223 else sprintf (string, "Object rotation2: Random");
1224 text.glPrint(10,105,string,0,.8,1024,768);
1225 sprintf (string, "Object type: %d",editortype);
1226 text.glPrint(10,120,string,0,.8,1024,768);
1227 switch(editortype) {
1229 sprintf (string, "(box)");
1232 sprintf (string, "(tree)");
1235 sprintf (string, "(wall)");
1238 sprintf (string, "(weird)");
1241 sprintf (string, "(spike)");
1244 sprintf (string, "(rock)");
1247 sprintf (string, "(bush)");
1250 sprintf (string, "(tunnel)");
1253 sprintf (string, "(chimney)");
1256 sprintf (string, "(platform)");
1259 sprintf (string, "(cool)");
1262 sprintf (string, "(fire)");
1265 text.glPrint(130,120,string,0,.8,1024,768);
1267 sprintf (string, "Numplayers: %d",numplayers);
1268 text.glPrint(10,155,string,0,.8,1024,768);
1269 sprintf (string, "Player %d: numwaypoints: %d",numplayers,player[numplayers-1].numwaypoints);
1270 text.glPrint(10,140,string,0,.8,1024,768);
1272 sprintf (string, "Difficulty: %d",difficulty);
1273 text.glPrint(10,240,string,0,.8,1024,768);
1278 if(drawmode==glowmode){
1279 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1280 glDisable(GL_CULL_FACE);
1281 glDisable(GL_LIGHTING);
1282 glDisable(GL_TEXTURE_2D);
1284 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1285 glPushMatrix(); // Store The Projection Matrix
1286 glLoadIdentity(); // Reset The Projection Matrix
1287 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1288 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1289 glPushMatrix(); // Store The Modelview Matrix
1290 glLoadIdentity(); // Reset The Modelview Matrix
1291 glScalef(screenwidth,screenheight,1);
1292 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1294 glColor4f(0,0,0,.5);
1296 glVertex3f(0, 0, 0.0f);
1297 glVertex3f(256, 0, 0.0f);
1298 glVertex3f(256, 256, 0.0f);
1299 glVertex3f(0, 256, 0.0f);
1301 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1302 glPopMatrix(); // Restore The Old Projection Matrix
1303 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1304 glPopMatrix(); // Restore The Old Projection Matrix
1305 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1306 glEnable(GL_CULL_FACE);
1307 glDisable(GL_BLEND);
1311 if((((blackout&&damageeffects)||(player[0].bloodloss>0&&damageeffects&&player[0].blooddimamount>0)||player[0].dead)&&!cameramode)||console){
1312 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1313 glDisable(GL_CULL_FACE);
1314 glDisable(GL_LIGHTING);
1315 glDisable(GL_TEXTURE_2D);
1317 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1318 glPushMatrix(); // Store The Projection Matrix
1319 glLoadIdentity(); // Reset The Projection Matrix
1320 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1321 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1322 glPushMatrix(); // Store The Modelview Matrix
1323 glLoadIdentity(); // Reset The Modelview Matrix
1324 glScalef(screenwidth,screenheight,1);
1325 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1327 if(player[0].dead)blackout+=multiplier*3;
1328 if(player[0].dead==1)blackout=.4f;
1329 if(player[0].dead==2&&blackout>.6)blackout=.6;
1330 glColor4f(0,0,0,blackout);
1331 if(!player[0].dead){
1332 if((player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5))*.3<.3){
1333 glColor4f(0,0,0,player[0].blooddimamount*player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5)*.3);
1334 blackout=player[0].blooddimamount*player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5)*.3;
1337 glColor4f(0,0,0,player[0].blooddimamount*.3);
1338 blackout=player[0].blooddimamount*.3;
1341 if(console)glColor4f(.7,0,0,.2);
1343 glVertex3f(0, 0, 0.0f);
1344 glVertex3f(256, 0, 0.0f);
1345 glVertex3f(256, 256, 0.0f);
1346 glVertex3f(0, 256, 0.0f);
1348 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1349 glPopMatrix(); // Restore The Old Projection Matrix
1350 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1351 glPopMatrix(); // Restore The Old Projection Matrix
1352 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1353 glEnable(GL_CULL_FACE);
1354 glDisable(GL_BLEND);
1358 if(flashamount>0&&damageeffects) {
1359 if(flashamount>1)flashamount=1;
1360 if(flashdelay<=0)flashamount-=multiplier;
1362 if(flashamount<0)flashamount=0;
1363 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1364 glDisable(GL_CULL_FACE);
1365 glDisable(GL_LIGHTING);
1367 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1368 glPushMatrix(); // Store The Projection Matrix
1369 glLoadIdentity(); // Reset The Projection Matrix
1370 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1371 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1372 glPushMatrix(); // Store The Modelview Matrix
1373 glLoadIdentity(); // Reset The Modelview Matrix
1374 glScalef(screenwidth,screenheight,1);
1375 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1377 glColor4f(flashr,flashg,flashb,flashamount);
1379 glVertex3f(0, 0, 0.0f);
1380 glVertex3f(256, 0, 0.0f);
1381 glVertex3f(256, 256, 0.0f);
1382 glVertex3f(0, 256, 0.0f);
1384 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1385 glPopMatrix(); // Restore The Old Projection Matrix
1386 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1387 glPopMatrix(); // Restore The Old Projection Matrix
1388 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1389 glEnable(GL_CULL_FACE);
1390 glDisable(GL_BLEND);
1396 glEnable(GL_TEXTURE_2D);
1399 sprintf (string, " ]");
1400 text.glPrint(10,30+screenheight-330,string,0,1,screenwidth,screenheight);
1402 sprintf (string, "_");
1403 text.glPrint(30+(float)(displayselected)*10,30+(screenheight-330),string,0,1,screenwidth,screenheight);
1407 if((i!=0||chatting)&&displaytime[i]<4)
1408 for(j=0;j<displaychars[i];j++) {
1409 glColor4f(1,1,1,4-displaytime[i]);
1410 if(j<displaychars[i]) {
1411 sprintf (string, "%c",displaytext[i][j]);
1412 text.glPrint(30+j*10,30+i*20+(screenheight-330),string,0,1,screenwidth,screenheight);
1417 if(minimap&&indialogue==-1){
1418 float mapviewdist = 20000;
1420 glDisable(GL_DEPTH_TEST);
1421 glColor3f (1.0, 1.0, 1.0); // no coloring
1423 glEnable(GL_TEXTURE_2D);
1424 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1425 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1426 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1427 glDisable(GL_CULL_FACE);
1428 glDisable(GL_LIGHTING);
1430 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1431 glPushMatrix(); // Store The Projection Matrix
1432 glLoadIdentity(); // Reset The Projection Matrix
1433 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1434 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1435 glPushMatrix(); // Store The Modelview Matrix
1436 glLoadIdentity(); // Reset The Modelview Matrix
1437 glScalef((float)screenwidth/2,(float)screenwidth/2,1);
1438 glTranslatef(1.75,.25,0);
1439 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1447 int numliveplayers=0;
1449 for(i=0;i<numplayers;i++){
1450 if(!player[i].dead) numliveplayers++;
1455 for(i=0;i<objects.numobjects;i++){
1456 if(objects.type[i]==treetrunktype||objects.type[i]==boxtype){
1457 center+=objects.position[i];
1461 for(i=0;i<numplayers;i++){
1462 if(!player[i].dead)center+=player[i].coords;
1464 center/=numadd+numliveplayers;
1466 center=player[0].coords;
1468 float maxdistance=0;
1470 //~ int whichclosest;
1471 for(i=0;i<objects.numobjects;i++){
1472 tempdist=findDistancefast(¢er,&objects.position[i]);
1473 if(tempdist>maxdistance){
1475 maxdistance=tempdist;
1478 for(i=0;i<numplayers;i++){
1479 if(!player[i].dead){
1480 tempdist=findDistancefast(¢er,&player[i].coords);
1481 if(tempdist>maxdistance){
1483 maxdistance=tempdist;
1487 radius=fast_sqrt(maxdistance);
1491 glScalef(.25/radius*256*terrain.scale*.4,.25/radius*256*terrain.scale*.4,1);
1493 glScalef(1/(1/radius*256*terrain.scale*.4),1/(1/radius*256*terrain.scale*.4),1);
1495 glRotatef(player[0].lookrotation*-1+180,0,0,1);
1496 glTranslatef(-(center.x/terrain.scale/256*-2+1),(center.z/terrain.scale/256*-2+1),0);
1497 for(i=0;i<objects.numobjects;i++){
1498 if(objects.type[i]==treetrunktype){
1499 distcheck=findDistancefast(&player[0].coords,&objects.position[i]);
1500 if(distcheck<mapviewdist){
1501 glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
1502 glColor4f(0,.3,0,opac*(1-distcheck/mapviewdist));
1504 glTranslatef(objects.position[i].x/terrain.scale/256*-2+1,objects.position[i].z/terrain.scale/256*2-1,0);
1505 glRotatef(objects.rotation[i],0,0,1);
1506 glScalef(.003,.003,.003);
1509 glVertex3f(-1, -1, 0.0f);
1511 glVertex3f(1, -1, 0.0f);
1513 glVertex3f(1, 1, 0.0f);
1515 glVertex3f(-1, 1, 0.0f);
1520 if(objects.type[i]==boxtype){
1521 distcheck=findDistancefast(&player[0].coords,&objects.position[i]);
1522 if(distcheck<mapviewdist){
1523 glBindTexture( GL_TEXTURE_2D, Mapboxtexture);
1524 glColor4f(.4,.4,.4,opac*(1-distcheck/mapviewdist));
1526 glTranslatef(objects.position[i].x/terrain.scale/256*-2+1,objects.position[i].z/terrain.scale/256*2-1,0);
1527 glRotatef(objects.rotation[i],0,0,1);
1528 glScalef(.01*objects.scale[i],.01*objects.scale[i],.01*objects.scale[i]);
1531 glVertex3f(-1, -1, 0.0f);
1533 glVertex3f(1, -1, 0.0f);
1535 glVertex3f(1, 1, 0.0f);
1537 glVertex3f(-1, 1, 0.0f);
1544 glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
1545 for(i=0;i<numboundaries;i++){
1546 glColor4f(0,0,0,opac/3);
1548 glTranslatef(boundary[i].x/terrain.scale/256*-2+1,boundary[i].z/terrain.scale/256*2-1,0);
1549 glScalef(.002,.002,.002);
1552 glVertex3f(-1, -1, 0.0f);
1554 glVertex3f(1, -1, 0.0f);
1556 glVertex3f(1, 1, 0.0f);
1558 glVertex3f(-1, 1, 0.0f);
1563 for(i=0;i<numplayers;i++){
1564 distcheck=findDistancefast(&player[0].coords,&player[i].coords);
1565 if(distcheck<mapviewdist){
1567 glBindTexture( GL_TEXTURE_2D, Maparrowtexture);
1568 if(i==0)glColor4f(1,1,1,opac);
1569 else if(player[i].dead==2||player[i].howactive>typesleeping)glColor4f(0,0,0,opac*(1-distcheck/mapviewdist));
1570 else if(player[i].dead)glColor4f(.3,.3,.3,opac*(1-distcheck/mapviewdist));
1571 else if(player[i].aitype==attacktypecutoff)glColor4f(1,0,0,opac*(1-distcheck/mapviewdist));
1572 else if(player[i].aitype==passivetype)glColor4f(0,1,0,opac*(1-distcheck/mapviewdist));
1573 else glColor4f(1,1,0,1);
1574 glTranslatef(player[i].coords.x/terrain.scale/256*-2+1,player[i].coords.z/terrain.scale/256*2-1,0);
1575 glRotatef(player[i].rotation+180,0,0,1);
1576 glScalef(.005,.005,.005);
1579 glVertex3f(-1, -1, 0.0f);
1581 glVertex3f(1, -1, 0.0f);
1583 glVertex3f(1, 1, 0.0f);
1585 glVertex3f(-1, 1, 0.0f);
1591 glDisable(GL_TEXTURE_2D);
1592 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1593 glPopMatrix(); // Restore The Old Projection Matrix
1594 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1595 glPopMatrix(); // Restore The Old Projection Matrix
1596 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1597 glEnable(GL_CULL_FACE);
1598 glDisable(GL_BLEND);
1602 if(loading&&!stealthloading&&(!campaign||player[0].dead)){
1603 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1604 glDisable(GL_CULL_FACE);
1605 glDisable(GL_LIGHTING);
1606 glDisable(GL_TEXTURE_2D);
1608 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1609 glPushMatrix(); // Store The Projection Matrix
1610 glLoadIdentity(); // Reset The Projection Matrix
1611 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1612 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1613 glPushMatrix(); // Store The Modelview Matrix
1614 glLoadIdentity(); // Reset The Modelview Matrix
1615 glScalef(screenwidth,screenheight,1);
1616 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1618 glColor4f(0,0,0,.7);
1620 glVertex3f(0, 0, 0.0f);
1621 glVertex3f(256, 0, 0.0f);
1622 glVertex3f(256, 256, 0.0f);
1623 glVertex3f(0, 256, 0.0f);
1625 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1626 glPopMatrix(); // Restore The Old Projection Matrix
1627 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1628 glPopMatrix(); // Restore The Old Projection Matrix
1629 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1630 glEnable(GL_CULL_FACE);
1631 glDisable(GL_BLEND);
1635 glDisable(GL_DEPTH_TEST);
1636 glColor3f (1.0, 1.0, 1.0); // no coloring
1638 glEnable(GL_TEXTURE_2D);
1643 glEnable(GL_TEXTURE_2D);
1645 sprintf (string, "Loading...");
1646 text.glPrint(1024/2-90,768/2,string,1,2,1024,768);
1649 //if(ismotionblur)drawmode=motionblurmode;
1650 drawmode=normalmode;
1653 if(winfreeze&&!campaign){
1654 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1655 glDisable(GL_CULL_FACE);
1656 glDisable(GL_LIGHTING);
1657 glDisable(GL_TEXTURE_2D);
1659 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1660 glPushMatrix(); // Store The Projection Matrix
1661 glLoadIdentity(); // Reset The Projection Matrix
1662 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1663 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1664 glPushMatrix(); // Store The Modelview Matrix
1665 glLoadIdentity(); // Reset The Modelview Matrix
1666 glScalef(screenwidth,screenheight,1);
1667 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1669 glColor4f(0,0,0,.4);
1671 glVertex3f(0, 0, 0.0f);
1672 glVertex3f(256, 0, 0.0f);
1673 glVertex3f(256, 256, 0.0f);
1674 glVertex3f(0, 256, 0.0f);
1676 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1677 glPopMatrix(); // Restore The Old Projection Matrix
1678 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1679 glPopMatrix(); // Restore The Old Projection Matrix
1680 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1681 glEnable(GL_CULL_FACE);
1682 glDisable(GL_BLEND);
1686 glDisable(GL_DEPTH_TEST);
1687 glColor3f (1.0, 1.0, 1.0); // no coloring
1689 glEnable(GL_TEXTURE_2D);
1691 //Win Screen Won Victory
1693 glEnable(GL_TEXTURE_2D);
1695 sprintf (string, "Level Cleared!");
1696 text.glPrintOutlined(1024/2-strlen(string)*10,768*7/8,string,1,2,1024,768);
1698 sprintf (string, "Score: %d",(int)(bonustotal-startbonustotal));
1699 text.glPrintOutlined(1024/30,768*6/8,string,1,2,1024,768);
1702 sprintf (string, "Press Escape or Space to continue");
1704 sprintf (string, "Press Escape to return to menu or Space to continue");
1705 text.glPrintOutlined(640/2-strlen(string)*5,480*1/16,string,1,1,640,480);
1709 for(i=0;i<255;i++)string[i]='\0';
1710 sprintf (temp, "Time: %d:",(int)(((int)leveltime-(int)(leveltime)%60)/60));
1711 strcat(string,temp);
1712 if((int)(leveltime)%60<10)strcat(string,"0");
1713 sprintf (temp, "%d",(int)(leveltime)%60);
1714 strcat(string,temp);
1715 text.glPrintOutlined(1024/30,768*6/8-40,string,1,2,1024,768);
1718 int awards[award_count];
1719 int numawards = award_awards(awards);
1721 for (i = 0; i < numawards && i < 6; i++)
1722 text.glPrintOutlined(1024/30,768*6/8-90-40*i,award_names[awards[i]],1,2,1024,768);
1725 if(drawmode!=normalmode){
1726 glEnable(GL_TEXTURE_2D);
1728 if(!drawtoggle||drawmode!=realmotionblurmode||(drawtoggle==2||change==1)){
1731 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
1732 GLfloat subtractColor[4] = { 0.5, 0.5, 0.5, 0.0 };
1733 glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, subtractColor);
1734 //glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_SUBTRACT);
1735 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE);
1736 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_CONSTANT_EXT);
1737 glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 2.0f);
1739 glBindTexture( GL_TEXTURE_2D, screentexture);
1740 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1743 if((drawtoggle||change==1)&&drawmode==realmotionblurmode){
1745 glBindTexture( GL_TEXTURE_2D, screentexture2);
1746 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1748 if(!screentexture2){
1749 glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
1751 glGenTextures( 1, &screentexture2 );
1752 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
1754 glEnable(GL_TEXTURE_2D);
1755 glBindTexture( GL_TEXTURE_2D, screentexture2);
1756 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
1757 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
1759 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
1765 glClear(GL_DEPTH_BUFFER_BIT);
1766 ReSizeGLScene(90,.1f);
1767 glViewport(0,0,screenwidth,screenheight);
1769 if(drawmode!=normalmode){
1770 glDisable(GL_DEPTH_TEST);
1771 if(drawmode==motionblurmode){
1772 glDrawBuffer(GL_FRONT);
1773 glReadBuffer(GL_BACK);
1775 glColor3f (1.0, 1.0, 1.0); // no coloring
1777 glEnable(GL_TEXTURE_2D);
1778 glBindTexture( GL_TEXTURE_2D, screentexture);
1779 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1780 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1781 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1782 glDisable(GL_CULL_FACE);
1783 glDisable(GL_LIGHTING);
1785 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1786 glPushMatrix(); // Store The Projection Matrix
1787 glLoadIdentity(); // Reset The Projection Matrix
1788 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1789 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1790 glPushMatrix(); // Store The Modelview Matrix
1791 glLoadIdentity(); // Reset The Modelview Matrix
1792 glScalef((float)screenwidth/2,(float)screenheight/2,1);
1793 glTranslatef(1,1,0);
1794 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1796 if(drawmode==motionblurmode){
1797 if(motionbluramount<.2)motionbluramount=.2;
1798 //glColor4f(1,1,1,fast_sqrt(multiplier)*2.9*motionbluramount);
1799 glColor4f(1,1,1,motionbluramount);
1803 glVertex3f(-1, -1, 0.0f);
1804 glTexCoord2f(texcoordwidth,0);
1805 glVertex3f(1, -1, 0.0f);
1806 glTexCoord2f(texcoordwidth,texcoordheight);
1807 glVertex3f(1, 1, 0.0f);
1808 glTexCoord2f(0,texcoordheight);
1809 glVertex3f(-1, 1, 0.0f);
1813 if(drawmode==realmotionblurmode){
1814 glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
1815 glClear(GL_COLOR_BUFFER_BIT);
1816 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
1817 glBindTexture( GL_TEXTURE_2D, screentexture);
1818 glColor4f(1,1,1,.5);
1822 glVertex3f(-1, -1, 0.0f);
1823 glTexCoord2f(texcoordwidth,0);
1824 glVertex3f(1, -1, 0.0f);
1825 glTexCoord2f(texcoordwidth,texcoordheight);
1826 glVertex3f(1, 1, 0.0f);
1827 glTexCoord2f(0,texcoordheight);
1828 glVertex3f(-1, 1, 0.0f);
1831 glBindTexture( GL_TEXTURE_2D, screentexture2);
1832 glColor4f(1,1,1,.5);
1836 glVertex3f(-1, -1, 0.0f);
1837 glTexCoord2f(texcoordwidth,0);
1838 glVertex3f(1, -1, 0.0f);
1839 glTexCoord2f(texcoordwidth,texcoordheight);
1840 glVertex3f(1, 1, 0.0f);
1841 glTexCoord2f(0,texcoordheight);
1842 glVertex3f(-1, 1, 0.0f);
1845 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1847 if(drawmode==doublevisionmode){
1848 static float crosseyedness;
1849 crosseyedness=abs(player[0].damage-player[0].superpermanentdamage-(player[0].damagetolerance-player[0].superpermanentdamage)*1/2)/30;
1850 if(crosseyedness>1)crosseyedness=1;
1851 if(crosseyedness<0)crosseyedness=0;
1853 glDisable(GL_BLEND);
1858 glVertex3f(-1, -1, 0.0f);
1859 glTexCoord2f(texcoordwidth,0);
1860 glVertex3f(1, -1, 0.0f);
1861 glTexCoord2f(texcoordwidth,texcoordheight);
1862 glVertex3f(1, 1, 0.0f);
1863 glTexCoord2f(0,texcoordheight);
1864 glVertex3f(-1, 1, 0.0f);
1868 glColor4f(1,1,1,.5);
1871 glTranslatef(.015*crosseyedness,0,0);
1875 glVertex3f(-1, -1, 0.0f);
1876 glTexCoord2f(texcoordwidth,0);
1877 glVertex3f(1, -1, 0.0f);
1878 glTexCoord2f(texcoordwidth,texcoordheight);
1879 glVertex3f(1, 1, 0.0f);
1880 glTexCoord2f(0,texcoordheight);
1881 glVertex3f(-1, 1, 0.0f);
1886 if(drawmode==glowmode){
1887 glColor4f(.5,.5,.5,.5);
1889 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
1891 glTranslatef(.01,0,0);
1894 glVertex3f(-1, -1, 0.0f);
1895 glTexCoord2f(texcoordwidth,0);
1896 glVertex3f(1, -1, 0.0f);
1897 glTexCoord2f(texcoordwidth,texcoordheight);
1898 glVertex3f(1, 1, 0.0f);
1899 glTexCoord2f(0,texcoordheight);
1900 glVertex3f(-1, 1, 0.0f);
1904 glTranslatef(-.01,0,0);
1907 glVertex3f(-1, -1, 0.0f);
1908 glTexCoord2f(texcoordwidth,0);
1909 glVertex3f(1, -1, 0.0f);
1910 glTexCoord2f(texcoordwidth,texcoordheight);
1911 glVertex3f(1, 1, 0.0f);
1912 glTexCoord2f(0,texcoordheight);
1913 glVertex3f(-1, 1, 0.0f);
1917 glTranslatef(.0,.01,0);
1920 glVertex3f(-1, -1, 0.0f);
1921 glTexCoord2f(texcoordwidth,0);
1922 glVertex3f(1, -1, 0.0f);
1923 glTexCoord2f(texcoordwidth,texcoordheight);
1924 glVertex3f(1, 1, 0.0f);
1925 glTexCoord2f(0,texcoordheight);
1926 glVertex3f(-1, 1, 0.0f);
1930 glTranslatef(0,-.01,0);
1933 glVertex3f(-1, -1, 0.0f);
1934 glTexCoord2f(texcoordwidth,0);
1935 glVertex3f(1, -1, 0.0f);
1936 glTexCoord2f(texcoordwidth,texcoordheight);
1937 glVertex3f(1, 1, 0.0f);
1938 glTexCoord2f(0,texcoordheight);
1939 glVertex3f(-1, 1, 0.0f);
1943 if(drawmode==radialzoommode){
1945 //glRotatef((float)i*.1,0,0,1);
1946 glColor4f(1,1,1,1/((float)i+1));
1948 glScalef(1+(float)i*.01,1+(float)i*.01,1);
1951 glVertex3f(-1, -1, 0.0f);
1952 glTexCoord2f(texcoordwidth,0);
1953 glVertex3f(1, -1, 0.0f);
1954 glTexCoord2f(texcoordwidth,texcoordheight);
1955 glVertex3f(1, 1, 0.0f);
1956 glTexCoord2f(0,texcoordheight);
1957 glVertex3f(-1, 1, 0.0f);
1962 glDisable(GL_TEXTURE_2D);
1963 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1964 glPopMatrix(); // Restore The Old Projection Matrix
1965 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1966 glPopMatrix(); // Restore The Old Projection Matrix
1967 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1968 glEnable(GL_CULL_FACE);
1969 glDisable(GL_BLEND);
1974 glEnable(GL_TEXTURE_2D);
1977 if(consoleselected>=60)
1978 offset=consoleselected-60;
1979 sprintf (string, " ]");
1980 text.glPrint(10,30,string,0,1,1024,768);
1982 sprintf (string, "_");
1983 text.glPrint(30+(float)(consoleselected)*10-offset*10,30,string,0,1,1024,768);
1986 for(j=0;j<consolechars[i];j++){
1987 glColor4f(1,1,1,1-(float)(i)/16);
1988 if(j<consolechars[i]){
1989 sprintf (string, "%c",consoletext[i][j]);
1990 text.glPrint(30+j*10-offset*10,30+i*20,string,0,1,1024,768);
1996 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)){
1997 multiplier=tempmult;
2004 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)){
2005 tempmult=multiplier;
2010 if ( side == stereoRight || side == stereoCenter ) {
2011 if(drawmode!=motionblurmode||mainmenu){
2016 //myassert(glGetError() == GL_NO_ERROR);
2017 glDrawBuffer(GL_BACK);
2018 glReadBuffer(GL_BACK);
2023 if(drawtoggle==2)drawtoggle=0;
2025 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)){
2026 multiplier=tempmult;
2028 //Jordan fixed your warning!
2032 vector<string> Game::ListCampaigns() {
2033 DIR *campaigns = opendir(ConvertFileName(":Data:Campaigns"));
2034 struct dirent *campaign = NULL;
2036 perror("Problem while loading campaigns");
2037 cerr << "campaign folder was : " << ConvertFileName(":Data:Campaigns") << endl;
2040 vector<string> campaignNames;
2041 while ((campaign = readdir(campaigns)) != NULL) {
2042 string name(campaign->d_name);
2045 if(!name.compare(name.length()-4,4,".txt")) {
2046 campaignNames.push_back(name.substr(0,name.length()-4));
2049 closedir(campaigns);
2050 return campaignNames;
2053 void Game::LoadCampaign() {
2056 ifstream ipstream(ConvertFileName((":Data:Campaigns:"+accountactive->getCurrentCampaign()+".txt").c_str()));
2057 ipstream.ignore(256,':');
2059 ipstream >> numlevels;
2060 campaignlevels.clear();
2061 for(int i=0;i<numlevels;i++) {
2064 campaignlevels.push_back(cl);
2068 ifstream test(ConvertFileName((":Data:Textures:"+accountactive->getCurrentCampaign()+":World.png").c_str()));
2070 LoadTexture((":Data:Textures:"+accountactive->getCurrentCampaign()+":World.png").c_str(),&Mainmenuitems[7],0,0);
2072 LoadTexture(":Data:Textures:World.png",&Mainmenuitems[7],0,0);
2075 if(accountactive->getCampaignChoicesMade()==0) {
2076 accountactive->setCampaignScore(0);
2077 accountactive->resetFasttime();
2079 oldmainmenu=0; //reload menu
2082 void Game::DrawMenu() {
2083 // !!! FIXME: hack: clamp framerate in menu so text input works correctly on fast systems.
2086 glDrawBuffer(GL_BACK);
2087 glReadBuffer(GL_BACK);
2088 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
2089 ReSizeGLScene(90,.1f);
2091 if(oldmainmenu!=mainmenu){
2097 //draw menu background
2098 glClear(GL_DEPTH_BUFFER_BIT);
2099 glEnable(GL_ALPHA_TEST);
2100 glAlphaFunc(GL_GREATER, 0.001f);
2101 glEnable(GL_TEXTURE_2D);
2102 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
2103 glDisable(GL_CULL_FACE);
2104 glDisable(GL_LIGHTING);
2106 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2107 glPushMatrix(); // Store The Projection Matrix
2108 glLoadIdentity(); // Reset The Projection Matrix
2109 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
2110 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2111 glPushMatrix(); // Store The Modelview Matrix
2112 glLoadIdentity(); // Reset The Modelview Matrix
2113 glTranslatef(screenwidth/2,screenheight/2,0);
2115 glScalef((float)screenwidth/2,(float)screenheight/2,1);
2116 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
2117 glDisable(GL_BLEND);
2118 glColor4f(0,0,0,1.0);
2119 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2120 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2121 glDisable(GL_TEXTURE_2D);
2123 glVertex3f(-1,-1,0);
2124 glVertex3f(+1,-1,0);
2125 glVertex3f(+1,+1,0);
2126 glVertex3f(-1,+1,0);
2129 glColor4f(0.4,0.4,0.4,1.0);
2130 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2131 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2132 glEnable(GL_TEXTURE_2D);
2133 glBindTexture( GL_TEXTURE_2D, Mainmenuitems[4]);
2136 glVertex3f(-1,-1,0);
2138 glVertex3f(+1,-1,0);
2140 glVertex3f(+1,+1,0);
2142 glVertex3f(-1,+1,0);
2146 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2148 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2151 Values of mainmenu :
2153 2 Menu pause (resume/end game)
2155 4 Controls configuration menu
2156 5 Main game menu (choose level or challenge)
2157 6 Deleting user menu
2158 7 User managment menu (select/add)
2159 8 Choose difficulty menu
2160 9 Challenge level selection menu
2161 10 End of the campaign congratulation (is that really a menu?)
2162 11 Same that 9 ??? => unused
2163 18 stereo configuration
2166 if(oldmainmenu!=mainmenu)
2172 if(oldmainmenu!=mainmenu){
2173 Menu::addImage(0,Mainmenuitems[0],150,480-128,256,128);
2174 Menu::addImageButton(1,Mainmenuitems[mainmenu==1?1:5],NULL,18,480-152-32,128,32);
2175 Menu::addImageButton(2,Mainmenuitems[2],NULL,18,480-228-32,112,32);
2176 Menu::addImageButton(3,Mainmenuitems[mainmenu==1?3:6],NULL,18,480-306-32,mainmenu==1?68:132,32);
2181 if(oldmainmenu!=mainmenu){
2182 Menu::addButton( 0,"",NULL,10+20,440,-1,-1);
2183 Menu::addButton( 1,"",NULL,10+60,405,-1,-1);
2184 Menu::addButton( 2,"",NULL,10+70,370,-1,-1);
2185 Menu::addButton( 3,"",NULL,10+20-1000,335-1000,-1,-1);
2186 Menu::addButton( 4,"",NULL,10 ,335,-1,-1);
2187 Menu::addButton( 5,"",NULL,10+60,300,-1,-1);
2188 Menu::addButton( 6,"",NULL,10+70,265,-1,-1);
2189 Menu::addButton( 9,"",NULL,10 ,230,-1,-1);
2190 Menu::addButton(10,"",NULL,20 ,195,-1,-1);
2191 Menu::addButton(11,"",NULL,10+60,160,-1,-1);
2192 Menu::addButton(13,"",NULL,30 ,125,-1,-1);
2193 Menu::addButton( 7,"",NULL,10+15, 90,-1,-1);
2194 Menu::addButton(12,"",NULL,10+15, 55,-1,-1);
2195 Menu::addButton(8,"Back",NULL,10,10,-1,-1);
2197 if((float)newscreenwidth>(float)newscreenheight*1.61||(float)newscreenwidth<(float)newscreenheight*1.59)
2198 sprintf (menustring[0], "Resolution: %d*%d",(int)newscreenwidth,(int)newscreenheight);
2200 sprintf (menustring[0], "Resolution: %d*%d (widescreen)",(int)newscreenwidth,(int)newscreenheight);
2202 if(newdetail==2) sprintf (menustring[1], "Detail: High");
2203 else if(newdetail==1) sprintf (menustring[1], "Detail: Medium");
2204 else sprintf (menustring[1], "Detail: Low");
2206 if(bloodtoggle==2) sprintf (menustring[2], "Blood: On, high detail (slower)");
2207 if(bloodtoggle==1) sprintf (menustring[2], "Blood: On, low detail");
2208 if(bloodtoggle==0) sprintf (menustring[2], "Blood: Off");
2210 if(difficulty==2) sprintf (menustring[3], "Difficulty: Insane");
2211 if(difficulty==1) sprintf (menustring[3], "Difficulty: Difficult");
2212 if(difficulty==0) sprintf (menustring[3], "Difficulty: Easier");
2214 if(ismotionblur==1) sprintf (menustring[4], "Blur Effects: Enabled (less compatible)");
2215 if(ismotionblur==0) sprintf (menustring[4], "Blur Effects: Disabled (more compatible)");
2217 if(decals==1) sprintf (menustring[5], "Decals: Enabled (slower)");
2218 if(decals==0) sprintf (menustring[5], "Decals: Disabled");
2220 if(musictoggle==1) sprintf (menustring[6], "Music: Enabled");
2221 if(musictoggle==0) sprintf (menustring[6], "Music: Disabled");
2223 if(invertmouse==1) sprintf (menustring[9], "Invert mouse: Yes");
2224 if(invertmouse==0) sprintf (menustring[9], "Invert mouse: No");
2226 sprintf (menustring[10], "Mouse Speed: %d", (int)(usermousesensitivity*5));
2228 sprintf (menustring[11], "Volume: %d%%", (int)(volume*100));
2230 sprintf (menustring[13], "Damage Bar: %s",(showdamagebar?"on":"off"));
2232 sprintf (menustring[7], "-Configure Controls-");
2234 sprintf (menustring[12], "-Configure Stereo -");
2236 if(newdetail==detail&&newscreenheight==(int)screenheight&&newscreenwidth==(int)screenwidth)sprintf (menustring[8], "Back");
2237 else sprintf (menustring[8], "Back (some changes take effect next time Lugaru is opened)");
2239 for(int i=0;i<=13;i++)
2240 Menu::setButtonText(i,menustring[i]);
2244 if(oldmainmenu!=mainmenu){
2245 Menu::addButton(0,"",NULL,10 ,400,-1,-1);
2246 Menu::addButton(1,"",NULL,10+40,360,-1,-1);
2247 Menu::addButton(2,"",NULL,10+40,320,-1,-1);
2248 Menu::addButton(3,"",NULL,10+30,280,-1,-1);
2249 Menu::addButton(4,"",NULL,10+20,240,-1,-1);
2250 Menu::addButton(5,"",NULL,10+40,200,-1,-1);
2251 Menu::addButton(6,"",NULL,10+40,160,-1,-1);
2252 Menu::addButton(7,"",NULL,10+30,120,-1,-1);
2253 Menu::addButton(8,"",NULL,10+20,80,-1,-1);
2255 Menu::addButton(9,"",NULL,10+10,40,-1,-1);
2256 Menu::addButton(debugmode?10:9,"Back",NULL,10,10,-1,-1);
2258 Menu::setButtonText(0,(string)"Forwards: "+(keyselect==0?"_":Input::keyToChar(forwardkey)));
2259 Menu::setButtonText(1,(string)"Back: " +(keyselect==1?"_":Input::keyToChar(backkey)));
2260 Menu::setButtonText(2,(string)"Left: " +(keyselect==2?"_":Input::keyToChar(leftkey)));
2261 Menu::setButtonText(3,(string)"Right: " +(keyselect==3?"_":Input::keyToChar(rightkey)));
2262 Menu::setButtonText(4,(string)"Crouch: " +(keyselect==4?"_":Input::keyToChar(crouchkey)));
2263 Menu::setButtonText(5,(string)"Jump: " +(keyselect==5?"_":Input::keyToChar(jumpkey)));
2264 Menu::setButtonText(6,(string)"Draw: " +(keyselect==6?"_":Input::keyToChar(drawkey)));
2265 Menu::setButtonText(7,(string)"Throw: " +(keyselect==7?"_":Input::keyToChar(throwkey)));
2266 Menu::setButtonText(8,(string)"Attack: " +(keyselect==8?"_":Input::keyToChar(attackkey)));
2268 Menu::setButtonText(9,(string)"Console: "+(keyselect==9?"_":Input::keyToChar(consolekey)));
2272 if(oldmainmenu!=mainmenu){
2273 Menu::addLabel(-1,accountactive->getName(),5,400);
2274 Menu::addButton(1,"Tutorial",NULL,5,300,-1,-1);
2275 Menu::addButton(2,"Challenge",NULL,5,240,-1,-1);
2276 Menu::addButton(3,"Delete User",NULL,400,10,-1,-1);
2277 Menu::addButton(4,"Main Menu",NULL,5,10,-1,-1);
2278 Menu::addButton(5,"Change User",NULL,5,180,-1,-1);
2279 Menu::addButton(6,"Campaign : "+accountactive->getCurrentCampaign(),NULL,200,420,-1,-1);
2282 //with (2,-5) offset from old code
2283 Menu::addImage(-1,Mainmenuitems[7],150+2,60-5,400,400);
2285 int numlevels = accountactive->getCampaignChoicesMade();
2286 numlevels += numlevels>0 ? campaignlevels[numlevels-1].nextlevel.size() : 1;
2287 for(int i=0;i<numlevels;i++){
2288 XYZ midpoint=campaignlevels[i].getCenter();
2289 float itemsize=campaignlevels[i].getWidth();
2290 const bool active=i>=accountactive->getCampaignChoicesMade();
2295 XYZ start=campaignlevels[i-1].getCenter();
2296 Menu::addMapLine(start.x,start.y,midpoint.x-start.x,midpoint.y-start.y,0.5,active?1:0.5,active?1:0.5,0,0);
2298 Menu::addMapMarker(NB_CAMPAIGN_MENU_ITEM+i, Mapcircletexture, NULL,
2299 midpoint.x-itemsize/2, midpoint.y-itemsize/2, itemsize, itemsize, active?1:0.5, 0, 0);
2302 Menu::addLabel(-2,campaignlevels[i].description,
2303 campaignlevels[i].getStartX()+10,
2304 campaignlevels[i].getStartY()-4);
2305 Menu::setMapItem(-2);
2312 if(oldmainmenu!=mainmenu){
2313 Menu::addLabel(-1,"Are you sure you want to delete this user?",10,400);
2314 Menu::addButton(1,"Yes",NULL,10,360,-1,-1);
2315 Menu::addButton(2,"No",NULL,10,320,-1,-1);
2320 if(oldmainmenu!=mainmenu){
2321 Menu::addButton(0,Account::getNbAccounts()<8?"New User":"No More Users",NULL,10,400,-1,-1);
2322 Menu::addLabel(-2,"",20,400);
2323 Menu::addButton(Account::getNbAccounts()+1,"Back",NULL,10,10,-1,-1);
2324 for(int i=0;i<Account::getNbAccounts();i++)
2325 Menu::addButton(i+1,Account::get(i)->getName(),NULL,10,340-20*(i+1),-1,-1);
2328 Menu::setButtonText(0,displaytext[0],20,400,-1,-1);
2329 Menu::setButtonText(-2,displayblink?"_":"",20+displayselected*10,400,-1,-1);
2334 if(oldmainmenu!=mainmenu){
2335 Menu::addButton(0,"Easier",NULL,10,400,-1,-1);
2336 Menu::addButton(1,"Difficult",NULL,10,360,-1,-1);
2337 Menu::addButton(2,"Insane",NULL,10,320,-1,-1);
2342 if(oldmainmenu!=mainmenu){
2343 for(int i=0;i<numchallengelevels;i++){
2346 sprintf (temp, "Level %d",i+1);
2347 for(int j=strlen(temp);j<17;j++)
2350 sprintf (temp, "%d",(int)accountactive->getHighScore(i));
2351 for(int j=strlen(temp);j<(32-17);j++)
2354 sprintf (temp, "%d:",(int)(((int)accountactive->getFastTime(i)-(int)(accountactive->getFastTime(i))%60)/60));
2355 if((int)(accountactive->getFastTime(i))%60<10)strcat(temp,"0");
2357 sprintf (temp, "%d",(int)(accountactive->getFastTime(i))%60);
2360 Menu::addButton(i,name,NULL,10,400-i*25,-1,-1,i>accountactive->getProgress()?0.5:1,0,0);
2363 Menu::addButton(-1," High Score Best Time",NULL,10,440,-1,-1);
2364 Menu::addButton(numchallengelevels,"Back",NULL,10,10,-1,-1);
2369 if(oldmainmenu!=mainmenu){
2370 Menu::addLabel(0,"Congratulations!",220,330);
2371 Menu::addLabel(1,"You have avenged your family and",140,300);
2372 Menu::addLabel(2,"restored peace to the island of Lugaru.",110,270);
2373 Menu::addButton(3,"Back",NULL,10,10,-1,-1);
2374 sprintf(menustring[4],"Your score: %d",(int)accountactive->getCampaignScore());
2375 sprintf(menustring[5],"Highest score: %d",(int)accountactive->getCampaignHighScore());
2376 Menu::addLabel(4,menustring[4],190,200);
2377 Menu::addLabel(5,menustring[5],190,180);
2382 if(oldmainmenu!=mainmenu){
2383 Menu::addButton(0,"",NULL,70,400,-1,-1);
2384 Menu::addButton(1,"",NULL,10,360,-1,-1);
2385 Menu::addButton(2,"",NULL,40,320,-1,-1);
2386 Menu::addButton(3,"Back",NULL,10,10,-1,-1);
2388 sprintf(menustring[0], "Stereo mode: %s", StereoModeName(newstereomode));
2389 sprintf(menustring[1], "Stereo separation: %.3f", stereoseparation);
2390 sprintf(menustring[2], "Reverse stereo: %s", stereoreverse ? "Yes" : "No");
2391 Menu::setButtonText(0,menustring[0]);
2392 Menu::setButtonText(1,menustring[1]);
2393 Menu::setButtonText(2,menustring[2]);
2397 oldmainmenu=mainmenu;
2399 selected=Menu::getSelected(mousecoordh*640/screenwidth,480-mousecoordv*480/screenheight);
2400 Menu::GUITick(this);
2402 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2403 glPushMatrix(); // Store The Projection Matrix
2404 glLoadIdentity(); // Reset The Projection Matrix
2405 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
2406 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2407 glPushMatrix(); // Store The Modelview Matrix
2408 glLoadIdentity(); // Reset The Modelview Matrix
2409 glEnable(GL_TEXTURE_2D);
2411 Menu::drawItems(this);
2414 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2416 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2419 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2420 glPushMatrix(); // Store The Projection Matrix
2421 glLoadIdentity(); // Reset The Projection Matrix
2422 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
2423 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2424 glPushMatrix(); // Store The Modelview Matrix
2425 glLoadIdentity(); // Reset The Modelview Matrix
2426 glTranslatef(screenwidth/2,screenheight/2,0);
2428 glScalef((float)screenwidth/2,(float)screenheight/2,1);
2429 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
2431 glEnable(GL_TEXTURE_2D);
2433 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2434 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2436 if(!waiting) { // hide the cursor while waiting for a key
2438 glTranslatef(mousecoordh-screenwidth/2,mousecoordv*-1+screenheight/2,0);
2439 glScalef((float)screenwidth/64,(float)screenwidth/64,1);
2440 glTranslatef(1,-1,0);
2441 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
2443 glBindTexture( GL_TEXTURE_2D, cursortexture);
2445 //glScalef(.25,.25,.25);
2448 glVertex3f(-1, -1, 0.0f);
2450 glVertex3f(1, -1, 0.0f);
2452 glVertex3f(1, 1, 0.0f);
2454 glVertex3f(-1, 1, 0.0f);
2460 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2467 if(flashamount>1)flashamount=1;
2468 if(flashdelay<=0)flashamount-=multiplier;
2470 if(flashamount<0)flashamount=0;
2471 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
2472 glDisable(GL_CULL_FACE);
2473 glDisable(GL_LIGHTING);
2474 glDisable(GL_TEXTURE_2D);
2476 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2477 glPushMatrix(); // Store The Projection Matrix
2478 glLoadIdentity(); // Reset The Projection Matrix
2479 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
2480 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2481 glPushMatrix(); // Store The Modelview Matrix
2482 glLoadIdentity(); // Reset The Modelview Matrix
2483 glScalef(screenwidth,screenheight,1);
2484 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
2486 glColor4f(flashr,flashg,flashb,flashamount);
2488 glVertex3f(0, 0, 0.0f);
2489 glVertex3f(256, 0, 0.0f);
2490 glVertex3f(256, 256, 0.0f);
2491 glVertex3f(0, 256, 0.0f);
2493 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2494 glPopMatrix(); // Restore The Old Projection Matrix
2495 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2496 glPopMatrix(); // Restore The Old Projection Matrix
2497 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
2498 glEnable(GL_CULL_FACE);
2499 glDisable(GL_BLEND);