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"
29 extern int environment;
30 extern float texscale;
32 extern Terrain terrain;
33 //extern Sprites sprites;
34 extern float multiplier;
36 extern float viewdistance;
37 extern float fadestart;
38 extern float screenwidth,screenheight;
39 extern int kTextureSize;
40 extern FRUSTUM frustum;
42 extern Objects objects;
44 extern float usermousesensitivity;
46 extern float camerashake;
47 extern Weapons weapons;
48 extern Person player[maxplayers];
50 extern float slomodelay;
51 extern bool ismotionblur;
53 extern float blackout;
54 extern bool damageeffects;
56 extern int numplayers;
57 extern bool texttoggle;
58 extern float blurness;
59 extern float targetblurness;
60 extern float playerdist;
61 extern bool cellophane;
63 extern float flashamount,flashr,flashg,flashb;
64 extern int flashdelay;
66 extern float motionbluramount;
68 extern bool alwaysblur;
70 extern bool tilt2weird;
71 extern bool tiltweird;
73 extern bool proportionweird;
74 extern bool vertexweird[6];
75 extern bool velocityblur;
76 extern bool debugmode;
78 extern int oldmainmenu;
79 extern int bloodtoggle;
80 extern int difficulty;
83 //extern int texdetail;
84 extern float texdetail;
85 extern bool musictoggle;
87 extern float bonusvalue;
88 extern float bonustotal;
89 extern float bonustime;
91 extern float startbonustotal;
92 extern float bonusnum[100];
93 extern int tutoriallevel;
94 extern float smoketex;
95 extern float tutorialstagetime;
96 extern float tutorialmaxtime;
97 extern int tutorialstage;
98 extern bool againbonus;
99 extern float damagedealt;
100 extern float damagetaken;
101 extern bool invertmouse;
103 extern int numhotspots;
104 extern int winhotspot;
105 extern int killhotspot;
106 extern XYZ hotspot[40];
107 extern int hotspottype[40];
108 extern float hotspotsize[40];
109 extern char hotspottext[40][256];
110 extern int currenthotspot;;
113 extern int numflipfail;
115 extern int numstaffattack;
116 extern int numswordattack;
117 extern int numknifeattack;
118 extern int numunarmedattack;
119 extern int numescaped;
120 extern int numflipped;
121 extern int numwallflipped;
122 extern int numthrowkill;
123 extern int numafterkill;
124 extern int numreversals;
125 extern int numattacks;
126 extern int maxalarmed;
127 extern int numresponded;
129 extern bool campaign;
130 extern bool winfreeze;
132 extern float menupulse;
134 extern bool gamestart;
136 extern int numdialogues;
137 extern int numdialogueboxes[max_dialogues];
138 extern int dialoguetype[max_dialogues];
139 extern int dialogueboxlocation[max_dialogues][max_dialoguelength];
140 extern float dialogueboxcolor[max_dialogues][max_dialoguelength][3];
141 extern int dialogueboxsound[max_dialogues][max_dialoguelength];
142 extern char dialoguetext[max_dialogues][max_dialoguelength][128];
143 extern char dialoguename[max_dialogues][max_dialoguelength][64];
144 extern XYZ dialoguecamera[max_dialogues][max_dialoguelength];
145 extern XYZ participantlocation[max_dialogues][10];
146 extern int participantfocus[max_dialogues][max_dialoguelength];
147 extern int participantaction[max_dialogues][max_dialoguelength];
148 extern float participantrotation[max_dialogues][10];
149 extern XYZ participantfacing[max_dialogues][max_dialoguelength][10];
150 extern float dialoguecamerarotation[max_dialogues][max_dialoguelength];
151 extern float dialoguecamerarotation2[max_dialogues][max_dialoguelength];
152 extern int indialogue;
153 extern int whichdialogue;
154 extern int directing;
155 extern float dialoguetime;
156 extern int dialoguegonethrough[20];
158 extern bool gamestarted;
160 extern bool showdamagebar;
162 extern OPENAL_SAMPLE *samp[100];
163 extern int channels[100];
164 extern "C" void PlaySoundEx(int channel, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
166 void Game::flash() { // shouldn't be that way, these should be attributes and Person class should not change rendering.
173 /*********************> DrawGLScene() <*****/
174 int Game::DrawGLScene(StereoSide side)
176 static float texcoordwidth,texcoordheight;
177 static float texviewwidth, texviewheight;
179 static GLubyte color;
180 static float newbrightness;
181 static float changespeed;
182 static XYZ checkpoint;
183 static float tempmult;
185 static char string[256]="";
186 static char string2[256]="";
187 static char string3[256]="";
189 static float lastcheck;
191 lastcheck+=multiplier;
193 if ( stereomode == stereoAnaglyph ) {
195 case stereoLeft: glColorMask( 0.0, 1.0, 1.0, 1.0 ); break;
196 case stereoRight: glColorMask( 1.0, 0.0, 0.0, 1.0 ); break;
199 glColorMask( 1.0, 1.0, 1.0, 1.0 );
201 if ( stereomode == stereoHorizontalInterlaced || stereomode == stereoVerticalInterlaced ) {
202 glStencilFunc(side == stereoLeft ? GL_NOTEQUAL : GL_EQUAL, 0x01, 0x01);
206 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)){
213 numboundaries=mapradius*2;
214 if(numboundaries>360)numboundaries=360;
215 for(i=0;i<numboundaries;i++){
218 boundary[i]=mapcenter+DoRotation(boundary[i]*mapradius,0,i*(360/((float)(numboundaries))),0);
227 olddrawmode=drawmode;
228 if(ismotionblur&&!loading){
229 if((findLengthfast(&player[0].velocity)>200)&&velocityblur&&!cameramode){
230 drawmode=motionblurmode;
231 motionbluramount=200/(findLengthfast(&player[0].velocity));
234 if(player[0].damage-player[0].superpermanentdamage>(player[0].damagetolerance-player[0].superpermanentdamage)*1/2&&damageeffects&&!cameramode){
235 drawmode=doublevisionmode;
242 drawmode=motionblurmode;
244 slomodelay-=multiplier;
245 if(slomodelay<0)slomo=0;
249 if((!changed&&!slomo)||loading){
251 if(ismotionblur&&(/*fps>100||*/alwaysblur)){
252 if(olddrawmode!=realmotionblurmode)change=1;
254 drawmode=realmotionblurmode;
256 else if(olddrawmode==realmotionblurmode)change=2;
260 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted))drawmode=normalmode;
261 if((freeze||winfreeze)&&ismotionblur&&!mainmenu)drawmode=radialzoommode;
263 if(winfreeze||mainmenu)drawmode=normalmode;
266 if(drawmode==glowmode){
271 DSpContext_FadeGamma(NULL,200,&color2);
275 if(drawtoggle!=2)drawtoggle=1-drawtoggle;
279 texviewwidth=kTextureSize;
280 if(texviewwidth>screenwidth)texviewwidth=screenwidth;
281 texviewheight=kTextureSize;
282 if(texviewheight>screenheight)texviewheight=screenheight;
284 texcoordwidth=screenwidth/kTextureSize;
285 texcoordheight=screenheight/kTextureSize;
286 if(texcoordwidth>1)texcoordwidth=1;
287 if(texcoordheight>1)texcoordheight=1;
290 glDrawBuffer(GL_BACK);
291 glReadBuffer(GL_BACK);
293 if(abs(blurness-targetblurness)<multiplier*10||abs(blurness-targetblurness)>2){
294 blurness=targetblurness;
295 targetblurness=(float)(abs(Random()%100))/40;
297 if(blurness<targetblurness)
298 blurness+=multiplier*5;
300 blurness-=multiplier*5;
303 static XYZ terrainlight;
304 static float distance;
305 if(drawmode==normalmode)ReSizeGLScene(90,.1f);
306 if(drawmode!=normalmode)glViewport(0,0,texviewwidth,texviewheight);
307 glDepthFunc(GL_LEQUAL);
309 glAlphaFunc(GL_GREATER, 0.0001f);
310 glEnable(GL_ALPHA_TEST);
311 glClearColor(0.25f, 0.25f, 0.25f, 1.0f);
312 glClear(GL_DEPTH_BUFFER_BIT);
314 glMatrixMode (GL_MODELVIEW);
315 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
318 // Move the camera for the current eye's point of view.
319 // Reverse the movement if we're reversing stereo
320 glTranslatef((stereoseparation/2) * side * (stereoreverse ? -1 : 1), 0, 0);
322 if(!cameramode&&!freeze&&!winfreeze){
323 glRotatef(float(Random()%100)/10*camerashake/*+(woozy*woozy)/10*/,0,0,1);
324 glRotatef(rotation2+sin(woozy/2)*(player[0].damage/player[0].damagetolerance)*5,1,0,0);
325 glRotatef(rotation+sin(woozy)*(player[0].damage/player[0].damagetolerance)*5,0,1,0);
327 if(cameramode||freeze||winfreeze){
328 glRotatef(rotation2,1,0,0);
329 glRotatef(rotation,0,1,0);
332 if(environment==desertenvironment){
333 glRotatef((float)(abs(Random()%100))/3000-1,1,0,0);
334 glRotatef((float)(abs(Random()%100))/3000-1,0,1,0);
336 SetUpLight(&light,0);
338 if(environment==desertenvironment&&detail==2)glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, blurness+.4 );
339 if(environment==desertenvironment){
340 glRotatef((float)(abs(Random()%100))/1000,1,0,0);
341 glRotatef((float)(abs(Random()%100))/1000,0,1,0);
344 glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0);
346 glTranslatef(-viewer.x,-viewer.y,-viewer.z);
347 frustum.GetFrustum();
351 static float size,opacity,rotation;
353 for(k=0;k<numplayers;k++){
354 if(!player[k].skeleton.free&&player[k].playerdetail&&player[k].howactive<typesleeping)
355 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)
356 for(i=0;i<player[k].skeleton.num_joints;i++){
357 if(player[k].skeleton.joints[i].label==leftknee||player[k].skeleton.joints[i].label==rightknee||player[k].skeleton.joints[i].label==groin){
358 point=DoRotation(player[k].skeleton.joints[i].position,0,player[k].rotation,0)*player[k].scale+player[k].coords;
360 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;
361 if(k!=0&&tutoriallevel==1){
362 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;
364 terrain.MakeDecal(shadowdecal,point,size,opacity,rotation);
365 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
366 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
367 if(objects.position[j].y<player[k].coords.y||objects.type[j]==tunneltype||objects.type[j]==weirdtype){
368 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);
371 if(k!=0&&tutoriallevel==1){
372 opacity=.2+.2*sin(smoketex*6+i);
374 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
379 if((player[k].skeleton.free||player[k].howactive>=typesleeping)&&player[k].playerdetail)
380 if(frustum.SphereInFrustum(player[k].coords.x,player[k].coords.y,player[k].coords.z,player[k].scale*5)&&player[k].occluded<25)
381 for(i=0;i<player[k].skeleton.num_joints;i++){
382 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){
383 if(player[k].skeleton.free)point=player[k].skeleton.joints[i].position*player[k].scale+player[k].coords;
384 else point=DoRotation(player[k].skeleton.joints[i].position,0,player[k].rotation,0)*player[k].scale+player[k].coords;
386 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;
387 if(k!=0&&tutoriallevel==1){
388 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;
390 terrain.MakeDecal(shadowdecal,point,size,opacity*.7,rotation);
391 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
392 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
393 if(objects.position[j].y<player[k].coords.y||objects.type[j]==tunneltype||objects.type[j]==weirdtype){
394 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);
395 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);
398 if(k!=0&&tutoriallevel==1){
399 opacity=.2+.2*sin(smoketex*6+i);
401 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
407 if(!player[k].playerdetail)
408 if(frustum.SphereInFrustum(player[k].coords.x,player[k].coords.y,player[k].coords.z,player[k].scale*5))
410 point=player[k].coords;
412 opacity=.4-(player[k].coords.y-terrain.getHeight(player[k].coords.x,player[k].coords.z))/5;
413 terrain.MakeDecal(shadowdecal,point,size,opacity*.7,rotation);
414 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
415 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
416 point=DoRotation(player[k].coords-objects.position[j],0,-objects.rotation[j],0);
419 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
425 glEnable(GL_TEXTURE_2D);
427 glEnable(GL_DEPTH_TEST);
428 glEnable(GL_CULL_FACE);
430 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
431 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
432 glBindTexture( GL_TEXTURE_2D, terraintexture);
434 glBindTexture( GL_TEXTURE_2D, terraintexture2);
436 //glBindTexture( GL_TEXTURE_2D, terraintexture3);
437 //glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
440 terrain.drawdecals();
443 glEnable(GL_CULL_FACE);
444 glEnable(GL_LIGHTING);
446 glEnable(GL_TEXTURE_2D);
449 glEnable(GL_COLOR_MATERIAL);
464 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
465 glEnable(GL_CULL_FACE);
466 glCullFace(GL_FRONT);
468 for(k=0;k<numplayers;k++){
469 if(k==0||tutoriallevel!=1){
471 glEnable(GL_LIGHTING);
472 terrainlight=terrain.getLighting(player[k].coords.x,player[k].coords.z);
473 distance=findDistancefast(&viewer,&player[k].coords);
474 distance=(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance;
475 glColor4f(terrainlight.x,terrainlight.y,terrainlight.z,distance);
476 if(distance>=1)glDisable(GL_BLEND);
478 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;
480 if(!player[k].occluded==0)i=checkcollide(viewer,checkpoint,player[k].lastoccluded);
481 if(i==-1||player[k].occluded==0)i=checkcollide(viewer,checkpoint);
483 player[k].occluded+=1;
484 player[k].lastoccluded=i;
486 else player[k].occluded=0;
487 if(player[k].occluded<25)player[k].DrawSkeleton();
493 if(!cameramode&&musictype==stream_music2)playerdist=findDistancefastflat(&player[0].coords,&viewer);
494 else playerdist=-100;
497 glEnable(GL_TEXTURE_2D);
502 if(frustum.SphereInFrustum(realhawkcoords.x+hawk.boundingspherecenter.x,realhawkcoords.y+hawk.boundingspherecenter.y,realhawkcoords.z+hawk.boundingspherecenter.z,2)){
503 glAlphaFunc(GL_GREATER, 0.0001f);
505 glDisable(GL_CULL_FACE);
506 glDisable(GL_LIGHTING);
508 glTranslatef(hawkcoords.x,hawkcoords.y,hawkcoords.z);
509 glRotatef(hawkrotation,0,1,0);
510 glTranslatef(25,0,0);
511 distance=findDistancefast(&viewer,&realhawkcoords)*1.2;
512 glColor4f(light.color[0],light.color[1],light.color[2],(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance);
513 if((viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance>1)glColor4f(light.color[0],light.color[1],light.color[2],1);
514 if((viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance>0)
515 hawk.drawdifftex(hawktexture);
519 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
520 glEnable(GL_CULL_FACE);
521 glCullFace(GL_FRONT);
523 for(k=0;k<numplayers;k++){
524 if(!(k==0||tutoriallevel!=1)){
526 glEnable(GL_LIGHTING);
527 terrainlight=terrain.getLighting(player[k].coords.x,player[k].coords.z);
528 distance=findDistancefast(&viewer,&player[k].coords);
529 distance=(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance;
530 glColor4f(terrainlight.x,terrainlight.y,terrainlight.z,distance);
531 if(distance>=1)glDisable(GL_BLEND);
533 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;
535 if(!player[k].occluded==0)i=checkcollide(viewer,checkpoint,player[k].lastoccluded);
536 if(i==-1||player[k].occluded==0)i=checkcollide(viewer,checkpoint);
538 player[k].occluded+=1;
539 player[k].lastoccluded=i;
541 else player[k].occluded=0;
542 if(player[k].occluded<25)player[k].DrawSkeleton();
548 glEnable(GL_TEXTURE_2D);
553 glDisable(GL_COLOR_MATERIAL);
555 glDisable(GL_LIGHTING);
556 glDisable(GL_TEXTURE_2D);
564 glDisable(GL_LIGHTING);
565 glDisable(GL_TEXTURE_2D);
566 glDisable(GL_COLOR_MATERIAL);
569 for(k=0;k<numplayers;k++){
570 if(player[k].numwaypoints>1){
571 glBegin(GL_LINE_LOOP);
572 for(i=0;i<player[k].numwaypoints;i++){
573 glVertex3f(player[k].waypoints[i].x,player[k].waypoints[i].y+.5,player[k].waypoints[i].z);
582 for(k=0;k<numpathpoints;k++){
583 if(numpathpointconnect[k]){
584 for(i=0;i<numpathpointconnect[k];i++){
585 glBegin(GL_LINE_LOOP);
586 glVertex3f(pathpoint[k].x,pathpoint[k].y+.5,pathpoint[k].z);
587 glVertex3f(pathpoint[pathpointconnect[k][i]].x,pathpoint[pathpointconnect[k][i]].y+.5,pathpoint[pathpointconnect[k][i]].z);
595 glVertex3f(pathpoint[pathpointselected].x,pathpoint[pathpointselected].y+.5,pathpoint[pathpointselected].z);
602 glEnable(GL_TEXTURE_2D);
603 glColor4f(.5,.5,.5,1);
605 sprintf (string, " ",(int)(fps));
606 text.glPrint(10,30,string,0,.8,screenwidth,screenheight);
609 if(bonus>0&&bonustime<1&&!winfreeze&&indialogue==-1/*bonustime<4*/){
610 if(bonus==tracheotomy)sprintf (string, "Tracheotomy!");
611 else if(bonus==backstab)sprintf (string, "Backstabber!");
612 else if(bonus==spinecrusher)sprintf (string, "Spinecrusher!");
613 else if(bonus==ninja)sprintf (string, "Ninja Bonus!");
614 else if(bonus==style)sprintf (string, "Style Bonus!");
615 else if(bonus==cannon)sprintf (string, "Leg Cannon!");
616 else if(bonus==aimbonus)sprintf (string, "Nice Aim!");
617 else if(bonus==deepimpact)sprintf (string, "Heavy Impact!");
618 else if(bonus==touchofdeath)sprintf (string, "Touch of Death!");
619 else if(bonus==swordreversebonus)sprintf (string, "Sword Disarm!");
620 else if(bonus==staffreversebonus)sprintf (string, "Staff Disarm!");
621 else if(bonus==reverseko)sprintf (string, "Reversal KO!");
622 else if(bonus==solidhit)sprintf (string, "Solid Hit!");
623 else if(bonus==twoxcombo)sprintf (string, "2X Combo!");
624 else if(bonus==threexcombo)sprintf (string, "3X Combo!");
625 else if(bonus==fourxcombo)sprintf (string, "4X COMBO!");
626 else if(bonus==megacombo)sprintf (string, "MEGA COMBO!");
627 else if(bonus==Reversal)sprintf (string, "Reversal!");
628 else if(bonus==Stabbonus)sprintf (string, "Punctured!");
629 else if(bonus==Slicebonus)sprintf (string, "Sliced!");
630 else if(bonus==Bullseyebonus)sprintf (string, "Bullseye!");
631 else if(bonus==Slashbonus)sprintf (string, "Slashed!");
632 else if(bonus==Wolfbonus)sprintf (string, "WOLF SLAYER!");
633 else if(bonus==FinishedBonus)sprintf (string, "SLAIN!");
634 else if(bonus==TackleBonus)sprintf (string, "Tackle!");
635 else if(bonus==AboveBonus)sprintf (string, "Death from Above!");
636 else sprintf (string, "Excellent!");
638 glColor4f(0,0,0,1-bonustime);
639 text.glPrintOutline(1024/2-10*strlen(string)-4,768/16-4+768*4/5,string,1,2.5,1024,768);
640 glColor4f(1,0,0,1-bonustime);
641 text.glPrint(1024/2-10*strlen(string),768/16+768*4/5,string,1,2,1024,768);
643 sprintf (string, "%d",(int)bonusvalue);
644 glColor4f(0,0,0,1-bonustime);
645 text.glPrintOutline(1024/2-10*strlen(string)-4,768/16-4-20+768*4/5,string,1,2.5*.8,1024,768);
646 glColor4f(1,0,0,1-bonustime);
647 text.glPrint(1024/2-10*strlen(string),768/16-20+768*4/5,string,1,2*.8,1024,768);
648 glColor4f(.5,.5,.5,1);
651 if(tutoriallevel==1){
652 tutorialopac=tutorialmaxtime-tutorialstagetime;
653 if(tutorialopac>1)tutorialopac=1;
654 if(tutorialopac<0)tutorialopac=0;
656 sprintf (string, " ");
657 sprintf (string2, " ");
658 sprintf (string3, " ");
659 if(tutorialstage==0){
660 sprintf (string, " ");
661 sprintf (string2, " ");
662 sprintf (string3, " ");
664 if(tutorialstage==1){
665 sprintf (string, "Welcome to the Lugaru training level!");
666 sprintf (string2, " ");
667 sprintf (string3, " ");
669 if(tutorialstage==2){
670 sprintf (string, "BASIC MOVEMENT:");
671 sprintf (string2, " ");
672 sprintf (string3, " ");
674 if(tutorialstage==3){
675 sprintf (string, "You can move the mouse to rotate the camera.");
676 sprintf (string2, " ");
677 sprintf (string3, " ");
679 if(tutorialstage==4){
680 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));
681 sprintf (string2, "All movement is relative to the camera.");
682 sprintf (string3, " ");
684 if(tutorialstage==5){
685 sprintf (string, "Please press %s to jump.",Input::keyToChar(jumpkey));
686 sprintf (string2, "You can hold it longer to jump higher.");
687 sprintf (string3, " ");
689 if(tutorialstage==6){
690 sprintf (string, "You can press %s to crouch.",Input::keyToChar(crouchkey));
691 sprintf (string2, "You can jump higher from a crouching position.");
692 sprintf (string3, " ");
694 if(tutorialstage==7){
695 sprintf (string, "While running, you can press %s to roll.",Input::keyToChar(crouchkey));
696 sprintf (string2, " ");
697 sprintf (string3, " ");
699 if(tutorialstage==8){
700 sprintf (string, "While crouching, you can sneak around silently");
701 sprintf (string2, "using the movement keys.");
702 sprintf (string3, " ");
704 if(tutorialstage==9){
705 sprintf (string, "Release the crouch key while sneaking and hold the movement keys");
706 sprintf (string2, "to run animal-style.");
707 sprintf (string3, " ");
709 if(tutorialstage==10){
710 sprintf (string, "ADVANCED MOVEMENT:");
711 sprintf (string2, " ");
712 sprintf (string3, " ");
714 if(tutorialstage==11){
715 sprintf (string, "When you jump at a wall, you can hold %s again",Input::keyToChar(jumpkey));
716 sprintf (string2, "during impact to perform a walljump.");
717 sprintf (string3, "Be sure to use the movement keys to press against the wall");
719 if(tutorialstage==12){
720 sprintf (string, "While in the air, you can press crouch to flip.",Input::keyToChar(jumpkey));
721 sprintf (string2, "Walljumps and flips confuse enemies and give you more control.");
722 sprintf (string3, " ");
724 if(tutorialstage==13){
725 sprintf (string, "BASIC COMBAT:");
726 sprintf (string2, " ");
727 sprintf (string3, " ");
729 if(tutorialstage==14){
730 sprintf (string, "There is now an imaginary enemy");
731 sprintf (string2, "in the middle of the training area.");
732 sprintf (string3, " ");
734 if(tutorialstage==15){
735 if(attackkey==MOUSEBUTTON1)sprintf (string, "Click to attack when you are near an enemy.");
736 else sprintf (string, "Press %s to attack when you are near an enemy.",Input::keyToChar(attackkey));
737 sprintf (string2, "You can punch by standing still near an enemy and attacking.");
738 sprintf (string3, " ");
740 if(tutorialstage==16){
741 sprintf (string, "If you are close, you will perform a weak punch.");
742 sprintf (string2, "The weak punch is excellent for starting attack combinations.");
743 sprintf (string3, " ");
745 if(tutorialstage==17){
746 sprintf (string, "Attacking while running results in a spin kick.");
747 sprintf (string2, "This is one of your most powerful ground attacks.");
748 sprintf (string3, " ");
750 if(tutorialstage==18){
751 sprintf (string, "Sweep the enemy's legs out by attacking while crouched.");
752 sprintf (string2, "This is a very fast attack, and easy to follow up.");
753 sprintf (string3, " ");
755 if(tutorialstage==19){
756 sprintf (string, "When an enemy is on the ground, you can deal some extra");
757 sprintf (string2, "damage by running up and drop-kicking him.");
758 sprintf (string3, "(Try knocking them down with a sweep first)");
760 if(tutorialstage==20){
761 sprintf (string, "Your most powerful individual attack is the rabbit kick.");
762 if(attackkey==MOUSEBUTTON1)sprintf (string2, "Run at the enemy while holding the mouse button, and press");
763 else sprintf (string2, "Run at the enemy while holding %s, and press", Input::keyToChar(attackkey));
764 sprintf (string3, "the jump key (%s) to attack.",Input::keyToChar(jumpkey));
766 if(tutorialstage==21){
767 sprintf (string, "This attack is devastating if timed correctly.");
768 sprintf (string2, "Even if timed incorrectly, it will knock the enemy over.");
769 if(againbonus)sprintf (string3, "Try rabbit-kicking the imaginary enemy again.");
770 else sprintf (string3, "Try rabbit-kicking the imaginary enemy.");
772 if(tutorialstage==22){
773 sprintf (string, "If you sneak behind an enemy unnoticed, you can kill");
774 sprintf (string2, "him instantly. Move close behind this enemy");
775 sprintf (string3, "and attack.");
777 if(tutorialstage==23){
778 sprintf (string, "Another important attack is the wall kick. When an enemy");
779 sprintf (string2, "is near a wall, perform a walljump nearby and hold");
780 sprintf (string3, "the attack key during impact with the wall.");
782 if(tutorialstage==24){
783 sprintf (string, "You can tackle enemies by running at them animal-style");
784 if(attackkey==MOUSEBUTTON1)sprintf (string2, "and pressing jump (%s) or attack(mouse button).",Input::keyToChar(jumpkey));
785 else sprintf (string2, "and pressing jump (%s) or attack(%s).",Input::keyToChar(jumpkey),Input::keyToChar(attackkey));
786 sprintf (string3, "This is especially useful when they are running away.");
788 if(tutorialstage==25){
789 sprintf (string, "Dodge by pressing back and attack. Dodging is essential");
790 sprintf (string2, "against enemies with swords or other long weapons.");
791 sprintf (string3, " ");
793 if(tutorialstage==26){
794 sprintf (string, "REVERSALS AND COUNTER-REVERSALS");
795 sprintf (string2, " ");
796 sprintf (string3, " ");
798 if(tutorialstage==27){
799 sprintf (string, "The enemy can now reverse your attacks.");
800 sprintf (string2, " ");
801 sprintf (string3, " ");
803 if(tutorialstage==28){
804 sprintf (string, "If you attack, you will notice that the enemy now sometimes");
805 sprintf (string2, "catches your attack and uses it against you. Hold");
806 sprintf (string3, "crouch (%s) after attacking to escape from reversals.",Input::keyToChar(crouchkey));
808 if(tutorialstage==29){
809 sprintf (string, "Try escaping from two more reversals in a row.");
810 sprintf (string2, " ");
811 sprintf (string3, " ");
813 if(tutorialstage==30){
814 sprintf (string, "Good!");
815 sprintf (string2, " ");
816 sprintf (string3, " ");
818 if(tutorialstage==31){
819 sprintf (string, "To reverse an attack, you must tap crouch (%s) during the",Input::keyToChar(crouchkey));
820 sprintf (string2, "enemy's attack. You must also be close to the enemy;");
821 sprintf (string3, "this is especially important against armed opponents.");
823 if(tutorialstage==32){
824 sprintf (string, "The enemy can attack in %d seconds.", (int)(tutorialmaxtime-tutorialstagetime));
825 sprintf (string2, "This imaginary opponents attacks will be highlighted");
826 sprintf (string3, "to make this easier.");
828 if(tutorialstage==33){
829 sprintf (string, "Reverse three enemy attacks!");
830 sprintf (string2, " ");
831 sprintf (string3, " ");
833 if(tutorialstage==34){
834 sprintf (string, "Reverse two more enemy attacks!");
835 sprintf (string2, " ");
836 sprintf (string3, " ");
838 if(tutorialstage==35){
839 sprintf (string, "Reverse one more enemy attack!");
840 sprintf (string2, " ");
841 sprintf (string3, " ");
843 if(tutorialstage==36){
844 sprintf (string, "Excellent!");
845 sprintf (string2, " ");
846 sprintf (string3, " ");
848 if(tutorialstage==37){
849 sprintf (string, "Now spar with the enemy for %d more seconds.", (int)(tutorialmaxtime-tutorialstagetime));
850 sprintf (string2, "Damage dealt: %d",(int)damagedealt);
851 sprintf (string3, "Damage taken: %d.",(int)damagetaken);
853 if(tutorialstage==38){
854 sprintf (string, "WEAPONS:");
855 sprintf (string2, " ");
856 sprintf (string3, " ");
858 if(tutorialstage==39){
859 sprintf (string, "There is now an imaginary knife");
860 sprintf (string2, "in the center of the training area.");
861 sprintf (string3, " ");
863 if(tutorialstage==40){
864 sprintf (string, "Stand, roll or handspring over the knife");
865 sprintf (string2, "while pressing %s to pick it up.",Input::keyToChar(throwkey));
866 sprintf (string3, "You can crouch and press the same key to drop it again.");
868 if(tutorialstage==41){
869 sprintf (string, "You can equip and unequip weapons using the %s key.",Input::keyToChar(drawkey));
870 sprintf (string2, "Sometimes it is best to keep them unequipped to");
871 sprintf (string3, "prevent enemies from taking them. ");
873 if(tutorialstage==42){
874 sprintf (string, "The knife is the smallest weapon and the least encumbering.");
875 sprintf (string2, "You can equip or unequip it while standing, crouching,");
876 sprintf (string3, "running or flipping.");
878 if(tutorialstage==43){
879 sprintf (string, "You perform weapon attacks the same way as unarmed attacks,");
880 sprintf (string2, "but sharp weapons cause permanent damage, instead of the");
881 sprintf (string3, "temporary trauma from blunt weapons, fists and feet.");
883 if(tutorialstage==44){
884 sprintf (string, "The enemy now has your knife!");
885 sprintf (string2, "Please reverse two of his knife attacks.");
886 sprintf (string3, " ");
888 if(tutorialstage==45){
889 sprintf (string, "Please reverse one more of his knife attacks.");
890 sprintf (string2, " ");
891 sprintf (string3, " ");
893 if(tutorialstage==46){
894 sprintf (string, "Now he has a sword!");
895 sprintf (string2, "The sword has longer reach than your arms, so you");
896 sprintf (string3, "must move close to reverse the sword slash.");
898 if(tutorialstage==47){
899 sprintf (string, "Long weapons like the sword and staff are also useful for defense;");
900 sprintf (string2, "you can parry enemy weapon attacks by pressing the attack key");
901 sprintf (string3, "at the right time. Please try parrying the enemy's attacks!");
903 if(tutorialstage==48){
904 sprintf (string, "The staff is like the sword, but has two main attacks.");
905 sprintf (string2, "The standing smash is fast and effective, and the running");
906 sprintf (string3, "spin smash is slower and more powerful.");
908 if(tutorialstage==49){
909 sprintf (string, "When facing an enemy, you can throw the knife with %s.",Input::keyToChar(throwkey));
910 sprintf (string2, "It is possible to throw the knife while flipping,");
911 sprintf (string3, "but it is very inaccurate.");
913 if(tutorialstage==50){
914 sprintf (string, "You now know everything you can learn from training.");
915 sprintf (string2, "Everything else you must learn from experience!");
916 sprintf (string3, " ");
918 if(tutorialstage==51){
919 sprintf (string, "Walk out of the training area to return to the main menu.");
920 sprintf (string2, " ");
921 sprintf (string3, " ");
924 glColor4f(0,0,0,tutorialopac);
925 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);
926 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);
927 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);
928 glColor4f(1,1,1,tutorialopac);
929 text.glPrint(screenwidth/2-7.6*strlen(string)*screenwidth/1024,screenheight/16+screenheight*4/5,string,1,1.5*screenwidth/1024,screenwidth,screenheight);
930 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);
931 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);
933 sprintf (string, "Press 'tab' to skip to the next item.",Input::keyToChar(jumpkey));
934 sprintf (string2, "Press escape at any time to");
935 sprintf (string3, "pause or exit the tutorial.");
938 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);
939 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);
940 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);
941 glColor4f(0.5,0.5,0.5,1);
942 text.glPrint(screenwidth/2-7.6*strlen(string)*screenwidth/1024*.8,0+screenheight*1/10,string,1,1.5*screenwidth/1024*.8,screenwidth,screenheight);
943 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);
944 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);
948 if(numhotspots&&(bonustime>=1||bonus<=0||bonustime<0)&&!tutoriallevel){
950 float closestdist=-1;
952 closest=currenthotspot;
953 for(i=0;i<numhotspots;i++){
954 distance=findDistancefast(&player[0].coords,&hotspot[i]);
955 if(closestdist==-1||distance<closestdist){
956 if(findDistancefast(&player[0].coords,&hotspot[i])<hotspotsize[i]&&((hotspottype[i]<=10&&hotspottype[i]>=0)||(hotspottype[i]<=40&&hotspottype[i]>=20))){
957 closestdist=distance;
963 currenthotspot=closest;
964 if(currenthotspot!=-1){
965 if(hotspottype[closest]<=10){
966 if(findDistancefast(&player[0].coords,&hotspot[closest])<hotspotsize[closest])
969 tutorialopac=tutorialmaxtime-tutorialstagetime;
970 if(tutorialopac>1)tutorialopac=1;
971 if(tutorialopac<0)tutorialopac=0;
973 sprintf (string, "%s", hotspottext[closest]);
980 if(string[i]=='\n'||string[i]>'z'||string[i]<' '||string[i]=='\0'){
981 glColor4f(0,0,0,tutorialopac);
982 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);
983 glColor4f(1,1,1,tutorialopac);
984 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);
987 if(string[i]=='\0')done=1;
993 else if (hotspottype[closest]>=20&&dialoguegonethrough[hotspottype[closest]-20]==0){
994 whichdialogue=hotspottype[closest]-20;
995 for(j=0;j<numdialogueboxes[whichdialogue];j++){
996 player[participantfocus[whichdialogue][j]].coords=participantlocation[whichdialogue][participantfocus[whichdialogue][j]];
997 player[participantfocus[whichdialogue][j]].rotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
998 player[participantfocus[whichdialogue][j]].targetrotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
999 player[participantfocus[whichdialogue][j]].velocity=0;
1000 player[participantfocus[whichdialogue][j]].targetanimation=player[participantfocus[whichdialogue][j]].getIdle();
1001 player[participantfocus[whichdialogue][j]].targetframe=0;
1005 dialoguegonethrough[whichdialogue]++;
1006 if(dialogueboxsound[whichdialogue][indialogue]!=0){
1007 static float gLoc[3];
1008 static float vel[3];
1009 gLoc[0]=player[participantfocus[whichdialogue][indialogue]].coords.x;
1010 gLoc[1]=player[participantfocus[whichdialogue][indialogue]].coords.y;
1011 gLoc[2]=player[participantfocus[whichdialogue][indialogue]].coords.z;
1016 if(dialogueboxsound[whichdialogue][indialogue]==1)whichsoundplay=rabbitchitter;
1017 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
1018 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
1019 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
1020 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
1021 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
1022 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
1023 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
1024 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
1025 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
1026 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
1027 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
1028 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
1029 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
1030 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
1031 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
1032 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
1033 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
1034 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
1035 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
1036 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, true);
1037 OPENAL_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
1038 OPENAL_SetVolume(channels[whichsoundplay], 256);
1039 OPENAL_SetPaused(channels[whichsoundplay], false);
1045 if(indialogue!=-1&&!mainmenu){
1046 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1047 glDisable(GL_CULL_FACE);
1048 glDisable(GL_LIGHTING);
1049 glDisable(GL_TEXTURE_2D);
1051 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1052 glPushMatrix(); // Store The Projection Matrix
1053 glLoadIdentity(); // Reset The Projection Matrix
1054 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1055 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1056 glPushMatrix(); // Store The Modelview Matrix
1057 glLoadIdentity(); // Reset The Modelview Matrix
1058 if(dialogueboxlocation[whichdialogue][indialogue]==1)glTranslatef(0,screenheight*3/4,0);
1059 glScalef(screenwidth,screenheight/4,1);
1060 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1063 glColor4f(dialogueboxcolor[whichdialogue][indialogue][0],dialogueboxcolor[whichdialogue][indialogue][1],dialogueboxcolor[whichdialogue][indialogue][2],0.7);
1065 glVertex3f(0, 0, 0.0f);
1066 glVertex3f(1, 0, 0.0f);
1067 glVertex3f(1, 1, 0.0f);
1068 glVertex3f(0, 1, 0.0f);
1070 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1071 glPopMatrix(); // Restore The Old Projection Matrix
1072 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1073 glPopMatrix(); // Restore The Old Projection Matrix
1074 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1075 glEnable(GL_CULL_FACE);
1076 glDisable(GL_BLEND);
1078 glEnable(GL_TEXTURE_2D);
1085 startx=screenwidth*1/5;
1086 if(dialogueboxlocation[whichdialogue][indialogue]==1)starty=screenheight/16+screenheight*4/5;
1087 if(dialogueboxlocation[whichdialogue][indialogue]==2)starty=screenheight*1/5-screenheight/16;
1096 for(i=0;i<(int)strlen(dialoguename[whichdialogue][indialogue]);i++){
1097 tempname[tempnum]=dialoguename[whichdialogue][indialogue][i];
1099 if(dialoguename[whichdialogue][indialogue][i]=='#'||dialoguename[whichdialogue][indialogue][i]=='\0')goodchar=0;
1103 tempname[tempnum]='\0';
1106 sprintf (string, "%s: ", tempname);
1108 if(dialogueboxcolor[whichdialogue][indialogue][0]+dialogueboxcolor[whichdialogue][indialogue][1]+dialogueboxcolor[whichdialogue][indialogue][2]<1.5){
1109 glColor4f(0,0,0,tutorialopac);
1110 text.glPrintOutline(startx-2*7.6*strlen(string)*screenwidth/1024-4,starty-4,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight);
1111 glColor4f(0.7,0.7,0.7,tutorialopac);
1112 text.glPrint(startx-2*7.6*strlen(string)*screenwidth/1024,starty,string,1,1.5*screenwidth/1024,screenwidth,screenheight);
1116 glColor4f(0,0,0,tutorialopac);
1117 text.glPrintOutline(startx-2*7.6*strlen(string)*screenwidth/1024-4,starty-4,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight);
1121 for(i=0;i<(int)strlen(dialoguetext[whichdialogue][indialogue])+1;i++){
1122 tempname[tempnum]=dialoguetext[whichdialogue][indialogue][i];
1123 if(dialoguetext[whichdialogue][indialogue][i]!='#')tempnum++;
1126 sprintf (string, "%s", tempname);
1133 if(string[i]=='\n'||string[i]>'z'||string[i]<' '||string[i]=='\0'){
1134 if(dialogueboxcolor[whichdialogue][indialogue][0]+dialogueboxcolor[whichdialogue][indialogue][1]+dialogueboxcolor[whichdialogue][indialogue][2]<1.5){
1135 glColor4f(0,0,0,tutorialopac);
1136 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);
1137 glColor4f(1,1,1,tutorialopac);
1138 text.glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/,starty-20*screenwidth/1024*line,string,1,1.5*screenwidth/1024,screenwidth,screenheight,lastline,i);
1142 glColor4f(0,0,0,tutorialopac);
1143 text.glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/,starty-20*screenwidth/1024*line,string,1,1.5*screenwidth/1024,screenwidth,screenheight,lastline,i);
1147 if(string[i]=='\0')done=1;
1154 if(!tutoriallevel&&!winfreeze&&indialogue==-1&&!mainmenu){
1157 sprintf (string, "Score: %d", (int)accountactive->getCampaignScore());
1159 sprintf (string, "Score: %d", (int)accountactive->getCampaignScore()+(int)bonustotal);
1161 if(!campaign)sprintf (string, "Score: %d", (int)bonustotal);
1163 text.glPrintOutline(1024/40-4,768/16-4+768*14/16,string,1,1.5*1.25,1024,768);
1165 text.glPrint(1024/40,768/16+768*14/16,string,1,1.5,1024,768);
1167 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1168 glDisable(GL_CULL_FACE);
1169 glDisable(GL_LIGHTING);
1170 glDisable(GL_TEXTURE_2D);
1172 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1173 glPushMatrix(); // Store The Projection Matrix
1174 glLoadIdentity(); // Reset The Projection Matrix
1175 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1176 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1177 glPushMatrix(); // Store The Modelview Matrix
1178 glLoadIdentity(); // Reset The Modelview Matrix
1179 glTranslatef(15,screenheight*17.5/20,0);
1180 glScalef(screenwidth/3+20,screenheight/20,1);
1181 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1183 glColor4f(0.0,0.4,0.0,0.7);
1184 float bar=((float)player[0].damage)/player[0].damagetolerance;
1186 glVertex3f((bar<1?bar:1),0,0.0f);
1187 glVertex3f(1,0,0.0f);
1188 glVertex3f(1,1,0.0f);
1189 glVertex3f((bar<1?bar:1),1,0.0f);
1191 glColor4f(0.1,0.0,0.0,1);
1192 bar = ((float)player[0].bloodloss)/player[0].damagetolerance;
1194 glVertex3f(0,0,0.0f);
1195 glVertex3f((bar<1?bar:1),0,0.0f);
1196 glVertex3f((bar<1?bar:1),1,0.0f);
1197 glVertex3f(0,1,0.0f);
1199 glColor4f(0.4,0.0,0.0,0.7);
1200 bar = ((float)player[0].damage)/player[0].damagetolerance;
1202 glVertex3f(0,0,0.0f);
1203 glVertex3f((bar<1?bar:1),0,0.0f);
1204 glVertex3f((bar<1?bar:1),1,0.0f);
1205 glVertex3f(0,1,0.0f);
1207 glColor4f(0.4,0.0,0.0,0.7);
1208 bar = ((float)player[0].permanentdamage)/player[0].damagetolerance;
1210 glVertex3f(0,0,0.0f);
1211 glVertex3f((bar<1?bar:1),0,0.0f);
1212 glVertex3f((bar<1?bar:1),1,0.0f);
1213 glVertex3f(0,1,0.0f);
1215 glColor4f(0.4,0.0,0.0,0.7);
1216 bar = ((float)player[0].superpermanentdamage)/player[0].damagetolerance;
1218 glVertex3f(0,0,0.0f);
1219 glVertex3f((bar<1?bar:1),0,0.0f);
1220 glVertex3f((bar<1?bar:1),1,0.0f);
1221 glVertex3f(0,1,0.0f);
1223 glColor4f(0.0,0.0,0.0,0.7);
1225 glBegin(GL_LINE_STRIP);
1226 glVertex3f(0,0,0.0f);
1227 glVertex3f(1,0,0.0f);
1228 glVertex3f(1,1,0.0f);
1229 glVertex3f(0,1,0.0f);
1230 glVertex3f(0,0,0.0f);
1233 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1234 glPopMatrix(); // Restore The Old Projection Matrix
1235 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1236 glPopMatrix(); // Restore The Old Projection Matrix
1237 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1238 glEnable(GL_CULL_FACE);
1239 glDisable(GL_BLEND);
1241 glEnable(GL_TEXTURE_2D);
1243 // writing the numbers :
1244 sprintf (string, "Damages : %d/%d (%d)",(int)(player[0].damage),(int)(player[0].damagetolerance),(int)(player[0].bloodloss));
1246 text.glPrintOutline(1024/40-4,768/16-4+768*14/16-40,string,1,1.5*1.25,1024,768);
1248 text.glPrint(1024/40,768/16+768*14/16-40,string,1,1.5,1024,768);
1252 glColor4f(.5,.5,.5,1);
1255 if((texttoggle||editorenabled)&&debugmode&&!mainmenu){
1256 sprintf (string, "The framespersecond is %d.",(int)(fps));
1257 text.glPrint(10,30,string,0,.8,1024,768);
1259 sprintf (string, "Name: %s", registrationname);
1260 text.glPrint(10,260,string,0,.8,1024,768);
1264 sprintf (string, "Map editor enabled.");
1266 sprintf (string, "Map editor disabled.");
1267 text.glPrint(10,60,string,0,.8,1024,768);
1269 sprintf (string, "Object size: %f",editorsize);
1270 text.glPrint(10,75,string,0,.8,1024,768);
1271 if(editorrotation>=0)sprintf (string, "Object rotation: %f",editorrotation);
1272 else sprintf (string, "Object rotation: Random");
1273 text.glPrint(10,90,string,0,.8,1024,768);
1274 if(editorrotation2>=0)sprintf (string, "Object rotation2: %f",editorrotation2);
1275 else sprintf (string, "Object rotation2: Random");
1276 text.glPrint(10,105,string,0,.8,1024,768);
1277 sprintf (string, "Object type: %d",editortype);
1278 text.glPrint(10,120,string,0,.8,1024,768);
1279 switch(editortype) {
1281 sprintf (string, "(box)");
1284 sprintf (string, "(tree)");
1287 sprintf (string, "(wall)");
1290 sprintf (string, "(weird)");
1293 sprintf (string, "(spike)");
1296 sprintf (string, "(rock)");
1299 sprintf (string, "(bush)");
1302 sprintf (string, "(tunnel)");
1305 sprintf (string, "(chimney)");
1308 sprintf (string, "(platform)");
1311 sprintf (string, "(cool)");
1314 sprintf (string, "(fire)");
1317 text.glPrint(130,120,string,0,.8,1024,768);
1319 sprintf (string, "Numplayers: %d",numplayers);
1320 text.glPrint(10,155,string,0,.8,1024,768);
1321 sprintf (string, "Player %d: numwaypoints: %d",numplayers,player[numplayers-1].numwaypoints);
1322 text.glPrint(10,140,string,0,.8,1024,768);
1324 sprintf (string, "Difficulty: %d",difficulty);
1325 text.glPrint(10,240,string,0,.8,1024,768);
1330 if(drawmode==glowmode){
1331 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1332 glDisable(GL_CULL_FACE);
1333 glDisable(GL_LIGHTING);
1334 glDisable(GL_TEXTURE_2D);
1336 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1337 glPushMatrix(); // Store The Projection Matrix
1338 glLoadIdentity(); // Reset The Projection Matrix
1339 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1340 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1341 glPushMatrix(); // Store The Modelview Matrix
1342 glLoadIdentity(); // Reset The Modelview Matrix
1343 glScalef(screenwidth,screenheight,1);
1344 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1346 glColor4f(0,0,0,.5);
1348 glVertex3f(0, 0, 0.0f);
1349 glVertex3f(256, 0, 0.0f);
1350 glVertex3f(256, 256, 0.0f);
1351 glVertex3f(0, 256, 0.0f);
1353 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1354 glPopMatrix(); // Restore The Old Projection Matrix
1355 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1356 glPopMatrix(); // Restore The Old Projection Matrix
1357 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1358 glEnable(GL_CULL_FACE);
1359 glDisable(GL_BLEND);
1363 if((((blackout&&damageeffects)||(player[0].bloodloss>0&&damageeffects&&player[0].blooddimamount>0)||player[0].dead)&&!cameramode)||console){
1364 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1365 glDisable(GL_CULL_FACE);
1366 glDisable(GL_LIGHTING);
1367 glDisable(GL_TEXTURE_2D);
1369 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1370 glPushMatrix(); // Store The Projection Matrix
1371 glLoadIdentity(); // Reset The Projection Matrix
1372 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1373 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1374 glPushMatrix(); // Store The Modelview Matrix
1375 glLoadIdentity(); // Reset The Modelview Matrix
1376 glScalef(screenwidth,screenheight,1);
1377 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1379 if(player[0].dead)blackout+=multiplier*3;
1380 if(player[0].dead==1)blackout=.4f;
1381 if(player[0].dead==2&&blackout>.6)blackout=.6;
1382 glColor4f(0,0,0,blackout);
1383 if(!player[0].dead){
1384 if((player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5))*.3<.3){
1385 glColor4f(0,0,0,player[0].blooddimamount*player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5)*.3);
1386 blackout=player[0].blooddimamount*player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5)*.3;
1389 glColor4f(0,0,0,player[0].blooddimamount*.3);
1390 blackout=player[0].blooddimamount*.3;
1393 if(console)glColor4f(.7,0,0,.2);
1395 glVertex3f(0, 0, 0.0f);
1396 glVertex3f(256, 0, 0.0f);
1397 glVertex3f(256, 256, 0.0f);
1398 glVertex3f(0, 256, 0.0f);
1400 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1401 glPopMatrix(); // Restore The Old Projection Matrix
1402 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1403 glPopMatrix(); // Restore The Old Projection Matrix
1404 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1405 glEnable(GL_CULL_FACE);
1406 glDisable(GL_BLEND);
1410 if(flashamount>0&&damageeffects){
1411 if(flashamount>1)flashamount=1;
1412 if(flashdelay<=0)flashamount-=multiplier;
1414 if(flashamount<0)flashamount=0;
1415 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1416 glDisable(GL_CULL_FACE);
1417 glDisable(GL_LIGHTING);
1419 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1420 glPushMatrix(); // Store The Projection Matrix
1421 glLoadIdentity(); // Reset The Projection Matrix
1422 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1423 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1424 glPushMatrix(); // Store The Modelview Matrix
1425 glLoadIdentity(); // Reset The Modelview Matrix
1426 glScalef(screenwidth,screenheight,1);
1427 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1429 glColor4f(flashr,flashg,flashb,flashamount);
1431 glVertex3f(0, 0, 0.0f);
1432 glVertex3f(256, 0, 0.0f);
1433 glVertex3f(256, 256, 0.0f);
1434 glVertex3f(0, 256, 0.0f);
1436 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1437 glPopMatrix(); // Restore The Old Projection Matrix
1438 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1439 glPopMatrix(); // Restore The Old Projection Matrix
1440 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1441 glEnable(GL_CULL_FACE);
1442 glDisable(GL_BLEND);
1448 glEnable(GL_TEXTURE_2D);
1451 sprintf (string, " ]");
1452 text.glPrint(10,30+screenheight-330,string,0,1,screenwidth,screenheight);
1454 sprintf (string, "_");
1455 text.glPrint(30+(float)(displayselected)*10,30+(screenheight-330),string,0,1,screenwidth,screenheight);
1459 if((i!=0||chatting)&&displaytime[i]<4)
1460 for(j=0;j<displaychars[i];j++){
1461 glColor4f(1,1,1,4-displaytime[i]);
1462 if(j<displaychars[i]){
1463 sprintf (string, "%c",displaytext[i][j]);
1464 text.glPrint(30+j*10,30+i*20+(screenheight-330),string,0,1,screenwidth,screenheight);
1470 if(minimap&&indialogue==-1){
1471 float mapviewdist = 20000;
1473 glDisable(GL_DEPTH_TEST);
1474 glColor3f (1.0, 1.0, 1.0); // no coloring
1476 glEnable(GL_TEXTURE_2D);
1477 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1478 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1479 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1480 glDisable(GL_CULL_FACE);
1481 glDisable(GL_LIGHTING);
1483 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1484 glPushMatrix(); // Store The Projection Matrix
1485 glLoadIdentity(); // Reset The Projection Matrix
1486 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1487 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1488 glPushMatrix(); // Store The Modelview Matrix
1489 glLoadIdentity(); // Reset The Modelview Matrix
1490 glScalef((float)screenwidth/2,(float)screenwidth/2,1);
1491 glTranslatef(1.75,.25,0);
1492 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1500 int numliveplayers=0;
1502 for(i=0;i<numplayers;i++){
1503 if(!player[i].dead) numliveplayers++;
1508 for(i=0;i<objects.numobjects;i++){
1509 if(objects.type[i]==treetrunktype||objects.type[i]==boxtype){
1510 center+=objects.position[i];
1514 for(i=0;i<numplayers;i++){
1515 if(!player[i].dead)center+=player[i].coords;
1517 center/=numadd+numliveplayers;
1519 center=player[0].coords;
1521 float maxdistance=0;
1524 for(i=0;i<objects.numobjects;i++){
1525 tempdist=findDistancefast(¢er,&objects.position[i]);
1526 if(tempdist>maxdistance){
1528 maxdistance=tempdist;
1531 for(i=0;i<numplayers;i++){
1532 if(!player[i].dead){
1533 tempdist=findDistancefast(¢er,&player[i].coords);
1534 if(tempdist>maxdistance){
1536 maxdistance=tempdist;
1540 radius=fast_sqrt(maxdistance);
1544 glScalef(.25/radius*256*terrain.scale*.4,.25/radius*256*terrain.scale*.4,1);
1546 glScalef(1/(1/radius*256*terrain.scale*.4),1/(1/radius*256*terrain.scale*.4),1);
1548 glRotatef(player[0].lookrotation*-1+180,0,0,1);
1549 glTranslatef(-(center.x/terrain.scale/256*-2+1),(center.z/terrain.scale/256*-2+1),0);
1550 for(i=0;i<objects.numobjects;i++){
1551 if(objects.type[i]==treetrunktype){
1552 distcheck=findDistancefast(&player[0].coords,&objects.position[i]);
1553 if(distcheck<mapviewdist){
1554 glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
1555 glColor4f(0,.3,0,opac*(1-distcheck/mapviewdist));
1557 glTranslatef(objects.position[i].x/terrain.scale/256*-2+1,objects.position[i].z/terrain.scale/256*2-1,0);
1558 glRotatef(objects.rotation[i],0,0,1);
1559 glScalef(.003,.003,.003);
1562 glVertex3f(-1, -1, 0.0f);
1564 glVertex3f(1, -1, 0.0f);
1566 glVertex3f(1, 1, 0.0f);
1568 glVertex3f(-1, 1, 0.0f);
1573 if(objects.type[i]==boxtype){
1574 distcheck=findDistancefast(&player[0].coords,&objects.position[i]);
1575 if(distcheck<mapviewdist){
1576 glBindTexture( GL_TEXTURE_2D, Mapboxtexture);
1577 glColor4f(.4,.4,.4,opac*(1-distcheck/mapviewdist));
1579 glTranslatef(objects.position[i].x/terrain.scale/256*-2+1,objects.position[i].z/terrain.scale/256*2-1,0);
1580 glRotatef(objects.rotation[i],0,0,1);
1581 glScalef(.01*objects.scale[i],.01*objects.scale[i],.01*objects.scale[i]);
1584 glVertex3f(-1, -1, 0.0f);
1586 glVertex3f(1, -1, 0.0f);
1588 glVertex3f(1, 1, 0.0f);
1590 glVertex3f(-1, 1, 0.0f);
1597 glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
1598 for(i=0;i<numboundaries;i++){
1599 glColor4f(0,0,0,opac/3);
1601 glTranslatef(boundary[i].x/terrain.scale/256*-2+1,boundary[i].z/terrain.scale/256*2-1,0);
1602 glScalef(.002,.002,.002);
1605 glVertex3f(-1, -1, 0.0f);
1607 glVertex3f(1, -1, 0.0f);
1609 glVertex3f(1, 1, 0.0f);
1611 glVertex3f(-1, 1, 0.0f);
1616 for(i=0;i<numplayers;i++){
1617 distcheck=findDistancefast(&player[0].coords,&player[i].coords);
1618 if(distcheck<mapviewdist){
1620 glBindTexture( GL_TEXTURE_2D, Maparrowtexture);
1621 if(i==0)glColor4f(1,1,1,opac);
1622 else if(player[i].dead==2||player[i].howactive>typesleeping)glColor4f(0,0,0,opac*(1-distcheck/mapviewdist));
1623 else if(player[i].dead)glColor4f(.3,.3,.3,opac*(1-distcheck/mapviewdist));
1624 else if(player[i].aitype==attacktypecutoff)glColor4f(1,0,0,opac*(1-distcheck/mapviewdist));
1625 else if(player[i].aitype==passivetype)glColor4f(0,1,0,opac*(1-distcheck/mapviewdist));
1626 else glColor4f(1,1,0,1);
1627 glTranslatef(player[i].coords.x/terrain.scale/256*-2+1,player[i].coords.z/terrain.scale/256*2-1,0);
1628 glRotatef(player[i].rotation+180,0,0,1);
1629 glScalef(.005,.005,.005);
1632 glVertex3f(-1, -1, 0.0f);
1634 glVertex3f(1, -1, 0.0f);
1636 glVertex3f(1, 1, 0.0f);
1638 glVertex3f(-1, 1, 0.0f);
1644 glDisable(GL_TEXTURE_2D);
1645 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1646 glPopMatrix(); // Restore The Old Projection Matrix
1647 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1648 glPopMatrix(); // Restore The Old Projection Matrix
1649 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1650 glEnable(GL_CULL_FACE);
1651 glDisable(GL_BLEND);
1655 if(loading&&!stealthloading&&(!campaign||player[0].dead)){
1656 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1657 glDisable(GL_CULL_FACE);
1658 glDisable(GL_LIGHTING);
1659 glDisable(GL_TEXTURE_2D);
1661 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1662 glPushMatrix(); // Store The Projection Matrix
1663 glLoadIdentity(); // Reset The Projection Matrix
1664 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1665 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1666 glPushMatrix(); // Store The Modelview Matrix
1667 glLoadIdentity(); // Reset The Modelview Matrix
1668 glScalef(screenwidth,screenheight,1);
1669 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1671 glColor4f(0,0,0,.7);
1673 glVertex3f(0, 0, 0.0f);
1674 glVertex3f(256, 0, 0.0f);
1675 glVertex3f(256, 256, 0.0f);
1676 glVertex3f(0, 256, 0.0f);
1678 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1679 glPopMatrix(); // Restore The Old Projection Matrix
1680 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1681 glPopMatrix(); // Restore The Old Projection Matrix
1682 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1683 glEnable(GL_CULL_FACE);
1684 glDisable(GL_BLEND);
1688 glDisable(GL_DEPTH_TEST);
1689 glColor3f (1.0, 1.0, 1.0); // no coloring
1691 glEnable(GL_TEXTURE_2D);
1696 glEnable(GL_TEXTURE_2D);
1698 sprintf (string, "Loading...");
1699 text.glPrint(1024/2-90,768/2,string,1,2,1024,768);
1702 //if(ismotionblur)drawmode=motionblurmode;
1703 drawmode=normalmode;
1706 if(winfreeze&&!campaign){
1707 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1708 glDisable(GL_CULL_FACE);
1709 glDisable(GL_LIGHTING);
1710 glDisable(GL_TEXTURE_2D);
1712 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1713 glPushMatrix(); // Store The Projection Matrix
1714 glLoadIdentity(); // Reset The Projection Matrix
1715 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1716 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1717 glPushMatrix(); // Store The Modelview Matrix
1718 glLoadIdentity(); // Reset The Modelview Matrix
1719 glScalef(screenwidth,screenheight,1);
1720 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1722 glColor4f(0,0,0,.4);
1724 glVertex3f(0, 0, 0.0f);
1725 glVertex3f(256, 0, 0.0f);
1726 glVertex3f(256, 256, 0.0f);
1727 glVertex3f(0, 256, 0.0f);
1729 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1730 glPopMatrix(); // Restore The Old Projection Matrix
1731 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1732 glPopMatrix(); // Restore The Old Projection Matrix
1733 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1734 glEnable(GL_CULL_FACE);
1735 glDisable(GL_BLEND);
1739 glDisable(GL_DEPTH_TEST);
1740 glColor3f (1.0, 1.0, 1.0); // no coloring
1742 glEnable(GL_TEXTURE_2D);
1748 if(damagetaken==0&&player[0].bloodloss==0){
1749 awards[numawards]=awardflawless;
1752 bool alldead = true;
1753 for(i=1;i<numplayers;i++){
1754 if(player[i].dead!=2)alldead=0;
1757 awards[numawards]=awardalldead;
1761 for(i=1;i<numplayers;i++){
1762 if(player[i].dead!=1)alldead=0;
1765 awards[numawards]=awardnodead;
1768 if(numresponded==0&&!numthrowkill){
1769 awards[numawards]=awardstealth;
1772 if(numattacks==numstaffattack&&numattacks>0){
1773 awards[numawards]=awardbojutsu;
1776 if(numattacks==numswordattack&&numattacks>0){
1777 awards[numawards]=awardswordsman;
1780 if(numattacks==numknifeattack&&numattacks>0){
1781 awards[numawards]=awardknifefighter;
1784 if(numattacks==numunarmedattack&&numthrowkill==0&&weapons.numweapons>0){
1785 awards[numawards]=awardkungfu;
1789 awards[numawards]=awardevasion;
1792 if(numflipfail==0&&numflipped+numwallflipped*2>20){
1793 awards[numawards]=awardacrobat;
1796 if(numthrowkill==numplayers-1){
1797 awards[numawards]=awardlongrange;
1801 for(i=1;i<numplayers;i++){
1802 if(player[i].dead!=2)alldead=0;
1804 if(numafterkill>0&&alldead){
1805 awards[numawards]=awardbrutal;
1808 if(numreversals>((float)numattacks)*.8&&numreversals>3){
1809 awards[numawards]=awardaikido;
1812 if(maxalarmed==1&&numplayers>2){
1813 awards[numawards]=awardstrategy;
1817 awards[numawards]=awardklutz;
1821 //Win Screen Won Victory
1823 glEnable(GL_TEXTURE_2D);
1825 sprintf (string, "Level Cleared!");
1826 text.glPrintOutlined(1024/2-strlen(string)*10,768*7/8,string,1,2,1024,768);
1828 sprintf (string, "Score: %d",(int)(bonustotal-startbonustotal));
1829 text.glPrintOutlined(1024/30,768*6/8,string,1,2,1024,768);
1832 sprintf (string, "Press Escape or Space to continue");
1834 sprintf (string, "Press Escape to return to menu or Space to continue");
1835 text.glPrintOutlined(640/2-strlen(string)*5,480*1/16,string,1,1,640,480);
1839 for(i=0;i<255;i++)string[i]='\0';
1840 sprintf (temp, "Time: %d:",(int)(((int)leveltime-(int)(leveltime)%60)/60));
1841 strcat(string,temp);
1842 if((int)(leveltime)%60<10)strcat(string,"0");
1843 sprintf (temp, "%d",(int)(leveltime)%60);
1844 strcat(string,temp);
1845 text.glPrintOutlined(1024/30,768*6/8-40,string,1,2,1024,768);
1847 for(i=0;i<numawards;i++){
1849 if(awards[i]==awardklutz)sprintf (string, "Suicidal");
1850 if(awards[i]==awardflawless)sprintf (string, "Flawless!");
1851 if(awards[i]==awardalldead)sprintf (string, "Take no prisoners");
1852 if(awards[i]==awardnodead)sprintf (string, "Merciful");
1853 if(awards[i]==awardstealth)sprintf (string, "One with the shadows!");
1854 if(awards[i]==awardswordsman)sprintf (string, "Swordsman");
1855 if(awards[i]==awardkungfu)sprintf (string, "Unarmed!");
1856 if(awards[i]==awardknifefighter)sprintf (string, "Knife fighter");
1857 if(awards[i]==awardcoward)sprintf (string, "Coward");
1858 if(awards[i]==awardevasion)sprintf (string, "Escape artist");
1859 if(awards[i]==awardacrobat)sprintf (string, "Gymnast");
1860 if(awards[i]==awardlongrange)sprintf (string, "Blade slinger");
1861 if(awards[i]==awardbrutal)sprintf (string, "Brutal");
1862 if(awards[i]==awardhyper)sprintf (string, "Hyper");
1863 if(awards[i]==awardaikido)sprintf (string, "Aikido master!");
1864 if(awards[i]==awardrambo)sprintf (string, "Rambo");
1865 if(awards[i]==awardfast)sprintf (string, "Fast");
1866 if(awards[i]==awardrealfast)sprintf (string, "Real fast");
1867 if(awards[i]==awarddamnfast)sprintf (string, "Damn fast");
1868 if(awards[i]==awardstrategy)sprintf (string, "Divide and conquer");
1869 if(awards[i]==awardbojutsu)sprintf (string, "Bojutsu");
1870 text.glPrintOutlined(1024/30,768*6/8-90-40*i,string,1,2,1024,768);
1875 if(drawmode!=normalmode){
1876 glEnable(GL_TEXTURE_2D);
1878 if(!drawtoggle||drawmode!=realmotionblurmode||(drawtoggle==2||change==1)){
1881 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
1882 GLfloat subtractColor[4] = { 0.5, 0.5, 0.5, 0.0 };
1883 glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, subtractColor);
1884 //glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_SUBTRACT);
1885 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE);
1886 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_CONSTANT_EXT);
1887 glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 2.0f);
1889 glBindTexture( GL_TEXTURE_2D, screentexture);
1890 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1893 if((drawtoggle||change==1)&&drawmode==realmotionblurmode){
1895 glBindTexture( GL_TEXTURE_2D, screentexture2);
1896 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1898 if(!screentexture2){
1899 glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
1901 glGenTextures( 1, &screentexture2 );
1902 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
1904 glEnable(GL_TEXTURE_2D);
1905 glBindTexture( GL_TEXTURE_2D, screentexture2);
1906 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
1907 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
1909 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
1915 glClear(GL_DEPTH_BUFFER_BIT);
1916 ReSizeGLScene(90,.1f);
1917 glViewport(0,0,screenwidth,screenheight);
1919 if(drawmode!=normalmode){
1920 glDisable(GL_DEPTH_TEST);
1921 if(drawmode==motionblurmode){
1922 glDrawBuffer(GL_FRONT);
1923 glReadBuffer(GL_BACK);
1925 glColor3f (1.0, 1.0, 1.0); // no coloring
1927 glEnable(GL_TEXTURE_2D);
1928 glBindTexture( GL_TEXTURE_2D, screentexture);
1929 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1930 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1931 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1932 glDisable(GL_CULL_FACE);
1933 glDisable(GL_LIGHTING);
1935 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1936 glPushMatrix(); // Store The Projection Matrix
1937 glLoadIdentity(); // Reset The Projection Matrix
1938 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1939 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1940 glPushMatrix(); // Store The Modelview Matrix
1941 glLoadIdentity(); // Reset The Modelview Matrix
1942 glScalef((float)screenwidth/2,(float)screenheight/2,1);
1943 glTranslatef(1,1,0);
1944 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1946 if(drawmode==motionblurmode){
1947 if(motionbluramount<.2)motionbluramount=.2;
1948 //glColor4f(1,1,1,fast_sqrt(multiplier)*2.9*motionbluramount);
1949 glColor4f(1,1,1,motionbluramount);
1953 glVertex3f(-1, -1, 0.0f);
1954 glTexCoord2f(texcoordwidth,0);
1955 glVertex3f(1, -1, 0.0f);
1956 glTexCoord2f(texcoordwidth,texcoordheight);
1957 glVertex3f(1, 1, 0.0f);
1958 glTexCoord2f(0,texcoordheight);
1959 glVertex3f(-1, 1, 0.0f);
1963 if(drawmode==realmotionblurmode){
1964 glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
1965 glClear(GL_COLOR_BUFFER_BIT);
1966 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
1967 glBindTexture( GL_TEXTURE_2D, screentexture);
1968 glColor4f(1,1,1,.5);
1972 glVertex3f(-1, -1, 0.0f);
1973 glTexCoord2f(texcoordwidth,0);
1974 glVertex3f(1, -1, 0.0f);
1975 glTexCoord2f(texcoordwidth,texcoordheight);
1976 glVertex3f(1, 1, 0.0f);
1977 glTexCoord2f(0,texcoordheight);
1978 glVertex3f(-1, 1, 0.0f);
1981 glBindTexture( GL_TEXTURE_2D, screentexture2);
1982 glColor4f(1,1,1,.5);
1986 glVertex3f(-1, -1, 0.0f);
1987 glTexCoord2f(texcoordwidth,0);
1988 glVertex3f(1, -1, 0.0f);
1989 glTexCoord2f(texcoordwidth,texcoordheight);
1990 glVertex3f(1, 1, 0.0f);
1991 glTexCoord2f(0,texcoordheight);
1992 glVertex3f(-1, 1, 0.0f);
1995 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1997 if(drawmode==doublevisionmode){
1998 static float crosseyedness;
1999 crosseyedness=abs(player[0].damage-player[0].superpermanentdamage-(player[0].damagetolerance-player[0].superpermanentdamage)*1/2)/30;
2000 if(crosseyedness>1)crosseyedness=1;
2001 if(crosseyedness<0)crosseyedness=0;
2003 glDisable(GL_BLEND);
2008 glVertex3f(-1, -1, 0.0f);
2009 glTexCoord2f(texcoordwidth,0);
2010 glVertex3f(1, -1, 0.0f);
2011 glTexCoord2f(texcoordwidth,texcoordheight);
2012 glVertex3f(1, 1, 0.0f);
2013 glTexCoord2f(0,texcoordheight);
2014 glVertex3f(-1, 1, 0.0f);
2018 glColor4f(1,1,1,.5);
2021 glTranslatef(.015*crosseyedness,0,0);
2025 glVertex3f(-1, -1, 0.0f);
2026 glTexCoord2f(texcoordwidth,0);
2027 glVertex3f(1, -1, 0.0f);
2028 glTexCoord2f(texcoordwidth,texcoordheight);
2029 glVertex3f(1, 1, 0.0f);
2030 glTexCoord2f(0,texcoordheight);
2031 glVertex3f(-1, 1, 0.0f);
2036 if(drawmode==glowmode){
2037 glColor4f(.5,.5,.5,.5);
2039 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
2041 glTranslatef(.01,0,0);
2044 glVertex3f(-1, -1, 0.0f);
2045 glTexCoord2f(texcoordwidth,0);
2046 glVertex3f(1, -1, 0.0f);
2047 glTexCoord2f(texcoordwidth,texcoordheight);
2048 glVertex3f(1, 1, 0.0f);
2049 glTexCoord2f(0,texcoordheight);
2050 glVertex3f(-1, 1, 0.0f);
2054 glTranslatef(-.01,0,0);
2057 glVertex3f(-1, -1, 0.0f);
2058 glTexCoord2f(texcoordwidth,0);
2059 glVertex3f(1, -1, 0.0f);
2060 glTexCoord2f(texcoordwidth,texcoordheight);
2061 glVertex3f(1, 1, 0.0f);
2062 glTexCoord2f(0,texcoordheight);
2063 glVertex3f(-1, 1, 0.0f);
2067 glTranslatef(.0,.01,0);
2070 glVertex3f(-1, -1, 0.0f);
2071 glTexCoord2f(texcoordwidth,0);
2072 glVertex3f(1, -1, 0.0f);
2073 glTexCoord2f(texcoordwidth,texcoordheight);
2074 glVertex3f(1, 1, 0.0f);
2075 glTexCoord2f(0,texcoordheight);
2076 glVertex3f(-1, 1, 0.0f);
2080 glTranslatef(0,-.01,0);
2083 glVertex3f(-1, -1, 0.0f);
2084 glTexCoord2f(texcoordwidth,0);
2085 glVertex3f(1, -1, 0.0f);
2086 glTexCoord2f(texcoordwidth,texcoordheight);
2087 glVertex3f(1, 1, 0.0f);
2088 glTexCoord2f(0,texcoordheight);
2089 glVertex3f(-1, 1, 0.0f);
2093 if(drawmode==radialzoommode){
2095 //glRotatef((float)i*.1,0,0,1);
2096 glColor4f(1,1,1,1/((float)i+1));
2098 glScalef(1+(float)i*.01,1+(float)i*.01,1);
2101 glVertex3f(-1, -1, 0.0f);
2102 glTexCoord2f(texcoordwidth,0);
2103 glVertex3f(1, -1, 0.0f);
2104 glTexCoord2f(texcoordwidth,texcoordheight);
2105 glVertex3f(1, 1, 0.0f);
2106 glTexCoord2f(0,texcoordheight);
2107 glVertex3f(-1, 1, 0.0f);
2112 glDisable(GL_TEXTURE_2D);
2113 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2114 glPopMatrix(); // Restore The Old Projection Matrix
2115 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2116 glPopMatrix(); // Restore The Old Projection Matrix
2117 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
2118 glEnable(GL_CULL_FACE);
2119 glDisable(GL_BLEND);
2124 glEnable(GL_TEXTURE_2D);
2127 if(consoleselected>=60)
2128 offset=consoleselected-60;
2129 sprintf (string, " ]");
2130 text.glPrint(10,30,string,0,1,1024,768);
2132 sprintf (string, "_");
2133 text.glPrint(30+(float)(consoleselected)*10-offset*10,30,string,0,1,1024,768);
2136 for(j=0;j<consolechars[i];j++){
2137 glColor4f(1,1,1,1-(float)(i)/16);
2138 if(j<consolechars[i]){
2139 sprintf (string, "%c",consoletext[i][j]);
2140 text.glPrint(30+j*10-offset*10,30+i*20,string,0,1,1024,768);
2147 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)||(mainmenu&&gameon)||(!gameon&&gamestarted)||(!gameon&&gamestarted)){
2148 multiplier=tempmult;
2153 // !!! FIXME: hack: clamp framerate in menu so text input works correctly on fast systems.
2156 glDrawBuffer(GL_BACK);
2157 glReadBuffer(GL_BACK);
2158 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
2159 ReSizeGLScene(90,.1f);
2162 temptexdetail=texdetail;
2163 if(texdetail>2)texdetail=2;
2164 if(mainmenu!=oldmainmenu&&oldmainmenu!=0){
2166 LoadTexture(":Data:Textures:Newgame.png",&Mainmenuitems[1],0,0);
2167 LoadTexture(":Data:Textures:Quit.png",&Mainmenuitems[3],0,0);
2170 LoadTexture(":Data:Textures:Resume.png",&Mainmenuitems[1],0,0);
2171 LoadTexture(":Data:Textures:Endgame.png",&Mainmenuitems[3],0,0);
2174 if(lastcheck>.5||oldmainmenu!=mainmenu){
2176 ifstream ipstream(ConvertFileName(":Data:Campaigns:main.txt"));
2177 ipstream.ignore(256,':');
2178 ipstream >> campaignnumlevels;
2179 for(i=0;i<campaignnumlevels;i++){
2180 ipstream.ignore(256,':');
2181 ipstream.ignore(256,':');
2182 ipstream.ignore(256,' ');
2183 ipstream >> campaignmapname[i];
2184 ipstream.ignore(256,':');
2185 ipstream >> campaigndescription[i];
2187 if(campaigndescription[i][j]=='_')campaigndescription[i][j]=' ';
2189 ipstream.ignore(256,':');
2190 ipstream >> campaignchoosenext[i];
2191 ipstream.ignore(256,':');
2192 ipstream >> campaignnumnext[i];
2193 for(j=0;j<campaignnumnext[i];j++){
2194 ipstream.ignore(256,':');
2195 ipstream >> campaignnextlevel[i][j];
2196 campaignnextlevel[i][j]-=1;
2198 ipstream.ignore(256,':');
2199 ipstream >> campaignlocationx[i];
2200 ipstream.ignore(256,':');
2201 ipstream >> campaignlocationy[i];
2205 for(i=0;i<campaignnumlevels;i++){
2207 levelhighlight[i]=0;
2212 for(i=0;i<accountactive->getCampaignChoicesMade();i++){
2213 levelorder[i+1]=campaignnextlevel[levelorder[i]][accountactive->getCampaignChoice(i)];
2214 levelvisible[levelorder[i+1]]=1;
2216 int whichlevelstart = accountactive->getCampaignChoicesMade()-1;
2217 if(whichlevelstart<0){
2218 accountactive->setCampaignScore(0);
2219 accountactive->resetFasttime();
2220 campaignchoicenum=1;
2221 campaignchoicewhich[0]=0;
2225 campaignchoicenum=campaignnumnext[levelorder[whichlevelstart]];
2226 for(i=0;i<campaignchoicenum;i++){
2227 campaignchoicewhich[i]=campaignnextlevel[levelorder[whichlevelstart]][i];
2228 levelvisible[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
2229 levelhighlight[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
2238 texdetail=temptexdetail;
2240 oldmainmenu=mainmenu;
2242 if(mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==8||mainmenu==9||mainmenu==10||mainmenu==119||mainmenu==18){
2243 glClear(GL_DEPTH_BUFFER_BIT);
2244 glEnable(GL_ALPHA_TEST);
2245 glAlphaFunc(GL_GREATER, 0.001f);
2246 glEnable(GL_TEXTURE_2D);
2247 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
2248 glDisable(GL_CULL_FACE);
2249 glDisable(GL_LIGHTING);
2251 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2252 glPushMatrix(); // Store The Projection Matrix
2253 glLoadIdentity(); // Reset The Projection Matrix
2254 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
2255 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2256 glPushMatrix(); // Store The Modelview Matrix
2257 glLoadIdentity(); // Reset The Modelview Matrix
2258 glTranslatef(screenwidth/2,screenheight/2,0);
2260 glScalef((float)screenwidth/2,(float)screenheight/2,1);
2261 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
2262 glDisable(GL_BLEND);
2263 glColor4f(0,0,0,1.0);
2264 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2265 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2266 glDisable(GL_TEXTURE_2D);
2268 //glScalef(.25,.25,.25);
2271 glVertex3f(-1, -1, 0.0f);
2273 glVertex3f(1, -1, 0.0f);
2275 glVertex3f(1, 1, 0.0f);
2277 glVertex3f(-1, 1, 0.0f);
2281 glColor4f(0.4,0.4,0.4,1.0);
2282 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2283 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2284 glEnable(GL_TEXTURE_2D);
2285 glBindTexture( GL_TEXTURE_2D, Mainmenuitems[4]);
2287 //glScalef(.25,.25,.25);
2290 glVertex3f(-1, -1, 0.0f);
2292 glVertex3f(1, -1, 0.0f);
2294 glVertex3f(1, 1, 0.0f);
2296 glVertex3f(-1, 1, 0.0f);
2301 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2303 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2307 if((float)newscreenwidth>(float)newscreenheight*1.61||(float)newscreenwidth<(float)newscreenheight*1.59)sprintf (menustring[0], "Resolution: %d*%d",(int)newscreenwidth,(int)newscreenheight);
2308 else sprintf (menustring[0], "Resolution: %d*%d (widescreen)",(int)newscreenwidth,(int)newscreenheight);
2311 endx[0]=startx[0]+strlen(menustring[0])*10;
2312 endy[0]=starty[0]+20;
2316 if(newdetail==2)sprintf (menustring[1], "Detail: High");
2317 else if(newdetail==1)sprintf (menustring[1], "Detail: Medium");
2318 else sprintf (menustring[1], "Detail: Low");
2321 endx[1]=startx[1]+strlen(menustring[1])*10;
2322 endy[1]=starty[1]+20;
2326 if(bloodtoggle==2)sprintf (menustring[2], "Blood: On, high detail (slower)");
2327 if(bloodtoggle==1)sprintf (menustring[2], "Blood: On, low detail");
2328 if(bloodtoggle==0)sprintf (menustring[2], "Blood: Off");
2331 endx[2]=startx[2]+strlen(menustring[2])*10;
2332 endy[2]=starty[2]+20;
2336 if(difficulty==2)sprintf (menustring[3], "Difficulty: Insane");
2337 if(difficulty==1)sprintf (menustring[3], "Difficulty: Difficult");
2338 if(difficulty==0)sprintf (menustring[3], "Difficulty: Easier");
2339 startx[3]=10+20-1000;
2341 endx[3]=startx[3]+strlen(menustring[3])*10;
2342 endy[3]=starty[3]+20;
2346 if(ismotionblur==1)sprintf (menustring[4], "Blur Effects: Enabled (less compatible)");
2347 if(ismotionblur==0)sprintf (menustring[4], "Blur Effects: Disabled (more compatible)");
2350 endx[4]=startx[4]+strlen(menustring[4])*10;
2351 endy[4]=starty[4]+20;
2355 if(decals==1)sprintf (menustring[5], "Decals: Enabled (slower)");
2356 if(decals==0)sprintf (menustring[5], "Decals: Disabled");
2359 endx[5]=startx[5]+strlen(menustring[5])*10;
2360 endy[5]=starty[5]+20;
2364 if(musictoggle==1)sprintf (menustring[6], "Music: Enabled");
2365 if(musictoggle==0)sprintf (menustring[6], "Music: Disabled");
2368 endx[6]=startx[6]+strlen(menustring[6])*10;
2369 endy[6]=starty[6]+20;
2373 if(invertmouse==1)sprintf (menustring[9], "Invert mouse: Yes");
2374 if(invertmouse==0)sprintf (menustring[9], "Invert mouse: No");
2377 endx[9]=startx[9]+strlen(menustring[9])*10;
2378 endy[9]=starty[9]+20;
2382 sprintf (menustring[10], "Mouse Speed: %d", (int)(usermousesensitivity*5));
2385 endx[10]=startx[10]+strlen(menustring[10])*10;
2386 endy[10]=starty[10]+20;
2390 sprintf (menustring[11], "Volume: %d%%", (int)(volume*100));
2393 endx[11]=startx[11]+strlen(menustring[11])*10;
2394 endy[11]=starty[11]+20;
2398 sprintf (menustring[13], "Damage Bar: %s",(showdamagebar?"on":"off"));
2401 endx[13]=startx[13]+strlen(menustring[13])*10;
2402 endy[13]=starty[13]+20;
2406 sprintf (menustring[7], "-Configure Controls-");
2409 endx[7]=startx[7]+strlen(menustring[7])*10;
2410 endy[7]=starty[7]+20;
2414 sprintf (menustring[12], "-Configure Stereo -");
2417 endx[12]=startx[12]+strlen(menustring[7])*10;
2418 endy[12]=starty[12]+20;
2422 if(newdetail==detail&&newscreenheight==(int)screenheight&&newscreenwidth==(int)screenwidth)sprintf (menustring[8], "Back");
2423 else sprintf (menustring[8], "Back (some changes take effect next time Lugaru is opened)");
2425 endx[8]=startx[8]+strlen(menustring[8])*10;
2427 endy[8]=starty[8]+20;
2434 if(keyselect!=0)sprintf (menustring[0], "Forwards: %s",Input::keyToChar(forwardkey));
2435 else sprintf (menustring[0], "Forwards: _");
2438 endx[0]=startx[0]+strlen(menustring[0])*10;
2439 endy[0]=starty[0]+20;
2443 if(keyselect!=1)sprintf (menustring[1], "Back: %s",Input::keyToChar(backkey));
2444 else sprintf (menustring[1], "Back: _");
2447 endx[1]=startx[1]+strlen(menustring[1])*10;
2448 endy[1]=starty[1]+20;
2452 if(keyselect!=2)sprintf (menustring[2], "Left: %s",Input::keyToChar(leftkey));
2453 else sprintf (menustring[2], "Left: _");
2456 endx[2]=startx[2]+strlen(menustring[2])*10;
2457 endy[2]=starty[2]+20;
2461 if(keyselect!=3)sprintf (menustring[3], "Right: %s",Input::keyToChar(rightkey));
2462 else sprintf (menustring[3], "Right: _");
2465 endx[3]=startx[3]+strlen(menustring[3])*10;
2466 endy[3]=starty[3]+20;
2470 if(keyselect!=4)sprintf (menustring[4], "Crouch: %s",Input::keyToChar(crouchkey));
2471 else sprintf (menustring[4], "Crouch: _");
2474 endx[4]=startx[4]+strlen(menustring[4])*10;
2475 endy[4]=starty[4]+20;
2479 if(keyselect!=5)sprintf (menustring[5], "Jump: %s",Input::keyToChar(jumpkey));
2480 else sprintf (menustring[5], "Jump: _");
2483 endx[5]=startx[5]+strlen(menustring[5])*10;
2484 endy[5]=starty[5]+20;
2488 if(keyselect!=6)sprintf (menustring[6], "Draw: %s",Input::keyToChar(drawkey));
2489 else sprintf (menustring[6], "Draw: _");
2492 endx[6]=startx[6]+strlen(menustring[6])*10;
2493 endy[6]=starty[6]+20;
2497 if(keyselect!=7)sprintf (menustring[7], "Throw: %s",Input::keyToChar(throwkey));
2498 else sprintf (menustring[7], "Throw: _");
2501 endx[7]=startx[7]+strlen(menustring[7])*10;
2502 endy[7]=starty[7]+20;
2506 if(keyselect!=8)sprintf (menustring[8], "Attack: %s",Input::keyToChar(attackkey));
2507 else sprintf (menustring[8], "Attack: _");
2510 endx[8]=startx[8]+strlen(menustring[8])*10;
2511 endy[8]=starty[8]+20;
2517 sprintf (menustring[9], "Back");
2519 endx[9]=startx[9]+strlen(menustring[9])*10;
2521 endy[9]=starty[9]+20;
2526 nummenuitems=7+accountactive->getCampaignChoicesMade()+campaignchoicenum;
2528 sprintf (menustring[0], "%s",accountactive->getName());
2531 endx[0]=startx[0]+strlen(menustring[0])*10;
2532 endy[0]=starty[0]+20;
2536 sprintf (menustring[1], "Tutorial");
2539 endx[1]=startx[1]+strlen(menustring[1])*10;
2540 endy[1]=starty[1]+20;
2544 sprintf (menustring[2], "Challenge");
2547 endx[2]=startx[2]+strlen(menustring[2])*10;
2548 endy[2]=starty[2]+20;
2552 sprintf (menustring[3], "Delete User");
2555 endx[3]=startx[3]+strlen(menustring[3])*10;
2556 endy[3]=starty[3]+20;
2560 sprintf (menustring[4], "Main Menu");
2563 endx[4]=startx[4]+strlen(menustring[4])*10;
2564 endy[4]=starty[4]+20;
2568 sprintf (menustring[5], "Change User");
2570 endx[5]=startx[5]+strlen(menustring[5])*10;
2572 endy[5]=starty[5]+20;
2578 sprintf (menustring[6], "World");
2580 starty[6]=30+480-400-50;
2581 endx[6]=startx[6]+400;
2586 if(accountactive->getCampaignChoicesMade())
2587 for(i=0;i<accountactive->getCampaignChoicesMade();i++){
2588 sprintf (menustring[7+i], "%s", campaigndescription[levelorder[i]]);
2589 startx[7+i]=30+120+campaignlocationx[levelorder[i]]*400/512;
2590 starty[7+i]=30+30+(512-campaignlocationy[levelorder[i]])*400/512;
2591 endx[7+i]=startx[7+i]+10;
2592 endy[7+i]=starty[7+i]+10;
2597 if(campaignchoicenum>0)
2598 for(i=accountactive->getCampaignChoicesMade();i<accountactive->getCampaignChoicesMade()+campaignchoicenum;i++){
2599 sprintf (menustring[7+i], "%s", campaigndescription[levelorder[i]]);
2600 startx[7+i]=30+120+campaignlocationx[campaignchoicewhich[i-(accountactive->getCampaignChoicesMade())]]*400/512;
2601 starty[7+i]=30+30+(512-campaignlocationy[campaignchoicewhich[i-(accountactive->getCampaignChoicesMade())]])*400/512;
2602 endx[7+i]=startx[7+i]+10;
2603 endy[7+i]=starty[7+i]+10;
2608 /*sprintf (menustring[7], "Dot");
2609 startx[7]=120+260*400/512;
2610 starty[7]=30+(512-184)*400/512;
2611 endx[7]=startx[7]+10;
2612 endy[7]=starty[7]+10;
2616 sprintf (menustring[8], "Dot");
2617 startx[8]=120+129*400/512;
2618 starty[8]=30+(512-284)*400/512;
2619 endx[8]=startx[8]+10;
2620 endy[8]=starty[8]+10;
2624 sprintf (menustring[9], "Dot");
2625 startx[9]=120+358*400/512;
2626 starty[9]=30+(512-235)*400/512;
2627 endx[9]=startx[9]+10;
2628 endy[9]=starty[9]+10;
2632 sprintf (menustring[10], "Dot");
2633 startx[10]=120+359*400/512;
2634 starty[10]=30+(512-308)*400/512;
2635 endx[10]=startx[10]+10;
2636 endy[10]=starty[10]+10;
2640 sprintf (menustring[11], "Dot");
2641 startx[11]=120+288*400/512;
2642 starty[11]=30+(512-277)*400/512;
2643 endx[11]=startx[11]+10;
2644 endy[11]=starty[11]+10;
2652 sprintf (menustring[0], "Are you sure you want to delete this user?");
2655 endx[0]=startx[0]+strlen(menustring[0])*10;
2656 endy[0]=starty[0]+20;
2660 sprintf (menustring[1], "Yes");
2663 endx[1]=startx[1]+strlen(menustring[1])*10;
2664 endy[1]=starty[1]+20;
2668 sprintf (menustring[2], "No");
2671 endx[2]=startx[2]+strlen(menustring[2])*10;
2672 endy[2]=starty[2]+20;
2676 sprintf (menustring[3], "Extra 4");
2679 endx[3]=startx[3]+strlen(menustring[3])*10;
2680 endy[3]=starty[3]+20;
2684 sprintf (menustring[4], "Extra 5");
2687 endx[4]=startx[4]+strlen(menustring[4])*10;
2688 endy[4]=starty[4]+20;
2692 sprintf (menustring[5], "Back");
2694 endx[5]=startx[5]+strlen(menustring[5])*10;
2696 endy[5]=starty[5]+20;
2702 nummenuitems=Account::getNbAccounts()+2;
2706 if(Account::getNbAccounts()<8)
2707 sprintf (menustring[0], "New User");
2709 sprintf (menustring[0], "No More Users");
2712 endx[0]=startx[0]+strlen(menustring[0])*10;
2713 endy[0]=starty[0]+20;
2722 for(i=0;i<Account::getNbAccounts();i++){
2723 sprintf (menustring[num], "%s",Account::get(i)->getName());
2725 starty[num]=360-20-20*num;
2726 endx[num]=startx[num]+strlen(menustring[num])*10;
2727 endy[num]=starty[num]+20;
2734 sprintf (menustring[num], "Back");
2736 endx[num]=startx[num]+strlen(menustring[num])*10;
2738 endy[num]=starty[num]+20;
2745 sprintf (menustring[0], "Easier");
2748 endx[0]=startx[0]+strlen(menustring[0])*10;
2749 endy[0]=starty[0]+20;
2753 sprintf (menustring[1], "Difficult");
2756 endx[1]=startx[1]+strlen(menustring[1])*10;
2757 endy[1]=starty[1]+20;
2761 sprintf (menustring[2], "Insane");
2764 endx[2]=startx[2]+strlen(menustring[2])*10;
2765 endy[2]=starty[2]+20;
2771 //tempncl=numchallengelevels;
2772 //numchallengelevels=9;
2773 nummenuitems=2+numchallengelevels;
2776 for(j=0;j<numchallengelevels;j++){
2777 for(i=0;i<255;i++)menustring[j][i]='\0';
2778 sprintf (temp, "Level %d",j+1);
2779 strcpy(menustring[j],temp);
2780 for(i=0;i<17;i++)if(menustring[j][i]=='\0')menustring[j][i]=' ';
2781 menustring[j][17]='\0';
2782 sprintf (temp, "%d",(int)accountactive->getHighScore(j));
2783 strcat(menustring[j],temp);
2784 for(i=18;i<32;i++)if(menustring[j][i]=='\0')menustring[j][i]=' ';
2785 menustring[j][32]='\0';
2786 sprintf (temp, "%d:",(int)(((int)accountactive->getFastTime(j)-(int)(accountactive->getFastTime(j))%60)/60));
2787 strcat(menustring[j],temp);
2788 if((int)(accountactive->getFastTime(j))%60<10)strcat(menustring[j],"0");
2789 sprintf (temp, "%d",(int)(accountactive->getFastTime(j))%60);
2790 strcat(menustring[j],temp);
2794 endx[j]=startx[j]+strlen(menustring[j])*10;
2795 endy[j]=starty[j]+20;
2800 sprintf (menustring[numchallengelevels], "Back");
2801 startx[numchallengelevels]=10;
2802 endx[numchallengelevels]=startx[numchallengelevels]+strlen(menustring[numchallengelevels])*10;
2803 starty[numchallengelevels]=10;
2804 endy[numchallengelevels]=starty[numchallengelevels]+20;
2805 movex[numchallengelevels]=0;
2806 movey[numchallengelevels]=0;
2808 sprintf (menustring[numchallengelevels+1], " High Score Best Time");
2809 startx[numchallengelevels+1]=10;
2810 starty[numchallengelevels+1]=440;
2811 endx[numchallengelevels+1]=startx[numchallengelevels+1]+strlen(menustring[numchallengelevels+1])*10;
2812 endy[numchallengelevels+1]=starty[numchallengelevels+1]+20;
2813 movex[numchallengelevels+1]=0;
2814 movey[numchallengelevels+1]=0;
2816 //numchallengelevels=tempncl;
2823 sprintf (menustring[0], "Congratulations!");
2826 endx[0]=startx[0]+strlen(menustring[0])*10;
2827 endy[0]=starty[0]+20;
2831 sprintf (menustring[1], "You have avenged your family and");
2834 endx[1]=startx[1]+strlen(menustring[1])*10;
2835 endy[1]=starty[1]+20;
2839 sprintf (menustring[2], "restored peace to the island of Lugaru.");
2842 endx[2]=startx[2]+strlen(menustring[2])*10;
2843 endy[2]=starty[2]+20;
2847 sprintf (menustring[3], "Back");
2849 endx[3]=startx[3]+strlen(menustring[3])*10;
2851 endy[3]=starty[3]+20;
2855 for(i=0;i<255;i++)menustring[4][i]='\0';
2856 sprintf (temp, "Your score:");
2857 strcpy(menustring[4],temp);
2858 for(i=0;i<20;i++)if(menustring[4][i]=='\0')menustring[4][i]=' ';
2859 menustring[4][20]='\0';
2860 sprintf (temp, "%d",(int)accountactive->getCampaignScore());
2861 strcat(menustring[4],temp);
2863 endx[4]=startx[4]+strlen(menustring[4])*10;
2865 endy[4]=starty[4]+20;
2869 for(i=0;i<255;i++)menustring[5][i]='\0';
2870 sprintf (temp, "Your time:");
2871 strcpy(menustring[5],temp);
2872 for(i=0;i<20;i++)if(menustring[5][i]=='\0')menustring[5][i]=' ';
2873 menustring[5][20]='\0';
2874 sprintf (temp, "%d",(int)accountcampaigntime[accountactive]);
2875 strcat(menustring[5],temp);
2877 endx[5]=startx[5]+strlen(menustring[5])*10;
2879 endy[5]=starty[5]+20;
2883 for(i=0;i<255;i++)menustring[5][i]='\0';
2884 sprintf (temp, "Highest score:");
2885 strcpy(menustring[5],temp);
2886 for(i=0;i<20;i++)if(menustring[5][i]=='\0')menustring[5][i]=' ';
2887 menustring[5][20]='\0';
2888 sprintf (temp, "%d",(int)accountactive->getCampaignHighScore());
2889 strcat(menustring[5],temp);
2891 endx[5]=startx[5]+strlen(menustring[5])*10;
2893 endy[5]=starty[5]+20;
2897 for(i=0;i<255;i++)menustring[7][i]='\0';
2898 sprintf (temp, "Lowest time:");
2899 strcpy(menustring[7],temp);
2900 for(i=0;i<20;i++)if(menustring[7][i]=='\0')menustring[7][i]=' ';
2901 menustring[7][20]='\0';
2902 sprintf (temp, "%d",(int)accountactive->getCampaignFasttime());
2903 strcat(menustring[7],temp);
2905 endx[7]=startx[7]+strlen(menustring[7])*10;
2907 endy[7]=starty[7]+20;
2913 sprintf (menustring[0], "Stereo mode: %s", StereoModeName(newstereomode));
2916 endx[0]=startx[0]+strlen(menustring[0])*10;
2917 endy[0]=starty[0]+20;
2921 sprintf (menustring[1], "Stereo separation: %.3f", stereoseparation);
2924 endx[1]=startx[1]+strlen(menustring[1])*10;
2925 endy[1]=starty[1]+20;
2929 sprintf (menustring[2], "Reverse stereo: %s", stereoreverse ? "Yes" : "No");
2932 endx[2]=startx[2]+strlen(menustring[2])*10;
2933 endy[2]=starty[2]+20;
2937 sprintf (menustring[3], "Back");
2939 endx[3]=startx[3]+strlen(menustring[3])*10;
2941 endy[3]=starty[3]+20;
2947 if(mainmenu==1||mainmenu==2){
2957 starty[1]=480-152-32;
2964 starty[2]=480-228-32;
2972 starty[3]=480-306-32;
2981 starty[3]=480-306-32;
2995 starty[4]=480-140-256;
3002 starty[5]=480-138-256;
3009 starty[6]=480-144-256;
3017 starty[4]=480-140-256;
3024 starty[5]=480-138-256;
3031 starty[6]=480-144-256;
3039 starty[4]=480-140-256;
3046 starty[5]=480-150-256;
3053 starty[6]=480-144-256;
3061 starty[4]=480-140-256;
3068 starty[5]=480-150-256;
3075 starty[6]=480-144-256;
3083 starty[4]=480-100-256;
3090 starty[5]=480-120-256;
3097 starty[6]=480-144-256;
3107 if(mainmenu==1||mainmenu==2)
3109 if((mousecoordh/screenwidth*640)>startx[i]&&(mousecoordh/screenwidth*640)<endx[i]&&480-(mousecoordv/screenheight*480)>starty[i]&&480-(mousecoordv/screenheight*480)<endy[i]){
3114 if(mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==8||mainmenu==9||mainmenu==10||mainmenu==18)
3115 for(i=0;i<nummenuitems;i++){
3116 if((mousecoordh/screenwidth*640)>startx[i]&&(mousecoordh/screenwidth*640)<endx[i]&&480-(mousecoordv/screenheight*480)>starty[i]&&480-(mousecoordv/screenheight*480)<endy[i]){
3117 if(mainmenu!=5)selected=i;
3118 if(mainmenu==5&&(i!=0&&i!=6))selected=i;
3119 if(mainmenu==9&&(i!=numchallengelevels+1))selected=i; // seem useless, if mainmenu==9 then mainmenu!=5, so selected==i.
3123 for(i=0;i<nummenuitems;i++){
3125 selectedlong[i]+=multiplier*5;
3126 if(selectedlong[i]>1) selectedlong[i]=1;
3128 selectedlong[i]-=multiplier*5;
3129 if(selectedlong[i]<0) selectedlong[i]=0;
3131 offsetx[i]=(startx[i]+endx[i])/2-(mousecoordh/screenwidth*640);
3132 offsety[i]=(starty[i]+endy[i])/2-(480-(mousecoordv/screenheight*480));
3137 if(i>=4&&(mainmenu==1||mainmenu==2)){
3139 offsetx[i]=(startx[i]+endx[i]+movex[i]*transition)/2-(640+190)/2;
3140 offsety[i]=(starty[i]+endy[i]+movey[i]*transition)/2-(336+150)/2;
3146 if(mainmenu==1||mainmenu==2){
3147 glClear(GL_DEPTH_BUFFER_BIT);
3148 glEnable(GL_ALPHA_TEST);
3149 glAlphaFunc(GL_GREATER, 0.001f);
3150 glEnable(GL_TEXTURE_2D);
3151 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3152 glDisable(GL_CULL_FACE);
3153 glDisable(GL_LIGHTING);
3155 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3156 glPushMatrix(); // Store The Projection Matrix
3157 glLoadIdentity(); // Reset The Projection Matrix
3158 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
3159 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3160 glPushMatrix(); // Store The Modelview Matrix
3161 glLoadIdentity(); // Reset The Modelview Matrix
3162 glTranslatef(screenwidth/2,screenheight/2,0);
3164 glScalef((float)screenwidth/2,(float)screenheight/2,1);
3165 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3166 glDisable(GL_BLEND);
3167 glColor4f(0,0,0,1.0);
3168 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
3169 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
3170 glDisable(GL_TEXTURE_2D);
3172 //glScalef(.25,.25,.25);
3175 glVertex3f(-1, -1, 0.0f);
3177 glVertex3f(1, -1, 0.0f);
3179 glVertex3f(1, 1, 0.0f);
3181 glVertex3f(-1, 1, 0.0f);
3185 glColor4f(0.4,0.4,0.4,1.0);
3186 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
3187 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
3188 glEnable(GL_TEXTURE_2D);
3189 glBindTexture( GL_TEXTURE_2D, Mainmenuitems[4]);
3191 //glScalef(.25,.25,.25);
3194 glVertex3f(-1, -1, 0.0f);
3196 glVertex3f(1, -1, 0.0f);
3198 glVertex3f(1, 1, 0.0f);
3200 glVertex3f(-1, 1, 0.0f);
3205 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3208 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3209 glPushMatrix(); // Store The Projection Matrix
3210 glLoadIdentity(); // Reset The Projection Matrix
3211 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3212 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3213 glPushMatrix(); // Store The Modelview Matrix
3214 glLoadIdentity(); // Reset The Modelview Matrix
3216 glDisable(GL_TEXTURE_2D);
3220 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3222 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3226 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3227 glPushMatrix(); // Store The Projection Matrix
3228 glLoadIdentity(); // Reset The Projection Matrix
3229 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3230 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3231 glPushMatrix(); // Store The Modelview Matrix
3232 glLoadIdentity(); // Reset The Modelview Matrix
3233 glEnable(GL_TEXTURE_2D);
3234 for(j=0;j<nummenuitems;j++)
3236 if(j<=3||(mainmenu!=1&&mainmenu!=2))
3238 //glDisable(GL_BLEND);
3239 glEnable(GL_ALPHA_TEST);
3241 //glDisable(GL_ALPHA_TEST);
3242 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3243 if(mainmenu==1||mainmenu==2)
3246 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3247 glBindTexture( GL_TEXTURE_2D, Mainmenuitems[j]);
3248 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
3249 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
3250 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3254 glVertex3f(startx[j]+movex[j]*transition, starty[j]+movey[j]*transition, 0.0f);
3256 glVertex3f(endx[j]+movex[j]*transition, starty[j]+movey[j]*transition, 0.0f);
3258 glVertex3f(endx[j]+movex[j]*transition, endy[j]+movey[j]*transition, 0.0f);
3260 glVertex3f(startx[j]+movex[j]*transition, endy[j]+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,1,1,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3271 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3275 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);
3277 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);
3279 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);
3281 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);
3287 if(mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==8||mainmenu==9||mainmenu==10||mainmenu==18)
3289 if(mainmenu!=5||j<6)
3292 if(mainmenu==9&&j>accountactive->getProgress()&&j<numchallengelevels)glColor4f(0.5,0,0,1);
3293 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3295 if(mainmenu!=7||j!=0||!entername)
3296 text.glPrint(startx[j],starty[j],menustring[j],0,1,640,480);
3300 sprintf (string, "_");
3301 text.glPrint(startx[j]+(float)(displayselected)*10,starty[j],string,0,1,640,480);
3303 for(l=0;l<displaychars[0];l++){
3304 sprintf (string, "%c",displaytext[0][l]);
3305 text.glPrint(startx[j]+l*10,starty[j],string,0,1,640,480);
3310 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3313 if(1-((float)i)/15-(1-selectedlong[j])>0)
3315 glColor4f(1,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3316 if(mainmenu==9&&j>accountactive->getProgress()&&j<numchallengelevels)glColor4f(0.5,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3317 if(mainmenu==11&&j>accountactive->getProgress()&&j<numchallengelevels)glColor4f(0.5,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3318 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);
3319 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);
3320 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);
3321 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);
3322 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);
3323 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);
3324 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);
3325 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);
3326 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);
3332 glClear(GL_DEPTH_BUFFER_BIT);
3333 glEnable(GL_ALPHA_TEST);
3334 glAlphaFunc(GL_GREATER, 0.001f);
3335 glEnable(GL_TEXTURE_2D);
3336 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3337 glDisable(GL_CULL_FACE);
3338 glDisable(GL_LIGHTING);
3339 if(j==6)glColor4f(1,1,1,1);
3340 else glColor4f(1,0,0,1);
3342 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3343 glPushMatrix(); // Store The Projection Matrix
3344 glLoadIdentity(); // Reset The Projection Matrix
3345 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3346 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3347 glPushMatrix(); // Store The Modelview Matrix
3348 glLoadIdentity(); // Reset The Modelview Matrix
3351 //Draw world, draw map
3352 glTranslatef(2,-5,0);
3354 if(j>6&&j<nummenuitems-1)
3356 XYZ linestart,lineend,offset;
3363 //float linestartx,lineendx,linestarty,lineendy,offsetx,offsety;
3364 linestart.x=(startx[j]+endx[j])/2;
3365 linestart.y=(starty[j]+endy[j])/2;
3366 if(j>=6+accountactive->getCampaignChoicesMade()){
3367 linestart.x=(startx[6+accountactive->getCampaignChoicesMade()]+endx[6+accountactive->getCampaignChoicesMade()])/2;
3368 linestart.y=(starty[6+accountactive->getCampaignChoicesMade()]+endy[6+accountactive->getCampaignChoicesMade()])/2;
3370 lineend.x=(startx[j+1]+endx[j+1])/2;
3371 lineend.y=(starty[j+1]+endy[j+1])/2;
3372 offset=lineend-linestart;
3375 offset=DoRotation(offset,0,0,90);
3377 glDisable(GL_TEXTURE_2D);
3379 if(j<6+accountactive->getCampaignChoicesMade()){
3380 glColor4f(0.5,0,0,1);
3388 linestart+=fac*4*startsize;
3389 lineend-=fac*4*endsize;
3391 if(!(j>7+accountactive->getCampaignChoicesMade()+campaignchoicenum)){
3392 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3396 glVertex3f(linestart.x-offset.x*startsize, linestart.y-offset.y*startsize, 0.0f);
3398 glVertex3f(linestart.x+offset.x*startsize, linestart.y+offset.y*startsize, 0.0f);
3400 glVertex3f(lineend.x+offset.x*endsize, lineend.y+offset.y*endsize, 0.0f);
3402 glVertex3f(lineend.x-offset.x*endsize, lineend.y-offset.y*endsize, 0.0f);
3406 glEnable(GL_TEXTURE_2D);
3410 if(j==6)glBindTexture( GL_TEXTURE_2D, Mainmenuitems[7]);
3411 else glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
3412 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
3413 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
3414 if(j-7<accountactive->getCampaignChoicesMade())glColor4f(0.5,0,0,1);
3415 if(j-7>=accountactive->getCampaignChoicesMade())glColor4f(1,0,0,1);
3416 if(j==6)glColor4f(1,1,1,1);
3419 itemsize=abs(startx[j]-endx[j])/2;
3421 midpoint.x=(startx[j]+endx[j])/2;
3422 midpoint.y=(starty[j]+endy[j])/2;
3423 if(j>6&&(j-7<accountactive->getCampaignChoicesMade()))itemsize*=.5;
3424 if(!(j-7>accountactive->getCampaignChoicesMade()+campaignchoicenum))
3426 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3430 glVertex3f(midpoint.x-itemsize+movex[j]*transition, midpoint.y-itemsize+movey[j]*transition, 0.0f);
3432 glVertex3f(midpoint.x+itemsize+movex[j]*transition, midpoint.y-itemsize+movey[j]*transition, 0.0f);
3434 glVertex3f(midpoint.x+itemsize+movex[j]*transition, midpoint.y+itemsize+movey[j]*transition, 0.0f);
3436 glVertex3f(midpoint.x-itemsize+movex[j]*transition, midpoint.y+itemsize+movey[j]*transition, 0.0f);
3440 //glDisable(GL_ALPHA_TEST);
3441 if(j<4)glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3444 if(1-((float)i)/10-(1-selectedlong[j])>0)
3446 glColor4f(1,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3447 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3451 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);
3453 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);
3455 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);
3457 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);
3465 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3467 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3469 if(j-7>=accountactive->getCampaignChoicesMade()){
3470 text.glPrintOutlined(0.9,0,0,startx[j]+10,starty[j]-4,menustring[j],0,0.6,640,480);
3471 glDisable(GL_DEPTH_TEST);
3477 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3479 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3482 if(mainmenu==1||mainmenu==2)
3483 if(transition<.1||transition>.9){
3484 glClear(GL_DEPTH_BUFFER_BIT);
3485 glEnable(GL_ALPHA_TEST);
3486 glAlphaFunc(GL_GREATER, 0.001f);
3487 glEnable(GL_TEXTURE_2D);
3488 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3489 glDisable(GL_CULL_FACE);
3490 glDisable(GL_LIGHTING);
3492 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3493 glPushMatrix(); // Store The Projection Matrix
3494 glLoadIdentity(); // Reset The Projection Matrix
3495 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3496 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3497 glPushMatrix(); // Store The Modelview Matrix
3498 glLoadIdentity(); // Reset The Modelview Matrix
3500 glDisable(GL_TEXTURE_2D);
3502 glColor4f(1,0,0,1-(transition*10));
3504 glColor4f(1,0,0,1-((1-transition)*10));
3507 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3511 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3512 glPushMatrix(); // Store The Projection Matrix
3513 glLoadIdentity(); // Reset The Projection Matrix
3514 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
3515 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3516 glPushMatrix(); // Store The Modelview Matrix
3517 glLoadIdentity(); // Reset The Modelview Matrix
3518 glTranslatef(screenwidth/2,screenheight/2,0);
3520 glScalef((float)screenwidth/2,(float)screenheight/2,1);
3521 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3523 glEnable(GL_TEXTURE_2D);
3525 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
3526 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
3528 if(!waiting) { // hide the cursor while waiting for a key
3530 glTranslatef(mousecoordh-screenwidth/2,mousecoordv*-1+screenheight/2,0);
3531 glScalef((float)screenwidth/64,(float)screenwidth/64,1);
3532 glTranslatef(1,-1,0);
3533 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3535 glBindTexture( GL_TEXTURE_2D, cursortexture);
3537 //glScalef(.25,.25,.25);
3540 glVertex3f(-1, -1, 0.0f);
3542 glVertex3f(1, -1, 0.0f);
3544 glVertex3f(1, 1, 0.0f);
3546 glVertex3f(-1, 1, 0.0f);
3552 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3558 //printf("Flash amount: %f, delay %i\n", flashamount, flashdelay);
3559 if(flashamount>1)flashamount=1;
3560 if(flashdelay<=0)flashamount-=multiplier;
3562 if(flashamount<0)flashamount=0;
3563 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3564 glDisable(GL_CULL_FACE);
3565 glDisable(GL_LIGHTING);
3566 glDisable(GL_TEXTURE_2D);
3568 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3569 glPushMatrix(); // Store The Projection Matrix
3570 glLoadIdentity(); // Reset The Projection Matrix
3571 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
3572 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3573 glPushMatrix(); // Store The Modelview Matrix
3574 glLoadIdentity(); // Reset The Modelview Matrix
3575 glScalef(screenwidth,screenheight,1);
3576 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3578 glColor4f(flashr,flashg,flashb,flashamount);
3580 glVertex3f(0, 0, 0.0f);
3581 glVertex3f(256, 0, 0.0f);
3582 glVertex3f(256, 256, 0.0f);
3583 glVertex3f(0, 256, 0.0f);
3585 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3586 glPopMatrix(); // Restore The Old Projection Matrix
3587 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3588 glPopMatrix(); // Restore The Old Projection Matrix
3589 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
3590 glEnable(GL_CULL_FACE);
3591 glDisable(GL_BLEND);
3596 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)||(!gameon&&gamestarted)){
3597 tempmult=multiplier;
3602 if ( side == stereoRight || side == stereoCenter ) {
3603 if(drawmode!=motionblurmode||mainmenu){
3608 //myassert(glGetError() == GL_NO_ERROR);
3609 glDrawBuffer(GL_BACK);
3610 glReadBuffer(GL_BACK);
3615 if(drawtoggle==2)drawtoggle=0;
3617 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)){
3618 multiplier=tempmult;
3620 //Jordan fixed your warning!