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);
570 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
571 glEnable(GL_CULL_FACE);
572 glCullFace(GL_FRONT);
574 for(k=0;k<numplayers;k++){
575 if(!(k==0||tutoriallevel!=1)){
577 glEnable(GL_LIGHTING);
578 terrainlight=terrain.getLighting(player[k].coords.x,player[k].coords.z);
579 distance=findDistancefast(&viewer,&player[k].coords);
580 distance=(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance;
581 glColor4f(terrainlight.x,terrainlight.y,terrainlight.z,distance);
582 if(distance>=1)glDisable(GL_BLEND);
584 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;
586 if(!player[k].occluded==0)i=checkcollide(viewer,checkpoint,player[k].lastoccluded);
587 if(i==-1||player[k].occluded==0)i=checkcollide(viewer,checkpoint);
589 player[k].occluded+=1;
590 player[k].lastoccluded=i;
592 else player[k].occluded=0;
593 if(player[k].occluded<25)player[k].DrawSkeleton();
600 glEnable(GL_TEXTURE_2D);
605 glDisable(GL_COLOR_MATERIAL);
607 glDisable(GL_LIGHTING);
608 glDisable(GL_TEXTURE_2D);
616 glDisable(GL_LIGHTING);
617 glDisable(GL_TEXTURE_2D);
618 glDisable(GL_COLOR_MATERIAL);
621 for(k=0;k<numplayers;k++){
622 if(player[k].numwaypoints>1){
623 glBegin(GL_LINE_LOOP);
624 for(i=0;i<player[k].numwaypoints;i++){
625 glVertex3f(player[k].waypoints[i].x,player[k].waypoints[i].y+.5,player[k].waypoints[i].z);
634 for(k=0;k<numpathpoints;k++){
635 if(numpathpointconnect[k]){
636 for(i=0;i<numpathpointconnect[k];i++){
637 glBegin(GL_LINE_LOOP);
638 glVertex3f(pathpoint[k].x,pathpoint[k].y+.5,pathpoint[k].z);
639 glVertex3f(pathpoint[pathpointconnect[k][i]].x,pathpoint[pathpointconnect[k][i]].y+.5,pathpoint[pathpointconnect[k][i]].z);
647 glVertex3f(pathpoint[pathpointselected].x,pathpoint[pathpointselected].y+.5,pathpoint[pathpointselected].z);
654 glEnable(GL_TEXTURE_2D);
655 glColor4f(.5,.5,.5,1);
657 sprintf (string, " ",(int)(fps));
658 text.glPrint(10,30,string,0,.8,screenwidth,screenheight);
661 if(bonus>0&&bonustime<1&&!winfreeze&&indialogue==-1/*bonustime<4*/){
662 if(bonus==tracheotomy)sprintf (string, "Tracheotomy!");
663 else if(bonus==backstab)sprintf (string, "Backstabber!");
664 else if(bonus==spinecrusher)sprintf (string, "Spinecrusher!");
665 else if(bonus==ninja)sprintf (string, "Ninja Bonus!");
666 else if(bonus==style)sprintf (string, "Style Bonus!");
667 else if(bonus==cannon)sprintf (string, "Leg Cannon!");
668 else if(bonus==aimbonus)sprintf (string, "Nice Aim!");
669 else if(bonus==deepimpact)sprintf (string, "Heavy Impact!");
670 else if(bonus==touchofdeath)sprintf (string, "Touch of Death!");
671 else if(bonus==swordreversebonus)sprintf (string, "Sword Disarm!");
672 else if(bonus==staffreversebonus)sprintf (string, "Staff Disarm!");
673 else if(bonus==reverseko)sprintf (string, "Reversal KO!");
674 else if(bonus==solidhit)sprintf (string, "Solid Hit!");
675 else if(bonus==twoxcombo)sprintf (string, "2X Combo!");
676 else if(bonus==threexcombo)sprintf (string, "3X Combo!");
677 else if(bonus==fourxcombo)sprintf (string, "4X COMBO!");
678 else if(bonus==megacombo)sprintf (string, "MEGA COMBO!");
679 else if(bonus==Reversal)sprintf (string, "Reversal!");
680 else if(bonus==Stabbonus)sprintf (string, "Punctured!");
681 else if(bonus==Slicebonus)sprintf (string, "Sliced!");
682 else if(bonus==Bullseyebonus)sprintf (string, "Bullseye!");
683 else if(bonus==Slashbonus)sprintf (string, "Slashed!");
684 else if(bonus==Wolfbonus)sprintf (string, "WOLF SLAYER!");
685 else if(bonus==FinishedBonus)sprintf (string, "SLAIN!");
686 else if(bonus==TackleBonus)sprintf (string, "Tackle!");
687 else if(bonus==AboveBonus)sprintf (string, "Death from Above!");
688 else sprintf (string, "Excellent!");
690 glColor4f(0,0,0,1-bonustime);
691 text.glPrintOutline(1024/2-10*strlen(string)-4,768/16-4+768*4/5,string,1,2.5,1024,768);
692 glColor4f(1,0,0,1-bonustime);
693 text.glPrint(1024/2-10*strlen(string),768/16+768*4/5,string,1,2,1024,768);
695 sprintf (string, "%d",(int)bonusvalue);
696 glColor4f(0,0,0,1-bonustime);
697 text.glPrintOutline(1024/2-10*strlen(string)-4,768/16-4-20+768*4/5,string,1,2.5*.8,1024,768);
698 glColor4f(1,0,0,1-bonustime);
699 text.glPrint(1024/2-10*strlen(string),768/16-20+768*4/5,string,1,2*.8,1024,768);
700 glColor4f(.5,.5,.5,1);
703 if(tutoriallevel==1){
704 tutorialopac=tutorialmaxtime-tutorialstagetime;
705 if(tutorialopac>1)tutorialopac=1;
706 if(tutorialopac<0)tutorialopac=0;
708 sprintf (string, " ");
709 sprintf (string2, " ");
710 sprintf (string3, " ");
711 if(tutorialstage==0){
712 sprintf (string, " ");
713 sprintf (string2, " ");
714 sprintf (string3, " ");
716 if(tutorialstage==1){
717 sprintf (string, "Welcome to the Lugaru training level!");
718 sprintf (string2, " ");
719 sprintf (string3, " ");
721 if(tutorialstage==2){
722 sprintf (string, "BASIC MOVEMENT:");
723 sprintf (string2, " ");
724 sprintf (string3, " ");
726 if(tutorialstage==3){
727 sprintf (string, "You can move the mouse to rotate the camera.");
728 sprintf (string2, " ");
729 sprintf (string3, " ");
731 if(tutorialstage==4){
732 sprintf (string, "Try using the %s, %s, %s and %s keys to move around.",KeyToChar(forwardkey),KeyToChar(leftkey),KeyToChar(backkey),KeyToChar(rightkey));
733 sprintf (string2, "All movement is relative to the camera.");
734 sprintf (string3, " ");
736 if(tutorialstage==5){
737 sprintf (string, "Please press %s to jump.",KeyToChar(jumpkey));
738 sprintf (string2, "You can hold it longer to jump higher.");
739 sprintf (string3, " ");
741 if(tutorialstage==6){
742 sprintf (string, "You can press %s to crouch.",KeyToChar(crouchkey));
743 sprintf (string2, "You can jump higher from a crouching position.");
744 sprintf (string3, " ");
746 if(tutorialstage==7){
747 sprintf (string, "While running, you can press %s to roll.",KeyToChar(crouchkey));
748 sprintf (string2, " ");
749 sprintf (string3, " ");
751 if(tutorialstage==8){
752 sprintf (string, "While crouching, you can sneak around silently");
753 sprintf (string2, "using the movement keys.");
754 sprintf (string3, " ");
756 if(tutorialstage==9){
757 sprintf (string, "Release the crouch key while sneaking and hold the movement keys");
758 sprintf (string2, "to run animal-style.");
759 sprintf (string3, " ");
761 if(tutorialstage==10){
762 sprintf (string, "ADVANCED MOVEMENT:");
763 sprintf (string2, " ");
764 sprintf (string3, " ");
766 if(tutorialstage==11){
767 sprintf (string, "When you jump at a wall, you can hold %s again",KeyToChar(jumpkey));
768 sprintf (string2, "during impact to perform a walljump.");
769 sprintf (string3, "Be sure to use the movement keys to press against the wall");
771 if(tutorialstage==12){
772 sprintf (string, "While in the air, you can press crouch to flip.",KeyToChar(jumpkey));
773 sprintf (string2, "Walljumps and flips confuse enemies and give you more control.");
774 sprintf (string3, " ");
776 if(tutorialstage==13){
777 sprintf (string, "BASIC COMBAT:");
778 sprintf (string2, " ");
779 sprintf (string3, " ");
781 if(tutorialstage==14){
782 sprintf (string, "There is now an imaginary enemy");
783 sprintf (string2, "in the middle of the training area.");
784 sprintf (string3, " ");
786 if(tutorialstage==15){
787 if(attackkey==MAC_MOUSEBUTTON1)sprintf (string, "Click to attack when you are near an enemy.");
788 else sprintf (string, "Press %s to attack when you are near an enemy.",KeyToChar(attackkey));
789 sprintf (string2, "You can punch by standing still near an enemy and attacking.");
790 sprintf (string3, " ");
792 if(tutorialstage==16){
793 sprintf (string, "If you are close, you will perform a weak punch.");
794 sprintf (string2, "The weak punch is excellent for starting attack combinations.");
795 sprintf (string3, " ");
797 if(tutorialstage==17){
798 sprintf (string, "Attacking while running results in a spin kick.");
799 sprintf (string2, "This is one of your most powerful ground attacks.");
800 sprintf (string3, " ");
802 if(tutorialstage==18){
803 sprintf (string, "Sweep the enemy's legs out by attacking while crouched.");
804 sprintf (string2, "This is a very fast attack, and easy to follow up.");
805 sprintf (string3, " ");
807 if(tutorialstage==19){
808 sprintf (string, "When an enemy is on the ground, you can deal some extra");
809 sprintf (string2, "damage by running up and drop-kicking him.");
810 sprintf (string3, "(Try knocking them down with a sweep first)");
812 if(tutorialstage==20){
813 sprintf (string, "Your most powerful individual attack is the rabbit kick.");
814 if(attackkey==MAC_MOUSEBUTTON1)sprintf (string2, "Run at the enemy while holding the mouse button, and press");
815 else sprintf (string2, "Run at the enemy while holding %s, and press", KeyToChar(attackkey));
816 sprintf (string3, "the jump key (%s) to attack.",KeyToChar(jumpkey));
818 if(tutorialstage==21){
819 sprintf (string, "This attack is devastating if timed correctly.");
820 sprintf (string2, "Even if timed incorrectly, it will knock the enemy over.");
821 if(againbonus)sprintf (string3, "Try rabbit-kicking the imaginary enemy again.");
822 else sprintf (string3, "Try rabbit-kicking the imaginary enemy.");
824 if(tutorialstage==22){
825 sprintf (string, "If you sneak behind an enemy unnoticed, you can kill");
826 sprintf (string2, "him instantly. Move close behind this enemy");
827 sprintf (string3, "and attack.");
829 if(tutorialstage==23){
830 sprintf (string, "Another important attack is the wall kick. When an enemy");
831 sprintf (string2, "is near a wall, perform a walljump nearby and hold");
832 sprintf (string3, "the attack key during impact with the wall.");
834 if(tutorialstage==24){
835 sprintf (string, "You can tackle enemies by running at them animal-style");
836 if(attackkey==MAC_MOUSEBUTTON1)sprintf (string2, "and pressing jump (%s) or attack(mouse button).",KeyToChar(jumpkey));
837 else sprintf (string2, "and pressing jump (%s) or attack(%s).",KeyToChar(jumpkey),KeyToChar(attackkey));
838 sprintf (string3, "This is especially useful when they are running away.");
840 if(tutorialstage==25){
841 sprintf (string, "Dodge by pressing back and attack. Dodging is essential");
842 sprintf (string2, "against enemies with swords or other long weapons.");
843 sprintf (string3, " ");
845 if(tutorialstage==26){
846 sprintf (string, "REVERSALS AND COUNTER-REVERSALS");
847 sprintf (string2, " ");
848 sprintf (string3, " ");
850 if(tutorialstage==27){
851 sprintf (string, "The enemy can now reverse your attacks.");
852 sprintf (string2, " ");
853 sprintf (string3, " ");
855 if(tutorialstage==28){
856 sprintf (string, "If you attack, you will notice that the enemy now sometimes");
857 sprintf (string2, "catches your attack and uses it against you. Hold");
858 sprintf (string3, "crouch (%s) after attacking to escape from reversals.",KeyToChar(crouchkey));
860 if(tutorialstage==29){
861 sprintf (string, "Try escaping from two more reversals in a row.");
862 sprintf (string2, " ");
863 sprintf (string3, " ");
865 if(tutorialstage==30){
866 sprintf (string, "Good!");
867 sprintf (string2, " ");
868 sprintf (string3, " ");
870 if(tutorialstage==31){
871 sprintf (string, "To reverse an attack, you must tap crouch (%s) during the",KeyToChar(crouchkey));
872 sprintf (string2, "enemy's attack. You must also be close to the enemy;");
873 sprintf (string3, "this is especially important against armed opponents.");
875 if(tutorialstage==32){
876 sprintf (string, "The enemy can attack in %d seconds.", (int)(tutorialmaxtime-tutorialstagetime));
877 sprintf (string2, "This imaginary opponents attacks will be highlighted");
878 sprintf (string3, "to make this easier.");
880 if(tutorialstage==33){
881 sprintf (string, "Reverse three enemy attacks!");
882 sprintf (string2, " ");
883 sprintf (string3, " ");
885 if(tutorialstage==34){
886 sprintf (string, "Reverse two more enemy attacks!");
887 sprintf (string2, " ");
888 sprintf (string3, " ");
890 if(tutorialstage==35){
891 sprintf (string, "Reverse one more enemy attack!");
892 sprintf (string2, " ");
893 sprintf (string3, " ");
895 if(tutorialstage==36){
896 sprintf (string, "Excellent!");
897 sprintf (string2, " ");
898 sprintf (string3, " ");
900 if(tutorialstage==37){
901 sprintf (string, "Now spar with the enemy for %d more seconds.", (int)(tutorialmaxtime-tutorialstagetime));
902 sprintf (string2, "Damage dealt: %d",(int)damagedealt);
903 sprintf (string3, "Damage taken: %d.",(int)damagetaken);
905 if(tutorialstage==38){
906 sprintf (string, "WEAPONS:");
907 sprintf (string2, " ");
908 sprintf (string3, " ");
910 if(tutorialstage==39){
911 sprintf (string, "There is now an imaginary knife");
912 sprintf (string2, "in the center of the training area.");
913 sprintf (string3, " ");
915 if(tutorialstage==40){
916 sprintf (string, "Stand, roll or handspring over the knife");
917 sprintf (string2, "while pressing %s to pick it up.",KeyToChar(throwkey));
918 sprintf (string3, "You can crouch and press the same key to drop it again.");
920 if(tutorialstage==41){
921 sprintf (string, "You can equip and unequip weapons using the %s key.",KeyToChar(drawkey));
922 sprintf (string2, "Sometimes it is best to keep them unequipped to");
923 sprintf (string3, "prevent enemies from taking them. ");
925 if(tutorialstage==42){
926 sprintf (string, "The knife is the smallest weapon and the least encumbering.");
927 sprintf (string2, "You can equip or unequip it while standing, crouching,");
928 sprintf (string3, "running or flipping.");
930 if(tutorialstage==43){
931 sprintf (string, "You perform weapon attacks the same way as unarmed attacks,");
932 sprintf (string2, "but sharp weapons cause permanent damage, instead of the");
933 sprintf (string3, "temporary trauma from blunt weapons, fists and feet.");
935 if(tutorialstage==44){
936 sprintf (string, "The enemy now has your knife!");
937 sprintf (string2, "Please reverse two of his knife attacks.");
938 sprintf (string3, " ");
940 if(tutorialstage==45){
941 sprintf (string, "Please reverse one more of his knife attacks.");
942 sprintf (string2, " ");
943 sprintf (string3, " ");
945 if(tutorialstage==46){
946 sprintf (string, "Now he has a sword!");
947 sprintf (string2, "The sword has longer reach than your arms, so you");
948 sprintf (string3, "must move close to reverse the sword slash.");
950 if(tutorialstage==47){
951 sprintf (string, "Long weapons like the sword and staff are also useful for defense;");
952 sprintf (string2, "you can parry enemy weapon attacks by pressing the attack key");
953 sprintf (string3, "at the right time. Please try parrying the enemy's attacks!");
955 if(tutorialstage==48){
956 sprintf (string, "The staff is like the sword, but has two main attacks.");
957 sprintf (string2, "The standing smash is fast and effective, and the running");
958 sprintf (string3, "spin smash is slower and more powerful.");
960 if(tutorialstage==49){
961 sprintf (string, "When facing an enemy, you can throw the knife with %s.",KeyToChar(throwkey));
962 sprintf (string2, "It is possible to throw the knife while flipping,");
963 sprintf (string3, "but it is very inaccurate.");
965 if(tutorialstage==50){
966 sprintf (string, "You now know everything you can learn from training.");
967 sprintf (string2, "Everything else you must learn from experience!");
968 sprintf (string3, " ");
970 if(tutorialstage==51){
971 sprintf (string, "Walk out of the training area to return to the main menu.");
972 sprintf (string2, " ");
973 sprintf (string3, " ");
976 glColor4f(0,0,0,tutorialopac);
977 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);
978 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);
979 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);
980 glColor4f(1,1,1,tutorialopac);
981 text.glPrint(screenwidth/2-7.6*strlen(string)*screenwidth/1024,screenheight/16+screenheight*4/5,string,1,1.5*screenwidth/1024,screenwidth,screenheight);
982 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);
983 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);
985 sprintf (string, "Press 'tab' to skip to the next item.",KeyToChar(jumpkey));
986 sprintf (string2, "Press escape at any time to");
987 sprintf (string3, "pause or exit the tutorial.");
990 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);
991 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);
992 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);
993 glColor4f(0.5,0.5,0.5,1);
994 text.glPrint(screenwidth/2-7.6*strlen(string)*screenwidth/1024*.8,0+screenheight*1/10,string,1,1.5*screenwidth/1024*.8,screenwidth,screenheight);
995 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);
996 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);
1000 if(numhotspots&&(bonustime>=1||bonus<=0||bonustime<0)&&!tutoriallevel){
1002 float closestdist=-1;
1004 closest=currenthotspot;
1005 for(i=0;i<numhotspots;i++){
1006 distance=findDistancefast(&player[0].coords,&hotspot[i]);
1007 if(closestdist==-1||distance<closestdist){
1008 if(findDistancefast(&player[0].coords,&hotspot[i])<hotspotsize[i]&&((hotspottype[i]<=10&&hotspottype[i]>=0)||(hotspottype[i]<=40&&hotspottype[i]>=20))){
1009 closestdist=distance;
1015 currenthotspot=closest;
1016 if(currenthotspot!=-1){
1017 if(hotspottype[closest]<=10){
1018 if(findDistancefast(&player[0].coords,&hotspot[closest])<hotspotsize[closest])
1019 tutorialstagetime=0;
1021 tutorialopac=tutorialmaxtime-tutorialstagetime;
1022 if(tutorialopac>1)tutorialopac=1;
1023 if(tutorialopac<0)tutorialopac=0;
1025 sprintf (string, "%s", hotspottext[closest]);
1033 if(string[i]=='\n'||string[i]>'z'||string[i]<' '||string[i]=='\0'){
1034 glColor4f(0,0,0,tutorialopac);
1035 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);
1036 glColor4f(1,1,1,tutorialopac);
1037 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);
1040 if(string[i]=='\0')done=1;
1046 else if (hotspottype[closest]>=20&&dialoguegonethrough[hotspottype[closest]-20]==0){
1047 whichdialogue=hotspottype[closest]-20;
1048 for(j=0;j<numdialogueboxes[whichdialogue];j++){
1049 player[participantfocus[whichdialogue][j]].coords=participantlocation[whichdialogue][participantfocus[whichdialogue][j]];
1050 player[participantfocus[whichdialogue][j]].rotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
1051 player[participantfocus[whichdialogue][j]].targetrotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
1052 player[participantfocus[whichdialogue][j]].velocity=0;
1053 player[participantfocus[whichdialogue][j]].targetanimation=player[participantfocus[whichdialogue][j]].getIdle();
1054 player[participantfocus[whichdialogue][j]].targetframe=0;
1058 dialoguegonethrough[whichdialogue]++;
1059 if(dialogueboxsound[whichdialogue][indialogue]!=0){
1060 static float gLoc[3];
1061 static float vel[3];
1062 gLoc[0]=player[participantfocus[whichdialogue][indialogue]].coords.x;
1063 gLoc[1]=player[participantfocus[whichdialogue][indialogue]].coords.y;
1064 gLoc[2]=player[participantfocus[whichdialogue][indialogue]].coords.z;
1069 if(dialogueboxsound[whichdialogue][indialogue]==1)whichsoundplay=rabbitchitter;
1070 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
1071 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
1072 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
1073 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
1074 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
1075 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
1076 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
1077 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
1078 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
1079 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
1080 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
1081 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
1082 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
1083 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
1084 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
1085 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
1086 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
1087 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
1088 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
1089 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, true);
1090 OPENAL_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
1091 OPENAL_SetVolume(channels[whichsoundplay], 256);
1092 OPENAL_SetPaused(channels[whichsoundplay], false);
1098 if(indialogue!=-1&&!mainmenu){
1099 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1100 glDisable(GL_CULL_FACE);
1101 glDisable(GL_LIGHTING);
1102 glDisable(GL_TEXTURE_2D);
1104 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1105 glPushMatrix(); // Store The Projection Matrix
1106 glLoadIdentity(); // Reset The Projection Matrix
1107 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1108 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1109 glPushMatrix(); // Store The Modelview Matrix
1110 glLoadIdentity(); // Reset The Modelview Matrix
1111 if(dialogueboxlocation[whichdialogue][indialogue]==1)glTranslatef(0,screenheight*3/4,0);
1112 glScalef(screenwidth,screenheight/4,1);
1113 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1116 glColor4f(dialogueboxcolor[whichdialogue][indialogue][0],dialogueboxcolor[whichdialogue][indialogue][1],dialogueboxcolor[whichdialogue][indialogue][2],0.7);
1118 glVertex3f(0, 0, 0.0f);
1119 glVertex3f(1, 0, 0.0f);
1120 glVertex3f(1, 1, 0.0f);
1121 glVertex3f(0, 1, 0.0f);
1123 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1124 glPopMatrix(); // Restore The Old Projection Matrix
1125 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1126 glPopMatrix(); // Restore The Old Projection Matrix
1127 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1128 glEnable(GL_CULL_FACE);
1129 glDisable(GL_BLEND);
1131 glEnable(GL_TEXTURE_2D);
1138 startx=screenwidth*1/5;
1139 if(dialogueboxlocation[whichdialogue][indialogue]==1)starty=screenheight/16+screenheight*4/5;
1140 if(dialogueboxlocation[whichdialogue][indialogue]==2)starty=screenheight*1/5-screenheight/16;
1142 // char tempname[64];
1146 // for(i=0;i<64;i++){
1151 for(i=0;i<(int)strlen(dialoguename[whichdialogue][indialogue]);i++){
1152 tempname[tempnum]=dialoguename[whichdialogue][indialogue][i];
1154 if(dialoguename[whichdialogue][indialogue][i]=='#'||dialoguename[whichdialogue][indialogue][i]=='\0')goodchar=0;
1155 //if(tempnum>2)if(tempname[tempnum-2]=='e'&&tempname[tempnum-1]=='r')goodchar=0;
1156 //if(tempnum>2)if(tempname[tempnum]=='r'&&tempname[0]=='a')goodchar=0;
1157 if(goodchar)tempnum++;
1158 else tempname[tempnum]='\0';
1161 sprintf (string, "%s: ", tempname);
1163 if(dialogueboxcolor[whichdialogue][indialogue][0]+dialogueboxcolor[whichdialogue][indialogue][1]+dialogueboxcolor[whichdialogue][indialogue][2]<1.5){
1164 glColor4f(0,0,0,tutorialopac);
1165 text.glPrintOutline(startx-2*7.6*strlen(string)*screenwidth/1024-4,starty-4,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight);
1166 glColor4f(0.7,0.7,0.7,tutorialopac);
1167 text.glPrint(startx-2*7.6*strlen(string)*screenwidth/1024,starty,string,1,1.5*screenwidth/1024,screenwidth,screenheight);
1171 glColor4f(0,0,0,tutorialopac);
1172 text.glPrintOutline(startx-2*7.6*strlen(string)*screenwidth/1024-4,starty-4,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight);
1177 for(i=0;i<(int)strlen(dialoguetext[whichdialogue][indialogue])+1;i++){
1178 tempname[tempnum]=dialoguetext[whichdialogue][indialogue][i];
1179 if(dialoguetext[whichdialogue][indialogue][i]!='#')tempnum++;
1183 sprintf (string, "%s", tempname);
1192 if(string[i]=='\n'||string[i]>'z'||string[i]<' '||string[i]=='\0'){
1193 if(dialogueboxcolor[whichdialogue][indialogue][0]+dialogueboxcolor[whichdialogue][indialogue][1]+dialogueboxcolor[whichdialogue][indialogue][2]<1.5){
1194 glColor4f(0,0,0,tutorialopac);
1195 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);
1196 glColor4f(1,1,1,tutorialopac);
1197 text.glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/,starty-20*screenwidth/1024*line,string,1,1.5*screenwidth/1024,screenwidth,screenheight,lastline,i);
1201 glColor4f(0,0,0,tutorialopac);
1202 text.glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/,starty-20*screenwidth/1024*line,string,1,1.5*screenwidth/1024,screenwidth,screenheight,lastline,i);
1206 if(string[i]=='\0')done=1;
1213 if(!tutoriallevel&&!winfreeze&&indialogue==-1&&!mainmenu){
1215 if(!scoreadded)sprintf (string, "Score: %d", (int)accountcampaignscore[accountactive]+(int)bonustotal);//(int)bonustotal);
1216 if(scoreadded)sprintf (string, "Score: %d", (int)accountcampaignscore[accountactive]);//(int)bonustotal);
1218 if(!campaign)sprintf (string, "Score: %d", (int)bonustotal);
1220 text.glPrintOutline(1024/40-4,768/16-4+768*14/16,string,1,1.5*1.25,1024,768);
1222 text.glPrint(1024/40,768/16+768*14/16,string,1,1.5,1024,768);
1224 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1225 glDisable(GL_CULL_FACE);
1226 glDisable(GL_LIGHTING);
1227 glDisable(GL_TEXTURE_2D);
1229 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1230 glPushMatrix(); // Store The Projection Matrix
1231 glLoadIdentity(); // Reset The Projection Matrix
1232 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1233 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1234 glPushMatrix(); // Store The Modelview Matrix
1235 glLoadIdentity(); // Reset The Modelview Matrix
1236 glTranslatef(15,screenheight*17.5/20,0);
1237 glScalef(screenwidth/3+20,screenheight/20,1);
1238 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1240 glColor4f(0.0,0.4,0.0,0.7);
1241 float bar=((float)player[0].damage)/player[0].damagetolerance;
1243 glVertex3f((bar<1?bar:1),0,0.0f);
1244 glVertex3f(1,0,0.0f);
1245 glVertex3f(1,1,0.0f);
1246 glVertex3f((bar<1?bar:1),1,0.0f);
1248 glColor4f(0.1,0.0,0.0,1);
1249 bar = ((float)player[0].bloodloss)/player[0].damagetolerance;
1251 glVertex3f(0,0,0.0f);
1252 glVertex3f((bar<1?bar:1),0,0.0f);
1253 glVertex3f((bar<1?bar:1),1,0.0f);
1254 glVertex3f(0,1,0.0f);
1256 glColor4f(0.4,0.0,0.0,0.7);
1257 bar = ((float)player[0].damage)/player[0].damagetolerance;
1259 glVertex3f(0,0,0.0f);
1260 glVertex3f((bar<1?bar:1),0,0.0f);
1261 glVertex3f((bar<1?bar:1),1,0.0f);
1262 glVertex3f(0,1,0.0f);
1264 glColor4f(0.4,0.0,0.0,0.7);
1265 bar = ((float)player[0].permanentdamage)/player[0].damagetolerance;
1267 glVertex3f(0,0,0.0f);
1268 glVertex3f((bar<1?bar:1),0,0.0f);
1269 glVertex3f((bar<1?bar:1),1,0.0f);
1270 glVertex3f(0,1,0.0f);
1272 glColor4f(0.4,0.0,0.0,0.7);
1273 bar = ((float)player[0].superpermanentdamage)/player[0].damagetolerance;
1275 glVertex3f(0,0,0.0f);
1276 glVertex3f((bar<1?bar:1),0,0.0f);
1277 glVertex3f((bar<1?bar:1),1,0.0f);
1278 glVertex3f(0,1,0.0f);
1280 glColor4f(0.0,0.0,0.0,0.7);
1282 glBegin(GL_LINE_STRIP);
1283 glVertex3f(0,0,0.0f);
1284 glVertex3f(1,0,0.0f);
1285 glVertex3f(1,1,0.0f);
1286 glVertex3f(0,1,0.0f);
1287 glVertex3f(0,0,0.0f);
1290 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1291 glPopMatrix(); // Restore The Old Projection Matrix
1292 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1293 glPopMatrix(); // Restore The Old Projection Matrix
1294 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1295 glEnable(GL_CULL_FACE);
1296 glDisable(GL_BLEND);
1298 glEnable(GL_TEXTURE_2D);
1300 // writing the numbers :
1301 sprintf (string, "Damages : %d/%d (%d)",(int)(player[0].damage),(int)(player[0].damagetolerance),(int)(player[0].bloodloss));
1303 text.glPrintOutline(1024/40-4,768/16-4+768*14/16-40,string,1,1.5*1.25,1024,768);
1305 text.glPrint(1024/40,768/16+768*14/16-40,string,1,1.5,1024,768);
1309 glColor4f(.5,.5,.5,1);
1312 if((texttoggle||editorenabled)&&debugmode&&!mainmenu){
1313 sprintf (string, "The framespersecond is %d.",(int)(fps));
1314 text.glPrint(10,30,string,0,.8,1024,768);
1316 sprintf (string, "Name: %s", registrationname);
1317 text.glPrint(10,260,string,0,.8,1024,768);
1320 if(editorenabled)sprintf (string, "Map editor enabled.");
1321 if(!editorenabled)sprintf (string, "Map editor Disabled.");
1322 text.glPrint(10,60,string,0,.8,1024,768);
1324 sprintf (string, "Object size: %f",editorsize);
1325 text.glPrint(10,75,string,0,.8,1024,768);
1326 if(editorrotation>=0)sprintf (string, "Object rotation: %f",editorrotation);
1327 else sprintf (string, "Object rotation: Random");
1328 text.glPrint(10,90,string,0,.8,1024,768);
1329 if(editorrotation2>=0)sprintf (string, "Object rotation2: %f",editorrotation2);
1330 else sprintf (string, "Object rotation2: Random");
1331 text.glPrint(10,105,string,0,.8,1024,768);
1332 sprintf (string, "Object type: %d",editortype);
1333 text.glPrint(10,120,string,0,.8,1024,768);
1334 if(editortype==boxtype)sprintf (string, "(box)");
1335 if(editortype==treetrunktype)sprintf (string, "(tree)");
1336 if(editortype==walltype)sprintf (string, "(wall)");
1337 if(editortype==weirdtype)sprintf (string, "(weird)");
1338 if(editortype==spiketype)sprintf (string, "(spike)");
1339 if(editortype==rocktype)sprintf (string, "(rock)");
1340 if(editortype==bushtype)sprintf (string, "(bush)");
1341 if(editortype==tunneltype)sprintf (string, "(tunnel)");
1342 if(editortype==chimneytype)sprintf (string, "(chimney)");
1343 if(editortype==platformtype)sprintf (string, "(platform)");
1344 if(editortype==cooltype)sprintf (string, "(cool)");
1345 if(editortype==firetype)sprintf (string, "(fire)");
1346 text.glPrint(130,120,string,0,.8,1024,768);
1348 sprintf (string, "Numplayers: %d",numplayers);
1349 text.glPrint(10,155,string,0,.8,1024,768);
1350 sprintf (string, "Player %d: numwaypoints: %d",numplayers,player[numplayers-1].numwaypoints);
1351 text.glPrint(10,140,string,0,.8,1024,768);
1353 /*sprintf (string, "Coords are: %f %f %f",player[0].coords.x,player[0].coords.y,player[0].coords.z);
1354 text.glPrint(10,200,string,0,.8,1024,768);*/
1355 sprintf (string, "Difficulty: %d",difficulty);
1356 text.glPrint(10,240,string,0,.8,1024,768);
1358 sprintf (string, "lasthotspot: %d",hotspottype[numhotspots-1]);
1359 text.glPrint(10,240,string,0,.8,1024,768);
1360 sprintf (string, "killhotspot: %d",killhotspot);
1361 text.glPrint(10,220,string,0,.8,1024,768);
1362 sprintf (string, "winhotspot: %d",winhotspot);
1363 text.glPrint(10,200,string,0,.8,1024,768);*/
1368 if(drawmode==glowmode){
1369 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1370 glDisable(GL_CULL_FACE);
1371 glDisable(GL_LIGHTING);
1372 glDisable(GL_TEXTURE_2D);
1374 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1375 glPushMatrix(); // Store The Projection Matrix
1376 glLoadIdentity(); // Reset The Projection Matrix
1377 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1378 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1379 glPushMatrix(); // Store The Modelview Matrix
1380 glLoadIdentity(); // Reset The Modelview Matrix
1381 glScalef(screenwidth,screenheight,1);
1382 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1384 glColor4f(0,0,0,.5);
1386 glVertex3f(0, 0, 0.0f);
1387 glVertex3f(256, 0, 0.0f);
1388 glVertex3f(256, 256, 0.0f);
1389 glVertex3f(0, 256, 0.0f);
1391 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1392 glPopMatrix(); // Restore The Old Projection Matrix
1393 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1394 glPopMatrix(); // Restore The Old Projection Matrix
1395 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1396 glEnable(GL_CULL_FACE);
1397 glDisable(GL_BLEND);
1401 if((((blackout&&damageeffects)||(player[0].bloodloss>0&&damageeffects&&player[0].blooddimamount>0)||player[0].dead)&&!cameramode)||console){
1402 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1403 glDisable(GL_CULL_FACE);
1404 glDisable(GL_LIGHTING);
1405 glDisable(GL_TEXTURE_2D);
1407 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1408 glPushMatrix(); // Store The Projection Matrix
1409 glLoadIdentity(); // Reset The Projection Matrix
1410 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1411 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1412 glPushMatrix(); // Store The Modelview Matrix
1413 glLoadIdentity(); // Reset The Modelview Matrix
1414 glScalef(screenwidth,screenheight,1);
1415 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1417 if(player[0].dead)blackout+=multiplier*3;
1418 if(player[0].dead==1)blackout=.4f;
1419 if(player[0].dead==2&&blackout>.6)blackout=.6;
1420 glColor4f(0,0,0,blackout);
1421 if(!player[0].dead){
1422 if((player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5))*.3<.3){
1423 glColor4f(0,0,0,player[0].blooddimamount*player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5)*.3);
1424 blackout=player[0].blooddimamount*player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5)*.3;
1427 glColor4f(0,0,0,player[0].blooddimamount*.3);
1428 blackout=player[0].blooddimamount*.3;
1431 if(console)glColor4f(.7,0,0,.2);
1433 glVertex3f(0, 0, 0.0f);
1434 glVertex3f(256, 0, 0.0f);
1435 glVertex3f(256, 256, 0.0f);
1436 glVertex3f(0, 256, 0.0f);
1438 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1439 glPopMatrix(); // Restore The Old Projection Matrix
1440 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1441 glPopMatrix(); // Restore The Old Projection Matrix
1442 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1443 glEnable(GL_CULL_FACE);
1444 glDisable(GL_BLEND);
1448 if(flashamount>0&&damageeffects){
1449 if(flashamount>1)flashamount=1;
1450 if(flashdelay<=0)flashamount-=multiplier;
1452 if(flashamount<0)flashamount=0;
1453 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1454 glDisable(GL_CULL_FACE);
1455 glDisable(GL_LIGHTING);
1457 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1458 glPushMatrix(); // Store The Projection Matrix
1459 glLoadIdentity(); // Reset The Projection Matrix
1460 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1461 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1462 glPushMatrix(); // Store The Modelview Matrix
1463 glLoadIdentity(); // Reset The Modelview Matrix
1464 glScalef(screenwidth,screenheight,1);
1465 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1467 glColor4f(flashr,flashg,flashb,flashamount);
1469 glVertex3f(0, 0, 0.0f);
1470 glVertex3f(256, 0, 0.0f);
1471 glVertex3f(256, 256, 0.0f);
1472 glVertex3f(0, 256, 0.0f);
1474 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1475 glPopMatrix(); // Restore The Old Projection Matrix
1476 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1477 glPopMatrix(); // Restore The Old Projection Matrix
1478 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1479 glEnable(GL_CULL_FACE);
1480 glDisable(GL_BLEND);
1486 glEnable(GL_TEXTURE_2D);
1489 sprintf (string, " ]");
1490 text.glPrint(10,30+screenheight-330,string,0,1,screenwidth,screenheight);
1492 sprintf (string, "_");
1493 text.glPrint(30+(float)(displayselected)*10,30+(screenheight-330),string,0,1,screenwidth,screenheight);
1497 if((i!=0||chatting)&&displaytime[i]<4)
1498 for(j=0;j<displaychars[i];j++){
1499 glColor4f(1,1,1,4-displaytime[i]);
1500 if(j<displaychars[i]){
1501 sprintf (string, "%c",displaytext[i][j]);
1502 text.glPrint(30+j*10,30+i*20+(screenheight-330),string,0,1,screenwidth,screenheight);
1508 if(minimap&&indialogue==-1){
1512 glDisable(GL_DEPTH_TEST);
1513 glColor3f (1.0, 1.0, 1.0); // no coloring
1515 glEnable(GL_TEXTURE_2D);
1516 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1517 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1518 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1519 glDisable(GL_CULL_FACE);
1520 glDisable(GL_LIGHTING);
1522 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1523 glPushMatrix(); // Store The Projection Matrix
1524 glLoadIdentity(); // Reset The Projection Matrix
1525 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1526 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1527 glPushMatrix(); // Store The Modelview Matrix
1528 glLoadIdentity(); // Reset The Modelview Matrix
1529 glScalef((float)screenwidth/2,(float)screenwidth/2,1);
1530 glTranslatef(1.75,.25,0);
1531 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1541 int numliveplayers=0;
1542 for(i=0;i<numplayers;i++){
1543 if(!player[i].dead)numliveplayers++;
1549 for(i=0;i<objects.numobjects;i++){
1550 if(objects.type[i]==treetrunktype||objects.type[i]==boxtype){
1551 center+=objects.position[i];
1555 for(i=0;i<numplayers;i++){
1556 if(!player[i].dead)center+=player[i].coords;
1558 center/=numadd+numliveplayers;
1560 center=player[0].coords;
1562 float maxdistance=0;
1565 for(i=0;i<objects.numobjects;i++){
1566 tempdist=findDistancefast(¢er,&objects.position[i]);
1567 if(tempdist>maxdistance){
1569 maxdistance=tempdist;
1572 for(i=0;i<numplayers;i++){
1573 if(!player[i].dead){
1574 tempdist=findDistancefast(¢er,&player[i].coords);
1575 if(tempdist>maxdistance){
1577 maxdistance=tempdist;
1581 radius=fast_sqrt(maxdistance);
1585 glScalef(.25/radius*256*terrain.scale*.4,.25/radius*256*terrain.scale*.4,1);
1587 glScalef(1/(1/radius*256*terrain.scale*.4),1/(1/radius*256*terrain.scale*.4),1);
1588 /*float startx,starty,endx,endy;
1590 glTexCoord2f(1-(center.x-radius)/terrain.scale/256,(center.z-radius)/terrain.scale/256);
1591 glVertex3f(-1, -1, 0.0f);
1592 glTexCoord2f(1-(center.x+radius)/terrain.scale/256,(center.z-radius)/terrain.scale/256);
1593 glVertex3f(1, -1, 0.0f);
1594 glTexCoord2f(1-(center.x+radius)/terrain.scale/256,(center.z+radius)/terrain.scale/256);
1595 glVertex3f(1, 1, 0.0f);
1596 glTexCoord2f(1-(center.x-radius)/terrain.scale/256,(center.z+radius)/terrain.scale/256);
1597 glVertex3f(-1, 1, 0.0f);
1600 glRotatef(player[0].lookrotation*-1+180,0,0,1);
1601 glTranslatef(-(center.x/terrain.scale/256*-2+1),(center.z/terrain.scale/256*-2+1),0);
1602 for(i=0;i<objects.numobjects;i++){
1603 if(objects.type[i]==treetrunktype){
1604 distcheck=findDistancefast(&player[0].coords,&objects.position[i]);
1605 if(distcheck<mapviewdist){
1606 glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
1607 glColor4f(0,.3,0,opac*(1-distcheck/mapviewdist));
1609 glTranslatef(objects.position[i].x/terrain.scale/256*-2+1,objects.position[i].z/terrain.scale/256*2-1,0);
1610 glRotatef(objects.rotation[i],0,0,1);
1611 glScalef(.003,.003,.003);
1614 glVertex3f(-1, -1, 0.0f);
1616 glVertex3f(1, -1, 0.0f);
1618 glVertex3f(1, 1, 0.0f);
1620 glVertex3f(-1, 1, 0.0f);
1625 if(objects.type[i]==boxtype){
1626 distcheck=findDistancefast(&player[0].coords,&objects.position[i]);
1627 if(distcheck<mapviewdist){
1628 glBindTexture( GL_TEXTURE_2D, Mapboxtexture);
1629 glColor4f(.4,.4,.4,opac*(1-distcheck/mapviewdist));
1631 glTranslatef(objects.position[i].x/terrain.scale/256*-2+1,objects.position[i].z/terrain.scale/256*2-1,0);
1632 glRotatef(objects.rotation[i],0,0,1);
1633 glScalef(.01*objects.scale[i],.01*objects.scale[i],.01*objects.scale[i]);
1636 glVertex3f(-1, -1, 0.0f);
1638 glVertex3f(1, -1, 0.0f);
1640 glVertex3f(1, 1, 0.0f);
1642 glVertex3f(-1, 1, 0.0f);
1649 glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
1650 for(i=0;i<numboundaries;i++){
1651 glColor4f(0,0,0,opac/3);
1653 glTranslatef(boundary[i].x/terrain.scale/256*-2+1,boundary[i].z/terrain.scale/256*2-1,0);
1654 glScalef(.002,.002,.002);
1657 glVertex3f(-1, -1, 0.0f);
1659 glVertex3f(1, -1, 0.0f);
1661 glVertex3f(1, 1, 0.0f);
1663 glVertex3f(-1, 1, 0.0f);
1668 for(i=0;i<numplayers;i++){
1669 distcheck=findDistancefast(&player[0].coords,&player[i].coords);
1670 if(distcheck<mapviewdist){
1672 glBindTexture( GL_TEXTURE_2D, Maparrowtexture);
1673 if(i==0)glColor4f(1,1,1,opac);
1674 else if(player[i].dead==2||player[i].howactive>typesleeping)glColor4f(0,0,0,opac*(1-distcheck/mapviewdist));
1675 else if(player[i].dead)glColor4f(.3,.3,.3,opac*(1-distcheck/mapviewdist));
1676 else if(player[i].aitype==attacktypecutoff)glColor4f(1,0,0,opac*(1-distcheck/mapviewdist));
1677 else if(player[i].aitype==passivetype)glColor4f(0,1,0,opac*(1-distcheck/mapviewdist));
1678 else glColor4f(1,1,0,1);
1679 glTranslatef(player[i].coords.x/terrain.scale/256*-2+1,player[i].coords.z/terrain.scale/256*2-1,0);
1680 glRotatef(player[i].rotation+180,0,0,1);
1681 glScalef(.005,.005,.005);
1684 glVertex3f(-1, -1, 0.0f);
1686 glVertex3f(1, -1, 0.0f);
1688 glVertex3f(1, 1, 0.0f);
1690 glVertex3f(-1, 1, 0.0f);
1692 /*glBegin(GL_TRIANGLES);
1694 glVertex3f(-1, -1, 0.0f);
1696 glVertex3f(1, -1, 0.0f);
1698 glVertex3f(0, 1, 0.0f);
1703 /*glBegin(GL_QUADS);
1705 glVertex3f(-1, -1, 0.0f);
1707 glVertex3f(1, -1, 0.0f);
1709 glVertex3f(1, 1, 0.0f);
1711 glVertex3f(-1, 1, 0.0f);
1714 glDisable(GL_TEXTURE_2D);
1715 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1716 glPopMatrix(); // Restore The Old Projection Matrix
1717 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1718 glPopMatrix(); // Restore The Old Projection Matrix
1719 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1720 glEnable(GL_CULL_FACE);
1721 glDisable(GL_BLEND);
1727 drawmode=normalmode;
1731 if(loading&&!stealthloading&&(!campaign||player[0].dead)){
1732 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1733 glDisable(GL_CULL_FACE);
1734 glDisable(GL_LIGHTING);
1735 glDisable(GL_TEXTURE_2D);
1737 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1738 glPushMatrix(); // Store The Projection Matrix
1739 glLoadIdentity(); // Reset The Projection Matrix
1740 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1741 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1742 glPushMatrix(); // Store The Modelview Matrix
1743 glLoadIdentity(); // Reset The Modelview Matrix
1744 glScalef(screenwidth,screenheight,1);
1745 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1747 glColor4f(0,0,0,.7);
1749 glVertex3f(0, 0, 0.0f);
1750 glVertex3f(256, 0, 0.0f);
1751 glVertex3f(256, 256, 0.0f);
1752 glVertex3f(0, 256, 0.0f);
1754 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1755 glPopMatrix(); // Restore The Old Projection Matrix
1756 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1757 glPopMatrix(); // Restore The Old Projection Matrix
1758 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1759 glEnable(GL_CULL_FACE);
1760 glDisable(GL_BLEND);
1764 glDisable(GL_DEPTH_TEST);
1765 glColor3f (1.0, 1.0, 1.0); // no coloring
1767 glEnable(GL_TEXTURE_2D);
1768 /*glBindTexture( GL_TEXTURE_2D, logotexture);
1769 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1770 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1771 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1772 glDisable(GL_CULL_FACE);
1773 glDisable(GL_LIGHTING);
1775 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1776 glPushMatrix(); // Store The Projection Matrix
1777 glLoadIdentity(); // Reset The Projection Matrix
1778 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1779 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1780 glPushMatrix(); // Store The Modelview Matrix
1781 glLoadIdentity(); // Reset The Modelview Matrix
1782 glScalef((float)screenwidth/2,(float)screenwidth/2,1);
1783 glTranslatef(1.8,1.25,0);
1784 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1788 glScalef(.25,.25,.25);
1791 glVertex3f(-1, -1, 0.0f);
1793 glVertex3f(1, -1, 0.0f);
1795 glVertex3f(1, 1, 0.0f);
1797 glVertex3f(-1, 1, 0.0f);
1800 glDisable(GL_TEXTURE_2D);
1801 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1802 glPopMatrix(); // Restore The Old Projection Matrix
1803 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1804 glPopMatrix(); // Restore The Old Projection Matrix
1805 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1806 glEnable(GL_CULL_FACE);
1807 glDisable(GL_BLEND);
1813 glEnable(GL_TEXTURE_2D);
1815 sprintf (string, "Loading...");
1816 text.glPrint(1024/2-90,768/2,string,1,2,1024,768);
1819 //if(ismotionblur)drawmode=motionblurmode;
1820 drawmode=normalmode;
1823 if(winfreeze&&!campaign){
1824 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1825 glDisable(GL_CULL_FACE);
1826 glDisable(GL_LIGHTING);
1827 glDisable(GL_TEXTURE_2D);
1829 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1830 glPushMatrix(); // Store The Projection Matrix
1831 glLoadIdentity(); // Reset The Projection Matrix
1832 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1833 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1834 glPushMatrix(); // Store The Modelview Matrix
1835 glLoadIdentity(); // Reset The Modelview Matrix
1836 glScalef(screenwidth,screenheight,1);
1837 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1839 glColor4f(0,0,0,.4);
1841 glVertex3f(0, 0, 0.0f);
1842 glVertex3f(256, 0, 0.0f);
1843 glVertex3f(256, 256, 0.0f);
1844 glVertex3f(0, 256, 0.0f);
1846 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1847 glPopMatrix(); // Restore The Old Projection Matrix
1848 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1849 glPopMatrix(); // Restore The Old Projection Matrix
1850 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1851 glEnable(GL_CULL_FACE);
1852 glDisable(GL_BLEND);
1856 glDisable(GL_DEPTH_TEST);
1857 glColor3f (1.0, 1.0, 1.0); // no coloring
1859 glEnable(GL_TEXTURE_2D);
1860 /*glBindTexture( GL_TEXTURE_2D, logotexture);
1861 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1862 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1863 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1864 glDisable(GL_CULL_FACE);
1865 glDisable(GL_LIGHTING);
1867 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1868 glPushMatrix(); // Store The Projection Matrix
1869 glLoadIdentity(); // Reset The Projection Matrix
1870 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1871 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1872 glPushMatrix(); // Store The Modelview Matrix
1873 glLoadIdentity(); // Reset The Modelview Matrix
1874 glScalef((float)screenwidth/2,(float)screenwidth/2,1);
1875 glTranslatef(1.8,1.25,0);
1876 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1880 glScalef(.25,.25,.25);
1883 glVertex3f(-1, -1, 0.0f);
1885 glVertex3f(1, -1, 0.0f);
1887 glVertex3f(1, 1, 0.0f);
1889 glVertex3f(-1, 1, 0.0f);
1892 glDisable(GL_TEXTURE_2D);
1893 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1894 glPopMatrix(); // Restore The Old Projection Matrix
1895 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1896 glPopMatrix(); // Restore The Old Projection Matrix
1897 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1898 glEnable(GL_CULL_FACE);
1899 glDisable(GL_BLEND);
1907 if(damagetaken==0&&player[0].bloodloss==0){
1908 awards[numawards]=awardflawless;
1914 for(i=1;i<numplayers;i++){
1915 if(player[i].dead!=2)alldead=0;
1918 awards[numawards]=awardalldead;
1923 for(i=1;i<numplayers;i++){
1924 if(player[i].dead!=1)alldead=0;
1927 awards[numawards]=awardnodead;
1930 if(numresponded==0&&!numthrowkill){
1931 awards[numawards]=awardstealth;
1934 if(numattacks==numstaffattack&&numattacks>0){
1935 awards[numawards]=awardbojutsu;
1938 if(numattacks==numswordattack&&numattacks>0){
1939 awards[numawards]=awardswordsman;
1942 if(numattacks==numknifeattack&&numattacks>0){
1943 awards[numawards]=awardknifefighter;
1946 if(numattacks==numunarmedattack&&numthrowkill==0&&weapons.numweapons>0){
1947 awards[numawards]=awardkungfu;
1951 awards[numawards]=awardevasion;
1954 if(numflipfail==0&&numflipped+numwallflipped*2>20){
1955 awards[numawards]=awardacrobat;
1958 if(numthrowkill==numplayers-1){
1959 awards[numawards]=awardlongrange;
1964 for(i=1;i<numplayers;i++){
1965 if(player[i].dead!=2)alldead=0;
1967 if(numafterkill>0&&alldead){
1968 awards[numawards]=awardbrutal;
1971 if(numreversals>((float)numattacks)*.8&&numreversals>3){
1972 awards[numawards]=awardaikido;
1975 if(maxalarmed==1&&numplayers>2){
1976 awards[numawards]=awardstrategy;
1980 awards[numawards]=awardklutz;
1985 //Win Screen Won Victory
1987 glEnable(GL_TEXTURE_2D);
1989 sprintf (string, "Level Cleared!");
1990 text.glPrintOutlined(1024/2-strlen(string)*10,768*7/8,string,1,2,1024,768);
1992 sprintf (string, "Score: %d",(int)(bonustotal-startbonustotal));
1993 text.glPrintOutlined(1024/30,768*6/8,string,1,2,1024,768);
1995 if(!campaign)sprintf (string, "Press Escape to return to menu or Space to continue");
1996 if(campaign)sprintf (string, "Press Escape or Space to continue");
1997 text.glPrintOutlined(640/2-strlen(string)*5,480*1/16,string,1,1,640,480);
2001 for(i=0;i<255;i++)string[i]='\0';
2002 sprintf (temp, "Time: %d:",(int)(((int)leveltime-(int)(leveltime)%60)/60));
2003 strcat(string,temp);
2004 if((int)(leveltime)%60<10)strcat(string,"0");
2005 sprintf (temp, "%d",(int)(leveltime)%60);
2006 strcat(string,temp);
2007 text.glPrintOutlined(1024/30,768*6/8-40,string,1,2,1024,768);
2009 for(i=0;i<numawards;i++){
2011 if(awards[i]==awardklutz)sprintf (string, "Suicidal");
2012 if(awards[i]==awardflawless)sprintf (string, "Flawless!");
2013 if(awards[i]==awardalldead)sprintf (string, "Take no prisoners");
2014 if(awards[i]==awardnodead)sprintf (string, "Merciful");
2015 if(awards[i]==awardstealth)sprintf (string, "One with the shadows!");
2016 if(awards[i]==awardswordsman)sprintf (string, "Swordsman");
2017 if(awards[i]==awardkungfu)sprintf (string, "Unarmed!");
2018 if(awards[i]==awardknifefighter)sprintf (string, "Knife fighter");
2019 if(awards[i]==awardcoward)sprintf (string, "Coward");
2020 if(awards[i]==awardevasion)sprintf (string, "Escape artist");
2021 if(awards[i]==awardacrobat)sprintf (string, "Gymnast");
2022 if(awards[i]==awardlongrange)sprintf (string, "Blade slinger");
2023 if(awards[i]==awardbrutal)sprintf (string, "Brutal");
2024 if(awards[i]==awardhyper)sprintf (string, "Hyper");
2025 if(awards[i]==awardaikido)sprintf (string, "Aikido master!");
2026 if(awards[i]==awardrambo)sprintf (string, "Rambo");
2027 if(awards[i]==awardfast)sprintf (string, "Fast");
2028 if(awards[i]==awardrealfast)sprintf (string, "Real fast");
2029 if(awards[i]==awarddamnfast)sprintf (string, "Damn fast");
2030 if(awards[i]==awardstrategy)sprintf (string, "Divide and conquer");
2031 if(awards[i]==awardbojutsu)sprintf (string, "Bojutsu");
2032 text.glPrintOutlined(1024/30,768*6/8-90-40*i,string,1,2,1024,768);
2036 //drawmode=normalmode;
2039 if(drawmode!=normalmode){
2040 glEnable(GL_TEXTURE_2D);
2042 if(!drawtoggle||drawmode!=realmotionblurmode||(drawtoggle==2||change==1)){
2045 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
2046 GLfloat subtractColor[4] = { 0.5, 0.5, 0.5, 0.0 };
2047 glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, subtractColor);
2048 //glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_SUBTRACT);
2049 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE);
2050 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_CONSTANT_EXT);
2051 glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 2.0f);
2053 glBindTexture( GL_TEXTURE_2D, screentexture);
2054 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
2057 if((drawtoggle||change==1)&&drawmode==realmotionblurmode){
2059 glBindTexture( GL_TEXTURE_2D, screentexture2);
2060 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
2062 if(!screentexture2){
2063 glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
2065 glGenTextures( 1, &screentexture2 );
2066 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
2068 glEnable(GL_TEXTURE_2D);
2069 glBindTexture( GL_TEXTURE_2D, screentexture2);
2070 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
2071 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
2073 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
2079 glClear(GL_DEPTH_BUFFER_BIT);
2080 ReSizeGLScene(90,.1f);
2081 glViewport(0,0,screenwidth,screenheight);
2083 if(drawmode!=normalmode){
2084 glDisable(GL_DEPTH_TEST);
2085 if(drawmode==motionblurmode){
2086 glDrawBuffer(GL_FRONT);
2087 glReadBuffer(GL_BACK);
2088 //myassert(glGetError() == GL_NO_ERROR);
2091 glColor3f (1.0, 1.0, 1.0); // no coloring
2093 glEnable(GL_TEXTURE_2D);
2094 glBindTexture( GL_TEXTURE_2D, screentexture);
2095 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
2096 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
2097 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
2098 glDisable(GL_CULL_FACE);
2099 glDisable(GL_LIGHTING);
2101 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2102 glPushMatrix(); // Store The Projection Matrix
2103 glLoadIdentity(); // Reset The Projection Matrix
2104 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
2105 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2106 glPushMatrix(); // Store The Modelview Matrix
2107 glLoadIdentity(); // Reset The Modelview Matrix
2108 glScalef((float)screenwidth/2,(float)screenheight/2,1);
2109 glTranslatef(1,1,0);
2110 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
2112 if(drawmode==motionblurmode){
2113 if(motionbluramount<.2)motionbluramount=.2;
2114 //glColor4f(1,1,1,fast_sqrt(multiplier)*2.9*motionbluramount);
2115 glColor4f(1,1,1,motionbluramount);
2119 glVertex3f(-1, -1, 0.0f);
2120 glTexCoord2f(texcoordwidth,0);
2121 glVertex3f(1, -1, 0.0f);
2122 glTexCoord2f(texcoordwidth,texcoordheight);
2123 glVertex3f(1, 1, 0.0f);
2124 glTexCoord2f(0,texcoordheight);
2125 glVertex3f(-1, 1, 0.0f);
2129 if(drawmode==realmotionblurmode){
2130 glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
2131 glClear(GL_COLOR_BUFFER_BIT);
2132 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
2133 glBindTexture( GL_TEXTURE_2D, screentexture);
2134 glColor4f(1,1,1,.5);
2138 glVertex3f(-1, -1, 0.0f);
2139 glTexCoord2f(texcoordwidth,0);
2140 glVertex3f(1, -1, 0.0f);
2141 glTexCoord2f(texcoordwidth,texcoordheight);
2142 glVertex3f(1, 1, 0.0f);
2143 glTexCoord2f(0,texcoordheight);
2144 glVertex3f(-1, 1, 0.0f);
2147 glBindTexture( GL_TEXTURE_2D, screentexture2);
2148 glColor4f(1,1,1,.5);
2152 glVertex3f(-1, -1, 0.0f);
2153 glTexCoord2f(texcoordwidth,0);
2154 glVertex3f(1, -1, 0.0f);
2155 glTexCoord2f(texcoordwidth,texcoordheight);
2156 glVertex3f(1, 1, 0.0f);
2157 glTexCoord2f(0,texcoordheight);
2158 glVertex3f(-1, 1, 0.0f);
2161 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
2163 if(drawmode==doublevisionmode){
2164 static float crosseyedness;
2165 crosseyedness=abs(player[0].damage-player[0].superpermanentdamage-(player[0].damagetolerance-player[0].superpermanentdamage)*1/2)/30;
2166 if(crosseyedness>1)crosseyedness=1;
2167 if(crosseyedness<0)crosseyedness=0;
2169 glDisable(GL_BLEND);
2174 glVertex3f(-1, -1, 0.0f);
2175 glTexCoord2f(texcoordwidth,0);
2176 glVertex3f(1, -1, 0.0f);
2177 glTexCoord2f(texcoordwidth,texcoordheight);
2178 glVertex3f(1, 1, 0.0f);
2179 glTexCoord2f(0,texcoordheight);
2180 glVertex3f(-1, 1, 0.0f);
2184 glColor4f(1,1,1,.5);
2187 glTranslatef(.015*crosseyedness,0,0);
2191 glVertex3f(-1, -1, 0.0f);
2192 glTexCoord2f(texcoordwidth,0);
2193 glVertex3f(1, -1, 0.0f);
2194 glTexCoord2f(texcoordwidth,texcoordheight);
2195 glVertex3f(1, 1, 0.0f);
2196 glTexCoord2f(0,texcoordheight);
2197 glVertex3f(-1, 1, 0.0f);
2202 if(drawmode==glowmode){
2203 glColor4f(.5,.5,.5,.5);
2205 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
2207 glTranslatef(.01,0,0);
2210 glVertex3f(-1, -1, 0.0f);
2211 glTexCoord2f(texcoordwidth,0);
2212 glVertex3f(1, -1, 0.0f);
2213 glTexCoord2f(texcoordwidth,texcoordheight);
2214 glVertex3f(1, 1, 0.0f);
2215 glTexCoord2f(0,texcoordheight);
2216 glVertex3f(-1, 1, 0.0f);
2220 glTranslatef(-.01,0,0);
2223 glVertex3f(-1, -1, 0.0f);
2224 glTexCoord2f(texcoordwidth,0);
2225 glVertex3f(1, -1, 0.0f);
2226 glTexCoord2f(texcoordwidth,texcoordheight);
2227 glVertex3f(1, 1, 0.0f);
2228 glTexCoord2f(0,texcoordheight);
2229 glVertex3f(-1, 1, 0.0f);
2233 glTranslatef(.0,.01,0);
2236 glVertex3f(-1, -1, 0.0f);
2237 glTexCoord2f(texcoordwidth,0);
2238 glVertex3f(1, -1, 0.0f);
2239 glTexCoord2f(texcoordwidth,texcoordheight);
2240 glVertex3f(1, 1, 0.0f);
2241 glTexCoord2f(0,texcoordheight);
2242 glVertex3f(-1, 1, 0.0f);
2246 glTranslatef(0,-.01,0);
2249 glVertex3f(-1, -1, 0.0f);
2250 glTexCoord2f(texcoordwidth,0);
2251 glVertex3f(1, -1, 0.0f);
2252 glTexCoord2f(texcoordwidth,texcoordheight);
2253 glVertex3f(1, 1, 0.0f);
2254 glTexCoord2f(0,texcoordheight);
2255 glVertex3f(-1, 1, 0.0f);
2259 if(drawmode==radialzoommode){
2261 //glRotatef((float)i*.1,0,0,1);
2262 glColor4f(1,1,1,1/((float)i+1));
2264 glScalef(1+(float)i*.01,1+(float)i*.01,1);
2267 glVertex3f(-1, -1, 0.0f);
2268 glTexCoord2f(texcoordwidth,0);
2269 glVertex3f(1, -1, 0.0f);
2270 glTexCoord2f(texcoordwidth,texcoordheight);
2271 glVertex3f(1, 1, 0.0f);
2272 glTexCoord2f(0,texcoordheight);
2273 glVertex3f(-1, 1, 0.0f);
2278 glDisable(GL_TEXTURE_2D);
2279 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2280 glPopMatrix(); // Restore The Old Projection Matrix
2281 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2282 glPopMatrix(); // Restore The Old Projection Matrix
2283 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
2284 glEnable(GL_CULL_FACE);
2285 glDisable(GL_BLEND);
2290 glEnable(GL_TEXTURE_2D);
2295 if(consoleselected>=60)offset=consoleselected-60;
2296 sprintf (string, " ]");
2297 text.glPrint(10,30,string,0,1,1024,768);
2299 sprintf (string, "_");
2300 text.glPrint(30+(float)(consoleselected)*10-offset*10,30,string,0,1,1024,768);
2303 for(j=0;j<consolechars[i];j++){
2304 glColor4f(1,1,1,1-(float)(i)/16);
2305 if(j<consolechars[i]){
2306 sprintf (string, "%c",consoletext[i][j]);
2307 text.glPrint(30+j*10-offset*10,30+i*20,string,0,1,1024,768);
2315 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)||(mainmenu&&gameon)||(!gameon&&gamestarted)||(!gameon&&gamestarted)){
2316 multiplier=tempmult;
2321 // !!! FIXME: hack: clamp framerate in menu so text input works correctly on fast systems.
2324 glDrawBuffer(GL_BACK);
2325 glReadBuffer(GL_BACK);
2326 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
2327 ReSizeGLScene(90,.1f);
2330 temptexdetail=texdetail;
2331 if(texdetail>2)texdetail=2;
2332 if(mainmenu!=oldmainmenu&&oldmainmenu!=0){
2334 LoadTexture(":Data:Textures:Newgame.png",&Mainmenuitems[1],0,0);
2335 LoadTexture(":Data:Textures:Quit.png",&Mainmenuitems[3],0,0);
2336 /*if(oldmainmenu==1||oldmainmenu==0){
2337 LoadTexture(":Data:Textures:World.png",&Mainmenuitems[7],0,0);
2338 LoadTexture(":Data:Textures:Options.png",&Mainmenuitems[2],0,0);
2339 LoadTexture(":Data:Textures:Lugaru.png",&Mainmenuitems[0],0,0);
2344 LoadTexture(":Data:Textures:Resume.png",&Mainmenuitems[1],0,0);
2345 LoadTexture(":Data:Textures:Endgame.png",&Mainmenuitems[3],0,0);
2346 /*if(oldmainmenu==2||oldmainmenu==0){
2347 LoadTexture(":Data:Textures:World.png",&Mainmenuitems[7],0,0);
2348 LoadTexture(":Data:Textures:Options.png",&Mainmenuitems[2],0,0);
2349 LoadTexture(":Data:Textures:Lugaru.png",&Mainmenuitems[0],0,0);
2354 if(lastcheck>.5||oldmainmenu!=mainmenu){
2356 ifstream ipstream(ConvertFileName(":Data:Campaigns:main.txt"));
2357 //campaignnumlevels=0;
2358 //accountcampaignchoicesmade[accountactive]=0;
2359 ipstream.ignore(256,':');
2360 ipstream >> campaignnumlevels;
2361 for(i=0;i<campaignnumlevels;i++){
2362 ipstream.ignore(256,':');
2363 ipstream.ignore(256,':');
2364 ipstream.ignore(256,' ');
2365 ipstream >> campaignmapname[i];
2366 ipstream.ignore(256,':');
2367 ipstream >> campaigndescription[i];
2369 if(campaigndescription[i][j]=='_')campaigndescription[i][j]=' ';
2371 ipstream.ignore(256,':');
2372 ipstream >> campaignchoosenext[i];
2373 ipstream.ignore(256,':');
2374 ipstream >> campaignnumnext[i];
2375 if(campaignnumnext[i])
2376 for(j=0;j<campaignnumnext[i];j++){
2377 ipstream.ignore(256,':');
2378 ipstream >> campaignnextlevel[i][j];
2379 campaignnextlevel[i][j]-=1;
2381 ipstream.ignore(256,':');
2382 ipstream >> campaignlocationx[i];
2383 //campaignlocationx[i]-=30;
2384 ipstream.ignore(256,':');
2385 ipstream >> campaignlocationy[i];
2386 //campaignlocationy[i]+=30;
2390 for(i=0;i<campaignnumlevels;i++){
2392 levelhighlight[i]=0;
2397 if(accountcampaignchoicesmade[accountactive])
2398 for(i=0;i<accountcampaignchoicesmade[accountactive];i++){
2399 levelorder[i+1]=campaignnextlevel[levelorder[i]][accountcampaignchoices[accountactive][i]];
2400 levelvisible[levelorder[i+1]]=1;
2402 int whichlevelstart;
2403 whichlevelstart=accountcampaignchoicesmade[accountactive]-1;
2404 if(whichlevelstart<0){
2405 accountcampaignscore[accountactive]=0;
2406 accountcampaignfasttime[accountactive]=0;
2407 campaignchoicenum=1;
2408 campaignchoicewhich[0]=0;
2412 campaignchoicenum=campaignnumnext[levelorder[whichlevelstart]];
2413 if(campaignchoicenum==0){
2414 if(accountcampaignscore[accountactive]>accountcampaignhighscore[accountactive])accountcampaignhighscore[accountactive]=accountcampaignscore[accountactive];
2415 if(accountcampaignfasttime[accountactive]==0||accountcampaigntime[accountactive]<accountcampaignfasttime[accountactive])accountcampaignfasttime[accountactive]=accountcampaigntime[accountactive];
2417 if(campaignchoicenum)
2418 for(i=0;i<campaignchoicenum;i++){
2419 campaignchoicewhich[i]=campaignnextlevel[levelorder[whichlevelstart]][i];
2420 levelvisible[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
2421 levelhighlight[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
2434 texdetail=temptexdetail;
2436 /*if(mainmenu!=0)*/oldmainmenu=mainmenu;
2438 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){
2439 glClear(GL_DEPTH_BUFFER_BIT);
2440 glEnable(GL_ALPHA_TEST);
2441 glAlphaFunc(GL_GREATER, 0.001f);
2442 glEnable(GL_TEXTURE_2D);
2443 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
2444 glDisable(GL_CULL_FACE);
2445 glDisable(GL_LIGHTING);
2447 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2448 glPushMatrix(); // Store The Projection Matrix
2449 glLoadIdentity(); // Reset The Projection Matrix
2450 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
2451 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2452 glPushMatrix(); // Store The Modelview Matrix
2453 glLoadIdentity(); // Reset The Modelview Matrix
2454 glTranslatef(screenwidth/2,screenheight/2,0);
2456 glScalef((float)screenwidth/2,(float)screenheight/2,1);
2457 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
2458 glDisable(GL_BLEND);
2459 glColor4f(0,0,0,1.0);
2460 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2461 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2462 glDisable(GL_TEXTURE_2D);
2464 //glScalef(.25,.25,.25);
2467 glVertex3f(-1, -1, 0.0f);
2469 glVertex3f(1, -1, 0.0f);
2471 glVertex3f(1, 1, 0.0f);
2473 glVertex3f(-1, 1, 0.0f);
2477 glColor4f(0.4,0.4,0.4,1.0);
2478 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2479 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2480 glEnable(GL_TEXTURE_2D);
2481 glBindTexture( GL_TEXTURE_2D, Mainmenuitems[4]);
2483 //glScalef(.25,.25,.25);
2486 glVertex3f(-1, -1, 0.0f);
2488 glVertex3f(1, -1, 0.0f);
2490 glVertex3f(1, 1, 0.0f);
2492 glVertex3f(-1, 1, 0.0f);
2497 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2499 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2503 if((float)newscreenwidth>(float)newscreenheight*1.61||(float)newscreenwidth<(float)newscreenheight*1.59)sprintf (menustring[0], "Resolution: %d*%d",(int)newscreenwidth,(int)newscreenheight);
2504 else sprintf (menustring[0], "Resolution: %d*%d (widescreen)",(int)newscreenwidth,(int)newscreenheight);
2507 endx[0]=startx[0]+strlen(menustring[0])*10;
2508 endy[0]=starty[0]+20;
2512 if(newdetail==2)sprintf (menustring[1], "Detail: High");
2513 else if(newdetail==1)sprintf (menustring[1], "Detail: Medium");
2514 else sprintf (menustring[1], "Detail: Low");
2517 endx[1]=startx[1]+strlen(menustring[1])*10;
2518 endy[1]=starty[1]+20;
2522 if(bloodtoggle==2)sprintf (menustring[2], "Blood: On, high detail (slower)");
2523 if(bloodtoggle==1)sprintf (menustring[2], "Blood: On, low detail");
2524 if(bloodtoggle==0)sprintf (menustring[2], "Blood: Off");
2527 endx[2]=startx[2]+strlen(menustring[2])*10;
2528 endy[2]=starty[2]+20;
2532 if(difficulty==2)sprintf (menustring[3], "Difficulty: Insane");
2533 if(difficulty==1)sprintf (menustring[3], "Difficulty: Difficult");
2534 if(difficulty==0)sprintf (menustring[3], "Difficulty: Easier");
2535 startx[3]=10+20-1000;
2537 endx[3]=startx[3]+strlen(menustring[3])*10;
2538 endy[3]=starty[3]+20;
2542 if(ismotionblur==1)sprintf (menustring[4], "Blur Effects: Enabled (less compatible)");
2543 if(ismotionblur==0)sprintf (menustring[4], "Blur Effects: Disabled (more compatible)");
2546 endx[4]=startx[4]+strlen(menustring[4])*10;
2547 endy[4]=starty[4]+20;
2551 if(decals==1)sprintf (menustring[5], "Decals: Enabled (slower)");
2552 if(decals==0)sprintf (menustring[5], "Decals: Disabled");
2555 endx[5]=startx[5]+strlen(menustring[5])*10;
2556 endy[5]=starty[5]+20;
2560 if(musictoggle==1)sprintf (menustring[6], "Music: Enabled");
2561 if(musictoggle==0)sprintf (menustring[6], "Music: Disabled");
2564 endx[6]=startx[6]+strlen(menustring[6])*10;
2565 endy[6]=starty[6]+20;
2569 if(invertmouse==1)sprintf (menustring[9], "Invert mouse: Yes");
2570 if(invertmouse==0)sprintf (menustring[9], "Invert mouse: No");
2573 endx[9]=startx[9]+strlen(menustring[9])*10;
2574 endy[9]=starty[9]+20;
2578 sprintf (menustring[10], "Mouse Speed: %d", (int)(usermousesensitivity*5));
2581 endx[10]=startx[10]+strlen(menustring[10])*10;
2582 endy[10]=starty[10]+20;
2586 sprintf (menustring[11], "Volume: %d%%", (int)(volume*100));
2589 endx[11]=startx[11]+strlen(menustring[11])*10;
2590 endy[11]=starty[11]+20;
2594 sprintf (menustring[13], "Damage Bar: %s",(showdamagebar?"on":"off"));
2597 endx[13]=startx[13]+strlen(menustring[13])*10;
2598 endy[13]=starty[13]+20;
2602 sprintf (menustring[7], "-Configure Controls-");
2605 endx[7]=startx[7]+strlen(menustring[7])*10;
2606 endy[7]=starty[7]+20;
2610 sprintf (menustring[12], "-Configure Stereo -");
2613 endx[12]=startx[12]+strlen(menustring[7])*10;
2614 endy[12]=starty[12]+20;
2618 if(newdetail==detail&&newscreenheight==(int)screenheight&&newscreenwidth==(int)screenwidth)sprintf (menustring[8], "Back");
2619 else sprintf (menustring[8], "Back (some changes take effect next time Lugaru is opened)");
2621 endx[8]=startx[8]+strlen(menustring[8])*10;
2623 endy[8]=starty[8]+20;
2630 if(keyselect!=0)sprintf (menustring[0], "Forwards: %s",KeyToChar(forwardkey));
2631 else sprintf (menustring[0], "Forwards: _");
2634 endx[0]=startx[0]+strlen(menustring[0])*10;
2635 endy[0]=starty[0]+20;
2639 if(keyselect!=1)sprintf (menustring[1], "Back: %s",KeyToChar(backkey));
2640 else sprintf (menustring[1], "Back: _");
2643 endx[1]=startx[1]+strlen(menustring[1])*10;
2644 endy[1]=starty[1]+20;
2648 if(keyselect!=2)sprintf (menustring[2], "Left: %s",KeyToChar(leftkey));
2649 else sprintf (menustring[2], "Left: _");
2652 endx[2]=startx[2]+strlen(menustring[2])*10;
2653 endy[2]=starty[2]+20;
2657 if(keyselect!=3)sprintf (menustring[3], "Right: %s",KeyToChar(rightkey));
2658 else sprintf (menustring[3], "Right: _");
2661 endx[3]=startx[3]+strlen(menustring[3])*10;
2662 endy[3]=starty[3]+20;
2666 if(keyselect!=4)sprintf (menustring[4], "Crouch: %s",KeyToChar(crouchkey));
2667 else sprintf (menustring[4], "Crouch: _");
2670 endx[4]=startx[4]+strlen(menustring[4])*10;
2671 endy[4]=starty[4]+20;
2675 if(keyselect!=5)sprintf (menustring[5], "Jump: %s",KeyToChar(jumpkey));
2676 else sprintf (menustring[5], "Jump: _");
2679 endx[5]=startx[5]+strlen(menustring[5])*10;
2680 endy[5]=starty[5]+20;
2684 if(keyselect!=6)sprintf (menustring[6], "Draw: %s",KeyToChar(drawkey));
2685 else sprintf (menustring[6], "Draw: _");
2688 endx[6]=startx[6]+strlen(menustring[6])*10;
2689 endy[6]=starty[6]+20;
2693 if(keyselect!=7)sprintf (menustring[7], "Throw: %s",KeyToChar(throwkey));
2694 else sprintf (menustring[7], "Throw: _");
2697 endx[7]=startx[7]+strlen(menustring[7])*10;
2698 endy[7]=starty[7]+20;
2702 if(keyselect!=8)sprintf (menustring[8], "Attack: %s",KeyToChar(attackkey));
2703 else sprintf (menustring[8], "Attack: _");
2706 endx[8]=startx[8]+strlen(menustring[8])*10;
2707 endy[8]=starty[8]+20;
2713 sprintf (menustring[9], "Back");
2715 endx[9]=startx[9]+strlen(menustring[9])*10;
2717 endy[9]=starty[9]+20;
2722 nummenuitems=7+accountcampaignchoicesmade[accountactive]+campaignchoicenum;
2724 sprintf (menustring[0], "%s",accountname[accountactive]);
2727 endx[0]=startx[0]+strlen(menustring[0])*10;
2728 endy[0]=starty[0]+20;
2732 sprintf (menustring[1], "Tutorial");
2735 endx[1]=startx[1]+strlen(menustring[1])*10;
2736 endy[1]=starty[1]+20;
2740 sprintf (menustring[2], "Challenge");
2743 endx[2]=startx[2]+strlen(menustring[2])*10;
2744 endy[2]=starty[2]+20;
2748 sprintf (menustring[3], "Delete User");
2751 endx[3]=startx[3]+strlen(menustring[3])*10;
2752 endy[3]=starty[3]+20;
2756 sprintf (menustring[4], "Main Menu");
2759 endx[4]=startx[4]+strlen(menustring[4])*10;
2760 endy[4]=starty[4]+20;
2764 sprintf (menustring[5], "Change User");
2766 endx[5]=startx[5]+strlen(menustring[5])*10;
2768 endy[5]=starty[5]+20;
2774 sprintf (menustring[6], "World");
2776 starty[6]=30+480-400-50;
2777 endx[6]=startx[6]+400;
2782 if(accountcampaignchoicesmade[accountactive])
2783 for(i=0;i<accountcampaignchoicesmade[accountactive];i++){
2784 sprintf (menustring[7+i], "%s", campaigndescription[levelorder[i]]);
2785 startx[7+i]=30+120+campaignlocationx[levelorder[i]]*400/512;
2786 starty[7+i]=30+30+(512-campaignlocationy[levelorder[i]])*400/512;
2787 endx[7+i]=startx[7+i]+10;
2788 endy[7+i]=starty[7+i]+10;
2793 if(campaignchoicenum>0)
2794 for(i=accountcampaignchoicesmade[accountactive];i<accountcampaignchoicesmade[accountactive]+campaignchoicenum;i++){
2795 sprintf (menustring[7+i], "%s", campaigndescription[levelorder[i]]);
2796 startx[7+i]=30+120+campaignlocationx[campaignchoicewhich[i-(accountcampaignchoicesmade[accountactive])]]*400/512;
2797 starty[7+i]=30+30+(512-campaignlocationy[campaignchoicewhich[i-(accountcampaignchoicesmade[accountactive])]])*400/512;
2798 endx[7+i]=startx[7+i]+10;
2799 endy[7+i]=starty[7+i]+10;
2804 /*sprintf (menustring[7], "Dot");
2805 startx[7]=120+260*400/512;
2806 starty[7]=30+(512-184)*400/512;
2807 endx[7]=startx[7]+10;
2808 endy[7]=starty[7]+10;
2812 sprintf (menustring[8], "Dot");
2813 startx[8]=120+129*400/512;
2814 starty[8]=30+(512-284)*400/512;
2815 endx[8]=startx[8]+10;
2816 endy[8]=starty[8]+10;
2820 sprintf (menustring[9], "Dot");
2821 startx[9]=120+358*400/512;
2822 starty[9]=30+(512-235)*400/512;
2823 endx[9]=startx[9]+10;
2824 endy[9]=starty[9]+10;
2828 sprintf (menustring[10], "Dot");
2829 startx[10]=120+359*400/512;
2830 starty[10]=30+(512-308)*400/512;
2831 endx[10]=startx[10]+10;
2832 endy[10]=starty[10]+10;
2836 sprintf (menustring[11], "Dot");
2837 startx[11]=120+288*400/512;
2838 starty[11]=30+(512-277)*400/512;
2839 endx[11]=startx[11]+10;
2840 endy[11]=starty[11]+10;
2848 sprintf (menustring[0], "Are you sure you want to delete this user?");
2851 endx[0]=startx[0]+strlen(menustring[0])*10;
2852 endy[0]=starty[0]+20;
2856 sprintf (menustring[1], "Yes");
2859 endx[1]=startx[1]+strlen(menustring[1])*10;
2860 endy[1]=starty[1]+20;
2864 sprintf (menustring[2], "No");
2867 endx[2]=startx[2]+strlen(menustring[2])*10;
2868 endy[2]=starty[2]+20;
2872 sprintf (menustring[3], "Extra 4");
2875 endx[3]=startx[3]+strlen(menustring[3])*10;
2876 endy[3]=starty[3]+20;
2880 sprintf (menustring[4], "Extra 5");
2883 endx[4]=startx[4]+strlen(menustring[4])*10;
2884 endy[4]=starty[4]+20;
2888 sprintf (menustring[5], "Back");
2890 endx[5]=startx[5]+strlen(menustring[5])*10;
2892 endy[5]=starty[5]+20;
2898 nummenuitems=numaccounts+2;
2903 sprintf (menustring[0], "New User");
2905 sprintf (menustring[0], "No More Users");
2908 endx[0]=startx[0]+strlen(menustring[0])*10;
2909 endy[0]=starty[0]+20;
2913 if(entername)startx[0]+=10;
2918 for(i=0;i<numaccounts;i++){
2919 sprintf (menustring[num], "%s",accountname[i]);
2921 starty[num]=360-20-20*num;
2922 endx[num]=startx[num]+strlen(menustring[num])*10;
2923 endy[num]=starty[num]+20;
2930 sprintf (menustring[num], "Back");
2932 endx[num]=startx[num]+strlen(menustring[num])*10;
2934 endy[num]=starty[num]+20;
2941 sprintf (menustring[0], "Easier");
2944 endx[0]=startx[0]+strlen(menustring[0])*10;
2945 endy[0]=starty[0]+20;
2949 sprintf (menustring[1], "Difficult");
2952 endx[1]=startx[1]+strlen(menustring[1])*10;
2953 endy[1]=starty[1]+20;
2957 sprintf (menustring[2], "Insane");
2960 endx[2]=startx[2]+strlen(menustring[2])*10;
2961 endy[2]=starty[2]+20;
2967 //tempncl=numchallengelevels;
2968 //numchallengelevels=9;
2969 nummenuitems=2+numchallengelevels;
2972 for(j=0;j<numchallengelevels;j++){
2973 for(i=0;i<255;i++)menustring[j][i]='\0';
2974 sprintf (temp, "Level %d",j+1);
2975 strcpy(menustring[j],temp);
2976 for(i=0;i<17;i++)if(menustring[j][i]=='\0')menustring[j][i]=' ';
2977 menustring[j][17]='\0';
2978 sprintf (temp, "%d",(int)accounthighscore[accountactive][j]);
2979 strcat(menustring[j],temp);
2980 for(i=18;i<32;i++)if(menustring[j][i]=='\0')menustring[j][i]=' ';
2981 menustring[j][32]='\0';
2982 sprintf (temp, "%d:",(int)(((int)accountfasttime[accountactive][j]-(int)(accountfasttime[accountactive][j])%60)/60));
2983 strcat(menustring[j],temp);
2984 if((int)(accountfasttime[accountactive][j])%60<10)strcat(menustring[j],"0");
2985 sprintf (temp, "%d",(int)(accountfasttime[accountactive][j])%60);
2986 strcat(menustring[j],temp);
2990 endx[j]=startx[j]+strlen(menustring[j])*10;
2991 endy[j]=starty[j]+20;
2996 sprintf (menustring[numchallengelevels], "Back");
2997 startx[numchallengelevels]=10;
2998 endx[numchallengelevels]=startx[numchallengelevels]+strlen(menustring[numchallengelevels])*10;
2999 starty[numchallengelevels]=10;
3000 endy[numchallengelevels]=starty[numchallengelevels]+20;
3001 movex[numchallengelevels]=0;
3002 movey[numchallengelevels]=0;
3004 sprintf (menustring[numchallengelevels+1], " High Score Best Time");
3005 startx[numchallengelevels+1]=10;
3006 starty[numchallengelevels+1]=440;
3007 endx[numchallengelevels+1]=startx[numchallengelevels+1]+strlen(menustring[numchallengelevels+1])*10;
3008 endy[numchallengelevels+1]=starty[numchallengelevels+1]+20;
3009 movex[numchallengelevels+1]=0;
3010 movey[numchallengelevels+1]=0;
3012 //numchallengelevels=tempncl;
3016 nummenuitems=2+numchallengelevels;
3019 for(j=0;j<numchallengelevels;j++){
3020 for(i=0;i<255;i++)menustring[j][i]='\0';
3021 sprintf (temp, "Level %d",j+1);
3022 strcpy(menustring[j],temp);
3023 for(i=0;i<17;i++)if(menustring[j][i]=='\0')menustring[j][i]=' ';
3024 menustring[j][17]='\0';
3025 sprintf (temp, "%d",(int)accounthighscore[accountactive][j]);
3026 strcat(menustring[j],temp);
3027 for(i=18;i<32;i++)if(menustring[j][i]=='\0')menustring[j][i]=' ';
3028 menustring[j][32]='\0';
3029 sprintf (temp, "%d:",(int)(((int)accountfasttime[accountactive][j]-(int)(accountfasttime[accountactive][j])%60)/60));
3030 strcat(menustring[j],temp);
3031 if((int)(accountfasttime[accountactive][j])%60<10)strcat(menustring[j],"0");
3032 sprintf (temp, "%d",(int)(accountfasttime[accountactive][j])%60);
3033 strcat(menustring[j],temp);
3037 endx[j]=startx[j]+strlen(menustring[j])*10;
3038 endy[j]=starty[j]+20;
3043 sprintf (menustring[numchallengelevels], "Back");
3044 startx[numchallengelevels]=10;
3045 endx[numchallengelevels]=startx[numchallengelevels]+strlen(menustring[numchallengelevels])*10;
3046 starty[numchallengelevels]=10;
3047 endy[numchallengelevels]=starty[numchallengelevels]+20;
3048 movex[numchallengelevels]=0;
3049 movey[numchallengelevels]=0;
3051 sprintf (menustring[numchallengelevels+1], " High Score Best Time");
3052 startx[numchallengelevels+1]=10;
3053 starty[numchallengelevels+1]=400;
3054 endx[numchallengelevels+1]=startx[numchallengelevels+1]+strlen(menustring[numchallengelevels+1])*10;
3055 endy[numchallengelevels+1]=starty[numchallengelevels+1]+20;
3056 movex[numchallengelevels+1]=0;
3057 movey[numchallengelevels+1]=0;
3064 sprintf (menustring[0], "Congratulations!");
3067 endx[0]=startx[0]+strlen(menustring[0])*10;
3068 endy[0]=starty[0]+20;
3072 sprintf (menustring[1], "You have avenged your family and");
3075 endx[1]=startx[1]+strlen(menustring[1])*10;
3076 endy[1]=starty[1]+20;
3080 sprintf (menustring[2], "restored peace to the island of Lugaru.");
3083 endx[2]=startx[2]+strlen(menustring[2])*10;
3084 endy[2]=starty[2]+20;
3088 sprintf (menustring[3], "Back");
3090 endx[3]=startx[3]+strlen(menustring[3])*10;
3092 endy[3]=starty[3]+20;
3096 for(i=0;i<255;i++)menustring[4][i]='\0';
3097 sprintf (temp, "Your score:");
3098 strcpy(menustring[4],temp);
3099 for(i=0;i<20;i++)if(menustring[4][i]=='\0')menustring[4][i]=' ';
3100 menustring[4][20]='\0';
3101 sprintf (temp, "%d",(int)accountcampaignscore[accountactive]);
3102 strcat(menustring[4],temp);
3104 endx[4]=startx[4]+strlen(menustring[4])*10;
3106 endy[4]=starty[4]+20;
3110 for(i=0;i<255;i++)menustring[5][i]='\0';
3111 sprintf (temp, "Your time:");
3112 strcpy(menustring[5],temp);
3113 for(i=0;i<20;i++)if(menustring[5][i]=='\0')menustring[5][i]=' ';
3114 menustring[5][20]='\0';
3115 sprintf (temp, "%d",(int)accountcampaigntime[accountactive]);
3116 strcat(menustring[5],temp);
3118 endx[5]=startx[5]+strlen(menustring[5])*10;
3120 endy[5]=starty[5]+20;
3124 for(i=0;i<255;i++)menustring[5][i]='\0';
3125 sprintf (temp, "Highest score:");
3126 strcpy(menustring[5],temp);
3127 for(i=0;i<20;i++)if(menustring[5][i]=='\0')menustring[5][i]=' ';
3128 menustring[5][20]='\0';
3129 sprintf (temp, "%d",(int)accountcampaignhighscore[accountactive]);
3130 strcat(menustring[5],temp);
3132 endx[5]=startx[5]+strlen(menustring[5])*10;
3134 endy[5]=starty[5]+20;
3138 for(i=0;i<255;i++)menustring[7][i]='\0';
3139 sprintf (temp, "Lowest time:");
3140 strcpy(menustring[7],temp);
3141 for(i=0;i<20;i++)if(menustring[7][i]=='\0')menustring[7][i]=' ';
3142 menustring[7][20]='\0';
3143 sprintf (temp, "%d",(int)accountcampaignfasttime[accountactive]);
3144 strcat(menustring[7],temp);
3146 endx[7]=startx[7]+strlen(menustring[7])*10;
3148 endy[7]=starty[7]+20;
3154 sprintf (menustring[0], "Stereo mode: %s", StereoModeName(newstereomode));
3157 endx[0]=startx[0]+strlen(menustring[0])*10;
3158 endy[0]=starty[0]+20;
3162 sprintf (menustring[1], "Stereo separation: %.3f", stereoseparation);
3165 endx[1]=startx[1]+strlen(menustring[1])*10;
3166 endy[1]=starty[1]+20;
3170 sprintf (menustring[2], "Reverse stereo: %s", stereoreverse ? "Yes" : "No");
3173 endx[2]=startx[2]+strlen(menustring[2])*10;
3174 endy[2]=starty[2]+20;
3178 sprintf (menustring[3], "Back");
3180 endx[3]=startx[3]+strlen(menustring[3])*10;
3182 endy[3]=starty[3]+20;
3192 sprintf (menustring[0], "Please enter your name:");
3195 endx[0]=startx[0]+strlen(menustring[0])*10;
3196 endy[0]=starty[0]+20;
3200 sprintf (menustring[1], "Please enter your name:");
3203 endx[1]=startx[1]+strlen(menustring[1])*10;
3204 endy[1]=starty[1]+20;
3208 if(mainmenu==1||mainmenu==2){
3218 starty[1]=480-152-32;
3225 starty[2]=480-228-32;
3233 starty[3]=480-306-32;
3242 starty[3]=480-306-32;
3256 starty[4]=480-140-256;
3263 starty[5]=480-138-256;
3270 starty[6]=480-144-256;
3278 starty[4]=480-140-256;
3285 starty[5]=480-138-256;
3292 starty[6]=480-144-256;
3300 starty[4]=480-140-256;
3307 starty[5]=480-150-256;
3314 starty[6]=480-144-256;
3322 starty[4]=480-140-256;
3329 starty[5]=480-150-256;
3336 starty[6]=480-144-256;
3344 starty[4]=480-100-256;
3351 starty[5]=480-120-256;
3358 starty[6]=480-144-256;
3368 if(mainmenu==1||mainmenu==2)
3370 if((mousecoordh/screenwidth*640)>startx[i]&&(mousecoordh/screenwidth*640)<endx[i]&&480-(mousecoordv/screenheight*480)>starty[i]&&480-(mousecoordv/screenheight*480)<endy[i]){
3375 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)
3376 for(i=0;i<nummenuitems;i++){
3377 if((mousecoordh/screenwidth*640)>startx[i]&&(mousecoordh/screenwidth*640)<endx[i]&&480-(mousecoordv/screenheight*480)>starty[i]&&480-(mousecoordv/screenheight*480)<endy[i]){
3378 if(mainmenu!=5)selected=i;
3379 if(mainmenu==5&&(i!=0&&i!=6))selected=i;
3380 if(mainmenu==9&&(i!=numchallengelevels+1))selected=i;
3381 if(mainmenu==11&&(i!=numchallengelevels+1))selected=i;
3386 for(i=0;i<nummenuitems;i++){
3387 if(selected==i)selectedlong[i]+=multiplier*5;
3388 if(selectedlong[i]>1)selectedlong[i]=1;
3389 if(selected!=i)selectedlong[i]-=multiplier*5;
3390 if(selectedlong[i]<0)selectedlong[i]=0;
3391 //if(i>=4)selectedlong[i]=.3;
3392 if(i>=4&&(mainmenu==1||mainmenu==2))selectedlong[i]=0;
3396 for(i=0;i<nummenuitems;i++){
3397 offsetx[i]=(startx[i]+endx[i])/2-(mousecoordh/screenwidth*640);
3398 offsety[i]=(starty[i]+endy[i])/2-(480-(mousecoordv/screenheight*480));
3403 if(i>=4&&(mainmenu==1||mainmenu==2)){
3404 offsetx[i]=(startx[i]+endx[i]+movex[i]*transition)/2-(640+190)/2;
3405 offsety[i]=(starty[i]+endy[i]+movey[i]*transition)/2-(336+150)/2;
3411 if(mainmenu==1||mainmenu==2){
3412 glClear(GL_DEPTH_BUFFER_BIT);
3413 glEnable(GL_ALPHA_TEST);
3414 glAlphaFunc(GL_GREATER, 0.001f);
3415 glEnable(GL_TEXTURE_2D);
3416 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3417 glDisable(GL_CULL_FACE);
3418 glDisable(GL_LIGHTING);
3420 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3421 glPushMatrix(); // Store The Projection Matrix
3422 glLoadIdentity(); // Reset The Projection Matrix
3423 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
3424 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3425 glPushMatrix(); // Store The Modelview Matrix
3426 glLoadIdentity(); // Reset The Modelview Matrix
3427 glTranslatef(screenwidth/2,screenheight/2,0);
3429 glScalef((float)screenwidth/2,(float)screenheight/2,1);
3430 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3431 glDisable(GL_BLEND);
3432 glColor4f(0,0,0,1.0);
3433 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
3434 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
3435 glDisable(GL_TEXTURE_2D);
3437 //glScalef(.25,.25,.25);
3440 glVertex3f(-1, -1, 0.0f);
3442 glVertex3f(1, -1, 0.0f);
3444 glVertex3f(1, 1, 0.0f);
3446 glVertex3f(-1, 1, 0.0f);
3450 glColor4f(0.4,0.4,0.4,1.0);
3451 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
3452 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
3453 glEnable(GL_TEXTURE_2D);
3454 glBindTexture( GL_TEXTURE_2D, Mainmenuitems[4]);
3456 //glScalef(.25,.25,.25);
3459 glVertex3f(-1, -1, 0.0f);
3461 glVertex3f(1, -1, 0.0f);
3463 glVertex3f(1, 1, 0.0f);
3465 glVertex3f(-1, 1, 0.0f);
3470 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3473 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3474 glPushMatrix(); // Store The Projection Matrix
3475 glLoadIdentity(); // Reset The Projection Matrix
3476 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3477 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3478 glPushMatrix(); // Store The Modelview Matrix
3479 glLoadIdentity(); // Reset The Modelview Matrix
3481 glDisable(GL_TEXTURE_2D);
3486 if(anim!=1)glVertex3f(190, 150, 0.0f);
3487 if(anim==1)glVertex3f(190+movex[4]*transition, 150, 0.0f);
3489 glVertex3f(640, 150, 0.0f);
3491 glVertex3f(640, 336, 0.0f);
3493 if(anim!=1)glVertex3f(190, 336, 0.0f);
3494 if(anim==1)glVertex3f(190+movex[4]*transition, 336, 0.0f);
3499 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3501 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3505 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3506 glPushMatrix(); // Store The Projection Matrix
3507 glLoadIdentity(); // Reset The Projection Matrix
3508 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3509 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3510 glPushMatrix(); // Store The Modelview Matrix
3511 glLoadIdentity(); // Reset The Modelview Matrix
3512 glEnable(GL_TEXTURE_2D);
3515 for(j=0;j<nummenuitems;j++)
3517 if(j<=3||(mainmenu!=1&&mainmenu!=2))
3519 //glDisable(GL_BLEND);
3520 glEnable(GL_ALPHA_TEST);
3522 //glDisable(GL_ALPHA_TEST);
3523 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3524 if(mainmenu==1||mainmenu==2)
3527 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3528 glBindTexture( GL_TEXTURE_2D, Mainmenuitems[j]);
3529 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
3530 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
3531 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3535 glVertex3f(startx[j]+movex[j]*transition, starty[j]+movey[j]*transition, 0.0f);
3537 glVertex3f(endx[j]+movex[j]*transition, starty[j]+movey[j]*transition, 0.0f);
3539 glVertex3f(endx[j]+movex[j]*transition, endy[j]+movey[j]*transition, 0.0f);
3541 glVertex3f(startx[j]+movex[j]*transition, endy[j]+movey[j]*transition, 0.0f);
3545 //glDisable(GL_ALPHA_TEST);
3546 if(j<4)glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3549 if(1-((float)i)/10-(1-selectedlong[j])>0)
3551 glColor4f(1,1,1,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3552 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3556 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);
3558 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);
3560 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);
3562 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);
3568 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)
3570 if(mainmenu!=5||j<6)
3573 if(mainmenu==9&&j>accountprogress[accountactive]&&j<numchallengelevels)glColor4f(0.5,0,0,1);
3574 if(mainmenu==11&&j>accountprogress[accountactive]&&j<numchallengelevels)glColor4f(0.5,0,0,1);
3575 //if(1-((float)i)/10-(1-selectedlong[j])>0){
3576 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3578 if(mainmenu!=7||j!=0||!entername)text.glPrint(startx[j],starty[j],menustring[j],0,1,640,480);
3582 sprintf (string, "_");
3583 text.glPrint(startx[j]+(float)(displayselected)*10,starty[j],string,0,1,640,480);
3586 for(l=0;l<displaychars[k];l++){
3587 if(l<displaychars[k]){
3588 sprintf (string, "%c",displaytext[k][l]);
3589 text.glPrint(startx[j]+l*10,starty[j],string,0,1,640,480);
3595 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3598 if(1-((float)i)/15-(1-selectedlong[j])>0)
3600 glColor4f(1,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3601 if(mainmenu==9&&j>accountprogress[accountactive]&&j<numchallengelevels)glColor4f(0.5,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3602 if(mainmenu==11&&j>accountprogress[accountactive]&&j<numchallengelevels)glColor4f(0.5,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3603 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);
3604 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);
3605 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);
3606 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);
3607 if(mainmenu==7&&(j!=0||!entername)) text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4,starty[j]+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
3608 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);
3609 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);
3610 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);
3611 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);
3612 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);
3613 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);
3614 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);
3617 sprintf (string, "_");
3618 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);
3621 for(l=0;l<displaychars[k];l++){
3622 if(l<displaychars[k]){
3623 sprintf (string, "%c",displaytext[k][l]);
3624 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);
3633 glClear(GL_DEPTH_BUFFER_BIT);
3634 glEnable(GL_ALPHA_TEST);
3635 glAlphaFunc(GL_GREATER, 0.001f);
3636 glEnable(GL_TEXTURE_2D);
3637 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3638 glDisable(GL_CULL_FACE);
3639 glDisable(GL_LIGHTING);
3640 if(j==6)glColor4f(1,1,1,1);
3641 else glColor4f(1,0,0,1);
3643 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3644 glPushMatrix(); // Store The Projection Matrix
3645 glLoadIdentity(); // Reset The Projection Matrix
3646 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3647 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3648 glPushMatrix(); // Store The Modelview Matrix
3649 glLoadIdentity(); // Reset The Modelview Matrix
3652 //Draw world, draw map
3653 glTranslatef(2,-5,0);
3655 if(j>6&&j<nummenuitems-1)
3657 XYZ linestart,lineend,offset;
3664 //float linestartx,lineendx,linestarty,lineendy,offsetx,offsety;
3665 linestart.x=(startx[j]+endx[j])/2;
3666 linestart.y=(starty[j]+endy[j])/2;
3667 if(j>=6+accountcampaignchoicesmade[accountactive]){
3668 linestart.x=(startx[6+accountcampaignchoicesmade[accountactive]]+endx[6+accountcampaignchoicesmade[accountactive]])/2;
3669 linestart.y=(starty[6+accountcampaignchoicesmade[accountactive]]+endy[6+accountcampaignchoicesmade[accountactive]])/2;
3671 lineend.x=(startx[j+1]+endx[j+1])/2;
3672 lineend.y=(starty[j+1]+endy[j+1])/2;
3673 offset=lineend-linestart;
3676 offset=DoRotation(offset,0,0,90);
3678 glDisable(GL_TEXTURE_2D);
3680 if(j<6+accountcampaignchoicesmade[accountactive]){
3681 glColor4f(0.5,0,0,1);
3685 if(j>=6+accountcampaignchoicesmade[accountactive]){
3691 linestart+=fac*4*startsize;
3692 lineend-=fac*4*endsize;
3694 if(!(j>7+accountcampaignchoicesmade[accountactive]+campaignchoicenum)){
3695 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3699 glVertex3f(linestart.x-offset.x*startsize, linestart.y-offset.y*startsize, 0.0f);
3701 glVertex3f(linestart.x+offset.x*startsize, linestart.y+offset.y*startsize, 0.0f);
3703 glVertex3f(lineend.x+offset.x*endsize, lineend.y+offset.y*endsize, 0.0f);
3705 glVertex3f(lineend.x-offset.x*endsize, lineend.y-offset.y*endsize, 0.0f);
3709 glEnable(GL_TEXTURE_2D);
3713 if(j==6)glBindTexture( GL_TEXTURE_2D, Mainmenuitems[7]);
3714 else glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
3715 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
3716 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
3717 if(j-7<accountcampaignchoicesmade[accountactive])glColor4f(0.5,0,0,1);
3718 if(j-7>=accountcampaignchoicesmade[accountactive])glColor4f(1,0,0,1);
3719 if(j==6)glColor4f(1,1,1,1);
3722 itemsize=abs(startx[j]-endx[j])/2;
3724 midpoint.x=(startx[j]+endx[j])/2;
3725 midpoint.y=(starty[j]+endy[j])/2;
3726 if(j>6&&(j-7<accountcampaignchoicesmade[accountactive]))itemsize*=.5;
3727 if(!(j-7>accountcampaignchoicesmade[accountactive]+campaignchoicenum))
3729 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3733 glVertex3f(midpoint.x-itemsize+movex[j]*transition, midpoint.y-itemsize+movey[j]*transition, 0.0f);
3735 glVertex3f(midpoint.x+itemsize+movex[j]*transition, midpoint.y-itemsize+movey[j]*transition, 0.0f);
3737 glVertex3f(midpoint.x+itemsize+movex[j]*transition, midpoint.y+itemsize+movey[j]*transition, 0.0f);
3739 glVertex3f(midpoint.x-itemsize+movex[j]*transition, midpoint.y+itemsize+movey[j]*transition, 0.0f);
3743 //glDisable(GL_ALPHA_TEST);
3744 if(j<4)glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3747 if(1-((float)i)/10-(1-selectedlong[j])>0)
3749 glColor4f(1,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3750 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3754 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);
3756 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);
3758 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);
3760 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);
3768 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3770 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3772 if(j-7>=accountcampaignchoicesmade[accountactive]){
3773 //glColor4f(0,0,0,1);
3774 //text.glPrintOutline(startx[j]+10-1.5,starty[j]-4-1.5,menustring[j],0,0.6*1.25,640,480);
3775 //glColor4f(1,0,0,1);
3776 //text.glPrint(startx[j]+10,starty[j]-4,menustring[j],0,0.6,640,480);
3777 text.glPrintOutlined(0.9,0,0,startx[j]+10,starty[j]-4,menustring[j],0,0.6,640,480);
3778 glDisable(GL_DEPTH_TEST);
3785 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3787 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3790 if(mainmenu==1||mainmenu==2)
3791 if(transition<.1||transition>.9){
3792 glClear(GL_DEPTH_BUFFER_BIT);
3793 glEnable(GL_ALPHA_TEST);
3794 glAlphaFunc(GL_GREATER, 0.001f);
3795 glEnable(GL_TEXTURE_2D);
3796 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3797 glDisable(GL_CULL_FACE);
3798 glDisable(GL_LIGHTING);
3800 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3801 glPushMatrix(); // Store The Projection Matrix
3802 glLoadIdentity(); // Reset The Projection Matrix
3803 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3804 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3805 glPushMatrix(); // Store The Modelview Matrix
3806 glLoadIdentity(); // Reset The Modelview Matrix
3808 glDisable(GL_TEXTURE_2D);
3809 if(transition<.1)glColor4f(1,0,0,1-(transition*10));
3810 if(transition>.9)glColor4f(1,0,0,1-((1-transition)*10));
3814 glVertex3f(190, 150, 0.0f);
3816 glVertex3f(640, 150, 0.0f);
3818 glVertex3f(640, 336, 0.0f);
3820 glVertex3f(190, 336, 0.0f);
3825 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3829 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3830 glPushMatrix(); // Store The Projection Matrix
3831 glLoadIdentity(); // Reset The Projection Matrix
3832 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
3833 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3834 glPushMatrix(); // Store The Modelview Matrix
3835 glLoadIdentity(); // Reset The Modelview Matrix
3836 glTranslatef(screenwidth/2,screenheight/2,0);
3838 glScalef((float)screenwidth/2,(float)screenheight/2,1);
3839 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3841 glEnable(GL_TEXTURE_2D);
3843 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
3844 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
3847 glTranslatef(mousecoordh-screenwidth/2,mousecoordv*-1+screenheight/2,0);
3848 glScalef((float)screenwidth/64,(float)screenwidth/64,1);
3849 glTranslatef(1,-1,0);
3850 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3852 glBindTexture( GL_TEXTURE_2D, cursortexture);
3854 //glScalef(.25,.25,.25);
3857 glVertex3f(-1, -1, 0.0f);
3859 glVertex3f(1, -1, 0.0f);
3861 glVertex3f(1, 1, 0.0f);
3863 glVertex3f(-1, 1, 0.0f);
3868 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3874 //printf("Flash amount: %f, delay %i\n", flashamount, flashdelay);
3875 if(flashamount>1)flashamount=1;
3876 if(flashdelay<=0)flashamount-=multiplier;
3878 if(flashamount<0)flashamount=0;
3879 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3880 glDisable(GL_CULL_FACE);
3881 glDisable(GL_LIGHTING);
3882 glDisable(GL_TEXTURE_2D);
3884 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3885 glPushMatrix(); // Store The Projection Matrix
3886 glLoadIdentity(); // Reset The Projection Matrix
3887 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
3888 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3889 glPushMatrix(); // Store The Modelview Matrix
3890 glLoadIdentity(); // Reset The Modelview Matrix
3891 glScalef(screenwidth,screenheight,1);
3892 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3894 glColor4f(flashr,flashg,flashb,flashamount);
3896 glVertex3f(0, 0, 0.0f);
3897 glVertex3f(256, 0, 0.0f);
3898 glVertex3f(256, 256, 0.0f);
3899 glVertex3f(0, 256, 0.0f);
3901 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3902 glPopMatrix(); // Restore The Old Projection Matrix
3903 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3904 glPopMatrix(); // Restore The Old Projection Matrix
3905 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
3906 glEnable(GL_CULL_FACE);
3907 glDisable(GL_BLEND);
3912 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)||(!gameon&&gamestarted)){
3913 tempmult=multiplier;
3919 if ( side == stereoRight || side == stereoCenter ) {
3920 if(drawmode!=motionblurmode||mainmenu){
3925 //myassert(glGetError() == GL_NO_ERROR);
3926 glDrawBuffer(GL_BACK);
3927 glReadBuffer(GL_BACK);
3932 if(drawtoggle==2)drawtoggle=0;
3934 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)){
3935 multiplier=tempmult;
3937 //Jordan fixed your warning!