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){
272 DSpContext_FadeGamma(NULL,200,&color2);
276 if(drawtoggle!=2)drawtoggle=1-drawtoggle;
280 texviewwidth=kTextureSize;
281 if(texviewwidth>screenwidth)texviewwidth=screenwidth;
282 texviewheight=kTextureSize;
283 if(texviewheight>screenheight)texviewheight=screenheight;
285 texcoordwidth=screenwidth/kTextureSize;
286 texcoordheight=screenheight/kTextureSize;
287 if(texcoordwidth>1)texcoordwidth=1;
288 if(texcoordheight>1)texcoordheight=1;
291 glDrawBuffer(GL_BACK);
292 glReadBuffer(GL_BACK);
294 if(abs(blurness-targetblurness)<multiplier*10||abs(blurness-targetblurness)>2){
295 blurness=targetblurness;
296 targetblurness=(float)(abs(Random()%100))/40;
298 if(blurness<targetblurness)
299 blurness+=multiplier*5;
301 blurness-=multiplier*5;
304 static XYZ terrainlight;
305 static float distance;
306 if(drawmode==normalmode)ReSizeGLScene(90,.1f);
307 if(drawmode!=normalmode)glViewport(0,0,texviewwidth,texviewheight);
308 glDepthFunc(GL_LEQUAL);
310 glAlphaFunc(GL_GREATER, 0.0001f);
311 glEnable(GL_ALPHA_TEST);
312 glClearColor(0.25f, 0.25f, 0.25f, 1.0f);
313 glClear(GL_DEPTH_BUFFER_BIT);
315 glMatrixMode (GL_MODELVIEW);
316 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
319 // Move the camera for the current eye's point of view.
320 // Reverse the movement if we're reversing stereo
321 glTranslatef((stereoseparation/2) * side * (stereoreverse ? -1 : 1), 0, 0);
323 if(!cameramode&&!freeze&&!winfreeze){
324 glRotatef(float(Random()%100)/10*camerashake/*+(woozy*woozy)/10*/,0,0,1);
325 glRotatef(rotation2+sin(woozy/2)*(player[0].damage/player[0].damagetolerance)*5,1,0,0);
326 glRotatef(rotation+sin(woozy)*(player[0].damage/player[0].damagetolerance)*5,0,1,0);
328 if(cameramode||freeze||winfreeze){
329 glRotatef(rotation2,1,0,0);
330 glRotatef(rotation,0,1,0);
333 if(environment==desertenvironment){
334 glRotatef((float)(abs(Random()%100))/3000-1,1,0,0);
335 glRotatef((float)(abs(Random()%100))/3000-1,0,1,0);
337 SetUpLight(&light,0);
339 if(environment==desertenvironment&&detail==2)glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, blurness+.4 );
340 if(environment==desertenvironment){
341 glRotatef((float)(abs(Random()%100))/1000,1,0,0);
342 glRotatef((float)(abs(Random()%100))/1000,0,1,0);
345 glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0);
347 glTranslatef(-viewer.x,-viewer.y,-viewer.z);
348 frustum.GetFrustum();
352 static float size,opacity,rotation;
354 for(k=0;k<numplayers;k++){
355 if(!player[k].skeleton.free&&player[k].playerdetail&&player[k].howactive<typesleeping)
356 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)
357 for(i=0;i<player[k].skeleton.num_joints;i++){
358 if(player[k].skeleton.joints[i].label==leftknee||player[k].skeleton.joints[i].label==rightknee||player[k].skeleton.joints[i].label==groin){
359 point=DoRotation(player[k].skeleton.joints[i].position,0,player[k].rotation,0)*player[k].scale+player[k].coords;
361 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;
362 if(k!=0&&tutoriallevel==1){
363 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;
365 terrain.MakeDecal(shadowdecal,point,size,opacity,rotation);
366 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
367 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
368 if(objects.position[j].y<player[k].coords.y||objects.type[j]==tunneltype||objects.type[j]==weirdtype){
369 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);
372 if(k!=0&&tutoriallevel==1){
373 opacity=.2+.2*sin(smoketex*6+i);
375 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
380 if((player[k].skeleton.free||player[k].howactive>=typesleeping)&&player[k].playerdetail)
381 if(frustum.SphereInFrustum(player[k].coords.x,player[k].coords.y,player[k].coords.z,player[k].scale*5)&&player[k].occluded<25)
382 for(i=0;i<player[k].skeleton.num_joints;i++){
383 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){
384 if(player[k].skeleton.free)point=player[k].skeleton.joints[i].position*player[k].scale+player[k].coords;
385 else point=DoRotation(player[k].skeleton.joints[i].position,0,player[k].rotation,0)*player[k].scale+player[k].coords;
387 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;
388 if(k!=0&&tutoriallevel==1){
389 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;
391 terrain.MakeDecal(shadowdecal,point,size,opacity*.7,rotation);
392 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
393 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
394 if(objects.position[j].y<player[k].coords.y||objects.type[j]==tunneltype||objects.type[j]==weirdtype){
395 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);
396 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);
399 if(k!=0&&tutoriallevel==1){
400 opacity=.2+.2*sin(smoketex*6+i);
402 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
408 if(!player[k].playerdetail)
409 if(frustum.SphereInFrustum(player[k].coords.x,player[k].coords.y,player[k].coords.z,player[k].scale*5))
411 point=player[k].coords;
413 opacity=.4-(player[k].coords.y-terrain.getHeight(player[k].coords.x,player[k].coords.z))/5;
414 terrain.MakeDecal(shadowdecal,point,size,opacity*.7,rotation);
415 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
416 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
417 point=DoRotation(player[k].coords-objects.position[j],0,-objects.rotation[j],0);
420 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
426 glEnable(GL_TEXTURE_2D);
428 glEnable(GL_DEPTH_TEST);
429 glEnable(GL_CULL_FACE);
431 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
432 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
433 glBindTexture( GL_TEXTURE_2D, terraintexture);
435 glBindTexture( GL_TEXTURE_2D, terraintexture2);
437 //glBindTexture( GL_TEXTURE_2D, terraintexture3);
438 //glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
441 terrain.drawdecals();
444 glEnable(GL_CULL_FACE);
445 glEnable(GL_LIGHTING);
447 glEnable(GL_TEXTURE_2D);
450 glEnable(GL_COLOR_MATERIAL);
465 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
466 glEnable(GL_CULL_FACE);
467 glCullFace(GL_FRONT);
469 for(k=0;k<numplayers;k++){
470 if(k==0||tutoriallevel!=1){
472 glEnable(GL_LIGHTING);
473 terrainlight=terrain.getLighting(player[k].coords.x,player[k].coords.z);
474 distance=findDistancefast(&viewer,&player[k].coords);
475 distance=(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance;
476 glColor4f(terrainlight.x,terrainlight.y,terrainlight.z,distance);
477 if(distance>=1)glDisable(GL_BLEND);
479 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;
481 if(!player[k].occluded==0)i=checkcollide(viewer,checkpoint,player[k].lastoccluded);
482 if(i==-1||player[k].occluded==0)i=checkcollide(viewer,checkpoint);
484 player[k].occluded+=1;
485 player[k].lastoccluded=i;
487 else player[k].occluded=0;
488 if(player[k].occluded<25)player[k].DrawSkeleton();
494 if(!cameramode&&musictype==stream_music2)playerdist=findDistancefastflat(&player[0].coords,&viewer);
495 else playerdist=-100;
498 glEnable(GL_TEXTURE_2D);
503 if(frustum.SphereInFrustum(realhawkcoords.x+hawk.boundingspherecenter.x,realhawkcoords.y+hawk.boundingspherecenter.y,realhawkcoords.z+hawk.boundingspherecenter.z,2)){
504 glAlphaFunc(GL_GREATER, 0.0001f);
506 glDisable(GL_CULL_FACE);
507 glDisable(GL_LIGHTING);
509 glTranslatef(hawkcoords.x,hawkcoords.y,hawkcoords.z);
510 glRotatef(hawkrotation,0,1,0);
511 glTranslatef(25,0,0);
512 distance=findDistancefast(&viewer,&realhawkcoords)*1.2;
513 glColor4f(light.color[0],light.color[1],light.color[2],(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance);
514 if((viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance>1)glColor4f(light.color[0],light.color[1],light.color[2],1);
515 if((viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance>0)
516 hawk.drawdifftex(hawktexture);
520 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
521 glEnable(GL_CULL_FACE);
522 glCullFace(GL_FRONT);
524 for(k=0;k<numplayers;k++){
525 if(!(k==0||tutoriallevel!=1)){
527 glEnable(GL_LIGHTING);
528 terrainlight=terrain.getLighting(player[k].coords.x,player[k].coords.z);
529 distance=findDistancefast(&viewer,&player[k].coords);
530 distance=(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance;
531 glColor4f(terrainlight.x,terrainlight.y,terrainlight.z,distance);
532 if(distance>=1)glDisable(GL_BLEND);
534 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;
536 if(!player[k].occluded==0)i=checkcollide(viewer,checkpoint,player[k].lastoccluded);
537 if(i==-1||player[k].occluded==0)i=checkcollide(viewer,checkpoint);
539 player[k].occluded+=1;
540 player[k].lastoccluded=i;
542 else player[k].occluded=0;
543 if(player[k].occluded<25)player[k].DrawSkeleton();
549 glEnable(GL_TEXTURE_2D);
554 glDisable(GL_COLOR_MATERIAL);
556 glDisable(GL_LIGHTING);
557 glDisable(GL_TEXTURE_2D);
565 glDisable(GL_LIGHTING);
566 glDisable(GL_TEXTURE_2D);
567 glDisable(GL_COLOR_MATERIAL);
570 for(k=0;k<numplayers;k++){
571 if(player[k].numwaypoints>1){
572 glBegin(GL_LINE_LOOP);
573 for(i=0;i<player[k].numwaypoints;i++){
574 glVertex3f(player[k].waypoints[i].x,player[k].waypoints[i].y+.5,player[k].waypoints[i].z);
583 for(k=0;k<numpathpoints;k++){
584 if(numpathpointconnect[k]){
585 for(i=0;i<numpathpointconnect[k];i++){
586 glBegin(GL_LINE_LOOP);
587 glVertex3f(pathpoint[k].x,pathpoint[k].y+.5,pathpoint[k].z);
588 glVertex3f(pathpoint[pathpointconnect[k][i]].x,pathpoint[pathpointconnect[k][i]].y+.5,pathpoint[pathpointconnect[k][i]].z);
596 glVertex3f(pathpoint[pathpointselected].x,pathpoint[pathpointselected].y+.5,pathpoint[pathpointselected].z);
603 glEnable(GL_TEXTURE_2D);
604 glColor4f(.5,.5,.5,1);
606 sprintf (string, " ",(int)(fps));
607 text.glPrint(10,30,string,0,.8,screenwidth,screenheight);
610 if(bonus>0&&bonustime<1&&!winfreeze&&indialogue==-1/*bonustime<4*/){
611 if(bonus==tracheotomy)sprintf (string, "Tracheotomy!");
612 else if(bonus==backstab)sprintf (string, "Backstabber!");
613 else if(bonus==spinecrusher)sprintf (string, "Spinecrusher!");
614 else if(bonus==ninja)sprintf (string, "Ninja Bonus!");
615 else if(bonus==style)sprintf (string, "Style Bonus!");
616 else if(bonus==cannon)sprintf (string, "Leg Cannon!");
617 else if(bonus==aimbonus)sprintf (string, "Nice Aim!");
618 else if(bonus==deepimpact)sprintf (string, "Heavy Impact!");
619 else if(bonus==touchofdeath)sprintf (string, "Touch of Death!");
620 else if(bonus==swordreversebonus)sprintf (string, "Sword Disarm!");
621 else if(bonus==staffreversebonus)sprintf (string, "Staff Disarm!");
622 else if(bonus==reverseko)sprintf (string, "Reversal KO!");
623 else if(bonus==solidhit)sprintf (string, "Solid Hit!");
624 else if(bonus==twoxcombo)sprintf (string, "2X Combo!");
625 else if(bonus==threexcombo)sprintf (string, "3X Combo!");
626 else if(bonus==fourxcombo)sprintf (string, "4X COMBO!");
627 else if(bonus==megacombo)sprintf (string, "MEGA COMBO!");
628 else if(bonus==Reversal)sprintf (string, "Reversal!");
629 else if(bonus==Stabbonus)sprintf (string, "Punctured!");
630 else if(bonus==Slicebonus)sprintf (string, "Sliced!");
631 else if(bonus==Bullseyebonus)sprintf (string, "Bullseye!");
632 else if(bonus==Slashbonus)sprintf (string, "Slashed!");
633 else if(bonus==Wolfbonus)sprintf (string, "WOLF SLAYER!");
634 else if(bonus==FinishedBonus)sprintf (string, "SLAIN!");
635 else if(bonus==TackleBonus)sprintf (string, "Tackle!");
636 else if(bonus==AboveBonus)sprintf (string, "Death from Above!");
637 else sprintf (string, "Excellent!");
639 glColor4f(0,0,0,1-bonustime);
640 text.glPrintOutline(1024/2-10*strlen(string)-4,768/16-4+768*4/5,string,1,2.5,1024,768);
641 glColor4f(1,0,0,1-bonustime);
642 text.glPrint(1024/2-10*strlen(string),768/16+768*4/5,string,1,2,1024,768);
644 sprintf (string, "%d",(int)bonusvalue);
645 glColor4f(0,0,0,1-bonustime);
646 text.glPrintOutline(1024/2-10*strlen(string)-4,768/16-4-20+768*4/5,string,1,2.5*.8,1024,768);
647 glColor4f(1,0,0,1-bonustime);
648 text.glPrint(1024/2-10*strlen(string),768/16-20+768*4/5,string,1,2*.8,1024,768);
649 glColor4f(.5,.5,.5,1);
652 if(tutoriallevel==1){
653 tutorialopac=tutorialmaxtime-tutorialstagetime;
654 if(tutorialopac>1)tutorialopac=1;
655 if(tutorialopac<0)tutorialopac=0;
657 sprintf (string, " ");
658 sprintf (string2, " ");
659 sprintf (string3, " ");
660 if(tutorialstage==0){
661 sprintf (string, " ");
662 sprintf (string2, " ");
663 sprintf (string3, " ");
665 if(tutorialstage==1){
666 sprintf (string, "Welcome to the Lugaru training level!");
667 sprintf (string2, " ");
668 sprintf (string3, " ");
670 if(tutorialstage==2){
671 sprintf (string, "BASIC MOVEMENT:");
672 sprintf (string2, " ");
673 sprintf (string3, " ");
675 if(tutorialstage==3){
676 sprintf (string, "You can move the mouse to rotate the camera.");
677 sprintf (string2, " ");
678 sprintf (string3, " ");
680 if(tutorialstage==4){
681 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));
682 sprintf (string2, "All movement is relative to the camera.");
683 sprintf (string3, " ");
685 if(tutorialstage==5){
686 sprintf (string, "Please press %s to jump.",Input::keyToChar(jumpkey));
687 sprintf (string2, "You can hold it longer to jump higher.");
688 sprintf (string3, " ");
690 if(tutorialstage==6){
691 sprintf (string, "You can press %s to crouch.",Input::keyToChar(crouchkey));
692 sprintf (string2, "You can jump higher from a crouching position.");
693 sprintf (string3, " ");
695 if(tutorialstage==7){
696 sprintf (string, "While running, you can press %s to roll.",Input::keyToChar(crouchkey));
697 sprintf (string2, " ");
698 sprintf (string3, " ");
700 if(tutorialstage==8){
701 sprintf (string, "While crouching, you can sneak around silently");
702 sprintf (string2, "using the movement keys.");
703 sprintf (string3, " ");
705 if(tutorialstage==9){
706 sprintf (string, "Release the crouch key while sneaking and hold the movement keys");
707 sprintf (string2, "to run animal-style.");
708 sprintf (string3, " ");
710 if(tutorialstage==10){
711 sprintf (string, "ADVANCED MOVEMENT:");
712 sprintf (string2, " ");
713 sprintf (string3, " ");
715 if(tutorialstage==11){
716 sprintf (string, "When you jump at a wall, you can hold %s again",Input::keyToChar(jumpkey));
717 sprintf (string2, "during impact to perform a walljump.");
718 sprintf (string3, "Be sure to use the movement keys to press against the wall");
720 if(tutorialstage==12){
721 sprintf (string, "While in the air, you can press crouch to flip.",Input::keyToChar(jumpkey));
722 sprintf (string2, "Walljumps and flips confuse enemies and give you more control.");
723 sprintf (string3, " ");
725 if(tutorialstage==13){
726 sprintf (string, "BASIC COMBAT:");
727 sprintf (string2, " ");
728 sprintf (string3, " ");
730 if(tutorialstage==14){
731 sprintf (string, "There is now an imaginary enemy");
732 sprintf (string2, "in the middle of the training area.");
733 sprintf (string3, " ");
735 if(tutorialstage==15){
736 if(attackkey==MOUSEBUTTON1)sprintf (string, "Click to attack when you are near an enemy.");
737 else sprintf (string, "Press %s to attack when you are near an enemy.",Input::keyToChar(attackkey));
738 sprintf (string2, "You can punch by standing still near an enemy and attacking.");
739 sprintf (string3, " ");
741 if(tutorialstage==16){
742 sprintf (string, "If you are close, you will perform a weak punch.");
743 sprintf (string2, "The weak punch is excellent for starting attack combinations.");
744 sprintf (string3, " ");
746 if(tutorialstage==17){
747 sprintf (string, "Attacking while running results in a spin kick.");
748 sprintf (string2, "This is one of your most powerful ground attacks.");
749 sprintf (string3, " ");
751 if(tutorialstage==18){
752 sprintf (string, "Sweep the enemy's legs out by attacking while crouched.");
753 sprintf (string2, "This is a very fast attack, and easy to follow up.");
754 sprintf (string3, " ");
756 if(tutorialstage==19){
757 sprintf (string, "When an enemy is on the ground, you can deal some extra");
758 sprintf (string2, "damage by running up and drop-kicking him.");
759 sprintf (string3, "(Try knocking them down with a sweep first)");
761 if(tutorialstage==20){
762 sprintf (string, "Your most powerful individual attack is the rabbit kick.");
763 if(attackkey==MOUSEBUTTON1)sprintf (string2, "Run at the enemy while holding the mouse button, and press");
764 else sprintf (string2, "Run at the enemy while holding %s, and press", Input::keyToChar(attackkey));
765 sprintf (string3, "the jump key (%s) to attack.",Input::keyToChar(jumpkey));
767 if(tutorialstage==21){
768 sprintf (string, "This attack is devastating if timed correctly.");
769 sprintf (string2, "Even if timed incorrectly, it will knock the enemy over.");
770 if(againbonus)sprintf (string3, "Try rabbit-kicking the imaginary enemy again.");
771 else sprintf (string3, "Try rabbit-kicking the imaginary enemy.");
773 if(tutorialstage==22){
774 sprintf (string, "If you sneak behind an enemy unnoticed, you can kill");
775 sprintf (string2, "him instantly. Move close behind this enemy");
776 sprintf (string3, "and attack.");
778 if(tutorialstage==23){
779 sprintf (string, "Another important attack is the wall kick. When an enemy");
780 sprintf (string2, "is near a wall, perform a walljump nearby and hold");
781 sprintf (string3, "the attack key during impact with the wall.");
783 if(tutorialstage==24){
784 sprintf (string, "You can tackle enemies by running at them animal-style");
785 if(attackkey==MOUSEBUTTON1)sprintf (string2, "and pressing jump (%s) or attack(mouse button).",Input::keyToChar(jumpkey));
786 else sprintf (string2, "and pressing jump (%s) or attack(%s).",Input::keyToChar(jumpkey),Input::keyToChar(attackkey));
787 sprintf (string3, "This is especially useful when they are running away.");
789 if(tutorialstage==25){
790 sprintf (string, "Dodge by pressing back and attack. Dodging is essential");
791 sprintf (string2, "against enemies with swords or other long weapons.");
792 sprintf (string3, " ");
794 if(tutorialstage==26){
795 sprintf (string, "REVERSALS AND COUNTER-REVERSALS");
796 sprintf (string2, " ");
797 sprintf (string3, " ");
799 if(tutorialstage==27){
800 sprintf (string, "The enemy can now reverse your attacks.");
801 sprintf (string2, " ");
802 sprintf (string3, " ");
804 if(tutorialstage==28){
805 sprintf (string, "If you attack, you will notice that the enemy now sometimes");
806 sprintf (string2, "catches your attack and uses it against you. Hold");
807 sprintf (string3, "crouch (%s) after attacking to escape from reversals.",Input::keyToChar(crouchkey));
809 if(tutorialstage==29){
810 sprintf (string, "Try escaping from two more reversals in a row.");
811 sprintf (string2, " ");
812 sprintf (string3, " ");
814 if(tutorialstage==30){
815 sprintf (string, "Good!");
816 sprintf (string2, " ");
817 sprintf (string3, " ");
819 if(tutorialstage==31){
820 sprintf (string, "To reverse an attack, you must tap crouch (%s) during the",Input::keyToChar(crouchkey));
821 sprintf (string2, "enemy's attack. You must also be close to the enemy;");
822 sprintf (string3, "this is especially important against armed opponents.");
824 if(tutorialstage==32){
825 sprintf (string, "The enemy can attack in %d seconds.", (int)(tutorialmaxtime-tutorialstagetime));
826 sprintf (string2, "This imaginary opponents attacks will be highlighted");
827 sprintf (string3, "to make this easier.");
829 if(tutorialstage==33){
830 sprintf (string, "Reverse three enemy attacks!");
831 sprintf (string2, " ");
832 sprintf (string3, " ");
834 if(tutorialstage==34){
835 sprintf (string, "Reverse two more enemy attacks!");
836 sprintf (string2, " ");
837 sprintf (string3, " ");
839 if(tutorialstage==35){
840 sprintf (string, "Reverse one more enemy attack!");
841 sprintf (string2, " ");
842 sprintf (string3, " ");
844 if(tutorialstage==36){
845 sprintf (string, "Excellent!");
846 sprintf (string2, " ");
847 sprintf (string3, " ");
849 if(tutorialstage==37){
850 sprintf (string, "Now spar with the enemy for %d more seconds.", (int)(tutorialmaxtime-tutorialstagetime));
851 sprintf (string2, "Damage dealt: %d",(int)damagedealt);
852 sprintf (string3, "Damage taken: %d.",(int)damagetaken);
854 if(tutorialstage==38){
855 sprintf (string, "WEAPONS:");
856 sprintf (string2, " ");
857 sprintf (string3, " ");
859 if(tutorialstage==39){
860 sprintf (string, "There is now an imaginary knife");
861 sprintf (string2, "in the center of the training area.");
862 sprintf (string3, " ");
864 if(tutorialstage==40){
865 sprintf (string, "Stand, roll or handspring over the knife");
866 sprintf (string2, "while pressing %s to pick it up.",Input::keyToChar(throwkey));
867 sprintf (string3, "You can crouch and press the same key to drop it again.");
869 if(tutorialstage==41){
870 sprintf (string, "You can equip and unequip weapons using the %s key.",Input::keyToChar(drawkey));
871 sprintf (string2, "Sometimes it is best to keep them unequipped to");
872 sprintf (string3, "prevent enemies from taking them. ");
874 if(tutorialstage==42){
875 sprintf (string, "The knife is the smallest weapon and the least encumbering.");
876 sprintf (string2, "You can equip or unequip it while standing, crouching,");
877 sprintf (string3, "running or flipping.");
879 if(tutorialstage==43){
880 sprintf (string, "You perform weapon attacks the same way as unarmed attacks,");
881 sprintf (string2, "but sharp weapons cause permanent damage, instead of the");
882 sprintf (string3, "temporary trauma from blunt weapons, fists and feet.");
884 if(tutorialstage==44){
885 sprintf (string, "The enemy now has your knife!");
886 sprintf (string2, "Please reverse two of his knife attacks.");
887 sprintf (string3, " ");
889 if(tutorialstage==45){
890 sprintf (string, "Please reverse one more of his knife attacks.");
891 sprintf (string2, " ");
892 sprintf (string3, " ");
894 if(tutorialstage==46){
895 sprintf (string, "Now he has a sword!");
896 sprintf (string2, "The sword has longer reach than your arms, so you");
897 sprintf (string3, "must move close to reverse the sword slash.");
899 if(tutorialstage==47){
900 sprintf (string, "Long weapons like the sword and staff are also useful for defense;");
901 sprintf (string2, "you can parry enemy weapon attacks by pressing the attack key");
902 sprintf (string3, "at the right time. Please try parrying the enemy's attacks!");
904 if(tutorialstage==48){
905 sprintf (string, "The staff is like the sword, but has two main attacks.");
906 sprintf (string2, "The standing smash is fast and effective, and the running");
907 sprintf (string3, "spin smash is slower and more powerful.");
909 if(tutorialstage==49){
910 sprintf (string, "When facing an enemy, you can throw the knife with %s.",Input::keyToChar(throwkey));
911 sprintf (string2, "It is possible to throw the knife while flipping,");
912 sprintf (string3, "but it is very inaccurate.");
914 if(tutorialstage==50){
915 sprintf (string, "You now know everything you can learn from training.");
916 sprintf (string2, "Everything else you must learn from experience!");
917 sprintf (string3, " ");
919 if(tutorialstage==51){
920 sprintf (string, "Walk out of the training area to return to the main menu.");
921 sprintf (string2, " ");
922 sprintf (string3, " ");
925 glColor4f(0,0,0,tutorialopac);
926 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);
927 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);
928 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);
929 glColor4f(1,1,1,tutorialopac);
930 text.glPrint(screenwidth/2-7.6*strlen(string)*screenwidth/1024,screenheight/16+screenheight*4/5,string,1,1.5*screenwidth/1024,screenwidth,screenheight);
931 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);
932 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);
934 sprintf (string, "Press 'tab' to skip to the next item.",Input::keyToChar(jumpkey));
935 sprintf (string2, "Press escape at any time to");
936 sprintf (string3, "pause or exit the tutorial.");
939 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);
940 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);
941 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);
942 glColor4f(0.5,0.5,0.5,1);
943 text.glPrint(screenwidth/2-7.6*strlen(string)*screenwidth/1024*.8,0+screenheight*1/10,string,1,1.5*screenwidth/1024*.8,screenwidth,screenheight);
944 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);
945 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);
949 if(numhotspots&&(bonustime>=1||bonus<=0||bonustime<0)&&!tutoriallevel){
951 float closestdist=-1;
953 closest=currenthotspot;
954 for(i=0;i<numhotspots;i++){
955 distance=findDistancefast(&player[0].coords,&hotspot[i]);
956 if(closestdist==-1||distance<closestdist){
957 if(findDistancefast(&player[0].coords,&hotspot[i])<hotspotsize[i]&&((hotspottype[i]<=10&&hotspottype[i]>=0)||(hotspottype[i]<=40&&hotspottype[i]>=20))){
958 closestdist=distance;
964 currenthotspot=closest;
965 if(currenthotspot!=-1){
966 if(hotspottype[closest]<=10){
967 if(findDistancefast(&player[0].coords,&hotspot[closest])<hotspotsize[closest])
970 tutorialopac=tutorialmaxtime-tutorialstagetime;
971 if(tutorialopac>1)tutorialopac=1;
972 if(tutorialopac<0)tutorialopac=0;
974 sprintf (string, "%s", hotspottext[closest]);
981 if(string[i]=='\n'||string[i]>'z'||string[i]<' '||string[i]=='\0'){
982 glColor4f(0,0,0,tutorialopac);
983 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);
984 glColor4f(1,1,1,tutorialopac);
985 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);
988 if(string[i]=='\0')done=1;
994 else if (hotspottype[closest]>=20&&dialoguegonethrough[hotspottype[closest]-20]==0){
995 whichdialogue=hotspottype[closest]-20;
996 for(j=0;j<numdialogueboxes[whichdialogue];j++){
997 player[participantfocus[whichdialogue][j]].coords=participantlocation[whichdialogue][participantfocus[whichdialogue][j]];
998 player[participantfocus[whichdialogue][j]].rotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
999 player[participantfocus[whichdialogue][j]].targetrotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
1000 player[participantfocus[whichdialogue][j]].velocity=0;
1001 player[participantfocus[whichdialogue][j]].targetanimation=player[participantfocus[whichdialogue][j]].getIdle();
1002 player[participantfocus[whichdialogue][j]].targetframe=0;
1006 dialoguegonethrough[whichdialogue]++;
1007 if(dialogueboxsound[whichdialogue][indialogue]!=0){
1008 static float gLoc[3];
1009 static float vel[3];
1010 gLoc[0]=player[participantfocus[whichdialogue][indialogue]].coords.x;
1011 gLoc[1]=player[participantfocus[whichdialogue][indialogue]].coords.y;
1012 gLoc[2]=player[participantfocus[whichdialogue][indialogue]].coords.z;
1017 if(dialogueboxsound[whichdialogue][indialogue]==1)whichsoundplay=rabbitchitter;
1018 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
1019 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
1020 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
1021 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
1022 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
1023 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
1024 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
1025 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
1026 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
1027 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
1028 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
1029 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
1030 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
1031 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
1032 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
1033 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
1034 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
1035 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
1036 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
1037 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, true);
1038 OPENAL_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
1039 OPENAL_SetVolume(channels[whichsoundplay], 256);
1040 OPENAL_SetPaused(channels[whichsoundplay], false);
1046 if(indialogue!=-1&&!mainmenu){
1047 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1048 glDisable(GL_CULL_FACE);
1049 glDisable(GL_LIGHTING);
1050 glDisable(GL_TEXTURE_2D);
1052 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1053 glPushMatrix(); // Store The Projection Matrix
1054 glLoadIdentity(); // Reset The Projection Matrix
1055 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1056 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1057 glPushMatrix(); // Store The Modelview Matrix
1058 glLoadIdentity(); // Reset The Modelview Matrix
1059 if(dialogueboxlocation[whichdialogue][indialogue]==1)glTranslatef(0,screenheight*3/4,0);
1060 glScalef(screenwidth,screenheight/4,1);
1061 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1064 glColor4f(dialogueboxcolor[whichdialogue][indialogue][0],dialogueboxcolor[whichdialogue][indialogue][1],dialogueboxcolor[whichdialogue][indialogue][2],0.7);
1066 glVertex3f(0, 0, 0.0f);
1067 glVertex3f(1, 0, 0.0f);
1068 glVertex3f(1, 1, 0.0f);
1069 glVertex3f(0, 1, 0.0f);
1071 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1072 glPopMatrix(); // Restore The Old Projection Matrix
1073 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1074 glPopMatrix(); // Restore The Old Projection Matrix
1075 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1076 glEnable(GL_CULL_FACE);
1077 glDisable(GL_BLEND);
1079 glEnable(GL_TEXTURE_2D);
1086 startx=screenwidth*1/5;
1087 if(dialogueboxlocation[whichdialogue][indialogue]==1)starty=screenheight/16+screenheight*4/5;
1088 if(dialogueboxlocation[whichdialogue][indialogue]==2)starty=screenheight*1/5-screenheight/16;
1097 for(i=0;i<(int)strlen(dialoguename[whichdialogue][indialogue]);i++){
1098 tempname[tempnum]=dialoguename[whichdialogue][indialogue][i];
1100 if(dialoguename[whichdialogue][indialogue][i]=='#'||dialoguename[whichdialogue][indialogue][i]=='\0')goodchar=0;
1104 tempname[tempnum]='\0';
1107 sprintf (string, "%s: ", tempname);
1109 if(dialogueboxcolor[whichdialogue][indialogue][0]+dialogueboxcolor[whichdialogue][indialogue][1]+dialogueboxcolor[whichdialogue][indialogue][2]<1.5){
1110 glColor4f(0,0,0,tutorialopac);
1111 text.glPrintOutline(startx-2*7.6*strlen(string)*screenwidth/1024-4,starty-4,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight);
1112 glColor4f(0.7,0.7,0.7,tutorialopac);
1113 text.glPrint(startx-2*7.6*strlen(string)*screenwidth/1024,starty,string,1,1.5*screenwidth/1024,screenwidth,screenheight);
1117 glColor4f(0,0,0,tutorialopac);
1118 text.glPrintOutline(startx-2*7.6*strlen(string)*screenwidth/1024-4,starty-4,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight);
1122 for(i=0;i<(int)strlen(dialoguetext[whichdialogue][indialogue])+1;i++){
1123 tempname[tempnum]=dialoguetext[whichdialogue][indialogue][i];
1124 if(dialoguetext[whichdialogue][indialogue][i]!='#')tempnum++;
1127 sprintf (string, "%s", tempname);
1134 if(string[i]=='\n'||string[i]>'z'||string[i]<' '||string[i]=='\0'){
1135 if(dialogueboxcolor[whichdialogue][indialogue][0]+dialogueboxcolor[whichdialogue][indialogue][1]+dialogueboxcolor[whichdialogue][indialogue][2]<1.5){
1136 glColor4f(0,0,0,tutorialopac);
1137 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);
1138 glColor4f(1,1,1,tutorialopac);
1139 text.glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/,starty-20*screenwidth/1024*line,string,1,1.5*screenwidth/1024,screenwidth,screenheight,lastline,i);
1143 glColor4f(0,0,0,tutorialopac);
1144 text.glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/,starty-20*screenwidth/1024*line,string,1,1.5*screenwidth/1024,screenwidth,screenheight,lastline,i);
1148 if(string[i]=='\0')done=1;
1155 if(!tutoriallevel&&!winfreeze&&indialogue==-1&&!mainmenu){
1158 sprintf (string, "Score: %d", (int)accountactive->getCampaignScore());
1160 sprintf (string, "Score: %d", (int)accountactive->getCampaignScore()+(int)bonustotal);
1162 if(!campaign)sprintf (string, "Score: %d", (int)bonustotal);
1164 text.glPrintOutline(1024/40-4,768/16-4+768*14/16,string,1,1.5*1.25,1024,768);
1166 text.glPrint(1024/40,768/16+768*14/16,string,1,1.5,1024,768);
1168 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1169 glDisable(GL_CULL_FACE);
1170 glDisable(GL_LIGHTING);
1171 glDisable(GL_TEXTURE_2D);
1173 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1174 glPushMatrix(); // Store The Projection Matrix
1175 glLoadIdentity(); // Reset The Projection Matrix
1176 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1177 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1178 glPushMatrix(); // Store The Modelview Matrix
1179 glLoadIdentity(); // Reset The Modelview Matrix
1180 glTranslatef(15,screenheight*17.5/20,0);
1181 glScalef(screenwidth/3+20,screenheight/20,1);
1182 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1184 glColor4f(0.0,0.4,0.0,0.7);
1185 float bar=((float)player[0].damage)/player[0].damagetolerance;
1187 glVertex3f((bar<1?bar:1),0,0.0f);
1188 glVertex3f(1,0,0.0f);
1189 glVertex3f(1,1,0.0f);
1190 glVertex3f((bar<1?bar:1),1,0.0f);
1192 glColor4f(0.1,0.0,0.0,1);
1193 bar = ((float)player[0].bloodloss)/player[0].damagetolerance;
1195 glVertex3f(0,0,0.0f);
1196 glVertex3f((bar<1?bar:1),0,0.0f);
1197 glVertex3f((bar<1?bar:1),1,0.0f);
1198 glVertex3f(0,1,0.0f);
1200 glColor4f(0.4,0.0,0.0,0.7);
1201 bar = ((float)player[0].damage)/player[0].damagetolerance;
1203 glVertex3f(0,0,0.0f);
1204 glVertex3f((bar<1?bar:1),0,0.0f);
1205 glVertex3f((bar<1?bar:1),1,0.0f);
1206 glVertex3f(0,1,0.0f);
1208 glColor4f(0.4,0.0,0.0,0.7);
1209 bar = ((float)player[0].permanentdamage)/player[0].damagetolerance;
1211 glVertex3f(0,0,0.0f);
1212 glVertex3f((bar<1?bar:1),0,0.0f);
1213 glVertex3f((bar<1?bar:1),1,0.0f);
1214 glVertex3f(0,1,0.0f);
1216 glColor4f(0.4,0.0,0.0,0.7);
1217 bar = ((float)player[0].superpermanentdamage)/player[0].damagetolerance;
1219 glVertex3f(0,0,0.0f);
1220 glVertex3f((bar<1?bar:1),0,0.0f);
1221 glVertex3f((bar<1?bar:1),1,0.0f);
1222 glVertex3f(0,1,0.0f);
1224 glColor4f(0.0,0.0,0.0,0.7);
1226 glBegin(GL_LINE_STRIP);
1227 glVertex3f(0,0,0.0f);
1228 glVertex3f(1,0,0.0f);
1229 glVertex3f(1,1,0.0f);
1230 glVertex3f(0,1,0.0f);
1231 glVertex3f(0,0,0.0f);
1234 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1235 glPopMatrix(); // Restore The Old Projection Matrix
1236 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1237 glPopMatrix(); // Restore The Old Projection Matrix
1238 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1239 glEnable(GL_CULL_FACE);
1240 glDisable(GL_BLEND);
1242 glEnable(GL_TEXTURE_2D);
1244 // writing the numbers :
1245 sprintf (string, "Damages : %d/%d (%d)",(int)(player[0].damage),(int)(player[0].damagetolerance),(int)(player[0].bloodloss));
1247 text.glPrintOutline(1024/40-4,768/16-4+768*14/16-40,string,1,1.5*1.25,1024,768);
1249 text.glPrint(1024/40,768/16+768*14/16-40,string,1,1.5,1024,768);
1253 glColor4f(.5,.5,.5,1);
1256 if((texttoggle||editorenabled)&&debugmode&&!mainmenu){
1257 sprintf (string, "The framespersecond is %d.",(int)(fps));
1258 text.glPrint(10,30,string,0,.8,1024,768);
1260 sprintf (string, "Name: %s", registrationname);
1261 text.glPrint(10,260,string,0,.8,1024,768);
1265 sprintf (string, "Map editor enabled.");
1267 sprintf (string, "Map editor disabled.");
1268 text.glPrint(10,60,string,0,.8,1024,768);
1270 sprintf (string, "Object size: %f",editorsize);
1271 text.glPrint(10,75,string,0,.8,1024,768);
1272 if(editorrotation>=0)sprintf (string, "Object rotation: %f",editorrotation);
1273 else sprintf (string, "Object rotation: Random");
1274 text.glPrint(10,90,string,0,.8,1024,768);
1275 if(editorrotation2>=0)sprintf (string, "Object rotation2: %f",editorrotation2);
1276 else sprintf (string, "Object rotation2: Random");
1277 text.glPrint(10,105,string,0,.8,1024,768);
1278 sprintf (string, "Object type: %d",editortype);
1279 text.glPrint(10,120,string,0,.8,1024,768);
1280 switch(editortype) {
1282 sprintf (string, "(box)");
1285 sprintf (string, "(tree)");
1288 sprintf (string, "(wall)");
1291 sprintf (string, "(weird)");
1294 sprintf (string, "(spike)");
1297 sprintf (string, "(rock)");
1300 sprintf (string, "(bush)");
1303 sprintf (string, "(tunnel)");
1306 sprintf (string, "(chimney)");
1309 sprintf (string, "(platform)");
1312 sprintf (string, "(cool)");
1315 sprintf (string, "(fire)");
1318 text.glPrint(130,120,string,0,.8,1024,768);
1320 sprintf (string, "Numplayers: %d",numplayers);
1321 text.glPrint(10,155,string,0,.8,1024,768);
1322 sprintf (string, "Player %d: numwaypoints: %d",numplayers,player[numplayers-1].numwaypoints);
1323 text.glPrint(10,140,string,0,.8,1024,768);
1325 sprintf (string, "Difficulty: %d",difficulty);
1326 text.glPrint(10,240,string,0,.8,1024,768);
1331 if(drawmode==glowmode){
1332 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1333 glDisable(GL_CULL_FACE);
1334 glDisable(GL_LIGHTING);
1335 glDisable(GL_TEXTURE_2D);
1337 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1338 glPushMatrix(); // Store The Projection Matrix
1339 glLoadIdentity(); // Reset The Projection Matrix
1340 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1341 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1342 glPushMatrix(); // Store The Modelview Matrix
1343 glLoadIdentity(); // Reset The Modelview Matrix
1344 glScalef(screenwidth,screenheight,1);
1345 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1347 glColor4f(0,0,0,.5);
1349 glVertex3f(0, 0, 0.0f);
1350 glVertex3f(256, 0, 0.0f);
1351 glVertex3f(256, 256, 0.0f);
1352 glVertex3f(0, 256, 0.0f);
1354 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1355 glPopMatrix(); // Restore The Old Projection Matrix
1356 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1357 glPopMatrix(); // Restore The Old Projection Matrix
1358 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1359 glEnable(GL_CULL_FACE);
1360 glDisable(GL_BLEND);
1364 if((((blackout&&damageeffects)||(player[0].bloodloss>0&&damageeffects&&player[0].blooddimamount>0)||player[0].dead)&&!cameramode)||console){
1365 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1366 glDisable(GL_CULL_FACE);
1367 glDisable(GL_LIGHTING);
1368 glDisable(GL_TEXTURE_2D);
1370 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1371 glPushMatrix(); // Store The Projection Matrix
1372 glLoadIdentity(); // Reset The Projection Matrix
1373 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1374 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1375 glPushMatrix(); // Store The Modelview Matrix
1376 glLoadIdentity(); // Reset The Modelview Matrix
1377 glScalef(screenwidth,screenheight,1);
1378 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1380 if(player[0].dead)blackout+=multiplier*3;
1381 if(player[0].dead==1)blackout=.4f;
1382 if(player[0].dead==2&&blackout>.6)blackout=.6;
1383 glColor4f(0,0,0,blackout);
1384 if(!player[0].dead){
1385 if((player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5))*.3<.3){
1386 glColor4f(0,0,0,player[0].blooddimamount*player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5)*.3);
1387 blackout=player[0].blooddimamount*player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5)*.3;
1390 glColor4f(0,0,0,player[0].blooddimamount*.3);
1391 blackout=player[0].blooddimamount*.3;
1394 if(console)glColor4f(.7,0,0,.2);
1396 glVertex3f(0, 0, 0.0f);
1397 glVertex3f(256, 0, 0.0f);
1398 glVertex3f(256, 256, 0.0f);
1399 glVertex3f(0, 256, 0.0f);
1401 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1402 glPopMatrix(); // Restore The Old Projection Matrix
1403 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1404 glPopMatrix(); // Restore The Old Projection Matrix
1405 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1406 glEnable(GL_CULL_FACE);
1407 glDisable(GL_BLEND);
1411 if(flashamount>0&&damageeffects){
1412 if(flashamount>1)flashamount=1;
1413 if(flashdelay<=0)flashamount-=multiplier;
1415 if(flashamount<0)flashamount=0;
1416 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1417 glDisable(GL_CULL_FACE);
1418 glDisable(GL_LIGHTING);
1420 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1421 glPushMatrix(); // Store The Projection Matrix
1422 glLoadIdentity(); // Reset The Projection Matrix
1423 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1424 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1425 glPushMatrix(); // Store The Modelview Matrix
1426 glLoadIdentity(); // Reset The Modelview Matrix
1427 glScalef(screenwidth,screenheight,1);
1428 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1430 glColor4f(flashr,flashg,flashb,flashamount);
1432 glVertex3f(0, 0, 0.0f);
1433 glVertex3f(256, 0, 0.0f);
1434 glVertex3f(256, 256, 0.0f);
1435 glVertex3f(0, 256, 0.0f);
1437 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1438 glPopMatrix(); // Restore The Old Projection Matrix
1439 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1440 glPopMatrix(); // Restore The Old Projection Matrix
1441 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1442 glEnable(GL_CULL_FACE);
1443 glDisable(GL_BLEND);
1449 glEnable(GL_TEXTURE_2D);
1452 sprintf (string, " ]");
1453 text.glPrint(10,30+screenheight-330,string,0,1,screenwidth,screenheight);
1455 sprintf (string, "_");
1456 text.glPrint(30+(float)(displayselected)*10,30+(screenheight-330),string,0,1,screenwidth,screenheight);
1460 if((i!=0||chatting)&&displaytime[i]<4)
1461 for(j=0;j<displaychars[i];j++){
1462 glColor4f(1,1,1,4-displaytime[i]);
1463 if(j<displaychars[i]){
1464 sprintf (string, "%c",displaytext[i][j]);
1465 text.glPrint(30+j*10,30+i*20+(screenheight-330),string,0,1,screenwidth,screenheight);
1471 if(minimap&&indialogue==-1){
1472 float mapviewdist = 20000;
1474 glDisable(GL_DEPTH_TEST);
1475 glColor3f (1.0, 1.0, 1.0); // no coloring
1477 glEnable(GL_TEXTURE_2D);
1478 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1479 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1480 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1481 glDisable(GL_CULL_FACE);
1482 glDisable(GL_LIGHTING);
1484 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1485 glPushMatrix(); // Store The Projection Matrix
1486 glLoadIdentity(); // Reset The Projection Matrix
1487 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1488 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1489 glPushMatrix(); // Store The Modelview Matrix
1490 glLoadIdentity(); // Reset The Modelview Matrix
1491 glScalef((float)screenwidth/2,(float)screenwidth/2,1);
1492 glTranslatef(1.75,.25,0);
1493 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1501 int numliveplayers=0;
1503 for(i=0;i<numplayers;i++){
1504 if(!player[i].dead) numliveplayers++;
1509 for(i=0;i<objects.numobjects;i++){
1510 if(objects.type[i]==treetrunktype||objects.type[i]==boxtype){
1511 center+=objects.position[i];
1515 for(i=0;i<numplayers;i++){
1516 if(!player[i].dead)center+=player[i].coords;
1518 center/=numadd+numliveplayers;
1520 center=player[0].coords;
1522 float maxdistance=0;
1525 for(i=0;i<objects.numobjects;i++){
1526 tempdist=findDistancefast(¢er,&objects.position[i]);
1527 if(tempdist>maxdistance){
1529 maxdistance=tempdist;
1532 for(i=0;i<numplayers;i++){
1533 if(!player[i].dead){
1534 tempdist=findDistancefast(¢er,&player[i].coords);
1535 if(tempdist>maxdistance){
1537 maxdistance=tempdist;
1541 radius=fast_sqrt(maxdistance);
1545 glScalef(.25/radius*256*terrain.scale*.4,.25/radius*256*terrain.scale*.4,1);
1547 glScalef(1/(1/radius*256*terrain.scale*.4),1/(1/radius*256*terrain.scale*.4),1);
1549 glRotatef(player[0].lookrotation*-1+180,0,0,1);
1550 glTranslatef(-(center.x/terrain.scale/256*-2+1),(center.z/terrain.scale/256*-2+1),0);
1551 for(i=0;i<objects.numobjects;i++){
1552 if(objects.type[i]==treetrunktype){
1553 distcheck=findDistancefast(&player[0].coords,&objects.position[i]);
1554 if(distcheck<mapviewdist){
1555 glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
1556 glColor4f(0,.3,0,opac*(1-distcheck/mapviewdist));
1558 glTranslatef(objects.position[i].x/terrain.scale/256*-2+1,objects.position[i].z/terrain.scale/256*2-1,0);
1559 glRotatef(objects.rotation[i],0,0,1);
1560 glScalef(.003,.003,.003);
1563 glVertex3f(-1, -1, 0.0f);
1565 glVertex3f(1, -1, 0.0f);
1567 glVertex3f(1, 1, 0.0f);
1569 glVertex3f(-1, 1, 0.0f);
1574 if(objects.type[i]==boxtype){
1575 distcheck=findDistancefast(&player[0].coords,&objects.position[i]);
1576 if(distcheck<mapviewdist){
1577 glBindTexture( GL_TEXTURE_2D, Mapboxtexture);
1578 glColor4f(.4,.4,.4,opac*(1-distcheck/mapviewdist));
1580 glTranslatef(objects.position[i].x/terrain.scale/256*-2+1,objects.position[i].z/terrain.scale/256*2-1,0);
1581 glRotatef(objects.rotation[i],0,0,1);
1582 glScalef(.01*objects.scale[i],.01*objects.scale[i],.01*objects.scale[i]);
1585 glVertex3f(-1, -1, 0.0f);
1587 glVertex3f(1, -1, 0.0f);
1589 glVertex3f(1, 1, 0.0f);
1591 glVertex3f(-1, 1, 0.0f);
1598 glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
1599 for(i=0;i<numboundaries;i++){
1600 glColor4f(0,0,0,opac/3);
1602 glTranslatef(boundary[i].x/terrain.scale/256*-2+1,boundary[i].z/terrain.scale/256*2-1,0);
1603 glScalef(.002,.002,.002);
1606 glVertex3f(-1, -1, 0.0f);
1608 glVertex3f(1, -1, 0.0f);
1610 glVertex3f(1, 1, 0.0f);
1612 glVertex3f(-1, 1, 0.0f);
1617 for(i=0;i<numplayers;i++){
1618 distcheck=findDistancefast(&player[0].coords,&player[i].coords);
1619 if(distcheck<mapviewdist){
1621 glBindTexture( GL_TEXTURE_2D, Maparrowtexture);
1622 if(i==0)glColor4f(1,1,1,opac);
1623 else if(player[i].dead==2||player[i].howactive>typesleeping)glColor4f(0,0,0,opac*(1-distcheck/mapviewdist));
1624 else if(player[i].dead)glColor4f(.3,.3,.3,opac*(1-distcheck/mapviewdist));
1625 else if(player[i].aitype==attacktypecutoff)glColor4f(1,0,0,opac*(1-distcheck/mapviewdist));
1626 else if(player[i].aitype==passivetype)glColor4f(0,1,0,opac*(1-distcheck/mapviewdist));
1627 else glColor4f(1,1,0,1);
1628 glTranslatef(player[i].coords.x/terrain.scale/256*-2+1,player[i].coords.z/terrain.scale/256*2-1,0);
1629 glRotatef(player[i].rotation+180,0,0,1);
1630 glScalef(.005,.005,.005);
1633 glVertex3f(-1, -1, 0.0f);
1635 glVertex3f(1, -1, 0.0f);
1637 glVertex3f(1, 1, 0.0f);
1639 glVertex3f(-1, 1, 0.0f);
1645 glDisable(GL_TEXTURE_2D);
1646 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1647 glPopMatrix(); // Restore The Old Projection Matrix
1648 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1649 glPopMatrix(); // Restore The Old Projection Matrix
1650 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1651 glEnable(GL_CULL_FACE);
1652 glDisable(GL_BLEND);
1656 if(loading&&!stealthloading&&(!campaign||player[0].dead)){
1657 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1658 glDisable(GL_CULL_FACE);
1659 glDisable(GL_LIGHTING);
1660 glDisable(GL_TEXTURE_2D);
1662 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1663 glPushMatrix(); // Store The Projection Matrix
1664 glLoadIdentity(); // Reset The Projection Matrix
1665 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1666 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1667 glPushMatrix(); // Store The Modelview Matrix
1668 glLoadIdentity(); // Reset The Modelview Matrix
1669 glScalef(screenwidth,screenheight,1);
1670 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1672 glColor4f(0,0,0,.7);
1674 glVertex3f(0, 0, 0.0f);
1675 glVertex3f(256, 0, 0.0f);
1676 glVertex3f(256, 256, 0.0f);
1677 glVertex3f(0, 256, 0.0f);
1679 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1680 glPopMatrix(); // Restore The Old Projection Matrix
1681 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1682 glPopMatrix(); // Restore The Old Projection Matrix
1683 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1684 glEnable(GL_CULL_FACE);
1685 glDisable(GL_BLEND);
1689 glDisable(GL_DEPTH_TEST);
1690 glColor3f (1.0, 1.0, 1.0); // no coloring
1692 glEnable(GL_TEXTURE_2D);
1697 glEnable(GL_TEXTURE_2D);
1699 sprintf (string, "Loading...");
1700 text.glPrint(1024/2-90,768/2,string,1,2,1024,768);
1703 //if(ismotionblur)drawmode=motionblurmode;
1704 drawmode=normalmode;
1707 if(winfreeze&&!campaign){
1708 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1709 glDisable(GL_CULL_FACE);
1710 glDisable(GL_LIGHTING);
1711 glDisable(GL_TEXTURE_2D);
1713 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1714 glPushMatrix(); // Store The Projection Matrix
1715 glLoadIdentity(); // Reset The Projection Matrix
1716 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1717 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1718 glPushMatrix(); // Store The Modelview Matrix
1719 glLoadIdentity(); // Reset The Modelview Matrix
1720 glScalef(screenwidth,screenheight,1);
1721 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1723 glColor4f(0,0,0,.4);
1725 glVertex3f(0, 0, 0.0f);
1726 glVertex3f(256, 0, 0.0f);
1727 glVertex3f(256, 256, 0.0f);
1728 glVertex3f(0, 256, 0.0f);
1730 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1731 glPopMatrix(); // Restore The Old Projection Matrix
1732 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1733 glPopMatrix(); // Restore The Old Projection Matrix
1734 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1735 glEnable(GL_CULL_FACE);
1736 glDisable(GL_BLEND);
1740 glDisable(GL_DEPTH_TEST);
1741 glColor3f (1.0, 1.0, 1.0); // no coloring
1743 glEnable(GL_TEXTURE_2D);
1749 if(damagetaken==0&&player[0].bloodloss==0){
1750 awards[numawards]=awardflawless;
1753 bool alldead = true;
1754 for(i=1;i<numplayers;i++){
1755 if(player[i].dead!=2)alldead=0;
1758 awards[numawards]=awardalldead;
1762 for(i=1;i<numplayers;i++){
1763 if(player[i].dead!=1)alldead=0;
1766 awards[numawards]=awardnodead;
1769 if(numresponded==0&&!numthrowkill){
1770 awards[numawards]=awardstealth;
1773 if(numattacks==numstaffattack&&numattacks>0){
1774 awards[numawards]=awardbojutsu;
1777 if(numattacks==numswordattack&&numattacks>0){
1778 awards[numawards]=awardswordsman;
1781 if(numattacks==numknifeattack&&numattacks>0){
1782 awards[numawards]=awardknifefighter;
1785 if(numattacks==numunarmedattack&&numthrowkill==0&&weapons.numweapons>0){
1786 awards[numawards]=awardkungfu;
1790 awards[numawards]=awardevasion;
1793 if(numflipfail==0&&numflipped+numwallflipped*2>20){
1794 awards[numawards]=awardacrobat;
1797 if(numthrowkill==numplayers-1){
1798 awards[numawards]=awardlongrange;
1802 for(i=1;i<numplayers;i++){
1803 if(player[i].dead!=2)alldead=0;
1805 if(numafterkill>0&&alldead){
1806 awards[numawards]=awardbrutal;
1809 if(numreversals>((float)numattacks)*.8&&numreversals>3){
1810 awards[numawards]=awardaikido;
1813 if(maxalarmed==1&&numplayers>2){
1814 awards[numawards]=awardstrategy;
1818 awards[numawards]=awardklutz;
1822 //Win Screen Won Victory
1824 glEnable(GL_TEXTURE_2D);
1826 sprintf (string, "Level Cleared!");
1827 text.glPrintOutlined(1024/2-strlen(string)*10,768*7/8,string,1,2,1024,768);
1829 sprintf (string, "Score: %d",(int)(bonustotal-startbonustotal));
1830 text.glPrintOutlined(1024/30,768*6/8,string,1,2,1024,768);
1833 sprintf (string, "Press Escape or Space to continue");
1835 sprintf (string, "Press Escape to return to menu or Space to continue");
1836 text.glPrintOutlined(640/2-strlen(string)*5,480*1/16,string,1,1,640,480);
1840 for(i=0;i<255;i++)string[i]='\0';
1841 sprintf (temp, "Time: %d:",(int)(((int)leveltime-(int)(leveltime)%60)/60));
1842 strcat(string,temp);
1843 if((int)(leveltime)%60<10)strcat(string,"0");
1844 sprintf (temp, "%d",(int)(leveltime)%60);
1845 strcat(string,temp);
1846 text.glPrintOutlined(1024/30,768*6/8-40,string,1,2,1024,768);
1848 for(i=0;i<numawards;i++){
1850 if(awards[i]==awardklutz)sprintf (string, "Suicidal");
1851 if(awards[i]==awardflawless)sprintf (string, "Flawless!");
1852 if(awards[i]==awardalldead)sprintf (string, "Take no prisoners");
1853 if(awards[i]==awardnodead)sprintf (string, "Merciful");
1854 if(awards[i]==awardstealth)sprintf (string, "One with the shadows!");
1855 if(awards[i]==awardswordsman)sprintf (string, "Swordsman");
1856 if(awards[i]==awardkungfu)sprintf (string, "Unarmed!");
1857 if(awards[i]==awardknifefighter)sprintf (string, "Knife fighter");
1858 if(awards[i]==awardcoward)sprintf (string, "Coward");
1859 if(awards[i]==awardevasion)sprintf (string, "Escape artist");
1860 if(awards[i]==awardacrobat)sprintf (string, "Gymnast");
1861 if(awards[i]==awardlongrange)sprintf (string, "Blade slinger");
1862 if(awards[i]==awardbrutal)sprintf (string, "Brutal");
1863 if(awards[i]==awardhyper)sprintf (string, "Hyper");
1864 if(awards[i]==awardaikido)sprintf (string, "Aikido master!");
1865 if(awards[i]==awardrambo)sprintf (string, "Rambo");
1866 if(awards[i]==awardfast)sprintf (string, "Fast");
1867 if(awards[i]==awardrealfast)sprintf (string, "Real fast");
1868 if(awards[i]==awarddamnfast)sprintf (string, "Damn fast");
1869 if(awards[i]==awardstrategy)sprintf (string, "Divide and conquer");
1870 if(awards[i]==awardbojutsu)sprintf (string, "Bojutsu");
1871 text.glPrintOutlined(1024/30,768*6/8-90-40*i,string,1,2,1024,768);
1876 if(drawmode!=normalmode){
1877 glEnable(GL_TEXTURE_2D);
1879 if(!drawtoggle||drawmode!=realmotionblurmode||(drawtoggle==2||change==1)){
1882 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
1883 GLfloat subtractColor[4] = { 0.5, 0.5, 0.5, 0.0 };
1884 glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, subtractColor);
1885 //glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_SUBTRACT);
1886 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE);
1887 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_CONSTANT_EXT);
1888 glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 2.0f);
1890 glBindTexture( GL_TEXTURE_2D, screentexture);
1891 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1894 if((drawtoggle||change==1)&&drawmode==realmotionblurmode){
1896 glBindTexture( GL_TEXTURE_2D, screentexture2);
1897 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1899 if(!screentexture2){
1900 glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
1902 glGenTextures( 1, &screentexture2 );
1903 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
1905 glEnable(GL_TEXTURE_2D);
1906 glBindTexture( GL_TEXTURE_2D, screentexture2);
1907 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
1908 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
1910 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
1916 glClear(GL_DEPTH_BUFFER_BIT);
1917 ReSizeGLScene(90,.1f);
1918 glViewport(0,0,screenwidth,screenheight);
1920 if(drawmode!=normalmode){
1921 glDisable(GL_DEPTH_TEST);
1922 if(drawmode==motionblurmode){
1923 glDrawBuffer(GL_FRONT);
1924 glReadBuffer(GL_BACK);
1926 glColor3f (1.0, 1.0, 1.0); // no coloring
1928 glEnable(GL_TEXTURE_2D);
1929 glBindTexture( GL_TEXTURE_2D, screentexture);
1930 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1931 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1932 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1933 glDisable(GL_CULL_FACE);
1934 glDisable(GL_LIGHTING);
1936 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1937 glPushMatrix(); // Store The Projection Matrix
1938 glLoadIdentity(); // Reset The Projection Matrix
1939 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1940 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1941 glPushMatrix(); // Store The Modelview Matrix
1942 glLoadIdentity(); // Reset The Modelview Matrix
1943 glScalef((float)screenwidth/2,(float)screenheight/2,1);
1944 glTranslatef(1,1,0);
1945 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1947 if(drawmode==motionblurmode){
1948 if(motionbluramount<.2)motionbluramount=.2;
1949 //glColor4f(1,1,1,fast_sqrt(multiplier)*2.9*motionbluramount);
1950 glColor4f(1,1,1,motionbluramount);
1954 glVertex3f(-1, -1, 0.0f);
1955 glTexCoord2f(texcoordwidth,0);
1956 glVertex3f(1, -1, 0.0f);
1957 glTexCoord2f(texcoordwidth,texcoordheight);
1958 glVertex3f(1, 1, 0.0f);
1959 glTexCoord2f(0,texcoordheight);
1960 glVertex3f(-1, 1, 0.0f);
1964 if(drawmode==realmotionblurmode){
1965 glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
1966 glClear(GL_COLOR_BUFFER_BIT);
1967 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
1968 glBindTexture( GL_TEXTURE_2D, screentexture);
1969 glColor4f(1,1,1,.5);
1973 glVertex3f(-1, -1, 0.0f);
1974 glTexCoord2f(texcoordwidth,0);
1975 glVertex3f(1, -1, 0.0f);
1976 glTexCoord2f(texcoordwidth,texcoordheight);
1977 glVertex3f(1, 1, 0.0f);
1978 glTexCoord2f(0,texcoordheight);
1979 glVertex3f(-1, 1, 0.0f);
1982 glBindTexture( GL_TEXTURE_2D, screentexture2);
1983 glColor4f(1,1,1,.5);
1987 glVertex3f(-1, -1, 0.0f);
1988 glTexCoord2f(texcoordwidth,0);
1989 glVertex3f(1, -1, 0.0f);
1990 glTexCoord2f(texcoordwidth,texcoordheight);
1991 glVertex3f(1, 1, 0.0f);
1992 glTexCoord2f(0,texcoordheight);
1993 glVertex3f(-1, 1, 0.0f);
1996 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1998 if(drawmode==doublevisionmode){
1999 static float crosseyedness;
2000 crosseyedness=abs(player[0].damage-player[0].superpermanentdamage-(player[0].damagetolerance-player[0].superpermanentdamage)*1/2)/30;
2001 if(crosseyedness>1)crosseyedness=1;
2002 if(crosseyedness<0)crosseyedness=0;
2004 glDisable(GL_BLEND);
2009 glVertex3f(-1, -1, 0.0f);
2010 glTexCoord2f(texcoordwidth,0);
2011 glVertex3f(1, -1, 0.0f);
2012 glTexCoord2f(texcoordwidth,texcoordheight);
2013 glVertex3f(1, 1, 0.0f);
2014 glTexCoord2f(0,texcoordheight);
2015 glVertex3f(-1, 1, 0.0f);
2019 glColor4f(1,1,1,.5);
2022 glTranslatef(.015*crosseyedness,0,0);
2026 glVertex3f(-1, -1, 0.0f);
2027 glTexCoord2f(texcoordwidth,0);
2028 glVertex3f(1, -1, 0.0f);
2029 glTexCoord2f(texcoordwidth,texcoordheight);
2030 glVertex3f(1, 1, 0.0f);
2031 glTexCoord2f(0,texcoordheight);
2032 glVertex3f(-1, 1, 0.0f);
2037 if(drawmode==glowmode){
2038 glColor4f(.5,.5,.5,.5);
2040 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
2042 glTranslatef(.01,0,0);
2045 glVertex3f(-1, -1, 0.0f);
2046 glTexCoord2f(texcoordwidth,0);
2047 glVertex3f(1, -1, 0.0f);
2048 glTexCoord2f(texcoordwidth,texcoordheight);
2049 glVertex3f(1, 1, 0.0f);
2050 glTexCoord2f(0,texcoordheight);
2051 glVertex3f(-1, 1, 0.0f);
2055 glTranslatef(-.01,0,0);
2058 glVertex3f(-1, -1, 0.0f);
2059 glTexCoord2f(texcoordwidth,0);
2060 glVertex3f(1, -1, 0.0f);
2061 glTexCoord2f(texcoordwidth,texcoordheight);
2062 glVertex3f(1, 1, 0.0f);
2063 glTexCoord2f(0,texcoordheight);
2064 glVertex3f(-1, 1, 0.0f);
2068 glTranslatef(.0,.01,0);
2071 glVertex3f(-1, -1, 0.0f);
2072 glTexCoord2f(texcoordwidth,0);
2073 glVertex3f(1, -1, 0.0f);
2074 glTexCoord2f(texcoordwidth,texcoordheight);
2075 glVertex3f(1, 1, 0.0f);
2076 glTexCoord2f(0,texcoordheight);
2077 glVertex3f(-1, 1, 0.0f);
2081 glTranslatef(0,-.01,0);
2084 glVertex3f(-1, -1, 0.0f);
2085 glTexCoord2f(texcoordwidth,0);
2086 glVertex3f(1, -1, 0.0f);
2087 glTexCoord2f(texcoordwidth,texcoordheight);
2088 glVertex3f(1, 1, 0.0f);
2089 glTexCoord2f(0,texcoordheight);
2090 glVertex3f(-1, 1, 0.0f);
2094 if(drawmode==radialzoommode){
2096 //glRotatef((float)i*.1,0,0,1);
2097 glColor4f(1,1,1,1/((float)i+1));
2099 glScalef(1+(float)i*.01,1+(float)i*.01,1);
2102 glVertex3f(-1, -1, 0.0f);
2103 glTexCoord2f(texcoordwidth,0);
2104 glVertex3f(1, -1, 0.0f);
2105 glTexCoord2f(texcoordwidth,texcoordheight);
2106 glVertex3f(1, 1, 0.0f);
2107 glTexCoord2f(0,texcoordheight);
2108 glVertex3f(-1, 1, 0.0f);
2113 glDisable(GL_TEXTURE_2D);
2114 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2115 glPopMatrix(); // Restore The Old Projection Matrix
2116 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2117 glPopMatrix(); // Restore The Old Projection Matrix
2118 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
2119 glEnable(GL_CULL_FACE);
2120 glDisable(GL_BLEND);
2125 glEnable(GL_TEXTURE_2D);
2128 if(consoleselected>=60)
2129 offset=consoleselected-60;
2130 sprintf (string, " ]");
2131 text.glPrint(10,30,string,0,1,1024,768);
2133 sprintf (string, "_");
2134 text.glPrint(30+(float)(consoleselected)*10-offset*10,30,string,0,1,1024,768);
2137 for(j=0;j<consolechars[i];j++){
2138 glColor4f(1,1,1,1-(float)(i)/16);
2139 if(j<consolechars[i]){
2140 sprintf (string, "%c",consoletext[i][j]);
2141 text.glPrint(30+j*10-offset*10,30+i*20,string,0,1,1024,768);
2148 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)||(mainmenu&&gameon)||(!gameon&&gamestarted)||(!gameon&&gamestarted)){
2149 multiplier=tempmult;
2154 // !!! FIXME: hack: clamp framerate in menu so text input works correctly on fast systems.
2157 glDrawBuffer(GL_BACK);
2158 glReadBuffer(GL_BACK);
2159 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
2160 ReSizeGLScene(90,.1f);
2163 temptexdetail=texdetail;
2164 if(texdetail>2)texdetail=2;
2165 if(mainmenu!=oldmainmenu&&oldmainmenu!=0){
2167 LoadTexture(":Data:Textures:Newgame.png",&Mainmenuitems[1],0,0);
2168 LoadTexture(":Data:Textures:Quit.png",&Mainmenuitems[3],0,0);
2171 LoadTexture(":Data:Textures:Resume.png",&Mainmenuitems[1],0,0);
2172 LoadTexture(":Data:Textures:Endgame.png",&Mainmenuitems[3],0,0);
2175 if(lastcheck>.5||oldmainmenu!=mainmenu){
2177 ifstream ipstream(ConvertFileName(":Data:Campaigns:main.txt"));
2178 ipstream.ignore(256,':');
2179 ipstream >> campaignnumlevels;
2180 for(i=0;i<campaignnumlevels;i++){
2181 ipstream.ignore(256,':');
2182 ipstream.ignore(256,':');
2183 ipstream.ignore(256,' ');
2184 ipstream >> campaignmapname[i];
2185 ipstream.ignore(256,':');
2186 ipstream >> campaigndescription[i];
2188 if(campaigndescription[i][j]=='_')campaigndescription[i][j]=' ';
2190 ipstream.ignore(256,':');
2191 ipstream >> campaignchoosenext[i];
2192 ipstream.ignore(256,':');
2193 ipstream >> campaignnumnext[i];
2194 for(j=0;j<campaignnumnext[i];j++){
2195 ipstream.ignore(256,':');
2196 ipstream >> campaignnextlevel[i][j];
2197 campaignnextlevel[i][j]-=1;
2199 ipstream.ignore(256,':');
2200 ipstream >> campaignlocationx[i];
2201 ipstream.ignore(256,':');
2202 ipstream >> campaignlocationy[i];
2206 for(i=0;i<campaignnumlevels;i++){
2208 levelhighlight[i]=0;
2213 for(i=0;i<accountactive->getCampaignChoicesMade();i++){
2214 levelorder[i+1]=campaignnextlevel[levelorder[i]][accountactive->getCampaignChoice(i)];
2215 levelvisible[levelorder[i+1]]=1;
2217 int whichlevelstart = accountactive->getCampaignChoicesMade()-1;
2218 if(whichlevelstart<0){
2219 accountactive->setCampaignScore(0);
2220 accountactive->resetFasttime();
2221 campaignchoicenum=1;
2222 campaignchoicewhich[0]=0;
2226 campaignchoicenum=campaignnumnext[levelorder[whichlevelstart]];
2227 for(i=0;i<campaignchoicenum;i++){
2228 campaignchoicewhich[i]=campaignnextlevel[levelorder[whichlevelstart]][i];
2229 levelvisible[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
2230 levelhighlight[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
2239 texdetail=temptexdetail;
2241 oldmainmenu=mainmenu;
2243 if(mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==8||mainmenu==9||mainmenu==10||mainmenu==119||mainmenu==13||mainmenu==17||mainmenu==18){
2244 glClear(GL_DEPTH_BUFFER_BIT);
2245 glEnable(GL_ALPHA_TEST);
2246 glAlphaFunc(GL_GREATER, 0.001f);
2247 glEnable(GL_TEXTURE_2D);
2248 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
2249 glDisable(GL_CULL_FACE);
2250 glDisable(GL_LIGHTING);
2252 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2253 glPushMatrix(); // Store The Projection Matrix
2254 glLoadIdentity(); // Reset The Projection Matrix
2255 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
2256 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2257 glPushMatrix(); // Store The Modelview Matrix
2258 glLoadIdentity(); // Reset The Modelview Matrix
2259 glTranslatef(screenwidth/2,screenheight/2,0);
2261 glScalef((float)screenwidth/2,(float)screenheight/2,1);
2262 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
2263 glDisable(GL_BLEND);
2264 glColor4f(0,0,0,1.0);
2265 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2266 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2267 glDisable(GL_TEXTURE_2D);
2269 //glScalef(.25,.25,.25);
2272 glVertex3f(-1, -1, 0.0f);
2274 glVertex3f(1, -1, 0.0f);
2276 glVertex3f(1, 1, 0.0f);
2278 glVertex3f(-1, 1, 0.0f);
2282 glColor4f(0.4,0.4,0.4,1.0);
2283 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2284 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2285 glEnable(GL_TEXTURE_2D);
2286 glBindTexture( GL_TEXTURE_2D, Mainmenuitems[4]);
2288 //glScalef(.25,.25,.25);
2291 glVertex3f(-1, -1, 0.0f);
2293 glVertex3f(1, -1, 0.0f);
2295 glVertex3f(1, 1, 0.0f);
2297 glVertex3f(-1, 1, 0.0f);
2302 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2304 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2308 if((float)newscreenwidth>(float)newscreenheight*1.61||(float)newscreenwidth<(float)newscreenheight*1.59)sprintf (menustring[0], "Resolution: %d*%d",(int)newscreenwidth,(int)newscreenheight);
2309 else sprintf (menustring[0], "Resolution: %d*%d (widescreen)",(int)newscreenwidth,(int)newscreenheight);
2312 endx[0]=startx[0]+strlen(menustring[0])*10;
2313 endy[0]=starty[0]+20;
2317 if(newdetail==2)sprintf (menustring[1], "Detail: High");
2318 else if(newdetail==1)sprintf (menustring[1], "Detail: Medium");
2319 else sprintf (menustring[1], "Detail: Low");
2322 endx[1]=startx[1]+strlen(menustring[1])*10;
2323 endy[1]=starty[1]+20;
2327 if(bloodtoggle==2)sprintf (menustring[2], "Blood: On, high detail (slower)");
2328 if(bloodtoggle==1)sprintf (menustring[2], "Blood: On, low detail");
2329 if(bloodtoggle==0)sprintf (menustring[2], "Blood: Off");
2332 endx[2]=startx[2]+strlen(menustring[2])*10;
2333 endy[2]=starty[2]+20;
2337 if(difficulty==2)sprintf (menustring[3], "Difficulty: Insane");
2338 if(difficulty==1)sprintf (menustring[3], "Difficulty: Difficult");
2339 if(difficulty==0)sprintf (menustring[3], "Difficulty: Easier");
2340 startx[3]=10+20-1000;
2342 endx[3]=startx[3]+strlen(menustring[3])*10;
2343 endy[3]=starty[3]+20;
2347 if(ismotionblur==1)sprintf (menustring[4], "Blur Effects: Enabled (less compatible)");
2348 if(ismotionblur==0)sprintf (menustring[4], "Blur Effects: Disabled (more compatible)");
2351 endx[4]=startx[4]+strlen(menustring[4])*10;
2352 endy[4]=starty[4]+20;
2356 if(decals==1)sprintf (menustring[5], "Decals: Enabled (slower)");
2357 if(decals==0)sprintf (menustring[5], "Decals: Disabled");
2360 endx[5]=startx[5]+strlen(menustring[5])*10;
2361 endy[5]=starty[5]+20;
2365 if(musictoggle==1)sprintf (menustring[6], "Music: Enabled");
2366 if(musictoggle==0)sprintf (menustring[6], "Music: Disabled");
2369 endx[6]=startx[6]+strlen(menustring[6])*10;
2370 endy[6]=starty[6]+20;
2374 if(invertmouse==1)sprintf (menustring[9], "Invert mouse: Yes");
2375 if(invertmouse==0)sprintf (menustring[9], "Invert mouse: No");
2378 endx[9]=startx[9]+strlen(menustring[9])*10;
2379 endy[9]=starty[9]+20;
2383 sprintf (menustring[10], "Mouse Speed: %d", (int)(usermousesensitivity*5));
2386 endx[10]=startx[10]+strlen(menustring[10])*10;
2387 endy[10]=starty[10]+20;
2391 sprintf (menustring[11], "Volume: %d%%", (int)(volume*100));
2394 endx[11]=startx[11]+strlen(menustring[11])*10;
2395 endy[11]=starty[11]+20;
2399 sprintf (menustring[13], "Damage Bar: %s",(showdamagebar?"on":"off"));
2402 endx[13]=startx[13]+strlen(menustring[13])*10;
2403 endy[13]=starty[13]+20;
2407 sprintf (menustring[7], "-Configure Controls-");
2410 endx[7]=startx[7]+strlen(menustring[7])*10;
2411 endy[7]=starty[7]+20;
2415 sprintf (menustring[12], "-Configure Stereo -");
2418 endx[12]=startx[12]+strlen(menustring[7])*10;
2419 endy[12]=starty[12]+20;
2423 if(newdetail==detail&&newscreenheight==(int)screenheight&&newscreenwidth==(int)screenwidth)sprintf (menustring[8], "Back");
2424 else sprintf (menustring[8], "Back (some changes take effect next time Lugaru is opened)");
2426 endx[8]=startx[8]+strlen(menustring[8])*10;
2428 endy[8]=starty[8]+20;
2435 if(keyselect!=0)sprintf (menustring[0], "Forwards: %s",Input::keyToChar(forwardkey));
2436 else sprintf (menustring[0], "Forwards: _");
2439 endx[0]=startx[0]+strlen(menustring[0])*10;
2440 endy[0]=starty[0]+20;
2444 if(keyselect!=1)sprintf (menustring[1], "Back: %s",Input::keyToChar(backkey));
2445 else sprintf (menustring[1], "Back: _");
2448 endx[1]=startx[1]+strlen(menustring[1])*10;
2449 endy[1]=starty[1]+20;
2453 if(keyselect!=2)sprintf (menustring[2], "Left: %s",Input::keyToChar(leftkey));
2454 else sprintf (menustring[2], "Left: _");
2457 endx[2]=startx[2]+strlen(menustring[2])*10;
2458 endy[2]=starty[2]+20;
2462 if(keyselect!=3)sprintf (menustring[3], "Right: %s",Input::keyToChar(rightkey));
2463 else sprintf (menustring[3], "Right: _");
2466 endx[3]=startx[3]+strlen(menustring[3])*10;
2467 endy[3]=starty[3]+20;
2471 if(keyselect!=4)sprintf (menustring[4], "Crouch: %s",Input::keyToChar(crouchkey));
2472 else sprintf (menustring[4], "Crouch: _");
2475 endx[4]=startx[4]+strlen(menustring[4])*10;
2476 endy[4]=starty[4]+20;
2480 if(keyselect!=5)sprintf (menustring[5], "Jump: %s",Input::keyToChar(jumpkey));
2481 else sprintf (menustring[5], "Jump: _");
2484 endx[5]=startx[5]+strlen(menustring[5])*10;
2485 endy[5]=starty[5]+20;
2489 if(keyselect!=6)sprintf (menustring[6], "Draw: %s",Input::keyToChar(drawkey));
2490 else sprintf (menustring[6], "Draw: _");
2493 endx[6]=startx[6]+strlen(menustring[6])*10;
2494 endy[6]=starty[6]+20;
2498 if(keyselect!=7)sprintf (menustring[7], "Throw: %s",Input::keyToChar(throwkey));
2499 else sprintf (menustring[7], "Throw: _");
2502 endx[7]=startx[7]+strlen(menustring[7])*10;
2503 endy[7]=starty[7]+20;
2507 if(keyselect!=8)sprintf (menustring[8], "Attack: %s",Input::keyToChar(attackkey));
2508 else sprintf (menustring[8], "Attack: _");
2511 endx[8]=startx[8]+strlen(menustring[8])*10;
2512 endy[8]=starty[8]+20;
2518 sprintf (menustring[9], "Back");
2520 endx[9]=startx[9]+strlen(menustring[9])*10;
2522 endy[9]=starty[9]+20;
2527 nummenuitems=7+accountactive->getCampaignChoicesMade()+campaignchoicenum;
2529 sprintf (menustring[0], "%s",accountactive->getName());
2532 endx[0]=startx[0]+strlen(menustring[0])*10;
2533 endy[0]=starty[0]+20;
2537 sprintf (menustring[1], "Tutorial");
2540 endx[1]=startx[1]+strlen(menustring[1])*10;
2541 endy[1]=starty[1]+20;
2545 sprintf (menustring[2], "Challenge");
2548 endx[2]=startx[2]+strlen(menustring[2])*10;
2549 endy[2]=starty[2]+20;
2553 sprintf (menustring[3], "Delete User");
2556 endx[3]=startx[3]+strlen(menustring[3])*10;
2557 endy[3]=starty[3]+20;
2561 sprintf (menustring[4], "Main Menu");
2564 endx[4]=startx[4]+strlen(menustring[4])*10;
2565 endy[4]=starty[4]+20;
2569 sprintf (menustring[5], "Change User");
2571 endx[5]=startx[5]+strlen(menustring[5])*10;
2573 endy[5]=starty[5]+20;
2579 sprintf (menustring[6], "World");
2581 starty[6]=30+480-400-50;
2582 endx[6]=startx[6]+400;
2587 if(accountactive->getCampaignChoicesMade())
2588 for(i=0;i<accountactive->getCampaignChoicesMade();i++){
2589 sprintf (menustring[7+i], "%s", campaigndescription[levelorder[i]]);
2590 startx[7+i]=30+120+campaignlocationx[levelorder[i]]*400/512;
2591 starty[7+i]=30+30+(512-campaignlocationy[levelorder[i]])*400/512;
2592 endx[7+i]=startx[7+i]+10;
2593 endy[7+i]=starty[7+i]+10;
2598 if(campaignchoicenum>0)
2599 for(i=accountactive->getCampaignChoicesMade();i<accountactive->getCampaignChoicesMade()+campaignchoicenum;i++){
2600 sprintf (menustring[7+i], "%s", campaigndescription[levelorder[i]]);
2601 startx[7+i]=30+120+campaignlocationx[campaignchoicewhich[i-(accountactive->getCampaignChoicesMade())]]*400/512;
2602 starty[7+i]=30+30+(512-campaignlocationy[campaignchoicewhich[i-(accountactive->getCampaignChoicesMade())]])*400/512;
2603 endx[7+i]=startx[7+i]+10;
2604 endy[7+i]=starty[7+i]+10;
2609 /*sprintf (menustring[7], "Dot");
2610 startx[7]=120+260*400/512;
2611 starty[7]=30+(512-184)*400/512;
2612 endx[7]=startx[7]+10;
2613 endy[7]=starty[7]+10;
2617 sprintf (menustring[8], "Dot");
2618 startx[8]=120+129*400/512;
2619 starty[8]=30+(512-284)*400/512;
2620 endx[8]=startx[8]+10;
2621 endy[8]=starty[8]+10;
2625 sprintf (menustring[9], "Dot");
2626 startx[9]=120+358*400/512;
2627 starty[9]=30+(512-235)*400/512;
2628 endx[9]=startx[9]+10;
2629 endy[9]=starty[9]+10;
2633 sprintf (menustring[10], "Dot");
2634 startx[10]=120+359*400/512;
2635 starty[10]=30+(512-308)*400/512;
2636 endx[10]=startx[10]+10;
2637 endy[10]=starty[10]+10;
2641 sprintf (menustring[11], "Dot");
2642 startx[11]=120+288*400/512;
2643 starty[11]=30+(512-277)*400/512;
2644 endx[11]=startx[11]+10;
2645 endy[11]=starty[11]+10;
2653 sprintf (menustring[0], "Are you sure you want to delete this user?");
2656 endx[0]=startx[0]+strlen(menustring[0])*10;
2657 endy[0]=starty[0]+20;
2661 sprintf (menustring[1], "Yes");
2664 endx[1]=startx[1]+strlen(menustring[1])*10;
2665 endy[1]=starty[1]+20;
2669 sprintf (menustring[2], "No");
2672 endx[2]=startx[2]+strlen(menustring[2])*10;
2673 endy[2]=starty[2]+20;
2677 sprintf (menustring[3], "Extra 4");
2680 endx[3]=startx[3]+strlen(menustring[3])*10;
2681 endy[3]=starty[3]+20;
2685 sprintf (menustring[4], "Extra 5");
2688 endx[4]=startx[4]+strlen(menustring[4])*10;
2689 endy[4]=starty[4]+20;
2693 sprintf (menustring[5], "Back");
2695 endx[5]=startx[5]+strlen(menustring[5])*10;
2697 endy[5]=starty[5]+20;
2703 nummenuitems=Account::getNbAccounts()+2;
2707 if(Account::getNbAccounts()<8)
2708 sprintf (menustring[0], "New User");
2710 sprintf (menustring[0], "No More Users");
2713 endx[0]=startx[0]+strlen(menustring[0])*10;
2714 endy[0]=starty[0]+20;
2723 for(i=0;i<Account::getNbAccounts();i++){
2724 sprintf (menustring[num], "%s",Account::get(i)->getName());
2726 starty[num]=360-20-20*num;
2727 endx[num]=startx[num]+strlen(menustring[num])*10;
2728 endy[num]=starty[num]+20;
2735 sprintf (menustring[num], "Back");
2737 endx[num]=startx[num]+strlen(menustring[num])*10;
2739 endy[num]=starty[num]+20;
2746 sprintf (menustring[0], "Easier");
2749 endx[0]=startx[0]+strlen(menustring[0])*10;
2750 endy[0]=starty[0]+20;
2754 sprintf (menustring[1], "Difficult");
2757 endx[1]=startx[1]+strlen(menustring[1])*10;
2758 endy[1]=starty[1]+20;
2762 sprintf (menustring[2], "Insane");
2765 endx[2]=startx[2]+strlen(menustring[2])*10;
2766 endy[2]=starty[2]+20;
2772 //tempncl=numchallengelevels;
2773 //numchallengelevels=9;
2774 nummenuitems=2+numchallengelevels;
2777 for(j=0;j<numchallengelevels;j++){
2778 for(i=0;i<255;i++)menustring[j][i]='\0';
2779 sprintf (temp, "Level %d",j+1);
2780 strcpy(menustring[j],temp);
2781 for(i=0;i<17;i++)if(menustring[j][i]=='\0')menustring[j][i]=' ';
2782 menustring[j][17]='\0';
2783 sprintf (temp, "%d",(int)accountactive->getHighScore(j));
2784 strcat(menustring[j],temp);
2785 for(i=18;i<32;i++)if(menustring[j][i]=='\0')menustring[j][i]=' ';
2786 menustring[j][32]='\0';
2787 sprintf (temp, "%d:",(int)(((int)accountactive->getFastTime(j)-(int)(accountactive->getFastTime(j))%60)/60));
2788 strcat(menustring[j],temp);
2789 if((int)(accountactive->getFastTime(j))%60<10)strcat(menustring[j],"0");
2790 sprintf (temp, "%d",(int)(accountactive->getFastTime(j))%60);
2791 strcat(menustring[j],temp);
2795 endx[j]=startx[j]+strlen(menustring[j])*10;
2796 endy[j]=starty[j]+20;
2801 sprintf (menustring[numchallengelevels], "Back");
2802 startx[numchallengelevels]=10;
2803 endx[numchallengelevels]=startx[numchallengelevels]+strlen(menustring[numchallengelevels])*10;
2804 starty[numchallengelevels]=10;
2805 endy[numchallengelevels]=starty[numchallengelevels]+20;
2806 movex[numchallengelevels]=0;
2807 movey[numchallengelevels]=0;
2809 sprintf (menustring[numchallengelevels+1], " High Score Best Time");
2810 startx[numchallengelevels+1]=10;
2811 starty[numchallengelevels+1]=440;
2812 endx[numchallengelevels+1]=startx[numchallengelevels+1]+strlen(menustring[numchallengelevels+1])*10;
2813 endy[numchallengelevels+1]=starty[numchallengelevels+1]+20;
2814 movex[numchallengelevels+1]=0;
2815 movey[numchallengelevels+1]=0;
2817 //numchallengelevels=tempncl;
2821 nummenuitems=2+numchallengelevels;
2824 for(j=0;j<numchallengelevels;j++){
2825 for(i=0;i<255;i++)menustring[j][i]='\0';
2826 sprintf (temp, "Level %d",j+1);
2827 strcpy(menustring[j],temp);
2828 for(i=0;i<17;i++)if(menustring[j][i]=='\0')menustring[j][i]=' ';
2829 menustring[j][17]='\0';
2830 sprintf (temp, "%d",(int)accountactive->getHighScore(j));
2831 strcat(menustring[j],temp);
2832 for(i=18;i<32;i++)if(menustring[j][i]=='\0')menustring[j][i]=' ';
2833 menustring[j][32]='\0';
2834 sprintf (temp, "%d:",(int)(((int)accountactive->getFastTime(j)-(int)(accountactive->getFastTime(j))%60)/60));
2835 strcat(menustring[j],temp);
2836 if((int)(accountactive->getFastTime(j))%60<10)strcat(menustring[j],"0");
2837 sprintf (temp, "%d",(int)(accountactive->getFastTime(j))%60);
2838 strcat(menustring[j],temp);
2842 endx[j]=startx[j]+strlen(menustring[j])*10;
2843 endy[j]=starty[j]+20;
2848 sprintf (menustring[numchallengelevels], "Back");
2849 startx[numchallengelevels]=10;
2850 endx[numchallengelevels]=startx[numchallengelevels]+strlen(menustring[numchallengelevels])*10;
2851 starty[numchallengelevels]=10;
2852 endy[numchallengelevels]=starty[numchallengelevels]+20;
2853 movex[numchallengelevels]=0;
2854 movey[numchallengelevels]=0;
2856 sprintf (menustring[numchallengelevels+1], " High Score Best Time");
2857 startx[numchallengelevels+1]=10;
2858 starty[numchallengelevels+1]=400;
2859 endx[numchallengelevels+1]=startx[numchallengelevels+1]+strlen(menustring[numchallengelevels+1])*10;
2860 endy[numchallengelevels+1]=starty[numchallengelevels+1]+20;
2861 movex[numchallengelevels+1]=0;
2862 movey[numchallengelevels+1]=0;
2869 sprintf (menustring[0], "Congratulations!");
2872 endx[0]=startx[0]+strlen(menustring[0])*10;
2873 endy[0]=starty[0]+20;
2877 sprintf (menustring[1], "You have avenged your family and");
2880 endx[1]=startx[1]+strlen(menustring[1])*10;
2881 endy[1]=starty[1]+20;
2885 sprintf (menustring[2], "restored peace to the island of Lugaru.");
2888 endx[2]=startx[2]+strlen(menustring[2])*10;
2889 endy[2]=starty[2]+20;
2893 sprintf (menustring[3], "Back");
2895 endx[3]=startx[3]+strlen(menustring[3])*10;
2897 endy[3]=starty[3]+20;
2901 for(i=0;i<255;i++)menustring[4][i]='\0';
2902 sprintf (temp, "Your score:");
2903 strcpy(menustring[4],temp);
2904 for(i=0;i<20;i++)if(menustring[4][i]=='\0')menustring[4][i]=' ';
2905 menustring[4][20]='\0';
2906 sprintf (temp, "%d",(int)accountactive->getCampaignScore());
2907 strcat(menustring[4],temp);
2909 endx[4]=startx[4]+strlen(menustring[4])*10;
2911 endy[4]=starty[4]+20;
2915 for(i=0;i<255;i++)menustring[5][i]='\0';
2916 sprintf (temp, "Your time:");
2917 strcpy(menustring[5],temp);
2918 for(i=0;i<20;i++)if(menustring[5][i]=='\0')menustring[5][i]=' ';
2919 menustring[5][20]='\0';
2920 sprintf (temp, "%d",(int)accountcampaigntime[accountactive]);
2921 strcat(menustring[5],temp);
2923 endx[5]=startx[5]+strlen(menustring[5])*10;
2925 endy[5]=starty[5]+20;
2929 for(i=0;i<255;i++)menustring[5][i]='\0';
2930 sprintf (temp, "Highest score:");
2931 strcpy(menustring[5],temp);
2932 for(i=0;i<20;i++)if(menustring[5][i]=='\0')menustring[5][i]=' ';
2933 menustring[5][20]='\0';
2934 sprintf (temp, "%d",(int)accountactive->getCampaignHighScore());
2935 strcat(menustring[5],temp);
2937 endx[5]=startx[5]+strlen(menustring[5])*10;
2939 endy[5]=starty[5]+20;
2943 for(i=0;i<255;i++)menustring[7][i]='\0';
2944 sprintf (temp, "Lowest time:");
2945 strcpy(menustring[7],temp);
2946 for(i=0;i<20;i++)if(menustring[7][i]=='\0')menustring[7][i]=' ';
2947 menustring[7][20]='\0';
2948 sprintf (temp, "%d",(int)accountactive->getCampaignFasttime());
2949 strcat(menustring[7],temp);
2951 endx[7]=startx[7]+strlen(menustring[7])*10;
2953 endy[7]=starty[7]+20;
2959 sprintf (menustring[0], "Stereo mode: %s", StereoModeName(newstereomode));
2962 endx[0]=startx[0]+strlen(menustring[0])*10;
2963 endy[0]=starty[0]+20;
2967 sprintf (menustring[1], "Stereo separation: %.3f", stereoseparation);
2970 endx[1]=startx[1]+strlen(menustring[1])*10;
2971 endy[1]=starty[1]+20;
2975 sprintf (menustring[2], "Reverse stereo: %s", stereoreverse ? "Yes" : "No");
2978 endx[2]=startx[2]+strlen(menustring[2])*10;
2979 endy[2]=starty[2]+20;
2983 sprintf (menustring[3], "Back");
2985 endx[3]=startx[3]+strlen(menustring[3])*10;
2987 endy[3]=starty[3]+20;
2993 if(mainmenu==1||mainmenu==2){
3003 starty[1]=480-152-32;
3010 starty[2]=480-228-32;
3018 starty[3]=480-306-32;
3027 starty[3]=480-306-32;
3041 starty[4]=480-140-256;
3048 starty[5]=480-138-256;
3055 starty[6]=480-144-256;
3063 starty[4]=480-140-256;
3070 starty[5]=480-138-256;
3077 starty[6]=480-144-256;
3085 starty[4]=480-140-256;
3092 starty[5]=480-150-256;
3099 starty[6]=480-144-256;
3107 starty[4]=480-140-256;
3114 starty[5]=480-150-256;
3121 starty[6]=480-144-256;
3129 starty[4]=480-100-256;
3136 starty[5]=480-120-256;
3143 starty[6]=480-144-256;
3153 if(mainmenu==1||mainmenu==2)
3155 if((mousecoordh/screenwidth*640)>startx[i]&&(mousecoordh/screenwidth*640)<endx[i]&&480-(mousecoordv/screenheight*480)>starty[i]&&480-(mousecoordv/screenheight*480)<endy[i]){
3160 if(mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==8||mainmenu==9||mainmenu==10||mainmenu==11||mainmenu==13||mainmenu==17||mainmenu==18)
3161 for(i=0;i<nummenuitems;i++){
3162 if((mousecoordh/screenwidth*640)>startx[i]&&(mousecoordh/screenwidth*640)<endx[i]&&480-(mousecoordv/screenheight*480)>starty[i]&&480-(mousecoordv/screenheight*480)<endy[i]){
3163 if(mainmenu!=5)selected=i;
3164 if(mainmenu==5&&(i!=0&&i!=6))selected=i;
3165 if(mainmenu==9&&(i!=numchallengelevels+1))selected=i;
3166 if(mainmenu==11&&(i!=numchallengelevels+1))selected=i;
3170 for(i=0;i<nummenuitems;i++){
3172 selectedlong[i]+=multiplier*5;
3173 if(selectedlong[i]>1) selectedlong[i]=1;
3175 selectedlong[i]-=multiplier*5;
3176 if(selectedlong[i]<0) selectedlong[i]=0;
3178 offsetx[i]=(startx[i]+endx[i])/2-(mousecoordh/screenwidth*640);
3179 offsety[i]=(starty[i]+endy[i])/2-(480-(mousecoordv/screenheight*480));
3184 if(i>=4&&(mainmenu==1||mainmenu==2)){
3186 offsetx[i]=(startx[i]+endx[i]+movex[i]*transition)/2-(640+190)/2;
3187 offsety[i]=(starty[i]+endy[i]+movey[i]*transition)/2-(336+150)/2;
3193 if(mainmenu==1||mainmenu==2){
3194 glClear(GL_DEPTH_BUFFER_BIT);
3195 glEnable(GL_ALPHA_TEST);
3196 glAlphaFunc(GL_GREATER, 0.001f);
3197 glEnable(GL_TEXTURE_2D);
3198 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3199 glDisable(GL_CULL_FACE);
3200 glDisable(GL_LIGHTING);
3202 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3203 glPushMatrix(); // Store The Projection Matrix
3204 glLoadIdentity(); // Reset The Projection Matrix
3205 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
3206 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3207 glPushMatrix(); // Store The Modelview Matrix
3208 glLoadIdentity(); // Reset The Modelview Matrix
3209 glTranslatef(screenwidth/2,screenheight/2,0);
3211 glScalef((float)screenwidth/2,(float)screenheight/2,1);
3212 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3213 glDisable(GL_BLEND);
3214 glColor4f(0,0,0,1.0);
3215 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
3216 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
3217 glDisable(GL_TEXTURE_2D);
3219 //glScalef(.25,.25,.25);
3222 glVertex3f(-1, -1, 0.0f);
3224 glVertex3f(1, -1, 0.0f);
3226 glVertex3f(1, 1, 0.0f);
3228 glVertex3f(-1, 1, 0.0f);
3232 glColor4f(0.4,0.4,0.4,1.0);
3233 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
3234 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
3235 glEnable(GL_TEXTURE_2D);
3236 glBindTexture( GL_TEXTURE_2D, Mainmenuitems[4]);
3238 //glScalef(.25,.25,.25);
3241 glVertex3f(-1, -1, 0.0f);
3243 glVertex3f(1, -1, 0.0f);
3245 glVertex3f(1, 1, 0.0f);
3247 glVertex3f(-1, 1, 0.0f);
3252 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3255 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3256 glPushMatrix(); // Store The Projection Matrix
3257 glLoadIdentity(); // Reset The Projection Matrix
3258 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3259 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3260 glPushMatrix(); // Store The Modelview Matrix
3261 glLoadIdentity(); // Reset The Modelview Matrix
3263 glDisable(GL_TEXTURE_2D);
3267 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3269 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3273 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3274 glPushMatrix(); // Store The Projection Matrix
3275 glLoadIdentity(); // Reset The Projection Matrix
3276 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3277 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3278 glPushMatrix(); // Store The Modelview Matrix
3279 glLoadIdentity(); // Reset The Modelview Matrix
3280 glEnable(GL_TEXTURE_2D);
3281 for(j=0;j<nummenuitems;j++)
3283 if(j<=3||(mainmenu!=1&&mainmenu!=2))
3285 //glDisable(GL_BLEND);
3286 glEnable(GL_ALPHA_TEST);
3288 //glDisable(GL_ALPHA_TEST);
3289 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3290 if(mainmenu==1||mainmenu==2)
3293 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3294 glBindTexture( GL_TEXTURE_2D, Mainmenuitems[j]);
3295 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
3296 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
3297 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3301 glVertex3f(startx[j]+movex[j]*transition, starty[j]+movey[j]*transition, 0.0f);
3303 glVertex3f(endx[j]+movex[j]*transition, starty[j]+movey[j]*transition, 0.0f);
3305 glVertex3f(endx[j]+movex[j]*transition, endy[j]+movey[j]*transition, 0.0f);
3307 glVertex3f(startx[j]+movex[j]*transition, endy[j]+movey[j]*transition, 0.0f);
3311 //glDisable(GL_ALPHA_TEST);
3312 if(j<4)glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3315 if(1-((float)i)/10-(1-selectedlong[j])>0)
3317 glColor4f(1,1,1,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3318 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3322 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);
3324 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);
3326 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);
3328 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);
3334 if(mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==8||mainmenu==9||mainmenu==10||mainmenu==11||mainmenu==13||mainmenu==17||mainmenu==18)
3336 if(mainmenu!=5||j<6)
3339 if(mainmenu==9&&j>accountactive->getProgress()&&j<numchallengelevels)glColor4f(0.5,0,0,1);
3340 if(mainmenu==11&&j>accountactive->getProgress()&&j<numchallengelevels)glColor4f(0.5,0,0,1);
3341 //if(1-((float)i)/10-(1-selectedlong[j])>0){
3342 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3344 if(mainmenu!=7||j!=0||!entername)
3345 text.glPrint(startx[j],starty[j],menustring[j],0,1,640,480);
3349 sprintf (string, "_");
3350 text.glPrint(startx[j]+(float)(displayselected)*10,starty[j],string,0,1,640,480);
3352 for(l=0;l<displaychars[0];l++){
3353 sprintf (string, "%c",displaytext[0][l]);
3354 text.glPrint(startx[j]+l*10,starty[j],string,0,1,640,480);
3359 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3362 if(1-((float)i)/15-(1-selectedlong[j])>0)
3364 glColor4f(1,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3365 if(mainmenu==9&&j>accountactive->getProgress()&&j<numchallengelevels)glColor4f(0.5,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3366 if(mainmenu==11&&j>accountactive->getProgress()&&j<numchallengelevels)glColor4f(0.5,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3367 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);
3368 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);
3369 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);
3370 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);
3371 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);
3372 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);
3373 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);
3374 if(mainmenu==11)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);
3375 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);
3376 if(mainmenu==17)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);
3377 if(mainmenu==13&&j!=1)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);
3378 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);
3384 glClear(GL_DEPTH_BUFFER_BIT);
3385 glEnable(GL_ALPHA_TEST);
3386 glAlphaFunc(GL_GREATER, 0.001f);
3387 glEnable(GL_TEXTURE_2D);
3388 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3389 glDisable(GL_CULL_FACE);
3390 glDisable(GL_LIGHTING);
3391 if(j==6)glColor4f(1,1,1,1);
3392 else glColor4f(1,0,0,1);
3394 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3395 glPushMatrix(); // Store The Projection Matrix
3396 glLoadIdentity(); // Reset The Projection Matrix
3397 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3398 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3399 glPushMatrix(); // Store The Modelview Matrix
3400 glLoadIdentity(); // Reset The Modelview Matrix
3403 //Draw world, draw map
3404 glTranslatef(2,-5,0);
3406 if(j>6&&j<nummenuitems-1)
3408 XYZ linestart,lineend,offset;
3415 //float linestartx,lineendx,linestarty,lineendy,offsetx,offsety;
3416 linestart.x=(startx[j]+endx[j])/2;
3417 linestart.y=(starty[j]+endy[j])/2;
3418 if(j>=6+accountactive->getCampaignChoicesMade()){
3419 linestart.x=(startx[6+accountactive->getCampaignChoicesMade()]+endx[6+accountactive->getCampaignChoicesMade()])/2;
3420 linestart.y=(starty[6+accountactive->getCampaignChoicesMade()]+endy[6+accountactive->getCampaignChoicesMade()])/2;
3422 lineend.x=(startx[j+1]+endx[j+1])/2;
3423 lineend.y=(starty[j+1]+endy[j+1])/2;
3424 offset=lineend-linestart;
3427 offset=DoRotation(offset,0,0,90);
3429 glDisable(GL_TEXTURE_2D);
3431 if(j<6+accountactive->getCampaignChoicesMade()){
3432 glColor4f(0.5,0,0,1);
3440 linestart+=fac*4*startsize;
3441 lineend-=fac*4*endsize;
3443 if(!(j>7+accountactive->getCampaignChoicesMade()+campaignchoicenum)){
3444 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3448 glVertex3f(linestart.x-offset.x*startsize, linestart.y-offset.y*startsize, 0.0f);
3450 glVertex3f(linestart.x+offset.x*startsize, linestart.y+offset.y*startsize, 0.0f);
3452 glVertex3f(lineend.x+offset.x*endsize, lineend.y+offset.y*endsize, 0.0f);
3454 glVertex3f(lineend.x-offset.x*endsize, lineend.y-offset.y*endsize, 0.0f);
3458 glEnable(GL_TEXTURE_2D);
3462 if(j==6)glBindTexture( GL_TEXTURE_2D, Mainmenuitems[7]);
3463 else glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
3464 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
3465 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
3466 if(j-7<accountactive->getCampaignChoicesMade())glColor4f(0.5,0,0,1);
3467 if(j-7>=accountactive->getCampaignChoicesMade())glColor4f(1,0,0,1);
3468 if(j==6)glColor4f(1,1,1,1);
3471 itemsize=abs(startx[j]-endx[j])/2;
3473 midpoint.x=(startx[j]+endx[j])/2;
3474 midpoint.y=(starty[j]+endy[j])/2;
3475 if(j>6&&(j-7<accountactive->getCampaignChoicesMade()))itemsize*=.5;
3476 if(!(j-7>accountactive->getCampaignChoicesMade()+campaignchoicenum))
3478 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3482 glVertex3f(midpoint.x-itemsize+movex[j]*transition, midpoint.y-itemsize+movey[j]*transition, 0.0f);
3484 glVertex3f(midpoint.x+itemsize+movex[j]*transition, midpoint.y-itemsize+movey[j]*transition, 0.0f);
3486 glVertex3f(midpoint.x+itemsize+movex[j]*transition, midpoint.y+itemsize+movey[j]*transition, 0.0f);
3488 glVertex3f(midpoint.x-itemsize+movex[j]*transition, midpoint.y+itemsize+movey[j]*transition, 0.0f);
3492 //glDisable(GL_ALPHA_TEST);
3493 if(j<4)glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3496 if(1-((float)i)/10-(1-selectedlong[j])>0)
3498 glColor4f(1,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3499 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3503 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);
3505 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);
3507 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);
3509 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);
3517 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3519 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3521 if(j-7>=accountactive->getCampaignChoicesMade()){
3522 text.glPrintOutlined(0.9,0,0,startx[j]+10,starty[j]-4,menustring[j],0,0.6,640,480);
3523 glDisable(GL_DEPTH_TEST);
3529 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3531 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3534 if(mainmenu==1||mainmenu==2)
3535 if(transition<.1||transition>.9){
3536 glClear(GL_DEPTH_BUFFER_BIT);
3537 glEnable(GL_ALPHA_TEST);
3538 glAlphaFunc(GL_GREATER, 0.001f);
3539 glEnable(GL_TEXTURE_2D);
3540 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3541 glDisable(GL_CULL_FACE);
3542 glDisable(GL_LIGHTING);
3544 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3545 glPushMatrix(); // Store The Projection Matrix
3546 glLoadIdentity(); // Reset The Projection Matrix
3547 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3548 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3549 glPushMatrix(); // Store The Modelview Matrix
3550 glLoadIdentity(); // Reset The Modelview Matrix
3552 glDisable(GL_TEXTURE_2D);
3554 glColor4f(1,0,0,1-(transition*10));
3556 glColor4f(1,0,0,1-((1-transition)*10));
3559 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3563 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3564 glPushMatrix(); // Store The Projection Matrix
3565 glLoadIdentity(); // Reset The Projection Matrix
3566 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
3567 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3568 glPushMatrix(); // Store The Modelview Matrix
3569 glLoadIdentity(); // Reset The Modelview Matrix
3570 glTranslatef(screenwidth/2,screenheight/2,0);
3572 glScalef((float)screenwidth/2,(float)screenheight/2,1);
3573 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3575 glEnable(GL_TEXTURE_2D);
3577 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
3578 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
3580 if(!waiting) { // hide the cursor while waiting for a key
3582 glTranslatef(mousecoordh-screenwidth/2,mousecoordv*-1+screenheight/2,0);
3583 glScalef((float)screenwidth/64,(float)screenwidth/64,1);
3584 glTranslatef(1,-1,0);
3585 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3587 glBindTexture( GL_TEXTURE_2D, cursortexture);
3589 //glScalef(.25,.25,.25);
3592 glVertex3f(-1, -1, 0.0f);
3594 glVertex3f(1, -1, 0.0f);
3596 glVertex3f(1, 1, 0.0f);
3598 glVertex3f(-1, 1, 0.0f);
3604 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3610 //printf("Flash amount: %f, delay %i\n", flashamount, flashdelay);
3611 if(flashamount>1)flashamount=1;
3612 if(flashdelay<=0)flashamount-=multiplier;
3614 if(flashamount<0)flashamount=0;
3615 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3616 glDisable(GL_CULL_FACE);
3617 glDisable(GL_LIGHTING);
3618 glDisable(GL_TEXTURE_2D);
3620 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3621 glPushMatrix(); // Store The Projection Matrix
3622 glLoadIdentity(); // Reset The Projection Matrix
3623 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
3624 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3625 glPushMatrix(); // Store The Modelview Matrix
3626 glLoadIdentity(); // Reset The Modelview Matrix
3627 glScalef(screenwidth,screenheight,1);
3628 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3630 glColor4f(flashr,flashg,flashb,flashamount);
3632 glVertex3f(0, 0, 0.0f);
3633 glVertex3f(256, 0, 0.0f);
3634 glVertex3f(256, 256, 0.0f);
3635 glVertex3f(0, 256, 0.0f);
3637 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3638 glPopMatrix(); // Restore The Old Projection Matrix
3639 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3640 glPopMatrix(); // Restore The Old Projection Matrix
3641 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
3642 glEnable(GL_CULL_FACE);
3643 glDisable(GL_BLEND);
3648 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)||(!gameon&&gamestarted)){
3649 tempmult=multiplier;
3654 if ( side == stereoRight || side == stereoCenter ) {
3655 if(drawmode!=motionblurmode||mainmenu){
3660 //myassert(glGetError() == GL_NO_ERROR);
3661 glDrawBuffer(GL_BACK);
3662 glReadBuffer(GL_BACK);
3667 if(drawtoggle==2)drawtoggle=0;
3669 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)){
3670 multiplier=tempmult;
3672 //Jordan fixed your warning!