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"
30 extern int environment;
31 extern float texscale;
33 extern Terrain terrain;
34 //extern Sprites sprites;
35 extern float multiplier;
37 extern float viewdistance;
38 extern float fadestart;
39 extern float screenwidth,screenheight;
40 extern int kTextureSize;
41 extern FRUSTUM frustum;
43 extern Objects objects;
45 extern float usermousesensitivity;
47 extern float camerashake;
49 extern float slomodelay;
50 extern bool ismotionblur;
52 extern float blackout;
53 extern bool damageeffects;
55 extern bool texttoggle;
56 extern float blurness;
57 extern float targetblurness;
58 extern float playerdist;
59 extern bool cellophane;
61 extern float flashamount,flashr,flashg,flashb;
62 extern int flashdelay;
64 extern float motionbluramount;
66 extern bool alwaysblur;
68 extern bool tilt2weird;
69 extern bool tiltweird;
71 extern bool proportionweird;
72 extern bool vertexweird[6];
73 extern bool velocityblur;
74 extern bool debugmode;
76 extern int oldmainmenu;
77 extern int bloodtoggle;
78 extern int difficulty;
81 //extern int texdetail;
82 extern float texdetail;
83 extern bool musictoggle;
84 extern int tutoriallevel;
85 extern float smoketex;
86 extern float tutorialstagetime;
87 extern float tutorialmaxtime;
88 extern int tutorialstage;
89 extern bool againbonus;
90 extern float damagedealt;
91 extern bool invertmouse;
93 extern int numhotspots;
94 extern int winhotspot;
95 extern int killhotspot;
96 extern XYZ hotspot[40];
97 extern int hotspottype[40];
98 extern float hotspotsize[40];
99 extern char hotspottext[40][256];
100 extern int currenthotspot;;
102 extern bool campaign;
103 extern bool winfreeze;
105 extern float menupulse;
107 extern bool gamestart;
109 extern bool gamestarted;
111 extern bool showdamagebar;
114 normalmode, motionblurmode, radialzoommode,
115 realmotionblurmode, doublevisionmode, glowmode,
118 void Game::flash() { // shouldn't be that way, these should be attributes and Person class should not change rendering.
125 /*********************> DrawGLScene() <*****/
126 int Game::DrawGLScene(StereoSide side)
128 static float texcoordwidth,texcoordheight;
129 static float texviewwidth, texviewheight;
131 static GLubyte color;
132 static float newbrightness;
133 static float changespeed;
134 static XYZ checkpoint;
135 static float tempmult;
137 static char string[256]="";
138 static char string2[256]="";
139 static char string3[256]="";
141 static float lastcheck;
143 lastcheck+=multiplier;
145 if ( stereomode == stereoAnaglyph ) {
147 case stereoLeft: glColorMask( 0.0, 1.0, 1.0, 1.0 ); break;
148 case stereoRight: glColorMask( 1.0, 0.0, 0.0, 1.0 ); break;
151 glColorMask( 1.0, 1.0, 1.0, 1.0 );
153 if ( stereomode == stereoHorizontalInterlaced || stereomode == stereoVerticalInterlaced ) {
154 glStencilFunc(side == stereoLeft ? GL_NOTEQUAL : GL_EQUAL, 0x01, 0x01);
158 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)){
165 numboundaries=mapradius*2;
166 if(numboundaries>360)numboundaries=360;
167 for(i=0;i<numboundaries;i++){
170 boundary[i]=mapcenter+DoRotation(boundary[i]*mapradius,0,i*(360/((float)(numboundaries))),0);
179 olddrawmode=drawmode;
180 if(ismotionblur&&!loading){
181 if((findLengthfast(&player[0].velocity)>200)&&velocityblur&&!cameramode){
182 drawmode=motionblurmode;
183 motionbluramount=200/(findLengthfast(&player[0].velocity));
186 if(player[0].damage-player[0].superpermanentdamage>(player[0].damagetolerance-player[0].superpermanentdamage)*1/2&&damageeffects&&!cameramode){
187 drawmode=doublevisionmode;
194 drawmode=motionblurmode;
196 slomodelay-=multiplier;
197 if(slomodelay<0)slomo=0;
201 if((!changed&&!slomo)||loading){
203 if(ismotionblur&&(/*fps>100||*/alwaysblur)){
204 if(olddrawmode!=realmotionblurmode)change=1;
206 drawmode=realmotionblurmode;
208 else if(olddrawmode==realmotionblurmode)change=2;
212 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted))drawmode=normalmode;
213 if((freeze||winfreeze)&&ismotionblur&&!mainmenu)drawmode=radialzoommode;
215 if(winfreeze||mainmenu)drawmode=normalmode;
218 if(drawmode==glowmode){
223 DSpContext_FadeGamma(NULL,200,&color2);
227 if(drawtoggle!=2)drawtoggle=1-drawtoggle;
231 texviewwidth=kTextureSize;
232 if(texviewwidth>screenwidth)texviewwidth=screenwidth;
233 texviewheight=kTextureSize;
234 if(texviewheight>screenheight)texviewheight=screenheight;
236 texcoordwidth=screenwidth/kTextureSize;
237 texcoordheight=screenheight/kTextureSize;
238 if(texcoordwidth>1)texcoordwidth=1;
239 if(texcoordheight>1)texcoordheight=1;
242 glDrawBuffer(GL_BACK);
243 glReadBuffer(GL_BACK);
245 if(abs(blurness-targetblurness)<multiplier*10||abs(blurness-targetblurness)>2){
246 blurness=targetblurness;
247 targetblurness=(float)(abs(Random()%100))/40;
249 if(blurness<targetblurness)
250 blurness+=multiplier*5;
252 blurness-=multiplier*5;
255 static XYZ terrainlight;
256 static float distance;
257 if(drawmode==normalmode)ReSizeGLScene(90,.1f);
258 if(drawmode!=normalmode)glViewport(0,0,texviewwidth,texviewheight);
259 glDepthFunc(GL_LEQUAL);
261 glAlphaFunc(GL_GREATER, 0.0001f);
262 glEnable(GL_ALPHA_TEST);
263 glClearColor(0.25f, 0.25f, 0.25f, 1.0f);
264 glClear(GL_DEPTH_BUFFER_BIT);
266 glMatrixMode (GL_MODELVIEW);
267 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
270 // Move the camera for the current eye's point of view.
271 // Reverse the movement if we're reversing stereo
272 glTranslatef((stereoseparation/2) * side * (stereoreverse ? -1 : 1), 0, 0);
274 if(!cameramode&&!freeze&&!winfreeze){
275 glRotatef(float(Random()%100)/10*camerashake/*+(woozy*woozy)/10*/,0,0,1);
276 glRotatef(rotation2+sin(woozy/2)*(player[0].damage/player[0].damagetolerance)*5,1,0,0);
277 glRotatef(rotation+sin(woozy)*(player[0].damage/player[0].damagetolerance)*5,0,1,0);
279 if(cameramode||freeze||winfreeze){
280 glRotatef(rotation2,1,0,0);
281 glRotatef(rotation,0,1,0);
284 if(environment==desertenvironment){
285 glRotatef((float)(abs(Random()%100))/3000-1,1,0,0);
286 glRotatef((float)(abs(Random()%100))/3000-1,0,1,0);
288 SetUpLight(&light,0);
290 if(environment==desertenvironment&&detail==2)glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, blurness+.4 );
291 if(environment==desertenvironment){
292 glRotatef((float)(abs(Random()%100))/1000,1,0,0);
293 glRotatef((float)(abs(Random()%100))/1000,0,1,0);
296 glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0);
298 glTranslatef(-viewer.x,-viewer.y,-viewer.z);
299 frustum.GetFrustum();
303 static float size,opacity,rotation;
305 for(k=0;k<numplayers;k++){
306 if(!player[k].skeleton.free&&player[k].playerdetail&&player[k].howactive<typesleeping)
307 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)
308 for(i=0;i<player[k].skeleton.num_joints;i++){
309 if(player[k].skeleton.joints[i].label==leftknee||player[k].skeleton.joints[i].label==rightknee||player[k].skeleton.joints[i].label==groin){
310 point=DoRotation(player[k].skeleton.joints[i].position,0,player[k].rotation,0)*player[k].scale+player[k].coords;
312 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;
313 if(k!=0&&tutoriallevel==1){
314 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;
316 terrain.MakeDecal(shadowdecal,point,size,opacity,rotation);
317 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
318 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
319 if(objects.position[j].y<player[k].coords.y||objects.type[j]==tunneltype||objects.type[j]==weirdtype){
320 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);
323 if(k!=0&&tutoriallevel==1){
324 opacity=.2+.2*sin(smoketex*6+i);
326 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
331 if((player[k].skeleton.free||player[k].howactive>=typesleeping)&&player[k].playerdetail)
332 if(frustum.SphereInFrustum(player[k].coords.x,player[k].coords.y,player[k].coords.z,player[k].scale*5)&&player[k].occluded<25)
333 for(i=0;i<player[k].skeleton.num_joints;i++){
334 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){
335 if(player[k].skeleton.free)point=player[k].skeleton.joints[i].position*player[k].scale+player[k].coords;
336 else point=DoRotation(player[k].skeleton.joints[i].position,0,player[k].rotation,0)*player[k].scale+player[k].coords;
338 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;
339 if(k!=0&&tutoriallevel==1){
340 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;
342 terrain.MakeDecal(shadowdecal,point,size,opacity*.7,rotation);
343 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
344 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
345 if(objects.position[j].y<player[k].coords.y||objects.type[j]==tunneltype||objects.type[j]==weirdtype){
346 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);
347 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);
350 if(k!=0&&tutoriallevel==1){
351 opacity=.2+.2*sin(smoketex*6+i);
353 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
359 if(!player[k].playerdetail)
360 if(frustum.SphereInFrustum(player[k].coords.x,player[k].coords.y,player[k].coords.z,player[k].scale*5))
362 point=player[k].coords;
364 opacity=.4-(player[k].coords.y-terrain.getHeight(player[k].coords.x,player[k].coords.z))/5;
365 terrain.MakeDecal(shadowdecal,point,size,opacity*.7,rotation);
366 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
367 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
368 point=DoRotation(player[k].coords-objects.position[j],0,-objects.rotation[j],0);
371 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
377 glEnable(GL_TEXTURE_2D);
379 glEnable(GL_DEPTH_TEST);
380 glEnable(GL_CULL_FACE);
382 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
383 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
384 glBindTexture( GL_TEXTURE_2D, terraintexture);
386 glBindTexture( GL_TEXTURE_2D, terraintexture2);
388 //glBindTexture( GL_TEXTURE_2D, terraintexture3);
389 //glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
392 terrain.drawdecals();
395 glEnable(GL_CULL_FACE);
396 glEnable(GL_LIGHTING);
398 glEnable(GL_TEXTURE_2D);
401 glEnable(GL_COLOR_MATERIAL);
416 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
417 glEnable(GL_CULL_FACE);
418 glCullFace(GL_FRONT);
420 for(k=0;k<numplayers;k++){
421 if(k==0||tutoriallevel!=1){
423 glEnable(GL_LIGHTING);
424 terrainlight=terrain.getLighting(player[k].coords.x,player[k].coords.z);
425 distance=findDistancefast(&viewer,&player[k].coords);
426 distance=(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance;
427 glColor4f(terrainlight.x,terrainlight.y,terrainlight.z,distance);
428 if(distance>=1)glDisable(GL_BLEND);
430 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;
432 if(!player[k].occluded==0)i=checkcollide(viewer,checkpoint,player[k].lastoccluded);
433 if(i==-1||player[k].occluded==0)i=checkcollide(viewer,checkpoint);
435 player[k].occluded+=1;
436 player[k].lastoccluded=i;
438 else player[k].occluded=0;
439 if(player[k].occluded<25)player[k].DrawSkeleton();
445 if(!cameramode&&musictype==stream_fighttheme)playerdist=findDistancefastflat(&player[0].coords,&viewer);
446 else playerdist=-100;
449 glEnable(GL_TEXTURE_2D);
454 if(frustum.SphereInFrustum(realhawkcoords.x+hawk.boundingspherecenter.x,realhawkcoords.y+hawk.boundingspherecenter.y,realhawkcoords.z+hawk.boundingspherecenter.z,2)){
455 glAlphaFunc(GL_GREATER, 0.0001f);
457 glDisable(GL_CULL_FACE);
458 glDisable(GL_LIGHTING);
460 glTranslatef(hawkcoords.x,hawkcoords.y,hawkcoords.z);
461 glRotatef(hawkrotation,0,1,0);
462 glTranslatef(25,0,0);
463 distance=findDistancefast(&viewer,&realhawkcoords)*1.2;
464 glColor4f(light.color[0],light.color[1],light.color[2],(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance);
465 if((viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance>1)glColor4f(light.color[0],light.color[1],light.color[2],1);
466 if((viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance>0)
467 hawk.drawdifftex(hawktexture);
471 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
472 glEnable(GL_CULL_FACE);
473 glCullFace(GL_FRONT);
475 for(k=0;k<numplayers;k++){
476 if(!(k==0||tutoriallevel!=1)){
478 glEnable(GL_LIGHTING);
479 terrainlight=terrain.getLighting(player[k].coords.x,player[k].coords.z);
480 distance=findDistancefast(&viewer,&player[k].coords);
481 distance=(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance;
482 glColor4f(terrainlight.x,terrainlight.y,terrainlight.z,distance);
483 if(distance>=1)glDisable(GL_BLEND);
485 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;
487 if(!player[k].occluded==0)i=checkcollide(viewer,checkpoint,player[k].lastoccluded);
488 if(i==-1||player[k].occluded==0)i=checkcollide(viewer,checkpoint);
490 player[k].occluded+=1;
491 player[k].lastoccluded=i;
493 else player[k].occluded=0;
494 if(player[k].occluded<25)player[k].DrawSkeleton();
500 glEnable(GL_TEXTURE_2D);
505 glDisable(GL_COLOR_MATERIAL);
507 glDisable(GL_LIGHTING);
508 glDisable(GL_TEXTURE_2D);
516 glDisable(GL_LIGHTING);
517 glDisable(GL_TEXTURE_2D);
518 glDisable(GL_COLOR_MATERIAL);
521 for(k=0;k<numplayers;k++){
522 if(player[k].numwaypoints>1){
523 glBegin(GL_LINE_LOOP);
524 for(i=0;i<player[k].numwaypoints;i++){
525 glVertex3f(player[k].waypoints[i].x,player[k].waypoints[i].y+.5,player[k].waypoints[i].z);
534 for(k=0;k<numpathpoints;k++){
535 if(numpathpointconnect[k]){
536 for(i=0;i<numpathpointconnect[k];i++){
537 glBegin(GL_LINE_LOOP);
538 glVertex3f(pathpoint[k].x,pathpoint[k].y+.5,pathpoint[k].z);
539 glVertex3f(pathpoint[pathpointconnect[k][i]].x,pathpoint[pathpointconnect[k][i]].y+.5,pathpoint[pathpointconnect[k][i]].z);
547 glVertex3f(pathpoint[pathpointselected].x,pathpoint[pathpointselected].y+.5,pathpoint[pathpointselected].z);
554 glEnable(GL_TEXTURE_2D);
555 glColor4f(.5,.5,.5,1);
557 sprintf (string, " ",(int)(fps));
558 text.glPrint(10,30,string,0,.8,screenwidth,screenheight);
561 if(bonus>0&&bonustime<1&&!winfreeze&&indialogue==-1/*bonustime<4*/){
562 const char *bonus_name;
563 if (bonus < bonus_count)
564 bonus_name = bonus_names[bonus];
566 bonus_name = "Excellent!"; // When does this happen?
568 glColor4f(0,0,0,1-bonustime);
569 text.glPrintOutline(1024/2-10*strlen(bonus_name)-4,768/16-4+768*4/5,bonus_name,1,2.5,1024,768);
570 glColor4f(1,0,0,1-bonustime);
571 text.glPrint(1024/2-10*strlen(bonus_name),768/16+768*4/5,bonus_name,1,2,1024,768);
573 sprintf (string, "%d",(int)bonusvalue);
574 glColor4f(0,0,0,1-bonustime);
575 text.glPrintOutline(1024/2-10*strlen(string)-4,768/16-4-20+768*4/5,string,1,2.5*.8,1024,768);
576 glColor4f(1,0,0,1-bonustime);
577 text.glPrint(1024/2-10*strlen(string),768/16-20+768*4/5,string,1,2*.8,1024,768);
578 glColor4f(.5,.5,.5,1);
581 if(tutoriallevel==1){
582 tutorialopac=tutorialmaxtime-tutorialstagetime;
583 if(tutorialopac>1)tutorialopac=1;
584 if(tutorialopac<0)tutorialopac=0;
586 sprintf (string, " ");
587 sprintf (string2, " ");
588 sprintf (string3, " ");
589 if(tutorialstage==0){
590 sprintf (string, " ");
591 sprintf (string2, " ");
592 sprintf (string3, " ");
594 if(tutorialstage==1){
595 sprintf (string, "Welcome to the Lugaru training level!");
596 sprintf (string2, " ");
597 sprintf (string3, " ");
599 if(tutorialstage==2){
600 sprintf (string, "BASIC MOVEMENT:");
601 sprintf (string2, " ");
602 sprintf (string3, " ");
604 if(tutorialstage==3){
605 sprintf (string, "You can move the mouse to rotate the camera.");
606 sprintf (string2, " ");
607 sprintf (string3, " ");
609 if(tutorialstage==4){
610 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));
611 sprintf (string2, "All movement is relative to the camera.");
612 sprintf (string3, " ");
614 if(tutorialstage==5){
615 sprintf (string, "Please press %s to jump.",Input::keyToChar(jumpkey));
616 sprintf (string2, "You can hold it longer to jump higher.");
617 sprintf (string3, " ");
619 if(tutorialstage==6){
620 sprintf (string, "You can press %s to crouch.",Input::keyToChar(crouchkey));
621 sprintf (string2, "You can jump higher from a crouching position.");
622 sprintf (string3, " ");
624 if(tutorialstage==7){
625 sprintf (string, "While running, you can press %s to roll.",Input::keyToChar(crouchkey));
626 sprintf (string2, " ");
627 sprintf (string3, " ");
629 if(tutorialstage==8){
630 sprintf (string, "While crouching, you can sneak around silently");
631 sprintf (string2, "using the movement keys.");
632 sprintf (string3, " ");
634 if(tutorialstage==9){
635 sprintf (string, "Release the crouch key while sneaking and hold the movement keys");
636 sprintf (string2, "to run animal-style.");
637 sprintf (string3, " ");
639 if(tutorialstage==10){
640 sprintf (string, "ADVANCED MOVEMENT:");
641 sprintf (string2, " ");
642 sprintf (string3, " ");
644 if(tutorialstage==11){
645 sprintf (string, "When you jump at a wall, you can hold %s again",Input::keyToChar(jumpkey));
646 sprintf (string2, "during impact to perform a walljump.");
647 sprintf (string3, "Be sure to use the movement keys to press against the wall");
649 if(tutorialstage==12){
650 sprintf (string, "While in the air, you can press crouch to flip.",Input::keyToChar(jumpkey));
651 sprintf (string2, "Walljumps and flips confuse enemies and give you more control.");
652 sprintf (string3, " ");
654 if(tutorialstage==13){
655 sprintf (string, "BASIC COMBAT:");
656 sprintf (string2, " ");
657 sprintf (string3, " ");
659 if(tutorialstage==14){
660 sprintf (string, "There is now an imaginary enemy");
661 sprintf (string2, "in the middle of the training area.");
662 sprintf (string3, " ");
664 if(tutorialstage==15){
665 if(attackkey==MOUSEBUTTON1)sprintf (string, "Click to attack when you are near an enemy.");
666 else sprintf (string, "Press %s to attack when you are near an enemy.",Input::keyToChar(attackkey));
667 sprintf (string2, "You can punch by standing still near an enemy and attacking.");
668 sprintf (string3, " ");
670 if(tutorialstage==16){
671 sprintf (string, "If you are close, you will perform a weak punch.");
672 sprintf (string2, "The weak punch is excellent for starting attack combinations.");
673 sprintf (string3, " ");
675 if(tutorialstage==17){
676 sprintf (string, "Attacking while running results in a spin kick.");
677 sprintf (string2, "This is one of your most powerful ground attacks.");
678 sprintf (string3, " ");
680 if(tutorialstage==18){
681 sprintf (string, "Sweep the enemy's legs out by attacking while crouched.");
682 sprintf (string2, "This is a very fast attack, and easy to follow up.");
683 sprintf (string3, " ");
685 if(tutorialstage==19){
686 sprintf (string, "When an enemy is on the ground, you can deal some extra");
687 sprintf (string2, "damage by running up and drop-kicking him.");
688 sprintf (string3, "(Try knocking them down with a sweep first)");
690 if(tutorialstage==20){
691 sprintf (string, "Your most powerful individual attack is the rabbit kick.");
692 if(attackkey==MOUSEBUTTON1)sprintf (string2, "Run at the enemy while holding the mouse button, and press");
693 else sprintf (string2, "Run at the enemy while holding %s, and press", Input::keyToChar(attackkey));
694 sprintf (string3, "the jump key (%s) to attack.",Input::keyToChar(jumpkey));
696 if(tutorialstage==21){
697 sprintf (string, "This attack is devastating if timed correctly.");
698 sprintf (string2, "Even if timed incorrectly, it will knock the enemy over.");
699 if(againbonus)sprintf (string3, "Try rabbit-kicking the imaginary enemy again.");
700 else sprintf (string3, "Try rabbit-kicking the imaginary enemy.");
702 if(tutorialstage==22){
703 sprintf (string, "If you sneak behind an enemy unnoticed, you can kill");
704 sprintf (string2, "him instantly. Move close behind this enemy");
705 sprintf (string3, "and attack.");
707 if(tutorialstage==23){
708 sprintf (string, "Another important attack is the wall kick. When an enemy");
709 sprintf (string2, "is near a wall, perform a walljump nearby and hold");
710 sprintf (string3, "the attack key during impact with the wall.");
712 if(tutorialstage==24){
713 sprintf (string, "You can tackle enemies by running at them animal-style");
714 if(attackkey==MOUSEBUTTON1)sprintf (string2, "and pressing jump (%s) or attack(mouse button).",Input::keyToChar(jumpkey));
715 else sprintf (string2, "and pressing jump (%s) or attack(%s).",Input::keyToChar(jumpkey),Input::keyToChar(attackkey));
716 sprintf (string3, "This is especially useful when they are running away.");
718 if(tutorialstage==25){
719 sprintf (string, "Dodge by pressing back and attack. Dodging is essential");
720 sprintf (string2, "against enemies with swords or other long weapons.");
721 sprintf (string3, " ");
723 if(tutorialstage==26){
724 sprintf (string, "REVERSALS AND COUNTER-REVERSALS");
725 sprintf (string2, " ");
726 sprintf (string3, " ");
728 if(tutorialstage==27){
729 sprintf (string, "The enemy can now reverse your attacks.");
730 sprintf (string2, " ");
731 sprintf (string3, " ");
733 if(tutorialstage==28){
734 sprintf (string, "If you attack, you will notice that the enemy now sometimes");
735 sprintf (string2, "catches your attack and uses it against you. Hold");
736 sprintf (string3, "crouch (%s) after attacking to escape from reversals.",Input::keyToChar(crouchkey));
738 if(tutorialstage==29){
739 sprintf (string, "Try escaping from two more reversals in a row.");
740 sprintf (string2, " ");
741 sprintf (string3, " ");
743 if(tutorialstage==30){
744 sprintf (string, "Good!");
745 sprintf (string2, " ");
746 sprintf (string3, " ");
748 if(tutorialstage==31){
749 sprintf (string, "To reverse an attack, you must tap crouch (%s) during the",Input::keyToChar(crouchkey));
750 sprintf (string2, "enemy's attack. You must also be close to the enemy;");
751 sprintf (string3, "this is especially important against armed opponents.");
753 if(tutorialstage==32){
754 sprintf (string, "The enemy can attack in %d seconds.", (int)(tutorialmaxtime-tutorialstagetime));
755 sprintf (string2, "This imaginary opponents attacks will be highlighted");
756 sprintf (string3, "to make this easier.");
758 if(tutorialstage==33){
759 sprintf (string, "Reverse three enemy attacks!");
760 sprintf (string2, " ");
761 sprintf (string3, " ");
763 if(tutorialstage==34){
764 sprintf (string, "Reverse two more enemy attacks!");
765 sprintf (string2, " ");
766 sprintf (string3, " ");
768 if(tutorialstage==35){
769 sprintf (string, "Reverse one more enemy attack!");
770 sprintf (string2, " ");
771 sprintf (string3, " ");
773 if(tutorialstage==36){
774 sprintf (string, "Excellent!");
775 sprintf (string2, " ");
776 sprintf (string3, " ");
778 if(tutorialstage==37){
779 sprintf (string, "Now spar with the enemy for %d more seconds.", (int)(tutorialmaxtime-tutorialstagetime));
780 sprintf (string2, "Damage dealt: %d",(int)damagedealt);
781 sprintf (string3, "Damage taken: %d.",(int)damagetaken);
783 if(tutorialstage==38){
784 sprintf (string, "WEAPONS:");
785 sprintf (string2, " ");
786 sprintf (string3, " ");
788 if(tutorialstage==39){
789 sprintf (string, "There is now an imaginary knife");
790 sprintf (string2, "in the center of the training area.");
791 sprintf (string3, " ");
793 if(tutorialstage==40){
794 sprintf (string, "Stand, roll or handspring over the knife");
795 sprintf (string2, "while pressing %s to pick it up.",Input::keyToChar(throwkey));
796 sprintf (string3, "You can crouch and press the same key to drop it again.");
798 if(tutorialstage==41){
799 sprintf (string, "You can equip and unequip weapons using the %s key.",Input::keyToChar(drawkey));
800 sprintf (string2, "Sometimes it is best to keep them unequipped to");
801 sprintf (string3, "prevent enemies from taking them. ");
803 if(tutorialstage==42){
804 sprintf (string, "The knife is the smallest weapon and the least encumbering.");
805 sprintf (string2, "You can equip or unequip it while standing, crouching,");
806 sprintf (string3, "running or flipping.");
808 if(tutorialstage==43){
809 sprintf (string, "You perform weapon attacks the same way as unarmed attacks,");
810 sprintf (string2, "but sharp weapons cause permanent damage, instead of the");
811 sprintf (string3, "temporary trauma from blunt weapons, fists and feet.");
813 if(tutorialstage==44){
814 sprintf (string, "The enemy now has your knife!");
815 sprintf (string2, "Please reverse two of his knife attacks.");
816 sprintf (string3, " ");
818 if(tutorialstage==45){
819 sprintf (string, "Please reverse one more of his knife attacks.");
820 sprintf (string2, " ");
821 sprintf (string3, " ");
823 if(tutorialstage==46){
824 sprintf (string, "Now he has a sword!");
825 sprintf (string2, "The sword has longer reach than your arms, so you");
826 sprintf (string3, "must move close to reverse the sword slash.");
828 if(tutorialstage==47){
829 sprintf (string, "Long weapons like the sword and staff are also useful for defense;");
830 sprintf (string2, "you can parry enemy weapon attacks by pressing the attack key");
831 sprintf (string3, "at the right time. Please try parrying the enemy's attacks!");
833 if(tutorialstage==48){
834 sprintf (string, "The staff is like the sword, but has two main attacks.");
835 sprintf (string2, "The standing smash is fast and effective, and the running");
836 sprintf (string3, "spin smash is slower and more powerful.");
838 if(tutorialstage==49){
839 sprintf (string, "When facing an enemy, you can throw the knife with %s.",Input::keyToChar(throwkey));
840 sprintf (string2, "It is possible to throw the knife while flipping,");
841 sprintf (string3, "but it is very inaccurate.");
843 if(tutorialstage==50){
844 sprintf (string, "You now know everything you can learn from training.");
845 sprintf (string2, "Everything else you must learn from experience!");
846 sprintf (string3, " ");
848 if(tutorialstage==51){
849 sprintf (string, "Walk out of the training area to return to the main menu.");
850 sprintf (string2, " ");
851 sprintf (string3, " ");
854 glColor4f(0,0,0,tutorialopac);
855 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);
856 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);
857 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);
858 glColor4f(1,1,1,tutorialopac);
859 text.glPrint(screenwidth/2-7.6*strlen(string)*screenwidth/1024,screenheight/16+screenheight*4/5,string,1,1.5*screenwidth/1024,screenwidth,screenheight);
860 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);
861 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);
863 sprintf (string, "Press 'tab' to skip to the next item.",Input::keyToChar(jumpkey));
864 sprintf (string2, "Press escape at any time to");
865 sprintf (string3, "pause or exit the tutorial.");
868 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);
869 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);
870 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);
871 glColor4f(0.5,0.5,0.5,1);
872 text.glPrint(screenwidth/2-7.6*strlen(string)*screenwidth/1024*.8,0+screenheight*1/10,string,1,1.5*screenwidth/1024*.8,screenwidth,screenheight);
873 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);
874 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);
878 if(numhotspots&&(bonustime>=1||bonus<=0||bonustime<0)&&!tutoriallevel){
880 float closestdist=-1;
882 closest=currenthotspot;
883 for(i=0;i<numhotspots;i++){
884 distance=findDistancefast(&player[0].coords,&hotspot[i]);
885 if(closestdist==-1||distance<closestdist){
886 if(findDistancefast(&player[0].coords,&hotspot[i])<hotspotsize[i]&&((hotspottype[i]<=10&&hotspottype[i]>=0)||(hotspottype[i]<=40&&hotspottype[i]>=20))){
887 closestdist=distance;
893 currenthotspot=closest;
894 if(currenthotspot!=-1){
895 if(hotspottype[closest]<=10){
896 if(findDistancefast(&player[0].coords,&hotspot[closest])<hotspotsize[closest])
899 tutorialopac=tutorialmaxtime-tutorialstagetime;
900 if(tutorialopac>1)tutorialopac=1;
901 if(tutorialopac<0)tutorialopac=0;
903 sprintf (string, "%s", hotspottext[closest]);
910 if(string[i]=='\n'||string[i]>'z'||string[i]<' '||string[i]=='\0'){
911 glColor4f(0,0,0,tutorialopac);
912 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);
913 glColor4f(1,1,1,tutorialopac);
914 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);
917 if(string[i]=='\0')done=1;
923 else if (hotspottype[closest]>=20&&dialoguegonethrough[hotspottype[closest]-20]==0){
924 whichdialogue=hotspottype[closest]-20;
925 for(j=0;j<numdialogueboxes[whichdialogue];j++){
926 player[participantfocus[whichdialogue][j]].coords=participantlocation[whichdialogue][participantfocus[whichdialogue][j]];
927 player[participantfocus[whichdialogue][j]].rotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
928 player[participantfocus[whichdialogue][j]].targetrotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
929 player[participantfocus[whichdialogue][j]].velocity=0;
930 player[participantfocus[whichdialogue][j]].targetanimation=player[participantfocus[whichdialogue][j]].getIdle();
931 player[participantfocus[whichdialogue][j]].targetframe=0;
935 dialoguegonethrough[whichdialogue]++;
936 if(dialogueboxsound[whichdialogue][indialogue]!=0){
938 if(dialogueboxsound[whichdialogue][indialogue]==1)whichsoundplay=rabbitchitter;
939 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
940 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
941 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
942 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
943 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
944 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
945 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
946 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
947 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
948 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
949 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
950 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
951 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
952 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
953 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
954 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
955 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
956 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
957 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
958 emit_sound_at(whichsoundplay, player[participantfocus[whichdialogue][indialogue]].coords);
964 if(indialogue!=-1&&!mainmenu){
965 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
966 glDisable(GL_CULL_FACE);
967 glDisable(GL_LIGHTING);
968 glDisable(GL_TEXTURE_2D);
970 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
971 glPushMatrix(); // Store The Projection Matrix
972 glLoadIdentity(); // Reset The Projection Matrix
973 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
974 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
975 glPushMatrix(); // Store The Modelview Matrix
976 glLoadIdentity(); // Reset The Modelview Matrix
977 if(dialogueboxlocation[whichdialogue][indialogue]==1)glTranslatef(0,screenheight*3/4,0);
978 glScalef(screenwidth,screenheight/4,1);
979 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
982 glColor4f(dialogueboxcolor[whichdialogue][indialogue][0],dialogueboxcolor[whichdialogue][indialogue][1],dialogueboxcolor[whichdialogue][indialogue][2],0.7);
984 glVertex3f(0, 0, 0.0f);
985 glVertex3f(1, 0, 0.0f);
986 glVertex3f(1, 1, 0.0f);
987 glVertex3f(0, 1, 0.0f);
989 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
990 glPopMatrix(); // Restore The Old Projection Matrix
991 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
992 glPopMatrix(); // Restore The Old Projection Matrix
993 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
994 glEnable(GL_CULL_FACE);
997 glEnable(GL_TEXTURE_2D);
1004 startx=screenwidth*1/5;
1005 if(dialogueboxlocation[whichdialogue][indialogue]==1)starty=screenheight/16+screenheight*4/5;
1006 if(dialogueboxlocation[whichdialogue][indialogue]==2)starty=screenheight*1/5-screenheight/16;
1015 for(i=0;i<(int)strlen(dialoguename[whichdialogue][indialogue]);i++){
1016 tempname[tempnum]=dialoguename[whichdialogue][indialogue][i];
1018 if(dialoguename[whichdialogue][indialogue][i]=='#'||dialoguename[whichdialogue][indialogue][i]=='\0')goodchar=0;
1022 tempname[tempnum]='\0';
1025 sprintf (string, "%s: ", tempname);
1027 if(dialogueboxcolor[whichdialogue][indialogue][0]+dialogueboxcolor[whichdialogue][indialogue][1]+dialogueboxcolor[whichdialogue][indialogue][2]<1.5){
1028 glColor4f(0,0,0,tutorialopac);
1029 text.glPrintOutline(startx-2*7.6*strlen(string)*screenwidth/1024-4,starty-4,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight);
1030 glColor4f(0.7,0.7,0.7,tutorialopac);
1031 text.glPrint(startx-2*7.6*strlen(string)*screenwidth/1024,starty,string,1,1.5*screenwidth/1024,screenwidth,screenheight);
1035 glColor4f(0,0,0,tutorialopac);
1036 text.glPrintOutline(startx-2*7.6*strlen(string)*screenwidth/1024-4,starty-4,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight);
1040 for(i=0;i<(int)strlen(dialoguetext[whichdialogue][indialogue])+1;i++){
1041 tempname[tempnum]=dialoguetext[whichdialogue][indialogue][i];
1042 if(dialoguetext[whichdialogue][indialogue][i]!='#')tempnum++;
1045 sprintf (string, "%s", tempname);
1052 if(string[i]=='\n'||string[i]>'z'||string[i]<' '||string[i]=='\0'){
1053 if(dialogueboxcolor[whichdialogue][indialogue][0]+dialogueboxcolor[whichdialogue][indialogue][1]+dialogueboxcolor[whichdialogue][indialogue][2]<1.5){
1054 glColor4f(0,0,0,tutorialopac);
1055 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);
1056 glColor4f(1,1,1,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 glColor4f(0,0,0,tutorialopac);
1062 text.glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/,starty-20*screenwidth/1024*line,string,1,1.5*screenwidth/1024,screenwidth,screenheight,lastline,i);
1066 if(string[i]=='\0')done=1;
1073 if(!tutoriallevel&&!winfreeze&&indialogue==-1&&!mainmenu){
1076 sprintf (string, "Score: %d", (int)accountactive->getCampaignScore());
1078 sprintf (string, "Score: %d", (int)accountactive->getCampaignScore()+(int)bonustotal);
1080 if(!campaign)sprintf (string, "Score: %d", (int)bonustotal);
1082 text.glPrintOutline(1024/40-4,768/16-4+768*14/16,string,1,1.5*1.25,1024,768);
1084 text.glPrint(1024/40,768/16+768*14/16,string,1,1.5,1024,768);
1086 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1087 glDisable(GL_CULL_FACE);
1088 glDisable(GL_LIGHTING);
1089 glDisable(GL_TEXTURE_2D);
1091 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1092 glPushMatrix(); // Store The Projection Matrix
1093 glLoadIdentity(); // Reset The Projection Matrix
1094 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1095 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1096 glPushMatrix(); // Store The Modelview Matrix
1097 glLoadIdentity(); // Reset The Modelview Matrix
1098 glTranslatef(15,screenheight*17.5/20,0);
1099 glScalef(screenwidth/3+20,screenheight/20,1);
1100 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1102 glColor4f(0.0,0.4,0.0,0.7);
1103 float bar=((float)player[0].damage)/player[0].damagetolerance;
1105 glVertex3f((bar<1?bar:1),0,0.0f);
1106 glVertex3f(1,0,0.0f);
1107 glVertex3f(1,1,0.0f);
1108 glVertex3f((bar<1?bar:1),1,0.0f);
1110 glColor4f(0.1,0.0,0.0,1);
1111 bar = ((float)player[0].bloodloss)/player[0].damagetolerance;
1113 glVertex3f(0,0,0.0f);
1114 glVertex3f((bar<1?bar:1),0,0.0f);
1115 glVertex3f((bar<1?bar:1),1,0.0f);
1116 glVertex3f(0,1,0.0f);
1118 glColor4f(0.4,0.0,0.0,0.7);
1119 bar = ((float)player[0].damage)/player[0].damagetolerance;
1121 glVertex3f(0,0,0.0f);
1122 glVertex3f((bar<1?bar:1),0,0.0f);
1123 glVertex3f((bar<1?bar:1),1,0.0f);
1124 glVertex3f(0,1,0.0f);
1126 glColor4f(0.4,0.0,0.0,0.7);
1127 bar = ((float)player[0].permanentdamage)/player[0].damagetolerance;
1129 glVertex3f(0,0,0.0f);
1130 glVertex3f((bar<1?bar:1),0,0.0f);
1131 glVertex3f((bar<1?bar:1),1,0.0f);
1132 glVertex3f(0,1,0.0f);
1134 glColor4f(0.4,0.0,0.0,0.7);
1135 bar = ((float)player[0].superpermanentdamage)/player[0].damagetolerance;
1137 glVertex3f(0,0,0.0f);
1138 glVertex3f((bar<1?bar:1),0,0.0f);
1139 glVertex3f((bar<1?bar:1),1,0.0f);
1140 glVertex3f(0,1,0.0f);
1142 glColor4f(0.0,0.0,0.0,0.7);
1144 glBegin(GL_LINE_STRIP);
1145 glVertex3f(0,0,0.0f);
1146 glVertex3f(1,0,0.0f);
1147 glVertex3f(1,1,0.0f);
1148 glVertex3f(0,1,0.0f);
1149 glVertex3f(0,0,0.0f);
1152 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1153 glPopMatrix(); // Restore The Old Projection Matrix
1154 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1155 glPopMatrix(); // Restore The Old Projection Matrix
1156 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1157 glEnable(GL_CULL_FACE);
1158 glDisable(GL_BLEND);
1160 glEnable(GL_TEXTURE_2D);
1162 // writing the numbers :
1163 sprintf (string, "Damages : %d/%d (%d)",(int)(player[0].damage),(int)(player[0].damagetolerance),(int)(player[0].bloodloss));
1165 text.glPrintOutline(1024/40-4,768/16-4+768*14/16-40,string,1,1.5*1.25,1024,768);
1167 text.glPrint(1024/40,768/16+768*14/16-40,string,1,1.5,1024,768);
1171 glColor4f(.5,.5,.5,1);
1174 if((texttoggle||editorenabled)&&debugmode&&!mainmenu){
1175 sprintf (string, "The framespersecond is %d.",(int)(fps));
1176 text.glPrint(10,30,string,0,.8,1024,768);
1178 sprintf (string, "Name: %s", registrationname);
1179 text.glPrint(10,260,string,0,.8,1024,768);
1183 sprintf (string, "Map editor enabled.");
1185 sprintf (string, "Map editor disabled.");
1186 text.glPrint(10,60,string,0,.8,1024,768);
1188 sprintf (string, "Object size: %f",editorsize);
1189 text.glPrint(10,75,string,0,.8,1024,768);
1190 if(editorrotation>=0)sprintf (string, "Object rotation: %f",editorrotation);
1191 else sprintf (string, "Object rotation: Random");
1192 text.glPrint(10,90,string,0,.8,1024,768);
1193 if(editorrotation2>=0)sprintf (string, "Object rotation2: %f",editorrotation2);
1194 else sprintf (string, "Object rotation2: Random");
1195 text.glPrint(10,105,string,0,.8,1024,768);
1196 sprintf (string, "Object type: %d",editortype);
1197 text.glPrint(10,120,string,0,.8,1024,768);
1198 switch(editortype) {
1200 sprintf (string, "(box)");
1203 sprintf (string, "(tree)");
1206 sprintf (string, "(wall)");
1209 sprintf (string, "(weird)");
1212 sprintf (string, "(spike)");
1215 sprintf (string, "(rock)");
1218 sprintf (string, "(bush)");
1221 sprintf (string, "(tunnel)");
1224 sprintf (string, "(chimney)");
1227 sprintf (string, "(platform)");
1230 sprintf (string, "(cool)");
1233 sprintf (string, "(fire)");
1236 text.glPrint(130,120,string,0,.8,1024,768);
1238 sprintf (string, "Numplayers: %d",numplayers);
1239 text.glPrint(10,155,string,0,.8,1024,768);
1240 sprintf (string, "Player %d: numwaypoints: %d",numplayers,player[numplayers-1].numwaypoints);
1241 text.glPrint(10,140,string,0,.8,1024,768);
1243 sprintf (string, "Difficulty: %d",difficulty);
1244 text.glPrint(10,240,string,0,.8,1024,768);
1249 if(drawmode==glowmode){
1250 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1251 glDisable(GL_CULL_FACE);
1252 glDisable(GL_LIGHTING);
1253 glDisable(GL_TEXTURE_2D);
1255 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1256 glPushMatrix(); // Store The Projection Matrix
1257 glLoadIdentity(); // Reset The Projection Matrix
1258 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1259 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1260 glPushMatrix(); // Store The Modelview Matrix
1261 glLoadIdentity(); // Reset The Modelview Matrix
1262 glScalef(screenwidth,screenheight,1);
1263 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1265 glColor4f(0,0,0,.5);
1267 glVertex3f(0, 0, 0.0f);
1268 glVertex3f(256, 0, 0.0f);
1269 glVertex3f(256, 256, 0.0f);
1270 glVertex3f(0, 256, 0.0f);
1272 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1273 glPopMatrix(); // Restore The Old Projection Matrix
1274 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1275 glPopMatrix(); // Restore The Old Projection Matrix
1276 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1277 glEnable(GL_CULL_FACE);
1278 glDisable(GL_BLEND);
1282 if((((blackout&&damageeffects)||(player[0].bloodloss>0&&damageeffects&&player[0].blooddimamount>0)||player[0].dead)&&!cameramode)||console){
1283 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1284 glDisable(GL_CULL_FACE);
1285 glDisable(GL_LIGHTING);
1286 glDisable(GL_TEXTURE_2D);
1288 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1289 glPushMatrix(); // Store The Projection Matrix
1290 glLoadIdentity(); // Reset The Projection Matrix
1291 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1292 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1293 glPushMatrix(); // Store The Modelview Matrix
1294 glLoadIdentity(); // Reset The Modelview Matrix
1295 glScalef(screenwidth,screenheight,1);
1296 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1298 if(player[0].dead)blackout+=multiplier*3;
1299 if(player[0].dead==1)blackout=.4f;
1300 if(player[0].dead==2&&blackout>.6)blackout=.6;
1301 glColor4f(0,0,0,blackout);
1302 if(!player[0].dead){
1303 if((player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5))*.3<.3){
1304 glColor4f(0,0,0,player[0].blooddimamount*player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5)*.3);
1305 blackout=player[0].blooddimamount*player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5)*.3;
1308 glColor4f(0,0,0,player[0].blooddimamount*.3);
1309 blackout=player[0].blooddimamount*.3;
1312 if(console)glColor4f(.7,0,0,.2);
1314 glVertex3f(0, 0, 0.0f);
1315 glVertex3f(256, 0, 0.0f);
1316 glVertex3f(256, 256, 0.0f);
1317 glVertex3f(0, 256, 0.0f);
1319 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1320 glPopMatrix(); // Restore The Old Projection Matrix
1321 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1322 glPopMatrix(); // Restore The Old Projection Matrix
1323 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1324 glEnable(GL_CULL_FACE);
1325 glDisable(GL_BLEND);
1329 if(flashamount>0&&damageeffects){
1330 if(flashamount>1)flashamount=1;
1331 if(flashdelay<=0)flashamount-=multiplier;
1333 if(flashamount<0)flashamount=0;
1334 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1335 glDisable(GL_CULL_FACE);
1336 glDisable(GL_LIGHTING);
1338 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1339 glPushMatrix(); // Store The Projection Matrix
1340 glLoadIdentity(); // Reset The Projection Matrix
1341 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1342 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1343 glPushMatrix(); // Store The Modelview Matrix
1344 glLoadIdentity(); // Reset The Modelview Matrix
1345 glScalef(screenwidth,screenheight,1);
1346 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1348 glColor4f(flashr,flashg,flashb,flashamount);
1350 glVertex3f(0, 0, 0.0f);
1351 glVertex3f(256, 0, 0.0f);
1352 glVertex3f(256, 256, 0.0f);
1353 glVertex3f(0, 256, 0.0f);
1355 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1356 glPopMatrix(); // Restore The Old Projection Matrix
1357 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1358 glPopMatrix(); // Restore The Old Projection Matrix
1359 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1360 glEnable(GL_CULL_FACE);
1361 glDisable(GL_BLEND);
1367 glEnable(GL_TEXTURE_2D);
1370 sprintf (string, " ]");
1371 text.glPrint(10,30+screenheight-330,string,0,1,screenwidth,screenheight);
1373 sprintf (string, "_");
1374 text.glPrint(30+(float)(displayselected)*10,30+(screenheight-330),string,0,1,screenwidth,screenheight);
1378 if((i!=0||chatting)&&displaytime[i]<4)
1379 for(j=0;j<displaychars[i];j++){
1380 glColor4f(1,1,1,4-displaytime[i]);
1381 if(j<displaychars[i]){
1382 sprintf (string, "%c",displaytext[i][j]);
1383 text.glPrint(30+j*10,30+i*20+(screenheight-330),string,0,1,screenwidth,screenheight);
1389 if(minimap&&indialogue==-1){
1390 float mapviewdist = 20000;
1392 glDisable(GL_DEPTH_TEST);
1393 glColor3f (1.0, 1.0, 1.0); // no coloring
1395 glEnable(GL_TEXTURE_2D);
1396 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1397 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1398 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1399 glDisable(GL_CULL_FACE);
1400 glDisable(GL_LIGHTING);
1402 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1403 glPushMatrix(); // Store The Projection Matrix
1404 glLoadIdentity(); // Reset The Projection Matrix
1405 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1406 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1407 glPushMatrix(); // Store The Modelview Matrix
1408 glLoadIdentity(); // Reset The Modelview Matrix
1409 glScalef((float)screenwidth/2,(float)screenwidth/2,1);
1410 glTranslatef(1.75,.25,0);
1411 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1419 int numliveplayers=0;
1421 for(i=0;i<numplayers;i++){
1422 if(!player[i].dead) numliveplayers++;
1427 for(i=0;i<objects.numobjects;i++){
1428 if(objects.type[i]==treetrunktype||objects.type[i]==boxtype){
1429 center+=objects.position[i];
1433 for(i=0;i<numplayers;i++){
1434 if(!player[i].dead)center+=player[i].coords;
1436 center/=numadd+numliveplayers;
1438 center=player[0].coords;
1440 float maxdistance=0;
1443 for(i=0;i<objects.numobjects;i++){
1444 tempdist=findDistancefast(¢er,&objects.position[i]);
1445 if(tempdist>maxdistance){
1447 maxdistance=tempdist;
1450 for(i=0;i<numplayers;i++){
1451 if(!player[i].dead){
1452 tempdist=findDistancefast(¢er,&player[i].coords);
1453 if(tempdist>maxdistance){
1455 maxdistance=tempdist;
1459 radius=fast_sqrt(maxdistance);
1463 glScalef(.25/radius*256*terrain.scale*.4,.25/radius*256*terrain.scale*.4,1);
1465 glScalef(1/(1/radius*256*terrain.scale*.4),1/(1/radius*256*terrain.scale*.4),1);
1467 glRotatef(player[0].lookrotation*-1+180,0,0,1);
1468 glTranslatef(-(center.x/terrain.scale/256*-2+1),(center.z/terrain.scale/256*-2+1),0);
1469 for(i=0;i<objects.numobjects;i++){
1470 if(objects.type[i]==treetrunktype){
1471 distcheck=findDistancefast(&player[0].coords,&objects.position[i]);
1472 if(distcheck<mapviewdist){
1473 glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
1474 glColor4f(0,.3,0,opac*(1-distcheck/mapviewdist));
1476 glTranslatef(objects.position[i].x/terrain.scale/256*-2+1,objects.position[i].z/terrain.scale/256*2-1,0);
1477 glRotatef(objects.rotation[i],0,0,1);
1478 glScalef(.003,.003,.003);
1481 glVertex3f(-1, -1, 0.0f);
1483 glVertex3f(1, -1, 0.0f);
1485 glVertex3f(1, 1, 0.0f);
1487 glVertex3f(-1, 1, 0.0f);
1492 if(objects.type[i]==boxtype){
1493 distcheck=findDistancefast(&player[0].coords,&objects.position[i]);
1494 if(distcheck<mapviewdist){
1495 glBindTexture( GL_TEXTURE_2D, Mapboxtexture);
1496 glColor4f(.4,.4,.4,opac*(1-distcheck/mapviewdist));
1498 glTranslatef(objects.position[i].x/terrain.scale/256*-2+1,objects.position[i].z/terrain.scale/256*2-1,0);
1499 glRotatef(objects.rotation[i],0,0,1);
1500 glScalef(.01*objects.scale[i],.01*objects.scale[i],.01*objects.scale[i]);
1503 glVertex3f(-1, -1, 0.0f);
1505 glVertex3f(1, -1, 0.0f);
1507 glVertex3f(1, 1, 0.0f);
1509 glVertex3f(-1, 1, 0.0f);
1516 glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
1517 for(i=0;i<numboundaries;i++){
1518 glColor4f(0,0,0,opac/3);
1520 glTranslatef(boundary[i].x/terrain.scale/256*-2+1,boundary[i].z/terrain.scale/256*2-1,0);
1521 glScalef(.002,.002,.002);
1524 glVertex3f(-1, -1, 0.0f);
1526 glVertex3f(1, -1, 0.0f);
1528 glVertex3f(1, 1, 0.0f);
1530 glVertex3f(-1, 1, 0.0f);
1535 for(i=0;i<numplayers;i++){
1536 distcheck=findDistancefast(&player[0].coords,&player[i].coords);
1537 if(distcheck<mapviewdist){
1539 glBindTexture( GL_TEXTURE_2D, Maparrowtexture);
1540 if(i==0)glColor4f(1,1,1,opac);
1541 else if(player[i].dead==2||player[i].howactive>typesleeping)glColor4f(0,0,0,opac*(1-distcheck/mapviewdist));
1542 else if(player[i].dead)glColor4f(.3,.3,.3,opac*(1-distcheck/mapviewdist));
1543 else if(player[i].aitype==attacktypecutoff)glColor4f(1,0,0,opac*(1-distcheck/mapviewdist));
1544 else if(player[i].aitype==passivetype)glColor4f(0,1,0,opac*(1-distcheck/mapviewdist));
1545 else glColor4f(1,1,0,1);
1546 glTranslatef(player[i].coords.x/terrain.scale/256*-2+1,player[i].coords.z/terrain.scale/256*2-1,0);
1547 glRotatef(player[i].rotation+180,0,0,1);
1548 glScalef(.005,.005,.005);
1551 glVertex3f(-1, -1, 0.0f);
1553 glVertex3f(1, -1, 0.0f);
1555 glVertex3f(1, 1, 0.0f);
1557 glVertex3f(-1, 1, 0.0f);
1563 glDisable(GL_TEXTURE_2D);
1564 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1565 glPopMatrix(); // Restore The Old Projection Matrix
1566 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1567 glPopMatrix(); // Restore The Old Projection Matrix
1568 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1569 glEnable(GL_CULL_FACE);
1570 glDisable(GL_BLEND);
1574 if(loading&&!stealthloading&&(!campaign||player[0].dead)){
1575 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1576 glDisable(GL_CULL_FACE);
1577 glDisable(GL_LIGHTING);
1578 glDisable(GL_TEXTURE_2D);
1580 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1581 glPushMatrix(); // Store The Projection Matrix
1582 glLoadIdentity(); // Reset The Projection Matrix
1583 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1584 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1585 glPushMatrix(); // Store The Modelview Matrix
1586 glLoadIdentity(); // Reset The Modelview Matrix
1587 glScalef(screenwidth,screenheight,1);
1588 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1590 glColor4f(0,0,0,.7);
1592 glVertex3f(0, 0, 0.0f);
1593 glVertex3f(256, 0, 0.0f);
1594 glVertex3f(256, 256, 0.0f);
1595 glVertex3f(0, 256, 0.0f);
1597 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1598 glPopMatrix(); // Restore The Old Projection Matrix
1599 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1600 glPopMatrix(); // Restore The Old Projection Matrix
1601 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1602 glEnable(GL_CULL_FACE);
1603 glDisable(GL_BLEND);
1607 glDisable(GL_DEPTH_TEST);
1608 glColor3f (1.0, 1.0, 1.0); // no coloring
1610 glEnable(GL_TEXTURE_2D);
1615 glEnable(GL_TEXTURE_2D);
1617 sprintf (string, "Loading...");
1618 text.glPrint(1024/2-90,768/2,string,1,2,1024,768);
1621 //if(ismotionblur)drawmode=motionblurmode;
1622 drawmode=normalmode;
1625 if(winfreeze&&!campaign){
1626 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1627 glDisable(GL_CULL_FACE);
1628 glDisable(GL_LIGHTING);
1629 glDisable(GL_TEXTURE_2D);
1631 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1632 glPushMatrix(); // Store The Projection Matrix
1633 glLoadIdentity(); // Reset The Projection Matrix
1634 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1635 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1636 glPushMatrix(); // Store The Modelview Matrix
1637 glLoadIdentity(); // Reset The Modelview Matrix
1638 glScalef(screenwidth,screenheight,1);
1639 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1641 glColor4f(0,0,0,.4);
1643 glVertex3f(0, 0, 0.0f);
1644 glVertex3f(256, 0, 0.0f);
1645 glVertex3f(256, 256, 0.0f);
1646 glVertex3f(0, 256, 0.0f);
1648 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1649 glPopMatrix(); // Restore The Old Projection Matrix
1650 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1651 glPopMatrix(); // Restore The Old Projection Matrix
1652 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1653 glEnable(GL_CULL_FACE);
1654 glDisable(GL_BLEND);
1658 glDisable(GL_DEPTH_TEST);
1659 glColor3f (1.0, 1.0, 1.0); // no coloring
1661 glEnable(GL_TEXTURE_2D);
1663 //Win Screen Won Victory
1665 glEnable(GL_TEXTURE_2D);
1667 sprintf (string, "Level Cleared!");
1668 text.glPrintOutlined(1024/2-strlen(string)*10,768*7/8,string,1,2,1024,768);
1670 sprintf (string, "Score: %d",(int)(bonustotal-startbonustotal));
1671 text.glPrintOutlined(1024/30,768*6/8,string,1,2,1024,768);
1674 sprintf (string, "Press Escape or Space to continue");
1676 sprintf (string, "Press Escape to return to menu or Space to continue");
1677 text.glPrintOutlined(640/2-strlen(string)*5,480*1/16,string,1,1,640,480);
1681 for(i=0;i<255;i++)string[i]='\0';
1682 sprintf (temp, "Time: %d:",(int)(((int)leveltime-(int)(leveltime)%60)/60));
1683 strcat(string,temp);
1684 if((int)(leveltime)%60<10)strcat(string,"0");
1685 sprintf (temp, "%d",(int)(leveltime)%60);
1686 strcat(string,temp);
1687 text.glPrintOutlined(1024/30,768*6/8-40,string,1,2,1024,768);
1690 int awards[award_count];
1691 int numawards = award_awards(awards);
1693 for (i = 0; i < numawards && i < 6; i++)
1694 text.glPrintOutlined(1024/30,768*6/8-90-40*i,award_names[awards[i]],1,2,1024,768);
1697 if(drawmode!=normalmode){
1698 glEnable(GL_TEXTURE_2D);
1700 if(!drawtoggle||drawmode!=realmotionblurmode||(drawtoggle==2||change==1)){
1703 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
1704 GLfloat subtractColor[4] = { 0.5, 0.5, 0.5, 0.0 };
1705 glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, subtractColor);
1706 //glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_SUBTRACT);
1707 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE);
1708 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_CONSTANT_EXT);
1709 glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 2.0f);
1711 glBindTexture( GL_TEXTURE_2D, screentexture);
1712 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1715 if((drawtoggle||change==1)&&drawmode==realmotionblurmode){
1717 glBindTexture( GL_TEXTURE_2D, screentexture2);
1718 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1720 if(!screentexture2){
1721 glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
1723 glGenTextures( 1, &screentexture2 );
1724 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
1726 glEnable(GL_TEXTURE_2D);
1727 glBindTexture( GL_TEXTURE_2D, screentexture2);
1728 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
1729 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
1731 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
1737 glClear(GL_DEPTH_BUFFER_BIT);
1738 ReSizeGLScene(90,.1f);
1739 glViewport(0,0,screenwidth,screenheight);
1741 if(drawmode!=normalmode){
1742 glDisable(GL_DEPTH_TEST);
1743 if(drawmode==motionblurmode){
1744 glDrawBuffer(GL_FRONT);
1745 glReadBuffer(GL_BACK);
1747 glColor3f (1.0, 1.0, 1.0); // no coloring
1749 glEnable(GL_TEXTURE_2D);
1750 glBindTexture( GL_TEXTURE_2D, screentexture);
1751 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1752 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1753 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1754 glDisable(GL_CULL_FACE);
1755 glDisable(GL_LIGHTING);
1757 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1758 glPushMatrix(); // Store The Projection Matrix
1759 glLoadIdentity(); // Reset The Projection Matrix
1760 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1761 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1762 glPushMatrix(); // Store The Modelview Matrix
1763 glLoadIdentity(); // Reset The Modelview Matrix
1764 glScalef((float)screenwidth/2,(float)screenheight/2,1);
1765 glTranslatef(1,1,0);
1766 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1768 if(drawmode==motionblurmode){
1769 if(motionbluramount<.2)motionbluramount=.2;
1770 //glColor4f(1,1,1,fast_sqrt(multiplier)*2.9*motionbluramount);
1771 glColor4f(1,1,1,motionbluramount);
1775 glVertex3f(-1, -1, 0.0f);
1776 glTexCoord2f(texcoordwidth,0);
1777 glVertex3f(1, -1, 0.0f);
1778 glTexCoord2f(texcoordwidth,texcoordheight);
1779 glVertex3f(1, 1, 0.0f);
1780 glTexCoord2f(0,texcoordheight);
1781 glVertex3f(-1, 1, 0.0f);
1785 if(drawmode==realmotionblurmode){
1786 glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
1787 glClear(GL_COLOR_BUFFER_BIT);
1788 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
1789 glBindTexture( GL_TEXTURE_2D, screentexture);
1790 glColor4f(1,1,1,.5);
1794 glVertex3f(-1, -1, 0.0f);
1795 glTexCoord2f(texcoordwidth,0);
1796 glVertex3f(1, -1, 0.0f);
1797 glTexCoord2f(texcoordwidth,texcoordheight);
1798 glVertex3f(1, 1, 0.0f);
1799 glTexCoord2f(0,texcoordheight);
1800 glVertex3f(-1, 1, 0.0f);
1803 glBindTexture( GL_TEXTURE_2D, screentexture2);
1804 glColor4f(1,1,1,.5);
1808 glVertex3f(-1, -1, 0.0f);
1809 glTexCoord2f(texcoordwidth,0);
1810 glVertex3f(1, -1, 0.0f);
1811 glTexCoord2f(texcoordwidth,texcoordheight);
1812 glVertex3f(1, 1, 0.0f);
1813 glTexCoord2f(0,texcoordheight);
1814 glVertex3f(-1, 1, 0.0f);
1817 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1819 if(drawmode==doublevisionmode){
1820 static float crosseyedness;
1821 crosseyedness=abs(player[0].damage-player[0].superpermanentdamage-(player[0].damagetolerance-player[0].superpermanentdamage)*1/2)/30;
1822 if(crosseyedness>1)crosseyedness=1;
1823 if(crosseyedness<0)crosseyedness=0;
1825 glDisable(GL_BLEND);
1830 glVertex3f(-1, -1, 0.0f);
1831 glTexCoord2f(texcoordwidth,0);
1832 glVertex3f(1, -1, 0.0f);
1833 glTexCoord2f(texcoordwidth,texcoordheight);
1834 glVertex3f(1, 1, 0.0f);
1835 glTexCoord2f(0,texcoordheight);
1836 glVertex3f(-1, 1, 0.0f);
1840 glColor4f(1,1,1,.5);
1843 glTranslatef(.015*crosseyedness,0,0);
1847 glVertex3f(-1, -1, 0.0f);
1848 glTexCoord2f(texcoordwidth,0);
1849 glVertex3f(1, -1, 0.0f);
1850 glTexCoord2f(texcoordwidth,texcoordheight);
1851 glVertex3f(1, 1, 0.0f);
1852 glTexCoord2f(0,texcoordheight);
1853 glVertex3f(-1, 1, 0.0f);
1858 if(drawmode==glowmode){
1859 glColor4f(.5,.5,.5,.5);
1861 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
1863 glTranslatef(.01,0,0);
1866 glVertex3f(-1, -1, 0.0f);
1867 glTexCoord2f(texcoordwidth,0);
1868 glVertex3f(1, -1, 0.0f);
1869 glTexCoord2f(texcoordwidth,texcoordheight);
1870 glVertex3f(1, 1, 0.0f);
1871 glTexCoord2f(0,texcoordheight);
1872 glVertex3f(-1, 1, 0.0f);
1876 glTranslatef(-.01,0,0);
1879 glVertex3f(-1, -1, 0.0f);
1880 glTexCoord2f(texcoordwidth,0);
1881 glVertex3f(1, -1, 0.0f);
1882 glTexCoord2f(texcoordwidth,texcoordheight);
1883 glVertex3f(1, 1, 0.0f);
1884 glTexCoord2f(0,texcoordheight);
1885 glVertex3f(-1, 1, 0.0f);
1889 glTranslatef(.0,.01,0);
1892 glVertex3f(-1, -1, 0.0f);
1893 glTexCoord2f(texcoordwidth,0);
1894 glVertex3f(1, -1, 0.0f);
1895 glTexCoord2f(texcoordwidth,texcoordheight);
1896 glVertex3f(1, 1, 0.0f);
1897 glTexCoord2f(0,texcoordheight);
1898 glVertex3f(-1, 1, 0.0f);
1902 glTranslatef(0,-.01,0);
1905 glVertex3f(-1, -1, 0.0f);
1906 glTexCoord2f(texcoordwidth,0);
1907 glVertex3f(1, -1, 0.0f);
1908 glTexCoord2f(texcoordwidth,texcoordheight);
1909 glVertex3f(1, 1, 0.0f);
1910 glTexCoord2f(0,texcoordheight);
1911 glVertex3f(-1, 1, 0.0f);
1915 if(drawmode==radialzoommode){
1917 //glRotatef((float)i*.1,0,0,1);
1918 glColor4f(1,1,1,1/((float)i+1));
1920 glScalef(1+(float)i*.01,1+(float)i*.01,1);
1923 glVertex3f(-1, -1, 0.0f);
1924 glTexCoord2f(texcoordwidth,0);
1925 glVertex3f(1, -1, 0.0f);
1926 glTexCoord2f(texcoordwidth,texcoordheight);
1927 glVertex3f(1, 1, 0.0f);
1928 glTexCoord2f(0,texcoordheight);
1929 glVertex3f(-1, 1, 0.0f);
1934 glDisable(GL_TEXTURE_2D);
1935 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1936 glPopMatrix(); // Restore The Old Projection Matrix
1937 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1938 glPopMatrix(); // Restore The Old Projection Matrix
1939 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1940 glEnable(GL_CULL_FACE);
1941 glDisable(GL_BLEND);
1946 glEnable(GL_TEXTURE_2D);
1949 if(consoleselected>=60)
1950 offset=consoleselected-60;
1951 sprintf (string, " ]");
1952 text.glPrint(10,30,string,0,1,1024,768);
1954 sprintf (string, "_");
1955 text.glPrint(30+(float)(consoleselected)*10-offset*10,30,string,0,1,1024,768);
1958 for(j=0;j<consolechars[i];j++){
1959 glColor4f(1,1,1,1-(float)(i)/16);
1960 if(j<consolechars[i]){
1961 sprintf (string, "%c",consoletext[i][j]);
1962 text.glPrint(30+j*10-offset*10,30+i*20,string,0,1,1024,768);
1969 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)||(mainmenu&&gameon)||(!gameon&&gamestarted)||(!gameon&&gamestarted)){
1970 multiplier=tempmult;
1975 // !!! FIXME: hack: clamp framerate in menu so text input works correctly on fast systems.
1978 glDrawBuffer(GL_BACK);
1979 glReadBuffer(GL_BACK);
1980 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
1981 ReSizeGLScene(90,.1f);
1984 temptexdetail=texdetail;
1985 if(texdetail>2)texdetail=2;
1986 if(mainmenu!=oldmainmenu&&oldmainmenu!=0){
1988 LoadTexture(":Data:Textures:Newgame.png",&Mainmenuitems[1],0,0);
1989 LoadTexture(":Data:Textures:Quit.png",&Mainmenuitems[3],0,0);
1992 LoadTexture(":Data:Textures:Resume.png",&Mainmenuitems[1],0,0);
1993 LoadTexture(":Data:Textures:Endgame.png",&Mainmenuitems[3],0,0);
1996 if(lastcheck>.5||oldmainmenu!=mainmenu){
1998 ifstream ipstream(ConvertFileName(":Data:Campaigns:main.txt"));
1999 ipstream.ignore(256,':');
2000 ipstream >> campaignnumlevels;
2001 for(i=0;i<campaignnumlevels;i++){
2002 ipstream.ignore(256,':');
2003 ipstream.ignore(256,':');
2004 ipstream.ignore(256,' ');
2005 ipstream >> campaignmapname[i];
2006 ipstream.ignore(256,':');
2007 ipstream >> campaigndescription[i];
2009 if(campaigndescription[i][j]=='_')campaigndescription[i][j]=' ';
2011 ipstream.ignore(256,':');
2012 ipstream >> campaignchoosenext[i];
2013 ipstream.ignore(256,':');
2014 ipstream >> campaignnumnext[i];
2015 for(j=0;j<campaignnumnext[i];j++){
2016 ipstream.ignore(256,':');
2017 ipstream >> campaignnextlevel[i][j];
2018 campaignnextlevel[i][j]-=1;
2020 ipstream.ignore(256,':');
2021 ipstream >> campaignlocationx[i];
2022 ipstream.ignore(256,':');
2023 ipstream >> campaignlocationy[i];
2027 for(i=0;i<campaignnumlevels;i++){
2029 levelhighlight[i]=0;
2034 for(i=0;i<(accountactive?accountactive->getCampaignChoicesMade():0);i++){
2035 levelorder[i+1]=campaignnextlevel[levelorder[i]][accountactive->getCampaignChoice(i)];
2036 levelvisible[levelorder[i+1]]=1;
2038 int whichlevelstart = (accountactive?accountactive->getCampaignChoicesMade():0)-1;
2039 if(whichlevelstart<0){
2040 accountactive->setCampaignScore(0);
2041 accountactive->resetFasttime();
2042 campaignchoicenum=1;
2043 campaignchoicewhich[0]=0;
2047 campaignchoicenum=campaignnumnext[levelorder[whichlevelstart]];
2048 for(i=0;i<campaignchoicenum;i++){
2049 campaignchoicewhich[i]=campaignnextlevel[levelorder[whichlevelstart]][i];
2050 levelvisible[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
2051 levelhighlight[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
2060 texdetail=temptexdetail;
2062 oldmainmenu=mainmenu;
2064 if(mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==8||mainmenu==9||mainmenu==10||mainmenu==119||mainmenu==18){
2065 glClear(GL_DEPTH_BUFFER_BIT);
2066 glEnable(GL_ALPHA_TEST);
2067 glAlphaFunc(GL_GREATER, 0.001f);
2068 glEnable(GL_TEXTURE_2D);
2069 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
2070 glDisable(GL_CULL_FACE);
2071 glDisable(GL_LIGHTING);
2073 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2074 glPushMatrix(); // Store The Projection Matrix
2075 glLoadIdentity(); // Reset The Projection Matrix
2076 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
2077 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2078 glPushMatrix(); // Store The Modelview Matrix
2079 glLoadIdentity(); // Reset The Modelview Matrix
2080 glTranslatef(screenwidth/2,screenheight/2,0);
2082 glScalef((float)screenwidth/2,(float)screenheight/2,1);
2083 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
2084 glDisable(GL_BLEND);
2085 glColor4f(0,0,0,1.0);
2086 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2087 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2088 glDisable(GL_TEXTURE_2D);
2090 //glScalef(.25,.25,.25);
2093 glVertex3f(-1, -1, 0.0f);
2095 glVertex3f(1, -1, 0.0f);
2097 glVertex3f(1, 1, 0.0f);
2099 glVertex3f(-1, 1, 0.0f);
2103 glColor4f(0.4,0.4,0.4,1.0);
2104 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2105 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2106 glEnable(GL_TEXTURE_2D);
2107 glBindTexture( GL_TEXTURE_2D, Mainmenuitems[4]);
2109 //glScalef(.25,.25,.25);
2112 glVertex3f(-1, -1, 0.0f);
2114 glVertex3f(1, -1, 0.0f);
2116 glVertex3f(1, 1, 0.0f);
2118 glVertex3f(-1, 1, 0.0f);
2123 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2125 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2129 if((float)newscreenwidth>(float)newscreenheight*1.61||(float)newscreenwidth<(float)newscreenheight*1.59)sprintf (menustring[0], "Resolution: %d*%d",(int)newscreenwidth,(int)newscreenheight);
2130 else sprintf (menustring[0], "Resolution: %d*%d (widescreen)",(int)newscreenwidth,(int)newscreenheight);
2133 endx[0]=startx[0]+strlen(menustring[0])*10;
2134 endy[0]=starty[0]+20;
2138 if(newdetail==2)sprintf (menustring[1], "Detail: High");
2139 else if(newdetail==1)sprintf (menustring[1], "Detail: Medium");
2140 else sprintf (menustring[1], "Detail: Low");
2143 endx[1]=startx[1]+strlen(menustring[1])*10;
2144 endy[1]=starty[1]+20;
2148 if(bloodtoggle==2)sprintf (menustring[2], "Blood: On, high detail (slower)");
2149 if(bloodtoggle==1)sprintf (menustring[2], "Blood: On, low detail");
2150 if(bloodtoggle==0)sprintf (menustring[2], "Blood: Off");
2153 endx[2]=startx[2]+strlen(menustring[2])*10;
2154 endy[2]=starty[2]+20;
2158 if(difficulty==2)sprintf (menustring[3], "Difficulty: Insane");
2159 if(difficulty==1)sprintf (menustring[3], "Difficulty: Difficult");
2160 if(difficulty==0)sprintf (menustring[3], "Difficulty: Easier");
2161 startx[3]=10+20-1000;
2163 endx[3]=startx[3]+strlen(menustring[3])*10;
2164 endy[3]=starty[3]+20;
2168 if(ismotionblur==1)sprintf (menustring[4], "Blur Effects: Enabled (less compatible)");
2169 if(ismotionblur==0)sprintf (menustring[4], "Blur Effects: Disabled (more compatible)");
2172 endx[4]=startx[4]+strlen(menustring[4])*10;
2173 endy[4]=starty[4]+20;
2177 if(decals==1)sprintf (menustring[5], "Decals: Enabled (slower)");
2178 if(decals==0)sprintf (menustring[5], "Decals: Disabled");
2181 endx[5]=startx[5]+strlen(menustring[5])*10;
2182 endy[5]=starty[5]+20;
2186 if(musictoggle==1)sprintf (menustring[6], "Music: Enabled");
2187 if(musictoggle==0)sprintf (menustring[6], "Music: Disabled");
2190 endx[6]=startx[6]+strlen(menustring[6])*10;
2191 endy[6]=starty[6]+20;
2195 if(invertmouse==1)sprintf (menustring[9], "Invert mouse: Yes");
2196 if(invertmouse==0)sprintf (menustring[9], "Invert mouse: No");
2199 endx[9]=startx[9]+strlen(menustring[9])*10;
2200 endy[9]=starty[9]+20;
2204 sprintf (menustring[10], "Mouse Speed: %d", (int)(usermousesensitivity*5));
2207 endx[10]=startx[10]+strlen(menustring[10])*10;
2208 endy[10]=starty[10]+20;
2212 sprintf (menustring[11], "Volume: %d%%", (int)(volume*100));
2215 endx[11]=startx[11]+strlen(menustring[11])*10;
2216 endy[11]=starty[11]+20;
2220 sprintf (menustring[13], "Damage Bar: %s",(showdamagebar?"on":"off"));
2223 endx[13]=startx[13]+strlen(menustring[13])*10;
2224 endy[13]=starty[13]+20;
2228 sprintf (menustring[7], "-Configure Controls-");
2231 endx[7]=startx[7]+strlen(menustring[7])*10;
2232 endy[7]=starty[7]+20;
2236 sprintf (menustring[12], "-Configure Stereo -");
2239 endx[12]=startx[12]+strlen(menustring[7])*10;
2240 endy[12]=starty[12]+20;
2244 if(newdetail==detail&&newscreenheight==(int)screenheight&&newscreenwidth==(int)screenwidth)sprintf (menustring[8], "Back");
2245 else sprintf (menustring[8], "Back (some changes take effect next time Lugaru is opened)");
2247 endx[8]=startx[8]+strlen(menustring[8])*10;
2249 endy[8]=starty[8]+20;
2256 if(keyselect!=0)sprintf (menustring[0], "Forwards: %s",Input::keyToChar(forwardkey));
2257 else sprintf (menustring[0], "Forwards: _");
2260 endx[0]=startx[0]+strlen(menustring[0])*10;
2261 endy[0]=starty[0]+20;
2265 if(keyselect!=1)sprintf (menustring[1], "Back: %s",Input::keyToChar(backkey));
2266 else sprintf (menustring[1], "Back: _");
2269 endx[1]=startx[1]+strlen(menustring[1])*10;
2270 endy[1]=starty[1]+20;
2274 if(keyselect!=2)sprintf (menustring[2], "Left: %s",Input::keyToChar(leftkey));
2275 else sprintf (menustring[2], "Left: _");
2278 endx[2]=startx[2]+strlen(menustring[2])*10;
2279 endy[2]=starty[2]+20;
2283 if(keyselect!=3)sprintf (menustring[3], "Right: %s",Input::keyToChar(rightkey));
2284 else sprintf (menustring[3], "Right: _");
2287 endx[3]=startx[3]+strlen(menustring[3])*10;
2288 endy[3]=starty[3]+20;
2292 if(keyselect!=4)sprintf (menustring[4], "Crouch: %s",Input::keyToChar(crouchkey));
2293 else sprintf (menustring[4], "Crouch: _");
2296 endx[4]=startx[4]+strlen(menustring[4])*10;
2297 endy[4]=starty[4]+20;
2301 if(keyselect!=5)sprintf (menustring[5], "Jump: %s",Input::keyToChar(jumpkey));
2302 else sprintf (menustring[5], "Jump: _");
2305 endx[5]=startx[5]+strlen(menustring[5])*10;
2306 endy[5]=starty[5]+20;
2310 if(keyselect!=6)sprintf (menustring[6], "Draw: %s",Input::keyToChar(drawkey));
2311 else sprintf (menustring[6], "Draw: _");
2314 endx[6]=startx[6]+strlen(menustring[6])*10;
2315 endy[6]=starty[6]+20;
2319 if(keyselect!=7)sprintf (menustring[7], "Throw: %s",Input::keyToChar(throwkey));
2320 else sprintf (menustring[7], "Throw: _");
2323 endx[7]=startx[7]+strlen(menustring[7])*10;
2324 endy[7]=starty[7]+20;
2328 if(keyselect!=8)sprintf (menustring[8], "Attack: %s",Input::keyToChar(attackkey));
2329 else sprintf (menustring[8], "Attack: _");
2332 endx[8]=startx[8]+strlen(menustring[8])*10;
2333 endy[8]=starty[8]+20;
2339 sprintf (menustring[9], "Back");
2341 endx[9]=startx[9]+strlen(menustring[9])*10;
2343 endy[9]=starty[9]+20;
2348 nummenuitems=7+(accountactive?accountactive->getCampaignChoicesMade():0)+campaignchoicenum;
2350 sprintf (menustring[0], "%s",accountactive->getName());
2353 endx[0]=startx[0]+strlen(menustring[0])*10;
2354 endy[0]=starty[0]+20;
2358 sprintf (menustring[1], "Tutorial");
2361 endx[1]=startx[1]+strlen(menustring[1])*10;
2362 endy[1]=starty[1]+20;
2366 sprintf (menustring[2], "Challenge");
2369 endx[2]=startx[2]+strlen(menustring[2])*10;
2370 endy[2]=starty[2]+20;
2374 sprintf (menustring[3], "Delete User");
2377 endx[3]=startx[3]+strlen(menustring[3])*10;
2378 endy[3]=starty[3]+20;
2382 sprintf (menustring[4], "Main Menu");
2385 endx[4]=startx[4]+strlen(menustring[4])*10;
2386 endy[4]=starty[4]+20;
2390 sprintf (menustring[5], "Change User");
2392 endx[5]=startx[5]+strlen(menustring[5])*10;
2394 endy[5]=starty[5]+20;
2400 sprintf (menustring[6], "World");
2402 starty[6]=30+480-400-50;
2403 endx[6]=startx[6]+400;
2408 if((accountactive?accountactive->getCampaignChoicesMade():0)) {
2409 for(i=0;i<(accountactive?accountactive->getCampaignChoicesMade():0);i++) {
2410 sprintf (menustring[7+i], "%s", campaigndescription[levelorder[i]]);
2411 startx[7+i]=30+120+campaignlocationx[levelorder[i]]*400/512;
2412 starty[7+i]=30+30+(512-campaignlocationy[levelorder[i]])*400/512;
2413 endx[7+i]=startx[7+i]+10;
2414 endy[7+i]=starty[7+i]+10;
2420 if(campaignchoicenum>0)
2421 for(i=(accountactive?accountactive->getCampaignChoicesMade():0);i<(accountactive?accountactive->getCampaignChoicesMade():0)+campaignchoicenum;i++){
2422 sprintf (menustring[7+i], "%s", campaigndescription[levelorder[i]]);
2423 startx[7+i]=30+120+campaignlocationx[campaignchoicewhich[i-((accountactive?accountactive->getCampaignChoicesMade():0))]]*400/512;
2424 starty[7+i]=30+30+(512-campaignlocationy[campaignchoicewhich[i-((accountactive?accountactive->getCampaignChoicesMade():0))]])*400/512;
2425 endx[7+i]=startx[7+i]+10;
2426 endy[7+i]=starty[7+i]+10;
2431 /*sprintf (menustring[7], "Dot");
2432 startx[7]=120+260*400/512;
2433 starty[7]=30+(512-184)*400/512;
2434 endx[7]=startx[7]+10;
2435 endy[7]=starty[7]+10;
2439 sprintf (menustring[8], "Dot");
2440 startx[8]=120+129*400/512;
2441 starty[8]=30+(512-284)*400/512;
2442 endx[8]=startx[8]+10;
2443 endy[8]=starty[8]+10;
2447 sprintf (menustring[9], "Dot");
2448 startx[9]=120+358*400/512;
2449 starty[9]=30+(512-235)*400/512;
2450 endx[9]=startx[9]+10;
2451 endy[9]=starty[9]+10;
2455 sprintf (menustring[10], "Dot");
2456 startx[10]=120+359*400/512;
2457 starty[10]=30+(512-308)*400/512;
2458 endx[10]=startx[10]+10;
2459 endy[10]=starty[10]+10;
2463 sprintf (menustring[11], "Dot");
2464 startx[11]=120+288*400/512;
2465 starty[11]=30+(512-277)*400/512;
2466 endx[11]=startx[11]+10;
2467 endy[11]=starty[11]+10;
2475 sprintf (menustring[0], "Are you sure you want to delete this user?");
2478 endx[0]=startx[0]+strlen(menustring[0])*10;
2479 endy[0]=starty[0]+20;
2483 sprintf (menustring[1], "Yes");
2486 endx[1]=startx[1]+strlen(menustring[1])*10;
2487 endy[1]=starty[1]+20;
2491 sprintf (menustring[2], "No");
2494 endx[2]=startx[2]+strlen(menustring[2])*10;
2495 endy[2]=starty[2]+20;
2499 sprintf (menustring[3], "Extra 4");
2502 endx[3]=startx[3]+strlen(menustring[3])*10;
2503 endy[3]=starty[3]+20;
2507 sprintf (menustring[4], "Extra 5");
2510 endx[4]=startx[4]+strlen(menustring[4])*10;
2511 endy[4]=starty[4]+20;
2515 sprintf (menustring[5], "Back");
2517 endx[5]=startx[5]+strlen(menustring[5])*10;
2519 endy[5]=starty[5]+20;
2525 nummenuitems=Account::getNbAccounts()+2;
2529 if(Account::getNbAccounts()<8)
2530 sprintf (menustring[0], "New User");
2532 sprintf (menustring[0], "No More Users");
2535 endx[0]=startx[0]+strlen(menustring[0])*10;
2536 endy[0]=starty[0]+20;
2545 for(i=0;i<Account::getNbAccounts();i++){
2546 sprintf (menustring[num], "%s",Account::get(i)->getName());
2548 starty[num]=360-20-20*num;
2549 endx[num]=startx[num]+strlen(menustring[num])*10;
2550 endy[num]=starty[num]+20;
2557 sprintf (menustring[num], "Back");
2559 endx[num]=startx[num]+strlen(menustring[num])*10;
2561 endy[num]=starty[num]+20;
2568 sprintf (menustring[0], "Easier");
2571 endx[0]=startx[0]+strlen(menustring[0])*10;
2572 endy[0]=starty[0]+20;
2576 sprintf (menustring[1], "Difficult");
2579 endx[1]=startx[1]+strlen(menustring[1])*10;
2580 endy[1]=starty[1]+20;
2584 sprintf (menustring[2], "Insane");
2587 endx[2]=startx[2]+strlen(menustring[2])*10;
2588 endy[2]=starty[2]+20;
2594 //tempncl=numchallengelevels;
2595 //numchallengelevels=9;
2596 nummenuitems=2+numchallengelevels;
2599 for(j=0;j<numchallengelevels;j++){
2600 for(i=0;i<255;i++)menustring[j][i]='\0';
2601 sprintf (temp, "Level %d",j+1);
2602 strcpy(menustring[j],temp);
2603 for(i=0;i<17;i++)if(menustring[j][i]=='\0')menustring[j][i]=' ';
2604 menustring[j][17]='\0';
2605 sprintf (temp, "%d",(int)accountactive->getHighScore(j));
2606 strcat(menustring[j],temp);
2607 for(i=18;i<32;i++)if(menustring[j][i]=='\0')menustring[j][i]=' ';
2608 menustring[j][32]='\0';
2609 sprintf (temp, "%d:",(int)(((int)accountactive->getFastTime(j)-(int)(accountactive->getFastTime(j))%60)/60));
2610 strcat(menustring[j],temp);
2611 if((int)(accountactive->getFastTime(j))%60<10)strcat(menustring[j],"0");
2612 sprintf (temp, "%d",(int)(accountactive->getFastTime(j))%60);
2613 strcat(menustring[j],temp);
2617 endx[j]=startx[j]+strlen(menustring[j])*10;
2618 endy[j]=starty[j]+20;
2623 sprintf (menustring[numchallengelevels], "Back");
2624 startx[numchallengelevels]=10;
2625 endx[numchallengelevels]=startx[numchallengelevels]+strlen(menustring[numchallengelevels])*10;
2626 starty[numchallengelevels]=10;
2627 endy[numchallengelevels]=starty[numchallengelevels]+20;
2628 movex[numchallengelevels]=0;
2629 movey[numchallengelevels]=0;
2631 sprintf (menustring[numchallengelevels+1], " High Score Best Time");
2632 startx[numchallengelevels+1]=10;
2633 starty[numchallengelevels+1]=440;
2634 endx[numchallengelevels+1]=startx[numchallengelevels+1]+strlen(menustring[numchallengelevels+1])*10;
2635 endy[numchallengelevels+1]=starty[numchallengelevels+1]+20;
2636 movex[numchallengelevels+1]=0;
2637 movey[numchallengelevels+1]=0;
2639 //numchallengelevels=tempncl;
2646 sprintf (menustring[0], "Congratulations!");
2649 endx[0]=startx[0]+strlen(menustring[0])*10;
2650 endy[0]=starty[0]+20;
2654 sprintf (menustring[1], "You have avenged your family and");
2657 endx[1]=startx[1]+strlen(menustring[1])*10;
2658 endy[1]=starty[1]+20;
2662 sprintf (menustring[2], "restored peace to the island of Lugaru.");
2665 endx[2]=startx[2]+strlen(menustring[2])*10;
2666 endy[2]=starty[2]+20;
2670 sprintf (menustring[3], "Back");
2672 endx[3]=startx[3]+strlen(menustring[3])*10;
2674 endy[3]=starty[3]+20;
2678 for(i=0;i<255;i++)menustring[4][i]='\0';
2679 sprintf (temp, "Your score:");
2680 strcpy(menustring[4],temp);
2681 for(i=0;i<20;i++)if(menustring[4][i]=='\0')menustring[4][i]=' ';
2682 menustring[4][20]='\0';
2683 sprintf (temp, "%d",(int)accountactive->getCampaignScore());
2684 strcat(menustring[4],temp);
2686 endx[4]=startx[4]+strlen(menustring[4])*10;
2688 endy[4]=starty[4]+20;
2692 for(i=0;i<255;i++)menustring[5][i]='\0';
2693 sprintf (temp, "Your time:");
2694 strcpy(menustring[5],temp);
2695 for(i=0;i<20;i++)if(menustring[5][i]=='\0')menustring[5][i]=' ';
2696 menustring[5][20]='\0';
2697 sprintf (temp, "%d",(int)accountcampaigntime[accountactive]);
2698 strcat(menustring[5],temp);
2700 endx[5]=startx[5]+strlen(menustring[5])*10;
2702 endy[5]=starty[5]+20;
2706 for(i=0;i<255;i++)menustring[5][i]='\0';
2707 sprintf (temp, "Highest score:");
2708 strcpy(menustring[5],temp);
2709 for(i=0;i<20;i++)if(menustring[5][i]=='\0')menustring[5][i]=' ';
2710 menustring[5][20]='\0';
2711 sprintf (temp, "%d",(int)accountactive->getCampaignHighScore());
2712 strcat(menustring[5],temp);
2714 endx[5]=startx[5]+strlen(menustring[5])*10;
2716 endy[5]=starty[5]+20;
2720 for(i=0;i<255;i++)menustring[7][i]='\0';
2721 sprintf (temp, "Lowest time:");
2722 strcpy(menustring[7],temp);
2723 for(i=0;i<20;i++)if(menustring[7][i]=='\0')menustring[7][i]=' ';
2724 menustring[7][20]='\0';
2725 sprintf (temp, "%d",(int)accountactive->getCampaignFasttime());
2726 strcat(menustring[7],temp);
2728 endx[7]=startx[7]+strlen(menustring[7])*10;
2730 endy[7]=starty[7]+20;
2736 sprintf (menustring[0], "Stereo mode: %s", StereoModeName(newstereomode));
2739 endx[0]=startx[0]+strlen(menustring[0])*10;
2740 endy[0]=starty[0]+20;
2744 sprintf (menustring[1], "Stereo separation: %.3f", stereoseparation);
2747 endx[1]=startx[1]+strlen(menustring[1])*10;
2748 endy[1]=starty[1]+20;
2752 sprintf (menustring[2], "Reverse stereo: %s", stereoreverse ? "Yes" : "No");
2755 endx[2]=startx[2]+strlen(menustring[2])*10;
2756 endy[2]=starty[2]+20;
2760 sprintf (menustring[3], "Back");
2762 endx[3]=startx[3]+strlen(menustring[3])*10;
2764 endy[3]=starty[3]+20;
2770 if(mainmenu==1||mainmenu==2){
2780 starty[1]=480-152-32;
2787 starty[2]=480-228-32;
2795 starty[3]=480-306-32;
2804 starty[3]=480-306-32;
2818 starty[4]=480-140-256;
2825 starty[5]=480-138-256;
2832 starty[6]=480-144-256;
2840 starty[4]=480-140-256;
2847 starty[5]=480-138-256;
2854 starty[6]=480-144-256;
2862 starty[4]=480-140-256;
2869 starty[5]=480-150-256;
2876 starty[6]=480-144-256;
2884 starty[4]=480-140-256;
2891 starty[5]=480-150-256;
2898 starty[6]=480-144-256;
2906 starty[4]=480-100-256;
2913 starty[5]=480-120-256;
2920 starty[6]=480-144-256;
2930 if(mainmenu==1||mainmenu==2)
2932 if((mousecoordh/screenwidth*640)>startx[i]&&(mousecoordh/screenwidth*640)<endx[i]&&480-(mousecoordv/screenheight*480)>starty[i]&&480-(mousecoordv/screenheight*480)<endy[i]){
2937 if(mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==8||mainmenu==9||mainmenu==10||mainmenu==18)
2938 for(i=0;i<nummenuitems;i++){
2939 if((mousecoordh/screenwidth*640)>startx[i]&&(mousecoordh/screenwidth*640)<endx[i]&&480-(mousecoordv/screenheight*480)>starty[i]&&480-(mousecoordv/screenheight*480)<endy[i]){
2940 if(mainmenu!=5)selected=i;
2941 if(mainmenu==5&&(i!=0&&i!=6))selected=i;
2942 if(mainmenu==9&&(i!=numchallengelevels+1))selected=i; // seem useless, if mainmenu==9 then mainmenu!=5, so selected==i.
2946 for(i=0;i<nummenuitems;i++){
2948 selectedlong[i]+=multiplier*5;
2949 if(selectedlong[i]>1) selectedlong[i]=1;
2951 selectedlong[i]-=multiplier*5;
2952 if(selectedlong[i]<0) selectedlong[i]=0;
2954 offsetx[i]=(startx[i]+endx[i])/2-(mousecoordh/screenwidth*640);
2955 offsety[i]=(starty[i]+endy[i])/2-(480-(mousecoordv/screenheight*480));
2960 if(i>=4&&(mainmenu==1||mainmenu==2)){
2962 offsetx[i]=(startx[i]+endx[i]+movex[i]*transition)/2-(640+190)/2;
2963 offsety[i]=(starty[i]+endy[i]+movey[i]*transition)/2-(336+150)/2;
2969 if(mainmenu==1||mainmenu==2){
2970 glClear(GL_DEPTH_BUFFER_BIT);
2971 glEnable(GL_ALPHA_TEST);
2972 glAlphaFunc(GL_GREATER, 0.001f);
2973 glEnable(GL_TEXTURE_2D);
2974 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
2975 glDisable(GL_CULL_FACE);
2976 glDisable(GL_LIGHTING);
2978 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2979 glPushMatrix(); // Store The Projection Matrix
2980 glLoadIdentity(); // Reset The Projection Matrix
2981 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
2982 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2983 glPushMatrix(); // Store The Modelview Matrix
2984 glLoadIdentity(); // Reset The Modelview Matrix
2985 glTranslatef(screenwidth/2,screenheight/2,0);
2987 glScalef((float)screenwidth/2,(float)screenheight/2,1);
2988 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
2989 glDisable(GL_BLEND);
2990 glColor4f(0,0,0,1.0);
2991 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2992 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2993 glDisable(GL_TEXTURE_2D);
2995 //glScalef(.25,.25,.25);
2998 glVertex3f(-1, -1, 0.0f);
3000 glVertex3f(1, -1, 0.0f);
3002 glVertex3f(1, 1, 0.0f);
3004 glVertex3f(-1, 1, 0.0f);
3008 glColor4f(0.4,0.4,0.4,1.0);
3009 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
3010 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
3011 glEnable(GL_TEXTURE_2D);
3012 glBindTexture( GL_TEXTURE_2D, Mainmenuitems[4]);
3014 //glScalef(.25,.25,.25);
3017 glVertex3f(-1, -1, 0.0f);
3019 glVertex3f(1, -1, 0.0f);
3021 glVertex3f(1, 1, 0.0f);
3023 glVertex3f(-1, 1, 0.0f);
3028 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3031 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3032 glPushMatrix(); // Store The Projection Matrix
3033 glLoadIdentity(); // Reset The Projection Matrix
3034 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3035 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3036 glPushMatrix(); // Store The Modelview Matrix
3037 glLoadIdentity(); // Reset The Modelview Matrix
3039 glDisable(GL_TEXTURE_2D);
3043 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3045 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3049 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3050 glPushMatrix(); // Store The Projection Matrix
3051 glLoadIdentity(); // Reset The Projection Matrix
3052 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3053 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3054 glPushMatrix(); // Store The Modelview Matrix
3055 glLoadIdentity(); // Reset The Modelview Matrix
3056 glEnable(GL_TEXTURE_2D);
3057 for(j=0;j<nummenuitems;j++)
3059 if(j>3 && (mainmenu==1||mainmenu==2))
3061 //glDisable(GL_BLEND);
3062 glEnable(GL_ALPHA_TEST);
3064 //glDisable(GL_ALPHA_TEST);
3065 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3066 if(mainmenu==1||mainmenu==2)
3069 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3070 glBindTexture( GL_TEXTURE_2D, Mainmenuitems[j]);
3071 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
3072 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
3073 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3077 glVertex3f(startx[j]+movex[j]*transition, starty[j]+movey[j]*transition, 0.0f);
3079 glVertex3f(endx[j]+movex[j]*transition, starty[j]+movey[j]*transition, 0.0f);
3081 glVertex3f(endx[j]+movex[j]*transition, endy[j]+movey[j]*transition, 0.0f);
3083 glVertex3f(startx[j]+movex[j]*transition, endy[j]+movey[j]*transition, 0.0f);
3087 //glDisable(GL_ALPHA_TEST);
3088 if(j<4)glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3091 if(1-((float)i)/10-(1-selectedlong[j])>0)
3093 glColor4f(1,1,1,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3094 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3098 glVertex3f(startx[j]-((float)i)*1/2+offsetx[j]*((float)i)/2+movex[j]*transition, starty[j]-((float)i)*1/2+offsety[j]*((float)i)/2+movey[j]*transition, 0.0f);
3100 glVertex3f(endx[j]+((float)i)*1/2+offsetx[j]*((float)i)/2+movex[j]*transition, starty[j]-((float)i)*1/2+offsety[j]*((float)i)/2+movey[j]*transition, 0.0f);
3102 glVertex3f(endx[j]+((float)i)*1/2+offsetx[j]*((float)i)/2+movex[j]*transition, endy[j]+((float)i)*1/2+offsety[j]*((float)i)/2+movey[j]*transition, 0.0f);
3104 glVertex3f(startx[j]-((float)i)*1/2+offsetx[j]*((float)i)/2+movex[j]*transition, endy[j]+((float)i)*1/2+offsety[j]*((float)i)/2+movey[j]*transition, 0.0f);
3110 if(mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==8||mainmenu==9||mainmenu==10||mainmenu==18)
3112 if(mainmenu!=5||j<6)
3115 if( (mainmenu==9) && j>accountactive->getProgress() && (j<numchallengelevels) )
3116 glColor4f(0.5,0,0,1);
3117 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3119 if(mainmenu!=7||j!=0||!entername)
3120 text.glPrint(startx[j],starty[j],menustring[j],0,1,640,480);
3124 sprintf (string, "_");
3125 text.glPrint(startx[j]+(float)(displayselected)*10,starty[j],string,0,1,640,480);
3127 for(l=0;l<displaychars[0];l++) {
3128 sprintf (string, "%c",displaytext[0][l]);
3129 text.glPrint(startx[j]+l*10,starty[j],string,0,1,640,480);
3134 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3137 if(1-((float)i)/15-(1-selectedlong[j])>0)
3139 glColor4f(1,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3140 if(mainmenu==9&&j>accountactive->getProgress()&&j<numchallengelevels)glColor4f(0.5,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3141 if(mainmenu==11&&j>accountactive->getProgress()&&j<numchallengelevels)glColor4f(0.5,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3142 if(mainmenu==3)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4-((/*1*/+((float)i)/70)*strlen(menustring[j]))*3,starty[j]+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
3143 if(mainmenu==4)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4,starty[j]+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
3144 if(mainmenu==5)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4,starty[j]+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
3145 if(mainmenu==6)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4,starty[j]+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
3146 if(mainmenu==7&&(j!=0||!entername)) text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4,starty[j]+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
3147 if(mainmenu==8)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4,starty[j]+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
3148 if(mainmenu==9)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4,starty[j]+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
3149 if(mainmenu==10)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4,starty[j]+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
3150 if(mainmenu==18)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4,starty[j]+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
3156 glClear(GL_DEPTH_BUFFER_BIT);
3157 glEnable(GL_ALPHA_TEST);
3158 glAlphaFunc(GL_GREATER, 0.001f);
3159 glEnable(GL_TEXTURE_2D);
3160 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3161 glDisable(GL_CULL_FACE);
3162 glDisable(GL_LIGHTING);
3163 if(j==6)glColor4f(1,1,1,1);
3164 else glColor4f(1,0,0,1);
3166 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3167 glPushMatrix(); // Store The Projection Matrix
3168 glLoadIdentity(); // Reset The Projection Matrix
3169 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3170 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3171 glPushMatrix(); // Store The Modelview Matrix
3172 glLoadIdentity(); // Reset The Modelview Matrix
3175 //Draw world, draw map
3176 glTranslatef(2,-5,0);
3178 if(j>6&&j<nummenuitems-1)
3180 XYZ linestart,lineend,offset;
3187 //float linestartx,lineendx,linestarty,lineendy,offsetx,offsety;
3188 linestart.x=(startx[j]+endx[j])/2;
3189 linestart.y=(starty[j]+endy[j])/2;
3190 if(j>=6+(accountactive?accountactive->getCampaignChoicesMade():0)){
3191 linestart.x=(startx[6+(accountactive?accountactive->getCampaignChoicesMade():0)]+endx[6+(accountactive?accountactive->getCampaignChoicesMade():0)])/2;
3192 linestart.y=(starty[6+(accountactive?accountactive->getCampaignChoicesMade():0)]+endy[6+(accountactive?accountactive->getCampaignChoicesMade():0)])/2;
3194 lineend.x=(startx[j+1]+endx[j+1])/2;
3195 lineend.y=(starty[j+1]+endy[j+1])/2;
3196 offset=lineend-linestart;
3199 offset=DoRotation(offset,0,0,90);
3201 glDisable(GL_TEXTURE_2D);
3203 if(j<6+(accountactive?accountactive->getCampaignChoicesMade():0)){
3204 glColor4f(0.5,0,0,1);
3212 linestart+=fac*4*startsize;
3213 lineend-=fac*4*endsize;
3215 if(!(j>7+(accountactive?accountactive->getCampaignChoicesMade():0)+campaignchoicenum)){
3216 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3220 glVertex3f(linestart.x-offset.x*startsize, linestart.y-offset.y*startsize, 0.0f);
3222 glVertex3f(linestart.x+offset.x*startsize, linestart.y+offset.y*startsize, 0.0f);
3224 glVertex3f(lineend.x+offset.x*endsize, lineend.y+offset.y*endsize, 0.0f);
3226 glVertex3f(lineend.x-offset.x*endsize, lineend.y-offset.y*endsize, 0.0f);
3230 glEnable(GL_TEXTURE_2D);
3234 if(j==6)glBindTexture( GL_TEXTURE_2D, Mainmenuitems[7]);
3235 else glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
3236 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
3237 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
3238 if(j-7<(accountactive?accountactive->getCampaignChoicesMade():0))glColor4f(0.5,0,0,1);
3239 if(j-7>=(accountactive?accountactive->getCampaignChoicesMade():0))glColor4f(1,0,0,1);
3240 if(j==6)glColor4f(1,1,1,1);
3243 itemsize=abs(startx[j]-endx[j])/2;
3245 midpoint.x=(startx[j]+endx[j])/2;
3246 midpoint.y=(starty[j]+endy[j])/2;
3247 if(j>6&&(j-7<(accountactive?accountactive->getCampaignChoicesMade():0)))itemsize*=.5;
3248 if(!(j-7>(accountactive?accountactive->getCampaignChoicesMade():0)+campaignchoicenum))
3250 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3254 glVertex3f(midpoint.x-itemsize+movex[j]*transition, midpoint.y-itemsize+movey[j]*transition, 0.0f);
3256 glVertex3f(midpoint.x+itemsize+movex[j]*transition, midpoint.y-itemsize+movey[j]*transition, 0.0f);
3258 glVertex3f(midpoint.x+itemsize+movex[j]*transition, midpoint.y+itemsize+movey[j]*transition, 0.0f);
3260 glVertex3f(midpoint.x-itemsize+movex[j]*transition, midpoint.y+itemsize+movey[j]*transition, 0.0f);
3264 //glDisable(GL_ALPHA_TEST);
3265 if(j<4)glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3268 if(1-((float)i)/10-(1-selectedlong[j])>0)
3270 glColor4f(1,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3271 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3275 glVertex3f(midpoint.x-itemsize-((float)i)*1/2+offsetx[j]*((float)i)/2+movex[j]*transition, midpoint.y-itemsize-((float)i)*1/2+offsety[j]*((float)i)/2+movey[j]*transition, 0.0f);
3277 glVertex3f(midpoint.x+itemsize+((float)i)*1/2+offsetx[j]*((float)i)/2+movex[j]*transition, midpoint.y-itemsize-((float)i)*1/2+offsety[j]*((float)i)/2+movey[j]*transition, 0.0f);
3279 glVertex3f(midpoint.x+itemsize+((float)i)*1/2+offsetx[j]*((float)i)/2+movex[j]*transition, midpoint.y+itemsize+((float)i)*1/2+offsety[j]*((float)i)/2+movey[j]*transition, 0.0f);
3281 glVertex3f(midpoint.x-itemsize-((float)i)*1/2+offsetx[j]*((float)i)/2+movex[j]*transition, midpoint.y+itemsize+((float)i)*1/2+offsety[j]*((float)i)/2+movey[j]*transition, 0.0f);
3289 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3291 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3293 if(j-7>=(accountactive?accountactive->getCampaignChoicesMade():0)){
3294 text.glPrintOutlined(0.9,0,0,startx[j]+10,starty[j]-4,menustring[j],0,0.6,640,480);
3295 glDisable(GL_DEPTH_TEST);
3300 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3302 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3305 if(mainmenu==1||mainmenu==2)
3306 if(transition<.1||transition>.9){
3307 glClear(GL_DEPTH_BUFFER_BIT);
3308 glEnable(GL_ALPHA_TEST);
3309 glAlphaFunc(GL_GREATER, 0.001f);
3310 glEnable(GL_TEXTURE_2D);
3311 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3312 glDisable(GL_CULL_FACE);
3313 glDisable(GL_LIGHTING);
3315 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3316 glPushMatrix(); // Store The Projection Matrix
3317 glLoadIdentity(); // Reset The Projection Matrix
3318 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3319 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3320 glPushMatrix(); // Store The Modelview Matrix
3321 glLoadIdentity(); // Reset The Modelview Matrix
3323 glDisable(GL_TEXTURE_2D);
3325 glColor4f(1,0,0,1-(transition*10));
3327 glColor4f(1,0,0,1-((1-transition)*10));
3330 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3334 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3335 glPushMatrix(); // Store The Projection Matrix
3336 glLoadIdentity(); // Reset The Projection Matrix
3337 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
3338 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3339 glPushMatrix(); // Store The Modelview Matrix
3340 glLoadIdentity(); // Reset The Modelview Matrix
3341 glTranslatef(screenwidth/2,screenheight/2,0);
3343 glScalef((float)screenwidth/2,(float)screenheight/2,1);
3344 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3346 glEnable(GL_TEXTURE_2D);
3348 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
3349 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
3351 if(!waiting) { // hide the cursor while waiting for a key
3353 glTranslatef(mousecoordh-screenwidth/2,mousecoordv*-1+screenheight/2,0);
3354 glScalef((float)screenwidth/64,(float)screenwidth/64,1);
3355 glTranslatef(1,-1,0);
3356 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3358 glBindTexture( GL_TEXTURE_2D, cursortexture);
3360 //glScalef(.25,.25,.25);
3363 glVertex3f(-1, -1, 0.0f);
3365 glVertex3f(1, -1, 0.0f);
3367 glVertex3f(1, 1, 0.0f);
3369 glVertex3f(-1, 1, 0.0f);
3375 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3381 //printf("Flash amount: %f, delay %i\n", flashamount, flashdelay);
3382 if(flashamount>1)flashamount=1;
3383 if(flashdelay<=0)flashamount-=multiplier;
3385 if(flashamount<0)flashamount=0;
3386 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3387 glDisable(GL_CULL_FACE);
3388 glDisable(GL_LIGHTING);
3389 glDisable(GL_TEXTURE_2D);
3391 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3392 glPushMatrix(); // Store The Projection Matrix
3393 glLoadIdentity(); // Reset The Projection Matrix
3394 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
3395 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3396 glPushMatrix(); // Store The Modelview Matrix
3397 glLoadIdentity(); // Reset The Modelview Matrix
3398 glScalef(screenwidth,screenheight,1);
3399 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3401 glColor4f(flashr,flashg,flashb,flashamount);
3403 glVertex3f(0, 0, 0.0f);
3404 glVertex3f(256, 0, 0.0f);
3405 glVertex3f(256, 256, 0.0f);
3406 glVertex3f(0, 256, 0.0f);
3408 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3409 glPopMatrix(); // Restore The Old Projection Matrix
3410 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3411 glPopMatrix(); // Restore The Old Projection Matrix
3412 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
3413 glEnable(GL_CULL_FACE);
3414 glDisable(GL_BLEND);
3419 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)||(!gameon&&gamestarted)){
3420 tempmult=multiplier;
3425 if ( side == stereoRight || side == stereoCenter ) {
3426 if(drawmode!=motionblurmode||mainmenu){
3431 //myassert(glGetError() == GL_NO_ERROR);
3432 glDrawBuffer(GL_BACK);
3433 glReadBuffer(GL_BACK);
3438 if(drawtoggle==2)drawtoggle=0;
3440 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)){
3441 multiplier=tempmult;
3443 //Jordan fixed your warning!