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"
28 extern int environment;
29 extern float texscale;
31 extern Terrain terrain;
32 extern Sprites sprites;
33 extern float multiplier;
35 extern float viewdistance;
36 extern float fadestart;
37 extern float screenwidth,screenheight;
38 extern int kTextureSize;
39 extern FRUSTUM frustum;
41 extern Objects objects;
43 extern float usermousesensitivity;
45 extern float camerashake;
46 extern Weapons weapons;
47 extern Person player[maxplayers];
49 extern float slomodelay;
50 extern bool ismotionblur;
52 extern float blackout;
53 extern bool damageeffects;
55 extern int numplayers;
56 extern bool texttoggle;
57 extern float blurness;
58 extern float targetblurness;
59 extern float playerdist;
60 extern bool cellophane;
62 extern float flashamount,flashr,flashg,flashb;
63 extern int flashdelay;
65 extern float motionbluramount;
67 extern bool alwaysblur;
69 extern bool tilt2weird;
70 extern bool tiltweird;
72 extern bool proportionweird;
73 extern bool vertexweird[6];
74 extern bool velocityblur;
75 extern bool buttons[3];
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;
112 extern int numaccounts;
113 extern int accountactive;
114 extern int accountdifficulty[10];
115 extern int accountprogress[10];
116 extern float accountpoints[10];
117 extern float accounthighscore[10][50];
118 extern float accountfasttime[10][50];
119 extern bool accountunlocked[10][60];
120 extern char accountname[10][256];
123 extern int numflipfail;
125 extern int numstaffattack;
126 extern int numswordattack;
127 extern int numknifeattack;
128 extern int numunarmedattack;
129 extern int numescaped;
130 extern int numflipped;
131 extern int numwallflipped;
132 extern int numthrowkill;
133 extern int numafterkill;
134 extern int numreversals;
135 extern int numattacks;
136 extern int maxalarmed;
137 extern int numresponded;
139 extern bool campaign;
140 extern bool winfreeze;
142 extern float menupulse;
144 extern bool gamestart;
146 extern int numdialogues;
147 extern int numdialogueboxes[max_dialogues];
148 extern int dialoguetype[max_dialogues];
149 extern int dialogueboxlocation[max_dialogues][max_dialoguelength];
150 extern float dialogueboxcolor[max_dialogues][max_dialoguelength][3];
151 extern int dialogueboxsound[max_dialogues][max_dialoguelength];
152 extern char dialoguetext[max_dialogues][max_dialoguelength][128];
153 extern char dialoguename[max_dialogues][max_dialoguelength][64];
154 extern XYZ dialoguecamera[max_dialogues][max_dialoguelength];
155 extern XYZ participantlocation[max_dialogues][10];
156 extern int participantfocus[max_dialogues][max_dialoguelength];
157 extern int participantaction[max_dialogues][max_dialoguelength];
158 extern float participantrotation[max_dialogues][10];
159 extern XYZ participantfacing[max_dialogues][max_dialoguelength][10];
160 extern float dialoguecamerarotation[max_dialogues][max_dialoguelength];
161 extern float dialoguecamerarotation2[max_dialogues][max_dialoguelength];
162 extern int indialogue;
163 extern int whichdialogue;
164 extern int directing;
165 extern float dialoguetime;
166 extern int dialoguegonethrough[20];
168 extern int accountcampaignchoicesmade[10];
169 extern int accountcampaignchoices[10][5000];
171 extern float accountcampaignhighscore[10];
172 extern float accountcampaignfasttime[10];
173 extern float accountcampaignscore[10];
174 extern float accountcampaigntime[10];
176 extern bool gamestarted;
178 extern bool showdamagebar;
180 extern OPENAL_SAMPLE *samp[100];
181 extern int channels[100];
182 extern "C" void PlaySoundEx(int channel, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
184 /*********************> DrawGLScene() <*****/
185 long long Game::MD5_string (char *string){
190 sprintf (temp, "%s",string);
193 while (i<256&&temp[i]!='\0'){
194 if(temp[i]%3==0)num+=temp[i]*124;
195 else if(temp[i]%3==1)num-=temp[i]*temp[i];
200 num=longlongabs(num);
203 while(num<LONGLONGCONST(5000000000000000)){
207 while(num>LONGLONGCONST(9900000000000000)){
213 //return 1111111111111111;
216 int Game::DrawGLScene(StereoSide side)
218 static float texcoordwidth,texcoordheight;
219 static float texviewwidth, texviewheight;
221 static GLubyte color;
222 static float newbrightness;
223 static float changespeed;
224 static XYZ checkpoint;
225 static float tempmult;
227 static char string[256]="";
228 static char string2[256]="";
229 static char string3[256]="";
231 static float lastcheck;
233 lastcheck+=multiplier;
235 if ( stereomode == stereoAnaglyph ) {
237 case stereoLeft: glColorMask( 0.0, 1.0, 1.0, 1.0 ); break;
238 case stereoRight: glColorMask( 1.0, 0.0, 0.0, 1.0 ); break;
241 glColorMask( 1.0, 1.0, 1.0, 1.0 );
243 if ( stereomode == stereoHorizontalInterlaced || stereomode == stereoVerticalInterlaced ) {
244 glStencilFunc(side == stereoLeft ? GL_NOTEQUAL : GL_EQUAL, 0x01, 0x01);
248 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)){
255 numboundaries=mapradius*2;
256 if(numboundaries>360)numboundaries=360;
257 for(i=0;i<numboundaries;i++){
260 boundary[i]=mapcenter+DoRotation(boundary[i]*mapradius,0,i*(360/((float)(numboundaries))),0);
269 olddrawmode=drawmode;
270 if(ismotionblur&&!loading){
271 if((findLengthfast(&player[0].velocity)>200)&&velocityblur&&!cameramode){
272 drawmode=motionblurmode;
273 motionbluramount=200/(findLengthfast(&player[0].velocity));
276 if(player[0].damage-player[0].superpermanentdamage>(player[0].damagetolerance-player[0].superpermanentdamage)*1/2&&damageeffects&&!cameramode){
277 drawmode=doublevisionmode;
284 drawmode=motionblurmode;
286 slomodelay-=multiplier;
287 if(slomodelay<0)slomo=0;
291 if((!changed&&!slomo)||loading){
293 if(ismotionblur&&(/*fps>100||*/alwaysblur)){
294 if(olddrawmode!=realmotionblurmode)change=1;
296 drawmode=realmotionblurmode;
298 else if(olddrawmode==realmotionblurmode)change=2;
302 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted))drawmode=normalmode;
303 if((freeze||winfreeze)&&ismotionblur&&!mainmenu)drawmode=radialzoommode;
305 if(winfreeze||mainmenu)drawmode=normalmode;
308 if(drawmode==glowmode){
314 DSpContext_FadeGamma(NULL,200,&color2);
318 if(drawtoggle!=2)drawtoggle=1-drawtoggle;
322 texviewwidth=kTextureSize;
323 if(texviewwidth>screenwidth)texviewwidth=screenwidth;
324 texviewheight=kTextureSize;
325 if(texviewheight>screenheight)texviewheight=screenheight;
327 texcoordwidth=screenwidth/kTextureSize;
328 texcoordheight=screenheight/kTextureSize;
329 if(texcoordwidth>1)texcoordwidth=1;
330 if(texcoordheight>1)texcoordheight=1;
333 glDrawBuffer(GL_BACK);
334 glReadBuffer(GL_BACK);
336 /*if(environment==desertenvironment)glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, (float)(abs(Random()%100))/50 );
337 else glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0);
339 if(abs(blurness-targetblurness)<multiplier*10||abs(blurness-targetblurness)>2){
340 blurness=targetblurness;
341 targetblurness=(float)(abs(Random()%100))/40;
343 if(blurness<targetblurness)blurness+=multiplier*5;
344 if(blurness>targetblurness)blurness-=multiplier*5;
347 static XYZ terrainlight;
348 static float distance;
349 //if(drawmode==normalmode)ReSizeGLScene(90,.1);
350 if(drawmode==normalmode)ReSizeGLScene(90,.1f);
351 if(drawmode!=normalmode)glViewport(0,0,texviewwidth,texviewheight);
352 glDepthFunc(GL_LEQUAL);
354 glAlphaFunc(GL_GREATER, 0.0001f);
355 glEnable(GL_ALPHA_TEST);
356 glClearColor(0.25f, 0.25f, 0.25f, 1.0f);
357 glClear(GL_DEPTH_BUFFER_BIT);
359 glMatrixMode (GL_MODELVIEW);
360 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
363 // Move the camera for the current eye's point of view.
364 // Reverse the movement if we're reversing stereo
365 glTranslatef((stereoseparation/2) * side * (stereoreverse ? -1 : 1), 0, 0);
367 if(!cameramode&&!freeze&&!winfreeze){
368 glRotatef(float(Random()%100)/10*camerashake/*+(woozy*woozy)/10*/,0,0,1);
369 glRotatef(rotation2+sin(woozy/2)*(player[0].damage/player[0].damagetolerance)*5,1,0,0);
370 glRotatef(rotation+sin(woozy)*(player[0].damage/player[0].damagetolerance)*5,0,1,0);
372 if(cameramode||freeze||winfreeze){
373 //glRotatef(float(Random()%100)/10*camerashake/*+(woozy*woozy)/10*/,0,0,1);
374 glRotatef(rotation2,1,0,0);
375 glRotatef(rotation,0,1,0);
378 if(environment==desertenvironment){
379 glRotatef((float)(abs(Random()%100))/3000-1,1,0,0);
380 glRotatef((float)(abs(Random()%100))/3000-1,0,1,0);
381 //glRotatef(blurness/40-1,1,0,0);
382 //glRotatef(blurness/40-1,0,1,0);
384 SetUpLight(&light,0);
386 if(environment==desertenvironment&&detail==2)glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, blurness+.4 );
387 if(environment==desertenvironment){
388 glRotatef((float)(abs(Random()%100))/1000,1,0,0);
389 glRotatef((float)(abs(Random()%100))/1000,0,1,0);
392 glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0);
394 glTranslatef(-viewer.x,-viewer.y,-viewer.z);
395 frustum.GetFrustum();
399 static float size,opacity,rotation;
401 for(k=0;k<numplayers;k++){
402 if(!player[k].skeleton.free&&player[k].playerdetail&&player[k].howactive<typesleeping)
403 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)
404 for(i=0;i<player[k].skeleton.num_joints;i++){
405 if(player[k].skeleton.joints[i].label==leftknee||player[k].skeleton.joints[i].label==rightknee||player[k].skeleton.joints[i].label==groin){
406 point=DoRotation(player[k].skeleton.joints[i].position,0,player[k].rotation,0)*player[k].scale+player[k].coords;
408 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;
409 if(k!=0&&tutoriallevel==1){
410 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;
412 terrain.MakeDecal(shadowdecal,point,size,opacity,rotation);
413 if(terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz])
414 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
415 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
416 if(objects.position[j].y<player[k].coords.y||objects.type[j]==tunneltype||objects.type[j]==weirdtype){
417 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);
420 if(k!=0&&tutoriallevel==1){
421 opacity=.2+.2*sin(smoketex*6+i);
423 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
428 if((player[k].skeleton.free||player[k].howactive>=typesleeping)&&player[k].playerdetail)
429 if(frustum.SphereInFrustum(player[k].coords.x,player[k].coords.y,player[k].coords.z,player[k].scale*5)&&player[k].occluded<25)
430 for(i=0;i<player[k].skeleton.num_joints;i++){
431 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){
432 if(player[k].skeleton.free)point=player[k].skeleton.joints[i].position*player[k].scale+player[k].coords;
433 else point=DoRotation(player[k].skeleton.joints[i].position,0,player[k].rotation,0)*player[k].scale+player[k].coords;
435 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;
436 if(k!=0&&tutoriallevel==1){
437 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;
439 terrain.MakeDecal(shadowdecal,point,size,opacity*.7,rotation);
440 if(terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz])
441 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
442 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
443 if(objects.position[j].y<player[k].coords.y||objects.type[j]==tunneltype||objects.type[j]==weirdtype){
444 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);
445 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);
448 if(k!=0&&tutoriallevel==1){
449 opacity=.2+.2*sin(smoketex*6+i);
451 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
457 if(!player[k].playerdetail)
458 if(frustum.SphereInFrustum(player[k].coords.x,player[k].coords.y,player[k].coords.z,player[k].scale*5))
460 point=player[k].coords;
462 opacity=.4-(player[k].coords.y-terrain.getHeight(player[k].coords.x,player[k].coords.z))/5;
463 terrain.MakeDecal(shadowdecal,point,size,opacity*.7,rotation);
464 if(terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz])
465 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
466 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
467 point=DoRotation(player[k].coords-objects.position[j],0,-objects.rotation[j],0);
470 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
476 glEnable(GL_TEXTURE_2D);
478 glEnable(GL_DEPTH_TEST);
479 glEnable(GL_CULL_FACE);
481 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
482 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
483 glBindTexture( GL_TEXTURE_2D, terraintexture);
485 glBindTexture( GL_TEXTURE_2D, terraintexture2);
487 //glBindTexture( GL_TEXTURE_2D, terraintexture3);
488 //glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
491 terrain.drawdecals();
494 glEnable(GL_CULL_FACE);
495 glEnable(GL_LIGHTING);
497 glEnable(GL_TEXTURE_2D);
500 glEnable(GL_COLOR_MATERIAL);
515 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
516 glEnable(GL_CULL_FACE);
517 glCullFace(GL_FRONT);
519 for(k=0;k<numplayers;k++){
520 if(k==0||tutoriallevel!=1){
522 glEnable(GL_LIGHTING);
523 terrainlight=terrain.getLighting(player[k].coords.x,player[k].coords.z);
524 distance=findDistancefast(&viewer,&player[k].coords);
525 distance=(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance;
526 glColor4f(terrainlight.x,terrainlight.y,terrainlight.z,distance);
527 if(distance>=1)glDisable(GL_BLEND);
529 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;
531 if(!player[k].occluded==0)i=checkcollide(viewer,checkpoint,player[k].lastoccluded);
532 if(i==-1||player[k].occluded==0)i=checkcollide(viewer,checkpoint);
534 player[k].occluded+=1;
535 player[k].lastoccluded=i;
537 else player[k].occluded=0;
538 if(player[k].occluded<25)player[k].DrawSkeleton();
544 if(!cameramode&&musictype==stream_music2)playerdist=findDistancefastflat(&player[0].coords,&viewer);
545 else playerdist=-100;
548 glEnable(GL_TEXTURE_2D);
553 if(frustum.SphereInFrustum(realhawkcoords.x+hawk.boundingspherecenter.x,realhawkcoords.y+hawk.boundingspherecenter.y,realhawkcoords.z+hawk.boundingspherecenter.z,2)){
554 glAlphaFunc(GL_GREATER, 0.0001f);
556 glDisable(GL_CULL_FACE);
557 glDisable(GL_LIGHTING);
559 glTranslatef(hawkcoords.x,hawkcoords.y,hawkcoords.z);
560 glRotatef(hawkrotation,0,1,0);
561 glTranslatef(25,0,0);
562 distance=findDistancefast(&viewer,&realhawkcoords)*1.2;
563 glColor4f(light.color[0],light.color[1],light.color[2],(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance);
564 if((viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance>1)glColor4f(light.color[0],light.color[1],light.color[2],1);
565 if((viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance>0)
566 hawk.drawdifftex(hawktexture);
571 /*glEnable(GL_CULL_FACE);
572 glCullFace(GL_FRONT);
574 for(k=0;k<numplayers;k++){
576 glEnable(GL_LIGHTING);
577 terrainlight=terrain.getLighting(player[k].coords.x,player[k].coords.z);
578 distance=findDistancefast(&viewer,&player[k].coords);
579 distance=(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance;
580 glColor4f(terrainlight.x,terrainlight.y,terrainlight.z,distance);
581 if(distance>=1)glDisable(GL_BLEND);
583 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;
585 if(checkcollide(viewer,checkpoint)){
586 player[k].occluded+=1;
588 else player[k].occluded=0;
589 if(player[k].occluded<25)player[k].DrawSkeleton();
593 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
594 glEnable(GL_CULL_FACE);
595 glCullFace(GL_FRONT);
597 for(k=0;k<numplayers;k++){
598 if(!(k==0||tutoriallevel!=1)){
600 glEnable(GL_LIGHTING);
601 terrainlight=terrain.getLighting(player[k].coords.x,player[k].coords.z);
602 distance=findDistancefast(&viewer,&player[k].coords);
603 distance=(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance;
604 glColor4f(terrainlight.x,terrainlight.y,terrainlight.z,distance);
605 if(distance>=1)glDisable(GL_BLEND);
607 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;
609 if(!player[k].occluded==0)i=checkcollide(viewer,checkpoint,player[k].lastoccluded);
610 if(i==-1||player[k].occluded==0)i=checkcollide(viewer,checkpoint);
612 player[k].occluded+=1;
613 player[k].lastoccluded=i;
615 else player[k].occluded=0;
616 if(player[k].occluded<25)player[k].DrawSkeleton();
623 glEnable(GL_TEXTURE_2D);
628 glDisable(GL_COLOR_MATERIAL);
630 glDisable(GL_LIGHTING);
631 glDisable(GL_TEXTURE_2D);
639 glDisable(GL_LIGHTING);
640 glDisable(GL_TEXTURE_2D);
641 glDisable(GL_COLOR_MATERIAL);
644 for(k=0;k<numplayers;k++){
645 if(player[k].numwaypoints>1){
646 glBegin(GL_LINE_LOOP);
647 for(i=0;i<player[k].numwaypoints;i++){
648 glVertex3f(player[k].waypoints[i].x,player[k].waypoints[i].y+.5,player[k].waypoints[i].z);
657 for(k=0;k<numpathpoints;k++){
658 if(numpathpointconnect[k]){
659 for(i=0;i<numpathpointconnect[k];i++){
660 glBegin(GL_LINE_LOOP);
661 glVertex3f(pathpoint[k].x,pathpoint[k].y+.5,pathpoint[k].z);
662 glVertex3f(pathpoint[pathpointconnect[k][i]].x,pathpoint[pathpointconnect[k][i]].y+.5,pathpoint[pathpointconnect[k][i]].z);
670 glVertex3f(pathpoint[pathpointselected].x,pathpoint[pathpointselected].y+.5,pathpoint[pathpointselected].z);
677 glEnable(GL_TEXTURE_2D);
678 glColor4f(.5,.5,.5,1);
680 sprintf (string, " ",(int)(fps));
681 text.glPrint(10,30,string,0,.8,screenwidth,screenheight);
684 if(bonus>0&&bonustime<1&&!winfreeze&&indialogue==-1/*bonustime<4*/){
685 if(bonus==tracheotomy)sprintf (string, "Tracheotomy!");
686 else if(bonus==backstab)sprintf (string, "Backstabber!");
687 else if(bonus==spinecrusher)sprintf (string, "Spinecrusher!");
688 else if(bonus==ninja)sprintf (string, "Ninja Bonus!");
689 else if(bonus==style)sprintf (string, "Style Bonus!");
690 else if(bonus==cannon)sprintf (string, "Leg Cannon!");
691 else if(bonus==aimbonus)sprintf (string, "Nice Aim!");
692 else if(bonus==deepimpact)sprintf (string, "Heavy Impact!");
693 else if(bonus==touchofdeath)sprintf (string, "Touch of Death!");
694 else if(bonus==swordreversebonus)sprintf (string, "Sword Disarm!");
695 else if(bonus==staffreversebonus)sprintf (string, "Staff Disarm!");
696 else if(bonus==reverseko)sprintf (string, "Reversal KO!");
697 else if(bonus==solidhit)sprintf (string, "Solid Hit!");
698 else if(bonus==twoxcombo)sprintf (string, "2X Combo!");
699 else if(bonus==threexcombo)sprintf (string, "3X Combo!");
700 else if(bonus==fourxcombo)sprintf (string, "4X COMBO!");
701 else if(bonus==megacombo)sprintf (string, "MEGA COMBO!");
702 else if(bonus==Reversal)sprintf (string, "Reversal!");
703 else if(bonus==Stabbonus)sprintf (string, "Punctured!");
704 else if(bonus==Slicebonus)sprintf (string, "Sliced!");
705 else if(bonus==Bullseyebonus)sprintf (string, "Bullseye!");
706 else if(bonus==Slashbonus)sprintf (string, "Slashed!");
707 else if(bonus==Wolfbonus)sprintf (string, "WOLF SLAYER!");
708 else if(bonus==FinishedBonus)sprintf (string, "SLAIN!");
709 else if(bonus==TackleBonus)sprintf (string, "Tackle!");
710 else if(bonus==AboveBonus)sprintf (string, "Death from Above!");
711 else sprintf (string, "Excellent!");
713 glColor4f(0,0,0,1-bonustime);
714 text.glPrintOutline(1024/2-10*strlen(string)-4,768/16-4+768*4/5,string,1,2.5,1024,768);
715 glColor4f(1,0,0,1-bonustime);
716 text.glPrint(1024/2-10*strlen(string),768/16+768*4/5,string,1,2,1024,768);
718 sprintf (string, "%d",(int)bonusvalue);
719 glColor4f(0,0,0,1-bonustime);
720 text.glPrintOutline(1024/2-10*strlen(string)-4,768/16-4-20+768*4/5,string,1,2.5*.8,1024,768);
721 glColor4f(1,0,0,1-bonustime);
722 text.glPrint(1024/2-10*strlen(string),768/16-20+768*4/5,string,1,2*.8,1024,768);
723 glColor4f(.5,.5,.5,1);
726 if(tutoriallevel==1){
727 tutorialopac=tutorialmaxtime-tutorialstagetime;
728 if(tutorialopac>1)tutorialopac=1;
729 if(tutorialopac<0)tutorialopac=0;
731 sprintf (string, " ");
732 sprintf (string2, " ");
733 sprintf (string3, " ");
734 if(tutorialstage==0){
735 sprintf (string, " ");
736 sprintf (string2, " ");
737 sprintf (string3, " ");
739 if(tutorialstage==1){
740 sprintf (string, "Welcome to the Lugaru training level!");
741 sprintf (string2, " ");
742 sprintf (string3, " ");
744 if(tutorialstage==2){
745 sprintf (string, "BASIC MOVEMENT:");
746 sprintf (string2, " ");
747 sprintf (string3, " ");
749 if(tutorialstage==3){
750 sprintf (string, "You can move the mouse to rotate the camera.");
751 sprintf (string2, " ");
752 sprintf (string3, " ");
754 if(tutorialstage==4){
755 sprintf (string, "Try using the %s, %s, %s and %s keys to move around.",KeyToChar(forwardkey),KeyToChar(leftkey),KeyToChar(backkey),KeyToChar(rightkey));
756 sprintf (string2, "All movement is relative to the camera.");
757 sprintf (string3, " ");
759 if(tutorialstage==5){
760 sprintf (string, "Please press %s to jump.",KeyToChar(jumpkey));
761 sprintf (string2, "You can hold it longer to jump higher.");
762 sprintf (string3, " ");
764 if(tutorialstage==6){
765 sprintf (string, "You can press %s to crouch.",KeyToChar(crouchkey));
766 sprintf (string2, "You can jump higher from a crouching position.");
767 sprintf (string3, " ");
769 if(tutorialstage==7){
770 sprintf (string, "While running, you can press %s to roll.",KeyToChar(crouchkey));
771 sprintf (string2, " ");
772 sprintf (string3, " ");
774 if(tutorialstage==8){
775 sprintf (string, "While crouching, you can sneak around silently");
776 sprintf (string2, "using the movement keys.");
777 sprintf (string3, " ");
779 if(tutorialstage==9){
780 sprintf (string, "Release the crouch key while sneaking and hold the movement keys");
781 sprintf (string2, "to run animal-style.");
782 sprintf (string3, " ");
784 if(tutorialstage==10){
785 sprintf (string, "ADVANCED MOVEMENT:");
786 sprintf (string2, " ");
787 sprintf (string3, " ");
789 if(tutorialstage==11){
790 sprintf (string, "When you jump at a wall, you can hold %s again",KeyToChar(jumpkey));
791 sprintf (string2, "during impact to perform a walljump.");
792 sprintf (string3, "Be sure to use the movement keys to press against the wall");
794 if(tutorialstage==12){
795 sprintf (string, "While in the air, you can press crouch to flip.",KeyToChar(jumpkey));
796 sprintf (string2, "Walljumps and flips confuse enemies and give you more control.");
797 sprintf (string3, " ");
799 if(tutorialstage==13){
800 sprintf (string, "BASIC COMBAT:");
801 sprintf (string2, " ");
802 sprintf (string3, " ");
804 if(tutorialstage==14){
805 sprintf (string, "There is now an imaginary enemy");
806 sprintf (string2, "in the middle of the training area.");
807 sprintf (string3, " ");
809 if(tutorialstage==15){
810 if(attackkey==MAC_MOUSEBUTTON1)sprintf (string, "Click to attack when you are near an enemy.");
811 else sprintf (string, "Press %s to attack when you are near an enemy.",KeyToChar(attackkey));
812 sprintf (string2, "You can punch by standing still near an enemy and attacking.");
813 sprintf (string3, " ");
815 if(tutorialstage==16){
816 sprintf (string, "If you are close, you will perform a weak punch.");
817 sprintf (string2, "The weak punch is excellent for starting attack combinations.");
818 sprintf (string3, " ");
820 if(tutorialstage==17){
821 sprintf (string, "Attacking while running results in a spin kick.");
822 sprintf (string2, "This is one of your most powerful ground attacks.");
823 sprintf (string3, " ");
825 if(tutorialstage==18){
826 sprintf (string, "Sweep the enemy's legs out by attacking while crouched.");
827 sprintf (string2, "This is a very fast attack, and easy to follow up.");
828 sprintf (string3, " ");
830 if(tutorialstage==19){
831 sprintf (string, "When an enemy is on the ground, you can deal some extra");
832 sprintf (string2, "damage by running up and drop-kicking him.");
833 sprintf (string3, "(Try knocking them down with a sweep first)");
835 if(tutorialstage==20){
836 sprintf (string, "Your most powerful individual attack is the rabbit kick.");
837 if(attackkey==MAC_MOUSEBUTTON1)sprintf (string2, "Run at the enemy while holding the mouse button, and press");
838 else sprintf (string2, "Run at the enemy while holding %s, and press", KeyToChar(attackkey));
839 sprintf (string3, "the jump key (%s) to attack.",KeyToChar(jumpkey));
841 if(tutorialstage==21){
842 sprintf (string, "This attack is devastating if timed correctly.");
843 sprintf (string2, "Even if timed incorrectly, it will knock the enemy over.");
844 if(againbonus)sprintf (string3, "Try rabbit-kicking the imaginary enemy again.");
845 else sprintf (string3, "Try rabbit-kicking the imaginary enemy.");
847 if(tutorialstage==22){
848 sprintf (string, "If you sneak behind an enemy unnoticed, you can kill");
849 sprintf (string2, "him instantly. Move close behind this enemy");
850 sprintf (string3, "and attack.");
852 if(tutorialstage==23){
853 sprintf (string, "Another important attack is the wall kick. When an enemy");
854 sprintf (string2, "is near a wall, perform a walljump nearby and hold");
855 sprintf (string3, "the attack key during impact with the wall.");
857 if(tutorialstage==24){
858 sprintf (string, "You can tackle enemies by running at them animal-style");
859 if(attackkey==MAC_MOUSEBUTTON1)sprintf (string2, "and pressing jump (%s) or attack(mouse button).",KeyToChar(jumpkey));
860 else sprintf (string2, "and pressing jump (%s) or attack(%s).",KeyToChar(jumpkey),KeyToChar(attackkey));
861 sprintf (string3, "This is especially useful when they are running away.");
863 if(tutorialstage==25){
864 sprintf (string, "Dodge by pressing back and attack. Dodging is essential");
865 sprintf (string2, "against enemies with swords or other long weapons.");
866 sprintf (string3, " ");
868 if(tutorialstage==26){
869 sprintf (string, "REVERSALS AND COUNTER-REVERSALS");
870 sprintf (string2, " ");
871 sprintf (string3, " ");
873 if(tutorialstage==27){
874 sprintf (string, "The enemy can now reverse your attacks.");
875 sprintf (string2, " ");
876 sprintf (string3, " ");
878 if(tutorialstage==28){
879 sprintf (string, "If you attack, you will notice that the enemy now sometimes");
880 sprintf (string2, "catches your attack and uses it against you. Hold");
881 sprintf (string3, "crouch (%s) after attacking to escape from reversals.",KeyToChar(crouchkey));
883 if(tutorialstage==29){
884 sprintf (string, "Try escaping from two more reversals in a row.");
885 sprintf (string2, " ");
886 sprintf (string3, " ");
888 if(tutorialstage==30){
889 sprintf (string, "Good!");
890 sprintf (string2, " ");
891 sprintf (string3, " ");
893 if(tutorialstage==31){
894 sprintf (string, "To reverse an attack, you must tap crouch (%s) during the",KeyToChar(crouchkey));
895 sprintf (string2, "enemy's attack. You must also be close to the enemy;");
896 sprintf (string3, "this is especially important against armed opponents.");
898 if(tutorialstage==32){
899 sprintf (string, "The enemy can attack in %d seconds.", (int)(tutorialmaxtime-tutorialstagetime));
900 sprintf (string2, "This imaginary opponents attacks will be highlighted");
901 sprintf (string3, "to make this easier.");
903 if(tutorialstage==33){
904 sprintf (string, "Reverse three enemy attacks!");
905 sprintf (string2, " ");
906 sprintf (string3, " ");
908 if(tutorialstage==34){
909 sprintf (string, "Reverse two more enemy attacks!");
910 sprintf (string2, " ");
911 sprintf (string3, " ");
913 if(tutorialstage==35){
914 sprintf (string, "Reverse one more enemy attack!");
915 sprintf (string2, " ");
916 sprintf (string3, " ");
918 if(tutorialstage==36){
919 sprintf (string, "Excellent!");
920 sprintf (string2, " ");
921 sprintf (string3, " ");
923 if(tutorialstage==37){
924 sprintf (string, "Now spar with the enemy for %d more seconds.", (int)(tutorialmaxtime-tutorialstagetime));
925 sprintf (string2, "Damage dealt: %d",(int)damagedealt);
926 sprintf (string3, "Damage taken: %d.",(int)damagetaken);
928 if(tutorialstage==38){
929 sprintf (string, "WEAPONS:");
930 sprintf (string2, " ");
931 sprintf (string3, " ");
933 if(tutorialstage==39){
934 sprintf (string, "There is now an imaginary knife");
935 sprintf (string2, "in the center of the training area.");
936 sprintf (string3, " ");
938 if(tutorialstage==40){
939 sprintf (string, "Stand, roll or handspring over the knife");
940 sprintf (string2, "while pressing %s to pick it up.",KeyToChar(throwkey));
941 sprintf (string3, "You can crouch and press the same key to drop it again.");
943 if(tutorialstage==41){
944 sprintf (string, "You can equip and unequip weapons using the %s key.",KeyToChar(drawkey));
945 sprintf (string2, "Sometimes it is best to keep them unequipped to");
946 sprintf (string3, "prevent enemies from taking them. ");
948 if(tutorialstage==42){
949 sprintf (string, "The knife is the smallest weapon and the least encumbering.");
950 sprintf (string2, "You can equip or unequip it while standing, crouching,");
951 sprintf (string3, "running or flipping.");
953 if(tutorialstage==43){
954 sprintf (string, "You perform weapon attacks the same way as unarmed attacks,");
955 sprintf (string2, "but sharp weapons cause permanent damage, instead of the");
956 sprintf (string3, "temporary trauma from blunt weapons, fists and feet.");
958 if(tutorialstage==44){
959 sprintf (string, "The enemy now has your knife!");
960 sprintf (string2, "Please reverse two of his knife attacks.");
961 sprintf (string3, " ");
963 if(tutorialstage==45){
964 sprintf (string, "Please reverse one more of his knife attacks.");
965 sprintf (string2, " ");
966 sprintf (string3, " ");
968 if(tutorialstage==46){
969 sprintf (string, "Now he has a sword!");
970 sprintf (string2, "The sword has longer reach than your arms, so you");
971 sprintf (string3, "must move close to reverse the sword slash.");
973 if(tutorialstage==47){
974 sprintf (string, "Long weapons like the sword and staff are also useful for defense;");
975 sprintf (string2, "you can parry enemy weapon attacks by pressing the attack key");
976 sprintf (string3, "at the right time. Please try parrying the enemy's attacks!");
978 if(tutorialstage==48){
979 sprintf (string, "The staff is like the sword, but has two main attacks.");
980 sprintf (string2, "The standing smash is fast and effective, and the running");
981 sprintf (string3, "spin smash is slower and more powerful.");
983 if(tutorialstage==49){
984 sprintf (string, "When facing an enemy, you can throw the knife with %s.",KeyToChar(throwkey));
985 sprintf (string2, "It is possible to throw the knife while flipping,");
986 sprintf (string3, "but it is very inaccurate.");
988 if(tutorialstage==50){
989 sprintf (string, "You now know everything you can learn from training.");
990 sprintf (string2, "Everything else you must learn from experience!");
991 sprintf (string3, " ");
993 if(tutorialstage==51){
994 sprintf (string, "Walk out of the training area to return to the main menu.");
995 sprintf (string2, " ");
996 sprintf (string3, " ");
999 glColor4f(0,0,0,tutorialopac);
1000 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);
1001 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);
1002 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);
1003 glColor4f(1,1,1,tutorialopac);
1004 text.glPrint(screenwidth/2-7.6*strlen(string)*screenwidth/1024,screenheight/16+screenheight*4/5,string,1,1.5*screenwidth/1024,screenwidth,screenheight);
1005 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);
1006 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);
1008 sprintf (string, "Press 'tab' to skip to the next item.",KeyToChar(jumpkey));
1009 sprintf (string2, "Press escape at any time to");
1010 sprintf (string3, "pause or exit the tutorial.");
1013 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);
1014 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);
1015 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);
1016 glColor4f(0.5,0.5,0.5,1);
1017 text.glPrint(screenwidth/2-7.6*strlen(string)*screenwidth/1024*.8,0+screenheight*1/10,string,1,1.5*screenwidth/1024*.8,screenwidth,screenheight);
1018 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);
1019 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);
1023 if(numhotspots&&(bonustime>=1||bonus<=0||bonustime<0)&&!tutoriallevel){
1025 float closestdist=-1;
1027 closest=currenthotspot;
1028 for(i=0;i<numhotspots;i++){
1029 distance=findDistancefast(&player[0].coords,&hotspot[i]);
1030 if(closestdist==-1||distance<closestdist){
1031 if(findDistancefast(&player[0].coords,&hotspot[i])<hotspotsize[i]&&((hotspottype[i]<=10&&hotspottype[i]>=0)||(hotspottype[i]<=40&&hotspottype[i]>=20))){
1032 closestdist=distance;
1038 currenthotspot=closest;
1039 if(currenthotspot!=-1){
1040 if(hotspottype[closest]<=10){
1041 if(findDistancefast(&player[0].coords,&hotspot[closest])<hotspotsize[closest])
1042 tutorialstagetime=0;
1044 tutorialopac=tutorialmaxtime-tutorialstagetime;
1045 if(tutorialopac>1)tutorialopac=1;
1046 if(tutorialopac<0)tutorialopac=0;
1048 sprintf (string, "%s", hotspottext[closest]);
1056 if(string[i]=='\n'||string[i]>'z'||string[i]<' '||string[i]=='\0'){
1057 glColor4f(0,0,0,tutorialopac);
1058 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);
1059 glColor4f(1,1,1,tutorialopac);
1060 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);
1063 if(string[i]=='\0')done=1;
1069 else if (hotspottype[closest]>=20&&dialoguegonethrough[hotspottype[closest]-20]==0){
1070 whichdialogue=hotspottype[closest]-20;
1071 for(j=0;j<numdialogueboxes[whichdialogue];j++){
1072 player[participantfocus[whichdialogue][j]].coords=participantlocation[whichdialogue][participantfocus[whichdialogue][j]];
1073 player[participantfocus[whichdialogue][j]].rotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
1074 player[participantfocus[whichdialogue][j]].targetrotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
1075 player[participantfocus[whichdialogue][j]].velocity=0;
1076 player[participantfocus[whichdialogue][j]].targetanimation=player[participantfocus[whichdialogue][j]].getIdle();
1077 player[participantfocus[whichdialogue][j]].targetframe=0;
1081 dialoguegonethrough[whichdialogue]++;
1082 if(dialogueboxsound[whichdialogue][indialogue]!=0){
1083 static float gLoc[3];
1084 static float vel[3];
1085 gLoc[0]=player[participantfocus[whichdialogue][indialogue]].coords.x;
1086 gLoc[1]=player[participantfocus[whichdialogue][indialogue]].coords.y;
1087 gLoc[2]=player[participantfocus[whichdialogue][indialogue]].coords.z;
1092 if(dialogueboxsound[whichdialogue][indialogue]==1)whichsoundplay=rabbitchitter;
1093 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
1094 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
1095 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
1096 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
1097 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
1098 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
1099 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
1100 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
1101 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
1102 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
1103 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
1104 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
1105 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
1106 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
1107 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
1108 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
1109 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
1110 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
1111 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
1112 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, true);
1113 OPENAL_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
1114 OPENAL_SetVolume(channels[whichsoundplay], 256);
1115 OPENAL_SetPaused(channels[whichsoundplay], false);
1121 if(indialogue!=-1&&!mainmenu){
1122 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1123 glDisable(GL_CULL_FACE);
1124 glDisable(GL_LIGHTING);
1125 glDisable(GL_TEXTURE_2D);
1127 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1128 glPushMatrix(); // Store The Projection Matrix
1129 glLoadIdentity(); // Reset The Projection Matrix
1130 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1131 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1132 glPushMatrix(); // Store The Modelview Matrix
1133 glLoadIdentity(); // Reset The Modelview Matrix
1134 if(dialogueboxlocation[whichdialogue][indialogue]==1)glTranslatef(0,screenheight*3/4,0);
1135 glScalef(screenwidth,screenheight/4,1);
1136 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1139 glColor4f(dialogueboxcolor[whichdialogue][indialogue][0],dialogueboxcolor[whichdialogue][indialogue][1],dialogueboxcolor[whichdialogue][indialogue][2],0.7);
1141 glVertex3f(0, 0, 0.0f);
1142 glVertex3f(1, 0, 0.0f);
1143 glVertex3f(1, 1, 0.0f);
1144 glVertex3f(0, 1, 0.0f);
1146 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1147 glPopMatrix(); // Restore The Old Projection Matrix
1148 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1149 glPopMatrix(); // Restore The Old Projection Matrix
1150 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1151 glEnable(GL_CULL_FACE);
1152 glDisable(GL_BLEND);
1154 glEnable(GL_TEXTURE_2D);
1161 startx=screenwidth*1/5;
1162 if(dialogueboxlocation[whichdialogue][indialogue]==1)starty=screenheight/16+screenheight*4/5;
1163 if(dialogueboxlocation[whichdialogue][indialogue]==2)starty=screenheight*1/5-screenheight/16;
1165 // char tempname[64];
1169 // for(i=0;i<64;i++){
1174 for(i=0;i<(int)strlen(dialoguename[whichdialogue][indialogue]);i++){
1175 tempname[tempnum]=dialoguename[whichdialogue][indialogue][i];
1177 if(dialoguename[whichdialogue][indialogue][i]=='#'||dialoguename[whichdialogue][indialogue][i]=='\0')goodchar=0;
1178 //if(tempnum>2)if(tempname[tempnum-2]=='e'&&tempname[tempnum-1]=='r')goodchar=0;
1179 //if(tempnum>2)if(tempname[tempnum]=='r'&&tempname[0]=='a')goodchar=0;
1180 if(goodchar)tempnum++;
1181 else tempname[tempnum]='\0';
1184 sprintf (string, "%s: ", tempname);
1186 if(dialogueboxcolor[whichdialogue][indialogue][0]+dialogueboxcolor[whichdialogue][indialogue][1]+dialogueboxcolor[whichdialogue][indialogue][2]<1.5){
1187 glColor4f(0,0,0,tutorialopac);
1188 text.glPrintOutline(startx-2*7.6*strlen(string)*screenwidth/1024-4,starty-4,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight);
1189 glColor4f(0.7,0.7,0.7,tutorialopac);
1190 text.glPrint(startx-2*7.6*strlen(string)*screenwidth/1024,starty,string,1,1.5*screenwidth/1024,screenwidth,screenheight);
1194 glColor4f(0,0,0,tutorialopac);
1195 text.glPrintOutline(startx-2*7.6*strlen(string)*screenwidth/1024-4,starty-4,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight);
1200 for(i=0;i<(int)strlen(dialoguetext[whichdialogue][indialogue])+1;i++){
1201 tempname[tempnum]=dialoguetext[whichdialogue][indialogue][i];
1202 if(dialoguetext[whichdialogue][indialogue][i]!='#')tempnum++;
1206 sprintf (string, "%s", tempname);
1215 if(string[i]=='\n'||string[i]>'z'||string[i]<' '||string[i]=='\0'){
1216 if(dialogueboxcolor[whichdialogue][indialogue][0]+dialogueboxcolor[whichdialogue][indialogue][1]+dialogueboxcolor[whichdialogue][indialogue][2]<1.5){
1217 glColor4f(0,0,0,tutorialopac);
1218 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);
1219 glColor4f(1,1,1,tutorialopac);
1220 text.glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/,starty-20*screenwidth/1024*line,string,1,1.5*screenwidth/1024,screenwidth,screenheight,lastline,i);
1224 glColor4f(0,0,0,tutorialopac);
1225 text.glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/,starty-20*screenwidth/1024*line,string,1,1.5*screenwidth/1024,screenwidth,screenheight,lastline,i);
1229 if(string[i]=='\0')done=1;
1236 if(!tutoriallevel&&!winfreeze&&indialogue==-1&&!mainmenu){
1238 if(!scoreadded)sprintf (string, "Score: %d", (int)accountcampaignscore[accountactive]+(int)bonustotal);//(int)bonustotal);
1239 if(scoreadded)sprintf (string, "Score: %d", (int)accountcampaignscore[accountactive]);//(int)bonustotal);
1241 if(!campaign)sprintf (string, "Score: %d", (int)bonustotal);
1243 text.glPrintOutline(1024/40-4,768/16-4+768*14/16,string,1,1.5*1.25,1024,768);
1245 text.glPrint(1024/40,768/16+768*14/16,string,1,1.5,1024,768);
1247 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1248 glDisable(GL_CULL_FACE);
1249 glDisable(GL_LIGHTING);
1250 glDisable(GL_TEXTURE_2D);
1252 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1253 glPushMatrix(); // Store The Projection Matrix
1254 glLoadIdentity(); // Reset The Projection Matrix
1255 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1256 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1257 glPushMatrix(); // Store The Modelview Matrix
1258 glLoadIdentity(); // Reset The Modelview Matrix
1259 glTranslatef(15,screenheight*17.5/20,0);
1260 glScalef(screenwidth/3+20,screenheight/20,1);
1261 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1263 glColor4f(0.0,0.4,0.0,0.7);
1264 float bar=((float)player[0].damage)/player[0].damagetolerance;
1266 glVertex3f((bar<1?bar:1),0,0.0f);
1267 glVertex3f(1,0,0.0f);
1268 glVertex3f(1,1,0.0f);
1269 glVertex3f((bar<1?bar:1),1,0.0f);
1271 glColor4f(0.1,0.0,0.0,1);
1272 bar = ((float)player[0].bloodloss)/player[0].damagetolerance;
1274 glVertex3f(0,0,0.0f);
1275 glVertex3f((bar<1?bar:1),0,0.0f);
1276 glVertex3f((bar<1?bar:1),1,0.0f);
1277 glVertex3f(0,1,0.0f);
1279 glColor4f(0.4,0.0,0.0,0.7);
1280 bar = ((float)player[0].damage)/player[0].damagetolerance;
1282 glVertex3f(0,0,0.0f);
1283 glVertex3f((bar<1?bar:1),0,0.0f);
1284 glVertex3f((bar<1?bar:1),1,0.0f);
1285 glVertex3f(0,1,0.0f);
1287 glColor4f(0.4,0.0,0.0,0.7);
1288 bar = ((float)player[0].permanentdamage)/player[0].damagetolerance;
1290 glVertex3f(0,0,0.0f);
1291 glVertex3f((bar<1?bar:1),0,0.0f);
1292 glVertex3f((bar<1?bar:1),1,0.0f);
1293 glVertex3f(0,1,0.0f);
1295 glColor4f(0.4,0.0,0.0,0.7);
1296 bar = ((float)player[0].superpermanentdamage)/player[0].damagetolerance;
1298 glVertex3f(0,0,0.0f);
1299 glVertex3f((bar<1?bar:1),0,0.0f);
1300 glVertex3f((bar<1?bar:1),1,0.0f);
1301 glVertex3f(0,1,0.0f);
1303 glColor4f(0.0,0.0,0.0,0.7);
1305 glBegin(GL_LINE_STRIP);
1306 glVertex3f(0,0,0.0f);
1307 glVertex3f(1,0,0.0f);
1308 glVertex3f(1,1,0.0f);
1309 glVertex3f(0,1,0.0f);
1310 glVertex3f(0,0,0.0f);
1313 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1314 glPopMatrix(); // Restore The Old Projection Matrix
1315 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1316 glPopMatrix(); // Restore The Old Projection Matrix
1317 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1318 glEnable(GL_CULL_FACE);
1319 glDisable(GL_BLEND);
1321 glEnable(GL_TEXTURE_2D);
1323 // writing the numbers :
1324 sprintf (string, "Damages : %d/%d (%d)",(int)(player[0].damage),(int)(player[0].damagetolerance),(int)(player[0].bloodloss));
1326 text.glPrintOutline(1024/40-4,768/16-4+768*14/16-40,string,1,1.5*1.25,1024,768);
1328 text.glPrint(1024/40,768/16+768*14/16-40,string,1,1.5,1024,768);
1332 glColor4f(.5,.5,.5,1);
1335 if((texttoggle||editorenabled)&&debugmode&&!mainmenu){
1336 sprintf (string, "The framespersecond is %d.",(int)(fps));
1337 text.glPrint(10,30,string,0,.8,1024,768);
1339 sprintf (string, "Name: %s", registrationname);
1340 text.glPrint(10,260,string,0,.8,1024,768);
1343 if(editorenabled)sprintf (string, "Map editor enabled.");
1344 if(!editorenabled)sprintf (string, "Map editor Disabled.");
1345 text.glPrint(10,60,string,0,.8,1024,768);
1347 sprintf (string, "Object size: %f",editorsize);
1348 text.glPrint(10,75,string,0,.8,1024,768);
1349 if(editorrotation>=0)sprintf (string, "Object rotation: %f",editorrotation);
1350 else sprintf (string, "Object rotation: Random");
1351 text.glPrint(10,90,string,0,.8,1024,768);
1352 if(editorrotation2>=0)sprintf (string, "Object rotation2: %f",editorrotation2);
1353 else sprintf (string, "Object rotation2: Random");
1354 text.glPrint(10,105,string,0,.8,1024,768);
1355 sprintf (string, "Object type: %d",editortype);
1356 text.glPrint(10,120,string,0,.8,1024,768);
1357 if(editortype==boxtype)sprintf (string, "(box)");
1358 if(editortype==treetrunktype)sprintf (string, "(tree)");
1359 if(editortype==walltype)sprintf (string, "(wall)");
1360 if(editortype==weirdtype)sprintf (string, "(weird)");
1361 if(editortype==spiketype)sprintf (string, "(spike)");
1362 if(editortype==rocktype)sprintf (string, "(rock)");
1363 if(editortype==bushtype)sprintf (string, "(bush)");
1364 if(editortype==tunneltype)sprintf (string, "(tunnel)");
1365 if(editortype==chimneytype)sprintf (string, "(chimney)");
1366 if(editortype==platformtype)sprintf (string, "(platform)");
1367 if(editortype==cooltype)sprintf (string, "(cool)");
1368 if(editortype==firetype)sprintf (string, "(fire)");
1369 text.glPrint(130,120,string,0,.8,1024,768);
1371 sprintf (string, "Numplayers: %d",numplayers);
1372 text.glPrint(10,155,string,0,.8,1024,768);
1373 sprintf (string, "Player %d: numwaypoints: %d",numplayers,player[numplayers-1].numwaypoints);
1374 text.glPrint(10,140,string,0,.8,1024,768);
1376 /*sprintf (string, "Coords are: %f %f %f",player[0].coords.x,player[0].coords.y,player[0].coords.z);
1377 text.glPrint(10,200,string,0,.8,1024,768);*/
1378 sprintf (string, "Difficulty: %d",difficulty);
1379 text.glPrint(10,240,string,0,.8,1024,768);
1381 sprintf (string, "lasthotspot: %d",hotspottype[numhotspots-1]);
1382 text.glPrint(10,240,string,0,.8,1024,768);
1383 sprintf (string, "killhotspot: %d",killhotspot);
1384 text.glPrint(10,220,string,0,.8,1024,768);
1385 sprintf (string, "winhotspot: %d",winhotspot);
1386 text.glPrint(10,200,string,0,.8,1024,768);*/
1391 if(drawmode==glowmode){
1392 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1393 glDisable(GL_CULL_FACE);
1394 glDisable(GL_LIGHTING);
1395 glDisable(GL_TEXTURE_2D);
1397 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1398 glPushMatrix(); // Store The Projection Matrix
1399 glLoadIdentity(); // Reset The Projection Matrix
1400 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1401 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1402 glPushMatrix(); // Store The Modelview Matrix
1403 glLoadIdentity(); // Reset The Modelview Matrix
1404 glScalef(screenwidth,screenheight,1);
1405 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1407 glColor4f(0,0,0,.5);
1409 glVertex3f(0, 0, 0.0f);
1410 glVertex3f(256, 0, 0.0f);
1411 glVertex3f(256, 256, 0.0f);
1412 glVertex3f(0, 256, 0.0f);
1414 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1415 glPopMatrix(); // Restore The Old Projection Matrix
1416 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1417 glPopMatrix(); // Restore The Old Projection Matrix
1418 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1419 glEnable(GL_CULL_FACE);
1420 glDisable(GL_BLEND);
1424 if((((blackout&&damageeffects)||(player[0].bloodloss>0&&damageeffects&&player[0].blooddimamount>0)||player[0].dead)&&!cameramode)||console){
1425 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1426 glDisable(GL_CULL_FACE);
1427 glDisable(GL_LIGHTING);
1428 glDisable(GL_TEXTURE_2D);
1430 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1431 glPushMatrix(); // Store The Projection Matrix
1432 glLoadIdentity(); // Reset The Projection Matrix
1433 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1434 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1435 glPushMatrix(); // Store The Modelview Matrix
1436 glLoadIdentity(); // Reset The Modelview Matrix
1437 glScalef(screenwidth,screenheight,1);
1438 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1440 if(player[0].dead)blackout+=multiplier*3;
1441 if(player[0].dead==1)blackout=.4f;
1442 if(player[0].dead==2&&blackout>.6)blackout=.6;
1443 glColor4f(0,0,0,blackout);
1444 if(!player[0].dead){
1445 if((player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5))*.3<.3){
1446 glColor4f(0,0,0,player[0].blooddimamount*player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5)*.3);
1447 blackout=player[0].blooddimamount*player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5)*.3;
1450 glColor4f(0,0,0,player[0].blooddimamount*.3);
1451 blackout=player[0].blooddimamount*.3;
1454 if(console)glColor4f(.7,0,0,.2);
1456 glVertex3f(0, 0, 0.0f);
1457 glVertex3f(256, 0, 0.0f);
1458 glVertex3f(256, 256, 0.0f);
1459 glVertex3f(0, 256, 0.0f);
1461 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1462 glPopMatrix(); // Restore The Old Projection Matrix
1463 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1464 glPopMatrix(); // Restore The Old Projection Matrix
1465 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1466 glEnable(GL_CULL_FACE);
1467 glDisable(GL_BLEND);
1471 if(flashamount>0&&damageeffects){
1472 if(flashamount>1)flashamount=1;
1473 if(flashdelay<=0)flashamount-=multiplier;
1475 if(flashamount<0)flashamount=0;
1476 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1477 glDisable(GL_CULL_FACE);
1478 glDisable(GL_LIGHTING);
1480 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1481 glPushMatrix(); // Store The Projection Matrix
1482 glLoadIdentity(); // Reset The Projection Matrix
1483 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1484 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1485 glPushMatrix(); // Store The Modelview Matrix
1486 glLoadIdentity(); // Reset The Modelview Matrix
1487 glScalef(screenwidth,screenheight,1);
1488 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1490 glColor4f(flashr,flashg,flashb,flashamount);
1492 glVertex3f(0, 0, 0.0f);
1493 glVertex3f(256, 0, 0.0f);
1494 glVertex3f(256, 256, 0.0f);
1495 glVertex3f(0, 256, 0.0f);
1497 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1498 glPopMatrix(); // Restore The Old Projection Matrix
1499 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1500 glPopMatrix(); // Restore The Old Projection Matrix
1501 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1502 glEnable(GL_CULL_FACE);
1503 glDisable(GL_BLEND);
1509 glEnable(GL_TEXTURE_2D);
1512 sprintf (string, " ]");
1513 text.glPrint(10,30+screenheight-330,string,0,1,screenwidth,screenheight);
1515 sprintf (string, "_");
1516 text.glPrint(30+(float)(displayselected)*10,30+(screenheight-330),string,0,1,screenwidth,screenheight);
1520 if((i!=0||chatting)&&displaytime[i]<4)
1521 for(j=0;j<displaychars[i];j++){
1522 glColor4f(1,1,1,4-displaytime[i]);
1523 if(j<displaychars[i]){
1524 sprintf (string, "%c",displaytext[i][j]);
1525 text.glPrint(30+j*10,30+i*20+(screenheight-330),string,0,1,screenwidth,screenheight);
1531 if(minimap&&indialogue==-1){
1535 glDisable(GL_DEPTH_TEST);
1536 glColor3f (1.0, 1.0, 1.0); // no coloring
1538 glEnable(GL_TEXTURE_2D);
1539 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1540 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1541 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1542 glDisable(GL_CULL_FACE);
1543 glDisable(GL_LIGHTING);
1545 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1546 glPushMatrix(); // Store The Projection Matrix
1547 glLoadIdentity(); // Reset The Projection Matrix
1548 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1549 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1550 glPushMatrix(); // Store The Modelview Matrix
1551 glLoadIdentity(); // Reset The Modelview Matrix
1552 glScalef((float)screenwidth/2,(float)screenwidth/2,1);
1553 glTranslatef(1.75,.25,0);
1554 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1564 int numliveplayers=0;
1565 for(i=0;i<numplayers;i++){
1566 if(!player[i].dead)numliveplayers++;
1572 for(i=0;i<objects.numobjects;i++){
1573 if(objects.type[i]==treetrunktype||objects.type[i]==boxtype){
1574 center+=objects.position[i];
1578 for(i=0;i<numplayers;i++){
1579 if(!player[i].dead)center+=player[i].coords;
1581 center/=numadd+numliveplayers;
1583 center=player[0].coords;
1585 float maxdistance=0;
1588 for(i=0;i<objects.numobjects;i++){
1589 tempdist=findDistancefast(¢er,&objects.position[i]);
1590 if(tempdist>maxdistance){
1592 maxdistance=tempdist;
1595 for(i=0;i<numplayers;i++){
1596 if(!player[i].dead){
1597 tempdist=findDistancefast(¢er,&player[i].coords);
1598 if(tempdist>maxdistance){
1600 maxdistance=tempdist;
1604 radius=fast_sqrt(maxdistance);
1608 glScalef(.25/radius*256*terrain.scale*.4,.25/radius*256*terrain.scale*.4,1);
1610 glScalef(1/(1/radius*256*terrain.scale*.4),1/(1/radius*256*terrain.scale*.4),1);
1611 /*float startx,starty,endx,endy;
1613 glTexCoord2f(1-(center.x-radius)/terrain.scale/256,(center.z-radius)/terrain.scale/256);
1614 glVertex3f(-1, -1, 0.0f);
1615 glTexCoord2f(1-(center.x+radius)/terrain.scale/256,(center.z-radius)/terrain.scale/256);
1616 glVertex3f(1, -1, 0.0f);
1617 glTexCoord2f(1-(center.x+radius)/terrain.scale/256,(center.z+radius)/terrain.scale/256);
1618 glVertex3f(1, 1, 0.0f);
1619 glTexCoord2f(1-(center.x-radius)/terrain.scale/256,(center.z+radius)/terrain.scale/256);
1620 glVertex3f(-1, 1, 0.0f);
1623 glRotatef(player[0].lookrotation*-1+180,0,0,1);
1624 glTranslatef(-(center.x/terrain.scale/256*-2+1),(center.z/terrain.scale/256*-2+1),0);
1625 for(i=0;i<objects.numobjects;i++){
1626 if(objects.type[i]==treetrunktype){
1627 distcheck=findDistancefast(&player[0].coords,&objects.position[i]);
1628 if(distcheck<mapviewdist){
1629 glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
1630 glColor4f(0,.3,0,opac*(1-distcheck/mapviewdist));
1632 glTranslatef(objects.position[i].x/terrain.scale/256*-2+1,objects.position[i].z/terrain.scale/256*2-1,0);
1633 glRotatef(objects.rotation[i],0,0,1);
1634 glScalef(.003,.003,.003);
1637 glVertex3f(-1, -1, 0.0f);
1639 glVertex3f(1, -1, 0.0f);
1641 glVertex3f(1, 1, 0.0f);
1643 glVertex3f(-1, 1, 0.0f);
1648 if(objects.type[i]==boxtype){
1649 distcheck=findDistancefast(&player[0].coords,&objects.position[i]);
1650 if(distcheck<mapviewdist){
1651 glBindTexture( GL_TEXTURE_2D, Mapboxtexture);
1652 glColor4f(.4,.4,.4,opac*(1-distcheck/mapviewdist));
1654 glTranslatef(objects.position[i].x/terrain.scale/256*-2+1,objects.position[i].z/terrain.scale/256*2-1,0);
1655 glRotatef(objects.rotation[i],0,0,1);
1656 glScalef(.01*objects.scale[i],.01*objects.scale[i],.01*objects.scale[i]);
1659 glVertex3f(-1, -1, 0.0f);
1661 glVertex3f(1, -1, 0.0f);
1663 glVertex3f(1, 1, 0.0f);
1665 glVertex3f(-1, 1, 0.0f);
1672 glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
1673 for(i=0;i<numboundaries;i++){
1674 glColor4f(0,0,0,opac/3);
1676 glTranslatef(boundary[i].x/terrain.scale/256*-2+1,boundary[i].z/terrain.scale/256*2-1,0);
1677 glScalef(.002,.002,.002);
1680 glVertex3f(-1, -1, 0.0f);
1682 glVertex3f(1, -1, 0.0f);
1684 glVertex3f(1, 1, 0.0f);
1686 glVertex3f(-1, 1, 0.0f);
1691 for(i=0;i<numplayers;i++){
1692 distcheck=findDistancefast(&player[0].coords,&player[i].coords);
1693 if(distcheck<mapviewdist){
1695 glBindTexture( GL_TEXTURE_2D, Maparrowtexture);
1696 if(i==0)glColor4f(1,1,1,opac);
1697 else if(player[i].dead==2||player[i].howactive>typesleeping)glColor4f(0,0,0,opac*(1-distcheck/mapviewdist));
1698 else if(player[i].dead)glColor4f(.3,.3,.3,opac*(1-distcheck/mapviewdist));
1699 else if(player[i].aitype==attacktypecutoff)glColor4f(1,0,0,opac*(1-distcheck/mapviewdist));
1700 else if(player[i].aitype==passivetype)glColor4f(0,1,0,opac*(1-distcheck/mapviewdist));
1701 else glColor4f(1,1,0,1);
1702 glTranslatef(player[i].coords.x/terrain.scale/256*-2+1,player[i].coords.z/terrain.scale/256*2-1,0);
1703 glRotatef(player[i].rotation+180,0,0,1);
1704 glScalef(.005,.005,.005);
1707 glVertex3f(-1, -1, 0.0f);
1709 glVertex3f(1, -1, 0.0f);
1711 glVertex3f(1, 1, 0.0f);
1713 glVertex3f(-1, 1, 0.0f);
1715 /*glBegin(GL_TRIANGLES);
1717 glVertex3f(-1, -1, 0.0f);
1719 glVertex3f(1, -1, 0.0f);
1721 glVertex3f(0, 1, 0.0f);
1726 /*glBegin(GL_QUADS);
1728 glVertex3f(-1, -1, 0.0f);
1730 glVertex3f(1, -1, 0.0f);
1732 glVertex3f(1, 1, 0.0f);
1734 glVertex3f(-1, 1, 0.0f);
1737 glDisable(GL_TEXTURE_2D);
1738 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1739 glPopMatrix(); // Restore The Old Projection Matrix
1740 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1741 glPopMatrix(); // Restore The Old Projection Matrix
1742 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1743 glEnable(GL_CULL_FACE);
1744 glDisable(GL_BLEND);
1750 drawmode=normalmode;
1754 if(loading&&!stealthloading&&(!campaign||player[0].dead)){
1755 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1756 glDisable(GL_CULL_FACE);
1757 glDisable(GL_LIGHTING);
1758 glDisable(GL_TEXTURE_2D);
1760 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1761 glPushMatrix(); // Store The Projection Matrix
1762 glLoadIdentity(); // Reset The Projection Matrix
1763 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1764 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1765 glPushMatrix(); // Store The Modelview Matrix
1766 glLoadIdentity(); // Reset The Modelview Matrix
1767 glScalef(screenwidth,screenheight,1);
1768 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1770 glColor4f(0,0,0,.7);
1772 glVertex3f(0, 0, 0.0f);
1773 glVertex3f(256, 0, 0.0f);
1774 glVertex3f(256, 256, 0.0f);
1775 glVertex3f(0, 256, 0.0f);
1777 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1778 glPopMatrix(); // Restore The Old Projection Matrix
1779 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1780 glPopMatrix(); // Restore The Old Projection Matrix
1781 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1782 glEnable(GL_CULL_FACE);
1783 glDisable(GL_BLEND);
1787 glDisable(GL_DEPTH_TEST);
1788 glColor3f (1.0, 1.0, 1.0); // no coloring
1790 glEnable(GL_TEXTURE_2D);
1791 /*glBindTexture( GL_TEXTURE_2D, logotexture);
1792 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1793 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1794 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1795 glDisable(GL_CULL_FACE);
1796 glDisable(GL_LIGHTING);
1798 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1799 glPushMatrix(); // Store The Projection Matrix
1800 glLoadIdentity(); // Reset The Projection Matrix
1801 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1802 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1803 glPushMatrix(); // Store The Modelview Matrix
1804 glLoadIdentity(); // Reset The Modelview Matrix
1805 glScalef((float)screenwidth/2,(float)screenwidth/2,1);
1806 glTranslatef(1.8,1.25,0);
1807 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1811 glScalef(.25,.25,.25);
1814 glVertex3f(-1, -1, 0.0f);
1816 glVertex3f(1, -1, 0.0f);
1818 glVertex3f(1, 1, 0.0f);
1820 glVertex3f(-1, 1, 0.0f);
1823 glDisable(GL_TEXTURE_2D);
1824 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1825 glPopMatrix(); // Restore The Old Projection Matrix
1826 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1827 glPopMatrix(); // Restore The Old Projection Matrix
1828 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1829 glEnable(GL_CULL_FACE);
1830 glDisable(GL_BLEND);
1836 glEnable(GL_TEXTURE_2D);
1838 sprintf (string, "Loading...");
1839 text.glPrint(1024/2-90,768/2,string,1,2,1024,768);
1842 //if(ismotionblur)drawmode=motionblurmode;
1843 drawmode=normalmode;
1846 if(winfreeze&&!campaign){
1847 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1848 glDisable(GL_CULL_FACE);
1849 glDisable(GL_LIGHTING);
1850 glDisable(GL_TEXTURE_2D);
1852 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1853 glPushMatrix(); // Store The Projection Matrix
1854 glLoadIdentity(); // Reset The Projection Matrix
1855 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1856 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1857 glPushMatrix(); // Store The Modelview Matrix
1858 glLoadIdentity(); // Reset The Modelview Matrix
1859 glScalef(screenwidth,screenheight,1);
1860 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1862 glColor4f(0,0,0,.4);
1864 glVertex3f(0, 0, 0.0f);
1865 glVertex3f(256, 0, 0.0f);
1866 glVertex3f(256, 256, 0.0f);
1867 glVertex3f(0, 256, 0.0f);
1869 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1870 glPopMatrix(); // Restore The Old Projection Matrix
1871 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1872 glPopMatrix(); // Restore The Old Projection Matrix
1873 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1874 glEnable(GL_CULL_FACE);
1875 glDisable(GL_BLEND);
1879 glDisable(GL_DEPTH_TEST);
1880 glColor3f (1.0, 1.0, 1.0); // no coloring
1882 glEnable(GL_TEXTURE_2D);
1883 /*glBindTexture( GL_TEXTURE_2D, logotexture);
1884 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1885 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1886 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1887 glDisable(GL_CULL_FACE);
1888 glDisable(GL_LIGHTING);
1890 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1891 glPushMatrix(); // Store The Projection Matrix
1892 glLoadIdentity(); // Reset The Projection Matrix
1893 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1894 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1895 glPushMatrix(); // Store The Modelview Matrix
1896 glLoadIdentity(); // Reset The Modelview Matrix
1897 glScalef((float)screenwidth/2,(float)screenwidth/2,1);
1898 glTranslatef(1.8,1.25,0);
1899 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1903 glScalef(.25,.25,.25);
1906 glVertex3f(-1, -1, 0.0f);
1908 glVertex3f(1, -1, 0.0f);
1910 glVertex3f(1, 1, 0.0f);
1912 glVertex3f(-1, 1, 0.0f);
1915 glDisable(GL_TEXTURE_2D);
1916 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1917 glPopMatrix(); // Restore The Old Projection Matrix
1918 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1919 glPopMatrix(); // Restore The Old Projection Matrix
1920 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1921 glEnable(GL_CULL_FACE);
1922 glDisable(GL_BLEND);
1930 if(damagetaken==0&&player[0].bloodloss==0){
1931 awards[numawards]=awardflawless;
1937 for(i=1;i<numplayers;i++){
1938 if(player[i].dead!=2)alldead=0;
1941 awards[numawards]=awardalldead;
1946 for(i=1;i<numplayers;i++){
1947 if(player[i].dead!=1)alldead=0;
1950 awards[numawards]=awardnodead;
1953 if(numresponded==0&&!numthrowkill){
1954 awards[numawards]=awardstealth;
1957 if(numattacks==numstaffattack&&numattacks>0){
1958 awards[numawards]=awardbojutsu;
1961 if(numattacks==numswordattack&&numattacks>0){
1962 awards[numawards]=awardswordsman;
1965 if(numattacks==numknifeattack&&numattacks>0){
1966 awards[numawards]=awardknifefighter;
1969 if(numattacks==numunarmedattack&&numthrowkill==0&&weapons.numweapons>0){
1970 awards[numawards]=awardkungfu;
1974 awards[numawards]=awardevasion;
1977 if(numflipfail==0&&numflipped+numwallflipped*2>20){
1978 awards[numawards]=awardacrobat;
1981 if(numthrowkill==numplayers-1){
1982 awards[numawards]=awardlongrange;
1987 for(i=1;i<numplayers;i++){
1988 if(player[i].dead!=2)alldead=0;
1990 if(numafterkill>0&&alldead){
1991 awards[numawards]=awardbrutal;
1994 if(numreversals>((float)numattacks)*.8&&numreversals>3){
1995 awards[numawards]=awardaikido;
1998 if(maxalarmed==1&&numplayers>2){
1999 awards[numawards]=awardstrategy;
2003 awards[numawards]=awardklutz;
2008 //Win Screen Won Victory
2010 glEnable(GL_TEXTURE_2D);
2012 sprintf (string, "Level Cleared!");
2013 text.glPrintOutlined(1024/2-strlen(string)*10,768*7/8,string,1,2,1024,768);
2015 sprintf (string, "Score: %d",(int)(bonustotal-startbonustotal));
2016 text.glPrintOutlined(1024/30,768*6/8,string,1,2,1024,768);
2018 if(!campaign)sprintf (string, "Press Escape to return to menu or Space to continue");
2019 if(campaign)sprintf (string, "Press Escape or Space to continue");
2020 text.glPrintOutlined(640/2-strlen(string)*5,480*1/16,string,1,1,640,480);
2024 for(i=0;i<255;i++)string[i]='\0';
2025 sprintf (temp, "Time: %d:",(int)(((int)leveltime-(int)(leveltime)%60)/60));
2026 strcat(string,temp);
2027 if((int)(leveltime)%60<10)strcat(string,"0");
2028 sprintf (temp, "%d",(int)(leveltime)%60);
2029 strcat(string,temp);
2030 text.glPrintOutlined(1024/30,768*6/8-40,string,1,2,1024,768);
2032 for(i=0;i<numawards;i++){
2034 if(awards[i]==awardklutz)sprintf (string, "Suicidal");
2035 if(awards[i]==awardflawless)sprintf (string, "Flawless!");
2036 if(awards[i]==awardalldead)sprintf (string, "Take no prisoners");
2037 if(awards[i]==awardnodead)sprintf (string, "Merciful");
2038 if(awards[i]==awardstealth)sprintf (string, "One with the shadows!");
2039 if(awards[i]==awardswordsman)sprintf (string, "Swordsman");
2040 if(awards[i]==awardkungfu)sprintf (string, "Unarmed!");
2041 if(awards[i]==awardknifefighter)sprintf (string, "Knife fighter");
2042 if(awards[i]==awardcoward)sprintf (string, "Coward");
2043 if(awards[i]==awardevasion)sprintf (string, "Escape artist");
2044 if(awards[i]==awardacrobat)sprintf (string, "Gymnast");
2045 if(awards[i]==awardlongrange)sprintf (string, "Blade slinger");
2046 if(awards[i]==awardbrutal)sprintf (string, "Brutal");
2047 if(awards[i]==awardhyper)sprintf (string, "Hyper");
2048 if(awards[i]==awardaikido)sprintf (string, "Aikido master!");
2049 if(awards[i]==awardrambo)sprintf (string, "Rambo");
2050 if(awards[i]==awardfast)sprintf (string, "Fast");
2051 if(awards[i]==awardrealfast)sprintf (string, "Real fast");
2052 if(awards[i]==awarddamnfast)sprintf (string, "Damn fast");
2053 if(awards[i]==awardstrategy)sprintf (string, "Divide and conquer");
2054 if(awards[i]==awardbojutsu)sprintf (string, "Bojutsu");
2055 text.glPrintOutlined(1024/30,768*6/8-90-40*i,string,1,2,1024,768);
2059 //drawmode=normalmode;
2062 if(drawmode!=normalmode){
2063 glEnable(GL_TEXTURE_2D);
2065 if(!drawtoggle||drawmode!=realmotionblurmode||(drawtoggle==2||change==1)){
2068 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
2069 GLfloat subtractColor[4] = { 0.5, 0.5, 0.5, 0.0 };
2070 glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, subtractColor);
2071 //glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_SUBTRACT);
2072 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE);
2073 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_CONSTANT_EXT);
2074 glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 2.0f);
2076 glBindTexture( GL_TEXTURE_2D, screentexture);
2077 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
2080 if((drawtoggle||change==1)&&drawmode==realmotionblurmode){
2082 glBindTexture( GL_TEXTURE_2D, screentexture2);
2083 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
2085 if(!screentexture2){
2086 glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
2088 glGenTextures( 1, &screentexture2 );
2089 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
2091 glEnable(GL_TEXTURE_2D);
2092 glBindTexture( GL_TEXTURE_2D, screentexture2);
2093 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
2094 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
2096 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
2102 glClear(GL_DEPTH_BUFFER_BIT);
2103 ReSizeGLScene(90,.1f);
2104 glViewport(0,0,screenwidth,screenheight);
2106 if(drawmode!=normalmode){
2107 glDisable(GL_DEPTH_TEST);
2108 if(drawmode==motionblurmode){
2109 glDrawBuffer(GL_FRONT);
2110 glReadBuffer(GL_BACK);
2111 //myassert(glGetError() == GL_NO_ERROR);
2114 glColor3f (1.0, 1.0, 1.0); // no coloring
2116 glEnable(GL_TEXTURE_2D);
2117 glBindTexture( GL_TEXTURE_2D, screentexture);
2118 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
2119 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
2120 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
2121 glDisable(GL_CULL_FACE);
2122 glDisable(GL_LIGHTING);
2124 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2125 glPushMatrix(); // Store The Projection Matrix
2126 glLoadIdentity(); // Reset The Projection Matrix
2127 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
2128 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2129 glPushMatrix(); // Store The Modelview Matrix
2130 glLoadIdentity(); // Reset The Modelview Matrix
2131 glScalef((float)screenwidth/2,(float)screenheight/2,1);
2132 glTranslatef(1,1,0);
2133 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
2135 if(drawmode==motionblurmode){
2136 if(motionbluramount<.2)motionbluramount=.2;
2137 //glColor4f(1,1,1,fast_sqrt(multiplier)*2.9*motionbluramount);
2138 glColor4f(1,1,1,motionbluramount);
2142 glVertex3f(-1, -1, 0.0f);
2143 glTexCoord2f(texcoordwidth,0);
2144 glVertex3f(1, -1, 0.0f);
2145 glTexCoord2f(texcoordwidth,texcoordheight);
2146 glVertex3f(1, 1, 0.0f);
2147 glTexCoord2f(0,texcoordheight);
2148 glVertex3f(-1, 1, 0.0f);
2152 if(drawmode==realmotionblurmode){
2153 glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
2154 glClear(GL_COLOR_BUFFER_BIT);
2155 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
2156 glBindTexture( GL_TEXTURE_2D, screentexture);
2157 glColor4f(1,1,1,.5);
2161 glVertex3f(-1, -1, 0.0f);
2162 glTexCoord2f(texcoordwidth,0);
2163 glVertex3f(1, -1, 0.0f);
2164 glTexCoord2f(texcoordwidth,texcoordheight);
2165 glVertex3f(1, 1, 0.0f);
2166 glTexCoord2f(0,texcoordheight);
2167 glVertex3f(-1, 1, 0.0f);
2170 glBindTexture( GL_TEXTURE_2D, screentexture2);
2171 glColor4f(1,1,1,.5);
2175 glVertex3f(-1, -1, 0.0f);
2176 glTexCoord2f(texcoordwidth,0);
2177 glVertex3f(1, -1, 0.0f);
2178 glTexCoord2f(texcoordwidth,texcoordheight);
2179 glVertex3f(1, 1, 0.0f);
2180 glTexCoord2f(0,texcoordheight);
2181 glVertex3f(-1, 1, 0.0f);
2184 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
2186 if(drawmode==doublevisionmode){
2187 static float crosseyedness;
2188 crosseyedness=abs(player[0].damage-player[0].superpermanentdamage-(player[0].damagetolerance-player[0].superpermanentdamage)*1/2)/30;
2189 if(crosseyedness>1)crosseyedness=1;
2190 if(crosseyedness<0)crosseyedness=0;
2192 glDisable(GL_BLEND);
2197 glVertex3f(-1, -1, 0.0f);
2198 glTexCoord2f(texcoordwidth,0);
2199 glVertex3f(1, -1, 0.0f);
2200 glTexCoord2f(texcoordwidth,texcoordheight);
2201 glVertex3f(1, 1, 0.0f);
2202 glTexCoord2f(0,texcoordheight);
2203 glVertex3f(-1, 1, 0.0f);
2207 glColor4f(1,1,1,.5);
2210 glTranslatef(.015*crosseyedness,0,0);
2214 glVertex3f(-1, -1, 0.0f);
2215 glTexCoord2f(texcoordwidth,0);
2216 glVertex3f(1, -1, 0.0f);
2217 glTexCoord2f(texcoordwidth,texcoordheight);
2218 glVertex3f(1, 1, 0.0f);
2219 glTexCoord2f(0,texcoordheight);
2220 glVertex3f(-1, 1, 0.0f);
2225 if(drawmode==glowmode){
2226 glColor4f(.5,.5,.5,.5);
2228 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
2230 glTranslatef(.01,0,0);
2233 glVertex3f(-1, -1, 0.0f);
2234 glTexCoord2f(texcoordwidth,0);
2235 glVertex3f(1, -1, 0.0f);
2236 glTexCoord2f(texcoordwidth,texcoordheight);
2237 glVertex3f(1, 1, 0.0f);
2238 glTexCoord2f(0,texcoordheight);
2239 glVertex3f(-1, 1, 0.0f);
2243 glTranslatef(-.01,0,0);
2246 glVertex3f(-1, -1, 0.0f);
2247 glTexCoord2f(texcoordwidth,0);
2248 glVertex3f(1, -1, 0.0f);
2249 glTexCoord2f(texcoordwidth,texcoordheight);
2250 glVertex3f(1, 1, 0.0f);
2251 glTexCoord2f(0,texcoordheight);
2252 glVertex3f(-1, 1, 0.0f);
2256 glTranslatef(.0,.01,0);
2259 glVertex3f(-1, -1, 0.0f);
2260 glTexCoord2f(texcoordwidth,0);
2261 glVertex3f(1, -1, 0.0f);
2262 glTexCoord2f(texcoordwidth,texcoordheight);
2263 glVertex3f(1, 1, 0.0f);
2264 glTexCoord2f(0,texcoordheight);
2265 glVertex3f(-1, 1, 0.0f);
2269 glTranslatef(0,-.01,0);
2272 glVertex3f(-1, -1, 0.0f);
2273 glTexCoord2f(texcoordwidth,0);
2274 glVertex3f(1, -1, 0.0f);
2275 glTexCoord2f(texcoordwidth,texcoordheight);
2276 glVertex3f(1, 1, 0.0f);
2277 glTexCoord2f(0,texcoordheight);
2278 glVertex3f(-1, 1, 0.0f);
2282 if(drawmode==radialzoommode){
2284 //glRotatef((float)i*.1,0,0,1);
2285 glColor4f(1,1,1,1/((float)i+1));
2287 glScalef(1+(float)i*.01,1+(float)i*.01,1);
2290 glVertex3f(-1, -1, 0.0f);
2291 glTexCoord2f(texcoordwidth,0);
2292 glVertex3f(1, -1, 0.0f);
2293 glTexCoord2f(texcoordwidth,texcoordheight);
2294 glVertex3f(1, 1, 0.0f);
2295 glTexCoord2f(0,texcoordheight);
2296 glVertex3f(-1, 1, 0.0f);
2301 glDisable(GL_TEXTURE_2D);
2302 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2303 glPopMatrix(); // Restore The Old Projection Matrix
2304 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2305 glPopMatrix(); // Restore The Old Projection Matrix
2306 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
2307 glEnable(GL_CULL_FACE);
2308 glDisable(GL_BLEND);
2313 glEnable(GL_TEXTURE_2D);
2318 if(consoleselected>=60)offset=consoleselected-60;
2319 sprintf (string, " ]");
2320 text.glPrint(10,30,string,0,1,1024,768);
2322 sprintf (string, "_");
2323 text.glPrint(30+(float)(consoleselected)*10-offset*10,30,string,0,1,1024,768);
2326 for(j=0;j<consolechars[i];j++){
2327 glColor4f(1,1,1,1-(float)(i)/16);
2328 if(j<consolechars[i]){
2329 sprintf (string, "%c",consoletext[i][j]);
2330 text.glPrint(30+j*10-offset*10,30+i*20,string,0,1,1024,768);
2338 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)||(mainmenu&&gameon)||(!gameon&&gamestarted)||(!gameon&&gamestarted)){
2339 multiplier=tempmult;
2344 // !!! FIXME: hack: clamp framerate in menu so text input works correctly on fast systems.
2347 glDrawBuffer(GL_BACK);
2348 glReadBuffer(GL_BACK);
2349 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
2350 ReSizeGLScene(90,.1f);
2353 temptexdetail=texdetail;
2354 if(texdetail>2)texdetail=2;
2355 if(mainmenu!=oldmainmenu&&oldmainmenu!=0){
2357 LoadTexture(":Data:Textures:Newgame.png",&Mainmenuitems[1],0,0);
2358 LoadTexture(":Data:Textures:Quit.png",&Mainmenuitems[3],0,0);
2359 /*if(oldmainmenu==1||oldmainmenu==0){
2360 LoadTexture(":Data:Textures:World.png",&Mainmenuitems[7],0,0);
2361 LoadTexture(":Data:Textures:Options.png",&Mainmenuitems[2],0,0);
2362 LoadTexture(":Data:Textures:Lugaru.png",&Mainmenuitems[0],0,0);
2367 LoadTexture(":Data:Textures:Resume.png",&Mainmenuitems[1],0,0);
2368 LoadTexture(":Data:Textures:Endgame.png",&Mainmenuitems[3],0,0);
2369 /*if(oldmainmenu==2||oldmainmenu==0){
2370 LoadTexture(":Data:Textures:World.png",&Mainmenuitems[7],0,0);
2371 LoadTexture(":Data:Textures:Options.png",&Mainmenuitems[2],0,0);
2372 LoadTexture(":Data:Textures:Lugaru.png",&Mainmenuitems[0],0,0);
2377 if(lastcheck>.5||oldmainmenu!=mainmenu){
2379 ifstream ipstream(ConvertFileName(":Data:Campaigns:main.txt"));
2380 //campaignnumlevels=0;
2381 //accountcampaignchoicesmade[accountactive]=0;
2382 ipstream.ignore(256,':');
2383 ipstream >> campaignnumlevels;
2384 for(i=0;i<campaignnumlevels;i++){
2385 ipstream.ignore(256,':');
2386 ipstream.ignore(256,':');
2387 ipstream.ignore(256,' ');
2388 ipstream >> campaignmapname[i];
2389 ipstream.ignore(256,':');
2390 ipstream >> campaigndescription[i];
2392 if(campaigndescription[i][j]=='_')campaigndescription[i][j]=' ';
2394 ipstream.ignore(256,':');
2395 ipstream >> campaignchoosenext[i];
2396 ipstream.ignore(256,':');
2397 ipstream >> campaignnumnext[i];
2398 if(campaignnumnext[i])
2399 for(j=0;j<campaignnumnext[i];j++){
2400 ipstream.ignore(256,':');
2401 ipstream >> campaignnextlevel[i][j];
2402 campaignnextlevel[i][j]-=1;
2404 ipstream.ignore(256,':');
2405 ipstream >> campaignlocationx[i];
2406 //campaignlocationx[i]-=30;
2407 ipstream.ignore(256,':');
2408 ipstream >> campaignlocationy[i];
2409 //campaignlocationy[i]+=30;
2413 for(i=0;i<campaignnumlevels;i++){
2415 levelhighlight[i]=0;
2420 if(accountcampaignchoicesmade[accountactive])
2421 for(i=0;i<accountcampaignchoicesmade[accountactive];i++){
2422 levelorder[i+1]=campaignnextlevel[levelorder[i]][accountcampaignchoices[accountactive][i]];
2423 levelvisible[levelorder[i+1]]=1;
2425 int whichlevelstart;
2426 whichlevelstart=accountcampaignchoicesmade[accountactive]-1;
2427 if(whichlevelstart<0){
2428 accountcampaignscore[accountactive]=0;
2429 accountcampaignfasttime[accountactive]=0;
2430 campaignchoicenum=1;
2431 campaignchoicewhich[0]=0;
2435 campaignchoicenum=campaignnumnext[levelorder[whichlevelstart]];
2436 if(campaignchoicenum==0){
2437 if(accountcampaignscore[accountactive]>accountcampaignhighscore[accountactive])accountcampaignhighscore[accountactive]=accountcampaignscore[accountactive];
2438 if(accountcampaignfasttime[accountactive]==0||accountcampaigntime[accountactive]<accountcampaignfasttime[accountactive])accountcampaignfasttime[accountactive]=accountcampaigntime[accountactive];
2440 if(campaignchoicenum)
2441 for(i=0;i<campaignchoicenum;i++){
2442 campaignchoicewhich[i]=campaignnextlevel[levelorder[whichlevelstart]][i];
2443 levelvisible[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
2444 levelhighlight[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
2457 texdetail=temptexdetail;
2459 /*if(mainmenu!=0)*/oldmainmenu=mainmenu;
2461 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){
2462 glClear(GL_DEPTH_BUFFER_BIT);
2463 glEnable(GL_ALPHA_TEST);
2464 glAlphaFunc(GL_GREATER, 0.001f);
2465 glEnable(GL_TEXTURE_2D);
2466 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
2467 glDisable(GL_CULL_FACE);
2468 glDisable(GL_LIGHTING);
2470 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2471 glPushMatrix(); // Store The Projection Matrix
2472 glLoadIdentity(); // Reset The Projection Matrix
2473 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
2474 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2475 glPushMatrix(); // Store The Modelview Matrix
2476 glLoadIdentity(); // Reset The Modelview Matrix
2477 glTranslatef(screenwidth/2,screenheight/2,0);
2479 glScalef((float)screenwidth/2,(float)screenheight/2,1);
2480 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
2481 glDisable(GL_BLEND);
2482 glColor4f(0,0,0,1.0);
2483 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2484 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2485 glDisable(GL_TEXTURE_2D);
2487 //glScalef(.25,.25,.25);
2490 glVertex3f(-1, -1, 0.0f);
2492 glVertex3f(1, -1, 0.0f);
2494 glVertex3f(1, 1, 0.0f);
2496 glVertex3f(-1, 1, 0.0f);
2500 glColor4f(0.4,0.4,0.4,1.0);
2501 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2502 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2503 glEnable(GL_TEXTURE_2D);
2504 glBindTexture( GL_TEXTURE_2D, Mainmenuitems[4]);
2506 //glScalef(.25,.25,.25);
2509 glVertex3f(-1, -1, 0.0f);
2511 glVertex3f(1, -1, 0.0f);
2513 glVertex3f(1, 1, 0.0f);
2515 glVertex3f(-1, 1, 0.0f);
2520 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2522 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2526 if((float)newscreenwidth>(float)newscreenheight*1.61||(float)newscreenwidth<(float)newscreenheight*1.59)sprintf (menustring[0], "Resolution: %d*%d",(int)newscreenwidth,(int)newscreenheight);
2527 else sprintf (menustring[0], "Resolution: %d*%d (widescreen)",(int)newscreenwidth,(int)newscreenheight);
2530 endx[0]=startx[0]+strlen(menustring[0])*10;
2531 endy[0]=starty[0]+20;
2535 if(newdetail==2)sprintf (menustring[1], "Detail: High");
2536 else if(newdetail==1)sprintf (menustring[1], "Detail: Medium");
2537 else sprintf (menustring[1], "Detail: Low");
2540 endx[1]=startx[1]+strlen(menustring[1])*10;
2541 endy[1]=starty[1]+20;
2545 if(bloodtoggle==2)sprintf (menustring[2], "Blood: On, high detail (slower)");
2546 if(bloodtoggle==1)sprintf (menustring[2], "Blood: On, low detail");
2547 if(bloodtoggle==0)sprintf (menustring[2], "Blood: Off");
2550 endx[2]=startx[2]+strlen(menustring[2])*10;
2551 endy[2]=starty[2]+20;
2555 if(difficulty==2)sprintf (menustring[3], "Difficulty: Insane");
2556 if(difficulty==1)sprintf (menustring[3], "Difficulty: Difficult");
2557 if(difficulty==0)sprintf (menustring[3], "Difficulty: Easier");
2558 startx[3]=10+20-1000;
2560 endx[3]=startx[3]+strlen(menustring[3])*10;
2561 endy[3]=starty[3]+20;
2565 if(ismotionblur==1)sprintf (menustring[4], "Blur Effects: Enabled (less compatible)");
2566 if(ismotionblur==0)sprintf (menustring[4], "Blur Effects: Disabled (more compatible)");
2569 endx[4]=startx[4]+strlen(menustring[4])*10;
2570 endy[4]=starty[4]+20;
2574 if(decals==1)sprintf (menustring[5], "Decals: Enabled (slower)");
2575 if(decals==0)sprintf (menustring[5], "Decals: Disabled");
2578 endx[5]=startx[5]+strlen(menustring[5])*10;
2579 endy[5]=starty[5]+20;
2583 if(musictoggle==1)sprintf (menustring[6], "Music: Enabled");
2584 if(musictoggle==0)sprintf (menustring[6], "Music: Disabled");
2587 endx[6]=startx[6]+strlen(menustring[6])*10;
2588 endy[6]=starty[6]+20;
2592 if(invertmouse==1)sprintf (menustring[9], "Invert mouse: Yes");
2593 if(invertmouse==0)sprintf (menustring[9], "Invert mouse: No");
2596 endx[9]=startx[9]+strlen(menustring[9])*10;
2597 endy[9]=starty[9]+20;
2601 sprintf (menustring[10], "Mouse Speed: %d", (int)(usermousesensitivity*5));
2604 endx[10]=startx[10]+strlen(menustring[10])*10;
2605 endy[10]=starty[10]+20;
2609 sprintf (menustring[11], "Volume: %d%%", (int)(volume*100));
2612 endx[11]=startx[11]+strlen(menustring[11])*10;
2613 endy[11]=starty[11]+20;
2617 sprintf (menustring[13], "Damage Bar: %s",(showdamagebar?"on":"off"));
2620 endx[13]=startx[13]+strlen(menustring[13])*10;
2621 endy[13]=starty[13]+20;
2625 sprintf (menustring[7], "-Configure Controls-");
2628 endx[7]=startx[7]+strlen(menustring[7])*10;
2629 endy[7]=starty[7]+20;
2633 sprintf (menustring[12], "-Configure Stereo -");
2636 endx[12]=startx[12]+strlen(menustring[7])*10;
2637 endy[12]=starty[12]+20;
2641 if(newdetail==detail&&newscreenheight==(int)screenheight&&newscreenwidth==(int)screenwidth)sprintf (menustring[8], "Back");
2642 else sprintf (menustring[8], "Back (some changes take effect next time Lugaru is opened)");
2644 endx[8]=startx[8]+strlen(menustring[8])*10;
2646 endy[8]=starty[8]+20;
2653 if(keyselect!=0)sprintf (menustring[0], "Forwards: %s",KeyToChar(forwardkey));
2654 else sprintf (menustring[0], "Forwards: _");
2657 endx[0]=startx[0]+strlen(menustring[0])*10;
2658 endy[0]=starty[0]+20;
2662 if(keyselect!=1)sprintf (menustring[1], "Back: %s",KeyToChar(backkey));
2663 else sprintf (menustring[1], "Back: _");
2666 endx[1]=startx[1]+strlen(menustring[1])*10;
2667 endy[1]=starty[1]+20;
2671 if(keyselect!=2)sprintf (menustring[2], "Left: %s",KeyToChar(leftkey));
2672 else sprintf (menustring[2], "Left: _");
2675 endx[2]=startx[2]+strlen(menustring[2])*10;
2676 endy[2]=starty[2]+20;
2680 if(keyselect!=3)sprintf (menustring[3], "Right: %s",KeyToChar(rightkey));
2681 else sprintf (menustring[3], "Right: _");
2684 endx[3]=startx[3]+strlen(menustring[3])*10;
2685 endy[3]=starty[3]+20;
2689 if(keyselect!=4)sprintf (menustring[4], "Crouch: %s",KeyToChar(crouchkey));
2690 else sprintf (menustring[4], "Crouch: _");
2693 endx[4]=startx[4]+strlen(menustring[4])*10;
2694 endy[4]=starty[4]+20;
2698 if(keyselect!=5)sprintf (menustring[5], "Jump: %s",KeyToChar(jumpkey));
2699 else sprintf (menustring[5], "Jump: _");
2702 endx[5]=startx[5]+strlen(menustring[5])*10;
2703 endy[5]=starty[5]+20;
2707 if(keyselect!=6)sprintf (menustring[6], "Draw: %s",KeyToChar(drawkey));
2708 else sprintf (menustring[6], "Draw: _");
2711 endx[6]=startx[6]+strlen(menustring[6])*10;
2712 endy[6]=starty[6]+20;
2716 if(keyselect!=7)sprintf (menustring[7], "Throw: %s",KeyToChar(throwkey));
2717 else sprintf (menustring[7], "Throw: _");
2720 endx[7]=startx[7]+strlen(menustring[7])*10;
2721 endy[7]=starty[7]+20;
2725 if(keyselect!=8)sprintf (menustring[8], "Attack: %s",KeyToChar(attackkey));
2726 else sprintf (menustring[8], "Attack: _");
2729 endx[8]=startx[8]+strlen(menustring[8])*10;
2730 endy[8]=starty[8]+20;
2736 sprintf (menustring[9], "Back");
2738 endx[9]=startx[9]+strlen(menustring[9])*10;
2740 endy[9]=starty[9]+20;
2745 nummenuitems=7+accountcampaignchoicesmade[accountactive]+campaignchoicenum;
2747 sprintf (menustring[0], "%s",accountname[accountactive]);
2750 endx[0]=startx[0]+strlen(menustring[0])*10;
2751 endy[0]=starty[0]+20;
2755 sprintf (menustring[1], "Tutorial");
2758 endx[1]=startx[1]+strlen(menustring[1])*10;
2759 endy[1]=starty[1]+20;
2763 sprintf (menustring[2], "Challenge");
2766 endx[2]=startx[2]+strlen(menustring[2])*10;
2767 endy[2]=starty[2]+20;
2771 sprintf (menustring[3], "Delete User");
2774 endx[3]=startx[3]+strlen(menustring[3])*10;
2775 endy[3]=starty[3]+20;
2779 sprintf (menustring[4], "Main Menu");
2782 endx[4]=startx[4]+strlen(menustring[4])*10;
2783 endy[4]=starty[4]+20;
2787 sprintf (menustring[5], "Change User");
2789 endx[5]=startx[5]+strlen(menustring[5])*10;
2791 endy[5]=starty[5]+20;
2797 sprintf (menustring[6], "World");
2799 starty[6]=30+480-400-50;
2800 endx[6]=startx[6]+400;
2805 if(accountcampaignchoicesmade[accountactive])
2806 for(i=0;i<accountcampaignchoicesmade[accountactive];i++){
2807 sprintf (menustring[7+i], "%s", campaigndescription[levelorder[i]]);
2808 startx[7+i]=30+120+campaignlocationx[levelorder[i]]*400/512;
2809 starty[7+i]=30+30+(512-campaignlocationy[levelorder[i]])*400/512;
2810 endx[7+i]=startx[7+i]+10;
2811 endy[7+i]=starty[7+i]+10;
2816 if(campaignchoicenum>0)
2817 for(i=accountcampaignchoicesmade[accountactive];i<accountcampaignchoicesmade[accountactive]+campaignchoicenum;i++){
2818 sprintf (menustring[7+i], "%s", campaigndescription[levelorder[i]]);
2819 startx[7+i]=30+120+campaignlocationx[campaignchoicewhich[i-(accountcampaignchoicesmade[accountactive])]]*400/512;
2820 starty[7+i]=30+30+(512-campaignlocationy[campaignchoicewhich[i-(accountcampaignchoicesmade[accountactive])]])*400/512;
2821 endx[7+i]=startx[7+i]+10;
2822 endy[7+i]=starty[7+i]+10;
2827 /*sprintf (menustring[7], "Dot");
2828 startx[7]=120+260*400/512;
2829 starty[7]=30+(512-184)*400/512;
2830 endx[7]=startx[7]+10;
2831 endy[7]=starty[7]+10;
2835 sprintf (menustring[8], "Dot");
2836 startx[8]=120+129*400/512;
2837 starty[8]=30+(512-284)*400/512;
2838 endx[8]=startx[8]+10;
2839 endy[8]=starty[8]+10;
2843 sprintf (menustring[9], "Dot");
2844 startx[9]=120+358*400/512;
2845 starty[9]=30+(512-235)*400/512;
2846 endx[9]=startx[9]+10;
2847 endy[9]=starty[9]+10;
2851 sprintf (menustring[10], "Dot");
2852 startx[10]=120+359*400/512;
2853 starty[10]=30+(512-308)*400/512;
2854 endx[10]=startx[10]+10;
2855 endy[10]=starty[10]+10;
2859 sprintf (menustring[11], "Dot");
2860 startx[11]=120+288*400/512;
2861 starty[11]=30+(512-277)*400/512;
2862 endx[11]=startx[11]+10;
2863 endy[11]=starty[11]+10;
2871 sprintf (menustring[0], "Are you sure you want to delete this user?");
2874 endx[0]=startx[0]+strlen(menustring[0])*10;
2875 endy[0]=starty[0]+20;
2879 sprintf (menustring[1], "Yes");
2882 endx[1]=startx[1]+strlen(menustring[1])*10;
2883 endy[1]=starty[1]+20;
2887 sprintf (menustring[2], "No");
2890 endx[2]=startx[2]+strlen(menustring[2])*10;
2891 endy[2]=starty[2]+20;
2895 sprintf (menustring[3], "Extra 4");
2898 endx[3]=startx[3]+strlen(menustring[3])*10;
2899 endy[3]=starty[3]+20;
2903 sprintf (menustring[4], "Extra 5");
2906 endx[4]=startx[4]+strlen(menustring[4])*10;
2907 endy[4]=starty[4]+20;
2911 sprintf (menustring[5], "Back");
2913 endx[5]=startx[5]+strlen(menustring[5])*10;
2915 endy[5]=starty[5]+20;
2921 nummenuitems=numaccounts+2;
2926 sprintf (menustring[0], "New User");
2928 sprintf (menustring[0], "No More Users");
2931 endx[0]=startx[0]+strlen(menustring[0])*10;
2932 endy[0]=starty[0]+20;
2936 if(entername)startx[0]+=10;
2941 for(i=0;i<numaccounts;i++){
2942 sprintf (menustring[num], "%s",accountname[i]);
2944 starty[num]=360-20-20*num;
2945 endx[num]=startx[num]+strlen(menustring[num])*10;
2946 endy[num]=starty[num]+20;
2953 sprintf (menustring[num], "Back");
2955 endx[num]=startx[num]+strlen(menustring[num])*10;
2957 endy[num]=starty[num]+20;
2964 sprintf (menustring[0], "Easier");
2967 endx[0]=startx[0]+strlen(menustring[0])*10;
2968 endy[0]=starty[0]+20;
2972 sprintf (menustring[1], "Difficult");
2975 endx[1]=startx[1]+strlen(menustring[1])*10;
2976 endy[1]=starty[1]+20;
2980 sprintf (menustring[2], "Insane");
2983 endx[2]=startx[2]+strlen(menustring[2])*10;
2984 endy[2]=starty[2]+20;
2990 //tempncl=numchallengelevels;
2991 //numchallengelevels=9;
2992 nummenuitems=2+numchallengelevels;
2995 for(j=0;j<numchallengelevels;j++){
2996 for(i=0;i<255;i++)menustring[j][i]='\0';
2997 sprintf (temp, "Level %d",j+1);
2998 strcpy(menustring[j],temp);
2999 for(i=0;i<17;i++)if(menustring[j][i]=='\0')menustring[j][i]=' ';
3000 menustring[j][17]='\0';
3001 sprintf (temp, "%d",(int)accounthighscore[accountactive][j]);
3002 strcat(menustring[j],temp);
3003 for(i=18;i<32;i++)if(menustring[j][i]=='\0')menustring[j][i]=' ';
3004 menustring[j][32]='\0';
3005 sprintf (temp, "%d:",(int)(((int)accountfasttime[accountactive][j]-(int)(accountfasttime[accountactive][j])%60)/60));
3006 strcat(menustring[j],temp);
3007 if((int)(accountfasttime[accountactive][j])%60<10)strcat(menustring[j],"0");
3008 sprintf (temp, "%d",(int)(accountfasttime[accountactive][j])%60);
3009 strcat(menustring[j],temp);
3013 endx[j]=startx[j]+strlen(menustring[j])*10;
3014 endy[j]=starty[j]+20;
3019 sprintf (menustring[numchallengelevels], "Back");
3020 startx[numchallengelevels]=10;
3021 endx[numchallengelevels]=startx[numchallengelevels]+strlen(menustring[numchallengelevels])*10;
3022 starty[numchallengelevels]=10;
3023 endy[numchallengelevels]=starty[numchallengelevels]+20;
3024 movex[numchallengelevels]=0;
3025 movey[numchallengelevels]=0;
3027 sprintf (menustring[numchallengelevels+1], " High Score Best Time");
3028 startx[numchallengelevels+1]=10;
3029 starty[numchallengelevels+1]=440;
3030 endx[numchallengelevels+1]=startx[numchallengelevels+1]+strlen(menustring[numchallengelevels+1])*10;
3031 endy[numchallengelevels+1]=starty[numchallengelevels+1]+20;
3032 movex[numchallengelevels+1]=0;
3033 movey[numchallengelevels+1]=0;
3035 //numchallengelevels=tempncl;
3039 nummenuitems=2+numchallengelevels;
3042 for(j=0;j<numchallengelevels;j++){
3043 for(i=0;i<255;i++)menustring[j][i]='\0';
3044 sprintf (temp, "Level %d",j+1);
3045 strcpy(menustring[j],temp);
3046 for(i=0;i<17;i++)if(menustring[j][i]=='\0')menustring[j][i]=' ';
3047 menustring[j][17]='\0';
3048 sprintf (temp, "%d",(int)accounthighscore[accountactive][j]);
3049 strcat(menustring[j],temp);
3050 for(i=18;i<32;i++)if(menustring[j][i]=='\0')menustring[j][i]=' ';
3051 menustring[j][32]='\0';
3052 sprintf (temp, "%d:",(int)(((int)accountfasttime[accountactive][j]-(int)(accountfasttime[accountactive][j])%60)/60));
3053 strcat(menustring[j],temp);
3054 if((int)(accountfasttime[accountactive][j])%60<10)strcat(menustring[j],"0");
3055 sprintf (temp, "%d",(int)(accountfasttime[accountactive][j])%60);
3056 strcat(menustring[j],temp);
3060 endx[j]=startx[j]+strlen(menustring[j])*10;
3061 endy[j]=starty[j]+20;
3066 sprintf (menustring[numchallengelevels], "Back");
3067 startx[numchallengelevels]=10;
3068 endx[numchallengelevels]=startx[numchallengelevels]+strlen(menustring[numchallengelevels])*10;
3069 starty[numchallengelevels]=10;
3070 endy[numchallengelevels]=starty[numchallengelevels]+20;
3071 movex[numchallengelevels]=0;
3072 movey[numchallengelevels]=0;
3074 sprintf (menustring[numchallengelevels+1], " High Score Best Time");
3075 startx[numchallengelevels+1]=10;
3076 starty[numchallengelevels+1]=400;
3077 endx[numchallengelevels+1]=startx[numchallengelevels+1]+strlen(menustring[numchallengelevels+1])*10;
3078 endy[numchallengelevels+1]=starty[numchallengelevels+1]+20;
3079 movex[numchallengelevels+1]=0;
3080 movey[numchallengelevels+1]=0;
3087 sprintf (menustring[0], "Congratulations!");
3090 endx[0]=startx[0]+strlen(menustring[0])*10;
3091 endy[0]=starty[0]+20;
3095 sprintf (menustring[1], "You have avenged your family and");
3098 endx[1]=startx[1]+strlen(menustring[1])*10;
3099 endy[1]=starty[1]+20;
3103 sprintf (menustring[2], "restored peace to the island of Lugaru.");
3106 endx[2]=startx[2]+strlen(menustring[2])*10;
3107 endy[2]=starty[2]+20;
3111 sprintf (menustring[3], "Back");
3113 endx[3]=startx[3]+strlen(menustring[3])*10;
3115 endy[3]=starty[3]+20;
3119 for(i=0;i<255;i++)menustring[4][i]='\0';
3120 sprintf (temp, "Your score:");
3121 strcpy(menustring[4],temp);
3122 for(i=0;i<20;i++)if(menustring[4][i]=='\0')menustring[4][i]=' ';
3123 menustring[4][20]='\0';
3124 sprintf (temp, "%d",(int)accountcampaignscore[accountactive]);
3125 strcat(menustring[4],temp);
3127 endx[4]=startx[4]+strlen(menustring[4])*10;
3129 endy[4]=starty[4]+20;
3133 for(i=0;i<255;i++)menustring[5][i]='\0';
3134 sprintf (temp, "Your time:");
3135 strcpy(menustring[5],temp);
3136 for(i=0;i<20;i++)if(menustring[5][i]=='\0')menustring[5][i]=' ';
3137 menustring[5][20]='\0';
3138 sprintf (temp, "%d",(int)accountcampaigntime[accountactive]);
3139 strcat(menustring[5],temp);
3141 endx[5]=startx[5]+strlen(menustring[5])*10;
3143 endy[5]=starty[5]+20;
3147 for(i=0;i<255;i++)menustring[5][i]='\0';
3148 sprintf (temp, "Highest score:");
3149 strcpy(menustring[5],temp);
3150 for(i=0;i<20;i++)if(menustring[5][i]=='\0')menustring[5][i]=' ';
3151 menustring[5][20]='\0';
3152 sprintf (temp, "%d",(int)accountcampaignhighscore[accountactive]);
3153 strcat(menustring[5],temp);
3155 endx[5]=startx[5]+strlen(menustring[5])*10;
3157 endy[5]=starty[5]+20;
3161 for(i=0;i<255;i++)menustring[7][i]='\0';
3162 sprintf (temp, "Lowest time:");
3163 strcpy(menustring[7],temp);
3164 for(i=0;i<20;i++)if(menustring[7][i]=='\0')menustring[7][i]=' ';
3165 menustring[7][20]='\0';
3166 sprintf (temp, "%d",(int)accountcampaignfasttime[accountactive]);
3167 strcat(menustring[7],temp);
3169 endx[7]=startx[7]+strlen(menustring[7])*10;
3171 endy[7]=starty[7]+20;
3177 sprintf (menustring[0], "Stereo mode: %s", StereoModeName(newstereomode));
3180 endx[0]=startx[0]+strlen(menustring[0])*10;
3181 endy[0]=starty[0]+20;
3185 sprintf (menustring[1], "Stereo separation: %.3f", stereoseparation);
3188 endx[1]=startx[1]+strlen(menustring[1])*10;
3189 endy[1]=starty[1]+20;
3193 sprintf (menustring[2], "Reverse stereo: %s", stereoreverse ? "Yes" : "No");
3196 endx[2]=startx[2]+strlen(menustring[2])*10;
3197 endy[2]=starty[2]+20;
3201 sprintf (menustring[3], "Back");
3203 endx[3]=startx[3]+strlen(menustring[3])*10;
3205 endy[3]=starty[3]+20;
3215 sprintf (menustring[0], "Please enter your name:");
3218 endx[0]=startx[0]+strlen(menustring[0])*10;
3219 endy[0]=starty[0]+20;
3223 sprintf (menustring[1], "Please enter your name:");
3226 endx[1]=startx[1]+strlen(menustring[1])*10;
3227 endy[1]=starty[1]+20;
3231 if(mainmenu==1||mainmenu==2){
3241 starty[1]=480-152-32;
3248 starty[2]=480-228-32;
3256 starty[3]=480-306-32;
3265 starty[3]=480-306-32;
3279 starty[4]=480-140-256;
3286 starty[5]=480-138-256;
3293 starty[6]=480-144-256;
3301 starty[4]=480-140-256;
3308 starty[5]=480-138-256;
3315 starty[6]=480-144-256;
3323 starty[4]=480-140-256;
3330 starty[5]=480-150-256;
3337 starty[6]=480-144-256;
3345 starty[4]=480-140-256;
3352 starty[5]=480-150-256;
3359 starty[6]=480-144-256;
3367 starty[4]=480-100-256;
3374 starty[5]=480-120-256;
3381 starty[6]=480-144-256;
3391 if(mainmenu==1||mainmenu==2)
3393 if((mousecoordh/screenwidth*640)>startx[i]&&(mousecoordh/screenwidth*640)<endx[i]&&480-(mousecoordv/screenheight*480)>starty[i]&&480-(mousecoordv/screenheight*480)<endy[i]){
3398 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)
3399 for(i=0;i<nummenuitems;i++){
3400 if((mousecoordh/screenwidth*640)>startx[i]&&(mousecoordh/screenwidth*640)<endx[i]&&480-(mousecoordv/screenheight*480)>starty[i]&&480-(mousecoordv/screenheight*480)<endy[i]){
3401 if(mainmenu!=5)selected=i;
3402 if(mainmenu==5&&(i!=0&&i!=6))selected=i;
3403 if(mainmenu==9&&(i!=numchallengelevels+1))selected=i;
3404 if(mainmenu==11&&(i!=numchallengelevels+1))selected=i;
3409 for(i=0;i<nummenuitems;i++){
3410 if(selected==i)selectedlong[i]+=multiplier*5;
3411 if(selectedlong[i]>1)selectedlong[i]=1;
3412 if(selected!=i)selectedlong[i]-=multiplier*5;
3413 if(selectedlong[i]<0)selectedlong[i]=0;
3414 //if(i>=4)selectedlong[i]=.3;
3415 if(i>=4&&(mainmenu==1||mainmenu==2))selectedlong[i]=0;
3419 for(i=0;i<nummenuitems;i++){
3420 offsetx[i]=(startx[i]+endx[i])/2-(mousecoordh/screenwidth*640);
3421 offsety[i]=(starty[i]+endy[i])/2-(480-(mousecoordv/screenheight*480));
3426 if(i>=4&&(mainmenu==1||mainmenu==2)){
3427 offsetx[i]=(startx[i]+endx[i]+movex[i]*transition)/2-(640+190)/2;
3428 offsety[i]=(starty[i]+endy[i]+movey[i]*transition)/2-(336+150)/2;
3434 if(mainmenu==1||mainmenu==2){
3435 glClear(GL_DEPTH_BUFFER_BIT);
3436 glEnable(GL_ALPHA_TEST);
3437 glAlphaFunc(GL_GREATER, 0.001f);
3438 glEnable(GL_TEXTURE_2D);
3439 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3440 glDisable(GL_CULL_FACE);
3441 glDisable(GL_LIGHTING);
3443 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3444 glPushMatrix(); // Store The Projection Matrix
3445 glLoadIdentity(); // Reset The Projection Matrix
3446 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
3447 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3448 glPushMatrix(); // Store The Modelview Matrix
3449 glLoadIdentity(); // Reset The Modelview Matrix
3450 glTranslatef(screenwidth/2,screenheight/2,0);
3452 glScalef((float)screenwidth/2,(float)screenheight/2,1);
3453 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3454 glDisable(GL_BLEND);
3455 glColor4f(0,0,0,1.0);
3456 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
3457 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
3458 glDisable(GL_TEXTURE_2D);
3460 //glScalef(.25,.25,.25);
3463 glVertex3f(-1, -1, 0.0f);
3465 glVertex3f(1, -1, 0.0f);
3467 glVertex3f(1, 1, 0.0f);
3469 glVertex3f(-1, 1, 0.0f);
3473 glColor4f(0.4,0.4,0.4,1.0);
3474 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
3475 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
3476 glEnable(GL_TEXTURE_2D);
3477 glBindTexture( GL_TEXTURE_2D, Mainmenuitems[4]);
3479 //glScalef(.25,.25,.25);
3482 glVertex3f(-1, -1, 0.0f);
3484 glVertex3f(1, -1, 0.0f);
3486 glVertex3f(1, 1, 0.0f);
3488 glVertex3f(-1, 1, 0.0f);
3493 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3496 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3497 glPushMatrix(); // Store The Projection Matrix
3498 glLoadIdentity(); // Reset The Projection Matrix
3499 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3500 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3501 glPushMatrix(); // Store The Modelview Matrix
3502 glLoadIdentity(); // Reset The Modelview Matrix
3504 glDisable(GL_TEXTURE_2D);
3509 if(anim!=1)glVertex3f(190, 150, 0.0f);
3510 if(anim==1)glVertex3f(190+movex[4]*transition, 150, 0.0f);
3512 glVertex3f(640, 150, 0.0f);
3514 glVertex3f(640, 336, 0.0f);
3516 if(anim!=1)glVertex3f(190, 336, 0.0f);
3517 if(anim==1)glVertex3f(190+movex[4]*transition, 336, 0.0f);
3522 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3524 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3528 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3529 glPushMatrix(); // Store The Projection Matrix
3530 glLoadIdentity(); // Reset The Projection Matrix
3531 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3532 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3533 glPushMatrix(); // Store The Modelview Matrix
3534 glLoadIdentity(); // Reset The Modelview Matrix
3535 glEnable(GL_TEXTURE_2D);
3538 for(j=0;j<nummenuitems;j++)
3540 if(j<=3||(mainmenu!=1&&mainmenu!=2))
3542 //glDisable(GL_BLEND);
3543 glEnable(GL_ALPHA_TEST);
3545 //glDisable(GL_ALPHA_TEST);
3546 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3547 if(mainmenu==1||mainmenu==2)
3550 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3551 glBindTexture( GL_TEXTURE_2D, Mainmenuitems[j]);
3552 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
3553 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
3554 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3558 glVertex3f(startx[j]+movex[j]*transition, starty[j]+movey[j]*transition, 0.0f);
3560 glVertex3f(endx[j]+movex[j]*transition, starty[j]+movey[j]*transition, 0.0f);
3562 glVertex3f(endx[j]+movex[j]*transition, endy[j]+movey[j]*transition, 0.0f);
3564 glVertex3f(startx[j]+movex[j]*transition, endy[j]+movey[j]*transition, 0.0f);
3568 //glDisable(GL_ALPHA_TEST);
3569 if(j<4)glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3572 if(1-((float)i)/10-(1-selectedlong[j])>0)
3574 glColor4f(1,1,1,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3575 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3579 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);
3581 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);
3583 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);
3585 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);
3591 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)
3593 if(mainmenu!=5||j<6)
3596 if(mainmenu==9&&j>accountprogress[accountactive]&&j<numchallengelevels)glColor4f(0.5,0,0,1);
3597 if(mainmenu==11&&j>accountprogress[accountactive]&&j<numchallengelevels)glColor4f(0.5,0,0,1);
3598 //if(1-((float)i)/10-(1-selectedlong[j])>0){
3599 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3601 if(mainmenu!=7||j!=0||!entername)text.glPrint(startx[j],starty[j],menustring[j],0,1,640,480);
3605 sprintf (string, "_");
3606 text.glPrint(startx[j]+(float)(displayselected)*10,starty[j],string,0,1,640,480);
3609 for(l=0;l<displaychars[k];l++){
3610 if(l<displaychars[k]){
3611 sprintf (string, "%c",displaytext[k][l]);
3612 text.glPrint(startx[j]+l*10,starty[j],string,0,1,640,480);
3620 sprintf (string, "Hooo!");
3621 text.glPrint(startx[0],starty[0],string,0,1,640,480);
3625 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3628 if(1-((float)i)/15-(1-selectedlong[j])>0)
3630 glColor4f(1,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3631 if(mainmenu==9&&j>accountprogress[accountactive]&&j<numchallengelevels)glColor4f(0.5,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3632 if(mainmenu==11&&j>accountprogress[accountactive]&&j<numchallengelevels)glColor4f(0.5,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3633 if(mainmenu==3)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4-((/*1*/+((float)i)/70)*strlen(menustring[j]))*3,starty[j]/*-i*1/2*/+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
3634 if(mainmenu==4)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4/*-((((float)i)/70)*strlen(menustring[j]))*3*/,starty[j]/*-i*1/2*/+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
3635 if(mainmenu==5)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4/*-((((float)i)/70)*strlen(menustring[j]))*3*/,starty[j]/*-i*1/2*/+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
3636 if(mainmenu==6)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4/*-((((float)i)/70)*strlen(menustring[j]))*3*/,starty[j]/*-i*1/2*/+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
3637 if(mainmenu==7&&(j!=0||!entername))text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4/*-((((float)i)/70)*strlen(menustring[j]))*3*/,starty[j]/*-i*1/2*/+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
3638 if(mainmenu==8)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4/*-((((float)i)/70)*strlen(menustring[j]))*3*/,starty[j]/*-i*1/2*/+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
3639 if(mainmenu==9)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4/*-((((float)i)/70)*strlen(menustring[j]))*3*/,starty[j]/*-i*1/2*/+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
3640 if(mainmenu==11)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4/*-((((float)i)/70)*strlen(menustring[j]))*3*/,starty[j]/*-i*1/2*/+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
3641 if(mainmenu==10)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4/*-((((float)i)/70)*strlen(menustring[j]))*3*/,starty[j]/*-i*1/2*/+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
3642 if(mainmenu==17)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4/*-((((float)i)/70)*strlen(menustring[j]))*3*/,starty[j]/*-i*1/2*/+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
3643 if(mainmenu==13&&j!=1)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4/*-((((float)i)/70)*strlen(menustring[j]))*3*/,starty[j]/*-i*1/2*/+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
3644 if(mainmenu==18)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4/*-((((float)i)/70)*strlen(menustring[j]))*3*/,starty[j]/*-i*1/2*/+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
3647 sprintf (string, "_");
3648 text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4+(float)(displayselected)*10*(1+((float)i)/70),starty[j]+offsety[j]*((float)i)/4,string,0,1+((float)i)/70,640,480);
3651 for(l=0;l<displaychars[k];l++){
3652 if(l<displaychars[k]){
3653 sprintf (string, "%c",displaytext[k][l]);
3654 text.glPrint(startx[j]-((float)k)+offsetx[j]*((float)k)/4+l*10*(1+((float)i)/70),starty[j]+offsety[j]*((float)i)/4,string,0,1+((float)i)/70,640,480);
3663 glClear(GL_DEPTH_BUFFER_BIT);
3664 glEnable(GL_ALPHA_TEST);
3665 glAlphaFunc(GL_GREATER, 0.001f);
3666 glEnable(GL_TEXTURE_2D);
3667 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3668 glDisable(GL_CULL_FACE);
3669 glDisable(GL_LIGHTING);
3670 if(j==6)glColor4f(1,1,1,1);
3671 else glColor4f(1,0,0,1);
3673 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3674 glPushMatrix(); // Store The Projection Matrix
3675 glLoadIdentity(); // Reset The Projection Matrix
3676 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3677 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3678 glPushMatrix(); // Store The Modelview Matrix
3679 glLoadIdentity(); // Reset The Modelview Matrix
3682 //Draw world, draw map
3683 glTranslatef(2,-5,0);
3685 if(j>6&&j<nummenuitems-1)
3687 XYZ linestart,lineend,offset;
3694 //float linestartx,lineendx,linestarty,lineendy,offsetx,offsety;
3695 linestart.x=(startx[j]+endx[j])/2;
3696 linestart.y=(starty[j]+endy[j])/2;
3697 if(j>=6+accountcampaignchoicesmade[accountactive]){
3698 linestart.x=(startx[6+accountcampaignchoicesmade[accountactive]]+endx[6+accountcampaignchoicesmade[accountactive]])/2;
3699 linestart.y=(starty[6+accountcampaignchoicesmade[accountactive]]+endy[6+accountcampaignchoicesmade[accountactive]])/2;
3701 lineend.x=(startx[j+1]+endx[j+1])/2;
3702 lineend.y=(starty[j+1]+endy[j+1])/2;
3703 offset=lineend-linestart;
3706 offset=DoRotation(offset,0,0,90);
3708 glDisable(GL_TEXTURE_2D);
3710 if(j<6+accountcampaignchoicesmade[accountactive]){
3711 glColor4f(0.5,0,0,1);
3715 if(j>=6+accountcampaignchoicesmade[accountactive]){
3721 linestart+=fac*4*startsize;
3722 lineend-=fac*4*endsize;
3724 if(!(j>7+accountcampaignchoicesmade[accountactive]+campaignchoicenum)){
3725 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3729 glVertex3f(linestart.x-offset.x*startsize, linestart.y-offset.y*startsize, 0.0f);
3731 glVertex3f(linestart.x+offset.x*startsize, linestart.y+offset.y*startsize, 0.0f);
3733 glVertex3f(lineend.x+offset.x*endsize, lineend.y+offset.y*endsize, 0.0f);
3735 glVertex3f(lineend.x-offset.x*endsize, lineend.y-offset.y*endsize, 0.0f);
3739 glEnable(GL_TEXTURE_2D);
3743 if(j==6)glBindTexture( GL_TEXTURE_2D, Mainmenuitems[7]);
3744 else glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
3745 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
3746 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
3747 if(j-7<accountcampaignchoicesmade[accountactive])glColor4f(0.5,0,0,1);
3748 if(j-7>=accountcampaignchoicesmade[accountactive])glColor4f(1,0,0,1);
3749 if(j==6)glColor4f(1,1,1,1);
3752 itemsize=abs(startx[j]-endx[j])/2;
3754 midpoint.x=(startx[j]+endx[j])/2;
3755 midpoint.y=(starty[j]+endy[j])/2;
3756 if(j>6&&(j-7<accountcampaignchoicesmade[accountactive]))itemsize*=.5;
3757 if(!(j-7>accountcampaignchoicesmade[accountactive]+campaignchoicenum))
3759 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3763 glVertex3f(midpoint.x-itemsize+movex[j]*transition, midpoint.y-itemsize+movey[j]*transition, 0.0f);
3765 glVertex3f(midpoint.x+itemsize+movex[j]*transition, midpoint.y-itemsize+movey[j]*transition, 0.0f);
3767 glVertex3f(midpoint.x+itemsize+movex[j]*transition, midpoint.y+itemsize+movey[j]*transition, 0.0f);
3769 glVertex3f(midpoint.x-itemsize+movex[j]*transition, midpoint.y+itemsize+movey[j]*transition, 0.0f);
3773 //glDisable(GL_ALPHA_TEST);
3774 if(j<4)glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3777 if(1-((float)i)/10-(1-selectedlong[j])>0)
3779 glColor4f(1,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3780 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3784 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);
3786 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);
3788 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);
3790 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);
3798 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3800 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3802 if(j-7>=accountcampaignchoicesmade[accountactive]){
3803 //glColor4f(0,0,0,1);
3804 //text.glPrintOutline(startx[j]+10-1.5,starty[j]-4-1.5,menustring[j],0,0.6*1.25,640,480);
3805 //glColor4f(1,0,0,1);
3806 //text.glPrint(startx[j]+10,starty[j]-4,menustring[j],0,0.6,640,480);
3807 text.glPrintOutlined(0.9,0,0,startx[j]+10,starty[j]-4,menustring[j],0,0.6,640,480);
3808 glDisable(GL_DEPTH_TEST);
3815 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3817 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3820 if(mainmenu==1||mainmenu==2)
3821 if(transition<.1||transition>.9){
3822 glClear(GL_DEPTH_BUFFER_BIT);
3823 glEnable(GL_ALPHA_TEST);
3824 glAlphaFunc(GL_GREATER, 0.001f);
3825 glEnable(GL_TEXTURE_2D);
3826 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3827 glDisable(GL_CULL_FACE);
3828 glDisable(GL_LIGHTING);
3830 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3831 glPushMatrix(); // Store The Projection Matrix
3832 glLoadIdentity(); // Reset The Projection Matrix
3833 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3834 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3835 glPushMatrix(); // Store The Modelview Matrix
3836 glLoadIdentity(); // Reset The Modelview Matrix
3838 glDisable(GL_TEXTURE_2D);
3839 if(transition<.1)glColor4f(1,0,0,1-(transition*10));
3840 if(transition>.9)glColor4f(1,0,0,1-((1-transition)*10));
3844 glVertex3f(190, 150, 0.0f);
3846 glVertex3f(640, 150, 0.0f);
3848 glVertex3f(640, 336, 0.0f);
3850 glVertex3f(190, 336, 0.0f);
3855 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3859 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3860 glPushMatrix(); // Store The Projection Matrix
3861 glLoadIdentity(); // Reset The Projection Matrix
3862 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
3863 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3864 glPushMatrix(); // Store The Modelview Matrix
3865 glLoadIdentity(); // Reset The Modelview Matrix
3866 glTranslatef(screenwidth/2,screenheight/2,0);
3868 glScalef((float)screenwidth/2,(float)screenheight/2,1);
3869 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3871 glEnable(GL_TEXTURE_2D);
3873 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
3874 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
3877 glTranslatef(mousecoordh-screenwidth/2,mousecoordv*-1+screenheight/2,0);
3878 glScalef((float)screenwidth/64,(float)screenwidth/64,1);
3879 glTranslatef(1,-1,0);
3880 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3882 glBindTexture( GL_TEXTURE_2D, cursortexture);
3884 //glScalef(.25,.25,.25);
3887 glVertex3f(-1, -1, 0.0f);
3889 glVertex3f(1, -1, 0.0f);
3891 glVertex3f(1, 1, 0.0f);
3893 glVertex3f(-1, 1, 0.0f);
3898 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3904 //printf("Flash amount: %f, delay %i\n", flashamount, flashdelay);
3905 if(flashamount>1)flashamount=1;
3906 if(flashdelay<=0)flashamount-=multiplier;
3908 if(flashamount<0)flashamount=0;
3909 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3910 glDisable(GL_CULL_FACE);
3911 glDisable(GL_LIGHTING);
3912 glDisable(GL_TEXTURE_2D);
3914 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3915 glPushMatrix(); // Store The Projection Matrix
3916 glLoadIdentity(); // Reset The Projection Matrix
3917 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
3918 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3919 glPushMatrix(); // Store The Modelview Matrix
3920 glLoadIdentity(); // Reset The Modelview Matrix
3921 glScalef(screenwidth,screenheight,1);
3922 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3924 glColor4f(flashr,flashg,flashb,flashamount);
3926 glVertex3f(0, 0, 0.0f);
3927 glVertex3f(256, 0, 0.0f);
3928 glVertex3f(256, 256, 0.0f);
3929 glVertex3f(0, 256, 0.0f);
3931 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3932 glPopMatrix(); // Restore The Old Projection Matrix
3933 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3934 glPopMatrix(); // Restore The Old Projection Matrix
3935 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
3936 glEnable(GL_CULL_FACE);
3937 glDisable(GL_BLEND);
3942 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)||(!gameon&&gamestarted)){
3943 tempmult=multiplier;
3949 if ( side == stereoRight || side == stereoCenter ) {
3950 if(drawmode!=motionblurmode||mainmenu){
3955 //myassert(glGetError() == GL_NO_ERROR);
3956 glDrawBuffer(GL_BACK);
3957 glReadBuffer(GL_BACK);
3962 if(drawtoggle==2)drawtoggle=0;
3964 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)){
3965 multiplier=tempmult;
3967 //Jordan fixed your warning!