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"
30 extern int environment;
31 extern float texscale;
33 extern Terrain terrain;
34 //extern Sprites sprites;
35 extern float multiplier;
37 extern float viewdistance;
38 extern float fadestart;
39 extern float screenwidth,screenheight;
40 extern int kTextureSize;
41 extern FRUSTUM frustum;
43 extern Objects objects;
45 extern float usermousesensitivity;
47 extern float camerashake;
49 extern float slomodelay;
50 extern bool ismotionblur;
52 extern float blackout;
53 extern bool damageeffects;
55 extern bool texttoggle;
56 extern float blurness;
57 extern float targetblurness;
58 extern float playerdist;
59 extern bool cellophane;
61 extern float flashamount,flashr,flashg,flashb;
62 extern int flashdelay;
64 extern float motionbluramount;
66 extern bool alwaysblur;
68 extern bool tilt2weird;
69 extern bool tiltweird;
71 extern bool proportionweird;
72 extern bool vertexweird[6];
73 extern bool velocityblur;
74 extern bool debugmode;
76 extern int oldmainmenu;
77 extern int bloodtoggle;
78 extern int difficulty;
81 //extern int texdetail;
82 extern float texdetail;
83 extern bool musictoggle;
85 extern float bonusvalue;
86 extern float bonustotal;
87 extern float bonustime;
89 extern float startbonustotal;
90 extern float bonusnum[100];
91 extern int tutoriallevel;
92 extern float smoketex;
93 extern float tutorialstagetime;
94 extern float tutorialmaxtime;
95 extern int tutorialstage;
96 extern bool againbonus;
97 extern float damagedealt;
98 extern float damagetaken;
99 extern bool invertmouse;
101 extern int numhotspots;
102 extern int winhotspot;
103 extern int killhotspot;
104 extern XYZ hotspot[40];
105 extern int hotspottype[40];
106 extern float hotspotsize[40];
107 extern char hotspottext[40][256];
108 extern int currenthotspot;;
111 extern int numflipfail;
113 extern int numstaffattack;
114 extern int numswordattack;
115 extern int numknifeattack;
116 extern int numunarmedattack;
117 extern int numescaped;
118 extern int numflipped;
119 extern int numwallflipped;
120 extern int numthrowkill;
121 extern int numafterkill;
122 extern int numreversals;
123 extern int numattacks;
124 extern int maxalarmed;
125 extern int numresponded;
127 extern bool campaign;
128 extern bool winfreeze;
130 extern float menupulse;
132 extern bool gamestart;
134 extern int numdialogues;
135 extern int numdialogueboxes[max_dialogues];
136 extern int dialoguetype[max_dialogues];
137 extern int dialogueboxlocation[max_dialogues][max_dialoguelength];
138 extern float dialogueboxcolor[max_dialogues][max_dialoguelength][3];
139 extern int dialogueboxsound[max_dialogues][max_dialoguelength];
140 extern char dialoguetext[max_dialogues][max_dialoguelength][128];
141 extern char dialoguename[max_dialogues][max_dialoguelength][64];
142 extern XYZ dialoguecamera[max_dialogues][max_dialoguelength];
143 extern XYZ participantlocation[max_dialogues][10];
144 extern int participantfocus[max_dialogues][max_dialoguelength];
145 extern int participantaction[max_dialogues][max_dialoguelength];
146 extern float participantrotation[max_dialogues][10];
147 extern XYZ participantfacing[max_dialogues][max_dialoguelength][10];
148 extern float dialoguecamerarotation[max_dialogues][max_dialoguelength];
149 extern float dialoguecamerarotation2[max_dialogues][max_dialoguelength];
150 extern int indialogue;
151 extern int whichdialogue;
152 extern int directing;
153 extern float dialoguetime;
154 extern int dialoguegonethrough[20];
156 extern bool gamestarted;
158 extern bool showdamagebar;
160 extern int channels[100];
161 extern "C" void PlaySoundEx(int channel, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
163 void Game::flash() { // shouldn't be that way, these should be attributes and Person class should not change rendering.
170 /*********************> DrawGLScene() <*****/
171 int Game::DrawGLScene(StereoSide side)
173 static float texcoordwidth,texcoordheight;
174 static float texviewwidth, texviewheight;
176 static GLubyte color;
177 static float newbrightness;
178 static float changespeed;
179 static XYZ checkpoint;
180 static float tempmult;
182 static char string[256]="";
183 static char string2[256]="";
184 static char string3[256]="";
186 static float lastcheck;
188 lastcheck+=multiplier;
190 if ( stereomode == stereoAnaglyph ) {
192 case stereoLeft: glColorMask( 0.0, 1.0, 1.0, 1.0 ); break;
193 case stereoRight: glColorMask( 1.0, 0.0, 0.0, 1.0 ); break;
196 glColorMask( 1.0, 1.0, 1.0, 1.0 );
198 if ( stereomode == stereoHorizontalInterlaced || stereomode == stereoVerticalInterlaced ) {
199 glStencilFunc(side == stereoLeft ? GL_NOTEQUAL : GL_EQUAL, 0x01, 0x01);
203 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)){
210 numboundaries=mapradius*2;
211 if(numboundaries>360)numboundaries=360;
212 for(i=0;i<numboundaries;i++){
215 boundary[i]=mapcenter+DoRotation(boundary[i]*mapradius,0,i*(360/((float)(numboundaries))),0);
224 olddrawmode=drawmode;
225 if(ismotionblur&&!loading){
226 if((findLengthfast(&player[0].velocity)>200)&&velocityblur&&!cameramode){
227 drawmode=motionblurmode;
228 motionbluramount=200/(findLengthfast(&player[0].velocity));
231 if(player[0].damage-player[0].superpermanentdamage>(player[0].damagetolerance-player[0].superpermanentdamage)*1/2&&damageeffects&&!cameramode){
232 drawmode=doublevisionmode;
239 drawmode=motionblurmode;
241 slomodelay-=multiplier;
242 if(slomodelay<0)slomo=0;
246 if((!changed&&!slomo)||loading){
248 if(ismotionblur&&(/*fps>100||*/alwaysblur)){
249 if(olddrawmode!=realmotionblurmode)change=1;
251 drawmode=realmotionblurmode;
253 else if(olddrawmode==realmotionblurmode)change=2;
257 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted))drawmode=normalmode;
258 if((freeze||winfreeze)&&ismotionblur&&!mainmenu)drawmode=radialzoommode;
260 if(winfreeze||mainmenu)drawmode=normalmode;
263 if(drawmode==glowmode){
268 DSpContext_FadeGamma(NULL,200,&color2);
272 if(drawtoggle!=2)drawtoggle=1-drawtoggle;
276 texviewwidth=kTextureSize;
277 if(texviewwidth>screenwidth)texviewwidth=screenwidth;
278 texviewheight=kTextureSize;
279 if(texviewheight>screenheight)texviewheight=screenheight;
281 texcoordwidth=screenwidth/kTextureSize;
282 texcoordheight=screenheight/kTextureSize;
283 if(texcoordwidth>1)texcoordwidth=1;
284 if(texcoordheight>1)texcoordheight=1;
287 glDrawBuffer(GL_BACK);
288 glReadBuffer(GL_BACK);
290 if(abs(blurness-targetblurness)<multiplier*10||abs(blurness-targetblurness)>2){
291 blurness=targetblurness;
292 targetblurness=(float)(abs(Random()%100))/40;
294 if(blurness<targetblurness)
295 blurness+=multiplier*5;
297 blurness-=multiplier*5;
300 static XYZ terrainlight;
301 static float distance;
302 if(drawmode==normalmode)ReSizeGLScene(90,.1f);
303 if(drawmode!=normalmode)glViewport(0,0,texviewwidth,texviewheight);
304 glDepthFunc(GL_LEQUAL);
306 glAlphaFunc(GL_GREATER, 0.0001f);
307 glEnable(GL_ALPHA_TEST);
308 glClearColor(0.25f, 0.25f, 0.25f, 1.0f);
309 glClear(GL_DEPTH_BUFFER_BIT);
311 glMatrixMode (GL_MODELVIEW);
312 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
315 // Move the camera for the current eye's point of view.
316 // Reverse the movement if we're reversing stereo
317 glTranslatef((stereoseparation/2) * side * (stereoreverse ? -1 : 1), 0, 0);
319 if(!cameramode&&!freeze&&!winfreeze){
320 glRotatef(float(Random()%100)/10*camerashake/*+(woozy*woozy)/10*/,0,0,1);
321 glRotatef(rotation2+sin(woozy/2)*(player[0].damage/player[0].damagetolerance)*5,1,0,0);
322 glRotatef(rotation+sin(woozy)*(player[0].damage/player[0].damagetolerance)*5,0,1,0);
324 if(cameramode||freeze||winfreeze){
325 glRotatef(rotation2,1,0,0);
326 glRotatef(rotation,0,1,0);
329 if(environment==desertenvironment){
330 glRotatef((float)(abs(Random()%100))/3000-1,1,0,0);
331 glRotatef((float)(abs(Random()%100))/3000-1,0,1,0);
333 SetUpLight(&light,0);
335 if(environment==desertenvironment&&detail==2)glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, blurness+.4 );
336 if(environment==desertenvironment){
337 glRotatef((float)(abs(Random()%100))/1000,1,0,0);
338 glRotatef((float)(abs(Random()%100))/1000,0,1,0);
341 glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0);
343 glTranslatef(-viewer.x,-viewer.y,-viewer.z);
344 frustum.GetFrustum();
348 static float size,opacity,rotation;
350 for(k=0;k<numplayers;k++){
351 if(!player[k].skeleton.free&&player[k].playerdetail&&player[k].howactive<typesleeping)
352 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)
353 for(i=0;i<player[k].skeleton.num_joints;i++){
354 if(player[k].skeleton.joints[i].label==leftknee||player[k].skeleton.joints[i].label==rightknee||player[k].skeleton.joints[i].label==groin){
355 point=DoRotation(player[k].skeleton.joints[i].position,0,player[k].rotation,0)*player[k].scale+player[k].coords;
357 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;
358 if(k!=0&&tutoriallevel==1){
359 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;
361 terrain.MakeDecal(shadowdecal,point,size,opacity,rotation);
362 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
363 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
364 if(objects.position[j].y<player[k].coords.y||objects.type[j]==tunneltype||objects.type[j]==weirdtype){
365 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);
368 if(k!=0&&tutoriallevel==1){
369 opacity=.2+.2*sin(smoketex*6+i);
371 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
376 if((player[k].skeleton.free||player[k].howactive>=typesleeping)&&player[k].playerdetail)
377 if(frustum.SphereInFrustum(player[k].coords.x,player[k].coords.y,player[k].coords.z,player[k].scale*5)&&player[k].occluded<25)
378 for(i=0;i<player[k].skeleton.num_joints;i++){
379 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){
380 if(player[k].skeleton.free)point=player[k].skeleton.joints[i].position*player[k].scale+player[k].coords;
381 else point=DoRotation(player[k].skeleton.joints[i].position,0,player[k].rotation,0)*player[k].scale+player[k].coords;
383 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;
384 if(k!=0&&tutoriallevel==1){
385 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;
387 terrain.MakeDecal(shadowdecal,point,size,opacity*.7,rotation);
388 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
389 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
390 if(objects.position[j].y<player[k].coords.y||objects.type[j]==tunneltype||objects.type[j]==weirdtype){
391 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);
392 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);
395 if(k!=0&&tutoriallevel==1){
396 opacity=.2+.2*sin(smoketex*6+i);
398 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
404 if(!player[k].playerdetail)
405 if(frustum.SphereInFrustum(player[k].coords.x,player[k].coords.y,player[k].coords.z,player[k].scale*5))
407 point=player[k].coords;
409 opacity=.4-(player[k].coords.y-terrain.getHeight(player[k].coords.x,player[k].coords.z))/5;
410 terrain.MakeDecal(shadowdecal,point,size,opacity*.7,rotation);
411 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
412 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
413 point=DoRotation(player[k].coords-objects.position[j],0,-objects.rotation[j],0);
416 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
422 glEnable(GL_TEXTURE_2D);
424 glEnable(GL_DEPTH_TEST);
425 glEnable(GL_CULL_FACE);
427 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
428 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
429 glBindTexture( GL_TEXTURE_2D, terraintexture);
431 glBindTexture( GL_TEXTURE_2D, terraintexture2);
433 //glBindTexture( GL_TEXTURE_2D, terraintexture3);
434 //glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
437 terrain.drawdecals();
440 glEnable(GL_CULL_FACE);
441 glEnable(GL_LIGHTING);
443 glEnable(GL_TEXTURE_2D);
446 glEnable(GL_COLOR_MATERIAL);
461 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
462 glEnable(GL_CULL_FACE);
463 glCullFace(GL_FRONT);
465 for(k=0;k<numplayers;k++){
466 if(k==0||tutoriallevel!=1){
468 glEnable(GL_LIGHTING);
469 terrainlight=terrain.getLighting(player[k].coords.x,player[k].coords.z);
470 distance=findDistancefast(&viewer,&player[k].coords);
471 distance=(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance;
472 glColor4f(terrainlight.x,terrainlight.y,terrainlight.z,distance);
473 if(distance>=1)glDisable(GL_BLEND);
475 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;
477 if(!player[k].occluded==0)i=checkcollide(viewer,checkpoint,player[k].lastoccluded);
478 if(i==-1||player[k].occluded==0)i=checkcollide(viewer,checkpoint);
480 player[k].occluded+=1;
481 player[k].lastoccluded=i;
483 else player[k].occluded=0;
484 if(player[k].occluded<25)player[k].DrawSkeleton();
490 if(!cameramode&&musictype==stream_music2)playerdist=findDistancefastflat(&player[0].coords,&viewer);
491 else playerdist=-100;
494 glEnable(GL_TEXTURE_2D);
499 if(frustum.SphereInFrustum(realhawkcoords.x+hawk.boundingspherecenter.x,realhawkcoords.y+hawk.boundingspherecenter.y,realhawkcoords.z+hawk.boundingspherecenter.z,2)){
500 glAlphaFunc(GL_GREATER, 0.0001f);
502 glDisable(GL_CULL_FACE);
503 glDisable(GL_LIGHTING);
505 glTranslatef(hawkcoords.x,hawkcoords.y,hawkcoords.z);
506 glRotatef(hawkrotation,0,1,0);
507 glTranslatef(25,0,0);
508 distance=findDistancefast(&viewer,&realhawkcoords)*1.2;
509 glColor4f(light.color[0],light.color[1],light.color[2],(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance);
510 if((viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance>1)glColor4f(light.color[0],light.color[1],light.color[2],1);
511 if((viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance>0)
512 hawk.drawdifftex(hawktexture);
516 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
517 glEnable(GL_CULL_FACE);
518 glCullFace(GL_FRONT);
520 for(k=0;k<numplayers;k++){
521 if(!(k==0||tutoriallevel!=1)){
523 glEnable(GL_LIGHTING);
524 terrainlight=terrain.getLighting(player[k].coords.x,player[k].coords.z);
525 distance=findDistancefast(&viewer,&player[k].coords);
526 distance=(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance;
527 glColor4f(terrainlight.x,terrainlight.y,terrainlight.z,distance);
528 if(distance>=1)glDisable(GL_BLEND);
530 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;
532 if(!player[k].occluded==0)i=checkcollide(viewer,checkpoint,player[k].lastoccluded);
533 if(i==-1||player[k].occluded==0)i=checkcollide(viewer,checkpoint);
535 player[k].occluded+=1;
536 player[k].lastoccluded=i;
538 else player[k].occluded=0;
539 if(player[k].occluded<25)player[k].DrawSkeleton();
545 glEnable(GL_TEXTURE_2D);
550 glDisable(GL_COLOR_MATERIAL);
552 glDisable(GL_LIGHTING);
553 glDisable(GL_TEXTURE_2D);
561 glDisable(GL_LIGHTING);
562 glDisable(GL_TEXTURE_2D);
563 glDisable(GL_COLOR_MATERIAL);
566 for(k=0;k<numplayers;k++){
567 if(player[k].numwaypoints>1){
568 glBegin(GL_LINE_LOOP);
569 for(i=0;i<player[k].numwaypoints;i++){
570 glVertex3f(player[k].waypoints[i].x,player[k].waypoints[i].y+.5,player[k].waypoints[i].z);
579 for(k=0;k<numpathpoints;k++){
580 if(numpathpointconnect[k]){
581 for(i=0;i<numpathpointconnect[k];i++){
582 glBegin(GL_LINE_LOOP);
583 glVertex3f(pathpoint[k].x,pathpoint[k].y+.5,pathpoint[k].z);
584 glVertex3f(pathpoint[pathpointconnect[k][i]].x,pathpoint[pathpointconnect[k][i]].y+.5,pathpoint[pathpointconnect[k][i]].z);
592 glVertex3f(pathpoint[pathpointselected].x,pathpoint[pathpointselected].y+.5,pathpoint[pathpointselected].z);
599 glEnable(GL_TEXTURE_2D);
600 glColor4f(.5,.5,.5,1);
602 sprintf (string, " ",(int)(fps));
603 text.glPrint(10,30,string,0,.8,screenwidth,screenheight);
606 if(bonus>0&&bonustime<1&&!winfreeze&&indialogue==-1/*bonustime<4*/){
607 if(bonus==tracheotomy)sprintf (string, "Tracheotomy!");
608 else if(bonus==backstab)sprintf (string, "Backstabber!");
609 else if(bonus==spinecrusher)sprintf (string, "Spinecrusher!");
610 else if(bonus==ninja)sprintf (string, "Ninja Bonus!");
611 else if(bonus==style)sprintf (string, "Style Bonus!");
612 else if(bonus==cannon)sprintf (string, "Leg Cannon!");
613 else if(bonus==aimbonus)sprintf (string, "Nice Aim!");
614 else if(bonus==deepimpact)sprintf (string, "Heavy Impact!");
615 else if(bonus==touchofdeath)sprintf (string, "Touch of Death!");
616 else if(bonus==swordreversebonus)sprintf (string, "Sword Disarm!");
617 else if(bonus==staffreversebonus)sprintf (string, "Staff Disarm!");
618 else if(bonus==reverseko)sprintf (string, "Reversal KO!");
619 else if(bonus==solidhit)sprintf (string, "Solid Hit!");
620 else if(bonus==twoxcombo)sprintf (string, "2X Combo!");
621 else if(bonus==threexcombo)sprintf (string, "3X Combo!");
622 else if(bonus==fourxcombo)sprintf (string, "4X COMBO!");
623 else if(bonus==megacombo)sprintf (string, "MEGA COMBO!");
624 else if(bonus==Reversal)sprintf (string, "Reversal!");
625 else if(bonus==Stabbonus)sprintf (string, "Punctured!");
626 else if(bonus==Slicebonus)sprintf (string, "Sliced!");
627 else if(bonus==Bullseyebonus)sprintf (string, "Bullseye!");
628 else if(bonus==Slashbonus)sprintf (string, "Slashed!");
629 else if(bonus==Wolfbonus)sprintf (string, "WOLF SLAYER!");
630 else if(bonus==FinishedBonus)sprintf (string, "SLAIN!");
631 else if(bonus==TackleBonus)sprintf (string, "Tackle!");
632 else if(bonus==AboveBonus)sprintf (string, "Death from Above!");
633 else sprintf (string, "Excellent!");
635 glColor4f(0,0,0,1-bonustime);
636 text.glPrintOutline(1024/2-10*strlen(string)-4,768/16-4+768*4/5,string,1,2.5,1024,768);
637 glColor4f(1,0,0,1-bonustime);
638 text.glPrint(1024/2-10*strlen(string),768/16+768*4/5,string,1,2,1024,768);
640 sprintf (string, "%d",(int)bonusvalue);
641 glColor4f(0,0,0,1-bonustime);
642 text.glPrintOutline(1024/2-10*strlen(string)-4,768/16-4-20+768*4/5,string,1,2.5*.8,1024,768);
643 glColor4f(1,0,0,1-bonustime);
644 text.glPrint(1024/2-10*strlen(string),768/16-20+768*4/5,string,1,2*.8,1024,768);
645 glColor4f(.5,.5,.5,1);
648 if(tutoriallevel==1){
649 tutorialopac=tutorialmaxtime-tutorialstagetime;
650 if(tutorialopac>1)tutorialopac=1;
651 if(tutorialopac<0)tutorialopac=0;
653 sprintf (string, " ");
654 sprintf (string2, " ");
655 sprintf (string3, " ");
656 if(tutorialstage==0){
657 sprintf (string, " ");
658 sprintf (string2, " ");
659 sprintf (string3, " ");
661 if(tutorialstage==1){
662 sprintf (string, "Welcome to the Lugaru training level!");
663 sprintf (string2, " ");
664 sprintf (string3, " ");
666 if(tutorialstage==2){
667 sprintf (string, "BASIC MOVEMENT:");
668 sprintf (string2, " ");
669 sprintf (string3, " ");
671 if(tutorialstage==3){
672 sprintf (string, "You can move the mouse to rotate the camera.");
673 sprintf (string2, " ");
674 sprintf (string3, " ");
676 if(tutorialstage==4){
677 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));
678 sprintf (string2, "All movement is relative to the camera.");
679 sprintf (string3, " ");
681 if(tutorialstage==5){
682 sprintf (string, "Please press %s to jump.",Input::keyToChar(jumpkey));
683 sprintf (string2, "You can hold it longer to jump higher.");
684 sprintf (string3, " ");
686 if(tutorialstage==6){
687 sprintf (string, "You can press %s to crouch.",Input::keyToChar(crouchkey));
688 sprintf (string2, "You can jump higher from a crouching position.");
689 sprintf (string3, " ");
691 if(tutorialstage==7){
692 sprintf (string, "While running, you can press %s to roll.",Input::keyToChar(crouchkey));
693 sprintf (string2, " ");
694 sprintf (string3, " ");
696 if(tutorialstage==8){
697 sprintf (string, "While crouching, you can sneak around silently");
698 sprintf (string2, "using the movement keys.");
699 sprintf (string3, " ");
701 if(tutorialstage==9){
702 sprintf (string, "Release the crouch key while sneaking and hold the movement keys");
703 sprintf (string2, "to run animal-style.");
704 sprintf (string3, " ");
706 if(tutorialstage==10){
707 sprintf (string, "ADVANCED MOVEMENT:");
708 sprintf (string2, " ");
709 sprintf (string3, " ");
711 if(tutorialstage==11){
712 sprintf (string, "When you jump at a wall, you can hold %s again",Input::keyToChar(jumpkey));
713 sprintf (string2, "during impact to perform a walljump.");
714 sprintf (string3, "Be sure to use the movement keys to press against the wall");
716 if(tutorialstage==12){
717 sprintf (string, "While in the air, you can press crouch to flip.",Input::keyToChar(jumpkey));
718 sprintf (string2, "Walljumps and flips confuse enemies and give you more control.");
719 sprintf (string3, " ");
721 if(tutorialstage==13){
722 sprintf (string, "BASIC COMBAT:");
723 sprintf (string2, " ");
724 sprintf (string3, " ");
726 if(tutorialstage==14){
727 sprintf (string, "There is now an imaginary enemy");
728 sprintf (string2, "in the middle of the training area.");
729 sprintf (string3, " ");
731 if(tutorialstage==15){
732 if(attackkey==MOUSEBUTTON1)sprintf (string, "Click to attack when you are near an enemy.");
733 else sprintf (string, "Press %s to attack when you are near an enemy.",Input::keyToChar(attackkey));
734 sprintf (string2, "You can punch by standing still near an enemy and attacking.");
735 sprintf (string3, " ");
737 if(tutorialstage==16){
738 sprintf (string, "If you are close, you will perform a weak punch.");
739 sprintf (string2, "The weak punch is excellent for starting attack combinations.");
740 sprintf (string3, " ");
742 if(tutorialstage==17){
743 sprintf (string, "Attacking while running results in a spin kick.");
744 sprintf (string2, "This is one of your most powerful ground attacks.");
745 sprintf (string3, " ");
747 if(tutorialstage==18){
748 sprintf (string, "Sweep the enemy's legs out by attacking while crouched.");
749 sprintf (string2, "This is a very fast attack, and easy to follow up.");
750 sprintf (string3, " ");
752 if(tutorialstage==19){
753 sprintf (string, "When an enemy is on the ground, you can deal some extra");
754 sprintf (string2, "damage by running up and drop-kicking him.");
755 sprintf (string3, "(Try knocking them down with a sweep first)");
757 if(tutorialstage==20){
758 sprintf (string, "Your most powerful individual attack is the rabbit kick.");
759 if(attackkey==MOUSEBUTTON1)sprintf (string2, "Run at the enemy while holding the mouse button, and press");
760 else sprintf (string2, "Run at the enemy while holding %s, and press", Input::keyToChar(attackkey));
761 sprintf (string3, "the jump key (%s) to attack.",Input::keyToChar(jumpkey));
763 if(tutorialstage==21){
764 sprintf (string, "This attack is devastating if timed correctly.");
765 sprintf (string2, "Even if timed incorrectly, it will knock the enemy over.");
766 if(againbonus)sprintf (string3, "Try rabbit-kicking the imaginary enemy again.");
767 else sprintf (string3, "Try rabbit-kicking the imaginary enemy.");
769 if(tutorialstage==22){
770 sprintf (string, "If you sneak behind an enemy unnoticed, you can kill");
771 sprintf (string2, "him instantly. Move close behind this enemy");
772 sprintf (string3, "and attack.");
774 if(tutorialstage==23){
775 sprintf (string, "Another important attack is the wall kick. When an enemy");
776 sprintf (string2, "is near a wall, perform a walljump nearby and hold");
777 sprintf (string3, "the attack key during impact with the wall.");
779 if(tutorialstage==24){
780 sprintf (string, "You can tackle enemies by running at them animal-style");
781 if(attackkey==MOUSEBUTTON1)sprintf (string2, "and pressing jump (%s) or attack(mouse button).",Input::keyToChar(jumpkey));
782 else sprintf (string2, "and pressing jump (%s) or attack(%s).",Input::keyToChar(jumpkey),Input::keyToChar(attackkey));
783 sprintf (string3, "This is especially useful when they are running away.");
785 if(tutorialstage==25){
786 sprintf (string, "Dodge by pressing back and attack. Dodging is essential");
787 sprintf (string2, "against enemies with swords or other long weapons.");
788 sprintf (string3, " ");
790 if(tutorialstage==26){
791 sprintf (string, "REVERSALS AND COUNTER-REVERSALS");
792 sprintf (string2, " ");
793 sprintf (string3, " ");
795 if(tutorialstage==27){
796 sprintf (string, "The enemy can now reverse your attacks.");
797 sprintf (string2, " ");
798 sprintf (string3, " ");
800 if(tutorialstage==28){
801 sprintf (string, "If you attack, you will notice that the enemy now sometimes");
802 sprintf (string2, "catches your attack and uses it against you. Hold");
803 sprintf (string3, "crouch (%s) after attacking to escape from reversals.",Input::keyToChar(crouchkey));
805 if(tutorialstage==29){
806 sprintf (string, "Try escaping from two more reversals in a row.");
807 sprintf (string2, " ");
808 sprintf (string3, " ");
810 if(tutorialstage==30){
811 sprintf (string, "Good!");
812 sprintf (string2, " ");
813 sprintf (string3, " ");
815 if(tutorialstage==31){
816 sprintf (string, "To reverse an attack, you must tap crouch (%s) during the",Input::keyToChar(crouchkey));
817 sprintf (string2, "enemy's attack. You must also be close to the enemy;");
818 sprintf (string3, "this is especially important against armed opponents.");
820 if(tutorialstage==32){
821 sprintf (string, "The enemy can attack in %d seconds.", (int)(tutorialmaxtime-tutorialstagetime));
822 sprintf (string2, "This imaginary opponents attacks will be highlighted");
823 sprintf (string3, "to make this easier.");
825 if(tutorialstage==33){
826 sprintf (string, "Reverse three enemy attacks!");
827 sprintf (string2, " ");
828 sprintf (string3, " ");
830 if(tutorialstage==34){
831 sprintf (string, "Reverse two more enemy attacks!");
832 sprintf (string2, " ");
833 sprintf (string3, " ");
835 if(tutorialstage==35){
836 sprintf (string, "Reverse one more enemy attack!");
837 sprintf (string2, " ");
838 sprintf (string3, " ");
840 if(tutorialstage==36){
841 sprintf (string, "Excellent!");
842 sprintf (string2, " ");
843 sprintf (string3, " ");
845 if(tutorialstage==37){
846 sprintf (string, "Now spar with the enemy for %d more seconds.", (int)(tutorialmaxtime-tutorialstagetime));
847 sprintf (string2, "Damage dealt: %d",(int)damagedealt);
848 sprintf (string3, "Damage taken: %d.",(int)damagetaken);
850 if(tutorialstage==38){
851 sprintf (string, "WEAPONS:");
852 sprintf (string2, " ");
853 sprintf (string3, " ");
855 if(tutorialstage==39){
856 sprintf (string, "There is now an imaginary knife");
857 sprintf (string2, "in the center of the training area.");
858 sprintf (string3, " ");
860 if(tutorialstage==40){
861 sprintf (string, "Stand, roll or handspring over the knife");
862 sprintf (string2, "while pressing %s to pick it up.",Input::keyToChar(throwkey));
863 sprintf (string3, "You can crouch and press the same key to drop it again.");
865 if(tutorialstage==41){
866 sprintf (string, "You can equip and unequip weapons using the %s key.",Input::keyToChar(drawkey));
867 sprintf (string2, "Sometimes it is best to keep them unequipped to");
868 sprintf (string3, "prevent enemies from taking them. ");
870 if(tutorialstage==42){
871 sprintf (string, "The knife is the smallest weapon and the least encumbering.");
872 sprintf (string2, "You can equip or unequip it while standing, crouching,");
873 sprintf (string3, "running or flipping.");
875 if(tutorialstage==43){
876 sprintf (string, "You perform weapon attacks the same way as unarmed attacks,");
877 sprintf (string2, "but sharp weapons cause permanent damage, instead of the");
878 sprintf (string3, "temporary trauma from blunt weapons, fists and feet.");
880 if(tutorialstage==44){
881 sprintf (string, "The enemy now has your knife!");
882 sprintf (string2, "Please reverse two of his knife attacks.");
883 sprintf (string3, " ");
885 if(tutorialstage==45){
886 sprintf (string, "Please reverse one more of his knife attacks.");
887 sprintf (string2, " ");
888 sprintf (string3, " ");
890 if(tutorialstage==46){
891 sprintf (string, "Now he has a sword!");
892 sprintf (string2, "The sword has longer reach than your arms, so you");
893 sprintf (string3, "must move close to reverse the sword slash.");
895 if(tutorialstage==47){
896 sprintf (string, "Long weapons like the sword and staff are also useful for defense;");
897 sprintf (string2, "you can parry enemy weapon attacks by pressing the attack key");
898 sprintf (string3, "at the right time. Please try parrying the enemy's attacks!");
900 if(tutorialstage==48){
901 sprintf (string, "The staff is like the sword, but has two main attacks.");
902 sprintf (string2, "The standing smash is fast and effective, and the running");
903 sprintf (string3, "spin smash is slower and more powerful.");
905 if(tutorialstage==49){
906 sprintf (string, "When facing an enemy, you can throw the knife with %s.",Input::keyToChar(throwkey));
907 sprintf (string2, "It is possible to throw the knife while flipping,");
908 sprintf (string3, "but it is very inaccurate.");
910 if(tutorialstage==50){
911 sprintf (string, "You now know everything you can learn from training.");
912 sprintf (string2, "Everything else you must learn from experience!");
913 sprintf (string3, " ");
915 if(tutorialstage==51){
916 sprintf (string, "Walk out of the training area to return to the main menu.");
917 sprintf (string2, " ");
918 sprintf (string3, " ");
921 glColor4f(0,0,0,tutorialopac);
922 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);
923 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);
924 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);
925 glColor4f(1,1,1,tutorialopac);
926 text.glPrint(screenwidth/2-7.6*strlen(string)*screenwidth/1024,screenheight/16+screenheight*4/5,string,1,1.5*screenwidth/1024,screenwidth,screenheight);
927 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);
928 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);
930 sprintf (string, "Press 'tab' to skip to the next item.",Input::keyToChar(jumpkey));
931 sprintf (string2, "Press escape at any time to");
932 sprintf (string3, "pause or exit the tutorial.");
935 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);
936 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);
937 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);
938 glColor4f(0.5,0.5,0.5,1);
939 text.glPrint(screenwidth/2-7.6*strlen(string)*screenwidth/1024*.8,0+screenheight*1/10,string,1,1.5*screenwidth/1024*.8,screenwidth,screenheight);
940 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);
941 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);
945 if(numhotspots&&(bonustime>=1||bonus<=0||bonustime<0)&&!tutoriallevel){
947 float closestdist=-1;
949 closest=currenthotspot;
950 for(i=0;i<numhotspots;i++){
951 distance=findDistancefast(&player[0].coords,&hotspot[i]);
952 if(closestdist==-1||distance<closestdist){
953 if(findDistancefast(&player[0].coords,&hotspot[i])<hotspotsize[i]&&((hotspottype[i]<=10&&hotspottype[i]>=0)||(hotspottype[i]<=40&&hotspottype[i]>=20))){
954 closestdist=distance;
960 currenthotspot=closest;
961 if(currenthotspot!=-1){
962 if(hotspottype[closest]<=10){
963 if(findDistancefast(&player[0].coords,&hotspot[closest])<hotspotsize[closest])
966 tutorialopac=tutorialmaxtime-tutorialstagetime;
967 if(tutorialopac>1)tutorialopac=1;
968 if(tutorialopac<0)tutorialopac=0;
970 sprintf (string, "%s", hotspottext[closest]);
977 if(string[i]=='\n'||string[i]>'z'||string[i]<' '||string[i]=='\0'){
978 glColor4f(0,0,0,tutorialopac);
979 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);
980 glColor4f(1,1,1,tutorialopac);
981 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);
984 if(string[i]=='\0')done=1;
990 else if (hotspottype[closest]>=20&&dialoguegonethrough[hotspottype[closest]-20]==0){
991 whichdialogue=hotspottype[closest]-20;
992 for(j=0;j<numdialogueboxes[whichdialogue];j++){
993 player[participantfocus[whichdialogue][j]].coords=participantlocation[whichdialogue][participantfocus[whichdialogue][j]];
994 player[participantfocus[whichdialogue][j]].rotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
995 player[participantfocus[whichdialogue][j]].targetrotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
996 player[participantfocus[whichdialogue][j]].velocity=0;
997 player[participantfocus[whichdialogue][j]].targetanimation=player[participantfocus[whichdialogue][j]].getIdle();
998 player[participantfocus[whichdialogue][j]].targetframe=0;
1002 dialoguegonethrough[whichdialogue]++;
1003 if(dialogueboxsound[whichdialogue][indialogue]!=0){
1004 static float gLoc[3];
1005 static float vel[3];
1006 gLoc[0]=player[participantfocus[whichdialogue][indialogue]].coords.x;
1007 gLoc[1]=player[participantfocus[whichdialogue][indialogue]].coords.y;
1008 gLoc[2]=player[participantfocus[whichdialogue][indialogue]].coords.z;
1013 if(dialogueboxsound[whichdialogue][indialogue]==1)whichsoundplay=rabbitchitter;
1014 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
1015 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
1016 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
1017 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
1018 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
1019 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
1020 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
1021 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
1022 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
1023 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
1024 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
1025 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
1026 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
1027 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
1028 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
1029 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
1030 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
1031 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
1032 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
1033 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, true);
1034 OPENAL_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
1035 OPENAL_SetVolume(channels[whichsoundplay], 256);
1036 OPENAL_SetPaused(channels[whichsoundplay], false);
1042 if(indialogue!=-1&&!mainmenu){
1043 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1044 glDisable(GL_CULL_FACE);
1045 glDisable(GL_LIGHTING);
1046 glDisable(GL_TEXTURE_2D);
1048 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1049 glPushMatrix(); // Store The Projection Matrix
1050 glLoadIdentity(); // Reset The Projection Matrix
1051 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1052 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1053 glPushMatrix(); // Store The Modelview Matrix
1054 glLoadIdentity(); // Reset The Modelview Matrix
1055 if(dialogueboxlocation[whichdialogue][indialogue]==1)glTranslatef(0,screenheight*3/4,0);
1056 glScalef(screenwidth,screenheight/4,1);
1057 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1060 glColor4f(dialogueboxcolor[whichdialogue][indialogue][0],dialogueboxcolor[whichdialogue][indialogue][1],dialogueboxcolor[whichdialogue][indialogue][2],0.7);
1062 glVertex3f(0, 0, 0.0f);
1063 glVertex3f(1, 0, 0.0f);
1064 glVertex3f(1, 1, 0.0f);
1065 glVertex3f(0, 1, 0.0f);
1067 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1068 glPopMatrix(); // Restore The Old Projection Matrix
1069 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1070 glPopMatrix(); // Restore The Old Projection Matrix
1071 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1072 glEnable(GL_CULL_FACE);
1073 glDisable(GL_BLEND);
1075 glEnable(GL_TEXTURE_2D);
1082 startx=screenwidth*1/5;
1083 if(dialogueboxlocation[whichdialogue][indialogue]==1)starty=screenheight/16+screenheight*4/5;
1084 if(dialogueboxlocation[whichdialogue][indialogue]==2)starty=screenheight*1/5-screenheight/16;
1093 for(i=0;i<(int)strlen(dialoguename[whichdialogue][indialogue]);i++){
1094 tempname[tempnum]=dialoguename[whichdialogue][indialogue][i];
1096 if(dialoguename[whichdialogue][indialogue][i]=='#'||dialoguename[whichdialogue][indialogue][i]=='\0')goodchar=0;
1100 tempname[tempnum]='\0';
1103 sprintf (string, "%s: ", tempname);
1105 if(dialogueboxcolor[whichdialogue][indialogue][0]+dialogueboxcolor[whichdialogue][indialogue][1]+dialogueboxcolor[whichdialogue][indialogue][2]<1.5){
1106 glColor4f(0,0,0,tutorialopac);
1107 text.glPrintOutline(startx-2*7.6*strlen(string)*screenwidth/1024-4,starty-4,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight);
1108 glColor4f(0.7,0.7,0.7,tutorialopac);
1109 text.glPrint(startx-2*7.6*strlen(string)*screenwidth/1024,starty,string,1,1.5*screenwidth/1024,screenwidth,screenheight);
1113 glColor4f(0,0,0,tutorialopac);
1114 text.glPrintOutline(startx-2*7.6*strlen(string)*screenwidth/1024-4,starty-4,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight);
1118 for(i=0;i<(int)strlen(dialoguetext[whichdialogue][indialogue])+1;i++){
1119 tempname[tempnum]=dialoguetext[whichdialogue][indialogue][i];
1120 if(dialoguetext[whichdialogue][indialogue][i]!='#')tempnum++;
1123 sprintf (string, "%s", tempname);
1130 if(string[i]=='\n'||string[i]>'z'||string[i]<' '||string[i]=='\0'){
1131 if(dialogueboxcolor[whichdialogue][indialogue][0]+dialogueboxcolor[whichdialogue][indialogue][1]+dialogueboxcolor[whichdialogue][indialogue][2]<1.5){
1132 glColor4f(0,0,0,tutorialopac);
1133 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);
1134 glColor4f(1,1,1,tutorialopac);
1135 text.glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/,starty-20*screenwidth/1024*line,string,1,1.5*screenwidth/1024,screenwidth,screenheight,lastline,i);
1139 glColor4f(0,0,0,tutorialopac);
1140 text.glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/,starty-20*screenwidth/1024*line,string,1,1.5*screenwidth/1024,screenwidth,screenheight,lastline,i);
1144 if(string[i]=='\0')done=1;
1151 if(!tutoriallevel&&!winfreeze&&indialogue==-1&&!mainmenu){
1154 sprintf (string, "Score: %d", (int)accountactive->getCampaignScore());
1156 sprintf (string, "Score: %d", (int)accountactive->getCampaignScore()+(int)bonustotal);
1158 if(!campaign)sprintf (string, "Score: %d", (int)bonustotal);
1160 text.glPrintOutline(1024/40-4,768/16-4+768*14/16,string,1,1.5*1.25,1024,768);
1162 text.glPrint(1024/40,768/16+768*14/16,string,1,1.5,1024,768);
1164 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1165 glDisable(GL_CULL_FACE);
1166 glDisable(GL_LIGHTING);
1167 glDisable(GL_TEXTURE_2D);
1169 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1170 glPushMatrix(); // Store The Projection Matrix
1171 glLoadIdentity(); // Reset The Projection Matrix
1172 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1173 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1174 glPushMatrix(); // Store The Modelview Matrix
1175 glLoadIdentity(); // Reset The Modelview Matrix
1176 glTranslatef(15,screenheight*17.5/20,0);
1177 glScalef(screenwidth/3+20,screenheight/20,1);
1178 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1180 glColor4f(0.0,0.4,0.0,0.7);
1181 float bar=((float)player[0].damage)/player[0].damagetolerance;
1183 glVertex3f((bar<1?bar:1),0,0.0f);
1184 glVertex3f(1,0,0.0f);
1185 glVertex3f(1,1,0.0f);
1186 glVertex3f((bar<1?bar:1),1,0.0f);
1188 glColor4f(0.1,0.0,0.0,1);
1189 bar = ((float)player[0].bloodloss)/player[0].damagetolerance;
1191 glVertex3f(0,0,0.0f);
1192 glVertex3f((bar<1?bar:1),0,0.0f);
1193 glVertex3f((bar<1?bar:1),1,0.0f);
1194 glVertex3f(0,1,0.0f);
1196 glColor4f(0.4,0.0,0.0,0.7);
1197 bar = ((float)player[0].damage)/player[0].damagetolerance;
1199 glVertex3f(0,0,0.0f);
1200 glVertex3f((bar<1?bar:1),0,0.0f);
1201 glVertex3f((bar<1?bar:1),1,0.0f);
1202 glVertex3f(0,1,0.0f);
1204 glColor4f(0.4,0.0,0.0,0.7);
1205 bar = ((float)player[0].permanentdamage)/player[0].damagetolerance;
1207 glVertex3f(0,0,0.0f);
1208 glVertex3f((bar<1?bar:1),0,0.0f);
1209 glVertex3f((bar<1?bar:1),1,0.0f);
1210 glVertex3f(0,1,0.0f);
1212 glColor4f(0.4,0.0,0.0,0.7);
1213 bar = ((float)player[0].superpermanentdamage)/player[0].damagetolerance;
1215 glVertex3f(0,0,0.0f);
1216 glVertex3f((bar<1?bar:1),0,0.0f);
1217 glVertex3f((bar<1?bar:1),1,0.0f);
1218 glVertex3f(0,1,0.0f);
1220 glColor4f(0.0,0.0,0.0,0.7);
1222 glBegin(GL_LINE_STRIP);
1223 glVertex3f(0,0,0.0f);
1224 glVertex3f(1,0,0.0f);
1225 glVertex3f(1,1,0.0f);
1226 glVertex3f(0,1,0.0f);
1227 glVertex3f(0,0,0.0f);
1230 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1231 glPopMatrix(); // Restore The Old Projection Matrix
1232 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1233 glPopMatrix(); // Restore The Old Projection Matrix
1234 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1235 glEnable(GL_CULL_FACE);
1236 glDisable(GL_BLEND);
1238 glEnable(GL_TEXTURE_2D);
1240 // writing the numbers :
1241 sprintf (string, "Damages : %d/%d (%d)",(int)(player[0].damage),(int)(player[0].damagetolerance),(int)(player[0].bloodloss));
1243 text.glPrintOutline(1024/40-4,768/16-4+768*14/16-40,string,1,1.5*1.25,1024,768);
1245 text.glPrint(1024/40,768/16+768*14/16-40,string,1,1.5,1024,768);
1249 glColor4f(.5,.5,.5,1);
1252 if((texttoggle||editorenabled)&&debugmode&&!mainmenu){
1253 sprintf (string, "The framespersecond is %d.",(int)(fps));
1254 text.glPrint(10,30,string,0,.8,1024,768);
1256 sprintf (string, "Name: %s", registrationname);
1257 text.glPrint(10,260,string,0,.8,1024,768);
1261 sprintf (string, "Map editor enabled.");
1263 sprintf (string, "Map editor disabled.");
1264 text.glPrint(10,60,string,0,.8,1024,768);
1266 sprintf (string, "Object size: %f",editorsize);
1267 text.glPrint(10,75,string,0,.8,1024,768);
1268 if(editorrotation>=0)sprintf (string, "Object rotation: %f",editorrotation);
1269 else sprintf (string, "Object rotation: Random");
1270 text.glPrint(10,90,string,0,.8,1024,768);
1271 if(editorrotation2>=0)sprintf (string, "Object rotation2: %f",editorrotation2);
1272 else sprintf (string, "Object rotation2: Random");
1273 text.glPrint(10,105,string,0,.8,1024,768);
1274 sprintf (string, "Object type: %d",editortype);
1275 text.glPrint(10,120,string,0,.8,1024,768);
1276 switch(editortype) {
1278 sprintf (string, "(box)");
1281 sprintf (string, "(tree)");
1284 sprintf (string, "(wall)");
1287 sprintf (string, "(weird)");
1290 sprintf (string, "(spike)");
1293 sprintf (string, "(rock)");
1296 sprintf (string, "(bush)");
1299 sprintf (string, "(tunnel)");
1302 sprintf (string, "(chimney)");
1305 sprintf (string, "(platform)");
1308 sprintf (string, "(cool)");
1311 sprintf (string, "(fire)");
1314 text.glPrint(130,120,string,0,.8,1024,768);
1316 sprintf (string, "Numplayers: %d",numplayers);
1317 text.glPrint(10,155,string,0,.8,1024,768);
1318 sprintf (string, "Player %d: numwaypoints: %d",numplayers,player[numplayers-1].numwaypoints);
1319 text.glPrint(10,140,string,0,.8,1024,768);
1321 sprintf (string, "Difficulty: %d",difficulty);
1322 text.glPrint(10,240,string,0,.8,1024,768);
1327 if(drawmode==glowmode){
1328 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1329 glDisable(GL_CULL_FACE);
1330 glDisable(GL_LIGHTING);
1331 glDisable(GL_TEXTURE_2D);
1333 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1334 glPushMatrix(); // Store The Projection Matrix
1335 glLoadIdentity(); // Reset The Projection Matrix
1336 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1337 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1338 glPushMatrix(); // Store The Modelview Matrix
1339 glLoadIdentity(); // Reset The Modelview Matrix
1340 glScalef(screenwidth,screenheight,1);
1341 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1343 glColor4f(0,0,0,.5);
1345 glVertex3f(0, 0, 0.0f);
1346 glVertex3f(256, 0, 0.0f);
1347 glVertex3f(256, 256, 0.0f);
1348 glVertex3f(0, 256, 0.0f);
1350 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1351 glPopMatrix(); // Restore The Old Projection Matrix
1352 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1353 glPopMatrix(); // Restore The Old Projection Matrix
1354 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1355 glEnable(GL_CULL_FACE);
1356 glDisable(GL_BLEND);
1360 if((((blackout&&damageeffects)||(player[0].bloodloss>0&&damageeffects&&player[0].blooddimamount>0)||player[0].dead)&&!cameramode)||console){
1361 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1362 glDisable(GL_CULL_FACE);
1363 glDisable(GL_LIGHTING);
1364 glDisable(GL_TEXTURE_2D);
1366 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1367 glPushMatrix(); // Store The Projection Matrix
1368 glLoadIdentity(); // Reset The Projection Matrix
1369 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1370 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1371 glPushMatrix(); // Store The Modelview Matrix
1372 glLoadIdentity(); // Reset The Modelview Matrix
1373 glScalef(screenwidth,screenheight,1);
1374 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1376 if(player[0].dead)blackout+=multiplier*3;
1377 if(player[0].dead==1)blackout=.4f;
1378 if(player[0].dead==2&&blackout>.6)blackout=.6;
1379 glColor4f(0,0,0,blackout);
1380 if(!player[0].dead){
1381 if((player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5))*.3<.3){
1382 glColor4f(0,0,0,player[0].blooddimamount*player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5)*.3);
1383 blackout=player[0].blooddimamount*player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5)*.3;
1386 glColor4f(0,0,0,player[0].blooddimamount*.3);
1387 blackout=player[0].blooddimamount*.3;
1390 if(console)glColor4f(.7,0,0,.2);
1392 glVertex3f(0, 0, 0.0f);
1393 glVertex3f(256, 0, 0.0f);
1394 glVertex3f(256, 256, 0.0f);
1395 glVertex3f(0, 256, 0.0f);
1397 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1398 glPopMatrix(); // Restore The Old Projection Matrix
1399 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1400 glPopMatrix(); // Restore The Old Projection Matrix
1401 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1402 glEnable(GL_CULL_FACE);
1403 glDisable(GL_BLEND);
1407 if(flashamount>0&&damageeffects){
1408 if(flashamount>1)flashamount=1;
1409 if(flashdelay<=0)flashamount-=multiplier;
1411 if(flashamount<0)flashamount=0;
1412 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1413 glDisable(GL_CULL_FACE);
1414 glDisable(GL_LIGHTING);
1416 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1417 glPushMatrix(); // Store The Projection Matrix
1418 glLoadIdentity(); // Reset The Projection Matrix
1419 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1420 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1421 glPushMatrix(); // Store The Modelview Matrix
1422 glLoadIdentity(); // Reset The Modelview Matrix
1423 glScalef(screenwidth,screenheight,1);
1424 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1426 glColor4f(flashr,flashg,flashb,flashamount);
1428 glVertex3f(0, 0, 0.0f);
1429 glVertex3f(256, 0, 0.0f);
1430 glVertex3f(256, 256, 0.0f);
1431 glVertex3f(0, 256, 0.0f);
1433 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1434 glPopMatrix(); // Restore The Old Projection Matrix
1435 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1436 glPopMatrix(); // Restore The Old Projection Matrix
1437 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1438 glEnable(GL_CULL_FACE);
1439 glDisable(GL_BLEND);
1445 glEnable(GL_TEXTURE_2D);
1448 sprintf (string, " ]");
1449 text.glPrint(10,30+screenheight-330,string,0,1,screenwidth,screenheight);
1451 sprintf (string, "_");
1452 text.glPrint(30+(float)(displayselected)*10,30+(screenheight-330),string,0,1,screenwidth,screenheight);
1456 if((i!=0||chatting)&&displaytime[i]<4)
1457 for(j=0;j<displaychars[i];j++){
1458 glColor4f(1,1,1,4-displaytime[i]);
1459 if(j<displaychars[i]){
1460 sprintf (string, "%c",displaytext[i][j]);
1461 text.glPrint(30+j*10,30+i*20+(screenheight-330),string,0,1,screenwidth,screenheight);
1467 if(minimap&&indialogue==-1){
1468 float mapviewdist = 20000;
1470 glDisable(GL_DEPTH_TEST);
1471 glColor3f (1.0, 1.0, 1.0); // no coloring
1473 glEnable(GL_TEXTURE_2D);
1474 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1475 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1476 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1477 glDisable(GL_CULL_FACE);
1478 glDisable(GL_LIGHTING);
1480 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1481 glPushMatrix(); // Store The Projection Matrix
1482 glLoadIdentity(); // Reset The Projection Matrix
1483 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1484 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1485 glPushMatrix(); // Store The Modelview Matrix
1486 glLoadIdentity(); // Reset The Modelview Matrix
1487 glScalef((float)screenwidth/2,(float)screenwidth/2,1);
1488 glTranslatef(1.75,.25,0);
1489 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1497 int numliveplayers=0;
1499 for(i=0;i<numplayers;i++){
1500 if(!player[i].dead) numliveplayers++;
1505 for(i=0;i<objects.numobjects;i++){
1506 if(objects.type[i]==treetrunktype||objects.type[i]==boxtype){
1507 center+=objects.position[i];
1511 for(i=0;i<numplayers;i++){
1512 if(!player[i].dead)center+=player[i].coords;
1514 center/=numadd+numliveplayers;
1516 center=player[0].coords;
1518 float maxdistance=0;
1521 for(i=0;i<objects.numobjects;i++){
1522 tempdist=findDistancefast(¢er,&objects.position[i]);
1523 if(tempdist>maxdistance){
1525 maxdistance=tempdist;
1528 for(i=0;i<numplayers;i++){
1529 if(!player[i].dead){
1530 tempdist=findDistancefast(¢er,&player[i].coords);
1531 if(tempdist>maxdistance){
1533 maxdistance=tempdist;
1537 radius=fast_sqrt(maxdistance);
1541 glScalef(.25/radius*256*terrain.scale*.4,.25/radius*256*terrain.scale*.4,1);
1543 glScalef(1/(1/radius*256*terrain.scale*.4),1/(1/radius*256*terrain.scale*.4),1);
1545 glRotatef(player[0].lookrotation*-1+180,0,0,1);
1546 glTranslatef(-(center.x/terrain.scale/256*-2+1),(center.z/terrain.scale/256*-2+1),0);
1547 for(i=0;i<objects.numobjects;i++){
1548 if(objects.type[i]==treetrunktype){
1549 distcheck=findDistancefast(&player[0].coords,&objects.position[i]);
1550 if(distcheck<mapviewdist){
1551 glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
1552 glColor4f(0,.3,0,opac*(1-distcheck/mapviewdist));
1554 glTranslatef(objects.position[i].x/terrain.scale/256*-2+1,objects.position[i].z/terrain.scale/256*2-1,0);
1555 glRotatef(objects.rotation[i],0,0,1);
1556 glScalef(.003,.003,.003);
1559 glVertex3f(-1, -1, 0.0f);
1561 glVertex3f(1, -1, 0.0f);
1563 glVertex3f(1, 1, 0.0f);
1565 glVertex3f(-1, 1, 0.0f);
1570 if(objects.type[i]==boxtype){
1571 distcheck=findDistancefast(&player[0].coords,&objects.position[i]);
1572 if(distcheck<mapviewdist){
1573 glBindTexture( GL_TEXTURE_2D, Mapboxtexture);
1574 glColor4f(.4,.4,.4,opac*(1-distcheck/mapviewdist));
1576 glTranslatef(objects.position[i].x/terrain.scale/256*-2+1,objects.position[i].z/terrain.scale/256*2-1,0);
1577 glRotatef(objects.rotation[i],0,0,1);
1578 glScalef(.01*objects.scale[i],.01*objects.scale[i],.01*objects.scale[i]);
1581 glVertex3f(-1, -1, 0.0f);
1583 glVertex3f(1, -1, 0.0f);
1585 glVertex3f(1, 1, 0.0f);
1587 glVertex3f(-1, 1, 0.0f);
1594 glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
1595 for(i=0;i<numboundaries;i++){
1596 glColor4f(0,0,0,opac/3);
1598 glTranslatef(boundary[i].x/terrain.scale/256*-2+1,boundary[i].z/terrain.scale/256*2-1,0);
1599 glScalef(.002,.002,.002);
1602 glVertex3f(-1, -1, 0.0f);
1604 glVertex3f(1, -1, 0.0f);
1606 glVertex3f(1, 1, 0.0f);
1608 glVertex3f(-1, 1, 0.0f);
1613 for(i=0;i<numplayers;i++){
1614 distcheck=findDistancefast(&player[0].coords,&player[i].coords);
1615 if(distcheck<mapviewdist){
1617 glBindTexture( GL_TEXTURE_2D, Maparrowtexture);
1618 if(i==0)glColor4f(1,1,1,opac);
1619 else if(player[i].dead==2||player[i].howactive>typesleeping)glColor4f(0,0,0,opac*(1-distcheck/mapviewdist));
1620 else if(player[i].dead)glColor4f(.3,.3,.3,opac*(1-distcheck/mapviewdist));
1621 else if(player[i].aitype==attacktypecutoff)glColor4f(1,0,0,opac*(1-distcheck/mapviewdist));
1622 else if(player[i].aitype==passivetype)glColor4f(0,1,0,opac*(1-distcheck/mapviewdist));
1623 else glColor4f(1,1,0,1);
1624 glTranslatef(player[i].coords.x/terrain.scale/256*-2+1,player[i].coords.z/terrain.scale/256*2-1,0);
1625 glRotatef(player[i].rotation+180,0,0,1);
1626 glScalef(.005,.005,.005);
1629 glVertex3f(-1, -1, 0.0f);
1631 glVertex3f(1, -1, 0.0f);
1633 glVertex3f(1, 1, 0.0f);
1635 glVertex3f(-1, 1, 0.0f);
1641 glDisable(GL_TEXTURE_2D);
1642 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1643 glPopMatrix(); // Restore The Old Projection Matrix
1644 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1645 glPopMatrix(); // Restore The Old Projection Matrix
1646 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1647 glEnable(GL_CULL_FACE);
1648 glDisable(GL_BLEND);
1652 if(loading&&!stealthloading&&(!campaign||player[0].dead)){
1653 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1654 glDisable(GL_CULL_FACE);
1655 glDisable(GL_LIGHTING);
1656 glDisable(GL_TEXTURE_2D);
1658 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1659 glPushMatrix(); // Store The Projection Matrix
1660 glLoadIdentity(); // Reset The Projection Matrix
1661 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1662 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1663 glPushMatrix(); // Store The Modelview Matrix
1664 glLoadIdentity(); // Reset The Modelview Matrix
1665 glScalef(screenwidth,screenheight,1);
1666 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1668 glColor4f(0,0,0,.7);
1670 glVertex3f(0, 0, 0.0f);
1671 glVertex3f(256, 0, 0.0f);
1672 glVertex3f(256, 256, 0.0f);
1673 glVertex3f(0, 256, 0.0f);
1675 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1676 glPopMatrix(); // Restore The Old Projection Matrix
1677 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1678 glPopMatrix(); // Restore The Old Projection Matrix
1679 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1680 glEnable(GL_CULL_FACE);
1681 glDisable(GL_BLEND);
1685 glDisable(GL_DEPTH_TEST);
1686 glColor3f (1.0, 1.0, 1.0); // no coloring
1688 glEnable(GL_TEXTURE_2D);
1693 glEnable(GL_TEXTURE_2D);
1695 sprintf (string, "Loading...");
1696 text.glPrint(1024/2-90,768/2,string,1,2,1024,768);
1699 //if(ismotionblur)drawmode=motionblurmode;
1700 drawmode=normalmode;
1703 if(winfreeze&&!campaign){
1704 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1705 glDisable(GL_CULL_FACE);
1706 glDisable(GL_LIGHTING);
1707 glDisable(GL_TEXTURE_2D);
1709 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1710 glPushMatrix(); // Store The Projection Matrix
1711 glLoadIdentity(); // Reset The Projection Matrix
1712 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1713 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1714 glPushMatrix(); // Store The Modelview Matrix
1715 glLoadIdentity(); // Reset The Modelview Matrix
1716 glScalef(screenwidth,screenheight,1);
1717 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1719 glColor4f(0,0,0,.4);
1721 glVertex3f(0, 0, 0.0f);
1722 glVertex3f(256, 0, 0.0f);
1723 glVertex3f(256, 256, 0.0f);
1724 glVertex3f(0, 256, 0.0f);
1726 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1727 glPopMatrix(); // Restore The Old Projection Matrix
1728 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1729 glPopMatrix(); // Restore The Old Projection Matrix
1730 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1731 glEnable(GL_CULL_FACE);
1732 glDisable(GL_BLEND);
1736 glDisable(GL_DEPTH_TEST);
1737 glColor3f (1.0, 1.0, 1.0); // no coloring
1739 glEnable(GL_TEXTURE_2D);
1745 if(damagetaken==0&&player[0].bloodloss==0){
1746 awards[numawards]=awardflawless;
1749 bool alldead = true;
1750 for(i=1;i<numplayers;i++){
1751 if(player[i].dead!=2)alldead=0;
1754 awards[numawards]=awardalldead;
1758 for(i=1;i<numplayers;i++){
1759 if(player[i].dead!=1)alldead=0;
1762 awards[numawards]=awardnodead;
1765 if(numresponded==0&&!numthrowkill){
1766 awards[numawards]=awardstealth;
1769 if(numattacks==numstaffattack&&numattacks>0){
1770 awards[numawards]=awardbojutsu;
1773 if(numattacks==numswordattack&&numattacks>0){
1774 awards[numawards]=awardswordsman;
1777 if(numattacks==numknifeattack&&numattacks>0){
1778 awards[numawards]=awardknifefighter;
1781 if(numattacks==numunarmedattack&&numthrowkill==0&&weapons.numweapons>0){
1782 awards[numawards]=awardkungfu;
1786 awards[numawards]=awardevasion;
1789 if(numflipfail==0&&numflipped+numwallflipped*2>20){
1790 awards[numawards]=awardacrobat;
1793 if(numthrowkill==numplayers-1){
1794 awards[numawards]=awardlongrange;
1798 for(i=1;i<numplayers;i++){
1799 if(player[i].dead!=2)alldead=0;
1801 if(numafterkill>0&&alldead){
1802 awards[numawards]=awardbrutal;
1805 if(numreversals>((float)numattacks)*.8&&numreversals>3){
1806 awards[numawards]=awardaikido;
1809 if(maxalarmed==1&&numplayers>2){
1810 awards[numawards]=awardstrategy;
1814 awards[numawards]=awardklutz;
1818 //Win Screen Won Victory
1820 glEnable(GL_TEXTURE_2D);
1822 sprintf (string, "Level Cleared!");
1823 text.glPrintOutlined(1024/2-strlen(string)*10,768*7/8,string,1,2,1024,768);
1825 sprintf (string, "Score: %d",(int)(bonustotal-startbonustotal));
1826 text.glPrintOutlined(1024/30,768*6/8,string,1,2,1024,768);
1829 sprintf (string, "Press Escape or Space to continue");
1831 sprintf (string, "Press Escape to return to menu or Space to continue");
1832 text.glPrintOutlined(640/2-strlen(string)*5,480*1/16,string,1,1,640,480);
1836 for(i=0;i<255;i++)string[i]='\0';
1837 sprintf (temp, "Time: %d:",(int)(((int)leveltime-(int)(leveltime)%60)/60));
1838 strcat(string,temp);
1839 if((int)(leveltime)%60<10)strcat(string,"0");
1840 sprintf (temp, "%d",(int)(leveltime)%60);
1841 strcat(string,temp);
1842 text.glPrintOutlined(1024/30,768*6/8-40,string,1,2,1024,768);
1844 for (i = 0; i < numawards && i < 6; i++)
1845 text.glPrintOutlined(1024/30,768*6/8-90-40*i,award_names[awards[i]],1,2,1024,768);
1848 if(drawmode!=normalmode){
1849 glEnable(GL_TEXTURE_2D);
1851 if(!drawtoggle||drawmode!=realmotionblurmode||(drawtoggle==2||change==1)){
1854 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
1855 GLfloat subtractColor[4] = { 0.5, 0.5, 0.5, 0.0 };
1856 glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, subtractColor);
1857 //glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_SUBTRACT);
1858 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE);
1859 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_CONSTANT_EXT);
1860 glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 2.0f);
1862 glBindTexture( GL_TEXTURE_2D, screentexture);
1863 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1866 if((drawtoggle||change==1)&&drawmode==realmotionblurmode){
1868 glBindTexture( GL_TEXTURE_2D, screentexture2);
1869 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1871 if(!screentexture2){
1872 glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
1874 glGenTextures( 1, &screentexture2 );
1875 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
1877 glEnable(GL_TEXTURE_2D);
1878 glBindTexture( GL_TEXTURE_2D, screentexture2);
1879 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
1880 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
1882 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
1888 glClear(GL_DEPTH_BUFFER_BIT);
1889 ReSizeGLScene(90,.1f);
1890 glViewport(0,0,screenwidth,screenheight);
1892 if(drawmode!=normalmode){
1893 glDisable(GL_DEPTH_TEST);
1894 if(drawmode==motionblurmode){
1895 glDrawBuffer(GL_FRONT);
1896 glReadBuffer(GL_BACK);
1898 glColor3f (1.0, 1.0, 1.0); // no coloring
1900 glEnable(GL_TEXTURE_2D);
1901 glBindTexture( GL_TEXTURE_2D, screentexture);
1902 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1903 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1904 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1905 glDisable(GL_CULL_FACE);
1906 glDisable(GL_LIGHTING);
1908 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1909 glPushMatrix(); // Store The Projection Matrix
1910 glLoadIdentity(); // Reset The Projection Matrix
1911 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1912 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1913 glPushMatrix(); // Store The Modelview Matrix
1914 glLoadIdentity(); // Reset The Modelview Matrix
1915 glScalef((float)screenwidth/2,(float)screenheight/2,1);
1916 glTranslatef(1,1,0);
1917 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1919 if(drawmode==motionblurmode){
1920 if(motionbluramount<.2)motionbluramount=.2;
1921 //glColor4f(1,1,1,fast_sqrt(multiplier)*2.9*motionbluramount);
1922 glColor4f(1,1,1,motionbluramount);
1926 glVertex3f(-1, -1, 0.0f);
1927 glTexCoord2f(texcoordwidth,0);
1928 glVertex3f(1, -1, 0.0f);
1929 glTexCoord2f(texcoordwidth,texcoordheight);
1930 glVertex3f(1, 1, 0.0f);
1931 glTexCoord2f(0,texcoordheight);
1932 glVertex3f(-1, 1, 0.0f);
1936 if(drawmode==realmotionblurmode){
1937 glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
1938 glClear(GL_COLOR_BUFFER_BIT);
1939 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
1940 glBindTexture( GL_TEXTURE_2D, screentexture);
1941 glColor4f(1,1,1,.5);
1945 glVertex3f(-1, -1, 0.0f);
1946 glTexCoord2f(texcoordwidth,0);
1947 glVertex3f(1, -1, 0.0f);
1948 glTexCoord2f(texcoordwidth,texcoordheight);
1949 glVertex3f(1, 1, 0.0f);
1950 glTexCoord2f(0,texcoordheight);
1951 glVertex3f(-1, 1, 0.0f);
1954 glBindTexture( GL_TEXTURE_2D, screentexture2);
1955 glColor4f(1,1,1,.5);
1959 glVertex3f(-1, -1, 0.0f);
1960 glTexCoord2f(texcoordwidth,0);
1961 glVertex3f(1, -1, 0.0f);
1962 glTexCoord2f(texcoordwidth,texcoordheight);
1963 glVertex3f(1, 1, 0.0f);
1964 glTexCoord2f(0,texcoordheight);
1965 glVertex3f(-1, 1, 0.0f);
1968 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1970 if(drawmode==doublevisionmode){
1971 static float crosseyedness;
1972 crosseyedness=abs(player[0].damage-player[0].superpermanentdamage-(player[0].damagetolerance-player[0].superpermanentdamage)*1/2)/30;
1973 if(crosseyedness>1)crosseyedness=1;
1974 if(crosseyedness<0)crosseyedness=0;
1976 glDisable(GL_BLEND);
1981 glVertex3f(-1, -1, 0.0f);
1982 glTexCoord2f(texcoordwidth,0);
1983 glVertex3f(1, -1, 0.0f);
1984 glTexCoord2f(texcoordwidth,texcoordheight);
1985 glVertex3f(1, 1, 0.0f);
1986 glTexCoord2f(0,texcoordheight);
1987 glVertex3f(-1, 1, 0.0f);
1991 glColor4f(1,1,1,.5);
1994 glTranslatef(.015*crosseyedness,0,0);
1998 glVertex3f(-1, -1, 0.0f);
1999 glTexCoord2f(texcoordwidth,0);
2000 glVertex3f(1, -1, 0.0f);
2001 glTexCoord2f(texcoordwidth,texcoordheight);
2002 glVertex3f(1, 1, 0.0f);
2003 glTexCoord2f(0,texcoordheight);
2004 glVertex3f(-1, 1, 0.0f);
2009 if(drawmode==glowmode){
2010 glColor4f(.5,.5,.5,.5);
2012 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
2014 glTranslatef(.01,0,0);
2017 glVertex3f(-1, -1, 0.0f);
2018 glTexCoord2f(texcoordwidth,0);
2019 glVertex3f(1, -1, 0.0f);
2020 glTexCoord2f(texcoordwidth,texcoordheight);
2021 glVertex3f(1, 1, 0.0f);
2022 glTexCoord2f(0,texcoordheight);
2023 glVertex3f(-1, 1, 0.0f);
2027 glTranslatef(-.01,0,0);
2030 glVertex3f(-1, -1, 0.0f);
2031 glTexCoord2f(texcoordwidth,0);
2032 glVertex3f(1, -1, 0.0f);
2033 glTexCoord2f(texcoordwidth,texcoordheight);
2034 glVertex3f(1, 1, 0.0f);
2035 glTexCoord2f(0,texcoordheight);
2036 glVertex3f(-1, 1, 0.0f);
2040 glTranslatef(.0,.01,0);
2043 glVertex3f(-1, -1, 0.0f);
2044 glTexCoord2f(texcoordwidth,0);
2045 glVertex3f(1, -1, 0.0f);
2046 glTexCoord2f(texcoordwidth,texcoordheight);
2047 glVertex3f(1, 1, 0.0f);
2048 glTexCoord2f(0,texcoordheight);
2049 glVertex3f(-1, 1, 0.0f);
2053 glTranslatef(0,-.01,0);
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==radialzoommode){
2068 //glRotatef((float)i*.1,0,0,1);
2069 glColor4f(1,1,1,1/((float)i+1));
2071 glScalef(1+(float)i*.01,1+(float)i*.01,1);
2074 glVertex3f(-1, -1, 0.0f);
2075 glTexCoord2f(texcoordwidth,0);
2076 glVertex3f(1, -1, 0.0f);
2077 glTexCoord2f(texcoordwidth,texcoordheight);
2078 glVertex3f(1, 1, 0.0f);
2079 glTexCoord2f(0,texcoordheight);
2080 glVertex3f(-1, 1, 0.0f);
2085 glDisable(GL_TEXTURE_2D);
2086 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2087 glPopMatrix(); // Restore The Old Projection Matrix
2088 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2089 glPopMatrix(); // Restore The Old Projection Matrix
2090 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
2091 glEnable(GL_CULL_FACE);
2092 glDisable(GL_BLEND);
2097 glEnable(GL_TEXTURE_2D);
2100 if(consoleselected>=60)
2101 offset=consoleselected-60;
2102 sprintf (string, " ]");
2103 text.glPrint(10,30,string,0,1,1024,768);
2105 sprintf (string, "_");
2106 text.glPrint(30+(float)(consoleselected)*10-offset*10,30,string,0,1,1024,768);
2109 for(j=0;j<consolechars[i];j++){
2110 glColor4f(1,1,1,1-(float)(i)/16);
2111 if(j<consolechars[i]){
2112 sprintf (string, "%c",consoletext[i][j]);
2113 text.glPrint(30+j*10-offset*10,30+i*20,string,0,1,1024,768);
2120 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)||(mainmenu&&gameon)||(!gameon&&gamestarted)||(!gameon&&gamestarted)){
2121 multiplier=tempmult;
2126 // !!! FIXME: hack: clamp framerate in menu so text input works correctly on fast systems.
2129 glDrawBuffer(GL_BACK);
2130 glReadBuffer(GL_BACK);
2131 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
2132 ReSizeGLScene(90,.1f);
2135 temptexdetail=texdetail;
2136 if(texdetail>2)texdetail=2;
2137 if(mainmenu!=oldmainmenu&&oldmainmenu!=0){
2139 LoadTexture(":Data:Textures:Newgame.png",&Mainmenuitems[1],0,0);
2140 LoadTexture(":Data:Textures:Quit.png",&Mainmenuitems[3],0,0);
2143 LoadTexture(":Data:Textures:Resume.png",&Mainmenuitems[1],0,0);
2144 LoadTexture(":Data:Textures:Endgame.png",&Mainmenuitems[3],0,0);
2147 if(lastcheck>.5||oldmainmenu!=mainmenu){
2149 ifstream ipstream(ConvertFileName(":Data:Campaigns:main.txt"));
2150 ipstream.ignore(256,':');
2151 ipstream >> campaignnumlevels;
2152 for(i=0;i<campaignnumlevels;i++){
2153 ipstream.ignore(256,':');
2154 ipstream.ignore(256,':');
2155 ipstream.ignore(256,' ');
2156 ipstream >> campaignmapname[i];
2157 ipstream.ignore(256,':');
2158 ipstream >> campaigndescription[i];
2160 if(campaigndescription[i][j]=='_')campaigndescription[i][j]=' ';
2162 ipstream.ignore(256,':');
2163 ipstream >> campaignchoosenext[i];
2164 ipstream.ignore(256,':');
2165 ipstream >> campaignnumnext[i];
2166 for(j=0;j<campaignnumnext[i];j++){
2167 ipstream.ignore(256,':');
2168 ipstream >> campaignnextlevel[i][j];
2169 campaignnextlevel[i][j]-=1;
2171 ipstream.ignore(256,':');
2172 ipstream >> campaignlocationx[i];
2173 ipstream.ignore(256,':');
2174 ipstream >> campaignlocationy[i];
2178 for(i=0;i<campaignnumlevels;i++){
2180 levelhighlight[i]=0;
2185 for(i=0;i<accountactive->getCampaignChoicesMade();i++){
2186 levelorder[i+1]=campaignnextlevel[levelorder[i]][accountactive->getCampaignChoice(i)];
2187 levelvisible[levelorder[i+1]]=1;
2189 int whichlevelstart = accountactive->getCampaignChoicesMade()-1;
2190 if(whichlevelstart<0){
2191 accountactive->setCampaignScore(0);
2192 accountactive->resetFasttime();
2193 campaignchoicenum=1;
2194 campaignchoicewhich[0]=0;
2198 campaignchoicenum=campaignnumnext[levelorder[whichlevelstart]];
2199 for(i=0;i<campaignchoicenum;i++){
2200 campaignchoicewhich[i]=campaignnextlevel[levelorder[whichlevelstart]][i];
2201 levelvisible[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
2202 levelhighlight[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
2211 texdetail=temptexdetail;
2213 oldmainmenu=mainmenu;
2215 if(mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==8||mainmenu==9||mainmenu==10||mainmenu==119||mainmenu==18){
2216 glClear(GL_DEPTH_BUFFER_BIT);
2217 glEnable(GL_ALPHA_TEST);
2218 glAlphaFunc(GL_GREATER, 0.001f);
2219 glEnable(GL_TEXTURE_2D);
2220 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
2221 glDisable(GL_CULL_FACE);
2222 glDisable(GL_LIGHTING);
2224 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2225 glPushMatrix(); // Store The Projection Matrix
2226 glLoadIdentity(); // Reset The Projection Matrix
2227 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
2228 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2229 glPushMatrix(); // Store The Modelview Matrix
2230 glLoadIdentity(); // Reset The Modelview Matrix
2231 glTranslatef(screenwidth/2,screenheight/2,0);
2233 glScalef((float)screenwidth/2,(float)screenheight/2,1);
2234 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
2235 glDisable(GL_BLEND);
2236 glColor4f(0,0,0,1.0);
2237 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2238 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2239 glDisable(GL_TEXTURE_2D);
2241 //glScalef(.25,.25,.25);
2244 glVertex3f(-1, -1, 0.0f);
2246 glVertex3f(1, -1, 0.0f);
2248 glVertex3f(1, 1, 0.0f);
2250 glVertex3f(-1, 1, 0.0f);
2254 glColor4f(0.4,0.4,0.4,1.0);
2255 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2256 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2257 glEnable(GL_TEXTURE_2D);
2258 glBindTexture( GL_TEXTURE_2D, Mainmenuitems[4]);
2260 //glScalef(.25,.25,.25);
2263 glVertex3f(-1, -1, 0.0f);
2265 glVertex3f(1, -1, 0.0f);
2267 glVertex3f(1, 1, 0.0f);
2269 glVertex3f(-1, 1, 0.0f);
2274 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2276 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2280 if((float)newscreenwidth>(float)newscreenheight*1.61||(float)newscreenwidth<(float)newscreenheight*1.59)sprintf (menustring[0], "Resolution: %d*%d",(int)newscreenwidth,(int)newscreenheight);
2281 else sprintf (menustring[0], "Resolution: %d*%d (widescreen)",(int)newscreenwidth,(int)newscreenheight);
2284 endx[0]=startx[0]+strlen(menustring[0])*10;
2285 endy[0]=starty[0]+20;
2289 if(newdetail==2)sprintf (menustring[1], "Detail: High");
2290 else if(newdetail==1)sprintf (menustring[1], "Detail: Medium");
2291 else sprintf (menustring[1], "Detail: Low");
2294 endx[1]=startx[1]+strlen(menustring[1])*10;
2295 endy[1]=starty[1]+20;
2299 if(bloodtoggle==2)sprintf (menustring[2], "Blood: On, high detail (slower)");
2300 if(bloodtoggle==1)sprintf (menustring[2], "Blood: On, low detail");
2301 if(bloodtoggle==0)sprintf (menustring[2], "Blood: Off");
2304 endx[2]=startx[2]+strlen(menustring[2])*10;
2305 endy[2]=starty[2]+20;
2309 if(difficulty==2)sprintf (menustring[3], "Difficulty: Insane");
2310 if(difficulty==1)sprintf (menustring[3], "Difficulty: Difficult");
2311 if(difficulty==0)sprintf (menustring[3], "Difficulty: Easier");
2312 startx[3]=10+20-1000;
2314 endx[3]=startx[3]+strlen(menustring[3])*10;
2315 endy[3]=starty[3]+20;
2319 if(ismotionblur==1)sprintf (menustring[4], "Blur Effects: Enabled (less compatible)");
2320 if(ismotionblur==0)sprintf (menustring[4], "Blur Effects: Disabled (more compatible)");
2323 endx[4]=startx[4]+strlen(menustring[4])*10;
2324 endy[4]=starty[4]+20;
2328 if(decals==1)sprintf (menustring[5], "Decals: Enabled (slower)");
2329 if(decals==0)sprintf (menustring[5], "Decals: Disabled");
2332 endx[5]=startx[5]+strlen(menustring[5])*10;
2333 endy[5]=starty[5]+20;
2337 if(musictoggle==1)sprintf (menustring[6], "Music: Enabled");
2338 if(musictoggle==0)sprintf (menustring[6], "Music: Disabled");
2341 endx[6]=startx[6]+strlen(menustring[6])*10;
2342 endy[6]=starty[6]+20;
2346 if(invertmouse==1)sprintf (menustring[9], "Invert mouse: Yes");
2347 if(invertmouse==0)sprintf (menustring[9], "Invert mouse: No");
2350 endx[9]=startx[9]+strlen(menustring[9])*10;
2351 endy[9]=starty[9]+20;
2355 sprintf (menustring[10], "Mouse Speed: %d", (int)(usermousesensitivity*5));
2358 endx[10]=startx[10]+strlen(menustring[10])*10;
2359 endy[10]=starty[10]+20;
2363 sprintf (menustring[11], "Volume: %d%%", (int)(volume*100));
2366 endx[11]=startx[11]+strlen(menustring[11])*10;
2367 endy[11]=starty[11]+20;
2371 sprintf (menustring[13], "Damage Bar: %s",(showdamagebar?"on":"off"));
2374 endx[13]=startx[13]+strlen(menustring[13])*10;
2375 endy[13]=starty[13]+20;
2379 sprintf (menustring[7], "-Configure Controls-");
2382 endx[7]=startx[7]+strlen(menustring[7])*10;
2383 endy[7]=starty[7]+20;
2387 sprintf (menustring[12], "-Configure Stereo -");
2390 endx[12]=startx[12]+strlen(menustring[7])*10;
2391 endy[12]=starty[12]+20;
2395 if(newdetail==detail&&newscreenheight==(int)screenheight&&newscreenwidth==(int)screenwidth)sprintf (menustring[8], "Back");
2396 else sprintf (menustring[8], "Back (some changes take effect next time Lugaru is opened)");
2398 endx[8]=startx[8]+strlen(menustring[8])*10;
2400 endy[8]=starty[8]+20;
2407 if(keyselect!=0)sprintf (menustring[0], "Forwards: %s",Input::keyToChar(forwardkey));
2408 else sprintf (menustring[0], "Forwards: _");
2411 endx[0]=startx[0]+strlen(menustring[0])*10;
2412 endy[0]=starty[0]+20;
2416 if(keyselect!=1)sprintf (menustring[1], "Back: %s",Input::keyToChar(backkey));
2417 else sprintf (menustring[1], "Back: _");
2420 endx[1]=startx[1]+strlen(menustring[1])*10;
2421 endy[1]=starty[1]+20;
2425 if(keyselect!=2)sprintf (menustring[2], "Left: %s",Input::keyToChar(leftkey));
2426 else sprintf (menustring[2], "Left: _");
2429 endx[2]=startx[2]+strlen(menustring[2])*10;
2430 endy[2]=starty[2]+20;
2434 if(keyselect!=3)sprintf (menustring[3], "Right: %s",Input::keyToChar(rightkey));
2435 else sprintf (menustring[3], "Right: _");
2438 endx[3]=startx[3]+strlen(menustring[3])*10;
2439 endy[3]=starty[3]+20;
2443 if(keyselect!=4)sprintf (menustring[4], "Crouch: %s",Input::keyToChar(crouchkey));
2444 else sprintf (menustring[4], "Crouch: _");
2447 endx[4]=startx[4]+strlen(menustring[4])*10;
2448 endy[4]=starty[4]+20;
2452 if(keyselect!=5)sprintf (menustring[5], "Jump: %s",Input::keyToChar(jumpkey));
2453 else sprintf (menustring[5], "Jump: _");
2456 endx[5]=startx[5]+strlen(menustring[5])*10;
2457 endy[5]=starty[5]+20;
2461 if(keyselect!=6)sprintf (menustring[6], "Draw: %s",Input::keyToChar(drawkey));
2462 else sprintf (menustring[6], "Draw: _");
2465 endx[6]=startx[6]+strlen(menustring[6])*10;
2466 endy[6]=starty[6]+20;
2470 if(keyselect!=7)sprintf (menustring[7], "Throw: %s",Input::keyToChar(throwkey));
2471 else sprintf (menustring[7], "Throw: _");
2474 endx[7]=startx[7]+strlen(menustring[7])*10;
2475 endy[7]=starty[7]+20;
2479 if(keyselect!=8)sprintf (menustring[8], "Attack: %s",Input::keyToChar(attackkey));
2480 else sprintf (menustring[8], "Attack: _");
2483 endx[8]=startx[8]+strlen(menustring[8])*10;
2484 endy[8]=starty[8]+20;
2490 sprintf (menustring[9], "Back");
2492 endx[9]=startx[9]+strlen(menustring[9])*10;
2494 endy[9]=starty[9]+20;
2499 nummenuitems=7+accountactive->getCampaignChoicesMade()+campaignchoicenum;
2501 sprintf (menustring[0], "%s",accountactive->getName());
2504 endx[0]=startx[0]+strlen(menustring[0])*10;
2505 endy[0]=starty[0]+20;
2509 sprintf (menustring[1], "Tutorial");
2512 endx[1]=startx[1]+strlen(menustring[1])*10;
2513 endy[1]=starty[1]+20;
2517 sprintf (menustring[2], "Challenge");
2520 endx[2]=startx[2]+strlen(menustring[2])*10;
2521 endy[2]=starty[2]+20;
2525 sprintf (menustring[3], "Delete User");
2528 endx[3]=startx[3]+strlen(menustring[3])*10;
2529 endy[3]=starty[3]+20;
2533 sprintf (menustring[4], "Main Menu");
2536 endx[4]=startx[4]+strlen(menustring[4])*10;
2537 endy[4]=starty[4]+20;
2541 sprintf (menustring[5], "Change User");
2543 endx[5]=startx[5]+strlen(menustring[5])*10;
2545 endy[5]=starty[5]+20;
2551 sprintf (menustring[6], "World");
2553 starty[6]=30+480-400-50;
2554 endx[6]=startx[6]+400;
2559 if(accountactive->getCampaignChoicesMade())
2560 for(i=0;i<accountactive->getCampaignChoicesMade();i++){
2561 sprintf (menustring[7+i], "%s", campaigndescription[levelorder[i]]);
2562 startx[7+i]=30+120+campaignlocationx[levelorder[i]]*400/512;
2563 starty[7+i]=30+30+(512-campaignlocationy[levelorder[i]])*400/512;
2564 endx[7+i]=startx[7+i]+10;
2565 endy[7+i]=starty[7+i]+10;
2570 if(campaignchoicenum>0)
2571 for(i=accountactive->getCampaignChoicesMade();i<accountactive->getCampaignChoicesMade()+campaignchoicenum;i++){
2572 sprintf (menustring[7+i], "%s", campaigndescription[levelorder[i]]);
2573 startx[7+i]=30+120+campaignlocationx[campaignchoicewhich[i-(accountactive->getCampaignChoicesMade())]]*400/512;
2574 starty[7+i]=30+30+(512-campaignlocationy[campaignchoicewhich[i-(accountactive->getCampaignChoicesMade())]])*400/512;
2575 endx[7+i]=startx[7+i]+10;
2576 endy[7+i]=starty[7+i]+10;
2581 /*sprintf (menustring[7], "Dot");
2582 startx[7]=120+260*400/512;
2583 starty[7]=30+(512-184)*400/512;
2584 endx[7]=startx[7]+10;
2585 endy[7]=starty[7]+10;
2589 sprintf (menustring[8], "Dot");
2590 startx[8]=120+129*400/512;
2591 starty[8]=30+(512-284)*400/512;
2592 endx[8]=startx[8]+10;
2593 endy[8]=starty[8]+10;
2597 sprintf (menustring[9], "Dot");
2598 startx[9]=120+358*400/512;
2599 starty[9]=30+(512-235)*400/512;
2600 endx[9]=startx[9]+10;
2601 endy[9]=starty[9]+10;
2605 sprintf (menustring[10], "Dot");
2606 startx[10]=120+359*400/512;
2607 starty[10]=30+(512-308)*400/512;
2608 endx[10]=startx[10]+10;
2609 endy[10]=starty[10]+10;
2613 sprintf (menustring[11], "Dot");
2614 startx[11]=120+288*400/512;
2615 starty[11]=30+(512-277)*400/512;
2616 endx[11]=startx[11]+10;
2617 endy[11]=starty[11]+10;
2625 sprintf (menustring[0], "Are you sure you want to delete this user?");
2628 endx[0]=startx[0]+strlen(menustring[0])*10;
2629 endy[0]=starty[0]+20;
2633 sprintf (menustring[1], "Yes");
2636 endx[1]=startx[1]+strlen(menustring[1])*10;
2637 endy[1]=starty[1]+20;
2641 sprintf (menustring[2], "No");
2644 endx[2]=startx[2]+strlen(menustring[2])*10;
2645 endy[2]=starty[2]+20;
2649 sprintf (menustring[3], "Extra 4");
2652 endx[3]=startx[3]+strlen(menustring[3])*10;
2653 endy[3]=starty[3]+20;
2657 sprintf (menustring[4], "Extra 5");
2660 endx[4]=startx[4]+strlen(menustring[4])*10;
2661 endy[4]=starty[4]+20;
2665 sprintf (menustring[5], "Back");
2667 endx[5]=startx[5]+strlen(menustring[5])*10;
2669 endy[5]=starty[5]+20;
2675 nummenuitems=Account::getNbAccounts()+2;
2679 if(Account::getNbAccounts()<8)
2680 sprintf (menustring[0], "New User");
2682 sprintf (menustring[0], "No More Users");
2685 endx[0]=startx[0]+strlen(menustring[0])*10;
2686 endy[0]=starty[0]+20;
2695 for(i=0;i<Account::getNbAccounts();i++){
2696 sprintf (menustring[num], "%s",Account::get(i)->getName());
2698 starty[num]=360-20-20*num;
2699 endx[num]=startx[num]+strlen(menustring[num])*10;
2700 endy[num]=starty[num]+20;
2707 sprintf (menustring[num], "Back");
2709 endx[num]=startx[num]+strlen(menustring[num])*10;
2711 endy[num]=starty[num]+20;
2718 sprintf (menustring[0], "Easier");
2721 endx[0]=startx[0]+strlen(menustring[0])*10;
2722 endy[0]=starty[0]+20;
2726 sprintf (menustring[1], "Difficult");
2729 endx[1]=startx[1]+strlen(menustring[1])*10;
2730 endy[1]=starty[1]+20;
2734 sprintf (menustring[2], "Insane");
2737 endx[2]=startx[2]+strlen(menustring[2])*10;
2738 endy[2]=starty[2]+20;
2744 //tempncl=numchallengelevels;
2745 //numchallengelevels=9;
2746 nummenuitems=2+numchallengelevels;
2749 for(j=0;j<numchallengelevels;j++){
2750 for(i=0;i<255;i++)menustring[j][i]='\0';
2751 sprintf (temp, "Level %d",j+1);
2752 strcpy(menustring[j],temp);
2753 for(i=0;i<17;i++)if(menustring[j][i]=='\0')menustring[j][i]=' ';
2754 menustring[j][17]='\0';
2755 sprintf (temp, "%d",(int)accountactive->getHighScore(j));
2756 strcat(menustring[j],temp);
2757 for(i=18;i<32;i++)if(menustring[j][i]=='\0')menustring[j][i]=' ';
2758 menustring[j][32]='\0';
2759 sprintf (temp, "%d:",(int)(((int)accountactive->getFastTime(j)-(int)(accountactive->getFastTime(j))%60)/60));
2760 strcat(menustring[j],temp);
2761 if((int)(accountactive->getFastTime(j))%60<10)strcat(menustring[j],"0");
2762 sprintf (temp, "%d",(int)(accountactive->getFastTime(j))%60);
2763 strcat(menustring[j],temp);
2767 endx[j]=startx[j]+strlen(menustring[j])*10;
2768 endy[j]=starty[j]+20;
2773 sprintf (menustring[numchallengelevels], "Back");
2774 startx[numchallengelevels]=10;
2775 endx[numchallengelevels]=startx[numchallengelevels]+strlen(menustring[numchallengelevels])*10;
2776 starty[numchallengelevels]=10;
2777 endy[numchallengelevels]=starty[numchallengelevels]+20;
2778 movex[numchallengelevels]=0;
2779 movey[numchallengelevels]=0;
2781 sprintf (menustring[numchallengelevels+1], " High Score Best Time");
2782 startx[numchallengelevels+1]=10;
2783 starty[numchallengelevels+1]=440;
2784 endx[numchallengelevels+1]=startx[numchallengelevels+1]+strlen(menustring[numchallengelevels+1])*10;
2785 endy[numchallengelevels+1]=starty[numchallengelevels+1]+20;
2786 movex[numchallengelevels+1]=0;
2787 movey[numchallengelevels+1]=0;
2789 //numchallengelevels=tempncl;
2796 sprintf (menustring[0], "Congratulations!");
2799 endx[0]=startx[0]+strlen(menustring[0])*10;
2800 endy[0]=starty[0]+20;
2804 sprintf (menustring[1], "You have avenged your family and");
2807 endx[1]=startx[1]+strlen(menustring[1])*10;
2808 endy[1]=starty[1]+20;
2812 sprintf (menustring[2], "restored peace to the island of Lugaru.");
2815 endx[2]=startx[2]+strlen(menustring[2])*10;
2816 endy[2]=starty[2]+20;
2820 sprintf (menustring[3], "Back");
2822 endx[3]=startx[3]+strlen(menustring[3])*10;
2824 endy[3]=starty[3]+20;
2828 for(i=0;i<255;i++)menustring[4][i]='\0';
2829 sprintf (temp, "Your score:");
2830 strcpy(menustring[4],temp);
2831 for(i=0;i<20;i++)if(menustring[4][i]=='\0')menustring[4][i]=' ';
2832 menustring[4][20]='\0';
2833 sprintf (temp, "%d",(int)accountactive->getCampaignScore());
2834 strcat(menustring[4],temp);
2836 endx[4]=startx[4]+strlen(menustring[4])*10;
2838 endy[4]=starty[4]+20;
2842 for(i=0;i<255;i++)menustring[5][i]='\0';
2843 sprintf (temp, "Your time:");
2844 strcpy(menustring[5],temp);
2845 for(i=0;i<20;i++)if(menustring[5][i]=='\0')menustring[5][i]=' ';
2846 menustring[5][20]='\0';
2847 sprintf (temp, "%d",(int)accountcampaigntime[accountactive]);
2848 strcat(menustring[5],temp);
2850 endx[5]=startx[5]+strlen(menustring[5])*10;
2852 endy[5]=starty[5]+20;
2856 for(i=0;i<255;i++)menustring[5][i]='\0';
2857 sprintf (temp, "Highest score:");
2858 strcpy(menustring[5],temp);
2859 for(i=0;i<20;i++)if(menustring[5][i]=='\0')menustring[5][i]=' ';
2860 menustring[5][20]='\0';
2861 sprintf (temp, "%d",(int)accountactive->getCampaignHighScore());
2862 strcat(menustring[5],temp);
2864 endx[5]=startx[5]+strlen(menustring[5])*10;
2866 endy[5]=starty[5]+20;
2870 for(i=0;i<255;i++)menustring[7][i]='\0';
2871 sprintf (temp, "Lowest time:");
2872 strcpy(menustring[7],temp);
2873 for(i=0;i<20;i++)if(menustring[7][i]=='\0')menustring[7][i]=' ';
2874 menustring[7][20]='\0';
2875 sprintf (temp, "%d",(int)accountactive->getCampaignFasttime());
2876 strcat(menustring[7],temp);
2878 endx[7]=startx[7]+strlen(menustring[7])*10;
2880 endy[7]=starty[7]+20;
2886 sprintf (menustring[0], "Stereo mode: %s", StereoModeName(newstereomode));
2889 endx[0]=startx[0]+strlen(menustring[0])*10;
2890 endy[0]=starty[0]+20;
2894 sprintf (menustring[1], "Stereo separation: %.3f", stereoseparation);
2897 endx[1]=startx[1]+strlen(menustring[1])*10;
2898 endy[1]=starty[1]+20;
2902 sprintf (menustring[2], "Reverse stereo: %s", stereoreverse ? "Yes" : "No");
2905 endx[2]=startx[2]+strlen(menustring[2])*10;
2906 endy[2]=starty[2]+20;
2910 sprintf (menustring[3], "Back");
2912 endx[3]=startx[3]+strlen(menustring[3])*10;
2914 endy[3]=starty[3]+20;
2920 if(mainmenu==1||mainmenu==2){
2930 starty[1]=480-152-32;
2937 starty[2]=480-228-32;
2945 starty[3]=480-306-32;
2954 starty[3]=480-306-32;
2968 starty[4]=480-140-256;
2975 starty[5]=480-138-256;
2982 starty[6]=480-144-256;
2990 starty[4]=480-140-256;
2997 starty[5]=480-138-256;
3004 starty[6]=480-144-256;
3012 starty[4]=480-140-256;
3019 starty[5]=480-150-256;
3026 starty[6]=480-144-256;
3034 starty[4]=480-140-256;
3041 starty[5]=480-150-256;
3048 starty[6]=480-144-256;
3056 starty[4]=480-100-256;
3063 starty[5]=480-120-256;
3070 starty[6]=480-144-256;
3080 if(mainmenu==1||mainmenu==2)
3082 if((mousecoordh/screenwidth*640)>startx[i]&&(mousecoordh/screenwidth*640)<endx[i]&&480-(mousecoordv/screenheight*480)>starty[i]&&480-(mousecoordv/screenheight*480)<endy[i]){
3087 if(mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==8||mainmenu==9||mainmenu==10||mainmenu==18)
3088 for(i=0;i<nummenuitems;i++){
3089 if((mousecoordh/screenwidth*640)>startx[i]&&(mousecoordh/screenwidth*640)<endx[i]&&480-(mousecoordv/screenheight*480)>starty[i]&&480-(mousecoordv/screenheight*480)<endy[i]){
3090 if(mainmenu!=5)selected=i;
3091 if(mainmenu==5&&(i!=0&&i!=6))selected=i;
3092 if(mainmenu==9&&(i!=numchallengelevels+1))selected=i; // seem useless, if mainmenu==9 then mainmenu!=5, so selected==i.
3096 for(i=0;i<nummenuitems;i++){
3098 selectedlong[i]+=multiplier*5;
3099 if(selectedlong[i]>1) selectedlong[i]=1;
3101 selectedlong[i]-=multiplier*5;
3102 if(selectedlong[i]<0) selectedlong[i]=0;
3104 offsetx[i]=(startx[i]+endx[i])/2-(mousecoordh/screenwidth*640);
3105 offsety[i]=(starty[i]+endy[i])/2-(480-(mousecoordv/screenheight*480));
3110 if(i>=4&&(mainmenu==1||mainmenu==2)){
3112 offsetx[i]=(startx[i]+endx[i]+movex[i]*transition)/2-(640+190)/2;
3113 offsety[i]=(starty[i]+endy[i]+movey[i]*transition)/2-(336+150)/2;
3119 if(mainmenu==1||mainmenu==2){
3120 glClear(GL_DEPTH_BUFFER_BIT);
3121 glEnable(GL_ALPHA_TEST);
3122 glAlphaFunc(GL_GREATER, 0.001f);
3123 glEnable(GL_TEXTURE_2D);
3124 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3125 glDisable(GL_CULL_FACE);
3126 glDisable(GL_LIGHTING);
3128 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3129 glPushMatrix(); // Store The Projection Matrix
3130 glLoadIdentity(); // Reset The Projection Matrix
3131 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
3132 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3133 glPushMatrix(); // Store The Modelview Matrix
3134 glLoadIdentity(); // Reset The Modelview Matrix
3135 glTranslatef(screenwidth/2,screenheight/2,0);
3137 glScalef((float)screenwidth/2,(float)screenheight/2,1);
3138 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3139 glDisable(GL_BLEND);
3140 glColor4f(0,0,0,1.0);
3141 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
3142 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
3143 glDisable(GL_TEXTURE_2D);
3145 //glScalef(.25,.25,.25);
3148 glVertex3f(-1, -1, 0.0f);
3150 glVertex3f(1, -1, 0.0f);
3152 glVertex3f(1, 1, 0.0f);
3154 glVertex3f(-1, 1, 0.0f);
3158 glColor4f(0.4,0.4,0.4,1.0);
3159 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
3160 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
3161 glEnable(GL_TEXTURE_2D);
3162 glBindTexture( GL_TEXTURE_2D, Mainmenuitems[4]);
3164 //glScalef(.25,.25,.25);
3167 glVertex3f(-1, -1, 0.0f);
3169 glVertex3f(1, -1, 0.0f);
3171 glVertex3f(1, 1, 0.0f);
3173 glVertex3f(-1, 1, 0.0f);
3178 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3181 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3182 glPushMatrix(); // Store The Projection Matrix
3183 glLoadIdentity(); // Reset The Projection Matrix
3184 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3185 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3186 glPushMatrix(); // Store The Modelview Matrix
3187 glLoadIdentity(); // Reset The Modelview Matrix
3189 glDisable(GL_TEXTURE_2D);
3193 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3195 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3199 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3200 glPushMatrix(); // Store The Projection Matrix
3201 glLoadIdentity(); // Reset The Projection Matrix
3202 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3203 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3204 glPushMatrix(); // Store The Modelview Matrix
3205 glLoadIdentity(); // Reset The Modelview Matrix
3206 glEnable(GL_TEXTURE_2D);
3207 for(j=0;j<nummenuitems;j++)
3209 if(j<=3||(mainmenu!=1&&mainmenu!=2))
3211 //glDisable(GL_BLEND);
3212 glEnable(GL_ALPHA_TEST);
3214 //glDisable(GL_ALPHA_TEST);
3215 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3216 if(mainmenu==1||mainmenu==2)
3219 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3220 glBindTexture( GL_TEXTURE_2D, Mainmenuitems[j]);
3221 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
3222 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
3223 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3227 glVertex3f(startx[j]+movex[j]*transition, starty[j]+movey[j]*transition, 0.0f);
3229 glVertex3f(endx[j]+movex[j]*transition, starty[j]+movey[j]*transition, 0.0f);
3231 glVertex3f(endx[j]+movex[j]*transition, endy[j]+movey[j]*transition, 0.0f);
3233 glVertex3f(startx[j]+movex[j]*transition, endy[j]+movey[j]*transition, 0.0f);
3237 //glDisable(GL_ALPHA_TEST);
3238 if(j<4)glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3241 if(1-((float)i)/10-(1-selectedlong[j])>0)
3243 glColor4f(1,1,1,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3244 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3248 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);
3250 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);
3252 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);
3254 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);
3260 if(mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==8||mainmenu==9||mainmenu==10||mainmenu==18)
3262 if(mainmenu!=5||j<6)
3265 if(mainmenu==9&&j>accountactive->getProgress()&&j<numchallengelevels)glColor4f(0.5,0,0,1);
3266 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3268 if(mainmenu!=7||j!=0||!entername)
3269 text.glPrint(startx[j],starty[j],menustring[j],0,1,640,480);
3273 sprintf (string, "_");
3274 text.glPrint(startx[j]+(float)(displayselected)*10,starty[j],string,0,1,640,480);
3276 for(l=0;l<displaychars[0];l++){
3277 sprintf (string, "%c",displaytext[0][l]);
3278 text.glPrint(startx[j]+l*10,starty[j],string,0,1,640,480);
3283 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3286 if(1-((float)i)/15-(1-selectedlong[j])>0)
3288 glColor4f(1,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3289 if(mainmenu==9&&j>accountactive->getProgress()&&j<numchallengelevels)glColor4f(0.5,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3290 if(mainmenu==11&&j>accountactive->getProgress()&&j<numchallengelevels)glColor4f(0.5,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3291 if(mainmenu==3)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4-((/*1*/+((float)i)/70)*strlen(menustring[j]))*3,starty[j]+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
3292 if(mainmenu==4)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4,starty[j]+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
3293 if(mainmenu==5)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4,starty[j]+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
3294 if(mainmenu==6)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4,starty[j]+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
3295 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);
3296 if(mainmenu==8)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4,starty[j]+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
3297 if(mainmenu==9)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4,starty[j]+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
3298 if(mainmenu==10)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4,starty[j]+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
3299 if(mainmenu==18)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4,starty[j]+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
3305 glClear(GL_DEPTH_BUFFER_BIT);
3306 glEnable(GL_ALPHA_TEST);
3307 glAlphaFunc(GL_GREATER, 0.001f);
3308 glEnable(GL_TEXTURE_2D);
3309 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3310 glDisable(GL_CULL_FACE);
3311 glDisable(GL_LIGHTING);
3312 if(j==6)glColor4f(1,1,1,1);
3313 else glColor4f(1,0,0,1);
3315 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3316 glPushMatrix(); // Store The Projection Matrix
3317 glLoadIdentity(); // Reset The Projection Matrix
3318 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3319 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3320 glPushMatrix(); // Store The Modelview Matrix
3321 glLoadIdentity(); // Reset The Modelview Matrix
3324 //Draw world, draw map
3325 glTranslatef(2,-5,0);
3327 if(j>6&&j<nummenuitems-1)
3329 XYZ linestart,lineend,offset;
3336 //float linestartx,lineendx,linestarty,lineendy,offsetx,offsety;
3337 linestart.x=(startx[j]+endx[j])/2;
3338 linestart.y=(starty[j]+endy[j])/2;
3339 if(j>=6+accountactive->getCampaignChoicesMade()){
3340 linestart.x=(startx[6+accountactive->getCampaignChoicesMade()]+endx[6+accountactive->getCampaignChoicesMade()])/2;
3341 linestart.y=(starty[6+accountactive->getCampaignChoicesMade()]+endy[6+accountactive->getCampaignChoicesMade()])/2;
3343 lineend.x=(startx[j+1]+endx[j+1])/2;
3344 lineend.y=(starty[j+1]+endy[j+1])/2;
3345 offset=lineend-linestart;
3348 offset=DoRotation(offset,0,0,90);
3350 glDisable(GL_TEXTURE_2D);
3352 if(j<6+accountactive->getCampaignChoicesMade()){
3353 glColor4f(0.5,0,0,1);
3361 linestart+=fac*4*startsize;
3362 lineend-=fac*4*endsize;
3364 if(!(j>7+accountactive->getCampaignChoicesMade()+campaignchoicenum)){
3365 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3369 glVertex3f(linestart.x-offset.x*startsize, linestart.y-offset.y*startsize, 0.0f);
3371 glVertex3f(linestart.x+offset.x*startsize, linestart.y+offset.y*startsize, 0.0f);
3373 glVertex3f(lineend.x+offset.x*endsize, lineend.y+offset.y*endsize, 0.0f);
3375 glVertex3f(lineend.x-offset.x*endsize, lineend.y-offset.y*endsize, 0.0f);
3379 glEnable(GL_TEXTURE_2D);
3383 if(j==6)glBindTexture( GL_TEXTURE_2D, Mainmenuitems[7]);
3384 else glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
3385 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
3386 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
3387 if(j-7<accountactive->getCampaignChoicesMade())glColor4f(0.5,0,0,1);
3388 if(j-7>=accountactive->getCampaignChoicesMade())glColor4f(1,0,0,1);
3389 if(j==6)glColor4f(1,1,1,1);
3392 itemsize=abs(startx[j]-endx[j])/2;
3394 midpoint.x=(startx[j]+endx[j])/2;
3395 midpoint.y=(starty[j]+endy[j])/2;
3396 if(j>6&&(j-7<accountactive->getCampaignChoicesMade()))itemsize*=.5;
3397 if(!(j-7>accountactive->getCampaignChoicesMade()+campaignchoicenum))
3399 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3403 glVertex3f(midpoint.x-itemsize+movex[j]*transition, midpoint.y-itemsize+movey[j]*transition, 0.0f);
3405 glVertex3f(midpoint.x+itemsize+movex[j]*transition, midpoint.y-itemsize+movey[j]*transition, 0.0f);
3407 glVertex3f(midpoint.x+itemsize+movex[j]*transition, midpoint.y+itemsize+movey[j]*transition, 0.0f);
3409 glVertex3f(midpoint.x-itemsize+movex[j]*transition, midpoint.y+itemsize+movey[j]*transition, 0.0f);
3413 //glDisable(GL_ALPHA_TEST);
3414 if(j<4)glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3417 if(1-((float)i)/10-(1-selectedlong[j])>0)
3419 glColor4f(1,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3420 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3424 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);
3426 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);
3428 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);
3430 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);
3438 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3440 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3442 if(j-7>=accountactive->getCampaignChoicesMade()){
3443 text.glPrintOutlined(0.9,0,0,startx[j]+10,starty[j]-4,menustring[j],0,0.6,640,480);
3444 glDisable(GL_DEPTH_TEST);
3450 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3452 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3455 if(mainmenu==1||mainmenu==2)
3456 if(transition<.1||transition>.9){
3457 glClear(GL_DEPTH_BUFFER_BIT);
3458 glEnable(GL_ALPHA_TEST);
3459 glAlphaFunc(GL_GREATER, 0.001f);
3460 glEnable(GL_TEXTURE_2D);
3461 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3462 glDisable(GL_CULL_FACE);
3463 glDisable(GL_LIGHTING);
3465 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3466 glPushMatrix(); // Store The Projection Matrix
3467 glLoadIdentity(); // Reset The Projection Matrix
3468 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3469 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3470 glPushMatrix(); // Store The Modelview Matrix
3471 glLoadIdentity(); // Reset The Modelview Matrix
3473 glDisable(GL_TEXTURE_2D);
3475 glColor4f(1,0,0,1-(transition*10));
3477 glColor4f(1,0,0,1-((1-transition)*10));
3480 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3484 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3485 glPushMatrix(); // Store The Projection Matrix
3486 glLoadIdentity(); // Reset The Projection Matrix
3487 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
3488 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3489 glPushMatrix(); // Store The Modelview Matrix
3490 glLoadIdentity(); // Reset The Modelview Matrix
3491 glTranslatef(screenwidth/2,screenheight/2,0);
3493 glScalef((float)screenwidth/2,(float)screenheight/2,1);
3494 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3496 glEnable(GL_TEXTURE_2D);
3498 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
3499 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
3501 if(!waiting) { // hide the cursor while waiting for a key
3503 glTranslatef(mousecoordh-screenwidth/2,mousecoordv*-1+screenheight/2,0);
3504 glScalef((float)screenwidth/64,(float)screenwidth/64,1);
3505 glTranslatef(1,-1,0);
3506 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3508 glBindTexture( GL_TEXTURE_2D, cursortexture);
3510 //glScalef(.25,.25,.25);
3513 glVertex3f(-1, -1, 0.0f);
3515 glVertex3f(1, -1, 0.0f);
3517 glVertex3f(1, 1, 0.0f);
3519 glVertex3f(-1, 1, 0.0f);
3525 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3531 //printf("Flash amount: %f, delay %i\n", flashamount, flashdelay);
3532 if(flashamount>1)flashamount=1;
3533 if(flashdelay<=0)flashamount-=multiplier;
3535 if(flashamount<0)flashamount=0;
3536 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3537 glDisable(GL_CULL_FACE);
3538 glDisable(GL_LIGHTING);
3539 glDisable(GL_TEXTURE_2D);
3541 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3542 glPushMatrix(); // Store The Projection Matrix
3543 glLoadIdentity(); // Reset The Projection Matrix
3544 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
3545 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3546 glPushMatrix(); // Store The Modelview Matrix
3547 glLoadIdentity(); // Reset The Modelview Matrix
3548 glScalef(screenwidth,screenheight,1);
3549 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3551 glColor4f(flashr,flashg,flashb,flashamount);
3553 glVertex3f(0, 0, 0.0f);
3554 glVertex3f(256, 0, 0.0f);
3555 glVertex3f(256, 256, 0.0f);
3556 glVertex3f(0, 256, 0.0f);
3558 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3559 glPopMatrix(); // Restore The Old Projection Matrix
3560 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3561 glPopMatrix(); // Restore The Old Projection Matrix
3562 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
3563 glEnable(GL_CULL_FACE);
3564 glDisable(GL_BLEND);
3569 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)||(!gameon&&gamestarted)){
3570 tempmult=multiplier;
3575 if ( side == stereoRight || side == stereoCenter ) {
3576 if(drawmode!=motionblurmode||mainmenu){
3581 //myassert(glGetError() == GL_NO_ERROR);
3582 glDrawBuffer(GL_BACK);
3583 glReadBuffer(GL_BACK);
3588 if(drawtoggle==2)drawtoggle=0;
3590 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)){
3591 multiplier=tempmult;
3593 //Jordan fixed your warning!