2 Copyright (C) 2003, 2010 - Wolfire Games
4 This file is part of Lugaru.
6 Lugaru is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; either version 2
9 of the License, or (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 See the GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 #include "openal_wrapper.h"
29 extern int environment;
30 extern float texscale;
32 extern Terrain terrain;
33 extern Sprites sprites;
34 extern float multiplier;
36 extern float viewdistance;
37 extern float fadestart;
38 extern float screenwidth,screenheight;
39 extern int kTextureSize;
40 extern FRUSTUM frustum;
42 extern Objects objects;
44 extern float usermousesensitivity;
46 extern float camerashake;
47 extern Weapons weapons;
48 extern Person player[maxplayers];
50 extern float slomodelay;
51 extern bool ismotionblur;
53 extern float blackout;
54 extern bool damageeffects;
56 extern int numplayers;
57 extern bool texttoggle;
58 extern float blurness;
59 extern float targetblurness;
60 extern float playerdist;
61 extern bool cellophane;
63 extern float flashamount,flashr,flashg,flashb;
64 extern int flashdelay;
66 extern float motionbluramount;
68 extern bool alwaysblur;
70 extern bool tilt2weird;
71 extern bool tiltweird;
73 extern bool proportionweird;
74 extern bool vertexweird[6];
75 extern bool velocityblur;
76 extern bool debugmode;
78 extern int oldmainmenu;
79 extern int bloodtoggle;
80 extern int difficulty;
83 //extern int texdetail;
84 extern float texdetail;
85 extern bool musictoggle;
87 extern float bonusvalue;
88 extern float bonustotal;
89 extern float bonustime;
91 extern float startbonustotal;
92 extern float bonusnum[100];
93 extern int tutoriallevel;
94 extern float smoketex;
95 extern float tutorialstagetime;
96 extern float tutorialmaxtime;
97 extern int tutorialstage;
98 extern bool againbonus;
99 extern float damagedealt;
100 extern float damagetaken;
101 extern bool invertmouse;
103 extern int numhotspots;
104 extern int winhotspot;
105 extern int killhotspot;
106 extern XYZ hotspot[40];
107 extern int hotspottype[40];
108 extern float hotspotsize[40];
109 extern char hotspottext[40][256];
110 extern int currenthotspot;;
113 extern int numflipfail;
115 extern int numstaffattack;
116 extern int numswordattack;
117 extern int numknifeattack;
118 extern int numunarmedattack;
119 extern int numescaped;
120 extern int numflipped;
121 extern int numwallflipped;
122 extern int numthrowkill;
123 extern int numafterkill;
124 extern int numreversals;
125 extern int numattacks;
126 extern int maxalarmed;
127 extern int numresponded;
129 extern bool campaign;
130 extern bool winfreeze;
132 extern float menupulse;
134 extern bool gamestart;
136 extern int numdialogues;
137 extern int numdialogueboxes[max_dialogues];
138 extern int dialoguetype[max_dialogues];
139 extern int dialogueboxlocation[max_dialogues][max_dialoguelength];
140 extern float dialogueboxcolor[max_dialogues][max_dialoguelength][3];
141 extern int dialogueboxsound[max_dialogues][max_dialoguelength];
142 extern char dialoguetext[max_dialogues][max_dialoguelength][128];
143 extern char dialoguename[max_dialogues][max_dialoguelength][64];
144 extern XYZ dialoguecamera[max_dialogues][max_dialoguelength];
145 extern XYZ participantlocation[max_dialogues][10];
146 extern int participantfocus[max_dialogues][max_dialoguelength];
147 extern int participantaction[max_dialogues][max_dialoguelength];
148 extern float participantrotation[max_dialogues][10];
149 extern XYZ participantfacing[max_dialogues][max_dialoguelength][10];
150 extern float dialoguecamerarotation[max_dialogues][max_dialoguelength];
151 extern float dialoguecamerarotation2[max_dialogues][max_dialoguelength];
152 extern int indialogue;
153 extern int whichdialogue;
154 extern int directing;
155 extern float dialoguetime;
156 extern int dialoguegonethrough[20];
158 extern bool gamestarted;
160 extern bool showdamagebar;
162 extern OPENAL_SAMPLE *samp[100];
163 extern int channels[100];
164 extern "C" void PlaySoundEx(int channel, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
166 void Game::flash() { // shouldn't be that way, these should be attributes and Person class should not change rendering.
173 /*********************> DrawGLScene() <*****/
174 long long Game::MD5_string (char *string){
179 sprintf (temp, "%s",string);
182 while (i<256&&temp[i]!='\0'){
183 if(temp[i]%3==0)num+=temp[i]*124;
184 else if(temp[i]%3==1)num-=temp[i]*temp[i];
189 num=longlongabs(num);
192 while(num<LONGLONGCONST(5000000000000000)){
196 while(num>LONGLONGCONST(9900000000000000)){
202 //return 1111111111111111;
205 int Game::DrawGLScene(StereoSide side)
207 static float texcoordwidth,texcoordheight;
208 static float texviewwidth, texviewheight;
210 static GLubyte color;
211 static float newbrightness;
212 static float changespeed;
213 static XYZ checkpoint;
214 static float tempmult;
216 static char string[256]="";
217 static char string2[256]="";
218 static char string3[256]="";
220 static float lastcheck;
222 lastcheck+=multiplier;
224 if ( stereomode == stereoAnaglyph ) {
226 case stereoLeft: glColorMask( 0.0, 1.0, 1.0, 1.0 ); break;
227 case stereoRight: glColorMask( 1.0, 0.0, 0.0, 1.0 ); break;
230 glColorMask( 1.0, 1.0, 1.0, 1.0 );
232 if ( stereomode == stereoHorizontalInterlaced || stereomode == stereoVerticalInterlaced ) {
233 glStencilFunc(side == stereoLeft ? GL_NOTEQUAL : GL_EQUAL, 0x01, 0x01);
237 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)){
244 numboundaries=mapradius*2;
245 if(numboundaries>360)numboundaries=360;
246 for(i=0;i<numboundaries;i++){
249 boundary[i]=mapcenter+DoRotation(boundary[i]*mapradius,0,i*(360/((float)(numboundaries))),0);
258 olddrawmode=drawmode;
259 if(ismotionblur&&!loading){
260 if((findLengthfast(&player[0].velocity)>200)&&velocityblur&&!cameramode){
261 drawmode=motionblurmode;
262 motionbluramount=200/(findLengthfast(&player[0].velocity));
265 if(player[0].damage-player[0].superpermanentdamage>(player[0].damagetolerance-player[0].superpermanentdamage)*1/2&&damageeffects&&!cameramode){
266 drawmode=doublevisionmode;
273 drawmode=motionblurmode;
275 slomodelay-=multiplier;
276 if(slomodelay<0)slomo=0;
280 if((!changed&&!slomo)||loading){
282 if(ismotionblur&&(/*fps>100||*/alwaysblur)){
283 if(olddrawmode!=realmotionblurmode)change=1;
285 drawmode=realmotionblurmode;
287 else if(olddrawmode==realmotionblurmode)change=2;
291 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted))drawmode=normalmode;
292 if((freeze||winfreeze)&&ismotionblur&&!mainmenu)drawmode=radialzoommode;
294 if(winfreeze||mainmenu)drawmode=normalmode;
297 if(drawmode==glowmode){
303 DSpContext_FadeGamma(NULL,200,&color2);
307 if(drawtoggle!=2)drawtoggle=1-drawtoggle;
311 texviewwidth=kTextureSize;
312 if(texviewwidth>screenwidth)texviewwidth=screenwidth;
313 texviewheight=kTextureSize;
314 if(texviewheight>screenheight)texviewheight=screenheight;
316 texcoordwidth=screenwidth/kTextureSize;
317 texcoordheight=screenheight/kTextureSize;
318 if(texcoordwidth>1)texcoordwidth=1;
319 if(texcoordheight>1)texcoordheight=1;
322 glDrawBuffer(GL_BACK);
323 glReadBuffer(GL_BACK);
325 /*if(environment==desertenvironment)glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, (float)(abs(Random()%100))/50 );
326 else glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0);
328 if(abs(blurness-targetblurness)<multiplier*10||abs(blurness-targetblurness)>2){
329 blurness=targetblurness;
330 targetblurness=(float)(abs(Random()%100))/40;
332 if(blurness<targetblurness)blurness+=multiplier*5;
333 if(blurness>targetblurness)blurness-=multiplier*5;
336 static XYZ terrainlight;
337 static float distance;
338 //if(drawmode==normalmode)ReSizeGLScene(90,.1);
339 if(drawmode==normalmode)ReSizeGLScene(90,.1f);
340 if(drawmode!=normalmode)glViewport(0,0,texviewwidth,texviewheight);
341 glDepthFunc(GL_LEQUAL);
343 glAlphaFunc(GL_GREATER, 0.0001f);
344 glEnable(GL_ALPHA_TEST);
345 glClearColor(0.25f, 0.25f, 0.25f, 1.0f);
346 glClear(GL_DEPTH_BUFFER_BIT);
348 glMatrixMode (GL_MODELVIEW);
349 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
352 // Move the camera for the current eye's point of view.
353 // Reverse the movement if we're reversing stereo
354 glTranslatef((stereoseparation/2) * side * (stereoreverse ? -1 : 1), 0, 0);
356 if(!cameramode&&!freeze&&!winfreeze){
357 glRotatef(float(Random()%100)/10*camerashake/*+(woozy*woozy)/10*/,0,0,1);
358 glRotatef(rotation2+sin(woozy/2)*(player[0].damage/player[0].damagetolerance)*5,1,0,0);
359 glRotatef(rotation+sin(woozy)*(player[0].damage/player[0].damagetolerance)*5,0,1,0);
361 if(cameramode||freeze||winfreeze){
362 //glRotatef(float(Random()%100)/10*camerashake/*+(woozy*woozy)/10*/,0,0,1);
363 glRotatef(rotation2,1,0,0);
364 glRotatef(rotation,0,1,0);
367 if(environment==desertenvironment){
368 glRotatef((float)(abs(Random()%100))/3000-1,1,0,0);
369 glRotatef((float)(abs(Random()%100))/3000-1,0,1,0);
370 //glRotatef(blurness/40-1,1,0,0);
371 //glRotatef(blurness/40-1,0,1,0);
373 SetUpLight(&light,0);
375 if(environment==desertenvironment&&detail==2)glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, blurness+.4 );
376 if(environment==desertenvironment){
377 glRotatef((float)(abs(Random()%100))/1000,1,0,0);
378 glRotatef((float)(abs(Random()%100))/1000,0,1,0);
381 glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0);
383 glTranslatef(-viewer.x,-viewer.y,-viewer.z);
384 frustum.GetFrustum();
388 static float size,opacity,rotation;
390 for(k=0;k<numplayers;k++){
391 if(!player[k].skeleton.free&&player[k].playerdetail&&player[k].howactive<typesleeping)
392 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)
393 for(i=0;i<player[k].skeleton.num_joints;i++){
394 if(player[k].skeleton.joints[i].label==leftknee||player[k].skeleton.joints[i].label==rightknee||player[k].skeleton.joints[i].label==groin){
395 point=DoRotation(player[k].skeleton.joints[i].position,0,player[k].rotation,0)*player[k].scale+player[k].coords;
397 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;
398 if(k!=0&&tutoriallevel==1){
399 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;
401 terrain.MakeDecal(shadowdecal,point,size,opacity,rotation);
402 if(terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz])
403 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
404 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
405 if(objects.position[j].y<player[k].coords.y||objects.type[j]==tunneltype||objects.type[j]==weirdtype){
406 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);
409 if(k!=0&&tutoriallevel==1){
410 opacity=.2+.2*sin(smoketex*6+i);
412 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
417 if((player[k].skeleton.free||player[k].howactive>=typesleeping)&&player[k].playerdetail)
418 if(frustum.SphereInFrustum(player[k].coords.x,player[k].coords.y,player[k].coords.z,player[k].scale*5)&&player[k].occluded<25)
419 for(i=0;i<player[k].skeleton.num_joints;i++){
420 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){
421 if(player[k].skeleton.free)point=player[k].skeleton.joints[i].position*player[k].scale+player[k].coords;
422 else point=DoRotation(player[k].skeleton.joints[i].position,0,player[k].rotation,0)*player[k].scale+player[k].coords;
424 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;
425 if(k!=0&&tutoriallevel==1){
426 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;
428 terrain.MakeDecal(shadowdecal,point,size,opacity*.7,rotation);
429 if(terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz])
430 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
431 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
432 if(objects.position[j].y<player[k].coords.y||objects.type[j]==tunneltype||objects.type[j]==weirdtype){
433 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);
434 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);
437 if(k!=0&&tutoriallevel==1){
438 opacity=.2+.2*sin(smoketex*6+i);
440 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
446 if(!player[k].playerdetail)
447 if(frustum.SphereInFrustum(player[k].coords.x,player[k].coords.y,player[k].coords.z,player[k].scale*5))
449 point=player[k].coords;
451 opacity=.4-(player[k].coords.y-terrain.getHeight(player[k].coords.x,player[k].coords.z))/5;
452 terrain.MakeDecal(shadowdecal,point,size,opacity*.7,rotation);
453 if(terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz])
454 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
455 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
456 point=DoRotation(player[k].coords-objects.position[j],0,-objects.rotation[j],0);
459 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
465 glEnable(GL_TEXTURE_2D);
467 glEnable(GL_DEPTH_TEST);
468 glEnable(GL_CULL_FACE);
470 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
471 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
472 glBindTexture( GL_TEXTURE_2D, terraintexture);
474 glBindTexture( GL_TEXTURE_2D, terraintexture2);
476 //glBindTexture( GL_TEXTURE_2D, terraintexture3);
477 //glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
480 terrain.drawdecals();
483 glEnable(GL_CULL_FACE);
484 glEnable(GL_LIGHTING);
486 glEnable(GL_TEXTURE_2D);
489 glEnable(GL_COLOR_MATERIAL);
504 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
505 glEnable(GL_CULL_FACE);
506 glCullFace(GL_FRONT);
508 for(k=0;k<numplayers;k++){
509 if(k==0||tutoriallevel!=1){
511 glEnable(GL_LIGHTING);
512 terrainlight=terrain.getLighting(player[k].coords.x,player[k].coords.z);
513 distance=findDistancefast(&viewer,&player[k].coords);
514 distance=(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance;
515 glColor4f(terrainlight.x,terrainlight.y,terrainlight.z,distance);
516 if(distance>=1)glDisable(GL_BLEND);
518 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;
520 if(!player[k].occluded==0)i=checkcollide(viewer,checkpoint,player[k].lastoccluded);
521 if(i==-1||player[k].occluded==0)i=checkcollide(viewer,checkpoint);
523 player[k].occluded+=1;
524 player[k].lastoccluded=i;
526 else player[k].occluded=0;
527 if(player[k].occluded<25)player[k].DrawSkeleton();
533 if(!cameramode&&musictype==stream_music2)playerdist=findDistancefastflat(&player[0].coords,&viewer);
534 else playerdist=-100;
537 glEnable(GL_TEXTURE_2D);
542 if(frustum.SphereInFrustum(realhawkcoords.x+hawk.boundingspherecenter.x,realhawkcoords.y+hawk.boundingspherecenter.y,realhawkcoords.z+hawk.boundingspherecenter.z,2)){
543 glAlphaFunc(GL_GREATER, 0.0001f);
545 glDisable(GL_CULL_FACE);
546 glDisable(GL_LIGHTING);
548 glTranslatef(hawkcoords.x,hawkcoords.y,hawkcoords.z);
549 glRotatef(hawkrotation,0,1,0);
550 glTranslatef(25,0,0);
551 distance=findDistancefast(&viewer,&realhawkcoords)*1.2;
552 glColor4f(light.color[0],light.color[1],light.color[2],(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance);
553 if((viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance>1)glColor4f(light.color[0],light.color[1],light.color[2],1);
554 if((viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance>0)
555 hawk.drawdifftex(hawktexture);
559 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
560 glEnable(GL_CULL_FACE);
561 glCullFace(GL_FRONT);
563 for(k=0;k<numplayers;k++){
564 if(!(k==0||tutoriallevel!=1)){
566 glEnable(GL_LIGHTING);
567 terrainlight=terrain.getLighting(player[k].coords.x,player[k].coords.z);
568 distance=findDistancefast(&viewer,&player[k].coords);
569 distance=(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance;
570 glColor4f(terrainlight.x,terrainlight.y,terrainlight.z,distance);
571 if(distance>=1)glDisable(GL_BLEND);
573 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;
575 if(!player[k].occluded==0)i=checkcollide(viewer,checkpoint,player[k].lastoccluded);
576 if(i==-1||player[k].occluded==0)i=checkcollide(viewer,checkpoint);
578 player[k].occluded+=1;
579 player[k].lastoccluded=i;
581 else player[k].occluded=0;
582 if(player[k].occluded<25)player[k].DrawSkeleton();
589 glEnable(GL_TEXTURE_2D);
594 glDisable(GL_COLOR_MATERIAL);
596 glDisable(GL_LIGHTING);
597 glDisable(GL_TEXTURE_2D);
605 glDisable(GL_LIGHTING);
606 glDisable(GL_TEXTURE_2D);
607 glDisable(GL_COLOR_MATERIAL);
610 for(k=0;k<numplayers;k++){
611 if(player[k].numwaypoints>1){
612 glBegin(GL_LINE_LOOP);
613 for(i=0;i<player[k].numwaypoints;i++){
614 glVertex3f(player[k].waypoints[i].x,player[k].waypoints[i].y+.5,player[k].waypoints[i].z);
623 for(k=0;k<numpathpoints;k++){
624 if(numpathpointconnect[k]){
625 for(i=0;i<numpathpointconnect[k];i++){
626 glBegin(GL_LINE_LOOP);
627 glVertex3f(pathpoint[k].x,pathpoint[k].y+.5,pathpoint[k].z);
628 glVertex3f(pathpoint[pathpointconnect[k][i]].x,pathpoint[pathpointconnect[k][i]].y+.5,pathpoint[pathpointconnect[k][i]].z);
636 glVertex3f(pathpoint[pathpointselected].x,pathpoint[pathpointselected].y+.5,pathpoint[pathpointselected].z);
643 glEnable(GL_TEXTURE_2D);
644 glColor4f(.5,.5,.5,1);
646 sprintf (string, " ",(int)(fps));
647 text.glPrint(10,30,string,0,.8,screenwidth,screenheight);
650 if(bonus>0&&bonustime<1&&!winfreeze&&indialogue==-1/*bonustime<4*/){
651 if(bonus==tracheotomy)sprintf (string, "Tracheotomy!");
652 else if(bonus==backstab)sprintf (string, "Backstabber!");
653 else if(bonus==spinecrusher)sprintf (string, "Spinecrusher!");
654 else if(bonus==ninja)sprintf (string, "Ninja Bonus!");
655 else if(bonus==style)sprintf (string, "Style Bonus!");
656 else if(bonus==cannon)sprintf (string, "Leg Cannon!");
657 else if(bonus==aimbonus)sprintf (string, "Nice Aim!");
658 else if(bonus==deepimpact)sprintf (string, "Heavy Impact!");
659 else if(bonus==touchofdeath)sprintf (string, "Touch of Death!");
660 else if(bonus==swordreversebonus)sprintf (string, "Sword Disarm!");
661 else if(bonus==staffreversebonus)sprintf (string, "Staff Disarm!");
662 else if(bonus==reverseko)sprintf (string, "Reversal KO!");
663 else if(bonus==solidhit)sprintf (string, "Solid Hit!");
664 else if(bonus==twoxcombo)sprintf (string, "2X Combo!");
665 else if(bonus==threexcombo)sprintf (string, "3X Combo!");
666 else if(bonus==fourxcombo)sprintf (string, "4X COMBO!");
667 else if(bonus==megacombo)sprintf (string, "MEGA COMBO!");
668 else if(bonus==Reversal)sprintf (string, "Reversal!");
669 else if(bonus==Stabbonus)sprintf (string, "Punctured!");
670 else if(bonus==Slicebonus)sprintf (string, "Sliced!");
671 else if(bonus==Bullseyebonus)sprintf (string, "Bullseye!");
672 else if(bonus==Slashbonus)sprintf (string, "Slashed!");
673 else if(bonus==Wolfbonus)sprintf (string, "WOLF SLAYER!");
674 else if(bonus==FinishedBonus)sprintf (string, "SLAIN!");
675 else if(bonus==TackleBonus)sprintf (string, "Tackle!");
676 else if(bonus==AboveBonus)sprintf (string, "Death from Above!");
677 else sprintf (string, "Excellent!");
679 glColor4f(0,0,0,1-bonustime);
680 text.glPrintOutline(1024/2-10*strlen(string)-4,768/16-4+768*4/5,string,1,2.5,1024,768);
681 glColor4f(1,0,0,1-bonustime);
682 text.glPrint(1024/2-10*strlen(string),768/16+768*4/5,string,1,2,1024,768);
684 sprintf (string, "%d",(int)bonusvalue);
685 glColor4f(0,0,0,1-bonustime);
686 text.glPrintOutline(1024/2-10*strlen(string)-4,768/16-4-20+768*4/5,string,1,2.5*.8,1024,768);
687 glColor4f(1,0,0,1-bonustime);
688 text.glPrint(1024/2-10*strlen(string),768/16-20+768*4/5,string,1,2*.8,1024,768);
689 glColor4f(.5,.5,.5,1);
692 if(tutoriallevel==1){
693 tutorialopac=tutorialmaxtime-tutorialstagetime;
694 if(tutorialopac>1)tutorialopac=1;
695 if(tutorialopac<0)tutorialopac=0;
697 sprintf (string, " ");
698 sprintf (string2, " ");
699 sprintf (string3, " ");
700 if(tutorialstage==0){
701 sprintf (string, " ");
702 sprintf (string2, " ");
703 sprintf (string3, " ");
705 if(tutorialstage==1){
706 sprintf (string, "Welcome to the Lugaru training level!");
707 sprintf (string2, " ");
708 sprintf (string3, " ");
710 if(tutorialstage==2){
711 sprintf (string, "BASIC MOVEMENT:");
712 sprintf (string2, " ");
713 sprintf (string3, " ");
715 if(tutorialstage==3){
716 sprintf (string, "You can move the mouse to rotate the camera.");
717 sprintf (string2, " ");
718 sprintf (string3, " ");
720 if(tutorialstage==4){
721 sprintf (string, "Try using the %s, %s, %s and %s keys to move around.",Input::keyToChar(forwardkey),Input::keyToChar(leftkey),Input::keyToChar(backkey),Input::keyToChar(rightkey));
722 sprintf (string2, "All movement is relative to the camera.");
723 sprintf (string3, " ");
725 if(tutorialstage==5){
726 sprintf (string, "Please press %s to jump.",Input::keyToChar(jumpkey));
727 sprintf (string2, "You can hold it longer to jump higher.");
728 sprintf (string3, " ");
730 if(tutorialstage==6){
731 sprintf (string, "You can press %s to crouch.",Input::keyToChar(crouchkey));
732 sprintf (string2, "You can jump higher from a crouching position.");
733 sprintf (string3, " ");
735 if(tutorialstage==7){
736 sprintf (string, "While running, you can press %s to roll.",Input::keyToChar(crouchkey));
737 sprintf (string2, " ");
738 sprintf (string3, " ");
740 if(tutorialstage==8){
741 sprintf (string, "While crouching, you can sneak around silently");
742 sprintf (string2, "using the movement keys.");
743 sprintf (string3, " ");
745 if(tutorialstage==9){
746 sprintf (string, "Release the crouch key while sneaking and hold the movement keys");
747 sprintf (string2, "to run animal-style.");
748 sprintf (string3, " ");
750 if(tutorialstage==10){
751 sprintf (string, "ADVANCED MOVEMENT:");
752 sprintf (string2, " ");
753 sprintf (string3, " ");
755 if(tutorialstage==11){
756 sprintf (string, "When you jump at a wall, you can hold %s again",Input::keyToChar(jumpkey));
757 sprintf (string2, "during impact to perform a walljump.");
758 sprintf (string3, "Be sure to use the movement keys to press against the wall");
760 if(tutorialstage==12){
761 sprintf (string, "While in the air, you can press crouch to flip.",Input::keyToChar(jumpkey));
762 sprintf (string2, "Walljumps and flips confuse enemies and give you more control.");
763 sprintf (string3, " ");
765 if(tutorialstage==13){
766 sprintf (string, "BASIC COMBAT:");
767 sprintf (string2, " ");
768 sprintf (string3, " ");
770 if(tutorialstage==14){
771 sprintf (string, "There is now an imaginary enemy");
772 sprintf (string2, "in the middle of the training area.");
773 sprintf (string3, " ");
775 if(tutorialstage==15){
776 if(attackkey==MOUSEBUTTON1)sprintf (string, "Click to attack when you are near an enemy.");
777 else sprintf (string, "Press %s to attack when you are near an enemy.",Input::keyToChar(attackkey));
778 sprintf (string2, "You can punch by standing still near an enemy and attacking.");
779 sprintf (string3, " ");
781 if(tutorialstage==16){
782 sprintf (string, "If you are close, you will perform a weak punch.");
783 sprintf (string2, "The weak punch is excellent for starting attack combinations.");
784 sprintf (string3, " ");
786 if(tutorialstage==17){
787 sprintf (string, "Attacking while running results in a spin kick.");
788 sprintf (string2, "This is one of your most powerful ground attacks.");
789 sprintf (string3, " ");
791 if(tutorialstage==18){
792 sprintf (string, "Sweep the enemy's legs out by attacking while crouched.");
793 sprintf (string2, "This is a very fast attack, and easy to follow up.");
794 sprintf (string3, " ");
796 if(tutorialstage==19){
797 sprintf (string, "When an enemy is on the ground, you can deal some extra");
798 sprintf (string2, "damage by running up and drop-kicking him.");
799 sprintf (string3, "(Try knocking them down with a sweep first)");
801 if(tutorialstage==20){
802 sprintf (string, "Your most powerful individual attack is the rabbit kick.");
803 if(attackkey==MOUSEBUTTON1)sprintf (string2, "Run at the enemy while holding the mouse button, and press");
804 else sprintf (string2, "Run at the enemy while holding %s, and press", Input::keyToChar(attackkey));
805 sprintf (string3, "the jump key (%s) to attack.",Input::keyToChar(jumpkey));
807 if(tutorialstage==21){
808 sprintf (string, "This attack is devastating if timed correctly.");
809 sprintf (string2, "Even if timed incorrectly, it will knock the enemy over.");
810 if(againbonus)sprintf (string3, "Try rabbit-kicking the imaginary enemy again.");
811 else sprintf (string3, "Try rabbit-kicking the imaginary enemy.");
813 if(tutorialstage==22){
814 sprintf (string, "If you sneak behind an enemy unnoticed, you can kill");
815 sprintf (string2, "him instantly. Move close behind this enemy");
816 sprintf (string3, "and attack.");
818 if(tutorialstage==23){
819 sprintf (string, "Another important attack is the wall kick. When an enemy");
820 sprintf (string2, "is near a wall, perform a walljump nearby and hold");
821 sprintf (string3, "the attack key during impact with the wall.");
823 if(tutorialstage==24){
824 sprintf (string, "You can tackle enemies by running at them animal-style");
825 if(attackkey==MOUSEBUTTON1)sprintf (string2, "and pressing jump (%s) or attack(mouse button).",Input::keyToChar(jumpkey));
826 else sprintf (string2, "and pressing jump (%s) or attack(%s).",Input::keyToChar(jumpkey),Input::keyToChar(attackkey));
827 sprintf (string3, "This is especially useful when they are running away.");
829 if(tutorialstage==25){
830 sprintf (string, "Dodge by pressing back and attack. Dodging is essential");
831 sprintf (string2, "against enemies with swords or other long weapons.");
832 sprintf (string3, " ");
834 if(tutorialstage==26){
835 sprintf (string, "REVERSALS AND COUNTER-REVERSALS");
836 sprintf (string2, " ");
837 sprintf (string3, " ");
839 if(tutorialstage==27){
840 sprintf (string, "The enemy can now reverse your attacks.");
841 sprintf (string2, " ");
842 sprintf (string3, " ");
844 if(tutorialstage==28){
845 sprintf (string, "If you attack, you will notice that the enemy now sometimes");
846 sprintf (string2, "catches your attack and uses it against you. Hold");
847 sprintf (string3, "crouch (%s) after attacking to escape from reversals.",Input::keyToChar(crouchkey));
849 if(tutorialstage==29){
850 sprintf (string, "Try escaping from two more reversals in a row.");
851 sprintf (string2, " ");
852 sprintf (string3, " ");
854 if(tutorialstage==30){
855 sprintf (string, "Good!");
856 sprintf (string2, " ");
857 sprintf (string3, " ");
859 if(tutorialstage==31){
860 sprintf (string, "To reverse an attack, you must tap crouch (%s) during the",Input::keyToChar(crouchkey));
861 sprintf (string2, "enemy's attack. You must also be close to the enemy;");
862 sprintf (string3, "this is especially important against armed opponents.");
864 if(tutorialstage==32){
865 sprintf (string, "The enemy can attack in %d seconds.", (int)(tutorialmaxtime-tutorialstagetime));
866 sprintf (string2, "This imaginary opponents attacks will be highlighted");
867 sprintf (string3, "to make this easier.");
869 if(tutorialstage==33){
870 sprintf (string, "Reverse three enemy attacks!");
871 sprintf (string2, " ");
872 sprintf (string3, " ");
874 if(tutorialstage==34){
875 sprintf (string, "Reverse two more enemy attacks!");
876 sprintf (string2, " ");
877 sprintf (string3, " ");
879 if(tutorialstage==35){
880 sprintf (string, "Reverse one more enemy attack!");
881 sprintf (string2, " ");
882 sprintf (string3, " ");
884 if(tutorialstage==36){
885 sprintf (string, "Excellent!");
886 sprintf (string2, " ");
887 sprintf (string3, " ");
889 if(tutorialstage==37){
890 sprintf (string, "Now spar with the enemy for %d more seconds.", (int)(tutorialmaxtime-tutorialstagetime));
891 sprintf (string2, "Damage dealt: %d",(int)damagedealt);
892 sprintf (string3, "Damage taken: %d.",(int)damagetaken);
894 if(tutorialstage==38){
895 sprintf (string, "WEAPONS:");
896 sprintf (string2, " ");
897 sprintf (string3, " ");
899 if(tutorialstage==39){
900 sprintf (string, "There is now an imaginary knife");
901 sprintf (string2, "in the center of the training area.");
902 sprintf (string3, " ");
904 if(tutorialstage==40){
905 sprintf (string, "Stand, roll or handspring over the knife");
906 sprintf (string2, "while pressing %s to pick it up.",Input::keyToChar(throwkey));
907 sprintf (string3, "You can crouch and press the same key to drop it again.");
909 if(tutorialstage==41){
910 sprintf (string, "You can equip and unequip weapons using the %s key.",Input::keyToChar(drawkey));
911 sprintf (string2, "Sometimes it is best to keep them unequipped to");
912 sprintf (string3, "prevent enemies from taking them. ");
914 if(tutorialstage==42){
915 sprintf (string, "The knife is the smallest weapon and the least encumbering.");
916 sprintf (string2, "You can equip or unequip it while standing, crouching,");
917 sprintf (string3, "running or flipping.");
919 if(tutorialstage==43){
920 sprintf (string, "You perform weapon attacks the same way as unarmed attacks,");
921 sprintf (string2, "but sharp weapons cause permanent damage, instead of the");
922 sprintf (string3, "temporary trauma from blunt weapons, fists and feet.");
924 if(tutorialstage==44){
925 sprintf (string, "The enemy now has your knife!");
926 sprintf (string2, "Please reverse two of his knife attacks.");
927 sprintf (string3, " ");
929 if(tutorialstage==45){
930 sprintf (string, "Please reverse one more of his knife attacks.");
931 sprintf (string2, " ");
932 sprintf (string3, " ");
934 if(tutorialstage==46){
935 sprintf (string, "Now he has a sword!");
936 sprintf (string2, "The sword has longer reach than your arms, so you");
937 sprintf (string3, "must move close to reverse the sword slash.");
939 if(tutorialstage==47){
940 sprintf (string, "Long weapons like the sword and staff are also useful for defense;");
941 sprintf (string2, "you can parry enemy weapon attacks by pressing the attack key");
942 sprintf (string3, "at the right time. Please try parrying the enemy's attacks!");
944 if(tutorialstage==48){
945 sprintf (string, "The staff is like the sword, but has two main attacks.");
946 sprintf (string2, "The standing smash is fast and effective, and the running");
947 sprintf (string3, "spin smash is slower and more powerful.");
949 if(tutorialstage==49){
950 sprintf (string, "When facing an enemy, you can throw the knife with %s.",Input::keyToChar(throwkey));
951 sprintf (string2, "It is possible to throw the knife while flipping,");
952 sprintf (string3, "but it is very inaccurate.");
954 if(tutorialstage==50){
955 sprintf (string, "You now know everything you can learn from training.");
956 sprintf (string2, "Everything else you must learn from experience!");
957 sprintf (string3, " ");
959 if(tutorialstage==51){
960 sprintf (string, "Walk out of the training area to return to the main menu.");
961 sprintf (string2, " ");
962 sprintf (string3, " ");
965 glColor4f(0,0,0,tutorialopac);
966 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);
967 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);
968 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);
969 glColor4f(1,1,1,tutorialopac);
970 text.glPrint(screenwidth/2-7.6*strlen(string)*screenwidth/1024,screenheight/16+screenheight*4/5,string,1,1.5*screenwidth/1024,screenwidth,screenheight);
971 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);
972 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);
974 sprintf (string, "Press 'tab' to skip to the next item.",Input::keyToChar(jumpkey));
975 sprintf (string2, "Press escape at any time to");
976 sprintf (string3, "pause or exit the tutorial.");
979 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);
980 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);
981 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);
982 glColor4f(0.5,0.5,0.5,1);
983 text.glPrint(screenwidth/2-7.6*strlen(string)*screenwidth/1024*.8,0+screenheight*1/10,string,1,1.5*screenwidth/1024*.8,screenwidth,screenheight);
984 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);
985 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);
989 if(numhotspots&&(bonustime>=1||bonus<=0||bonustime<0)&&!tutoriallevel){
991 float closestdist=-1;
993 closest=currenthotspot;
994 for(i=0;i<numhotspots;i++){
995 distance=findDistancefast(&player[0].coords,&hotspot[i]);
996 if(closestdist==-1||distance<closestdist){
997 if(findDistancefast(&player[0].coords,&hotspot[i])<hotspotsize[i]&&((hotspottype[i]<=10&&hotspottype[i]>=0)||(hotspottype[i]<=40&&hotspottype[i]>=20))){
998 closestdist=distance;
1004 currenthotspot=closest;
1005 if(currenthotspot!=-1){
1006 if(hotspottype[closest]<=10){
1007 if(findDistancefast(&player[0].coords,&hotspot[closest])<hotspotsize[closest])
1008 tutorialstagetime=0;
1010 tutorialopac=tutorialmaxtime-tutorialstagetime;
1011 if(tutorialopac>1)tutorialopac=1;
1012 if(tutorialopac<0)tutorialopac=0;
1014 sprintf (string, "%s", hotspottext[closest]);
1022 if(string[i]=='\n'||string[i]>'z'||string[i]<' '||string[i]=='\0'){
1023 glColor4f(0,0,0,tutorialopac);
1024 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);
1025 glColor4f(1,1,1,tutorialopac);
1026 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);
1029 if(string[i]=='\0')done=1;
1035 else if (hotspottype[closest]>=20&&dialoguegonethrough[hotspottype[closest]-20]==0){
1036 whichdialogue=hotspottype[closest]-20;
1037 for(j=0;j<numdialogueboxes[whichdialogue];j++){
1038 player[participantfocus[whichdialogue][j]].coords=participantlocation[whichdialogue][participantfocus[whichdialogue][j]];
1039 player[participantfocus[whichdialogue][j]].rotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
1040 player[participantfocus[whichdialogue][j]].targetrotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
1041 player[participantfocus[whichdialogue][j]].velocity=0;
1042 player[participantfocus[whichdialogue][j]].targetanimation=player[participantfocus[whichdialogue][j]].getIdle();
1043 player[participantfocus[whichdialogue][j]].targetframe=0;
1047 dialoguegonethrough[whichdialogue]++;
1048 if(dialogueboxsound[whichdialogue][indialogue]!=0){
1049 static float gLoc[3];
1050 static float vel[3];
1051 gLoc[0]=player[participantfocus[whichdialogue][indialogue]].coords.x;
1052 gLoc[1]=player[participantfocus[whichdialogue][indialogue]].coords.y;
1053 gLoc[2]=player[participantfocus[whichdialogue][indialogue]].coords.z;
1058 if(dialogueboxsound[whichdialogue][indialogue]==1)whichsoundplay=rabbitchitter;
1059 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
1060 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
1061 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
1062 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
1063 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
1064 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
1065 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
1066 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
1067 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
1068 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
1069 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
1070 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
1071 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
1072 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
1073 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
1074 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
1075 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
1076 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
1077 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
1078 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, true);
1079 OPENAL_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
1080 OPENAL_SetVolume(channels[whichsoundplay], 256);
1081 OPENAL_SetPaused(channels[whichsoundplay], false);
1087 if(indialogue!=-1&&!mainmenu){
1088 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1089 glDisable(GL_CULL_FACE);
1090 glDisable(GL_LIGHTING);
1091 glDisable(GL_TEXTURE_2D);
1093 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1094 glPushMatrix(); // Store The Projection Matrix
1095 glLoadIdentity(); // Reset The Projection Matrix
1096 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1097 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1098 glPushMatrix(); // Store The Modelview Matrix
1099 glLoadIdentity(); // Reset The Modelview Matrix
1100 if(dialogueboxlocation[whichdialogue][indialogue]==1)glTranslatef(0,screenheight*3/4,0);
1101 glScalef(screenwidth,screenheight/4,1);
1102 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1105 glColor4f(dialogueboxcolor[whichdialogue][indialogue][0],dialogueboxcolor[whichdialogue][indialogue][1],dialogueboxcolor[whichdialogue][indialogue][2],0.7);
1107 glVertex3f(0, 0, 0.0f);
1108 glVertex3f(1, 0, 0.0f);
1109 glVertex3f(1, 1, 0.0f);
1110 glVertex3f(0, 1, 0.0f);
1112 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1113 glPopMatrix(); // Restore The Old Projection Matrix
1114 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1115 glPopMatrix(); // Restore The Old Projection Matrix
1116 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1117 glEnable(GL_CULL_FACE);
1118 glDisable(GL_BLEND);
1120 glEnable(GL_TEXTURE_2D);
1127 startx=screenwidth*1/5;
1128 if(dialogueboxlocation[whichdialogue][indialogue]==1)starty=screenheight/16+screenheight*4/5;
1129 if(dialogueboxlocation[whichdialogue][indialogue]==2)starty=screenheight*1/5-screenheight/16;
1131 // char tempname[64];
1135 // for(i=0;i<64;i++){
1140 for(i=0;i<(int)strlen(dialoguename[whichdialogue][indialogue]);i++){
1141 tempname[tempnum]=dialoguename[whichdialogue][indialogue][i];
1143 if(dialoguename[whichdialogue][indialogue][i]=='#'||dialoguename[whichdialogue][indialogue][i]=='\0')goodchar=0;
1144 //if(tempnum>2)if(tempname[tempnum-2]=='e'&&tempname[tempnum-1]=='r')goodchar=0;
1145 //if(tempnum>2)if(tempname[tempnum]=='r'&&tempname[0]=='a')goodchar=0;
1146 if(goodchar)tempnum++;
1147 else tempname[tempnum]='\0';
1150 sprintf (string, "%s: ", tempname);
1152 if(dialogueboxcolor[whichdialogue][indialogue][0]+dialogueboxcolor[whichdialogue][indialogue][1]+dialogueboxcolor[whichdialogue][indialogue][2]<1.5){
1153 glColor4f(0,0,0,tutorialopac);
1154 text.glPrintOutline(startx-2*7.6*strlen(string)*screenwidth/1024-4,starty-4,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight);
1155 glColor4f(0.7,0.7,0.7,tutorialopac);
1156 text.glPrint(startx-2*7.6*strlen(string)*screenwidth/1024,starty,string,1,1.5*screenwidth/1024,screenwidth,screenheight);
1160 glColor4f(0,0,0,tutorialopac);
1161 text.glPrintOutline(startx-2*7.6*strlen(string)*screenwidth/1024-4,starty-4,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight);
1166 for(i=0;i<(int)strlen(dialoguetext[whichdialogue][indialogue])+1;i++){
1167 tempname[tempnum]=dialoguetext[whichdialogue][indialogue][i];
1168 if(dialoguetext[whichdialogue][indialogue][i]!='#')tempnum++;
1172 sprintf (string, "%s", tempname);
1181 if(string[i]=='\n'||string[i]>'z'||string[i]<' '||string[i]=='\0'){
1182 if(dialogueboxcolor[whichdialogue][indialogue][0]+dialogueboxcolor[whichdialogue][indialogue][1]+dialogueboxcolor[whichdialogue][indialogue][2]<1.5){
1183 glColor4f(0,0,0,tutorialopac);
1184 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);
1185 glColor4f(1,1,1,tutorialopac);
1186 text.glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/,starty-20*screenwidth/1024*line,string,1,1.5*screenwidth/1024,screenwidth,screenheight,lastline,i);
1190 glColor4f(0,0,0,tutorialopac);
1191 text.glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/,starty-20*screenwidth/1024*line,string,1,1.5*screenwidth/1024,screenwidth,screenheight,lastline,i);
1195 if(string[i]=='\0')done=1;
1202 if(!tutoriallevel&&!winfreeze&&indialogue==-1&&!mainmenu){
1204 if(!scoreadded)sprintf (string, "Score: %d", (int)accountactive->getCampaignScore()+(int)bonustotal);//(int)bonustotal);
1205 if(scoreadded)sprintf (string, "Score: %d", (int)accountactive->getCampaignScore());//(int)bonustotal);
1207 if(!campaign)sprintf (string, "Score: %d", (int)bonustotal);
1209 text.glPrintOutline(1024/40-4,768/16-4+768*14/16,string,1,1.5*1.25,1024,768);
1211 text.glPrint(1024/40,768/16+768*14/16,string,1,1.5,1024,768);
1213 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1214 glDisable(GL_CULL_FACE);
1215 glDisable(GL_LIGHTING);
1216 glDisable(GL_TEXTURE_2D);
1218 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1219 glPushMatrix(); // Store The Projection Matrix
1220 glLoadIdentity(); // Reset The Projection Matrix
1221 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1222 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1223 glPushMatrix(); // Store The Modelview Matrix
1224 glLoadIdentity(); // Reset The Modelview Matrix
1225 glTranslatef(15,screenheight*17.5/20,0);
1226 glScalef(screenwidth/3+20,screenheight/20,1);
1227 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1229 glColor4f(0.0,0.4,0.0,0.7);
1230 float bar=((float)player[0].damage)/player[0].damagetolerance;
1232 glVertex3f((bar<1?bar:1),0,0.0f);
1233 glVertex3f(1,0,0.0f);
1234 glVertex3f(1,1,0.0f);
1235 glVertex3f((bar<1?bar:1),1,0.0f);
1237 glColor4f(0.1,0.0,0.0,1);
1238 bar = ((float)player[0].bloodloss)/player[0].damagetolerance;
1240 glVertex3f(0,0,0.0f);
1241 glVertex3f((bar<1?bar:1),0,0.0f);
1242 glVertex3f((bar<1?bar:1),1,0.0f);
1243 glVertex3f(0,1,0.0f);
1245 glColor4f(0.4,0.0,0.0,0.7);
1246 bar = ((float)player[0].damage)/player[0].damagetolerance;
1248 glVertex3f(0,0,0.0f);
1249 glVertex3f((bar<1?bar:1),0,0.0f);
1250 glVertex3f((bar<1?bar:1),1,0.0f);
1251 glVertex3f(0,1,0.0f);
1253 glColor4f(0.4,0.0,0.0,0.7);
1254 bar = ((float)player[0].permanentdamage)/player[0].damagetolerance;
1256 glVertex3f(0,0,0.0f);
1257 glVertex3f((bar<1?bar:1),0,0.0f);
1258 glVertex3f((bar<1?bar:1),1,0.0f);
1259 glVertex3f(0,1,0.0f);
1261 glColor4f(0.4,0.0,0.0,0.7);
1262 bar = ((float)player[0].superpermanentdamage)/player[0].damagetolerance;
1264 glVertex3f(0,0,0.0f);
1265 glVertex3f((bar<1?bar:1),0,0.0f);
1266 glVertex3f((bar<1?bar:1),1,0.0f);
1267 glVertex3f(0,1,0.0f);
1269 glColor4f(0.0,0.0,0.0,0.7);
1271 glBegin(GL_LINE_STRIP);
1272 glVertex3f(0,0,0.0f);
1273 glVertex3f(1,0,0.0f);
1274 glVertex3f(1,1,0.0f);
1275 glVertex3f(0,1,0.0f);
1276 glVertex3f(0,0,0.0f);
1279 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1280 glPopMatrix(); // Restore The Old Projection Matrix
1281 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1282 glPopMatrix(); // Restore The Old Projection Matrix
1283 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1284 glEnable(GL_CULL_FACE);
1285 glDisable(GL_BLEND);
1287 glEnable(GL_TEXTURE_2D);
1289 // writing the numbers :
1290 sprintf (string, "Damages : %d/%d (%d)",(int)(player[0].damage),(int)(player[0].damagetolerance),(int)(player[0].bloodloss));
1292 text.glPrintOutline(1024/40-4,768/16-4+768*14/16-40,string,1,1.5*1.25,1024,768);
1294 text.glPrint(1024/40,768/16+768*14/16-40,string,1,1.5,1024,768);
1298 glColor4f(.5,.5,.5,1);
1301 if((texttoggle||editorenabled)&&debugmode&&!mainmenu){
1302 sprintf (string, "The framespersecond is %d.",(int)(fps));
1303 text.glPrint(10,30,string,0,.8,1024,768);
1305 sprintf (string, "Name: %s", registrationname);
1306 text.glPrint(10,260,string,0,.8,1024,768);
1309 if(editorenabled)sprintf (string, "Map editor enabled.");
1310 if(!editorenabled)sprintf (string, "Map editor Disabled.");
1311 text.glPrint(10,60,string,0,.8,1024,768);
1313 sprintf (string, "Object size: %f",editorsize);
1314 text.glPrint(10,75,string,0,.8,1024,768);
1315 if(editorrotation>=0)sprintf (string, "Object rotation: %f",editorrotation);
1316 else sprintf (string, "Object rotation: Random");
1317 text.glPrint(10,90,string,0,.8,1024,768);
1318 if(editorrotation2>=0)sprintf (string, "Object rotation2: %f",editorrotation2);
1319 else sprintf (string, "Object rotation2: Random");
1320 text.glPrint(10,105,string,0,.8,1024,768);
1321 sprintf (string, "Object type: %d",editortype);
1322 text.glPrint(10,120,string,0,.8,1024,768);
1323 if(editortype==boxtype)sprintf (string, "(box)");
1324 if(editortype==treetrunktype)sprintf (string, "(tree)");
1325 if(editortype==walltype)sprintf (string, "(wall)");
1326 if(editortype==weirdtype)sprintf (string, "(weird)");
1327 if(editortype==spiketype)sprintf (string, "(spike)");
1328 if(editortype==rocktype)sprintf (string, "(rock)");
1329 if(editortype==bushtype)sprintf (string, "(bush)");
1330 if(editortype==tunneltype)sprintf (string, "(tunnel)");
1331 if(editortype==chimneytype)sprintf (string, "(chimney)");
1332 if(editortype==platformtype)sprintf (string, "(platform)");
1333 if(editortype==cooltype)sprintf (string, "(cool)");
1334 if(editortype==firetype)sprintf (string, "(fire)");
1335 text.glPrint(130,120,string,0,.8,1024,768);
1337 sprintf (string, "Numplayers: %d",numplayers);
1338 text.glPrint(10,155,string,0,.8,1024,768);
1339 sprintf (string, "Player %d: numwaypoints: %d",numplayers,player[numplayers-1].numwaypoints);
1340 text.glPrint(10,140,string,0,.8,1024,768);
1342 /*sprintf (string, "Coords are: %f %f %f",player[0].coords.x,player[0].coords.y,player[0].coords.z);
1343 text.glPrint(10,200,string,0,.8,1024,768);*/
1344 sprintf (string, "Difficulty: %d",difficulty);
1345 text.glPrint(10,240,string,0,.8,1024,768);
1347 sprintf (string, "lasthotspot: %d",hotspottype[numhotspots-1]);
1348 text.glPrint(10,240,string,0,.8,1024,768);
1349 sprintf (string, "killhotspot: %d",killhotspot);
1350 text.glPrint(10,220,string,0,.8,1024,768);
1351 sprintf (string, "winhotspot: %d",winhotspot);
1352 text.glPrint(10,200,string,0,.8,1024,768);*/
1357 if(drawmode==glowmode){
1358 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1359 glDisable(GL_CULL_FACE);
1360 glDisable(GL_LIGHTING);
1361 glDisable(GL_TEXTURE_2D);
1363 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1364 glPushMatrix(); // Store The Projection Matrix
1365 glLoadIdentity(); // Reset The Projection Matrix
1366 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1367 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1368 glPushMatrix(); // Store The Modelview Matrix
1369 glLoadIdentity(); // Reset The Modelview Matrix
1370 glScalef(screenwidth,screenheight,1);
1371 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1373 glColor4f(0,0,0,.5);
1375 glVertex3f(0, 0, 0.0f);
1376 glVertex3f(256, 0, 0.0f);
1377 glVertex3f(256, 256, 0.0f);
1378 glVertex3f(0, 256, 0.0f);
1380 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1381 glPopMatrix(); // Restore The Old Projection Matrix
1382 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1383 glPopMatrix(); // Restore The Old Projection Matrix
1384 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1385 glEnable(GL_CULL_FACE);
1386 glDisable(GL_BLEND);
1390 if((((blackout&&damageeffects)||(player[0].bloodloss>0&&damageeffects&&player[0].blooddimamount>0)||player[0].dead)&&!cameramode)||console){
1391 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1392 glDisable(GL_CULL_FACE);
1393 glDisable(GL_LIGHTING);
1394 glDisable(GL_TEXTURE_2D);
1396 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1397 glPushMatrix(); // Store The Projection Matrix
1398 glLoadIdentity(); // Reset The Projection Matrix
1399 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1400 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1401 glPushMatrix(); // Store The Modelview Matrix
1402 glLoadIdentity(); // Reset The Modelview Matrix
1403 glScalef(screenwidth,screenheight,1);
1404 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1406 if(player[0].dead)blackout+=multiplier*3;
1407 if(player[0].dead==1)blackout=.4f;
1408 if(player[0].dead==2&&blackout>.6)blackout=.6;
1409 glColor4f(0,0,0,blackout);
1410 if(!player[0].dead){
1411 if((player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5))*.3<.3){
1412 glColor4f(0,0,0,player[0].blooddimamount*player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5)*.3);
1413 blackout=player[0].blooddimamount*player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5)*.3;
1416 glColor4f(0,0,0,player[0].blooddimamount*.3);
1417 blackout=player[0].blooddimamount*.3;
1420 if(console)glColor4f(.7,0,0,.2);
1422 glVertex3f(0, 0, 0.0f);
1423 glVertex3f(256, 0, 0.0f);
1424 glVertex3f(256, 256, 0.0f);
1425 glVertex3f(0, 256, 0.0f);
1427 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1428 glPopMatrix(); // Restore The Old Projection Matrix
1429 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1430 glPopMatrix(); // Restore The Old Projection Matrix
1431 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1432 glEnable(GL_CULL_FACE);
1433 glDisable(GL_BLEND);
1437 if(flashamount>0&&damageeffects){
1438 if(flashamount>1)flashamount=1;
1439 if(flashdelay<=0)flashamount-=multiplier;
1441 if(flashamount<0)flashamount=0;
1442 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1443 glDisable(GL_CULL_FACE);
1444 glDisable(GL_LIGHTING);
1446 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1447 glPushMatrix(); // Store The Projection Matrix
1448 glLoadIdentity(); // Reset The Projection Matrix
1449 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1450 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1451 glPushMatrix(); // Store The Modelview Matrix
1452 glLoadIdentity(); // Reset The Modelview Matrix
1453 glScalef(screenwidth,screenheight,1);
1454 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1456 glColor4f(flashr,flashg,flashb,flashamount);
1458 glVertex3f(0, 0, 0.0f);
1459 glVertex3f(256, 0, 0.0f);
1460 glVertex3f(256, 256, 0.0f);
1461 glVertex3f(0, 256, 0.0f);
1463 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1464 glPopMatrix(); // Restore The Old Projection Matrix
1465 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1466 glPopMatrix(); // Restore The Old Projection Matrix
1467 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1468 glEnable(GL_CULL_FACE);
1469 glDisable(GL_BLEND);
1475 glEnable(GL_TEXTURE_2D);
1478 sprintf (string, " ]");
1479 text.glPrint(10,30+screenheight-330,string,0,1,screenwidth,screenheight);
1481 sprintf (string, "_");
1482 text.glPrint(30+(float)(displayselected)*10,30+(screenheight-330),string,0,1,screenwidth,screenheight);
1486 if((i!=0||chatting)&&displaytime[i]<4)
1487 for(j=0;j<displaychars[i];j++){
1488 glColor4f(1,1,1,4-displaytime[i]);
1489 if(j<displaychars[i]){
1490 sprintf (string, "%c",displaytext[i][j]);
1491 text.glPrint(30+j*10,30+i*20+(screenheight-330),string,0,1,screenwidth,screenheight);
1497 if(minimap&&indialogue==-1){
1501 glDisable(GL_DEPTH_TEST);
1502 glColor3f (1.0, 1.0, 1.0); // no coloring
1504 glEnable(GL_TEXTURE_2D);
1505 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1506 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1507 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1508 glDisable(GL_CULL_FACE);
1509 glDisable(GL_LIGHTING);
1511 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1512 glPushMatrix(); // Store The Projection Matrix
1513 glLoadIdentity(); // Reset The Projection Matrix
1514 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1515 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1516 glPushMatrix(); // Store The Modelview Matrix
1517 glLoadIdentity(); // Reset The Modelview Matrix
1518 glScalef((float)screenwidth/2,(float)screenwidth/2,1);
1519 glTranslatef(1.75,.25,0);
1520 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1530 int numliveplayers=0;
1531 for(i=0;i<numplayers;i++){
1532 if(!player[i].dead)numliveplayers++;
1538 for(i=0;i<objects.numobjects;i++){
1539 if(objects.type[i]==treetrunktype||objects.type[i]==boxtype){
1540 center+=objects.position[i];
1544 for(i=0;i<numplayers;i++){
1545 if(!player[i].dead)center+=player[i].coords;
1547 center/=numadd+numliveplayers;
1549 center=player[0].coords;
1551 float maxdistance=0;
1554 for(i=0;i<objects.numobjects;i++){
1555 tempdist=findDistancefast(¢er,&objects.position[i]);
1556 if(tempdist>maxdistance){
1558 maxdistance=tempdist;
1561 for(i=0;i<numplayers;i++){
1562 if(!player[i].dead){
1563 tempdist=findDistancefast(¢er,&player[i].coords);
1564 if(tempdist>maxdistance){
1566 maxdistance=tempdist;
1570 radius=fast_sqrt(maxdistance);
1574 glScalef(.25/radius*256*terrain.scale*.4,.25/radius*256*terrain.scale*.4,1);
1576 glScalef(1/(1/radius*256*terrain.scale*.4),1/(1/radius*256*terrain.scale*.4),1);
1578 glRotatef(player[0].lookrotation*-1+180,0,0,1);
1579 glTranslatef(-(center.x/terrain.scale/256*-2+1),(center.z/terrain.scale/256*-2+1),0);
1580 for(i=0;i<objects.numobjects;i++){
1581 if(objects.type[i]==treetrunktype){
1582 distcheck=findDistancefast(&player[0].coords,&objects.position[i]);
1583 if(distcheck<mapviewdist){
1584 glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
1585 glColor4f(0,.3,0,opac*(1-distcheck/mapviewdist));
1587 glTranslatef(objects.position[i].x/terrain.scale/256*-2+1,objects.position[i].z/terrain.scale/256*2-1,0);
1588 glRotatef(objects.rotation[i],0,0,1);
1589 glScalef(.003,.003,.003);
1592 glVertex3f(-1, -1, 0.0f);
1594 glVertex3f(1, -1, 0.0f);
1596 glVertex3f(1, 1, 0.0f);
1598 glVertex3f(-1, 1, 0.0f);
1603 if(objects.type[i]==boxtype){
1604 distcheck=findDistancefast(&player[0].coords,&objects.position[i]);
1605 if(distcheck<mapviewdist){
1606 glBindTexture( GL_TEXTURE_2D, Mapboxtexture);
1607 glColor4f(.4,.4,.4,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(.01*objects.scale[i],.01*objects.scale[i],.01*objects.scale[i]);
1614 glVertex3f(-1, -1, 0.0f);
1616 glVertex3f(1, -1, 0.0f);
1618 glVertex3f(1, 1, 0.0f);
1620 glVertex3f(-1, 1, 0.0f);
1627 glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
1628 for(i=0;i<numboundaries;i++){
1629 glColor4f(0,0,0,opac/3);
1631 glTranslatef(boundary[i].x/terrain.scale/256*-2+1,boundary[i].z/terrain.scale/256*2-1,0);
1632 glScalef(.002,.002,.002);
1635 glVertex3f(-1, -1, 0.0f);
1637 glVertex3f(1, -1, 0.0f);
1639 glVertex3f(1, 1, 0.0f);
1641 glVertex3f(-1, 1, 0.0f);
1646 for(i=0;i<numplayers;i++){
1647 distcheck=findDistancefast(&player[0].coords,&player[i].coords);
1648 if(distcheck<mapviewdist){
1650 glBindTexture( GL_TEXTURE_2D, Maparrowtexture);
1651 if(i==0)glColor4f(1,1,1,opac);
1652 else if(player[i].dead==2||player[i].howactive>typesleeping)glColor4f(0,0,0,opac*(1-distcheck/mapviewdist));
1653 else if(player[i].dead)glColor4f(.3,.3,.3,opac*(1-distcheck/mapviewdist));
1654 else if(player[i].aitype==attacktypecutoff)glColor4f(1,0,0,opac*(1-distcheck/mapviewdist));
1655 else if(player[i].aitype==passivetype)glColor4f(0,1,0,opac*(1-distcheck/mapviewdist));
1656 else glColor4f(1,1,0,1);
1657 glTranslatef(player[i].coords.x/terrain.scale/256*-2+1,player[i].coords.z/terrain.scale/256*2-1,0);
1658 glRotatef(player[i].rotation+180,0,0,1);
1659 glScalef(.005,.005,.005);
1662 glVertex3f(-1, -1, 0.0f);
1664 glVertex3f(1, -1, 0.0f);
1666 glVertex3f(1, 1, 0.0f);
1668 glVertex3f(-1, 1, 0.0f);
1670 /*glBegin(GL_TRIANGLES);
1672 glVertex3f(-1, -1, 0.0f);
1674 glVertex3f(1, -1, 0.0f);
1676 glVertex3f(0, 1, 0.0f);
1681 /*glBegin(GL_QUADS);
1683 glVertex3f(-1, -1, 0.0f);
1685 glVertex3f(1, -1, 0.0f);
1687 glVertex3f(1, 1, 0.0f);
1689 glVertex3f(-1, 1, 0.0f);
1692 glDisable(GL_TEXTURE_2D);
1693 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1694 glPopMatrix(); // Restore The Old Projection Matrix
1695 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1696 glPopMatrix(); // Restore The Old Projection Matrix
1697 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1698 glEnable(GL_CULL_FACE);
1699 glDisable(GL_BLEND);
1705 drawmode=normalmode;
1709 if(loading&&!stealthloading&&(!campaign||player[0].dead)){
1710 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1711 glDisable(GL_CULL_FACE);
1712 glDisable(GL_LIGHTING);
1713 glDisable(GL_TEXTURE_2D);
1715 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1716 glPushMatrix(); // Store The Projection Matrix
1717 glLoadIdentity(); // Reset The Projection Matrix
1718 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1719 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1720 glPushMatrix(); // Store The Modelview Matrix
1721 glLoadIdentity(); // Reset The Modelview Matrix
1722 glScalef(screenwidth,screenheight,1);
1723 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1725 glColor4f(0,0,0,.7);
1727 glVertex3f(0, 0, 0.0f);
1728 glVertex3f(256, 0, 0.0f);
1729 glVertex3f(256, 256, 0.0f);
1730 glVertex3f(0, 256, 0.0f);
1732 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1733 glPopMatrix(); // Restore The Old Projection Matrix
1734 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1735 glPopMatrix(); // Restore The Old Projection Matrix
1736 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1737 glEnable(GL_CULL_FACE);
1738 glDisable(GL_BLEND);
1742 glDisable(GL_DEPTH_TEST);
1743 glColor3f (1.0, 1.0, 1.0); // no coloring
1745 glEnable(GL_TEXTURE_2D);
1750 glEnable(GL_TEXTURE_2D);
1752 sprintf (string, "Loading...");
1753 text.glPrint(1024/2-90,768/2,string,1,2,1024,768);
1756 //if(ismotionblur)drawmode=motionblurmode;
1757 drawmode=normalmode;
1760 if(winfreeze&&!campaign){
1761 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1762 glDisable(GL_CULL_FACE);
1763 glDisable(GL_LIGHTING);
1764 glDisable(GL_TEXTURE_2D);
1766 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1767 glPushMatrix(); // Store The Projection Matrix
1768 glLoadIdentity(); // Reset The Projection Matrix
1769 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1770 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1771 glPushMatrix(); // Store The Modelview Matrix
1772 glLoadIdentity(); // Reset The Modelview Matrix
1773 glScalef(screenwidth,screenheight,1);
1774 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1776 glColor4f(0,0,0,.4);
1778 glVertex3f(0, 0, 0.0f);
1779 glVertex3f(256, 0, 0.0f);
1780 glVertex3f(256, 256, 0.0f);
1781 glVertex3f(0, 256, 0.0f);
1783 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1784 glPopMatrix(); // Restore The Old Projection Matrix
1785 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1786 glPopMatrix(); // Restore The Old Projection Matrix
1787 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1788 glEnable(GL_CULL_FACE);
1789 glDisable(GL_BLEND);
1793 glDisable(GL_DEPTH_TEST);
1794 glColor3f (1.0, 1.0, 1.0); // no coloring
1796 glEnable(GL_TEXTURE_2D);
1797 /*glBindTexture( GL_TEXTURE_2D, logotexture);
1798 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1799 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1800 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1801 glDisable(GL_CULL_FACE);
1802 glDisable(GL_LIGHTING);
1804 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1805 glPushMatrix(); // Store The Projection Matrix
1806 glLoadIdentity(); // Reset The Projection Matrix
1807 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1808 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1809 glPushMatrix(); // Store The Modelview Matrix
1810 glLoadIdentity(); // Reset The Modelview Matrix
1811 glScalef((float)screenwidth/2,(float)screenwidth/2,1);
1812 glTranslatef(1.8,1.25,0);
1813 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1817 glScalef(.25,.25,.25);
1820 glVertex3f(-1, -1, 0.0f);
1822 glVertex3f(1, -1, 0.0f);
1824 glVertex3f(1, 1, 0.0f);
1826 glVertex3f(-1, 1, 0.0f);
1829 glDisable(GL_TEXTURE_2D);
1830 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1831 glPopMatrix(); // Restore The Old Projection Matrix
1832 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1833 glPopMatrix(); // Restore The Old Projection Matrix
1834 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1835 glEnable(GL_CULL_FACE);
1836 glDisable(GL_BLEND);
1844 if(damagetaken==0&&player[0].bloodloss==0){
1845 awards[numawards]=awardflawless;
1851 for(i=1;i<numplayers;i++){
1852 if(player[i].dead!=2)alldead=0;
1855 awards[numawards]=awardalldead;
1860 for(i=1;i<numplayers;i++){
1861 if(player[i].dead!=1)alldead=0;
1864 awards[numawards]=awardnodead;
1867 if(numresponded==0&&!numthrowkill){
1868 awards[numawards]=awardstealth;
1871 if(numattacks==numstaffattack&&numattacks>0){
1872 awards[numawards]=awardbojutsu;
1875 if(numattacks==numswordattack&&numattacks>0){
1876 awards[numawards]=awardswordsman;
1879 if(numattacks==numknifeattack&&numattacks>0){
1880 awards[numawards]=awardknifefighter;
1883 if(numattacks==numunarmedattack&&numthrowkill==0&&weapons.numweapons>0){
1884 awards[numawards]=awardkungfu;
1888 awards[numawards]=awardevasion;
1891 if(numflipfail==0&&numflipped+numwallflipped*2>20){
1892 awards[numawards]=awardacrobat;
1895 if(numthrowkill==numplayers-1){
1896 awards[numawards]=awardlongrange;
1901 for(i=1;i<numplayers;i++){
1902 if(player[i].dead!=2)alldead=0;
1904 if(numafterkill>0&&alldead){
1905 awards[numawards]=awardbrutal;
1908 if(numreversals>((float)numattacks)*.8&&numreversals>3){
1909 awards[numawards]=awardaikido;
1912 if(maxalarmed==1&&numplayers>2){
1913 awards[numawards]=awardstrategy;
1917 awards[numawards]=awardklutz;
1922 //Win Screen Won Victory
1924 glEnable(GL_TEXTURE_2D);
1926 sprintf (string, "Level Cleared!");
1927 text.glPrintOutlined(1024/2-strlen(string)*10,768*7/8,string,1,2,1024,768);
1929 sprintf (string, "Score: %d",(int)(bonustotal-startbonustotal));
1930 text.glPrintOutlined(1024/30,768*6/8,string,1,2,1024,768);
1932 if(!campaign)sprintf (string, "Press Escape to return to menu or Space to continue");
1933 if(campaign)sprintf (string, "Press Escape or Space to continue");
1934 text.glPrintOutlined(640/2-strlen(string)*5,480*1/16,string,1,1,640,480);
1938 for(i=0;i<255;i++)string[i]='\0';
1939 sprintf (temp, "Time: %d:",(int)(((int)leveltime-(int)(leveltime)%60)/60));
1940 strcat(string,temp);
1941 if((int)(leveltime)%60<10)strcat(string,"0");
1942 sprintf (temp, "%d",(int)(leveltime)%60);
1943 strcat(string,temp);
1944 text.glPrintOutlined(1024/30,768*6/8-40,string,1,2,1024,768);
1946 for(i=0;i<numawards;i++){
1948 if(awards[i]==awardklutz)sprintf (string, "Suicidal");
1949 if(awards[i]==awardflawless)sprintf (string, "Flawless!");
1950 if(awards[i]==awardalldead)sprintf (string, "Take no prisoners");
1951 if(awards[i]==awardnodead)sprintf (string, "Merciful");
1952 if(awards[i]==awardstealth)sprintf (string, "One with the shadows!");
1953 if(awards[i]==awardswordsman)sprintf (string, "Swordsman");
1954 if(awards[i]==awardkungfu)sprintf (string, "Unarmed!");
1955 if(awards[i]==awardknifefighter)sprintf (string, "Knife fighter");
1956 if(awards[i]==awardcoward)sprintf (string, "Coward");
1957 if(awards[i]==awardevasion)sprintf (string, "Escape artist");
1958 if(awards[i]==awardacrobat)sprintf (string, "Gymnast");
1959 if(awards[i]==awardlongrange)sprintf (string, "Blade slinger");
1960 if(awards[i]==awardbrutal)sprintf (string, "Brutal");
1961 if(awards[i]==awardhyper)sprintf (string, "Hyper");
1962 if(awards[i]==awardaikido)sprintf (string, "Aikido master!");
1963 if(awards[i]==awardrambo)sprintf (string, "Rambo");
1964 if(awards[i]==awardfast)sprintf (string, "Fast");
1965 if(awards[i]==awardrealfast)sprintf (string, "Real fast");
1966 if(awards[i]==awarddamnfast)sprintf (string, "Damn fast");
1967 if(awards[i]==awardstrategy)sprintf (string, "Divide and conquer");
1968 if(awards[i]==awardbojutsu)sprintf (string, "Bojutsu");
1969 text.glPrintOutlined(1024/30,768*6/8-90-40*i,string,1,2,1024,768);
1973 //drawmode=normalmode;
1976 if(drawmode!=normalmode){
1977 glEnable(GL_TEXTURE_2D);
1979 if(!drawtoggle||drawmode!=realmotionblurmode||(drawtoggle==2||change==1)){
1982 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
1983 GLfloat subtractColor[4] = { 0.5, 0.5, 0.5, 0.0 };
1984 glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, subtractColor);
1985 //glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_SUBTRACT);
1986 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE);
1987 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_CONSTANT_EXT);
1988 glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 2.0f);
1990 glBindTexture( GL_TEXTURE_2D, screentexture);
1991 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1994 if((drawtoggle||change==1)&&drawmode==realmotionblurmode){
1996 glBindTexture( GL_TEXTURE_2D, screentexture2);
1997 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1999 if(!screentexture2){
2000 glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
2002 glGenTextures( 1, &screentexture2 );
2003 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
2005 glEnable(GL_TEXTURE_2D);
2006 glBindTexture( GL_TEXTURE_2D, screentexture2);
2007 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
2008 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
2010 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
2016 glClear(GL_DEPTH_BUFFER_BIT);
2017 ReSizeGLScene(90,.1f);
2018 glViewport(0,0,screenwidth,screenheight);
2020 if(drawmode!=normalmode){
2021 glDisable(GL_DEPTH_TEST);
2022 if(drawmode==motionblurmode){
2023 glDrawBuffer(GL_FRONT);
2024 glReadBuffer(GL_BACK);
2025 //myassert(glGetError() == GL_NO_ERROR);
2028 glColor3f (1.0, 1.0, 1.0); // no coloring
2030 glEnable(GL_TEXTURE_2D);
2031 glBindTexture( GL_TEXTURE_2D, screentexture);
2032 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
2033 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
2034 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
2035 glDisable(GL_CULL_FACE);
2036 glDisable(GL_LIGHTING);
2038 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2039 glPushMatrix(); // Store The Projection Matrix
2040 glLoadIdentity(); // Reset The Projection Matrix
2041 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
2042 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2043 glPushMatrix(); // Store The Modelview Matrix
2044 glLoadIdentity(); // Reset The Modelview Matrix
2045 glScalef((float)screenwidth/2,(float)screenheight/2,1);
2046 glTranslatef(1,1,0);
2047 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
2049 if(drawmode==motionblurmode){
2050 if(motionbluramount<.2)motionbluramount=.2;
2051 //glColor4f(1,1,1,fast_sqrt(multiplier)*2.9*motionbluramount);
2052 glColor4f(1,1,1,motionbluramount);
2056 glVertex3f(-1, -1, 0.0f);
2057 glTexCoord2f(texcoordwidth,0);
2058 glVertex3f(1, -1, 0.0f);
2059 glTexCoord2f(texcoordwidth,texcoordheight);
2060 glVertex3f(1, 1, 0.0f);
2061 glTexCoord2f(0,texcoordheight);
2062 glVertex3f(-1, 1, 0.0f);
2066 if(drawmode==realmotionblurmode){
2067 glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
2068 glClear(GL_COLOR_BUFFER_BIT);
2069 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
2070 glBindTexture( GL_TEXTURE_2D, screentexture);
2071 glColor4f(1,1,1,.5);
2075 glVertex3f(-1, -1, 0.0f);
2076 glTexCoord2f(texcoordwidth,0);
2077 glVertex3f(1, -1, 0.0f);
2078 glTexCoord2f(texcoordwidth,texcoordheight);
2079 glVertex3f(1, 1, 0.0f);
2080 glTexCoord2f(0,texcoordheight);
2081 glVertex3f(-1, 1, 0.0f);
2084 glBindTexture( GL_TEXTURE_2D, screentexture2);
2085 glColor4f(1,1,1,.5);
2089 glVertex3f(-1, -1, 0.0f);
2090 glTexCoord2f(texcoordwidth,0);
2091 glVertex3f(1, -1, 0.0f);
2092 glTexCoord2f(texcoordwidth,texcoordheight);
2093 glVertex3f(1, 1, 0.0f);
2094 glTexCoord2f(0,texcoordheight);
2095 glVertex3f(-1, 1, 0.0f);
2098 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
2100 if(drawmode==doublevisionmode){
2101 static float crosseyedness;
2102 crosseyedness=abs(player[0].damage-player[0].superpermanentdamage-(player[0].damagetolerance-player[0].superpermanentdamage)*1/2)/30;
2103 if(crosseyedness>1)crosseyedness=1;
2104 if(crosseyedness<0)crosseyedness=0;
2106 glDisable(GL_BLEND);
2111 glVertex3f(-1, -1, 0.0f);
2112 glTexCoord2f(texcoordwidth,0);
2113 glVertex3f(1, -1, 0.0f);
2114 glTexCoord2f(texcoordwidth,texcoordheight);
2115 glVertex3f(1, 1, 0.0f);
2116 glTexCoord2f(0,texcoordheight);
2117 glVertex3f(-1, 1, 0.0f);
2121 glColor4f(1,1,1,.5);
2124 glTranslatef(.015*crosseyedness,0,0);
2128 glVertex3f(-1, -1, 0.0f);
2129 glTexCoord2f(texcoordwidth,0);
2130 glVertex3f(1, -1, 0.0f);
2131 glTexCoord2f(texcoordwidth,texcoordheight);
2132 glVertex3f(1, 1, 0.0f);
2133 glTexCoord2f(0,texcoordheight);
2134 glVertex3f(-1, 1, 0.0f);
2139 if(drawmode==glowmode){
2140 glColor4f(.5,.5,.5,.5);
2142 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
2144 glTranslatef(.01,0,0);
2147 glVertex3f(-1, -1, 0.0f);
2148 glTexCoord2f(texcoordwidth,0);
2149 glVertex3f(1, -1, 0.0f);
2150 glTexCoord2f(texcoordwidth,texcoordheight);
2151 glVertex3f(1, 1, 0.0f);
2152 glTexCoord2f(0,texcoordheight);
2153 glVertex3f(-1, 1, 0.0f);
2157 glTranslatef(-.01,0,0);
2160 glVertex3f(-1, -1, 0.0f);
2161 glTexCoord2f(texcoordwidth,0);
2162 glVertex3f(1, -1, 0.0f);
2163 glTexCoord2f(texcoordwidth,texcoordheight);
2164 glVertex3f(1, 1, 0.0f);
2165 glTexCoord2f(0,texcoordheight);
2166 glVertex3f(-1, 1, 0.0f);
2170 glTranslatef(.0,.01,0);
2173 glVertex3f(-1, -1, 0.0f);
2174 glTexCoord2f(texcoordwidth,0);
2175 glVertex3f(1, -1, 0.0f);
2176 glTexCoord2f(texcoordwidth,texcoordheight);
2177 glVertex3f(1, 1, 0.0f);
2178 glTexCoord2f(0,texcoordheight);
2179 glVertex3f(-1, 1, 0.0f);
2183 glTranslatef(0,-.01,0);
2186 glVertex3f(-1, -1, 0.0f);
2187 glTexCoord2f(texcoordwidth,0);
2188 glVertex3f(1, -1, 0.0f);
2189 glTexCoord2f(texcoordwidth,texcoordheight);
2190 glVertex3f(1, 1, 0.0f);
2191 glTexCoord2f(0,texcoordheight);
2192 glVertex3f(-1, 1, 0.0f);
2196 if(drawmode==radialzoommode){
2198 //glRotatef((float)i*.1,0,0,1);
2199 glColor4f(1,1,1,1/((float)i+1));
2201 glScalef(1+(float)i*.01,1+(float)i*.01,1);
2204 glVertex3f(-1, -1, 0.0f);
2205 glTexCoord2f(texcoordwidth,0);
2206 glVertex3f(1, -1, 0.0f);
2207 glTexCoord2f(texcoordwidth,texcoordheight);
2208 glVertex3f(1, 1, 0.0f);
2209 glTexCoord2f(0,texcoordheight);
2210 glVertex3f(-1, 1, 0.0f);
2215 glDisable(GL_TEXTURE_2D);
2216 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2217 glPopMatrix(); // Restore The Old Projection Matrix
2218 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2219 glPopMatrix(); // Restore The Old Projection Matrix
2220 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
2221 glEnable(GL_CULL_FACE);
2222 glDisable(GL_BLEND);
2227 glEnable(GL_TEXTURE_2D);
2232 if(consoleselected>=60)offset=consoleselected-60;
2233 sprintf (string, " ]");
2234 text.glPrint(10,30,string,0,1,1024,768);
2236 sprintf (string, "_");
2237 text.glPrint(30+(float)(consoleselected)*10-offset*10,30,string,0,1,1024,768);
2240 for(j=0;j<consolechars[i];j++){
2241 glColor4f(1,1,1,1-(float)(i)/16);
2242 if(j<consolechars[i]){
2243 sprintf (string, "%c",consoletext[i][j]);
2244 text.glPrint(30+j*10-offset*10,30+i*20,string,0,1,1024,768);
2252 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)||(mainmenu&&gameon)||(!gameon&&gamestarted)||(!gameon&&gamestarted)){
2253 multiplier=tempmult;
2258 // !!! FIXME: hack: clamp framerate in menu so text input works correctly on fast systems.
2261 glDrawBuffer(GL_BACK);
2262 glReadBuffer(GL_BACK);
2263 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
2264 ReSizeGLScene(90,.1f);
2267 temptexdetail=texdetail;
2268 if(texdetail>2)texdetail=2;
2269 if(mainmenu!=oldmainmenu&&oldmainmenu!=0){
2271 LoadTexture(":Data:Textures:Newgame.png",&Mainmenuitems[1],0,0);
2272 LoadTexture(":Data:Textures:Quit.png",&Mainmenuitems[3],0,0);
2273 /*if(oldmainmenu==1||oldmainmenu==0){
2274 LoadTexture(":Data:Textures:World.png",&Mainmenuitems[7],0,0);
2275 LoadTexture(":Data:Textures:Options.png",&Mainmenuitems[2],0,0);
2276 LoadTexture(":Data:Textures:Lugaru.png",&Mainmenuitems[0],0,0);
2281 LoadTexture(":Data:Textures:Resume.png",&Mainmenuitems[1],0,0);
2282 LoadTexture(":Data:Textures:Endgame.png",&Mainmenuitems[3],0,0);
2283 /*if(oldmainmenu==2||oldmainmenu==0){
2284 LoadTexture(":Data:Textures:World.png",&Mainmenuitems[7],0,0);
2285 LoadTexture(":Data:Textures:Options.png",&Mainmenuitems[2],0,0);
2286 LoadTexture(":Data:Textures:Lugaru.png",&Mainmenuitems[0],0,0);
2291 if(lastcheck>.5||oldmainmenu!=mainmenu){
2293 ifstream ipstream(ConvertFileName(":Data:Campaigns:main.txt"));
2294 //campaignnumlevels=0;
2295 //accountactive->getCampaignChoicesMade()=0;
2296 ipstream.ignore(256,':');
2297 ipstream >> campaignnumlevels;
2298 for(i=0;i<campaignnumlevels;i++){
2299 ipstream.ignore(256,':');
2300 ipstream.ignore(256,':');
2301 ipstream.ignore(256,' ');
2302 ipstream >> campaignmapname[i];
2303 ipstream.ignore(256,':');
2304 ipstream >> campaigndescription[i];
2306 if(campaigndescription[i][j]=='_')campaigndescription[i][j]=' ';
2308 ipstream.ignore(256,':');
2309 ipstream >> campaignchoosenext[i];
2310 ipstream.ignore(256,':');
2311 ipstream >> campaignnumnext[i];
2312 if(campaignnumnext[i])
2313 for(j=0;j<campaignnumnext[i];j++){
2314 ipstream.ignore(256,':');
2315 ipstream >> campaignnextlevel[i][j];
2316 campaignnextlevel[i][j]-=1;
2318 ipstream.ignore(256,':');
2319 ipstream >> campaignlocationx[i];
2320 //campaignlocationx[i]-=30;
2321 ipstream.ignore(256,':');
2322 ipstream >> campaignlocationy[i];
2323 //campaignlocationy[i]+=30;
2327 for(i=0;i<campaignnumlevels;i++){
2329 levelhighlight[i]=0;
2334 if(accountactive->getCampaignChoicesMade())
2335 for(i=0;i<accountactive->getCampaignChoicesMade();i++){
2336 levelorder[i+1]=campaignnextlevel[levelorder[i]][accountactive->getCampaignChoice(i)];
2337 levelvisible[levelorder[i+1]]=1;
2339 int whichlevelstart;
2340 whichlevelstart=accountactive->getCampaignChoicesMade()-1;
2341 if(whichlevelstart<0){
2342 accountactive->setCampaignScore(0);
2343 accountactive->resetFasttime();
2344 campaignchoicenum=1;
2345 campaignchoicewhich[0]=0;
2349 campaignchoicenum=campaignnumnext[levelorder[whichlevelstart]];
2350 if(campaignchoicenum==0){
2351 //if(accountactive->getCampaignFasttime()==0||accountcampaigntime[accountactive]<accountactive->getCampaignFasttime())accountactive->getCampaignFasttime()=accountcampaigntime[accountactive];
2353 if(campaignchoicenum)
2354 for(i=0;i<campaignchoicenum;i++){
2355 campaignchoicewhich[i]=campaignnextlevel[levelorder[whichlevelstart]][i];
2356 levelvisible[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
2357 levelhighlight[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
2370 texdetail=temptexdetail;
2372 /*if(mainmenu!=0)*/oldmainmenu=mainmenu;
2374 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){
2375 glClear(GL_DEPTH_BUFFER_BIT);
2376 glEnable(GL_ALPHA_TEST);
2377 glAlphaFunc(GL_GREATER, 0.001f);
2378 glEnable(GL_TEXTURE_2D);
2379 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
2380 glDisable(GL_CULL_FACE);
2381 glDisable(GL_LIGHTING);
2383 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2384 glPushMatrix(); // Store The Projection Matrix
2385 glLoadIdentity(); // Reset The Projection Matrix
2386 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
2387 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2388 glPushMatrix(); // Store The Modelview Matrix
2389 glLoadIdentity(); // Reset The Modelview Matrix
2390 glTranslatef(screenwidth/2,screenheight/2,0);
2392 glScalef((float)screenwidth/2,(float)screenheight/2,1);
2393 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
2394 glDisable(GL_BLEND);
2395 glColor4f(0,0,0,1.0);
2396 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2397 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2398 glDisable(GL_TEXTURE_2D);
2400 //glScalef(.25,.25,.25);
2403 glVertex3f(-1, -1, 0.0f);
2405 glVertex3f(1, -1, 0.0f);
2407 glVertex3f(1, 1, 0.0f);
2409 glVertex3f(-1, 1, 0.0f);
2413 glColor4f(0.4,0.4,0.4,1.0);
2414 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2415 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2416 glEnable(GL_TEXTURE_2D);
2417 glBindTexture( GL_TEXTURE_2D, Mainmenuitems[4]);
2419 //glScalef(.25,.25,.25);
2422 glVertex3f(-1, -1, 0.0f);
2424 glVertex3f(1, -1, 0.0f);
2426 glVertex3f(1, 1, 0.0f);
2428 glVertex3f(-1, 1, 0.0f);
2433 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2435 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2439 if((float)newscreenwidth>(float)newscreenheight*1.61||(float)newscreenwidth<(float)newscreenheight*1.59)sprintf (menustring[0], "Resolution: %d*%d",(int)newscreenwidth,(int)newscreenheight);
2440 else sprintf (menustring[0], "Resolution: %d*%d (widescreen)",(int)newscreenwidth,(int)newscreenheight);
2443 endx[0]=startx[0]+strlen(menustring[0])*10;
2444 endy[0]=starty[0]+20;
2448 if(newdetail==2)sprintf (menustring[1], "Detail: High");
2449 else if(newdetail==1)sprintf (menustring[1], "Detail: Medium");
2450 else sprintf (menustring[1], "Detail: Low");
2453 endx[1]=startx[1]+strlen(menustring[1])*10;
2454 endy[1]=starty[1]+20;
2458 if(bloodtoggle==2)sprintf (menustring[2], "Blood: On, high detail (slower)");
2459 if(bloodtoggle==1)sprintf (menustring[2], "Blood: On, low detail");
2460 if(bloodtoggle==0)sprintf (menustring[2], "Blood: Off");
2463 endx[2]=startx[2]+strlen(menustring[2])*10;
2464 endy[2]=starty[2]+20;
2468 if(difficulty==2)sprintf (menustring[3], "Difficulty: Insane");
2469 if(difficulty==1)sprintf (menustring[3], "Difficulty: Difficult");
2470 if(difficulty==0)sprintf (menustring[3], "Difficulty: Easier");
2471 startx[3]=10+20-1000;
2473 endx[3]=startx[3]+strlen(menustring[3])*10;
2474 endy[3]=starty[3]+20;
2478 if(ismotionblur==1)sprintf (menustring[4], "Blur Effects: Enabled (less compatible)");
2479 if(ismotionblur==0)sprintf (menustring[4], "Blur Effects: Disabled (more compatible)");
2482 endx[4]=startx[4]+strlen(menustring[4])*10;
2483 endy[4]=starty[4]+20;
2487 if(decals==1)sprintf (menustring[5], "Decals: Enabled (slower)");
2488 if(decals==0)sprintf (menustring[5], "Decals: Disabled");
2491 endx[5]=startx[5]+strlen(menustring[5])*10;
2492 endy[5]=starty[5]+20;
2496 if(musictoggle==1)sprintf (menustring[6], "Music: Enabled");
2497 if(musictoggle==0)sprintf (menustring[6], "Music: Disabled");
2500 endx[6]=startx[6]+strlen(menustring[6])*10;
2501 endy[6]=starty[6]+20;
2505 if(invertmouse==1)sprintf (menustring[9], "Invert mouse: Yes");
2506 if(invertmouse==0)sprintf (menustring[9], "Invert mouse: No");
2509 endx[9]=startx[9]+strlen(menustring[9])*10;
2510 endy[9]=starty[9]+20;
2514 sprintf (menustring[10], "Mouse Speed: %d", (int)(usermousesensitivity*5));
2517 endx[10]=startx[10]+strlen(menustring[10])*10;
2518 endy[10]=starty[10]+20;
2522 sprintf (menustring[11], "Volume: %d%%", (int)(volume*100));
2525 endx[11]=startx[11]+strlen(menustring[11])*10;
2526 endy[11]=starty[11]+20;
2530 sprintf (menustring[13], "Damage Bar: %s",(showdamagebar?"on":"off"));
2533 endx[13]=startx[13]+strlen(menustring[13])*10;
2534 endy[13]=starty[13]+20;
2538 sprintf (menustring[7], "-Configure Controls-");
2541 endx[7]=startx[7]+strlen(menustring[7])*10;
2542 endy[7]=starty[7]+20;
2546 sprintf (menustring[12], "-Configure Stereo -");
2549 endx[12]=startx[12]+strlen(menustring[7])*10;
2550 endy[12]=starty[12]+20;
2554 if(newdetail==detail&&newscreenheight==(int)screenheight&&newscreenwidth==(int)screenwidth)sprintf (menustring[8], "Back");
2555 else sprintf (menustring[8], "Back (some changes take effect next time Lugaru is opened)");
2557 endx[8]=startx[8]+strlen(menustring[8])*10;
2559 endy[8]=starty[8]+20;
2566 if(keyselect!=0)sprintf (menustring[0], "Forwards: %s",Input::keyToChar(forwardkey));
2567 else sprintf (menustring[0], "Forwards: _");
2570 endx[0]=startx[0]+strlen(menustring[0])*10;
2571 endy[0]=starty[0]+20;
2575 if(keyselect!=1)sprintf (menustring[1], "Back: %s",Input::keyToChar(backkey));
2576 else sprintf (menustring[1], "Back: _");
2579 endx[1]=startx[1]+strlen(menustring[1])*10;
2580 endy[1]=starty[1]+20;
2584 if(keyselect!=2)sprintf (menustring[2], "Left: %s",Input::keyToChar(leftkey));
2585 else sprintf (menustring[2], "Left: _");
2588 endx[2]=startx[2]+strlen(menustring[2])*10;
2589 endy[2]=starty[2]+20;
2593 if(keyselect!=3)sprintf (menustring[3], "Right: %s",Input::keyToChar(rightkey));
2594 else sprintf (menustring[3], "Right: _");
2597 endx[3]=startx[3]+strlen(menustring[3])*10;
2598 endy[3]=starty[3]+20;
2602 if(keyselect!=4)sprintf (menustring[4], "Crouch: %s",Input::keyToChar(crouchkey));
2603 else sprintf (menustring[4], "Crouch: _");
2606 endx[4]=startx[4]+strlen(menustring[4])*10;
2607 endy[4]=starty[4]+20;
2611 if(keyselect!=5)sprintf (menustring[5], "Jump: %s",Input::keyToChar(jumpkey));
2612 else sprintf (menustring[5], "Jump: _");
2615 endx[5]=startx[5]+strlen(menustring[5])*10;
2616 endy[5]=starty[5]+20;
2620 if(keyselect!=6)sprintf (menustring[6], "Draw: %s",Input::keyToChar(drawkey));
2621 else sprintf (menustring[6], "Draw: _");
2624 endx[6]=startx[6]+strlen(menustring[6])*10;
2625 endy[6]=starty[6]+20;
2629 if(keyselect!=7)sprintf (menustring[7], "Throw: %s",Input::keyToChar(throwkey));
2630 else sprintf (menustring[7], "Throw: _");
2633 endx[7]=startx[7]+strlen(menustring[7])*10;
2634 endy[7]=starty[7]+20;
2638 if(keyselect!=8)sprintf (menustring[8], "Attack: %s",Input::keyToChar(attackkey));
2639 else sprintf (menustring[8], "Attack: _");
2642 endx[8]=startx[8]+strlen(menustring[8])*10;
2643 endy[8]=starty[8]+20;
2649 sprintf (menustring[9], "Back");
2651 endx[9]=startx[9]+strlen(menustring[9])*10;
2653 endy[9]=starty[9]+20;
2658 nummenuitems=7+accountactive->getCampaignChoicesMade()+campaignchoicenum;
2660 sprintf (menustring[0], "%s",accountactive->getName());
2663 endx[0]=startx[0]+strlen(menustring[0])*10;
2664 endy[0]=starty[0]+20;
2668 sprintf (menustring[1], "Tutorial");
2671 endx[1]=startx[1]+strlen(menustring[1])*10;
2672 endy[1]=starty[1]+20;
2676 sprintf (menustring[2], "Challenge");
2679 endx[2]=startx[2]+strlen(menustring[2])*10;
2680 endy[2]=starty[2]+20;
2684 sprintf (menustring[3], "Delete User");
2687 endx[3]=startx[3]+strlen(menustring[3])*10;
2688 endy[3]=starty[3]+20;
2692 sprintf (menustring[4], "Main Menu");
2695 endx[4]=startx[4]+strlen(menustring[4])*10;
2696 endy[4]=starty[4]+20;
2700 sprintf (menustring[5], "Change User");
2702 endx[5]=startx[5]+strlen(menustring[5])*10;
2704 endy[5]=starty[5]+20;
2710 sprintf (menustring[6], "World");
2712 starty[6]=30+480-400-50;
2713 endx[6]=startx[6]+400;
2718 if(accountactive->getCampaignChoicesMade())
2719 for(i=0;i<accountactive->getCampaignChoicesMade();i++){
2720 sprintf (menustring[7+i], "%s", campaigndescription[levelorder[i]]);
2721 startx[7+i]=30+120+campaignlocationx[levelorder[i]]*400/512;
2722 starty[7+i]=30+30+(512-campaignlocationy[levelorder[i]])*400/512;
2723 endx[7+i]=startx[7+i]+10;
2724 endy[7+i]=starty[7+i]+10;
2729 if(campaignchoicenum>0)
2730 for(i=accountactive->getCampaignChoicesMade();i<accountactive->getCampaignChoicesMade()+campaignchoicenum;i++){
2731 sprintf (menustring[7+i], "%s", campaigndescription[levelorder[i]]);
2732 startx[7+i]=30+120+campaignlocationx[campaignchoicewhich[i-(accountactive->getCampaignChoicesMade())]]*400/512;
2733 starty[7+i]=30+30+(512-campaignlocationy[campaignchoicewhich[i-(accountactive->getCampaignChoicesMade())]])*400/512;
2734 endx[7+i]=startx[7+i]+10;
2735 endy[7+i]=starty[7+i]+10;
2740 /*sprintf (menustring[7], "Dot");
2741 startx[7]=120+260*400/512;
2742 starty[7]=30+(512-184)*400/512;
2743 endx[7]=startx[7]+10;
2744 endy[7]=starty[7]+10;
2748 sprintf (menustring[8], "Dot");
2749 startx[8]=120+129*400/512;
2750 starty[8]=30+(512-284)*400/512;
2751 endx[8]=startx[8]+10;
2752 endy[8]=starty[8]+10;
2756 sprintf (menustring[9], "Dot");
2757 startx[9]=120+358*400/512;
2758 starty[9]=30+(512-235)*400/512;
2759 endx[9]=startx[9]+10;
2760 endy[9]=starty[9]+10;
2764 sprintf (menustring[10], "Dot");
2765 startx[10]=120+359*400/512;
2766 starty[10]=30+(512-308)*400/512;
2767 endx[10]=startx[10]+10;
2768 endy[10]=starty[10]+10;
2772 sprintf (menustring[11], "Dot");
2773 startx[11]=120+288*400/512;
2774 starty[11]=30+(512-277)*400/512;
2775 endx[11]=startx[11]+10;
2776 endy[11]=starty[11]+10;
2784 sprintf (menustring[0], "Are you sure you want to delete this user?");
2787 endx[0]=startx[0]+strlen(menustring[0])*10;
2788 endy[0]=starty[0]+20;
2792 sprintf (menustring[1], "Yes");
2795 endx[1]=startx[1]+strlen(menustring[1])*10;
2796 endy[1]=starty[1]+20;
2800 sprintf (menustring[2], "No");
2803 endx[2]=startx[2]+strlen(menustring[2])*10;
2804 endy[2]=starty[2]+20;
2808 sprintf (menustring[3], "Extra 4");
2811 endx[3]=startx[3]+strlen(menustring[3])*10;
2812 endy[3]=starty[3]+20;
2816 sprintf (menustring[4], "Extra 5");
2819 endx[4]=startx[4]+strlen(menustring[4])*10;
2820 endy[4]=starty[4]+20;
2824 sprintf (menustring[5], "Back");
2826 endx[5]=startx[5]+strlen(menustring[5])*10;
2828 endy[5]=starty[5]+20;
2834 nummenuitems=Account::getNbAccounts()+2;
2838 if(Account::getNbAccounts()<8)
2839 sprintf (menustring[0], "New User");
2841 sprintf (menustring[0], "No More Users");
2844 endx[0]=startx[0]+strlen(menustring[0])*10;
2845 endy[0]=starty[0]+20;
2854 for(i=0;i<Account::getNbAccounts();i++){
2855 sprintf (menustring[num], "%s",Account::get(i)->getName());
2857 starty[num]=360-20-20*num;
2858 endx[num]=startx[num]+strlen(menustring[num])*10;
2859 endy[num]=starty[num]+20;
2866 sprintf (menustring[num], "Back");
2868 endx[num]=startx[num]+strlen(menustring[num])*10;
2870 endy[num]=starty[num]+20;
2877 sprintf (menustring[0], "Easier");
2880 endx[0]=startx[0]+strlen(menustring[0])*10;
2881 endy[0]=starty[0]+20;
2885 sprintf (menustring[1], "Difficult");
2888 endx[1]=startx[1]+strlen(menustring[1])*10;
2889 endy[1]=starty[1]+20;
2893 sprintf (menustring[2], "Insane");
2896 endx[2]=startx[2]+strlen(menustring[2])*10;
2897 endy[2]=starty[2]+20;
2903 //tempncl=numchallengelevels;
2904 //numchallengelevels=9;
2905 nummenuitems=2+numchallengelevels;
2908 for(j=0;j<numchallengelevels;j++){
2909 for(i=0;i<255;i++)menustring[j][i]='\0';
2910 sprintf (temp, "Level %d",j+1);
2911 strcpy(menustring[j],temp);
2912 for(i=0;i<17;i++)if(menustring[j][i]=='\0')menustring[j][i]=' ';
2913 menustring[j][17]='\0';
2914 sprintf (temp, "%d",(int)accountactive->getHighScore(j));
2915 strcat(menustring[j],temp);
2916 for(i=18;i<32;i++)if(menustring[j][i]=='\0')menustring[j][i]=' ';
2917 menustring[j][32]='\0';
2918 sprintf (temp, "%d:",(int)(((int)accountactive->getFastTime(j)-(int)(accountactive->getFastTime(j))%60)/60));
2919 strcat(menustring[j],temp);
2920 if((int)(accountactive->getFastTime(j))%60<10)strcat(menustring[j],"0");
2921 sprintf (temp, "%d",(int)(accountactive->getFastTime(j))%60);
2922 strcat(menustring[j],temp);
2926 endx[j]=startx[j]+strlen(menustring[j])*10;
2927 endy[j]=starty[j]+20;
2932 sprintf (menustring[numchallengelevels], "Back");
2933 startx[numchallengelevels]=10;
2934 endx[numchallengelevels]=startx[numchallengelevels]+strlen(menustring[numchallengelevels])*10;
2935 starty[numchallengelevels]=10;
2936 endy[numchallengelevels]=starty[numchallengelevels]+20;
2937 movex[numchallengelevels]=0;
2938 movey[numchallengelevels]=0;
2940 sprintf (menustring[numchallengelevels+1], " High Score Best Time");
2941 startx[numchallengelevels+1]=10;
2942 starty[numchallengelevels+1]=440;
2943 endx[numchallengelevels+1]=startx[numchallengelevels+1]+strlen(menustring[numchallengelevels+1])*10;
2944 endy[numchallengelevels+1]=starty[numchallengelevels+1]+20;
2945 movex[numchallengelevels+1]=0;
2946 movey[numchallengelevels+1]=0;
2948 //numchallengelevels=tempncl;
2952 nummenuitems=2+numchallengelevels;
2955 for(j=0;j<numchallengelevels;j++){
2956 for(i=0;i<255;i++)menustring[j][i]='\0';
2957 sprintf (temp, "Level %d",j+1);
2958 strcpy(menustring[j],temp);
2959 for(i=0;i<17;i++)if(menustring[j][i]=='\0')menustring[j][i]=' ';
2960 menustring[j][17]='\0';
2961 sprintf (temp, "%d",(int)accountactive->getHighScore(j));
2962 strcat(menustring[j],temp);
2963 for(i=18;i<32;i++)if(menustring[j][i]=='\0')menustring[j][i]=' ';
2964 menustring[j][32]='\0';
2965 sprintf (temp, "%d:",(int)(((int)accountactive->getFastTime(j)-(int)(accountactive->getFastTime(j))%60)/60));
2966 strcat(menustring[j],temp);
2967 if((int)(accountactive->getFastTime(j))%60<10)strcat(menustring[j],"0");
2968 sprintf (temp, "%d",(int)(accountactive->getFastTime(j))%60);
2969 strcat(menustring[j],temp);
2973 endx[j]=startx[j]+strlen(menustring[j])*10;
2974 endy[j]=starty[j]+20;
2979 sprintf (menustring[numchallengelevels], "Back");
2980 startx[numchallengelevels]=10;
2981 endx[numchallengelevels]=startx[numchallengelevels]+strlen(menustring[numchallengelevels])*10;
2982 starty[numchallengelevels]=10;
2983 endy[numchallengelevels]=starty[numchallengelevels]+20;
2984 movex[numchallengelevels]=0;
2985 movey[numchallengelevels]=0;
2987 sprintf (menustring[numchallengelevels+1], " High Score Best Time");
2988 startx[numchallengelevels+1]=10;
2989 starty[numchallengelevels+1]=400;
2990 endx[numchallengelevels+1]=startx[numchallengelevels+1]+strlen(menustring[numchallengelevels+1])*10;
2991 endy[numchallengelevels+1]=starty[numchallengelevels+1]+20;
2992 movex[numchallengelevels+1]=0;
2993 movey[numchallengelevels+1]=0;
3000 sprintf (menustring[0], "Congratulations!");
3003 endx[0]=startx[0]+strlen(menustring[0])*10;
3004 endy[0]=starty[0]+20;
3008 sprintf (menustring[1], "You have avenged your family and");
3011 endx[1]=startx[1]+strlen(menustring[1])*10;
3012 endy[1]=starty[1]+20;
3016 sprintf (menustring[2], "restored peace to the island of Lugaru.");
3019 endx[2]=startx[2]+strlen(menustring[2])*10;
3020 endy[2]=starty[2]+20;
3024 sprintf (menustring[3], "Back");
3026 endx[3]=startx[3]+strlen(menustring[3])*10;
3028 endy[3]=starty[3]+20;
3032 for(i=0;i<255;i++)menustring[4][i]='\0';
3033 sprintf (temp, "Your score:");
3034 strcpy(menustring[4],temp);
3035 for(i=0;i<20;i++)if(menustring[4][i]=='\0')menustring[4][i]=' ';
3036 menustring[4][20]='\0';
3037 sprintf (temp, "%d",(int)accountactive->getCampaignScore());
3038 strcat(menustring[4],temp);
3040 endx[4]=startx[4]+strlen(menustring[4])*10;
3042 endy[4]=starty[4]+20;
3046 for(i=0;i<255;i++)menustring[5][i]='\0';
3047 sprintf (temp, "Your time:");
3048 strcpy(menustring[5],temp);
3049 for(i=0;i<20;i++)if(menustring[5][i]=='\0')menustring[5][i]=' ';
3050 menustring[5][20]='\0';
3051 sprintf (temp, "%d",(int)accountcampaigntime[accountactive]);
3052 strcat(menustring[5],temp);
3054 endx[5]=startx[5]+strlen(menustring[5])*10;
3056 endy[5]=starty[5]+20;
3060 for(i=0;i<255;i++)menustring[5][i]='\0';
3061 sprintf (temp, "Highest score:");
3062 strcpy(menustring[5],temp);
3063 for(i=0;i<20;i++)if(menustring[5][i]=='\0')menustring[5][i]=' ';
3064 menustring[5][20]='\0';
3065 sprintf (temp, "%d",(int)accountactive->getCampaignHighScore());
3066 strcat(menustring[5],temp);
3068 endx[5]=startx[5]+strlen(menustring[5])*10;
3070 endy[5]=starty[5]+20;
3074 for(i=0;i<255;i++)menustring[7][i]='\0';
3075 sprintf (temp, "Lowest time:");
3076 strcpy(menustring[7],temp);
3077 for(i=0;i<20;i++)if(menustring[7][i]=='\0')menustring[7][i]=' ';
3078 menustring[7][20]='\0';
3079 sprintf (temp, "%d",(int)accountactive->getCampaignFasttime());
3080 strcat(menustring[7],temp);
3082 endx[7]=startx[7]+strlen(menustring[7])*10;
3084 endy[7]=starty[7]+20;
3090 sprintf (menustring[0], "Stereo mode: %s", StereoModeName(newstereomode));
3093 endx[0]=startx[0]+strlen(menustring[0])*10;
3094 endy[0]=starty[0]+20;
3098 sprintf (menustring[1], "Stereo separation: %.3f", stereoseparation);
3101 endx[1]=startx[1]+strlen(menustring[1])*10;
3102 endy[1]=starty[1]+20;
3106 sprintf (menustring[2], "Reverse stereo: %s", stereoreverse ? "Yes" : "No");
3109 endx[2]=startx[2]+strlen(menustring[2])*10;
3110 endy[2]=starty[2]+20;
3114 sprintf (menustring[3], "Back");
3116 endx[3]=startx[3]+strlen(menustring[3])*10;
3118 endy[3]=starty[3]+20;
3128 sprintf (menustring[0], "Please enter your name:");
3131 endx[0]=startx[0]+strlen(menustring[0])*10;
3132 endy[0]=starty[0]+20;
3136 sprintf (menustring[1], "Please enter your name:");
3139 endx[1]=startx[1]+strlen(menustring[1])*10;
3140 endy[1]=starty[1]+20;
3144 if(mainmenu==1||mainmenu==2){
3154 starty[1]=480-152-32;
3161 starty[2]=480-228-32;
3169 starty[3]=480-306-32;
3178 starty[3]=480-306-32;
3192 starty[4]=480-140-256;
3199 starty[5]=480-138-256;
3206 starty[6]=480-144-256;
3214 starty[4]=480-140-256;
3221 starty[5]=480-138-256;
3228 starty[6]=480-144-256;
3236 starty[4]=480-140-256;
3243 starty[5]=480-150-256;
3250 starty[6]=480-144-256;
3258 starty[4]=480-140-256;
3265 starty[5]=480-150-256;
3272 starty[6]=480-144-256;
3280 starty[4]=480-100-256;
3287 starty[5]=480-120-256;
3294 starty[6]=480-144-256;
3304 if(mainmenu==1||mainmenu==2)
3306 if((mousecoordh/screenwidth*640)>startx[i]&&(mousecoordh/screenwidth*640)<endx[i]&&480-(mousecoordv/screenheight*480)>starty[i]&&480-(mousecoordv/screenheight*480)<endy[i]){
3311 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)
3312 for(i=0;i<nummenuitems;i++){
3313 if((mousecoordh/screenwidth*640)>startx[i]&&(mousecoordh/screenwidth*640)<endx[i]&&480-(mousecoordv/screenheight*480)>starty[i]&&480-(mousecoordv/screenheight*480)<endy[i]){
3314 if(mainmenu!=5)selected=i;
3315 if(mainmenu==5&&(i!=0&&i!=6))selected=i;
3316 if(mainmenu==9&&(i!=numchallengelevels+1))selected=i;
3317 if(mainmenu==11&&(i!=numchallengelevels+1))selected=i;
3322 for(i=0;i<nummenuitems;i++){
3323 if(selected==i)selectedlong[i]+=multiplier*5;
3324 if(selectedlong[i]>1)selectedlong[i]=1;
3325 if(selected!=i)selectedlong[i]-=multiplier*5;
3326 if(selectedlong[i]<0)selectedlong[i]=0;
3327 //if(i>=4)selectedlong[i]=.3;
3328 if(i>=4&&(mainmenu==1||mainmenu==2))selectedlong[i]=0;
3332 for(i=0;i<nummenuitems;i++){
3333 offsetx[i]=(startx[i]+endx[i])/2-(mousecoordh/screenwidth*640);
3334 offsety[i]=(starty[i]+endy[i])/2-(480-(mousecoordv/screenheight*480));
3339 if(i>=4&&(mainmenu==1||mainmenu==2)){
3340 offsetx[i]=(startx[i]+endx[i]+movex[i]*transition)/2-(640+190)/2;
3341 offsety[i]=(starty[i]+endy[i]+movey[i]*transition)/2-(336+150)/2;
3347 if(mainmenu==1||mainmenu==2){
3348 glClear(GL_DEPTH_BUFFER_BIT);
3349 glEnable(GL_ALPHA_TEST);
3350 glAlphaFunc(GL_GREATER, 0.001f);
3351 glEnable(GL_TEXTURE_2D);
3352 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3353 glDisable(GL_CULL_FACE);
3354 glDisable(GL_LIGHTING);
3356 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3357 glPushMatrix(); // Store The Projection Matrix
3358 glLoadIdentity(); // Reset The Projection Matrix
3359 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
3360 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3361 glPushMatrix(); // Store The Modelview Matrix
3362 glLoadIdentity(); // Reset The Modelview Matrix
3363 glTranslatef(screenwidth/2,screenheight/2,0);
3365 glScalef((float)screenwidth/2,(float)screenheight/2,1);
3366 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3367 glDisable(GL_BLEND);
3368 glColor4f(0,0,0,1.0);
3369 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
3370 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
3371 glDisable(GL_TEXTURE_2D);
3373 //glScalef(.25,.25,.25);
3376 glVertex3f(-1, -1, 0.0f);
3378 glVertex3f(1, -1, 0.0f);
3380 glVertex3f(1, 1, 0.0f);
3382 glVertex3f(-1, 1, 0.0f);
3386 glColor4f(0.4,0.4,0.4,1.0);
3387 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
3388 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
3389 glEnable(GL_TEXTURE_2D);
3390 glBindTexture( GL_TEXTURE_2D, Mainmenuitems[4]);
3392 //glScalef(.25,.25,.25);
3395 glVertex3f(-1, -1, 0.0f);
3397 glVertex3f(1, -1, 0.0f);
3399 glVertex3f(1, 1, 0.0f);
3401 glVertex3f(-1, 1, 0.0f);
3406 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3409 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3410 glPushMatrix(); // Store The Projection Matrix
3411 glLoadIdentity(); // Reset The Projection Matrix
3412 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3413 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3414 glPushMatrix(); // Store The Modelview Matrix
3415 glLoadIdentity(); // Reset The Modelview Matrix
3417 glDisable(GL_TEXTURE_2D);
3422 if(anim!=1)glVertex3f(190, 150, 0.0f);
3423 if(anim==1)glVertex3f(190+movex[4]*transition, 150, 0.0f);
3425 glVertex3f(640, 150, 0.0f);
3427 glVertex3f(640, 336, 0.0f);
3429 if(anim!=1)glVertex3f(190, 336, 0.0f);
3430 if(anim==1)glVertex3f(190+movex[4]*transition, 336, 0.0f);
3435 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3437 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3441 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3442 glPushMatrix(); // Store The Projection Matrix
3443 glLoadIdentity(); // Reset The Projection Matrix
3444 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3445 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3446 glPushMatrix(); // Store The Modelview Matrix
3447 glLoadIdentity(); // Reset The Modelview Matrix
3448 glEnable(GL_TEXTURE_2D);
3451 for(j=0;j<nummenuitems;j++)
3453 if(j<=3||(mainmenu!=1&&mainmenu!=2))
3455 //glDisable(GL_BLEND);
3456 glEnable(GL_ALPHA_TEST);
3458 //glDisable(GL_ALPHA_TEST);
3459 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3460 if(mainmenu==1||mainmenu==2)
3463 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3464 glBindTexture( GL_TEXTURE_2D, Mainmenuitems[j]);
3465 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
3466 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
3467 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3471 glVertex3f(startx[j]+movex[j]*transition, starty[j]+movey[j]*transition, 0.0f);
3473 glVertex3f(endx[j]+movex[j]*transition, starty[j]+movey[j]*transition, 0.0f);
3475 glVertex3f(endx[j]+movex[j]*transition, endy[j]+movey[j]*transition, 0.0f);
3477 glVertex3f(startx[j]+movex[j]*transition, endy[j]+movey[j]*transition, 0.0f);
3481 //glDisable(GL_ALPHA_TEST);
3482 if(j<4)glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3485 if(1-((float)i)/10-(1-selectedlong[j])>0)
3487 glColor4f(1,1,1,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3488 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3492 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);
3494 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);
3496 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);
3498 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);
3504 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)
3506 if(mainmenu!=5||j<6)
3509 if(mainmenu==9&&j>accountactive->getProgress()&&j<numchallengelevels)glColor4f(0.5,0,0,1);
3510 if(mainmenu==11&&j>accountactive->getProgress()&&j<numchallengelevels)glColor4f(0.5,0,0,1);
3511 //if(1-((float)i)/10-(1-selectedlong[j])>0){
3512 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3514 if(mainmenu!=7||j!=0||!entername)
3515 text.glPrint(startx[j],starty[j],menustring[j],0,1,640,480);
3519 sprintf (string, "_");
3520 text.glPrint(startx[j]+(float)(displayselected)*10,starty[j],string,0,1,640,480);
3522 for(l=0;l<displaychars[0];l++){
3523 sprintf (string, "%c",displaytext[0][l]);
3524 text.glPrint(startx[j]+l*10,starty[j],string,0,1,640,480);
3529 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3532 if(1-((float)i)/15-(1-selectedlong[j])>0)
3534 glColor4f(1,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3535 if(mainmenu==9&&j>accountactive->getProgress()&&j<numchallengelevels)glColor4f(0.5,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3536 if(mainmenu==11&&j>accountactive->getProgress()&&j<numchallengelevels)glColor4f(0.5,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3537 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);
3538 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);
3539 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);
3540 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);
3541 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);
3542 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);
3543 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);
3544 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);
3545 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);
3546 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);
3547 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);
3548 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);
3551 sprintf (string, "_");
3552 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);
3555 for(l=0;l<displaychars[k];l++){
3556 if(l<displaychars[k]){
3557 sprintf (string, "%c",displaytext[k][l]);
3558 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);
3567 glClear(GL_DEPTH_BUFFER_BIT);
3568 glEnable(GL_ALPHA_TEST);
3569 glAlphaFunc(GL_GREATER, 0.001f);
3570 glEnable(GL_TEXTURE_2D);
3571 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3572 glDisable(GL_CULL_FACE);
3573 glDisable(GL_LIGHTING);
3574 if(j==6)glColor4f(1,1,1,1);
3575 else glColor4f(1,0,0,1);
3577 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3578 glPushMatrix(); // Store The Projection Matrix
3579 glLoadIdentity(); // Reset The Projection Matrix
3580 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3581 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3582 glPushMatrix(); // Store The Modelview Matrix
3583 glLoadIdentity(); // Reset The Modelview Matrix
3586 //Draw world, draw map
3587 glTranslatef(2,-5,0);
3589 if(j>6&&j<nummenuitems-1)
3591 XYZ linestart,lineend,offset;
3598 //float linestartx,lineendx,linestarty,lineendy,offsetx,offsety;
3599 linestart.x=(startx[j]+endx[j])/2;
3600 linestart.y=(starty[j]+endy[j])/2;
3601 if(j>=6+accountactive->getCampaignChoicesMade()){
3602 linestart.x=(startx[6+accountactive->getCampaignChoicesMade()]+endx[6+accountactive->getCampaignChoicesMade()])/2;
3603 linestart.y=(starty[6+accountactive->getCampaignChoicesMade()]+endy[6+accountactive->getCampaignChoicesMade()])/2;
3605 lineend.x=(startx[j+1]+endx[j+1])/2;
3606 lineend.y=(starty[j+1]+endy[j+1])/2;
3607 offset=lineend-linestart;
3610 offset=DoRotation(offset,0,0,90);
3612 glDisable(GL_TEXTURE_2D);
3614 if(j<6+accountactive->getCampaignChoicesMade()){
3615 glColor4f(0.5,0,0,1);
3619 if(j>=6+accountactive->getCampaignChoicesMade()){
3625 linestart+=fac*4*startsize;
3626 lineend-=fac*4*endsize;
3628 if(!(j>7+accountactive->getCampaignChoicesMade()+campaignchoicenum)){
3629 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3633 glVertex3f(linestart.x-offset.x*startsize, linestart.y-offset.y*startsize, 0.0f);
3635 glVertex3f(linestart.x+offset.x*startsize, linestart.y+offset.y*startsize, 0.0f);
3637 glVertex3f(lineend.x+offset.x*endsize, lineend.y+offset.y*endsize, 0.0f);
3639 glVertex3f(lineend.x-offset.x*endsize, lineend.y-offset.y*endsize, 0.0f);
3643 glEnable(GL_TEXTURE_2D);
3647 if(j==6)glBindTexture( GL_TEXTURE_2D, Mainmenuitems[7]);
3648 else glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
3649 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
3650 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
3651 if(j-7<accountactive->getCampaignChoicesMade())glColor4f(0.5,0,0,1);
3652 if(j-7>=accountactive->getCampaignChoicesMade())glColor4f(1,0,0,1);
3653 if(j==6)glColor4f(1,1,1,1);
3656 itemsize=abs(startx[j]-endx[j])/2;
3658 midpoint.x=(startx[j]+endx[j])/2;
3659 midpoint.y=(starty[j]+endy[j])/2;
3660 if(j>6&&(j-7<accountactive->getCampaignChoicesMade()))itemsize*=.5;
3661 if(!(j-7>accountactive->getCampaignChoicesMade()+campaignchoicenum))
3663 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3667 glVertex3f(midpoint.x-itemsize+movex[j]*transition, midpoint.y-itemsize+movey[j]*transition, 0.0f);
3669 glVertex3f(midpoint.x+itemsize+movex[j]*transition, midpoint.y-itemsize+movey[j]*transition, 0.0f);
3671 glVertex3f(midpoint.x+itemsize+movex[j]*transition, midpoint.y+itemsize+movey[j]*transition, 0.0f);
3673 glVertex3f(midpoint.x-itemsize+movex[j]*transition, midpoint.y+itemsize+movey[j]*transition, 0.0f);
3677 //glDisable(GL_ALPHA_TEST);
3678 if(j<4)glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3681 if(1-((float)i)/10-(1-selectedlong[j])>0)
3683 glColor4f(1,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3684 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3688 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);
3690 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);
3692 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);
3694 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);
3702 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3704 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3706 if(j-7>=accountactive->getCampaignChoicesMade()){
3707 //glColor4f(0,0,0,1);
3708 //text.glPrintOutline(startx[j]+10-1.5,starty[j]-4-1.5,menustring[j],0,0.6*1.25,640,480);
3709 //glColor4f(1,0,0,1);
3710 //text.glPrint(startx[j]+10,starty[j]-4,menustring[j],0,0.6,640,480);
3711 text.glPrintOutlined(0.9,0,0,startx[j]+10,starty[j]-4,menustring[j],0,0.6,640,480);
3712 glDisable(GL_DEPTH_TEST);
3719 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3721 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3724 if(mainmenu==1||mainmenu==2)
3725 if(transition<.1||transition>.9){
3726 glClear(GL_DEPTH_BUFFER_BIT);
3727 glEnable(GL_ALPHA_TEST);
3728 glAlphaFunc(GL_GREATER, 0.001f);
3729 glEnable(GL_TEXTURE_2D);
3730 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3731 glDisable(GL_CULL_FACE);
3732 glDisable(GL_LIGHTING);
3734 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3735 glPushMatrix(); // Store The Projection Matrix
3736 glLoadIdentity(); // Reset The Projection Matrix
3737 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3738 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3739 glPushMatrix(); // Store The Modelview Matrix
3740 glLoadIdentity(); // Reset The Modelview Matrix
3742 glDisable(GL_TEXTURE_2D);
3743 if(transition<.1)glColor4f(1,0,0,1-(transition*10));
3744 if(transition>.9)glColor4f(1,0,0,1-((1-transition)*10));
3748 glVertex3f(190, 150, 0.0f);
3750 glVertex3f(640, 150, 0.0f);
3752 glVertex3f(640, 336, 0.0f);
3754 glVertex3f(190, 336, 0.0f);
3759 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3763 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3764 glPushMatrix(); // Store The Projection Matrix
3765 glLoadIdentity(); // Reset The Projection Matrix
3766 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
3767 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3768 glPushMatrix(); // Store The Modelview Matrix
3769 glLoadIdentity(); // Reset The Modelview Matrix
3770 glTranslatef(screenwidth/2,screenheight/2,0);
3772 glScalef((float)screenwidth/2,(float)screenheight/2,1);
3773 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3775 glEnable(GL_TEXTURE_2D);
3777 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
3778 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
3780 if(!waiting) { // hide the cursor while waiting for a key
3782 glTranslatef(mousecoordh-screenwidth/2,mousecoordv*-1+screenheight/2,0);
3783 glScalef((float)screenwidth/64,(float)screenwidth/64,1);
3784 glTranslatef(1,-1,0);
3785 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3787 glBindTexture( GL_TEXTURE_2D, cursortexture);
3789 //glScalef(.25,.25,.25);
3792 glVertex3f(-1, -1, 0.0f);
3794 glVertex3f(1, -1, 0.0f);
3796 glVertex3f(1, 1, 0.0f);
3798 glVertex3f(-1, 1, 0.0f);
3804 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3810 //printf("Flash amount: %f, delay %i\n", flashamount, flashdelay);
3811 if(flashamount>1)flashamount=1;
3812 if(flashdelay<=0)flashamount-=multiplier;
3814 if(flashamount<0)flashamount=0;
3815 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3816 glDisable(GL_CULL_FACE);
3817 glDisable(GL_LIGHTING);
3818 glDisable(GL_TEXTURE_2D);
3820 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3821 glPushMatrix(); // Store The Projection Matrix
3822 glLoadIdentity(); // Reset The Projection Matrix
3823 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
3824 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3825 glPushMatrix(); // Store The Modelview Matrix
3826 glLoadIdentity(); // Reset The Modelview Matrix
3827 glScalef(screenwidth,screenheight,1);
3828 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3830 glColor4f(flashr,flashg,flashb,flashamount);
3832 glVertex3f(0, 0, 0.0f);
3833 glVertex3f(256, 0, 0.0f);
3834 glVertex3f(256, 256, 0.0f);
3835 glVertex3f(0, 256, 0.0f);
3837 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3838 glPopMatrix(); // Restore The Old Projection Matrix
3839 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3840 glPopMatrix(); // Restore The Old Projection Matrix
3841 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
3842 glEnable(GL_CULL_FACE);
3843 glDisable(GL_BLEND);
3848 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)||(!gameon&&gamestarted)){
3849 tempmult=multiplier;
3854 if ( side == stereoRight || side == stereoCenter ) {
3855 if(drawmode!=motionblurmode||mainmenu){
3860 //myassert(glGetError() == GL_NO_ERROR);
3861 glDrawBuffer(GL_BACK);
3862 glReadBuffer(GL_BACK);
3867 if(drawtoggle==2)drawtoggle=0;
3869 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)){
3870 multiplier=tempmult;
3872 //Jordan fixed your warning!