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"
32 extern int environment;
33 extern float texscale;
35 extern Terrain terrain;
36 //extern Sprites sprites;
37 extern float multiplier;
39 extern float viewdistance;
40 extern float fadestart;
41 extern float screenwidth,screenheight;
42 extern int kTextureSize;
43 extern FRUSTUM frustum;
45 extern Objects objects;
47 extern float usermousesensitivity;
49 extern float camerashake;
51 extern float slomodelay;
52 extern bool ismotionblur;
54 extern float blackout;
55 extern bool damageeffects;
57 extern bool texttoggle;
58 extern float blurness;
59 extern float targetblurness;
60 extern float playerdist;
61 extern bool cellophane;
63 extern float flashamount,flashr,flashg,flashb;
64 extern int flashdelay;
66 extern float motionbluramount;
68 extern bool alwaysblur;
70 extern bool tilt2weird;
71 extern bool tiltweird;
73 extern bool proportionweird;
74 extern bool vertexweird[6];
75 extern bool velocityblur;
76 extern bool debugmode;
78 extern int oldmainmenu;
79 extern int bloodtoggle;
80 extern int difficulty;
83 //extern int texdetail;
84 extern float texdetail;
85 extern bool musictoggle;
86 extern int tutoriallevel;
87 extern float smoketex;
88 extern float tutorialstagetime;
89 extern float tutorialmaxtime;
90 extern int tutorialstage;
91 extern bool againbonus;
92 extern float damagedealt;
93 extern bool invertmouse;
95 extern int numhotspots;
96 extern int killhotspot;
97 extern XYZ hotspot[40];
98 extern int hotspottype[40];
99 extern float hotspotsize[40];
100 extern char hotspottext[40][256];
101 extern int currenthotspot;;
103 extern bool campaign;
104 extern bool winfreeze;
106 extern float menupulse;
108 extern bool gamestart;
110 extern bool gamestarted;
112 extern bool showdamagebar;
115 normalmode, motionblurmode, radialzoommode,
116 realmotionblurmode, doublevisionmode, glowmode,
119 void Game::flash() { // shouldn't be that way, these should be attributes and Person class should not change rendering.
126 /*********************> DrawGLScene() <*****/
127 int Game::DrawGLScene(StereoSide side)
129 static float texcoordwidth,texcoordheight;
130 static float texviewwidth, texviewheight;
132 static GLubyte color;
133 static XYZ checkpoint;
134 static float tempmult;
136 static char string[256]="";
137 static char string2[256]="";
138 static char string3[256]="";
140 if ( stereomode == stereoAnaglyph ) {
142 case stereoLeft: glColorMask( 0.0, 1.0, 1.0, 1.0 ); break;
143 case stereoRight: glColorMask( 1.0, 0.0, 0.0, 1.0 ); break;
146 glColorMask( 1.0, 1.0, 1.0, 1.0 );
148 if ( stereomode == stereoHorizontalInterlaced || stereomode == stereoVerticalInterlaced ) {
149 glStencilFunc(side == stereoLeft ? GL_NOTEQUAL : GL_EQUAL, 0x01, 0x01);
153 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)){
160 numboundaries=mapradius*2;
161 if(numboundaries>360)numboundaries=360;
162 for(i=0;i<numboundaries;i++){
165 boundary[i]=mapcenter+DoRotation(boundary[i]*mapradius,0,i*(360/((float)(numboundaries))),0);
174 olddrawmode=drawmode;
175 if(ismotionblur&&!loading){
176 if((findLengthfast(&player[0].velocity)>200)&&velocityblur&&!cameramode){
177 drawmode=motionblurmode;
178 motionbluramount=200/(findLengthfast(&player[0].velocity));
181 if(player[0].damage-player[0].superpermanentdamage>(player[0].damagetolerance-player[0].superpermanentdamage)*1/2&&damageeffects&&!cameramode){
182 drawmode=doublevisionmode;
189 drawmode=motionblurmode;
191 slomodelay-=multiplier;
192 if(slomodelay<0)slomo=0;
196 if((!changed&&!slomo)||loading){
198 if(ismotionblur&&(/*fps>100||*/alwaysblur)){
199 if(olddrawmode!=realmotionblurmode)change=1;
201 drawmode=realmotionblurmode;
203 else if(olddrawmode==realmotionblurmode)change=2;
207 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted))drawmode=normalmode;
208 if((freeze||winfreeze)&&ismotionblur&&!mainmenu)drawmode=radialzoommode;
210 if(winfreeze||mainmenu)drawmode=normalmode;
213 if(drawmode==glowmode){
218 DSpContext_FadeGamma(NULL,200,&color2);
222 if(drawtoggle!=2)drawtoggle=1-drawtoggle;
226 texviewwidth=kTextureSize;
227 if(texviewwidth>screenwidth)texviewwidth=screenwidth;
228 texviewheight=kTextureSize;
229 if(texviewheight>screenheight)texviewheight=screenheight;
231 texcoordwidth=screenwidth/kTextureSize;
232 texcoordheight=screenheight/kTextureSize;
233 if(texcoordwidth>1)texcoordwidth=1;
234 if(texcoordheight>1)texcoordheight=1;
237 glDrawBuffer(GL_BACK);
238 glReadBuffer(GL_BACK);
240 if(abs(blurness-targetblurness)<multiplier*10||abs(blurness-targetblurness)>2){
241 blurness=targetblurness;
242 targetblurness=(float)(abs(Random()%100))/40;
244 if(blurness<targetblurness)
245 blurness+=multiplier*5;
247 blurness-=multiplier*5;
250 static XYZ terrainlight;
251 static float distance;
252 if(drawmode==normalmode)ReSizeGLScene(90,.1f);
253 if(drawmode!=normalmode)glViewport(0,0,texviewwidth,texviewheight);
254 glDepthFunc(GL_LEQUAL);
256 glAlphaFunc(GL_GREATER, 0.0001f);
257 glEnable(GL_ALPHA_TEST);
258 glClearColor(0.25f, 0.25f, 0.25f, 1.0f);
259 glClear(GL_DEPTH_BUFFER_BIT);
261 glMatrixMode (GL_MODELVIEW);
262 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
265 // Move the camera for the current eye's point of view.
266 // Reverse the movement if we're reversing stereo
267 glTranslatef((stereoseparation/2) * side * (stereoreverse ? -1 : 1), 0, 0);
269 if(!cameramode&&!freeze&&!winfreeze){
270 glRotatef(float(Random()%100)/10*camerashake/*+(woozy*woozy)/10*/,0,0,1);
271 glRotatef(rotation2+sin(woozy/2)*(player[0].damage/player[0].damagetolerance)*5,1,0,0);
272 glRotatef(rotation+sin(woozy)*(player[0].damage/player[0].damagetolerance)*5,0,1,0);
274 if(cameramode||freeze||winfreeze){
275 glRotatef(rotation2,1,0,0);
276 glRotatef(rotation,0,1,0);
279 if(environment==desertenvironment){
280 glRotatef((float)(abs(Random()%100))/3000-1,1,0,0);
281 glRotatef((float)(abs(Random()%100))/3000-1,0,1,0);
283 SetUpLight(&light,0);
285 if(environment==desertenvironment&&detail==2)glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, blurness+.4 );
286 if(environment==desertenvironment){
287 glRotatef((float)(abs(Random()%100))/1000,1,0,0);
288 glRotatef((float)(abs(Random()%100))/1000,0,1,0);
291 glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0);
293 glTranslatef(-viewer.x,-viewer.y,-viewer.z);
294 frustum.GetFrustum();
298 static float size,opacity,rotation;
300 for(k=0;k<numplayers;k++){
301 if(!player[k].skeleton.free&&player[k].playerdetail&&player[k].howactive<typesleeping)
302 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)
303 for(i=0;i<player[k].skeleton.num_joints;i++){
304 if(player[k].skeleton.joints[i].label==leftknee||player[k].skeleton.joints[i].label==rightknee||player[k].skeleton.joints[i].label==groin){
305 point=DoRotation(player[k].skeleton.joints[i].position,0,player[k].rotation,0)*player[k].scale+player[k].coords;
307 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;
308 if(k!=0&&tutoriallevel==1){
309 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;
311 terrain.MakeDecal(shadowdecal,point,size,opacity,rotation);
312 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
313 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
314 if(objects.position[j].y<player[k].coords.y||objects.type[j]==tunneltype||objects.type[j]==weirdtype){
315 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);
318 if(k!=0&&tutoriallevel==1){
319 opacity=.2+.2*sin(smoketex*6+i);
321 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
326 if((player[k].skeleton.free||player[k].howactive>=typesleeping)&&player[k].playerdetail)
327 if(frustum.SphereInFrustum(player[k].coords.x,player[k].coords.y,player[k].coords.z,player[k].scale*5)&&player[k].occluded<25)
328 for(i=0;i<player[k].skeleton.num_joints;i++){
329 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){
330 if(player[k].skeleton.free)point=player[k].skeleton.joints[i].position*player[k].scale+player[k].coords;
331 else point=DoRotation(player[k].skeleton.joints[i].position,0,player[k].rotation,0)*player[k].scale+player[k].coords;
333 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;
334 if(k!=0&&tutoriallevel==1){
335 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;
337 terrain.MakeDecal(shadowdecal,point,size,opacity*.7,rotation);
338 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
339 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
340 if(objects.position[j].y<player[k].coords.y||objects.type[j]==tunneltype||objects.type[j]==weirdtype){
341 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);
342 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);
345 if(k!=0&&tutoriallevel==1){
346 opacity=.2+.2*sin(smoketex*6+i);
348 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
354 if(!player[k].playerdetail)
355 if(frustum.SphereInFrustum(player[k].coords.x,player[k].coords.y,player[k].coords.z,player[k].scale*5))
357 point=player[k].coords;
359 opacity=.4-(player[k].coords.y-terrain.getHeight(player[k].coords.x,player[k].coords.z))/5;
360 terrain.MakeDecal(shadowdecal,point,size,opacity*.7,rotation);
361 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
362 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
363 point=DoRotation(player[k].coords-objects.position[j],0,-objects.rotation[j],0);
366 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
372 glEnable(GL_TEXTURE_2D);
374 glEnable(GL_DEPTH_TEST);
375 glEnable(GL_CULL_FACE);
377 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
378 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
379 glBindTexture( GL_TEXTURE_2D, terraintexture);
381 glBindTexture( GL_TEXTURE_2D, terraintexture2);
383 //glBindTexture( GL_TEXTURE_2D, terraintexture3);
384 //glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
387 terrain.drawdecals();
390 glEnable(GL_CULL_FACE);
391 glEnable(GL_LIGHTING);
393 glEnable(GL_TEXTURE_2D);
396 glEnable(GL_COLOR_MATERIAL);
411 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
412 glEnable(GL_CULL_FACE);
413 glCullFace(GL_FRONT);
415 for(k=0;k<numplayers;k++){
416 if(k==0||tutoriallevel!=1){
418 glEnable(GL_LIGHTING);
419 terrainlight=terrain.getLighting(player[k].coords.x,player[k].coords.z);
420 distance=findDistancefast(&viewer,&player[k].coords);
421 distance=(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance;
422 glColor4f(terrainlight.x,terrainlight.y,terrainlight.z,distance);
423 if(distance>=1)glDisable(GL_BLEND);
425 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;
427 if(!player[k].occluded==0)i=checkcollide(viewer,checkpoint,player[k].lastoccluded);
428 if(i==-1||player[k].occluded==0)i=checkcollide(viewer,checkpoint);
430 player[k].occluded+=1;
431 player[k].lastoccluded=i;
433 else player[k].occluded=0;
434 if(player[k].occluded<25)player[k].DrawSkeleton();
440 if(!cameramode&&musictype==stream_fighttheme)playerdist=findDistancefastflat(&player[0].coords,&viewer);
441 else playerdist=-100;
444 glEnable(GL_TEXTURE_2D);
449 if(frustum.SphereInFrustum(realhawkcoords.x+hawk.boundingspherecenter.x,realhawkcoords.y+hawk.boundingspherecenter.y,realhawkcoords.z+hawk.boundingspherecenter.z,2)){
450 glAlphaFunc(GL_GREATER, 0.0001f);
452 glDisable(GL_CULL_FACE);
453 glDisable(GL_LIGHTING);
455 glTranslatef(hawkcoords.x,hawkcoords.y,hawkcoords.z);
456 glRotatef(hawkrotation,0,1,0);
457 glTranslatef(25,0,0);
458 distance=findDistancefast(&viewer,&realhawkcoords)*1.2;
459 glColor4f(light.color[0],light.color[1],light.color[2],(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance);
460 if((viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance>1)glColor4f(light.color[0],light.color[1],light.color[2],1);
461 if((viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance>0)
462 hawk.drawdifftex(hawktexture);
466 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
467 glEnable(GL_CULL_FACE);
468 glCullFace(GL_FRONT);
470 for(k=0;k<numplayers;k++){
471 if(!(k==0||tutoriallevel!=1)){
473 glEnable(GL_LIGHTING);
474 terrainlight=terrain.getLighting(player[k].coords.x,player[k].coords.z);
475 distance=findDistancefast(&viewer,&player[k].coords);
476 distance=(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance;
477 glColor4f(terrainlight.x,terrainlight.y,terrainlight.z,distance);
478 if(distance>=1)glDisable(GL_BLEND);
480 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;
482 if(!player[k].occluded==0)i=checkcollide(viewer,checkpoint,player[k].lastoccluded);
483 if(i==-1||player[k].occluded==0)i=checkcollide(viewer,checkpoint);
485 player[k].occluded+=1;
486 player[k].lastoccluded=i;
488 else player[k].occluded=0;
489 if(player[k].occluded<25)player[k].DrawSkeleton();
495 glEnable(GL_TEXTURE_2D);
500 glDisable(GL_COLOR_MATERIAL);
502 glDisable(GL_LIGHTING);
503 glDisable(GL_TEXTURE_2D);
511 glDisable(GL_LIGHTING);
512 glDisable(GL_TEXTURE_2D);
513 glDisable(GL_COLOR_MATERIAL);
516 for(k=0;k<numplayers;k++){
517 if(player[k].numwaypoints>1){
518 glBegin(GL_LINE_LOOP);
519 for(i=0;i<player[k].numwaypoints;i++){
520 glVertex3f(player[k].waypoints[i].x,player[k].waypoints[i].y+.5,player[k].waypoints[i].z);
529 for(k=0;k<numpathpoints;k++){
530 if(numpathpointconnect[k]){
531 for(i=0;i<numpathpointconnect[k];i++){
532 glBegin(GL_LINE_LOOP);
533 glVertex3f(pathpoint[k].x,pathpoint[k].y+.5,pathpoint[k].z);
534 glVertex3f(pathpoint[pathpointconnect[k][i]].x,pathpoint[pathpointconnect[k][i]].y+.5,pathpoint[pathpointconnect[k][i]].z);
542 glVertex3f(pathpoint[pathpointselected].x,pathpoint[pathpointselected].y+.5,pathpoint[pathpointselected].z);
549 glEnable(GL_TEXTURE_2D);
550 glColor4f(.5,.5,.5,1);
552 sprintf (string, " ",(int)(fps));
553 text.glPrint(10,30,string,0,.8,screenwidth,screenheight);
556 if(bonus>0&&bonustime<1&&!winfreeze&&indialogue==-1/*bonustime<4*/){
557 const char *bonus_name;
558 if (bonus < bonus_count)
559 bonus_name = bonus_names[bonus];
561 bonus_name = "Excellent!"; // When does this happen?
563 glColor4f(0,0,0,1-bonustime);
564 text.glPrintOutline(1024/2-10*strlen(bonus_name)-4,768/16-4+768*4/5,bonus_name,1,2.5,1024,768);
565 glColor4f(1,0,0,1-bonustime);
566 text.glPrint(1024/2-10*strlen(bonus_name),768/16+768*4/5,bonus_name,1,2,1024,768);
568 sprintf (string, "%d",(int)bonusvalue);
569 glColor4f(0,0,0,1-bonustime);
570 text.glPrintOutline(1024/2-10*strlen(string)-4,768/16-4-20+768*4/5,string,1,2.5*.8,1024,768);
571 glColor4f(1,0,0,1-bonustime);
572 text.glPrint(1024/2-10*strlen(string),768/16-20+768*4/5,string,1,2*.8,1024,768);
573 glColor4f(.5,.5,.5,1);
576 if(tutoriallevel==1){
577 tutorialopac=tutorialmaxtime-tutorialstagetime;
578 if(tutorialopac>1)tutorialopac=1;
579 if(tutorialopac<0)tutorialopac=0;
581 sprintf (string, " ");
582 sprintf (string2, " ");
583 sprintf (string3, " ");
584 if(tutorialstage==0){
585 sprintf (string, " ");
586 sprintf (string2, " ");
587 sprintf (string3, " ");
589 if(tutorialstage==1){
590 sprintf (string, "Welcome to the Lugaru training level!");
591 sprintf (string2, " ");
592 sprintf (string3, " ");
594 if(tutorialstage==2){
595 sprintf (string, "BASIC MOVEMENT:");
596 sprintf (string2, " ");
597 sprintf (string3, " ");
599 if(tutorialstage==3){
600 sprintf (string, "You can move the mouse to rotate the camera.");
601 sprintf (string2, " ");
602 sprintf (string3, " ");
604 if(tutorialstage==4){
605 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));
606 sprintf (string2, "All movement is relative to the camera.");
607 sprintf (string3, " ");
609 if(tutorialstage==5){
610 sprintf (string, "Please press %s to jump.",Input::keyToChar(jumpkey));
611 sprintf (string2, "You can hold it longer to jump higher.");
612 sprintf (string3, " ");
614 if(tutorialstage==6){
615 sprintf (string, "You can press %s to crouch.",Input::keyToChar(crouchkey));
616 sprintf (string2, "You can jump higher from a crouching position.");
617 sprintf (string3, " ");
619 if(tutorialstage==7){
620 sprintf (string, "While running, you can press %s to roll.",Input::keyToChar(crouchkey));
621 sprintf (string2, " ");
622 sprintf (string3, " ");
624 if(tutorialstage==8){
625 sprintf (string, "While crouching, you can sneak around silently");
626 sprintf (string2, "using the movement keys.");
627 sprintf (string3, " ");
629 if(tutorialstage==9){
630 sprintf (string, "Release the crouch key while sneaking and hold the movement keys");
631 sprintf (string2, "to run animal-style.");
632 sprintf (string3, " ");
634 if(tutorialstage==10){
635 sprintf (string, "ADVANCED MOVEMENT:");
636 sprintf (string2, " ");
637 sprintf (string3, " ");
639 if(tutorialstage==11){
640 sprintf (string, "When you jump at a wall, you can hold %s again",Input::keyToChar(jumpkey));
641 sprintf (string2, "during impact to perform a walljump.");
642 sprintf (string3, "Be sure to use the movement keys to press against the wall");
644 if(tutorialstage==12){
645 sprintf (string, "While in the air, you can press crouch to flip.",Input::keyToChar(jumpkey));
646 sprintf (string2, "Walljumps and flips confuse enemies and give you more control.");
647 sprintf (string3, " ");
649 if(tutorialstage==13){
650 sprintf (string, "BASIC COMBAT:");
651 sprintf (string2, " ");
652 sprintf (string3, " ");
654 if(tutorialstage==14){
655 sprintf (string, "There is now an imaginary enemy");
656 sprintf (string2, "in the middle of the training area.");
657 sprintf (string3, " ");
659 if(tutorialstage==15){
660 if(attackkey==MOUSEBUTTON1)sprintf (string, "Click to attack when you are near an enemy.");
661 else sprintf (string, "Press %s to attack when you are near an enemy.",Input::keyToChar(attackkey));
662 sprintf (string2, "You can punch by standing still near an enemy and attacking.");
663 sprintf (string3, " ");
665 if(tutorialstage==16){
666 sprintf (string, "If you are close, you will perform a weak punch.");
667 sprintf (string2, "The weak punch is excellent for starting attack combinations.");
668 sprintf (string3, " ");
670 if(tutorialstage==17){
671 sprintf (string, "Attacking while running results in a spin kick.");
672 sprintf (string2, "This is one of your most powerful ground attacks.");
673 sprintf (string3, " ");
675 if(tutorialstage==18){
676 sprintf (string, "Sweep the enemy's legs out by attacking while crouched.");
677 sprintf (string2, "This is a very fast attack, and easy to follow up.");
678 sprintf (string3, " ");
680 if(tutorialstage==19){
681 sprintf (string, "When an enemy is on the ground, you can deal some extra");
682 sprintf (string2, "damage by running up and drop-kicking him.");
683 sprintf (string3, "(Try knocking them down with a sweep first)");
685 if(tutorialstage==20){
686 sprintf (string, "Your most powerful individual attack is the rabbit kick.");
687 if(attackkey==MOUSEBUTTON1)sprintf (string2, "Run at the enemy while holding the mouse button, and press");
688 else sprintf (string2, "Run at the enemy while holding %s, and press", Input::keyToChar(attackkey));
689 sprintf (string3, "the jump key (%s) to attack.",Input::keyToChar(jumpkey));
691 if(tutorialstage==21){
692 sprintf (string, "This attack is devastating if timed correctly.");
693 sprintf (string2, "Even if timed incorrectly, it will knock the enemy over.");
694 if(againbonus)sprintf (string3, "Try rabbit-kicking the imaginary enemy again.");
695 else sprintf (string3, "Try rabbit-kicking the imaginary enemy.");
697 if(tutorialstage==22){
698 sprintf (string, "If you sneak behind an enemy unnoticed, you can kill");
699 sprintf (string2, "him instantly. Move close behind this enemy");
700 sprintf (string3, "and attack.");
702 if(tutorialstage==23){
703 sprintf (string, "Another important attack is the wall kick. When an enemy");
704 sprintf (string2, "is near a wall, perform a walljump nearby and hold");
705 sprintf (string3, "the attack key during impact with the wall.");
707 if(tutorialstage==24){
708 sprintf (string, "You can tackle enemies by running at them animal-style");
709 if(attackkey==MOUSEBUTTON1)sprintf (string2, "and pressing jump (%s) or attack(mouse button).",Input::keyToChar(jumpkey));
710 else sprintf (string2, "and pressing jump (%s) or attack(%s).",Input::keyToChar(jumpkey),Input::keyToChar(attackkey));
711 sprintf (string3, "This is especially useful when they are running away.");
713 if(tutorialstage==25){
714 sprintf (string, "Dodge by pressing back and attack. Dodging is essential");
715 sprintf (string2, "against enemies with swords or other long weapons.");
716 sprintf (string3, " ");
718 if(tutorialstage==26){
719 sprintf (string, "REVERSALS AND COUNTER-REVERSALS");
720 sprintf (string2, " ");
721 sprintf (string3, " ");
723 if(tutorialstage==27){
724 sprintf (string, "The enemy can now reverse your attacks.");
725 sprintf (string2, " ");
726 sprintf (string3, " ");
728 if(tutorialstage==28){
729 sprintf (string, "If you attack, you will notice that the enemy now sometimes");
730 sprintf (string2, "catches your attack and uses it against you. Hold");
731 sprintf (string3, "crouch (%s) after attacking to escape from reversals.",Input::keyToChar(crouchkey));
733 if(tutorialstage==29){
734 sprintf (string, "Try escaping from two more reversals in a row.");
735 sprintf (string2, " ");
736 sprintf (string3, " ");
738 if(tutorialstage==30){
739 sprintf (string, "Good!");
740 sprintf (string2, " ");
741 sprintf (string3, " ");
743 if(tutorialstage==31){
744 sprintf (string, "To reverse an attack, you must tap crouch (%s) during the",Input::keyToChar(crouchkey));
745 sprintf (string2, "enemy's attack. You must also be close to the enemy;");
746 sprintf (string3, "this is especially important against armed opponents.");
748 if(tutorialstage==32){
749 sprintf (string, "The enemy can attack in %d seconds.", (int)(tutorialmaxtime-tutorialstagetime));
750 sprintf (string2, "This imaginary opponents attacks will be highlighted");
751 sprintf (string3, "to make this easier.");
753 if(tutorialstage==33){
754 sprintf (string, "Reverse three enemy attacks!");
755 sprintf (string2, " ");
756 sprintf (string3, " ");
758 if(tutorialstage==34){
759 sprintf (string, "Reverse two more enemy attacks!");
760 sprintf (string2, " ");
761 sprintf (string3, " ");
763 if(tutorialstage==35){
764 sprintf (string, "Reverse one more enemy attack!");
765 sprintf (string2, " ");
766 sprintf (string3, " ");
768 if(tutorialstage==36){
769 sprintf (string, "Excellent!");
770 sprintf (string2, " ");
771 sprintf (string3, " ");
773 if(tutorialstage==37){
774 sprintf (string, "Now spar with the enemy for %d more seconds.", (int)(tutorialmaxtime-tutorialstagetime));
775 sprintf (string2, "Damage dealt: %d",(int)damagedealt);
776 sprintf (string3, "Damage taken: %d.",(int)damagetaken);
778 if(tutorialstage==38){
779 sprintf (string, "WEAPONS:");
780 sprintf (string2, " ");
781 sprintf (string3, " ");
783 if(tutorialstage==39){
784 sprintf (string, "There is now an imaginary knife");
785 sprintf (string2, "in the center of the training area.");
786 sprintf (string3, " ");
788 if(tutorialstage==40){
789 sprintf (string, "Stand, roll or handspring over the knife");
790 sprintf (string2, "while pressing %s to pick it up.",Input::keyToChar(throwkey));
791 sprintf (string3, "You can crouch and press the same key to drop it again.");
793 if(tutorialstage==41){
794 sprintf (string, "You can equip and unequip weapons using the %s key.",Input::keyToChar(drawkey));
795 sprintf (string2, "Sometimes it is best to keep them unequipped to");
796 sprintf (string3, "prevent enemies from taking them. ");
798 if(tutorialstage==42){
799 sprintf (string, "The knife is the smallest weapon and the least encumbering.");
800 sprintf (string2, "You can equip or unequip it while standing, crouching,");
801 sprintf (string3, "running or flipping.");
803 if(tutorialstage==43){
804 sprintf (string, "You perform weapon attacks the same way as unarmed attacks,");
805 sprintf (string2, "but sharp weapons cause permanent damage, instead of the");
806 sprintf (string3, "temporary trauma from blunt weapons, fists and feet.");
808 if(tutorialstage==44){
809 sprintf (string, "The enemy now has your knife!");
810 sprintf (string2, "Please reverse two of his knife attacks.");
811 sprintf (string3, " ");
813 if(tutorialstage==45){
814 sprintf (string, "Please reverse one more of his knife attacks.");
815 sprintf (string2, " ");
816 sprintf (string3, " ");
818 if(tutorialstage==46){
819 sprintf (string, "Now he has a sword!");
820 sprintf (string2, "The sword has longer reach than your arms, so you");
821 sprintf (string3, "must move close to reverse the sword slash.");
823 if(tutorialstage==47){
824 sprintf (string, "Long weapons like the sword and staff are also useful for defense;");
825 sprintf (string2, "you can parry enemy weapon attacks by pressing the attack key");
826 sprintf (string3, "at the right time. Please try parrying the enemy's attacks!");
828 if(tutorialstage==48){
829 sprintf (string, "The staff is like the sword, but has two main attacks.");
830 sprintf (string2, "The standing smash is fast and effective, and the running");
831 sprintf (string3, "spin smash is slower and more powerful.");
833 if(tutorialstage==49){
834 sprintf (string, "When facing an enemy, you can throw the knife with %s.",Input::keyToChar(throwkey));
835 sprintf (string2, "It is possible to throw the knife while flipping,");
836 sprintf (string3, "but it is very inaccurate.");
838 if(tutorialstage==50){
839 sprintf (string, "You now know everything you can learn from training.");
840 sprintf (string2, "Everything else you must learn from experience!");
841 sprintf (string3, " ");
843 if(tutorialstage==51){
844 sprintf (string, "Walk out of the training area to return to the main menu.");
845 sprintf (string2, " ");
846 sprintf (string3, " ");
849 glColor4f(0,0,0,tutorialopac);
850 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);
851 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);
852 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);
853 glColor4f(1,1,1,tutorialopac);
854 text.glPrint(screenwidth/2-7.6*strlen(string)*screenwidth/1024,screenheight/16+screenheight*4/5,string,1,1.5*screenwidth/1024,screenwidth,screenheight);
855 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);
856 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);
858 sprintf (string, "Press 'tab' to skip to the next item.",Input::keyToChar(jumpkey));
859 sprintf (string2, "Press escape at any time to");
860 sprintf (string3, "pause or exit the tutorial.");
863 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);
864 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);
865 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);
866 glColor4f(0.5,0.5,0.5,1);
867 text.glPrint(screenwidth/2-7.6*strlen(string)*screenwidth/1024*.8,0+screenheight*1/10,string,1,1.5*screenwidth/1024*.8,screenwidth,screenheight);
868 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);
869 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);
873 if(numhotspots&&(bonustime>=1||bonus<=0||bonustime<0)&&!tutoriallevel){
875 float closestdist=-1;
877 closest=currenthotspot;
878 for(i=0;i<numhotspots;i++){
879 distance=findDistancefast(&player[0].coords,&hotspot[i]);
880 if(closestdist==-1||distance<closestdist){
881 if(findDistancefast(&player[0].coords,&hotspot[i])<hotspotsize[i]&&((hotspottype[i]<=10&&hotspottype[i]>=0)||(hotspottype[i]<=40&&hotspottype[i]>=20))){
882 closestdist=distance;
888 currenthotspot=closest;
889 if(currenthotspot!=-1){
890 if(hotspottype[closest]<=10){
891 if(findDistancefast(&player[0].coords,&hotspot[closest])<hotspotsize[closest])
894 tutorialopac=tutorialmaxtime-tutorialstagetime;
895 if(tutorialopac>1)tutorialopac=1;
896 if(tutorialopac<0)tutorialopac=0;
898 sprintf (string, "%s", hotspottext[closest]);
905 if(string[i]=='\n'||string[i]>'z'||string[i]<' '||string[i]=='\0'){
906 glColor4f(0,0,0,tutorialopac);
907 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);
908 glColor4f(1,1,1,tutorialopac);
909 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);
912 if(string[i]=='\0')done=1;
918 else if (hotspottype[closest]>=20&&dialoguegonethrough[hotspottype[closest]-20]==0){
919 whichdialogue=hotspottype[closest]-20;
920 for(j=0;j<numdialogueboxes[whichdialogue];j++){
921 player[participantfocus[whichdialogue][j]].coords=participantlocation[whichdialogue][participantfocus[whichdialogue][j]];
922 player[participantfocus[whichdialogue][j]].rotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
923 player[participantfocus[whichdialogue][j]].targetrotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
924 player[participantfocus[whichdialogue][j]].velocity=0;
925 player[participantfocus[whichdialogue][j]].targetanimation=player[participantfocus[whichdialogue][j]].getIdle();
926 player[participantfocus[whichdialogue][j]].targetframe=0;
930 dialoguegonethrough[whichdialogue]++;
931 if(dialogueboxsound[whichdialogue][indialogue]!=0){
933 if(dialogueboxsound[whichdialogue][indialogue]==1)whichsoundplay=rabbitchitter;
934 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
935 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
936 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
937 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
938 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
939 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
940 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
941 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
942 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
943 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
944 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
945 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
946 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
947 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
948 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
949 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
950 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
951 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
952 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
953 emit_sound_at(whichsoundplay, player[participantfocus[whichdialogue][indialogue]].coords);
959 if(indialogue!=-1&&!mainmenu){
960 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
961 glDisable(GL_CULL_FACE);
962 glDisable(GL_LIGHTING);
963 glDisable(GL_TEXTURE_2D);
965 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
966 glPushMatrix(); // Store The Projection Matrix
967 glLoadIdentity(); // Reset The Projection Matrix
968 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
969 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
970 glPushMatrix(); // Store The Modelview Matrix
971 glLoadIdentity(); // Reset The Modelview Matrix
972 if(dialogueboxlocation[whichdialogue][indialogue]==1)glTranslatef(0,screenheight*3/4,0);
973 glScalef(screenwidth,screenheight/4,1);
974 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
977 glColor4f(dialogueboxcolor[whichdialogue][indialogue][0],dialogueboxcolor[whichdialogue][indialogue][1],dialogueboxcolor[whichdialogue][indialogue][2],0.7);
979 glVertex3f(0, 0, 0.0f);
980 glVertex3f(1, 0, 0.0f);
981 glVertex3f(1, 1, 0.0f);
982 glVertex3f(0, 1, 0.0f);
984 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
985 glPopMatrix(); // Restore The Old Projection Matrix
986 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
987 glPopMatrix(); // Restore The Old Projection Matrix
988 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
989 glEnable(GL_CULL_FACE);
992 glEnable(GL_TEXTURE_2D);
999 startx=screenwidth*1/5;
1000 if(dialogueboxlocation[whichdialogue][indialogue]==1)starty=screenheight/16+screenheight*4/5;
1001 if(dialogueboxlocation[whichdialogue][indialogue]==2)starty=screenheight*1/5-screenheight/16;
1010 for(i=0;i<(int)strlen(dialoguename[whichdialogue][indialogue]);i++){
1011 tempname[tempnum]=dialoguename[whichdialogue][indialogue][i];
1013 if(dialoguename[whichdialogue][indialogue][i]=='#'||dialoguename[whichdialogue][indialogue][i]=='\0')goodchar=0;
1017 tempname[tempnum]='\0';
1020 sprintf (string, "%s: ", tempname);
1022 if(dialogueboxcolor[whichdialogue][indialogue][0]+dialogueboxcolor[whichdialogue][indialogue][1]+dialogueboxcolor[whichdialogue][indialogue][2]<1.5){
1023 glColor4f(0,0,0,tutorialopac);
1024 text.glPrintOutline(startx-2*7.6*strlen(string)*screenwidth/1024-4,starty-4,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight);
1025 glColor4f(0.7,0.7,0.7,tutorialopac);
1026 text.glPrint(startx-2*7.6*strlen(string)*screenwidth/1024,starty,string,1,1.5*screenwidth/1024,screenwidth,screenheight);
1030 glColor4f(0,0,0,tutorialopac);
1031 text.glPrintOutline(startx-2*7.6*strlen(string)*screenwidth/1024-4,starty-4,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight);
1035 for(i=0;i<(int)strlen(dialoguetext[whichdialogue][indialogue])+1;i++){
1036 tempname[tempnum]=dialoguetext[whichdialogue][indialogue][i];
1037 if(dialoguetext[whichdialogue][indialogue][i]!='#')tempnum++;
1040 sprintf (string, "%s", tempname);
1047 if(string[i]=='\n'||string[i]>'z'||string[i]<' '||string[i]=='\0'){
1048 if(dialogueboxcolor[whichdialogue][indialogue][0]+dialogueboxcolor[whichdialogue][indialogue][1]+dialogueboxcolor[whichdialogue][indialogue][2]<1.5){
1049 glColor4f(0,0,0,tutorialopac);
1050 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);
1051 glColor4f(1,1,1,tutorialopac);
1052 text.glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/,starty-20*screenwidth/1024*line,string,1,1.5*screenwidth/1024,screenwidth,screenheight,lastline,i);
1056 glColor4f(0,0,0,tutorialopac);
1057 text.glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/,starty-20*screenwidth/1024*line,string,1,1.5*screenwidth/1024,screenwidth,screenheight,lastline,i);
1061 if(string[i]=='\0')done=1;
1068 if(!tutoriallevel&&!winfreeze&&indialogue==-1&&!mainmenu){
1071 sprintf (string, "Score: %d", (int)accountactive->getCampaignScore());
1073 sprintf (string, "Score: %d", (int)accountactive->getCampaignScore()+(int)bonustotal);
1075 if(!campaign)sprintf (string, "Score: %d", (int)bonustotal);
1077 text.glPrintOutline(1024/40-4,768/16-4+768*14/16,string,1,1.5*1.25,1024,768);
1079 text.glPrint(1024/40,768/16+768*14/16,string,1,1.5,1024,768);
1081 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1082 glDisable(GL_CULL_FACE);
1083 glDisable(GL_LIGHTING);
1084 glDisable(GL_TEXTURE_2D);
1086 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1087 glPushMatrix(); // Store The Projection Matrix
1088 glLoadIdentity(); // Reset The Projection Matrix
1089 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1090 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1091 glPushMatrix(); // Store The Modelview Matrix
1092 glLoadIdentity(); // Reset The Modelview Matrix
1093 glTranslatef(15,screenheight*17.5/20,0);
1094 glScalef(screenwidth/3+20,screenheight/20,1);
1095 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1097 glColor4f(0.0,0.4,0.0,0.7);
1098 float bar=((float)player[0].damage)/player[0].damagetolerance;
1100 glVertex3f((bar<1?bar:1),0,0.0f);
1101 glVertex3f(1,0,0.0f);
1102 glVertex3f(1,1,0.0f);
1103 glVertex3f((bar<1?bar:1),1,0.0f);
1105 glColor4f(0.1,0.0,0.0,1);
1106 bar = ((float)player[0].bloodloss)/player[0].damagetolerance;
1108 glVertex3f(0,0,0.0f);
1109 glVertex3f((bar<1?bar:1),0,0.0f);
1110 glVertex3f((bar<1?bar:1),1,0.0f);
1111 glVertex3f(0,1,0.0f);
1113 glColor4f(0.4,0.0,0.0,0.7);
1114 bar = ((float)player[0].damage)/player[0].damagetolerance;
1116 glVertex3f(0,0,0.0f);
1117 glVertex3f((bar<1?bar:1),0,0.0f);
1118 glVertex3f((bar<1?bar:1),1,0.0f);
1119 glVertex3f(0,1,0.0f);
1121 glColor4f(0.4,0.0,0.0,0.7);
1122 bar = ((float)player[0].permanentdamage)/player[0].damagetolerance;
1124 glVertex3f(0,0,0.0f);
1125 glVertex3f((bar<1?bar:1),0,0.0f);
1126 glVertex3f((bar<1?bar:1),1,0.0f);
1127 glVertex3f(0,1,0.0f);
1129 glColor4f(0.4,0.0,0.0,0.7);
1130 bar = ((float)player[0].superpermanentdamage)/player[0].damagetolerance;
1132 glVertex3f(0,0,0.0f);
1133 glVertex3f((bar<1?bar:1),0,0.0f);
1134 glVertex3f((bar<1?bar:1),1,0.0f);
1135 glVertex3f(0,1,0.0f);
1137 glColor4f(0.0,0.0,0.0,0.7);
1139 glBegin(GL_LINE_STRIP);
1140 glVertex3f(0,0,0.0f);
1141 glVertex3f(1,0,0.0f);
1142 glVertex3f(1,1,0.0f);
1143 glVertex3f(0,1,0.0f);
1144 glVertex3f(0,0,0.0f);
1147 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1148 glPopMatrix(); // Restore The Old Projection Matrix
1149 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1150 glPopMatrix(); // Restore The Old Projection Matrix
1151 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1152 glEnable(GL_CULL_FACE);
1153 glDisable(GL_BLEND);
1155 glEnable(GL_TEXTURE_2D);
1157 // writing the numbers :
1158 sprintf (string, "Damages : %d/%d (%d)",(int)(player[0].damage),(int)(player[0].damagetolerance),(int)(player[0].bloodloss));
1160 text.glPrintOutline(1024/40-4,768/16-4+768*14/16-40,string,1,1.5*1.25,1024,768);
1162 text.glPrint(1024/40,768/16+768*14/16-40,string,1,1.5,1024,768);
1166 glColor4f(.5,.5,.5,1);
1169 if((texttoggle||editorenabled)&&debugmode&&!mainmenu){
1170 sprintf (string, "The framespersecond is %d.",(int)(fps));
1171 text.glPrint(10,30,string,0,.8,1024,768);
1173 sprintf (string, "Name: %s", registrationname);
1174 text.glPrint(10,260,string,0,.8,1024,768);
1178 sprintf (string, "Map editor enabled.");
1180 sprintf (string, "Map editor disabled.");
1181 text.glPrint(10,60,string,0,.8,1024,768);
1183 sprintf (string, "Object size: %f",editorsize);
1184 text.glPrint(10,75,string,0,.8,1024,768);
1185 if(editorrotation>=0)sprintf (string, "Object rotation: %f",editorrotation);
1186 else sprintf (string, "Object rotation: Random");
1187 text.glPrint(10,90,string,0,.8,1024,768);
1188 if(editorrotation2>=0)sprintf (string, "Object rotation2: %f",editorrotation2);
1189 else sprintf (string, "Object rotation2: Random");
1190 text.glPrint(10,105,string,0,.8,1024,768);
1191 sprintf (string, "Object type: %d",editortype);
1192 text.glPrint(10,120,string,0,.8,1024,768);
1193 switch(editortype) {
1195 sprintf (string, "(box)");
1198 sprintf (string, "(tree)");
1201 sprintf (string, "(wall)");
1204 sprintf (string, "(weird)");
1207 sprintf (string, "(spike)");
1210 sprintf (string, "(rock)");
1213 sprintf (string, "(bush)");
1216 sprintf (string, "(tunnel)");
1219 sprintf (string, "(chimney)");
1222 sprintf (string, "(platform)");
1225 sprintf (string, "(cool)");
1228 sprintf (string, "(fire)");
1231 text.glPrint(130,120,string,0,.8,1024,768);
1233 sprintf (string, "Numplayers: %d",numplayers);
1234 text.glPrint(10,155,string,0,.8,1024,768);
1235 sprintf (string, "Player %d: numwaypoints: %d",numplayers,player[numplayers-1].numwaypoints);
1236 text.glPrint(10,140,string,0,.8,1024,768);
1238 sprintf (string, "Difficulty: %d",difficulty);
1239 text.glPrint(10,240,string,0,.8,1024,768);
1244 if(drawmode==glowmode){
1245 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1246 glDisable(GL_CULL_FACE);
1247 glDisable(GL_LIGHTING);
1248 glDisable(GL_TEXTURE_2D);
1250 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1251 glPushMatrix(); // Store The Projection Matrix
1252 glLoadIdentity(); // Reset The Projection Matrix
1253 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1254 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1255 glPushMatrix(); // Store The Modelview Matrix
1256 glLoadIdentity(); // Reset The Modelview Matrix
1257 glScalef(screenwidth,screenheight,1);
1258 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1260 glColor4f(0,0,0,.5);
1262 glVertex3f(0, 0, 0.0f);
1263 glVertex3f(256, 0, 0.0f);
1264 glVertex3f(256, 256, 0.0f);
1265 glVertex3f(0, 256, 0.0f);
1267 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1268 glPopMatrix(); // Restore The Old Projection Matrix
1269 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1270 glPopMatrix(); // Restore The Old Projection Matrix
1271 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1272 glEnable(GL_CULL_FACE);
1273 glDisable(GL_BLEND);
1277 if((((blackout&&damageeffects)||(player[0].bloodloss>0&&damageeffects&&player[0].blooddimamount>0)||player[0].dead)&&!cameramode)||console){
1278 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1279 glDisable(GL_CULL_FACE);
1280 glDisable(GL_LIGHTING);
1281 glDisable(GL_TEXTURE_2D);
1283 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1284 glPushMatrix(); // Store The Projection Matrix
1285 glLoadIdentity(); // Reset The Projection Matrix
1286 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1287 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1288 glPushMatrix(); // Store The Modelview Matrix
1289 glLoadIdentity(); // Reset The Modelview Matrix
1290 glScalef(screenwidth,screenheight,1);
1291 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1293 if(player[0].dead)blackout+=multiplier*3;
1294 if(player[0].dead==1)blackout=.4f;
1295 if(player[0].dead==2&&blackout>.6)blackout=.6;
1296 glColor4f(0,0,0,blackout);
1297 if(!player[0].dead){
1298 if((player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5))*.3<.3){
1299 glColor4f(0,0,0,player[0].blooddimamount*player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5)*.3);
1300 blackout=player[0].blooddimamount*player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5)*.3;
1303 glColor4f(0,0,0,player[0].blooddimamount*.3);
1304 blackout=player[0].blooddimamount*.3;
1307 if(console)glColor4f(.7,0,0,.2);
1309 glVertex3f(0, 0, 0.0f);
1310 glVertex3f(256, 0, 0.0f);
1311 glVertex3f(256, 256, 0.0f);
1312 glVertex3f(0, 256, 0.0f);
1314 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1315 glPopMatrix(); // Restore The Old Projection Matrix
1316 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1317 glPopMatrix(); // Restore The Old Projection Matrix
1318 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1319 glEnable(GL_CULL_FACE);
1320 glDisable(GL_BLEND);
1324 if(flashamount>0&&damageeffects) {
1325 if(flashamount>1)flashamount=1;
1326 if(flashdelay<=0)flashamount-=multiplier;
1328 if(flashamount<0)flashamount=0;
1329 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1330 glDisable(GL_CULL_FACE);
1331 glDisable(GL_LIGHTING);
1333 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1334 glPushMatrix(); // Store The Projection Matrix
1335 glLoadIdentity(); // Reset The Projection Matrix
1336 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1337 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1338 glPushMatrix(); // Store The Modelview Matrix
1339 glLoadIdentity(); // Reset The Modelview Matrix
1340 glScalef(screenwidth,screenheight,1);
1341 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1343 glColor4f(flashr,flashg,flashb,flashamount);
1345 glVertex3f(0, 0, 0.0f);
1346 glVertex3f(256, 0, 0.0f);
1347 glVertex3f(256, 256, 0.0f);
1348 glVertex3f(0, 256, 0.0f);
1350 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1351 glPopMatrix(); // Restore The Old Projection Matrix
1352 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1353 glPopMatrix(); // Restore The Old Projection Matrix
1354 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1355 glEnable(GL_CULL_FACE);
1356 glDisable(GL_BLEND);
1362 glEnable(GL_TEXTURE_2D);
1365 sprintf (string, " ]");
1366 text.glPrint(10,30+screenheight-330,string,0,1,screenwidth,screenheight);
1368 sprintf (string, "_");
1369 text.glPrint(30+(float)(displayselected)*10,30+(screenheight-330),string,0,1,screenwidth,screenheight);
1373 if((i!=0||chatting)&&displaytime[i]<4)
1374 for(j=0;j<displaychars[i];j++) {
1375 glColor4f(1,1,1,4-displaytime[i]);
1376 if(j<displaychars[i]) {
1377 sprintf (string, "%c",displaytext[i][j]);
1378 text.glPrint(30+j*10,30+i*20+(screenheight-330),string,0,1,screenwidth,screenheight);
1384 if(minimap&&indialogue==-1){
1385 float mapviewdist = 20000;
1387 glDisable(GL_DEPTH_TEST);
1388 glColor3f (1.0, 1.0, 1.0); // no coloring
1390 glEnable(GL_TEXTURE_2D);
1391 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1392 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1393 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1394 glDisable(GL_CULL_FACE);
1395 glDisable(GL_LIGHTING);
1397 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1398 glPushMatrix(); // Store The Projection Matrix
1399 glLoadIdentity(); // Reset The Projection Matrix
1400 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1401 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1402 glPushMatrix(); // Store The Modelview Matrix
1403 glLoadIdentity(); // Reset The Modelview Matrix
1404 glScalef((float)screenwidth/2,(float)screenwidth/2,1);
1405 glTranslatef(1.75,.25,0);
1406 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1414 int numliveplayers=0;
1416 for(i=0;i<numplayers;i++){
1417 if(!player[i].dead) numliveplayers++;
1422 for(i=0;i<objects.numobjects;i++){
1423 if(objects.type[i]==treetrunktype||objects.type[i]==boxtype){
1424 center+=objects.position[i];
1428 for(i=0;i<numplayers;i++){
1429 if(!player[i].dead)center+=player[i].coords;
1431 center/=numadd+numliveplayers;
1433 center=player[0].coords;
1435 float maxdistance=0;
1437 //~ int whichclosest;
1438 for(i=0;i<objects.numobjects;i++){
1439 tempdist=findDistancefast(¢er,&objects.position[i]);
1440 if(tempdist>maxdistance){
1442 maxdistance=tempdist;
1445 for(i=0;i<numplayers;i++){
1446 if(!player[i].dead){
1447 tempdist=findDistancefast(¢er,&player[i].coords);
1448 if(tempdist>maxdistance){
1450 maxdistance=tempdist;
1454 radius=fast_sqrt(maxdistance);
1458 glScalef(.25/radius*256*terrain.scale*.4,.25/radius*256*terrain.scale*.4,1);
1460 glScalef(1/(1/radius*256*terrain.scale*.4),1/(1/radius*256*terrain.scale*.4),1);
1462 glRotatef(player[0].lookrotation*-1+180,0,0,1);
1463 glTranslatef(-(center.x/terrain.scale/256*-2+1),(center.z/terrain.scale/256*-2+1),0);
1464 for(i=0;i<objects.numobjects;i++){
1465 if(objects.type[i]==treetrunktype){
1466 distcheck=findDistancefast(&player[0].coords,&objects.position[i]);
1467 if(distcheck<mapviewdist){
1468 glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
1469 glColor4f(0,.3,0,opac*(1-distcheck/mapviewdist));
1471 glTranslatef(objects.position[i].x/terrain.scale/256*-2+1,objects.position[i].z/terrain.scale/256*2-1,0);
1472 glRotatef(objects.rotation[i],0,0,1);
1473 glScalef(.003,.003,.003);
1476 glVertex3f(-1, -1, 0.0f);
1478 glVertex3f(1, -1, 0.0f);
1480 glVertex3f(1, 1, 0.0f);
1482 glVertex3f(-1, 1, 0.0f);
1487 if(objects.type[i]==boxtype){
1488 distcheck=findDistancefast(&player[0].coords,&objects.position[i]);
1489 if(distcheck<mapviewdist){
1490 glBindTexture( GL_TEXTURE_2D, Mapboxtexture);
1491 glColor4f(.4,.4,.4,opac*(1-distcheck/mapviewdist));
1493 glTranslatef(objects.position[i].x/terrain.scale/256*-2+1,objects.position[i].z/terrain.scale/256*2-1,0);
1494 glRotatef(objects.rotation[i],0,0,1);
1495 glScalef(.01*objects.scale[i],.01*objects.scale[i],.01*objects.scale[i]);
1498 glVertex3f(-1, -1, 0.0f);
1500 glVertex3f(1, -1, 0.0f);
1502 glVertex3f(1, 1, 0.0f);
1504 glVertex3f(-1, 1, 0.0f);
1511 glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
1512 for(i=0;i<numboundaries;i++){
1513 glColor4f(0,0,0,opac/3);
1515 glTranslatef(boundary[i].x/terrain.scale/256*-2+1,boundary[i].z/terrain.scale/256*2-1,0);
1516 glScalef(.002,.002,.002);
1519 glVertex3f(-1, -1, 0.0f);
1521 glVertex3f(1, -1, 0.0f);
1523 glVertex3f(1, 1, 0.0f);
1525 glVertex3f(-1, 1, 0.0f);
1530 for(i=0;i<numplayers;i++){
1531 distcheck=findDistancefast(&player[0].coords,&player[i].coords);
1532 if(distcheck<mapviewdist){
1534 glBindTexture( GL_TEXTURE_2D, Maparrowtexture);
1535 if(i==0)glColor4f(1,1,1,opac);
1536 else if(player[i].dead==2||player[i].howactive>typesleeping)glColor4f(0,0,0,opac*(1-distcheck/mapviewdist));
1537 else if(player[i].dead)glColor4f(.3,.3,.3,opac*(1-distcheck/mapviewdist));
1538 else if(player[i].aitype==attacktypecutoff)glColor4f(1,0,0,opac*(1-distcheck/mapviewdist));
1539 else if(player[i].aitype==passivetype)glColor4f(0,1,0,opac*(1-distcheck/mapviewdist));
1540 else glColor4f(1,1,0,1);
1541 glTranslatef(player[i].coords.x/terrain.scale/256*-2+1,player[i].coords.z/terrain.scale/256*2-1,0);
1542 glRotatef(player[i].rotation+180,0,0,1);
1543 glScalef(.005,.005,.005);
1546 glVertex3f(-1, -1, 0.0f);
1548 glVertex3f(1, -1, 0.0f);
1550 glVertex3f(1, 1, 0.0f);
1552 glVertex3f(-1, 1, 0.0f);
1558 glDisable(GL_TEXTURE_2D);
1559 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1560 glPopMatrix(); // Restore The Old Projection Matrix
1561 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1562 glPopMatrix(); // Restore The Old Projection Matrix
1563 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1564 glEnable(GL_CULL_FACE);
1565 glDisable(GL_BLEND);
1569 if(loading&&!stealthloading&&(!campaign||player[0].dead)){
1570 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1571 glDisable(GL_CULL_FACE);
1572 glDisable(GL_LIGHTING);
1573 glDisable(GL_TEXTURE_2D);
1575 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1576 glPushMatrix(); // Store The Projection Matrix
1577 glLoadIdentity(); // Reset The Projection Matrix
1578 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1579 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1580 glPushMatrix(); // Store The Modelview Matrix
1581 glLoadIdentity(); // Reset The Modelview Matrix
1582 glScalef(screenwidth,screenheight,1);
1583 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1585 glColor4f(0,0,0,.7);
1587 glVertex3f(0, 0, 0.0f);
1588 glVertex3f(256, 0, 0.0f);
1589 glVertex3f(256, 256, 0.0f);
1590 glVertex3f(0, 256, 0.0f);
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 glDisable(GL_DEPTH_TEST);
1603 glColor3f (1.0, 1.0, 1.0); // no coloring
1605 glEnable(GL_TEXTURE_2D);
1610 glEnable(GL_TEXTURE_2D);
1612 sprintf (string, "Loading...");
1613 text.glPrint(1024/2-90,768/2,string,1,2,1024,768);
1616 //if(ismotionblur)drawmode=motionblurmode;
1617 drawmode=normalmode;
1620 if(winfreeze&&!campaign){
1621 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1622 glDisable(GL_CULL_FACE);
1623 glDisable(GL_LIGHTING);
1624 glDisable(GL_TEXTURE_2D);
1626 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1627 glPushMatrix(); // Store The Projection Matrix
1628 glLoadIdentity(); // Reset The Projection Matrix
1629 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1630 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1631 glPushMatrix(); // Store The Modelview Matrix
1632 glLoadIdentity(); // Reset The Modelview Matrix
1633 glScalef(screenwidth,screenheight,1);
1634 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1636 glColor4f(0,0,0,.4);
1638 glVertex3f(0, 0, 0.0f);
1639 glVertex3f(256, 0, 0.0f);
1640 glVertex3f(256, 256, 0.0f);
1641 glVertex3f(0, 256, 0.0f);
1643 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1644 glPopMatrix(); // Restore The Old Projection Matrix
1645 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1646 glPopMatrix(); // Restore The Old Projection Matrix
1647 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1648 glEnable(GL_CULL_FACE);
1649 glDisable(GL_BLEND);
1653 glDisable(GL_DEPTH_TEST);
1654 glColor3f (1.0, 1.0, 1.0); // no coloring
1656 glEnable(GL_TEXTURE_2D);
1658 //Win Screen Won Victory
1660 glEnable(GL_TEXTURE_2D);
1662 sprintf (string, "Level Cleared!");
1663 text.glPrintOutlined(1024/2-strlen(string)*10,768*7/8,string,1,2,1024,768);
1665 sprintf (string, "Score: %d",(int)(bonustotal-startbonustotal));
1666 text.glPrintOutlined(1024/30,768*6/8,string,1,2,1024,768);
1669 sprintf (string, "Press Escape or Space to continue");
1671 sprintf (string, "Press Escape to return to menu or Space to continue");
1672 text.glPrintOutlined(640/2-strlen(string)*5,480*1/16,string,1,1,640,480);
1676 for(i=0;i<255;i++)string[i]='\0';
1677 sprintf (temp, "Time: %d:",(int)(((int)leveltime-(int)(leveltime)%60)/60));
1678 strcat(string,temp);
1679 if((int)(leveltime)%60<10)strcat(string,"0");
1680 sprintf (temp, "%d",(int)(leveltime)%60);
1681 strcat(string,temp);
1682 text.glPrintOutlined(1024/30,768*6/8-40,string,1,2,1024,768);
1685 int awards[award_count];
1686 int numawards = award_awards(awards);
1688 for (i = 0; i < numawards && i < 6; i++)
1689 text.glPrintOutlined(1024/30,768*6/8-90-40*i,award_names[awards[i]],1,2,1024,768);
1692 if(drawmode!=normalmode){
1693 glEnable(GL_TEXTURE_2D);
1695 if(!drawtoggle||drawmode!=realmotionblurmode||(drawtoggle==2||change==1)){
1698 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
1699 GLfloat subtractColor[4] = { 0.5, 0.5, 0.5, 0.0 };
1700 glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, subtractColor);
1701 //glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_SUBTRACT);
1702 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE);
1703 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_CONSTANT_EXT);
1704 glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 2.0f);
1706 glBindTexture( GL_TEXTURE_2D, screentexture);
1707 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1710 if((drawtoggle||change==1)&&drawmode==realmotionblurmode){
1712 glBindTexture( GL_TEXTURE_2D, screentexture2);
1713 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1715 if(!screentexture2){
1716 glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
1718 glGenTextures( 1, &screentexture2 );
1719 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
1721 glEnable(GL_TEXTURE_2D);
1722 glBindTexture( GL_TEXTURE_2D, screentexture2);
1723 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
1724 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
1726 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
1732 glClear(GL_DEPTH_BUFFER_BIT);
1733 ReSizeGLScene(90,.1f);
1734 glViewport(0,0,screenwidth,screenheight);
1736 if(drawmode!=normalmode){
1737 glDisable(GL_DEPTH_TEST);
1738 if(drawmode==motionblurmode){
1739 glDrawBuffer(GL_FRONT);
1740 glReadBuffer(GL_BACK);
1742 glColor3f (1.0, 1.0, 1.0); // no coloring
1744 glEnable(GL_TEXTURE_2D);
1745 glBindTexture( GL_TEXTURE_2D, screentexture);
1746 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1747 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1748 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1749 glDisable(GL_CULL_FACE);
1750 glDisable(GL_LIGHTING);
1752 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1753 glPushMatrix(); // Store The Projection Matrix
1754 glLoadIdentity(); // Reset The Projection Matrix
1755 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1756 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1757 glPushMatrix(); // Store The Modelview Matrix
1758 glLoadIdentity(); // Reset The Modelview Matrix
1759 glScalef((float)screenwidth/2,(float)screenheight/2,1);
1760 glTranslatef(1,1,0);
1761 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1763 if(drawmode==motionblurmode){
1764 if(motionbluramount<.2)motionbluramount=.2;
1765 //glColor4f(1,1,1,fast_sqrt(multiplier)*2.9*motionbluramount);
1766 glColor4f(1,1,1,motionbluramount);
1770 glVertex3f(-1, -1, 0.0f);
1771 glTexCoord2f(texcoordwidth,0);
1772 glVertex3f(1, -1, 0.0f);
1773 glTexCoord2f(texcoordwidth,texcoordheight);
1774 glVertex3f(1, 1, 0.0f);
1775 glTexCoord2f(0,texcoordheight);
1776 glVertex3f(-1, 1, 0.0f);
1780 if(drawmode==realmotionblurmode){
1781 glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
1782 glClear(GL_COLOR_BUFFER_BIT);
1783 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
1784 glBindTexture( GL_TEXTURE_2D, screentexture);
1785 glColor4f(1,1,1,.5);
1789 glVertex3f(-1, -1, 0.0f);
1790 glTexCoord2f(texcoordwidth,0);
1791 glVertex3f(1, -1, 0.0f);
1792 glTexCoord2f(texcoordwidth,texcoordheight);
1793 glVertex3f(1, 1, 0.0f);
1794 glTexCoord2f(0,texcoordheight);
1795 glVertex3f(-1, 1, 0.0f);
1798 glBindTexture( GL_TEXTURE_2D, screentexture2);
1799 glColor4f(1,1,1,.5);
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);
1812 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1814 if(drawmode==doublevisionmode){
1815 static float crosseyedness;
1816 crosseyedness=abs(player[0].damage-player[0].superpermanentdamage-(player[0].damagetolerance-player[0].superpermanentdamage)*1/2)/30;
1817 if(crosseyedness>1)crosseyedness=1;
1818 if(crosseyedness<0)crosseyedness=0;
1820 glDisable(GL_BLEND);
1825 glVertex3f(-1, -1, 0.0f);
1826 glTexCoord2f(texcoordwidth,0);
1827 glVertex3f(1, -1, 0.0f);
1828 glTexCoord2f(texcoordwidth,texcoordheight);
1829 glVertex3f(1, 1, 0.0f);
1830 glTexCoord2f(0,texcoordheight);
1831 glVertex3f(-1, 1, 0.0f);
1835 glColor4f(1,1,1,.5);
1838 glTranslatef(.015*crosseyedness,0,0);
1842 glVertex3f(-1, -1, 0.0f);
1843 glTexCoord2f(texcoordwidth,0);
1844 glVertex3f(1, -1, 0.0f);
1845 glTexCoord2f(texcoordwidth,texcoordheight);
1846 glVertex3f(1, 1, 0.0f);
1847 glTexCoord2f(0,texcoordheight);
1848 glVertex3f(-1, 1, 0.0f);
1853 if(drawmode==glowmode){
1854 glColor4f(.5,.5,.5,.5);
1856 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
1858 glTranslatef(.01,0,0);
1861 glVertex3f(-1, -1, 0.0f);
1862 glTexCoord2f(texcoordwidth,0);
1863 glVertex3f(1, -1, 0.0f);
1864 glTexCoord2f(texcoordwidth,texcoordheight);
1865 glVertex3f(1, 1, 0.0f);
1866 glTexCoord2f(0,texcoordheight);
1867 glVertex3f(-1, 1, 0.0f);
1871 glTranslatef(-.01,0,0);
1874 glVertex3f(-1, -1, 0.0f);
1875 glTexCoord2f(texcoordwidth,0);
1876 glVertex3f(1, -1, 0.0f);
1877 glTexCoord2f(texcoordwidth,texcoordheight);
1878 glVertex3f(1, 1, 0.0f);
1879 glTexCoord2f(0,texcoordheight);
1880 glVertex3f(-1, 1, 0.0f);
1884 glTranslatef(.0,.01,0);
1887 glVertex3f(-1, -1, 0.0f);
1888 glTexCoord2f(texcoordwidth,0);
1889 glVertex3f(1, -1, 0.0f);
1890 glTexCoord2f(texcoordwidth,texcoordheight);
1891 glVertex3f(1, 1, 0.0f);
1892 glTexCoord2f(0,texcoordheight);
1893 glVertex3f(-1, 1, 0.0f);
1897 glTranslatef(0,-.01,0);
1900 glVertex3f(-1, -1, 0.0f);
1901 glTexCoord2f(texcoordwidth,0);
1902 glVertex3f(1, -1, 0.0f);
1903 glTexCoord2f(texcoordwidth,texcoordheight);
1904 glVertex3f(1, 1, 0.0f);
1905 glTexCoord2f(0,texcoordheight);
1906 glVertex3f(-1, 1, 0.0f);
1910 if(drawmode==radialzoommode){
1912 //glRotatef((float)i*.1,0,0,1);
1913 glColor4f(1,1,1,1/((float)i+1));
1915 glScalef(1+(float)i*.01,1+(float)i*.01,1);
1918 glVertex3f(-1, -1, 0.0f);
1919 glTexCoord2f(texcoordwidth,0);
1920 glVertex3f(1, -1, 0.0f);
1921 glTexCoord2f(texcoordwidth,texcoordheight);
1922 glVertex3f(1, 1, 0.0f);
1923 glTexCoord2f(0,texcoordheight);
1924 glVertex3f(-1, 1, 0.0f);
1929 glDisable(GL_TEXTURE_2D);
1930 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1931 glPopMatrix(); // Restore The Old Projection Matrix
1932 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1933 glPopMatrix(); // Restore The Old Projection Matrix
1934 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1935 glEnable(GL_CULL_FACE);
1936 glDisable(GL_BLEND);
1941 glEnable(GL_TEXTURE_2D);
1944 if(consoleselected>=60)
1945 offset=consoleselected-60;
1946 sprintf (string, " ]");
1947 text.glPrint(10,30,string,0,1,1024,768);
1949 sprintf (string, "_");
1950 text.glPrint(30+(float)(consoleselected)*10-offset*10,30,string,0,1,1024,768);
1953 for(j=0;j<consolechars[i];j++){
1954 glColor4f(1,1,1,1-(float)(i)/16);
1955 if(j<consolechars[i]){
1956 sprintf (string, "%c",consoletext[i][j]);
1957 text.glPrint(30+j*10-offset*10,30+i*20,string,0,1,1024,768);
1964 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)){
1965 multiplier=tempmult;
1972 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)){
1973 tempmult=multiplier;
1978 if ( side == stereoRight || side == stereoCenter ) {
1979 if(drawmode!=motionblurmode||mainmenu){
1984 //myassert(glGetError() == GL_NO_ERROR);
1985 glDrawBuffer(GL_BACK);
1986 glReadBuffer(GL_BACK);
1991 if(drawtoggle==2)drawtoggle=0;
1993 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)){
1994 multiplier=tempmult;
1996 //Jordan fixed your warning!
2000 vector<string> Game::ListCampaigns() {
2001 DIR *campaigns = opendir(ConvertFileName(":Data:Campaigns"));
2002 struct dirent *campaign = NULL;
2004 perror("Problem while loading campaigns");
2005 cerr << "campaign folder was : " << ConvertFileName(":Data:Campaigns") << endl;
2008 vector<string> campaignNames;
2009 while ((campaign = readdir(campaigns)) != NULL) {
2010 string name(campaign->d_name);
2013 if(!name.compare(name.length()-4,4,".txt")) {
2014 campaignNames.push_back(name.substr(0,name.length()-4));
2017 closedir(campaigns);
2018 return campaignNames;
2021 void Game::LoadCampaign() {
2024 ifstream ipstream(ConvertFileName((":Data:Campaigns:"+accountactive->getCurrentCampaign()+".txt").c_str()));
2025 ipstream.ignore(256,':');
2027 ipstream >> numlevels;
2028 campaignlevels.clear();
2029 for(int i=0;i<numlevels;i++) {
2032 campaignlevels.push_back(cl);
2036 ifstream test(ConvertFileName((":Data:Textures:"+accountactive->getCurrentCampaign()+":World.png").c_str()));
2038 LoadTexture((":Data:Textures:"+accountactive->getCurrentCampaign()+":World.png").c_str(),&Mainmenuitems[7],0,0);
2040 LoadTexture(":Data:Textures:World.png",&Mainmenuitems[7],0,0);
2043 if(accountactive->getCampaignChoicesMade()==0) {
2044 accountactive->setCampaignScore(0);
2045 accountactive->resetFasttime();
2049 void Game::DrawMenu() {
2050 // !!! FIXME: hack: clamp framerate in menu so text input works correctly on fast systems.
2053 glDrawBuffer(GL_BACK);
2054 glReadBuffer(GL_BACK);
2055 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
2056 ReSizeGLScene(90,.1f);
2058 if(oldmainmenu!=mainmenu){
2064 oldmainmenu=mainmenu;
2066 glClear(GL_DEPTH_BUFFER_BIT);
2067 glEnable(GL_ALPHA_TEST);
2068 glAlphaFunc(GL_GREATER, 0.001f);
2069 glEnable(GL_TEXTURE_2D);
2070 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
2071 glDisable(GL_CULL_FACE);
2072 glDisable(GL_LIGHTING);
2074 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2075 glPushMatrix(); // Store The Projection Matrix
2076 glLoadIdentity(); // Reset The Projection Matrix
2077 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
2078 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2079 glPushMatrix(); // Store The Modelview Matrix
2080 glLoadIdentity(); // Reset The Modelview Matrix
2081 glTranslatef(screenwidth/2,screenheight/2,0);
2083 glScalef((float)screenwidth/2,(float)screenheight/2,1);
2084 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
2085 glDisable(GL_BLEND);
2086 glColor4f(0,0,0,1.0);
2087 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2088 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2089 glDisable(GL_TEXTURE_2D);
2091 //glScalef(.25,.25,.25);
2094 glVertex3f(-1, -1, 0.0f);
2096 glVertex3f(1, -1, 0.0f);
2098 glVertex3f(1, 1, 0.0f);
2100 glVertex3f(-1, 1, 0.0f);
2104 glColor4f(0.4,0.4,0.4,1.0);
2105 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2106 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2107 glEnable(GL_TEXTURE_2D);
2108 glBindTexture( GL_TEXTURE_2D, Mainmenuitems[4]);
2110 //glScalef(.25,.25,.25);
2113 glVertex3f(-1, -1, 0.0f);
2115 glVertex3f(1, -1, 0.0f);
2117 glVertex3f(1, 1, 0.0f);
2119 glVertex3f(-1, 1, 0.0f);
2124 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2126 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2138 starty[1]=480-152-32;
2143 starty[2]=480-228-32;
2149 starty[3]=480-306-32;
2156 starty[3]=480-306-32;
2165 if((float)newscreenwidth>(float)newscreenheight*1.61||(float)newscreenwidth<(float)newscreenheight*1.59)sprintf (menustring[0], "Resolution: %d*%d",(int)newscreenwidth,(int)newscreenheight);
2166 else sprintf (menustring[0], "Resolution: %d*%d (widescreen)",(int)newscreenwidth,(int)newscreenheight);
2170 if(newdetail==2) sprintf (menustring[1], "Detail: High");
2171 else if(newdetail==1) sprintf (menustring[1], "Detail: Medium");
2172 else sprintf (menustring[1], "Detail: Low");
2176 if(bloodtoggle==2) sprintf (menustring[2], "Blood: On, high detail (slower)");
2177 if(bloodtoggle==1) sprintf (menustring[2], "Blood: On, low detail");
2178 if(bloodtoggle==0) sprintf (menustring[2], "Blood: Off");
2182 if(difficulty==2) sprintf (menustring[3], "Difficulty: Insane");
2183 if(difficulty==1) sprintf (menustring[3], "Difficulty: Difficult");
2184 if(difficulty==0) sprintf (menustring[3], "Difficulty: Easier");
2185 startx[3]=10+20-1000;
2188 if(ismotionblur==1) sprintf (menustring[4], "Blur Effects: Enabled (less compatible)");
2189 if(ismotionblur==0) sprintf (menustring[4], "Blur Effects: Disabled (more compatible)");
2193 if(decals==1) sprintf (menustring[5], "Decals: Enabled (slower)");
2194 if(decals==0) sprintf (menustring[5], "Decals: Disabled");
2198 if(musictoggle==1) sprintf (menustring[6], "Music: Enabled");
2199 if(musictoggle==0) sprintf (menustring[6], "Music: Disabled");
2203 if(invertmouse==1) sprintf (menustring[9], "Invert mouse: Yes");
2204 if(invertmouse==0) sprintf (menustring[9], "Invert mouse: No");
2208 sprintf (menustring[10], "Mouse Speed: %d", (int)(usermousesensitivity*5));
2212 sprintf (menustring[11], "Volume: %d%%", (int)(volume*100));
2216 sprintf (menustring[13], "Damage Bar: %s",(showdamagebar?"on":"off"));
2220 sprintf (menustring[7], "-Configure Controls-");
2224 sprintf (menustring[12], "-Configure Stereo -");
2228 if(newdetail==detail&&newscreenheight==(int)screenheight&&newscreenwidth==(int)screenwidth)sprintf (menustring[8], "Back");
2229 else sprintf (menustring[8], "Back (some changes take effect next time Lugaru is opened)");
2236 if(keyselect!=0)sprintf (menustring[0], "Forwards: %s",Input::keyToChar(forwardkey));
2237 else sprintf (menustring[0], "Forwards: _");
2241 if(keyselect!=1)sprintf (menustring[1], "Back: %s",Input::keyToChar(backkey));
2242 else sprintf (menustring[1], "Back: _");
2246 if(keyselect!=2)sprintf (menustring[2], "Left: %s",Input::keyToChar(leftkey));
2247 else sprintf (menustring[2], "Left: _");
2251 if(keyselect!=3)sprintf (menustring[3], "Right: %s",Input::keyToChar(rightkey));
2252 else sprintf (menustring[3], "Right: _");
2256 if(keyselect!=4)sprintf (menustring[4], "Crouch: %s",Input::keyToChar(crouchkey));
2257 else sprintf (menustring[4], "Crouch: _");
2261 if(keyselect!=5)sprintf (menustring[5], "Jump: %s",Input::keyToChar(jumpkey));
2262 else sprintf (menustring[5], "Jump: _");
2266 if(keyselect!=6)sprintf (menustring[6], "Draw: %s",Input::keyToChar(drawkey));
2267 else sprintf (menustring[6], "Draw: _");
2271 if(keyselect!=7)sprintf (menustring[7], "Throw: %s",Input::keyToChar(throwkey));
2272 else sprintf (menustring[7], "Throw: _");
2276 if(keyselect!=8)sprintf (menustring[8], "Attack: %s",Input::keyToChar(attackkey));
2277 else sprintf (menustring[8], "Attack: _");
2282 if(keyselect!=9)sprintf (menustring[9], "Console: %s",Input::keyToChar(consolekey));
2283 else sprintf (menustring[9], "Console: _");
2289 sprintf (menustring[nummenuitems-1], "Back");
2290 startx[nummenuitems-1]=10;
2291 starty[nummenuitems-1]=10;
2295 nummenuitems=NB_CAMPAIGN_MENU_ITEM;
2297 sprintf (menustring[0], "%s",accountactive->getName());
2301 sprintf (menustring[1], "Tutorial");
2305 sprintf (menustring[2], "Challenge");
2309 sprintf (menustring[3], "Delete User");
2313 sprintf (menustring[4], "Main Menu");
2317 sprintf (menustring[5], "Change User");
2321 sprintf (menustring[6], "Campaign : %s", accountactive->getCurrentCampaign().c_str());
2329 sprintf (menustring[0], "Are you sure you want to delete this user?");
2333 sprintf (menustring[1], "Yes");
2337 sprintf (menustring[2], "No");
2343 nummenuitems=Account::getNbAccounts()+2;
2347 if(Account::getNbAccounts()<8)
2348 sprintf (menustring[0], "New User");
2350 sprintf (menustring[0], "No More Users");
2358 for(int i=0;i<Account::getNbAccounts();i++){
2359 sprintf (menustring[num], "%s",Account::get(i)->getName());
2361 starty[num]=360-20-20*num;
2366 sprintf (menustring[num], "Back");
2374 sprintf (menustring[0], "Easier");
2378 sprintf (menustring[1], "Difficult");
2382 sprintf (menustring[2], "Insane");
2388 nummenuitems=2+numchallengelevels;
2391 for(int i=0;i<numchallengelevels;i++){
2393 sprintf (temp, "Level %d",i+1);
2394 for(int j=strlen(temp);j<17;j++)
2397 sprintf (temp, "%d",(int)accountactive->getHighScore(i));
2398 for(int j=strlen(temp);j<(32-17);j++)
2401 sprintf (temp, "%d:",(int)(((int)accountactive->getFastTime(i)-(int)(accountactive->getFastTime(i))%60)/60));
2402 if((int)(accountactive->getFastTime(i))%60<10)strcat(temp,"0");
2404 sprintf (temp, "%d",(int)(accountactive->getFastTime(i))%60);
2407 sprintf(menustring[i],"%s",name.c_str());
2413 sprintf (menustring[numchallengelevels], "Back");
2414 startx[numchallengelevels]=10;
2415 starty[numchallengelevels]=10;
2417 sprintf (menustring[numchallengelevels+1], " High Score Best Time");
2418 startx[numchallengelevels+1]=10;
2419 starty[numchallengelevels+1]=440;
2421 //numchallengelevels=tempncl;
2429 sprintf (menustring[0], "Congratulations!");
2433 sprintf (menustring[1], "You have avenged your family and");
2437 sprintf (menustring[2], "restored peace to the island of Lugaru.");
2441 sprintf (menustring[3], "Back");
2445 for(int i=0;i<255;i++)
2446 menustring[4][i]='\0';
2447 sprintf (temp, "Your score:");
2448 strcpy(menustring[4],temp);
2449 for(int i=0;i<20;i++)
2450 if(menustring[4][i]=='\0')
2451 menustring[4][i]=' ';
2452 menustring[4][20]='\0';
2453 sprintf (temp, "%d",(int)accountactive->getCampaignScore());
2454 strcat(menustring[4],temp);
2457 for(int i=0;i<255;i++)
2458 menustring[5][i]='\0';
2459 sprintf (temp, "Highest score:");
2460 strcpy(menustring[5],temp);
2461 for(int i=0;i<20;i++)
2462 if(menustring[5][i]=='\0')menustring[5][i]=' ';
2463 menustring[5][20]='\0';
2464 sprintf (temp, "%d",(int)accountactive->getCampaignHighScore());
2465 strcat(menustring[5],temp);
2472 sprintf (menustring[0], "Stereo mode: %s", StereoModeName(newstereomode));
2476 sprintf (menustring[1], "Stereo separation: %.3f", stereoseparation);
2480 sprintf (menustring[2], "Reverse stereo: %s", stereoreverse ? "Yes" : "No");
2484 sprintf (menustring[3], "Back");
2489 if(mainmenu!=1 && mainmenu!=2) {
2490 for(int i=0;i<nummenuitems;++i) {
2491 endx[i]=startx[i]+strlen(menustring[i])*10;
2492 endy[i]=starty[i]+20;
2498 for(int i=0;i<nummenuitems;i++) {
2499 if((mousecoordh/screenwidth*640)>startx[i]&&(mousecoordh/screenwidth*640)<endx[i]&&480-(mousecoordv/screenheight*480)>starty[i]&&480-(mousecoordv/screenheight*480)<endy[i]) {
2500 if((mainmenu!=5) && (mainmenu!=1) && (mainmenu!=2)) selected=i; // username in menu 5 and game title in menu 1&2 can't be selected
2501 else if (i>0) selected=i;
2506 numlevelsonmap = accountactive->getCampaignChoicesMade()+(accountactive->getCampaignChoicesMade()>0?campaignlevels[accountactive->getCampaignChoicesMade()-1].nextlevel.size():1);
2507 for (int i=0;i<numlevelsonmap;i++) {
2508 if ((mousecoordh/screenwidth*640)>campaignlevels[i].getStartX()&&
2509 (mousecoordh/screenwidth*640)<campaignlevels[i].getEndX()&&
2510 480-(mousecoordv/screenheight*480)>campaignlevels[i].getStartY()&&
2511 480-(mousecoordv/screenheight*480)<campaignlevels[i].getEndY()) {
2512 selected=nummenuitems+i;
2519 for(int i=0;i<nummenuitems+numlevelsonmap;i++) {
2521 selectedlong[i]+=multiplier*5;
2522 if(selectedlong[i]>1) selectedlong[i]=1;
2524 selectedlong[i]-=multiplier*5;
2525 if(selectedlong[i]<0) selectedlong[i]=0;
2529 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2530 glPushMatrix(); // Store The Projection Matrix
2531 glLoadIdentity(); // Reset The Projection Matrix
2532 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
2533 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2534 glPushMatrix(); // Store The Modelview Matrix
2535 glLoadIdentity(); // Reset The Modelview Matrix
2536 glEnable(GL_TEXTURE_2D);
2537 for(int j=0;j<nummenuitems;j++)
2539 //glDisable(GL_BLEND);
2540 glEnable(GL_ALPHA_TEST);
2542 //glDisable(GL_ALPHA_TEST);
2543 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
2544 if(mainmenu==1||mainmenu==2)
2547 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
2548 if(mainmenu==2 && (j==1 || j == 3)) {
2549 glBindTexture( GL_TEXTURE_2D, Mainmenuitems[(j==1?5:6)]);
2551 glBindTexture( GL_TEXTURE_2D, Mainmenuitems[j]);
2553 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
2554 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
2555 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2559 glVertex3f(startx[j], starty[j], 0.0f);
2561 glVertex3f(endx[j], starty[j], 0.0f);
2563 glVertex3f(endx[j], endy[j], 0.0f);
2565 glVertex3f(startx[j], endy[j], 0.0f);
2569 //glDisable(GL_ALPHA_TEST);
2570 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
2571 for(int i=0;i<10;i++)
2573 if(1-((float)i)/10-(1-selectedlong[j])>0)
2575 glColor4f(1,1,1,(1-((float)i)/10-(1-selectedlong[j]))*.25);
2576 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2580 glVertex3f(startx[j]-((float)i)*1/2, starty[j]-((float)i)*1/2, 0.0f);
2582 glVertex3f(endx[j]+((float)i)*1/2, starty[j]-((float)i)*1/2, 0.0f);
2584 glVertex3f(endx[j]+((float)i)*1/2, endy[j]+((float)i)*1/2, 0.0f);
2586 glVertex3f(startx[j]-((float)i)*1/2, endy[j]+((float)i)*1/2, 0.0f);
2592 if(mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==8||mainmenu==9||mainmenu==10||mainmenu==18)
2595 if( (mainmenu==9) && j>accountactive->getProgress() && (j<numchallengelevels) )
2596 glColor4f(0.5,0,0,1);
2597 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2599 if(mainmenu!=7||j!=0||!entername)
2600 text.glPrint(startx[j],starty[j],menustring[j],0,1,640,480);
2605 text.glPrint(startx[j]+(float)(displayselected)*10,starty[j],string,0,1,640,480);
2607 for(int l=0;l<displaychars[0];l++) {
2608 sprintf (string, "%c",displaytext[0][l]);
2609 text.glPrint(startx[j]+l*10,starty[j],string,0,1,640,480);
2614 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
2615 for(int i=0;i<15;i++)
2617 if(1-((float)i)/15-(1-selectedlong[j])>0)
2619 glColor4f(1,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
2620 if(mainmenu==9&&j>accountactive->getProgress()&&j<numchallengelevels)glColor4f(0.5,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
2621 if(mainmenu==3)text.glPrint(startx[j]-((float)i)-((((float)i)/70)*strlen(menustring[j]))*3,starty[j],menustring[j],0,1+((float)i)/70,640,480);
2622 if(mainmenu==4)text.glPrint(startx[j]-((float)i),starty[j],menustring[j],0,1+((float)i)/70,640,480);
2623 if(mainmenu==5)text.glPrint(startx[j]-((float)i),starty[j],menustring[j],0,1+((float)i)/70,640,480);
2624 if(mainmenu==6)text.glPrint(startx[j]-((float)i),starty[j],menustring[j],0,1+((float)i)/70,640,480);
2625 if(mainmenu==7&&(j!=0||!entername)) text.glPrint(startx[j]-((float)i),starty[j],menustring[j],0,1+((float)i)/70,640,480);
2626 if(mainmenu==8)text.glPrint(startx[j]-((float)i),starty[j],menustring[j],0,1+((float)i)/70,640,480);
2627 if(mainmenu==9)text.glPrint(startx[j]-((float)i),starty[j],menustring[j],0,1+((float)i)/70,640,480);
2628 if(mainmenu==10)text.glPrint(startx[j]-((float)i),starty[j],menustring[j],0,1+((float)i)/70,640,480);
2629 if(mainmenu==18)text.glPrint(startx[j]-((float)i),starty[j],menustring[j],0,1+((float)i)/70,640,480);
2635 if(mainmenu==5) { // show map
2636 //glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); // black background for the map
2637 glBlendFunc(GL_SRC_ALPHA,GL_ONE); // no background
2638 glClear(GL_DEPTH_BUFFER_BIT);
2639 glEnable(GL_ALPHA_TEST);
2640 glAlphaFunc(GL_GREATER, 0.001f);
2641 glEnable(GL_TEXTURE_2D);
2642 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
2643 glDisable(GL_CULL_FACE);
2644 glDisable(GL_LIGHTING);
2646 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2647 glPushMatrix(); // Store The Projection Matrix
2648 glLoadIdentity(); // Reset The Projection Matrix
2649 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
2650 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2651 glPushMatrix(); // Store The Modelview Matrix
2652 glLoadIdentity(); // Reset The Modelview Matrix
2655 //Draw world, draw map
2656 glTranslatef(2,-5,0);
2657 glBindTexture( GL_TEXTURE_2D, Mainmenuitems[7]);
2658 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
2659 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
2666 midpoint.x=150+itemsize;
2667 midpoint.y=60+itemsize;
2668 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2672 glVertex3f(midpoint.x-itemsize, midpoint.y-itemsize, 0.0f);
2674 glVertex3f(midpoint.x+itemsize, midpoint.y-itemsize, 0.0f);
2676 glVertex3f(midpoint.x+itemsize, midpoint.y+itemsize, 0.0f);
2678 glVertex3f(midpoint.x-itemsize, midpoint.y+itemsize, 0.0f);
2684 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2686 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2689 for(int i=0; i<numlevelsonmap;i++) { // show levels on the map
2690 glEnable(GL_ALPHA_TEST);
2692 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
2694 glClear(GL_DEPTH_BUFFER_BIT);
2695 glEnable(GL_ALPHA_TEST);
2696 glAlphaFunc(GL_GREATER, 0.001f);
2697 glEnable(GL_TEXTURE_2D);
2698 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
2699 glDisable(GL_CULL_FACE);
2700 glDisable(GL_LIGHTING);
2703 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2704 glPushMatrix(); // Store The Projection Matrix
2705 glLoadIdentity(); // Reset The Projection Matrix
2706 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
2707 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2708 glPushMatrix(); // Store The Modelview Matrix
2709 glLoadIdentity(); // Reset The Modelview Matrix
2712 //Draw world, draw map
2713 glTranslatef(2,-5,0);
2715 if(i<numlevelsonmap-1)
2717 XYZ linestart,lineend,offset;
2724 linestart=campaignlevels[i].getCenter();
2725 lineend=campaignlevels[i+1].getCenter();
2726 offset=lineend-linestart;
2729 offset=DoRotation(offset,0,0,90);
2731 glDisable(GL_TEXTURE_2D);
2733 if(i+1<accountactive->getCampaignChoicesMade()){
2734 glColor4f(0.5,0,0,1);
2742 linestart+=fac*4*startsize;
2743 lineend-=fac*4*endsize;
2745 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2749 glVertex3f(linestart.x-offset.x*startsize, linestart.y-offset.y*startsize, 0.0f);
2751 glVertex3f(linestart.x+offset.x*startsize, linestart.y+offset.y*startsize, 0.0f);
2753 glVertex3f(lineend.x+offset.x*endsize, lineend.y+offset.y*endsize, 0.0f);
2755 glVertex3f(lineend.x-offset.x*endsize, lineend.y-offset.y*endsize, 0.0f);
2758 glEnable(GL_TEXTURE_2D);
2761 glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
2762 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
2763 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
2766 itemsize=campaignlevels[i].getWidth()/2;
2767 midpoint=campaignlevels[i].getCenter();
2768 if(i < accountactive->getCampaignChoicesMade()) {
2769 glColor4f(0.5,0,0,1);
2774 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2778 glVertex3f(midpoint.x-itemsize, midpoint.y-itemsize, 0.0f);
2780 glVertex3f(midpoint.x+itemsize, midpoint.y-itemsize, 0.0f);
2782 glVertex3f(midpoint.x+itemsize, midpoint.y+itemsize, 0.0f);
2784 glVertex3f(midpoint.x-itemsize, midpoint.y+itemsize, 0.0f);
2788 for(int j=0;j<10;j++)
2790 if(1-((float)j)/10-(1-selectedlong[NB_CAMPAIGN_MENU_ITEM+i])>0)
2792 glColor4f(1,0,0,(1-((float)j)/10-(1-selectedlong[NB_CAMPAIGN_MENU_ITEM+i]))*.25);
2793 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2797 glVertex3f(midpoint.x-itemsize-((float)j)*1/2, midpoint.y-itemsize-((float)j)*1/2, 0.0f);
2799 glVertex3f(midpoint.x+itemsize+((float)j)*1/2, midpoint.y-itemsize-((float)j)*1/2, 0.0f);
2801 glVertex3f(midpoint.x+itemsize+((float)j)*1/2, midpoint.y+itemsize+((float)j)*1/2, 0.0f);
2803 glVertex3f(midpoint.x-itemsize-((float)j)*1/2, midpoint.y+itemsize+((float)j)*1/2, 0.0f);
2810 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2812 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2814 if(i>=accountactive->getCampaignChoicesMade()){
2815 text.glPrintOutlined(0.9,0,0,campaignlevels[i].getStartX()+10,
2816 campaignlevels[i].getStartY()-4,
2817 campaignlevels[i].description.c_str(),0,0.6,640,480);
2818 glDisable(GL_DEPTH_TEST);
2822 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2824 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2827 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2828 glPushMatrix(); // Store The Projection Matrix
2829 glLoadIdentity(); // Reset The Projection Matrix
2830 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
2831 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2832 glPushMatrix(); // Store The Modelview Matrix
2833 glLoadIdentity(); // Reset The Modelview Matrix
2834 glTranslatef(screenwidth/2,screenheight/2,0);
2836 glScalef((float)screenwidth/2,(float)screenheight/2,1);
2837 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
2839 glEnable(GL_TEXTURE_2D);
2841 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2842 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2844 if(!waiting) { // hide the cursor while waiting for a key
2846 glTranslatef(mousecoordh-screenwidth/2,mousecoordv*-1+screenheight/2,0);
2847 glScalef((float)screenwidth/64,(float)screenwidth/64,1);
2848 glTranslatef(1,-1,0);
2849 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
2851 glBindTexture( GL_TEXTURE_2D, cursortexture);
2853 //glScalef(.25,.25,.25);
2856 glVertex3f(-1, -1, 0.0f);
2858 glVertex3f(1, -1, 0.0f);
2860 glVertex3f(1, 1, 0.0f);
2862 glVertex3f(-1, 1, 0.0f);
2868 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2874 if(flashamount>1)flashamount=1;
2875 if(flashdelay<=0)flashamount-=multiplier;
2877 if(flashamount<0)flashamount=0;
2878 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
2879 glDisable(GL_CULL_FACE);
2880 glDisable(GL_LIGHTING);
2881 glDisable(GL_TEXTURE_2D);
2883 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2884 glPushMatrix(); // Store The Projection Matrix
2885 glLoadIdentity(); // Reset The Projection Matrix
2886 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
2887 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2888 glPushMatrix(); // Store The Modelview Matrix
2889 glLoadIdentity(); // Reset The Modelview Matrix
2890 glScalef(screenwidth,screenheight,1);
2891 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
2893 glColor4f(flashr,flashg,flashb,flashamount);
2895 glVertex3f(0, 0, 0.0f);
2896 glVertex3f(256, 0, 0.0f);
2897 glVertex3f(256, 256, 0.0f);
2898 glVertex3f(0, 256, 0.0f);
2900 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2901 glPopMatrix(); // Restore The Old Projection Matrix
2902 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2903 glPopMatrix(); // Restore The Old Projection Matrix
2904 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
2905 glEnable(GL_CULL_FACE);
2906 glDisable(GL_BLEND);