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;
84 extern int tutoriallevel;
85 extern float smoketex;
86 extern float tutorialstagetime;
87 extern float tutorialmaxtime;
88 extern int tutorialstage;
89 extern bool againbonus;
90 extern float damagedealt;
91 extern bool invertmouse;
93 extern int numhotspots;
94 extern int winhotspot;
95 extern int killhotspot;
96 extern XYZ hotspot[40];
97 extern int hotspottype[40];
98 extern float hotspotsize[40];
99 extern char hotspottext[40][256];
100 extern int currenthotspot;;
102 extern bool campaign;
103 extern bool winfreeze;
105 extern float menupulse;
107 extern bool gamestart;
109 extern int numdialogues;
110 extern int numdialogueboxes[max_dialogues];
111 extern int dialoguetype[max_dialogues];
112 extern int dialogueboxlocation[max_dialogues][max_dialoguelength];
113 extern float dialogueboxcolor[max_dialogues][max_dialoguelength][3];
114 extern int dialogueboxsound[max_dialogues][max_dialoguelength];
115 extern char dialoguetext[max_dialogues][max_dialoguelength][128];
116 extern char dialoguename[max_dialogues][max_dialoguelength][64];
117 extern XYZ dialoguecamera[max_dialogues][max_dialoguelength];
118 extern XYZ participantlocation[max_dialogues][10];
119 extern int participantfocus[max_dialogues][max_dialoguelength];
120 extern int participantaction[max_dialogues][max_dialoguelength];
121 extern float participantrotation[max_dialogues][10];
122 extern XYZ participantfacing[max_dialogues][max_dialoguelength][10];
123 extern float dialoguecamerarotation[max_dialogues][max_dialoguelength];
124 extern float dialoguecamerarotation2[max_dialogues][max_dialoguelength];
125 extern int indialogue;
126 extern int whichdialogue;
127 extern int directing;
128 extern float dialoguetime;
129 extern int dialoguegonethrough[20];
131 extern bool gamestarted;
133 extern bool showdamagebar;
135 extern int channels[100];
136 extern "C" void PlaySoundEx(int channel, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
138 void Game::flash() { // shouldn't be that way, these should be attributes and Person class should not change rendering.
145 /*********************> DrawGLScene() <*****/
146 int Game::DrawGLScene(StereoSide side)
148 static float texcoordwidth,texcoordheight;
149 static float texviewwidth, texviewheight;
151 static GLubyte color;
152 static float newbrightness;
153 static float changespeed;
154 static XYZ checkpoint;
155 static float tempmult;
157 static char string[256]="";
158 static char string2[256]="";
159 static char string3[256]="";
161 static float lastcheck;
163 lastcheck+=multiplier;
165 if ( stereomode == stereoAnaglyph ) {
167 case stereoLeft: glColorMask( 0.0, 1.0, 1.0, 1.0 ); break;
168 case stereoRight: glColorMask( 1.0, 0.0, 0.0, 1.0 ); break;
171 glColorMask( 1.0, 1.0, 1.0, 1.0 );
173 if ( stereomode == stereoHorizontalInterlaced || stereomode == stereoVerticalInterlaced ) {
174 glStencilFunc(side == stereoLeft ? GL_NOTEQUAL : GL_EQUAL, 0x01, 0x01);
178 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)){
185 numboundaries=mapradius*2;
186 if(numboundaries>360)numboundaries=360;
187 for(i=0;i<numboundaries;i++){
190 boundary[i]=mapcenter+DoRotation(boundary[i]*mapradius,0,i*(360/((float)(numboundaries))),0);
199 olddrawmode=drawmode;
200 if(ismotionblur&&!loading){
201 if((findLengthfast(&player[0].velocity)>200)&&velocityblur&&!cameramode){
202 drawmode=motionblurmode;
203 motionbluramount=200/(findLengthfast(&player[0].velocity));
206 if(player[0].damage-player[0].superpermanentdamage>(player[0].damagetolerance-player[0].superpermanentdamage)*1/2&&damageeffects&&!cameramode){
207 drawmode=doublevisionmode;
214 drawmode=motionblurmode;
216 slomodelay-=multiplier;
217 if(slomodelay<0)slomo=0;
221 if((!changed&&!slomo)||loading){
223 if(ismotionblur&&(/*fps>100||*/alwaysblur)){
224 if(olddrawmode!=realmotionblurmode)change=1;
226 drawmode=realmotionblurmode;
228 else if(olddrawmode==realmotionblurmode)change=2;
232 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted))drawmode=normalmode;
233 if((freeze||winfreeze)&&ismotionblur&&!mainmenu)drawmode=radialzoommode;
235 if(winfreeze||mainmenu)drawmode=normalmode;
238 if(drawmode==glowmode){
243 DSpContext_FadeGamma(NULL,200,&color2);
247 if(drawtoggle!=2)drawtoggle=1-drawtoggle;
251 texviewwidth=kTextureSize;
252 if(texviewwidth>screenwidth)texviewwidth=screenwidth;
253 texviewheight=kTextureSize;
254 if(texviewheight>screenheight)texviewheight=screenheight;
256 texcoordwidth=screenwidth/kTextureSize;
257 texcoordheight=screenheight/kTextureSize;
258 if(texcoordwidth>1)texcoordwidth=1;
259 if(texcoordheight>1)texcoordheight=1;
262 glDrawBuffer(GL_BACK);
263 glReadBuffer(GL_BACK);
265 if(abs(blurness-targetblurness)<multiplier*10||abs(blurness-targetblurness)>2){
266 blurness=targetblurness;
267 targetblurness=(float)(abs(Random()%100))/40;
269 if(blurness<targetblurness)
270 blurness+=multiplier*5;
272 blurness-=multiplier*5;
275 static XYZ terrainlight;
276 static float distance;
277 if(drawmode==normalmode)ReSizeGLScene(90,.1f);
278 if(drawmode!=normalmode)glViewport(0,0,texviewwidth,texviewheight);
279 glDepthFunc(GL_LEQUAL);
281 glAlphaFunc(GL_GREATER, 0.0001f);
282 glEnable(GL_ALPHA_TEST);
283 glClearColor(0.25f, 0.25f, 0.25f, 1.0f);
284 glClear(GL_DEPTH_BUFFER_BIT);
286 glMatrixMode (GL_MODELVIEW);
287 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
290 // Move the camera for the current eye's point of view.
291 // Reverse the movement if we're reversing stereo
292 glTranslatef((stereoseparation/2) * side * (stereoreverse ? -1 : 1), 0, 0);
294 if(!cameramode&&!freeze&&!winfreeze){
295 glRotatef(float(Random()%100)/10*camerashake/*+(woozy*woozy)/10*/,0,0,1);
296 glRotatef(rotation2+sin(woozy/2)*(player[0].damage/player[0].damagetolerance)*5,1,0,0);
297 glRotatef(rotation+sin(woozy)*(player[0].damage/player[0].damagetolerance)*5,0,1,0);
299 if(cameramode||freeze||winfreeze){
300 glRotatef(rotation2,1,0,0);
301 glRotatef(rotation,0,1,0);
304 if(environment==desertenvironment){
305 glRotatef((float)(abs(Random()%100))/3000-1,1,0,0);
306 glRotatef((float)(abs(Random()%100))/3000-1,0,1,0);
308 SetUpLight(&light,0);
310 if(environment==desertenvironment&&detail==2)glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, blurness+.4 );
311 if(environment==desertenvironment){
312 glRotatef((float)(abs(Random()%100))/1000,1,0,0);
313 glRotatef((float)(abs(Random()%100))/1000,0,1,0);
316 glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0);
318 glTranslatef(-viewer.x,-viewer.y,-viewer.z);
319 frustum.GetFrustum();
323 static float size,opacity,rotation;
325 for(k=0;k<numplayers;k++){
326 if(!player[k].skeleton.free&&player[k].playerdetail&&player[k].howactive<typesleeping)
327 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)
328 for(i=0;i<player[k].skeleton.num_joints;i++){
329 if(player[k].skeleton.joints[i].label==leftknee||player[k].skeleton.joints[i].label==rightknee||player[k].skeleton.joints[i].label==groin){
330 point=DoRotation(player[k].skeleton.joints[i].position,0,player[k].rotation,0)*player[k].scale+player[k].coords;
332 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;
333 if(k!=0&&tutoriallevel==1){
334 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;
336 terrain.MakeDecal(shadowdecal,point,size,opacity,rotation);
337 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
338 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
339 if(objects.position[j].y<player[k].coords.y||objects.type[j]==tunneltype||objects.type[j]==weirdtype){
340 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);
343 if(k!=0&&tutoriallevel==1){
344 opacity=.2+.2*sin(smoketex*6+i);
346 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
351 if((player[k].skeleton.free||player[k].howactive>=typesleeping)&&player[k].playerdetail)
352 if(frustum.SphereInFrustum(player[k].coords.x,player[k].coords.y,player[k].coords.z,player[k].scale*5)&&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||player[k].skeleton.joints[i].label==leftelbow||player[k].skeleton.joints[i].label==rightelbow||player[k].skeleton.joints[i].label==neck){
355 if(player[k].skeleton.free)point=player[k].skeleton.joints[i].position*player[k].scale+player[k].coords;
356 else point=DoRotation(player[k].skeleton.joints[i].position,0,player[k].rotation,0)*player[k].scale+player[k].coords;
358 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;
359 if(k!=0&&tutoriallevel==1){
360 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;
362 terrain.MakeDecal(shadowdecal,point,size,opacity*.7,rotation);
363 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
364 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
365 if(objects.position[j].y<player[k].coords.y||objects.type[j]==tunneltype||objects.type[j]==weirdtype){
366 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);
367 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);
370 if(k!=0&&tutoriallevel==1){
371 opacity=.2+.2*sin(smoketex*6+i);
373 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
379 if(!player[k].playerdetail)
380 if(frustum.SphereInFrustum(player[k].coords.x,player[k].coords.y,player[k].coords.z,player[k].scale*5))
382 point=player[k].coords;
384 opacity=.4-(player[k].coords.y-terrain.getHeight(player[k].coords.x,player[k].coords.z))/5;
385 terrain.MakeDecal(shadowdecal,point,size,opacity*.7,rotation);
386 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
387 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
388 point=DoRotation(player[k].coords-objects.position[j],0,-objects.rotation[j],0);
391 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
397 glEnable(GL_TEXTURE_2D);
399 glEnable(GL_DEPTH_TEST);
400 glEnable(GL_CULL_FACE);
402 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
403 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
404 glBindTexture( GL_TEXTURE_2D, terraintexture);
406 glBindTexture( GL_TEXTURE_2D, terraintexture2);
408 //glBindTexture( GL_TEXTURE_2D, terraintexture3);
409 //glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
412 terrain.drawdecals();
415 glEnable(GL_CULL_FACE);
416 glEnable(GL_LIGHTING);
418 glEnable(GL_TEXTURE_2D);
421 glEnable(GL_COLOR_MATERIAL);
436 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
437 glEnable(GL_CULL_FACE);
438 glCullFace(GL_FRONT);
440 for(k=0;k<numplayers;k++){
441 if(k==0||tutoriallevel!=1){
443 glEnable(GL_LIGHTING);
444 terrainlight=terrain.getLighting(player[k].coords.x,player[k].coords.z);
445 distance=findDistancefast(&viewer,&player[k].coords);
446 distance=(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance;
447 glColor4f(terrainlight.x,terrainlight.y,terrainlight.z,distance);
448 if(distance>=1)glDisable(GL_BLEND);
450 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;
452 if(!player[k].occluded==0)i=checkcollide(viewer,checkpoint,player[k].lastoccluded);
453 if(i==-1||player[k].occluded==0)i=checkcollide(viewer,checkpoint);
455 player[k].occluded+=1;
456 player[k].lastoccluded=i;
458 else player[k].occluded=0;
459 if(player[k].occluded<25)player[k].DrawSkeleton();
465 if(!cameramode&&musictype==stream_music2)playerdist=findDistancefastflat(&player[0].coords,&viewer);
466 else playerdist=-100;
469 glEnable(GL_TEXTURE_2D);
474 if(frustum.SphereInFrustum(realhawkcoords.x+hawk.boundingspherecenter.x,realhawkcoords.y+hawk.boundingspherecenter.y,realhawkcoords.z+hawk.boundingspherecenter.z,2)){
475 glAlphaFunc(GL_GREATER, 0.0001f);
477 glDisable(GL_CULL_FACE);
478 glDisable(GL_LIGHTING);
480 glTranslatef(hawkcoords.x,hawkcoords.y,hawkcoords.z);
481 glRotatef(hawkrotation,0,1,0);
482 glTranslatef(25,0,0);
483 distance=findDistancefast(&viewer,&realhawkcoords)*1.2;
484 glColor4f(light.color[0],light.color[1],light.color[2],(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance);
485 if((viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance>1)glColor4f(light.color[0],light.color[1],light.color[2],1);
486 if((viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance>0)
487 hawk.drawdifftex(hawktexture);
491 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
492 glEnable(GL_CULL_FACE);
493 glCullFace(GL_FRONT);
495 for(k=0;k<numplayers;k++){
496 if(!(k==0||tutoriallevel!=1)){
498 glEnable(GL_LIGHTING);
499 terrainlight=terrain.getLighting(player[k].coords.x,player[k].coords.z);
500 distance=findDistancefast(&viewer,&player[k].coords);
501 distance=(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance;
502 glColor4f(terrainlight.x,terrainlight.y,terrainlight.z,distance);
503 if(distance>=1)glDisable(GL_BLEND);
505 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;
507 if(!player[k].occluded==0)i=checkcollide(viewer,checkpoint,player[k].lastoccluded);
508 if(i==-1||player[k].occluded==0)i=checkcollide(viewer,checkpoint);
510 player[k].occluded+=1;
511 player[k].lastoccluded=i;
513 else player[k].occluded=0;
514 if(player[k].occluded<25)player[k].DrawSkeleton();
520 glEnable(GL_TEXTURE_2D);
525 glDisable(GL_COLOR_MATERIAL);
527 glDisable(GL_LIGHTING);
528 glDisable(GL_TEXTURE_2D);
536 glDisable(GL_LIGHTING);
537 glDisable(GL_TEXTURE_2D);
538 glDisable(GL_COLOR_MATERIAL);
541 for(k=0;k<numplayers;k++){
542 if(player[k].numwaypoints>1){
543 glBegin(GL_LINE_LOOP);
544 for(i=0;i<player[k].numwaypoints;i++){
545 glVertex3f(player[k].waypoints[i].x,player[k].waypoints[i].y+.5,player[k].waypoints[i].z);
554 for(k=0;k<numpathpoints;k++){
555 if(numpathpointconnect[k]){
556 for(i=0;i<numpathpointconnect[k];i++){
557 glBegin(GL_LINE_LOOP);
558 glVertex3f(pathpoint[k].x,pathpoint[k].y+.5,pathpoint[k].z);
559 glVertex3f(pathpoint[pathpointconnect[k][i]].x,pathpoint[pathpointconnect[k][i]].y+.5,pathpoint[pathpointconnect[k][i]].z);
567 glVertex3f(pathpoint[pathpointselected].x,pathpoint[pathpointselected].y+.5,pathpoint[pathpointselected].z);
574 glEnable(GL_TEXTURE_2D);
575 glColor4f(.5,.5,.5,1);
577 sprintf (string, " ",(int)(fps));
578 text.glPrint(10,30,string,0,.8,screenwidth,screenheight);
581 if(bonus>0&&bonustime<1&&!winfreeze&&indialogue==-1/*bonustime<4*/){
582 const char *bonus_name;
583 if (bonus < bonus_count)
584 bonus_name = bonus_names[bonus];
586 bonus_name = "Excellent!"; // When does this happen?
588 glColor4f(0,0,0,1-bonustime);
589 text.glPrintOutline(1024/2-10*strlen(bonus_name)-4,768/16-4+768*4/5,bonus_name,1,2.5,1024,768);
590 glColor4f(1,0,0,1-bonustime);
591 text.glPrint(1024/2-10*strlen(bonus_name),768/16+768*4/5,bonus_name,1,2,1024,768);
593 sprintf (string, "%d",(int)bonusvalue);
594 glColor4f(0,0,0,1-bonustime);
595 text.glPrintOutline(1024/2-10*strlen(string)-4,768/16-4-20+768*4/5,string,1,2.5*.8,1024,768);
596 glColor4f(1,0,0,1-bonustime);
597 text.glPrint(1024/2-10*strlen(string),768/16-20+768*4/5,string,1,2*.8,1024,768);
598 glColor4f(.5,.5,.5,1);
601 if(tutoriallevel==1){
602 tutorialopac=tutorialmaxtime-tutorialstagetime;
603 if(tutorialopac>1)tutorialopac=1;
604 if(tutorialopac<0)tutorialopac=0;
606 sprintf (string, " ");
607 sprintf (string2, " ");
608 sprintf (string3, " ");
609 if(tutorialstage==0){
610 sprintf (string, " ");
611 sprintf (string2, " ");
612 sprintf (string3, " ");
614 if(tutorialstage==1){
615 sprintf (string, "Welcome to the Lugaru training level!");
616 sprintf (string2, " ");
617 sprintf (string3, " ");
619 if(tutorialstage==2){
620 sprintf (string, "BASIC MOVEMENT:");
621 sprintf (string2, " ");
622 sprintf (string3, " ");
624 if(tutorialstage==3){
625 sprintf (string, "You can move the mouse to rotate the camera.");
626 sprintf (string2, " ");
627 sprintf (string3, " ");
629 if(tutorialstage==4){
630 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));
631 sprintf (string2, "All movement is relative to the camera.");
632 sprintf (string3, " ");
634 if(tutorialstage==5){
635 sprintf (string, "Please press %s to jump.",Input::keyToChar(jumpkey));
636 sprintf (string2, "You can hold it longer to jump higher.");
637 sprintf (string3, " ");
639 if(tutorialstage==6){
640 sprintf (string, "You can press %s to crouch.",Input::keyToChar(crouchkey));
641 sprintf (string2, "You can jump higher from a crouching position.");
642 sprintf (string3, " ");
644 if(tutorialstage==7){
645 sprintf (string, "While running, you can press %s to roll.",Input::keyToChar(crouchkey));
646 sprintf (string2, " ");
647 sprintf (string3, " ");
649 if(tutorialstage==8){
650 sprintf (string, "While crouching, you can sneak around silently");
651 sprintf (string2, "using the movement keys.");
652 sprintf (string3, " ");
654 if(tutorialstage==9){
655 sprintf (string, "Release the crouch key while sneaking and hold the movement keys");
656 sprintf (string2, "to run animal-style.");
657 sprintf (string3, " ");
659 if(tutorialstage==10){
660 sprintf (string, "ADVANCED MOVEMENT:");
661 sprintf (string2, " ");
662 sprintf (string3, " ");
664 if(tutorialstage==11){
665 sprintf (string, "When you jump at a wall, you can hold %s again",Input::keyToChar(jumpkey));
666 sprintf (string2, "during impact to perform a walljump.");
667 sprintf (string3, "Be sure to use the movement keys to press against the wall");
669 if(tutorialstage==12){
670 sprintf (string, "While in the air, you can press crouch to flip.",Input::keyToChar(jumpkey));
671 sprintf (string2, "Walljumps and flips confuse enemies and give you more control.");
672 sprintf (string3, " ");
674 if(tutorialstage==13){
675 sprintf (string, "BASIC COMBAT:");
676 sprintf (string2, " ");
677 sprintf (string3, " ");
679 if(tutorialstage==14){
680 sprintf (string, "There is now an imaginary enemy");
681 sprintf (string2, "in the middle of the training area.");
682 sprintf (string3, " ");
684 if(tutorialstage==15){
685 if(attackkey==MOUSEBUTTON1)sprintf (string, "Click to attack when you are near an enemy.");
686 else sprintf (string, "Press %s to attack when you are near an enemy.",Input::keyToChar(attackkey));
687 sprintf (string2, "You can punch by standing still near an enemy and attacking.");
688 sprintf (string3, " ");
690 if(tutorialstage==16){
691 sprintf (string, "If you are close, you will perform a weak punch.");
692 sprintf (string2, "The weak punch is excellent for starting attack combinations.");
693 sprintf (string3, " ");
695 if(tutorialstage==17){
696 sprintf (string, "Attacking while running results in a spin kick.");
697 sprintf (string2, "This is one of your most powerful ground attacks.");
698 sprintf (string3, " ");
700 if(tutorialstage==18){
701 sprintf (string, "Sweep the enemy's legs out by attacking while crouched.");
702 sprintf (string2, "This is a very fast attack, and easy to follow up.");
703 sprintf (string3, " ");
705 if(tutorialstage==19){
706 sprintf (string, "When an enemy is on the ground, you can deal some extra");
707 sprintf (string2, "damage by running up and drop-kicking him.");
708 sprintf (string3, "(Try knocking them down with a sweep first)");
710 if(tutorialstage==20){
711 sprintf (string, "Your most powerful individual attack is the rabbit kick.");
712 if(attackkey==MOUSEBUTTON1)sprintf (string2, "Run at the enemy while holding the mouse button, and press");
713 else sprintf (string2, "Run at the enemy while holding %s, and press", Input::keyToChar(attackkey));
714 sprintf (string3, "the jump key (%s) to attack.",Input::keyToChar(jumpkey));
716 if(tutorialstage==21){
717 sprintf (string, "This attack is devastating if timed correctly.");
718 sprintf (string2, "Even if timed incorrectly, it will knock the enemy over.");
719 if(againbonus)sprintf (string3, "Try rabbit-kicking the imaginary enemy again.");
720 else sprintf (string3, "Try rabbit-kicking the imaginary enemy.");
722 if(tutorialstage==22){
723 sprintf (string, "If you sneak behind an enemy unnoticed, you can kill");
724 sprintf (string2, "him instantly. Move close behind this enemy");
725 sprintf (string3, "and attack.");
727 if(tutorialstage==23){
728 sprintf (string, "Another important attack is the wall kick. When an enemy");
729 sprintf (string2, "is near a wall, perform a walljump nearby and hold");
730 sprintf (string3, "the attack key during impact with the wall.");
732 if(tutorialstage==24){
733 sprintf (string, "You can tackle enemies by running at them animal-style");
734 if(attackkey==MOUSEBUTTON1)sprintf (string2, "and pressing jump (%s) or attack(mouse button).",Input::keyToChar(jumpkey));
735 else sprintf (string2, "and pressing jump (%s) or attack(%s).",Input::keyToChar(jumpkey),Input::keyToChar(attackkey));
736 sprintf (string3, "This is especially useful when they are running away.");
738 if(tutorialstage==25){
739 sprintf (string, "Dodge by pressing back and attack. Dodging is essential");
740 sprintf (string2, "against enemies with swords or other long weapons.");
741 sprintf (string3, " ");
743 if(tutorialstage==26){
744 sprintf (string, "REVERSALS AND COUNTER-REVERSALS");
745 sprintf (string2, " ");
746 sprintf (string3, " ");
748 if(tutorialstage==27){
749 sprintf (string, "The enemy can now reverse your attacks.");
750 sprintf (string2, " ");
751 sprintf (string3, " ");
753 if(tutorialstage==28){
754 sprintf (string, "If you attack, you will notice that the enemy now sometimes");
755 sprintf (string2, "catches your attack and uses it against you. Hold");
756 sprintf (string3, "crouch (%s) after attacking to escape from reversals.",Input::keyToChar(crouchkey));
758 if(tutorialstage==29){
759 sprintf (string, "Try escaping from two more reversals in a row.");
760 sprintf (string2, " ");
761 sprintf (string3, " ");
763 if(tutorialstage==30){
764 sprintf (string, "Good!");
765 sprintf (string2, " ");
766 sprintf (string3, " ");
768 if(tutorialstage==31){
769 sprintf (string, "To reverse an attack, you must tap crouch (%s) during the",Input::keyToChar(crouchkey));
770 sprintf (string2, "enemy's attack. You must also be close to the enemy;");
771 sprintf (string3, "this is especially important against armed opponents.");
773 if(tutorialstage==32){
774 sprintf (string, "The enemy can attack in %d seconds.", (int)(tutorialmaxtime-tutorialstagetime));
775 sprintf (string2, "This imaginary opponents attacks will be highlighted");
776 sprintf (string3, "to make this easier.");
778 if(tutorialstage==33){
779 sprintf (string, "Reverse three enemy attacks!");
780 sprintf (string2, " ");
781 sprintf (string3, " ");
783 if(tutorialstage==34){
784 sprintf (string, "Reverse two more enemy attacks!");
785 sprintf (string2, " ");
786 sprintf (string3, " ");
788 if(tutorialstage==35){
789 sprintf (string, "Reverse one more enemy attack!");
790 sprintf (string2, " ");
791 sprintf (string3, " ");
793 if(tutorialstage==36){
794 sprintf (string, "Excellent!");
795 sprintf (string2, " ");
796 sprintf (string3, " ");
798 if(tutorialstage==37){
799 sprintf (string, "Now spar with the enemy for %d more seconds.", (int)(tutorialmaxtime-tutorialstagetime));
800 sprintf (string2, "Damage dealt: %d",(int)damagedealt);
801 sprintf (string3, "Damage taken: %d.",(int)damagetaken);
803 if(tutorialstage==38){
804 sprintf (string, "WEAPONS:");
805 sprintf (string2, " ");
806 sprintf (string3, " ");
808 if(tutorialstage==39){
809 sprintf (string, "There is now an imaginary knife");
810 sprintf (string2, "in the center of the training area.");
811 sprintf (string3, " ");
813 if(tutorialstage==40){
814 sprintf (string, "Stand, roll or handspring over the knife");
815 sprintf (string2, "while pressing %s to pick it up.",Input::keyToChar(throwkey));
816 sprintf (string3, "You can crouch and press the same key to drop it again.");
818 if(tutorialstage==41){
819 sprintf (string, "You can equip and unequip weapons using the %s key.",Input::keyToChar(drawkey));
820 sprintf (string2, "Sometimes it is best to keep them unequipped to");
821 sprintf (string3, "prevent enemies from taking them. ");
823 if(tutorialstage==42){
824 sprintf (string, "The knife is the smallest weapon and the least encumbering.");
825 sprintf (string2, "You can equip or unequip it while standing, crouching,");
826 sprintf (string3, "running or flipping.");
828 if(tutorialstage==43){
829 sprintf (string, "You perform weapon attacks the same way as unarmed attacks,");
830 sprintf (string2, "but sharp weapons cause permanent damage, instead of the");
831 sprintf (string3, "temporary trauma from blunt weapons, fists and feet.");
833 if(tutorialstage==44){
834 sprintf (string, "The enemy now has your knife!");
835 sprintf (string2, "Please reverse two of his knife attacks.");
836 sprintf (string3, " ");
838 if(tutorialstage==45){
839 sprintf (string, "Please reverse one more of his knife attacks.");
840 sprintf (string2, " ");
841 sprintf (string3, " ");
843 if(tutorialstage==46){
844 sprintf (string, "Now he has a sword!");
845 sprintf (string2, "The sword has longer reach than your arms, so you");
846 sprintf (string3, "must move close to reverse the sword slash.");
848 if(tutorialstage==47){
849 sprintf (string, "Long weapons like the sword and staff are also useful for defense;");
850 sprintf (string2, "you can parry enemy weapon attacks by pressing the attack key");
851 sprintf (string3, "at the right time. Please try parrying the enemy's attacks!");
853 if(tutorialstage==48){
854 sprintf (string, "The staff is like the sword, but has two main attacks.");
855 sprintf (string2, "The standing smash is fast and effective, and the running");
856 sprintf (string3, "spin smash is slower and more powerful.");
858 if(tutorialstage==49){
859 sprintf (string, "When facing an enemy, you can throw the knife with %s.",Input::keyToChar(throwkey));
860 sprintf (string2, "It is possible to throw the knife while flipping,");
861 sprintf (string3, "but it is very inaccurate.");
863 if(tutorialstage==50){
864 sprintf (string, "You now know everything you can learn from training.");
865 sprintf (string2, "Everything else you must learn from experience!");
866 sprintf (string3, " ");
868 if(tutorialstage==51){
869 sprintf (string, "Walk out of the training area to return to the main menu.");
870 sprintf (string2, " ");
871 sprintf (string3, " ");
874 glColor4f(0,0,0,tutorialopac);
875 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);
876 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);
877 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);
878 glColor4f(1,1,1,tutorialopac);
879 text.glPrint(screenwidth/2-7.6*strlen(string)*screenwidth/1024,screenheight/16+screenheight*4/5,string,1,1.5*screenwidth/1024,screenwidth,screenheight);
880 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);
881 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);
883 sprintf (string, "Press 'tab' to skip to the next item.",Input::keyToChar(jumpkey));
884 sprintf (string2, "Press escape at any time to");
885 sprintf (string3, "pause or exit the tutorial.");
888 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);
889 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);
890 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);
891 glColor4f(0.5,0.5,0.5,1);
892 text.glPrint(screenwidth/2-7.6*strlen(string)*screenwidth/1024*.8,0+screenheight*1/10,string,1,1.5*screenwidth/1024*.8,screenwidth,screenheight);
893 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);
894 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);
898 if(numhotspots&&(bonustime>=1||bonus<=0||bonustime<0)&&!tutoriallevel){
900 float closestdist=-1;
902 closest=currenthotspot;
903 for(i=0;i<numhotspots;i++){
904 distance=findDistancefast(&player[0].coords,&hotspot[i]);
905 if(closestdist==-1||distance<closestdist){
906 if(findDistancefast(&player[0].coords,&hotspot[i])<hotspotsize[i]&&((hotspottype[i]<=10&&hotspottype[i]>=0)||(hotspottype[i]<=40&&hotspottype[i]>=20))){
907 closestdist=distance;
913 currenthotspot=closest;
914 if(currenthotspot!=-1){
915 if(hotspottype[closest]<=10){
916 if(findDistancefast(&player[0].coords,&hotspot[closest])<hotspotsize[closest])
919 tutorialopac=tutorialmaxtime-tutorialstagetime;
920 if(tutorialopac>1)tutorialopac=1;
921 if(tutorialopac<0)tutorialopac=0;
923 sprintf (string, "%s", hotspottext[closest]);
930 if(string[i]=='\n'||string[i]>'z'||string[i]<' '||string[i]=='\0'){
931 glColor4f(0,0,0,tutorialopac);
932 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);
933 glColor4f(1,1,1,tutorialopac);
934 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);
937 if(string[i]=='\0')done=1;
943 else if (hotspottype[closest]>=20&&dialoguegonethrough[hotspottype[closest]-20]==0){
944 whichdialogue=hotspottype[closest]-20;
945 for(j=0;j<numdialogueboxes[whichdialogue];j++){
946 player[participantfocus[whichdialogue][j]].coords=participantlocation[whichdialogue][participantfocus[whichdialogue][j]];
947 player[participantfocus[whichdialogue][j]].rotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
948 player[participantfocus[whichdialogue][j]].targetrotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
949 player[participantfocus[whichdialogue][j]].velocity=0;
950 player[participantfocus[whichdialogue][j]].targetanimation=player[participantfocus[whichdialogue][j]].getIdle();
951 player[participantfocus[whichdialogue][j]].targetframe=0;
955 dialoguegonethrough[whichdialogue]++;
956 if(dialogueboxsound[whichdialogue][indialogue]!=0){
957 static float gLoc[3];
959 gLoc[0]=player[participantfocus[whichdialogue][indialogue]].coords.x;
960 gLoc[1]=player[participantfocus[whichdialogue][indialogue]].coords.y;
961 gLoc[2]=player[participantfocus[whichdialogue][indialogue]].coords.z;
966 if(dialogueboxsound[whichdialogue][indialogue]==1)whichsoundplay=rabbitchitter;
967 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
968 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
969 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
970 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
971 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
972 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
973 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
974 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
975 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
976 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
977 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
978 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
979 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
980 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
981 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
982 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
983 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
984 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
985 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
986 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, true);
987 OPENAL_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
988 OPENAL_SetVolume(channels[whichsoundplay], 256);
989 OPENAL_SetPaused(channels[whichsoundplay], false);
995 if(indialogue!=-1&&!mainmenu){
996 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
997 glDisable(GL_CULL_FACE);
998 glDisable(GL_LIGHTING);
999 glDisable(GL_TEXTURE_2D);
1001 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1002 glPushMatrix(); // Store The Projection Matrix
1003 glLoadIdentity(); // Reset The Projection Matrix
1004 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1005 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1006 glPushMatrix(); // Store The Modelview Matrix
1007 glLoadIdentity(); // Reset The Modelview Matrix
1008 if(dialogueboxlocation[whichdialogue][indialogue]==1)glTranslatef(0,screenheight*3/4,0);
1009 glScalef(screenwidth,screenheight/4,1);
1010 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1013 glColor4f(dialogueboxcolor[whichdialogue][indialogue][0],dialogueboxcolor[whichdialogue][indialogue][1],dialogueboxcolor[whichdialogue][indialogue][2],0.7);
1015 glVertex3f(0, 0, 0.0f);
1016 glVertex3f(1, 0, 0.0f);
1017 glVertex3f(1, 1, 0.0f);
1018 glVertex3f(0, 1, 0.0f);
1020 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1021 glPopMatrix(); // Restore The Old Projection Matrix
1022 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1023 glPopMatrix(); // Restore The Old Projection Matrix
1024 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1025 glEnable(GL_CULL_FACE);
1026 glDisable(GL_BLEND);
1028 glEnable(GL_TEXTURE_2D);
1035 startx=screenwidth*1/5;
1036 if(dialogueboxlocation[whichdialogue][indialogue]==1)starty=screenheight/16+screenheight*4/5;
1037 if(dialogueboxlocation[whichdialogue][indialogue]==2)starty=screenheight*1/5-screenheight/16;
1046 for(i=0;i<(int)strlen(dialoguename[whichdialogue][indialogue]);i++){
1047 tempname[tempnum]=dialoguename[whichdialogue][indialogue][i];
1049 if(dialoguename[whichdialogue][indialogue][i]=='#'||dialoguename[whichdialogue][indialogue][i]=='\0')goodchar=0;
1053 tempname[tempnum]='\0';
1056 sprintf (string, "%s: ", tempname);
1058 if(dialogueboxcolor[whichdialogue][indialogue][0]+dialogueboxcolor[whichdialogue][indialogue][1]+dialogueboxcolor[whichdialogue][indialogue][2]<1.5){
1059 glColor4f(0,0,0,tutorialopac);
1060 text.glPrintOutline(startx-2*7.6*strlen(string)*screenwidth/1024-4,starty-4,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight);
1061 glColor4f(0.7,0.7,0.7,tutorialopac);
1062 text.glPrint(startx-2*7.6*strlen(string)*screenwidth/1024,starty,string,1,1.5*screenwidth/1024,screenwidth,screenheight);
1066 glColor4f(0,0,0,tutorialopac);
1067 text.glPrintOutline(startx-2*7.6*strlen(string)*screenwidth/1024-4,starty-4,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight);
1071 for(i=0;i<(int)strlen(dialoguetext[whichdialogue][indialogue])+1;i++){
1072 tempname[tempnum]=dialoguetext[whichdialogue][indialogue][i];
1073 if(dialoguetext[whichdialogue][indialogue][i]!='#')tempnum++;
1076 sprintf (string, "%s", tempname);
1083 if(string[i]=='\n'||string[i]>'z'||string[i]<' '||string[i]=='\0'){
1084 if(dialogueboxcolor[whichdialogue][indialogue][0]+dialogueboxcolor[whichdialogue][indialogue][1]+dialogueboxcolor[whichdialogue][indialogue][2]<1.5){
1085 glColor4f(0,0,0,tutorialopac);
1086 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);
1087 glColor4f(1,1,1,tutorialopac);
1088 text.glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/,starty-20*screenwidth/1024*line,string,1,1.5*screenwidth/1024,screenwidth,screenheight,lastline,i);
1092 glColor4f(0,0,0,tutorialopac);
1093 text.glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/,starty-20*screenwidth/1024*line,string,1,1.5*screenwidth/1024,screenwidth,screenheight,lastline,i);
1097 if(string[i]=='\0')done=1;
1104 if(!tutoriallevel&&!winfreeze&&indialogue==-1&&!mainmenu){
1107 sprintf (string, "Score: %d", (int)accountactive->getCampaignScore());
1109 sprintf (string, "Score: %d", (int)accountactive->getCampaignScore()+(int)bonustotal);
1111 if(!campaign)sprintf (string, "Score: %d", (int)bonustotal);
1113 text.glPrintOutline(1024/40-4,768/16-4+768*14/16,string,1,1.5*1.25,1024,768);
1115 text.glPrint(1024/40,768/16+768*14/16,string,1,1.5,1024,768);
1117 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1118 glDisable(GL_CULL_FACE);
1119 glDisable(GL_LIGHTING);
1120 glDisable(GL_TEXTURE_2D);
1122 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1123 glPushMatrix(); // Store The Projection Matrix
1124 glLoadIdentity(); // Reset The Projection Matrix
1125 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1126 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1127 glPushMatrix(); // Store The Modelview Matrix
1128 glLoadIdentity(); // Reset The Modelview Matrix
1129 glTranslatef(15,screenheight*17.5/20,0);
1130 glScalef(screenwidth/3+20,screenheight/20,1);
1131 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1133 glColor4f(0.0,0.4,0.0,0.7);
1134 float bar=((float)player[0].damage)/player[0].damagetolerance;
1136 glVertex3f((bar<1?bar:1),0,0.0f);
1137 glVertex3f(1,0,0.0f);
1138 glVertex3f(1,1,0.0f);
1139 glVertex3f((bar<1?bar:1),1,0.0f);
1141 glColor4f(0.1,0.0,0.0,1);
1142 bar = ((float)player[0].bloodloss)/player[0].damagetolerance;
1144 glVertex3f(0,0,0.0f);
1145 glVertex3f((bar<1?bar:1),0,0.0f);
1146 glVertex3f((bar<1?bar:1),1,0.0f);
1147 glVertex3f(0,1,0.0f);
1149 glColor4f(0.4,0.0,0.0,0.7);
1150 bar = ((float)player[0].damage)/player[0].damagetolerance;
1152 glVertex3f(0,0,0.0f);
1153 glVertex3f((bar<1?bar:1),0,0.0f);
1154 glVertex3f((bar<1?bar:1),1,0.0f);
1155 glVertex3f(0,1,0.0f);
1157 glColor4f(0.4,0.0,0.0,0.7);
1158 bar = ((float)player[0].permanentdamage)/player[0].damagetolerance;
1160 glVertex3f(0,0,0.0f);
1161 glVertex3f((bar<1?bar:1),0,0.0f);
1162 glVertex3f((bar<1?bar:1),1,0.0f);
1163 glVertex3f(0,1,0.0f);
1165 glColor4f(0.4,0.0,0.0,0.7);
1166 bar = ((float)player[0].superpermanentdamage)/player[0].damagetolerance;
1168 glVertex3f(0,0,0.0f);
1169 glVertex3f((bar<1?bar:1),0,0.0f);
1170 glVertex3f((bar<1?bar:1),1,0.0f);
1171 glVertex3f(0,1,0.0f);
1173 glColor4f(0.0,0.0,0.0,0.7);
1175 glBegin(GL_LINE_STRIP);
1176 glVertex3f(0,0,0.0f);
1177 glVertex3f(1,0,0.0f);
1178 glVertex3f(1,1,0.0f);
1179 glVertex3f(0,1,0.0f);
1180 glVertex3f(0,0,0.0f);
1183 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1184 glPopMatrix(); // Restore The Old Projection Matrix
1185 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1186 glPopMatrix(); // Restore The Old Projection Matrix
1187 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1188 glEnable(GL_CULL_FACE);
1189 glDisable(GL_BLEND);
1191 glEnable(GL_TEXTURE_2D);
1193 // writing the numbers :
1194 sprintf (string, "Damages : %d/%d (%d)",(int)(player[0].damage),(int)(player[0].damagetolerance),(int)(player[0].bloodloss));
1196 text.glPrintOutline(1024/40-4,768/16-4+768*14/16-40,string,1,1.5*1.25,1024,768);
1198 text.glPrint(1024/40,768/16+768*14/16-40,string,1,1.5,1024,768);
1202 glColor4f(.5,.5,.5,1);
1205 if((texttoggle||editorenabled)&&debugmode&&!mainmenu){
1206 sprintf (string, "The framespersecond is %d.",(int)(fps));
1207 text.glPrint(10,30,string,0,.8,1024,768);
1209 sprintf (string, "Name: %s", registrationname);
1210 text.glPrint(10,260,string,0,.8,1024,768);
1214 sprintf (string, "Map editor enabled.");
1216 sprintf (string, "Map editor disabled.");
1217 text.glPrint(10,60,string,0,.8,1024,768);
1219 sprintf (string, "Object size: %f",editorsize);
1220 text.glPrint(10,75,string,0,.8,1024,768);
1221 if(editorrotation>=0)sprintf (string, "Object rotation: %f",editorrotation);
1222 else sprintf (string, "Object rotation: Random");
1223 text.glPrint(10,90,string,0,.8,1024,768);
1224 if(editorrotation2>=0)sprintf (string, "Object rotation2: %f",editorrotation2);
1225 else sprintf (string, "Object rotation2: Random");
1226 text.glPrint(10,105,string,0,.8,1024,768);
1227 sprintf (string, "Object type: %d",editortype);
1228 text.glPrint(10,120,string,0,.8,1024,768);
1229 switch(editortype) {
1231 sprintf (string, "(box)");
1234 sprintf (string, "(tree)");
1237 sprintf (string, "(wall)");
1240 sprintf (string, "(weird)");
1243 sprintf (string, "(spike)");
1246 sprintf (string, "(rock)");
1249 sprintf (string, "(bush)");
1252 sprintf (string, "(tunnel)");
1255 sprintf (string, "(chimney)");
1258 sprintf (string, "(platform)");
1261 sprintf (string, "(cool)");
1264 sprintf (string, "(fire)");
1267 text.glPrint(130,120,string,0,.8,1024,768);
1269 sprintf (string, "Numplayers: %d",numplayers);
1270 text.glPrint(10,155,string,0,.8,1024,768);
1271 sprintf (string, "Player %d: numwaypoints: %d",numplayers,player[numplayers-1].numwaypoints);
1272 text.glPrint(10,140,string,0,.8,1024,768);
1274 sprintf (string, "Difficulty: %d",difficulty);
1275 text.glPrint(10,240,string,0,.8,1024,768);
1280 if(drawmode==glowmode){
1281 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1282 glDisable(GL_CULL_FACE);
1283 glDisable(GL_LIGHTING);
1284 glDisable(GL_TEXTURE_2D);
1286 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1287 glPushMatrix(); // Store The Projection Matrix
1288 glLoadIdentity(); // Reset The Projection Matrix
1289 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1290 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1291 glPushMatrix(); // Store The Modelview Matrix
1292 glLoadIdentity(); // Reset The Modelview Matrix
1293 glScalef(screenwidth,screenheight,1);
1294 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1296 glColor4f(0,0,0,.5);
1298 glVertex3f(0, 0, 0.0f);
1299 glVertex3f(256, 0, 0.0f);
1300 glVertex3f(256, 256, 0.0f);
1301 glVertex3f(0, 256, 0.0f);
1303 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1304 glPopMatrix(); // Restore The Old Projection Matrix
1305 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1306 glPopMatrix(); // Restore The Old Projection Matrix
1307 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1308 glEnable(GL_CULL_FACE);
1309 glDisable(GL_BLEND);
1313 if((((blackout&&damageeffects)||(player[0].bloodloss>0&&damageeffects&&player[0].blooddimamount>0)||player[0].dead)&&!cameramode)||console){
1314 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1315 glDisable(GL_CULL_FACE);
1316 glDisable(GL_LIGHTING);
1317 glDisable(GL_TEXTURE_2D);
1319 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1320 glPushMatrix(); // Store The Projection Matrix
1321 glLoadIdentity(); // Reset The Projection Matrix
1322 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1323 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1324 glPushMatrix(); // Store The Modelview Matrix
1325 glLoadIdentity(); // Reset The Modelview Matrix
1326 glScalef(screenwidth,screenheight,1);
1327 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1329 if(player[0].dead)blackout+=multiplier*3;
1330 if(player[0].dead==1)blackout=.4f;
1331 if(player[0].dead==2&&blackout>.6)blackout=.6;
1332 glColor4f(0,0,0,blackout);
1333 if(!player[0].dead){
1334 if((player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5))*.3<.3){
1335 glColor4f(0,0,0,player[0].blooddimamount*player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5)*.3);
1336 blackout=player[0].blooddimamount*player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5)*.3;
1339 glColor4f(0,0,0,player[0].blooddimamount*.3);
1340 blackout=player[0].blooddimamount*.3;
1343 if(console)glColor4f(.7,0,0,.2);
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(flashamount>0&&damageeffects){
1361 if(flashamount>1)flashamount=1;
1362 if(flashdelay<=0)flashamount-=multiplier;
1364 if(flashamount<0)flashamount=0;
1365 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1366 glDisable(GL_CULL_FACE);
1367 glDisable(GL_LIGHTING);
1369 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1370 glPushMatrix(); // Store The Projection Matrix
1371 glLoadIdentity(); // Reset The Projection Matrix
1372 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1373 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1374 glPushMatrix(); // Store The Modelview Matrix
1375 glLoadIdentity(); // Reset The Modelview Matrix
1376 glScalef(screenwidth,screenheight,1);
1377 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1379 glColor4f(flashr,flashg,flashb,flashamount);
1381 glVertex3f(0, 0, 0.0f);
1382 glVertex3f(256, 0, 0.0f);
1383 glVertex3f(256, 256, 0.0f);
1384 glVertex3f(0, 256, 0.0f);
1386 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1387 glPopMatrix(); // Restore The Old Projection Matrix
1388 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1389 glPopMatrix(); // Restore The Old Projection Matrix
1390 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1391 glEnable(GL_CULL_FACE);
1392 glDisable(GL_BLEND);
1398 glEnable(GL_TEXTURE_2D);
1401 sprintf (string, " ]");
1402 text.glPrint(10,30+screenheight-330,string,0,1,screenwidth,screenheight);
1404 sprintf (string, "_");
1405 text.glPrint(30+(float)(displayselected)*10,30+(screenheight-330),string,0,1,screenwidth,screenheight);
1409 if((i!=0||chatting)&&displaytime[i]<4)
1410 for(j=0;j<displaychars[i];j++){
1411 glColor4f(1,1,1,4-displaytime[i]);
1412 if(j<displaychars[i]){
1413 sprintf (string, "%c",displaytext[i][j]);
1414 text.glPrint(30+j*10,30+i*20+(screenheight-330),string,0,1,screenwidth,screenheight);
1420 if(minimap&&indialogue==-1){
1421 float mapviewdist = 20000;
1423 glDisable(GL_DEPTH_TEST);
1424 glColor3f (1.0, 1.0, 1.0); // no coloring
1426 glEnable(GL_TEXTURE_2D);
1427 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1428 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1429 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1430 glDisable(GL_CULL_FACE);
1431 glDisable(GL_LIGHTING);
1433 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1434 glPushMatrix(); // Store The Projection Matrix
1435 glLoadIdentity(); // Reset The Projection Matrix
1436 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1437 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1438 glPushMatrix(); // Store The Modelview Matrix
1439 glLoadIdentity(); // Reset The Modelview Matrix
1440 glScalef((float)screenwidth/2,(float)screenwidth/2,1);
1441 glTranslatef(1.75,.25,0);
1442 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1450 int numliveplayers=0;
1452 for(i=0;i<numplayers;i++){
1453 if(!player[i].dead) numliveplayers++;
1458 for(i=0;i<objects.numobjects;i++){
1459 if(objects.type[i]==treetrunktype||objects.type[i]==boxtype){
1460 center+=objects.position[i];
1464 for(i=0;i<numplayers;i++){
1465 if(!player[i].dead)center+=player[i].coords;
1467 center/=numadd+numliveplayers;
1469 center=player[0].coords;
1471 float maxdistance=0;
1474 for(i=0;i<objects.numobjects;i++){
1475 tempdist=findDistancefast(¢er,&objects.position[i]);
1476 if(tempdist>maxdistance){
1478 maxdistance=tempdist;
1481 for(i=0;i<numplayers;i++){
1482 if(!player[i].dead){
1483 tempdist=findDistancefast(¢er,&player[i].coords);
1484 if(tempdist>maxdistance){
1486 maxdistance=tempdist;
1490 radius=fast_sqrt(maxdistance);
1494 glScalef(.25/radius*256*terrain.scale*.4,.25/radius*256*terrain.scale*.4,1);
1496 glScalef(1/(1/radius*256*terrain.scale*.4),1/(1/radius*256*terrain.scale*.4),1);
1498 glRotatef(player[0].lookrotation*-1+180,0,0,1);
1499 glTranslatef(-(center.x/terrain.scale/256*-2+1),(center.z/terrain.scale/256*-2+1),0);
1500 for(i=0;i<objects.numobjects;i++){
1501 if(objects.type[i]==treetrunktype){
1502 distcheck=findDistancefast(&player[0].coords,&objects.position[i]);
1503 if(distcheck<mapviewdist){
1504 glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
1505 glColor4f(0,.3,0,opac*(1-distcheck/mapviewdist));
1507 glTranslatef(objects.position[i].x/terrain.scale/256*-2+1,objects.position[i].z/terrain.scale/256*2-1,0);
1508 glRotatef(objects.rotation[i],0,0,1);
1509 glScalef(.003,.003,.003);
1512 glVertex3f(-1, -1, 0.0f);
1514 glVertex3f(1, -1, 0.0f);
1516 glVertex3f(1, 1, 0.0f);
1518 glVertex3f(-1, 1, 0.0f);
1523 if(objects.type[i]==boxtype){
1524 distcheck=findDistancefast(&player[0].coords,&objects.position[i]);
1525 if(distcheck<mapviewdist){
1526 glBindTexture( GL_TEXTURE_2D, Mapboxtexture);
1527 glColor4f(.4,.4,.4,opac*(1-distcheck/mapviewdist));
1529 glTranslatef(objects.position[i].x/terrain.scale/256*-2+1,objects.position[i].z/terrain.scale/256*2-1,0);
1530 glRotatef(objects.rotation[i],0,0,1);
1531 glScalef(.01*objects.scale[i],.01*objects.scale[i],.01*objects.scale[i]);
1534 glVertex3f(-1, -1, 0.0f);
1536 glVertex3f(1, -1, 0.0f);
1538 glVertex3f(1, 1, 0.0f);
1540 glVertex3f(-1, 1, 0.0f);
1547 glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
1548 for(i=0;i<numboundaries;i++){
1549 glColor4f(0,0,0,opac/3);
1551 glTranslatef(boundary[i].x/terrain.scale/256*-2+1,boundary[i].z/terrain.scale/256*2-1,0);
1552 glScalef(.002,.002,.002);
1555 glVertex3f(-1, -1, 0.0f);
1557 glVertex3f(1, -1, 0.0f);
1559 glVertex3f(1, 1, 0.0f);
1561 glVertex3f(-1, 1, 0.0f);
1566 for(i=0;i<numplayers;i++){
1567 distcheck=findDistancefast(&player[0].coords,&player[i].coords);
1568 if(distcheck<mapviewdist){
1570 glBindTexture( GL_TEXTURE_2D, Maparrowtexture);
1571 if(i==0)glColor4f(1,1,1,opac);
1572 else if(player[i].dead==2||player[i].howactive>typesleeping)glColor4f(0,0,0,opac*(1-distcheck/mapviewdist));
1573 else if(player[i].dead)glColor4f(.3,.3,.3,opac*(1-distcheck/mapviewdist));
1574 else if(player[i].aitype==attacktypecutoff)glColor4f(1,0,0,opac*(1-distcheck/mapviewdist));
1575 else if(player[i].aitype==passivetype)glColor4f(0,1,0,opac*(1-distcheck/mapviewdist));
1576 else glColor4f(1,1,0,1);
1577 glTranslatef(player[i].coords.x/terrain.scale/256*-2+1,player[i].coords.z/terrain.scale/256*2-1,0);
1578 glRotatef(player[i].rotation+180,0,0,1);
1579 glScalef(.005,.005,.005);
1582 glVertex3f(-1, -1, 0.0f);
1584 glVertex3f(1, -1, 0.0f);
1586 glVertex3f(1, 1, 0.0f);
1588 glVertex3f(-1, 1, 0.0f);
1594 glDisable(GL_TEXTURE_2D);
1595 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1596 glPopMatrix(); // Restore The Old Projection Matrix
1597 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1598 glPopMatrix(); // Restore The Old Projection Matrix
1599 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1600 glEnable(GL_CULL_FACE);
1601 glDisable(GL_BLEND);
1605 if(loading&&!stealthloading&&(!campaign||player[0].dead)){
1606 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1607 glDisable(GL_CULL_FACE);
1608 glDisable(GL_LIGHTING);
1609 glDisable(GL_TEXTURE_2D);
1611 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1612 glPushMatrix(); // Store The Projection Matrix
1613 glLoadIdentity(); // Reset The Projection Matrix
1614 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1615 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1616 glPushMatrix(); // Store The Modelview Matrix
1617 glLoadIdentity(); // Reset The Modelview Matrix
1618 glScalef(screenwidth,screenheight,1);
1619 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1621 glColor4f(0,0,0,.7);
1623 glVertex3f(0, 0, 0.0f);
1624 glVertex3f(256, 0, 0.0f);
1625 glVertex3f(256, 256, 0.0f);
1626 glVertex3f(0, 256, 0.0f);
1628 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1629 glPopMatrix(); // Restore The Old Projection Matrix
1630 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1631 glPopMatrix(); // Restore The Old Projection Matrix
1632 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1633 glEnable(GL_CULL_FACE);
1634 glDisable(GL_BLEND);
1638 glDisable(GL_DEPTH_TEST);
1639 glColor3f (1.0, 1.0, 1.0); // no coloring
1641 glEnable(GL_TEXTURE_2D);
1646 glEnable(GL_TEXTURE_2D);
1648 sprintf (string, "Loading...");
1649 text.glPrint(1024/2-90,768/2,string,1,2,1024,768);
1652 //if(ismotionblur)drawmode=motionblurmode;
1653 drawmode=normalmode;
1656 if(winfreeze&&!campaign){
1657 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1658 glDisable(GL_CULL_FACE);
1659 glDisable(GL_LIGHTING);
1660 glDisable(GL_TEXTURE_2D);
1662 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1663 glPushMatrix(); // Store The Projection Matrix
1664 glLoadIdentity(); // Reset The Projection Matrix
1665 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1666 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1667 glPushMatrix(); // Store The Modelview Matrix
1668 glLoadIdentity(); // Reset The Modelview Matrix
1669 glScalef(screenwidth,screenheight,1);
1670 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1672 glColor4f(0,0,0,.4);
1674 glVertex3f(0, 0, 0.0f);
1675 glVertex3f(256, 0, 0.0f);
1676 glVertex3f(256, 256, 0.0f);
1677 glVertex3f(0, 256, 0.0f);
1679 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1680 glPopMatrix(); // Restore The Old Projection Matrix
1681 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1682 glPopMatrix(); // Restore The Old Projection Matrix
1683 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1684 glEnable(GL_CULL_FACE);
1685 glDisable(GL_BLEND);
1689 glDisable(GL_DEPTH_TEST);
1690 glColor3f (1.0, 1.0, 1.0); // no coloring
1692 glEnable(GL_TEXTURE_2D);
1694 //Win Screen Won Victory
1696 glEnable(GL_TEXTURE_2D);
1698 sprintf (string, "Level Cleared!");
1699 text.glPrintOutlined(1024/2-strlen(string)*10,768*7/8,string,1,2,1024,768);
1701 sprintf (string, "Score: %d",(int)(bonustotal-startbonustotal));
1702 text.glPrintOutlined(1024/30,768*6/8,string,1,2,1024,768);
1705 sprintf (string, "Press Escape or Space to continue");
1707 sprintf (string, "Press Escape to return to menu or Space to continue");
1708 text.glPrintOutlined(640/2-strlen(string)*5,480*1/16,string,1,1,640,480);
1712 for(i=0;i<255;i++)string[i]='\0';
1713 sprintf (temp, "Time: %d:",(int)(((int)leveltime-(int)(leveltime)%60)/60));
1714 strcat(string,temp);
1715 if((int)(leveltime)%60<10)strcat(string,"0");
1716 sprintf (temp, "%d",(int)(leveltime)%60);
1717 strcat(string,temp);
1718 text.glPrintOutlined(1024/30,768*6/8-40,string,1,2,1024,768);
1721 int awards[award_count];
1722 int numawards = award_awards(awards);
1724 for (i = 0; i < numawards && i < 6; i++)
1725 text.glPrintOutlined(1024/30,768*6/8-90-40*i,award_names[awards[i]],1,2,1024,768);
1728 if(drawmode!=normalmode){
1729 glEnable(GL_TEXTURE_2D);
1731 if(!drawtoggle||drawmode!=realmotionblurmode||(drawtoggle==2||change==1)){
1734 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
1735 GLfloat subtractColor[4] = { 0.5, 0.5, 0.5, 0.0 };
1736 glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, subtractColor);
1737 //glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_SUBTRACT);
1738 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE);
1739 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_CONSTANT_EXT);
1740 glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 2.0f);
1742 glBindTexture( GL_TEXTURE_2D, screentexture);
1743 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1746 if((drawtoggle||change==1)&&drawmode==realmotionblurmode){
1748 glBindTexture( GL_TEXTURE_2D, screentexture2);
1749 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1751 if(!screentexture2){
1752 glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
1754 glGenTextures( 1, &screentexture2 );
1755 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
1757 glEnable(GL_TEXTURE_2D);
1758 glBindTexture( GL_TEXTURE_2D, screentexture2);
1759 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
1760 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
1762 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
1768 glClear(GL_DEPTH_BUFFER_BIT);
1769 ReSizeGLScene(90,.1f);
1770 glViewport(0,0,screenwidth,screenheight);
1772 if(drawmode!=normalmode){
1773 glDisable(GL_DEPTH_TEST);
1774 if(drawmode==motionblurmode){
1775 glDrawBuffer(GL_FRONT);
1776 glReadBuffer(GL_BACK);
1778 glColor3f (1.0, 1.0, 1.0); // no coloring
1780 glEnable(GL_TEXTURE_2D);
1781 glBindTexture( GL_TEXTURE_2D, screentexture);
1782 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1783 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1784 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1785 glDisable(GL_CULL_FACE);
1786 glDisable(GL_LIGHTING);
1788 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1789 glPushMatrix(); // Store The Projection Matrix
1790 glLoadIdentity(); // Reset The Projection Matrix
1791 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1792 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1793 glPushMatrix(); // Store The Modelview Matrix
1794 glLoadIdentity(); // Reset The Modelview Matrix
1795 glScalef((float)screenwidth/2,(float)screenheight/2,1);
1796 glTranslatef(1,1,0);
1797 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1799 if(drawmode==motionblurmode){
1800 if(motionbluramount<.2)motionbluramount=.2;
1801 //glColor4f(1,1,1,fast_sqrt(multiplier)*2.9*motionbluramount);
1802 glColor4f(1,1,1,motionbluramount);
1806 glVertex3f(-1, -1, 0.0f);
1807 glTexCoord2f(texcoordwidth,0);
1808 glVertex3f(1, -1, 0.0f);
1809 glTexCoord2f(texcoordwidth,texcoordheight);
1810 glVertex3f(1, 1, 0.0f);
1811 glTexCoord2f(0,texcoordheight);
1812 glVertex3f(-1, 1, 0.0f);
1816 if(drawmode==realmotionblurmode){
1817 glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
1818 glClear(GL_COLOR_BUFFER_BIT);
1819 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
1820 glBindTexture( GL_TEXTURE_2D, screentexture);
1821 glColor4f(1,1,1,.5);
1825 glVertex3f(-1, -1, 0.0f);
1826 glTexCoord2f(texcoordwidth,0);
1827 glVertex3f(1, -1, 0.0f);
1828 glTexCoord2f(texcoordwidth,texcoordheight);
1829 glVertex3f(1, 1, 0.0f);
1830 glTexCoord2f(0,texcoordheight);
1831 glVertex3f(-1, 1, 0.0f);
1834 glBindTexture( GL_TEXTURE_2D, screentexture2);
1835 glColor4f(1,1,1,.5);
1839 glVertex3f(-1, -1, 0.0f);
1840 glTexCoord2f(texcoordwidth,0);
1841 glVertex3f(1, -1, 0.0f);
1842 glTexCoord2f(texcoordwidth,texcoordheight);
1843 glVertex3f(1, 1, 0.0f);
1844 glTexCoord2f(0,texcoordheight);
1845 glVertex3f(-1, 1, 0.0f);
1848 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1850 if(drawmode==doublevisionmode){
1851 static float crosseyedness;
1852 crosseyedness=abs(player[0].damage-player[0].superpermanentdamage-(player[0].damagetolerance-player[0].superpermanentdamage)*1/2)/30;
1853 if(crosseyedness>1)crosseyedness=1;
1854 if(crosseyedness<0)crosseyedness=0;
1856 glDisable(GL_BLEND);
1861 glVertex3f(-1, -1, 0.0f);
1862 glTexCoord2f(texcoordwidth,0);
1863 glVertex3f(1, -1, 0.0f);
1864 glTexCoord2f(texcoordwidth,texcoordheight);
1865 glVertex3f(1, 1, 0.0f);
1866 glTexCoord2f(0,texcoordheight);
1867 glVertex3f(-1, 1, 0.0f);
1871 glColor4f(1,1,1,.5);
1874 glTranslatef(.015*crosseyedness,0,0);
1878 glVertex3f(-1, -1, 0.0f);
1879 glTexCoord2f(texcoordwidth,0);
1880 glVertex3f(1, -1, 0.0f);
1881 glTexCoord2f(texcoordwidth,texcoordheight);
1882 glVertex3f(1, 1, 0.0f);
1883 glTexCoord2f(0,texcoordheight);
1884 glVertex3f(-1, 1, 0.0f);
1889 if(drawmode==glowmode){
1890 glColor4f(.5,.5,.5,.5);
1892 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
1894 glTranslatef(.01,0,0);
1897 glVertex3f(-1, -1, 0.0f);
1898 glTexCoord2f(texcoordwidth,0);
1899 glVertex3f(1, -1, 0.0f);
1900 glTexCoord2f(texcoordwidth,texcoordheight);
1901 glVertex3f(1, 1, 0.0f);
1902 glTexCoord2f(0,texcoordheight);
1903 glVertex3f(-1, 1, 0.0f);
1907 glTranslatef(-.01,0,0);
1910 glVertex3f(-1, -1, 0.0f);
1911 glTexCoord2f(texcoordwidth,0);
1912 glVertex3f(1, -1, 0.0f);
1913 glTexCoord2f(texcoordwidth,texcoordheight);
1914 glVertex3f(1, 1, 0.0f);
1915 glTexCoord2f(0,texcoordheight);
1916 glVertex3f(-1, 1, 0.0f);
1920 glTranslatef(.0,.01,0);
1923 glVertex3f(-1, -1, 0.0f);
1924 glTexCoord2f(texcoordwidth,0);
1925 glVertex3f(1, -1, 0.0f);
1926 glTexCoord2f(texcoordwidth,texcoordheight);
1927 glVertex3f(1, 1, 0.0f);
1928 glTexCoord2f(0,texcoordheight);
1929 glVertex3f(-1, 1, 0.0f);
1933 glTranslatef(0,-.01,0);
1936 glVertex3f(-1, -1, 0.0f);
1937 glTexCoord2f(texcoordwidth,0);
1938 glVertex3f(1, -1, 0.0f);
1939 glTexCoord2f(texcoordwidth,texcoordheight);
1940 glVertex3f(1, 1, 0.0f);
1941 glTexCoord2f(0,texcoordheight);
1942 glVertex3f(-1, 1, 0.0f);
1946 if(drawmode==radialzoommode){
1948 //glRotatef((float)i*.1,0,0,1);
1949 glColor4f(1,1,1,1/((float)i+1));
1951 glScalef(1+(float)i*.01,1+(float)i*.01,1);
1954 glVertex3f(-1, -1, 0.0f);
1955 glTexCoord2f(texcoordwidth,0);
1956 glVertex3f(1, -1, 0.0f);
1957 glTexCoord2f(texcoordwidth,texcoordheight);
1958 glVertex3f(1, 1, 0.0f);
1959 glTexCoord2f(0,texcoordheight);
1960 glVertex3f(-1, 1, 0.0f);
1965 glDisable(GL_TEXTURE_2D);
1966 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1967 glPopMatrix(); // Restore The Old Projection Matrix
1968 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1969 glPopMatrix(); // Restore The Old Projection Matrix
1970 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1971 glEnable(GL_CULL_FACE);
1972 glDisable(GL_BLEND);
1977 glEnable(GL_TEXTURE_2D);
1980 if(consoleselected>=60)
1981 offset=consoleselected-60;
1982 sprintf (string, " ]");
1983 text.glPrint(10,30,string,0,1,1024,768);
1985 sprintf (string, "_");
1986 text.glPrint(30+(float)(consoleselected)*10-offset*10,30,string,0,1,1024,768);
1989 for(j=0;j<consolechars[i];j++){
1990 glColor4f(1,1,1,1-(float)(i)/16);
1991 if(j<consolechars[i]){
1992 sprintf (string, "%c",consoletext[i][j]);
1993 text.glPrint(30+j*10-offset*10,30+i*20,string,0,1,1024,768);
2000 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)||(mainmenu&&gameon)||(!gameon&&gamestarted)||(!gameon&&gamestarted)){
2001 multiplier=tempmult;
2006 // !!! FIXME: hack: clamp framerate in menu so text input works correctly on fast systems.
2009 glDrawBuffer(GL_BACK);
2010 glReadBuffer(GL_BACK);
2011 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
2012 ReSizeGLScene(90,.1f);
2015 temptexdetail=texdetail;
2016 if(texdetail>2)texdetail=2;
2017 if(mainmenu!=oldmainmenu&&oldmainmenu!=0){
2019 LoadTexture(":Data:Textures:Newgame.png",&Mainmenuitems[1],0,0);
2020 LoadTexture(":Data:Textures:Quit.png",&Mainmenuitems[3],0,0);
2023 LoadTexture(":Data:Textures:Resume.png",&Mainmenuitems[1],0,0);
2024 LoadTexture(":Data:Textures:Endgame.png",&Mainmenuitems[3],0,0);
2027 if(lastcheck>.5||oldmainmenu!=mainmenu){
2029 ifstream ipstream(ConvertFileName(":Data:Campaigns:main.txt"));
2030 ipstream.ignore(256,':');
2031 ipstream >> campaignnumlevels;
2032 for(i=0;i<campaignnumlevels;i++){
2033 ipstream.ignore(256,':');
2034 ipstream.ignore(256,':');
2035 ipstream.ignore(256,' ');
2036 ipstream >> campaignmapname[i];
2037 ipstream.ignore(256,':');
2038 ipstream >> campaigndescription[i];
2040 if(campaigndescription[i][j]=='_')campaigndescription[i][j]=' ';
2042 ipstream.ignore(256,':');
2043 ipstream >> campaignchoosenext[i];
2044 ipstream.ignore(256,':');
2045 ipstream >> campaignnumnext[i];
2046 for(j=0;j<campaignnumnext[i];j++){
2047 ipstream.ignore(256,':');
2048 ipstream >> campaignnextlevel[i][j];
2049 campaignnextlevel[i][j]-=1;
2051 ipstream.ignore(256,':');
2052 ipstream >> campaignlocationx[i];
2053 ipstream.ignore(256,':');
2054 ipstream >> campaignlocationy[i];
2058 for(i=0;i<campaignnumlevels;i++){
2060 levelhighlight[i]=0;
2065 for(i=0;i<accountactive->getCampaignChoicesMade();i++){
2066 levelorder[i+1]=campaignnextlevel[levelorder[i]][accountactive->getCampaignChoice(i)];
2067 levelvisible[levelorder[i+1]]=1;
2069 int whichlevelstart = accountactive->getCampaignChoicesMade()-1;
2070 if(whichlevelstart<0){
2071 accountactive->setCampaignScore(0);
2072 accountactive->resetFasttime();
2073 campaignchoicenum=1;
2074 campaignchoicewhich[0]=0;
2078 campaignchoicenum=campaignnumnext[levelorder[whichlevelstart]];
2079 for(i=0;i<campaignchoicenum;i++){
2080 campaignchoicewhich[i]=campaignnextlevel[levelorder[whichlevelstart]][i];
2081 levelvisible[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
2082 levelhighlight[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
2091 texdetail=temptexdetail;
2093 oldmainmenu=mainmenu;
2095 if(mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==8||mainmenu==9||mainmenu==10||mainmenu==119||mainmenu==18){
2096 glClear(GL_DEPTH_BUFFER_BIT);
2097 glEnable(GL_ALPHA_TEST);
2098 glAlphaFunc(GL_GREATER, 0.001f);
2099 glEnable(GL_TEXTURE_2D);
2100 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
2101 glDisable(GL_CULL_FACE);
2102 glDisable(GL_LIGHTING);
2104 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2105 glPushMatrix(); // Store The Projection Matrix
2106 glLoadIdentity(); // Reset The Projection Matrix
2107 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
2108 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2109 glPushMatrix(); // Store The Modelview Matrix
2110 glLoadIdentity(); // Reset The Modelview Matrix
2111 glTranslatef(screenwidth/2,screenheight/2,0);
2113 glScalef((float)screenwidth/2,(float)screenheight/2,1);
2114 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
2115 glDisable(GL_BLEND);
2116 glColor4f(0,0,0,1.0);
2117 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2118 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2119 glDisable(GL_TEXTURE_2D);
2121 //glScalef(.25,.25,.25);
2124 glVertex3f(-1, -1, 0.0f);
2126 glVertex3f(1, -1, 0.0f);
2128 glVertex3f(1, 1, 0.0f);
2130 glVertex3f(-1, 1, 0.0f);
2134 glColor4f(0.4,0.4,0.4,1.0);
2135 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2136 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2137 glEnable(GL_TEXTURE_2D);
2138 glBindTexture( GL_TEXTURE_2D, Mainmenuitems[4]);
2140 //glScalef(.25,.25,.25);
2143 glVertex3f(-1, -1, 0.0f);
2145 glVertex3f(1, -1, 0.0f);
2147 glVertex3f(1, 1, 0.0f);
2149 glVertex3f(-1, 1, 0.0f);
2154 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2156 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2160 if((float)newscreenwidth>(float)newscreenheight*1.61||(float)newscreenwidth<(float)newscreenheight*1.59)sprintf (menustring[0], "Resolution: %d*%d",(int)newscreenwidth,(int)newscreenheight);
2161 else sprintf (menustring[0], "Resolution: %d*%d (widescreen)",(int)newscreenwidth,(int)newscreenheight);
2164 endx[0]=startx[0]+strlen(menustring[0])*10;
2165 endy[0]=starty[0]+20;
2169 if(newdetail==2)sprintf (menustring[1], "Detail: High");
2170 else if(newdetail==1)sprintf (menustring[1], "Detail: Medium");
2171 else sprintf (menustring[1], "Detail: Low");
2174 endx[1]=startx[1]+strlen(menustring[1])*10;
2175 endy[1]=starty[1]+20;
2179 if(bloodtoggle==2)sprintf (menustring[2], "Blood: On, high detail (slower)");
2180 if(bloodtoggle==1)sprintf (menustring[2], "Blood: On, low detail");
2181 if(bloodtoggle==0)sprintf (menustring[2], "Blood: Off");
2184 endx[2]=startx[2]+strlen(menustring[2])*10;
2185 endy[2]=starty[2]+20;
2189 if(difficulty==2)sprintf (menustring[3], "Difficulty: Insane");
2190 if(difficulty==1)sprintf (menustring[3], "Difficulty: Difficult");
2191 if(difficulty==0)sprintf (menustring[3], "Difficulty: Easier");
2192 startx[3]=10+20-1000;
2194 endx[3]=startx[3]+strlen(menustring[3])*10;
2195 endy[3]=starty[3]+20;
2199 if(ismotionblur==1)sprintf (menustring[4], "Blur Effects: Enabled (less compatible)");
2200 if(ismotionblur==0)sprintf (menustring[4], "Blur Effects: Disabled (more compatible)");
2203 endx[4]=startx[4]+strlen(menustring[4])*10;
2204 endy[4]=starty[4]+20;
2208 if(decals==1)sprintf (menustring[5], "Decals: Enabled (slower)");
2209 if(decals==0)sprintf (menustring[5], "Decals: Disabled");
2212 endx[5]=startx[5]+strlen(menustring[5])*10;
2213 endy[5]=starty[5]+20;
2217 if(musictoggle==1)sprintf (menustring[6], "Music: Enabled");
2218 if(musictoggle==0)sprintf (menustring[6], "Music: Disabled");
2221 endx[6]=startx[6]+strlen(menustring[6])*10;
2222 endy[6]=starty[6]+20;
2226 if(invertmouse==1)sprintf (menustring[9], "Invert mouse: Yes");
2227 if(invertmouse==0)sprintf (menustring[9], "Invert mouse: No");
2230 endx[9]=startx[9]+strlen(menustring[9])*10;
2231 endy[9]=starty[9]+20;
2235 sprintf (menustring[10], "Mouse Speed: %d", (int)(usermousesensitivity*5));
2238 endx[10]=startx[10]+strlen(menustring[10])*10;
2239 endy[10]=starty[10]+20;
2243 sprintf (menustring[11], "Volume: %d%%", (int)(volume*100));
2246 endx[11]=startx[11]+strlen(menustring[11])*10;
2247 endy[11]=starty[11]+20;
2251 sprintf (menustring[13], "Damage Bar: %s",(showdamagebar?"on":"off"));
2254 endx[13]=startx[13]+strlen(menustring[13])*10;
2255 endy[13]=starty[13]+20;
2259 sprintf (menustring[7], "-Configure Controls-");
2262 endx[7]=startx[7]+strlen(menustring[7])*10;
2263 endy[7]=starty[7]+20;
2267 sprintf (menustring[12], "-Configure Stereo -");
2270 endx[12]=startx[12]+strlen(menustring[7])*10;
2271 endy[12]=starty[12]+20;
2275 if(newdetail==detail&&newscreenheight==(int)screenheight&&newscreenwidth==(int)screenwidth)sprintf (menustring[8], "Back");
2276 else sprintf (menustring[8], "Back (some changes take effect next time Lugaru is opened)");
2278 endx[8]=startx[8]+strlen(menustring[8])*10;
2280 endy[8]=starty[8]+20;
2287 if(keyselect!=0)sprintf (menustring[0], "Forwards: %s",Input::keyToChar(forwardkey));
2288 else sprintf (menustring[0], "Forwards: _");
2291 endx[0]=startx[0]+strlen(menustring[0])*10;
2292 endy[0]=starty[0]+20;
2296 if(keyselect!=1)sprintf (menustring[1], "Back: %s",Input::keyToChar(backkey));
2297 else sprintf (menustring[1], "Back: _");
2300 endx[1]=startx[1]+strlen(menustring[1])*10;
2301 endy[1]=starty[1]+20;
2305 if(keyselect!=2)sprintf (menustring[2], "Left: %s",Input::keyToChar(leftkey));
2306 else sprintf (menustring[2], "Left: _");
2309 endx[2]=startx[2]+strlen(menustring[2])*10;
2310 endy[2]=starty[2]+20;
2314 if(keyselect!=3)sprintf (menustring[3], "Right: %s",Input::keyToChar(rightkey));
2315 else sprintf (menustring[3], "Right: _");
2318 endx[3]=startx[3]+strlen(menustring[3])*10;
2319 endy[3]=starty[3]+20;
2323 if(keyselect!=4)sprintf (menustring[4], "Crouch: %s",Input::keyToChar(crouchkey));
2324 else sprintf (menustring[4], "Crouch: _");
2327 endx[4]=startx[4]+strlen(menustring[4])*10;
2328 endy[4]=starty[4]+20;
2332 if(keyselect!=5)sprintf (menustring[5], "Jump: %s",Input::keyToChar(jumpkey));
2333 else sprintf (menustring[5], "Jump: _");
2336 endx[5]=startx[5]+strlen(menustring[5])*10;
2337 endy[5]=starty[5]+20;
2341 if(keyselect!=6)sprintf (menustring[6], "Draw: %s",Input::keyToChar(drawkey));
2342 else sprintf (menustring[6], "Draw: _");
2345 endx[6]=startx[6]+strlen(menustring[6])*10;
2346 endy[6]=starty[6]+20;
2350 if(keyselect!=7)sprintf (menustring[7], "Throw: %s",Input::keyToChar(throwkey));
2351 else sprintf (menustring[7], "Throw: _");
2354 endx[7]=startx[7]+strlen(menustring[7])*10;
2355 endy[7]=starty[7]+20;
2359 if(keyselect!=8)sprintf (menustring[8], "Attack: %s",Input::keyToChar(attackkey));
2360 else sprintf (menustring[8], "Attack: _");
2363 endx[8]=startx[8]+strlen(menustring[8])*10;
2364 endy[8]=starty[8]+20;
2370 sprintf (menustring[9], "Back");
2372 endx[9]=startx[9]+strlen(menustring[9])*10;
2374 endy[9]=starty[9]+20;
2379 nummenuitems=7+accountactive->getCampaignChoicesMade()+campaignchoicenum;
2381 sprintf (menustring[0], "%s",accountactive->getName());
2384 endx[0]=startx[0]+strlen(menustring[0])*10;
2385 endy[0]=starty[0]+20;
2389 sprintf (menustring[1], "Tutorial");
2392 endx[1]=startx[1]+strlen(menustring[1])*10;
2393 endy[1]=starty[1]+20;
2397 sprintf (menustring[2], "Challenge");
2400 endx[2]=startx[2]+strlen(menustring[2])*10;
2401 endy[2]=starty[2]+20;
2405 sprintf (menustring[3], "Delete User");
2408 endx[3]=startx[3]+strlen(menustring[3])*10;
2409 endy[3]=starty[3]+20;
2413 sprintf (menustring[4], "Main Menu");
2416 endx[4]=startx[4]+strlen(menustring[4])*10;
2417 endy[4]=starty[4]+20;
2421 sprintf (menustring[5], "Change User");
2423 endx[5]=startx[5]+strlen(menustring[5])*10;
2425 endy[5]=starty[5]+20;
2431 sprintf (menustring[6], "World");
2433 starty[6]=30+480-400-50;
2434 endx[6]=startx[6]+400;
2439 if(accountactive->getCampaignChoicesMade())
2440 for(i=0;i<accountactive->getCampaignChoicesMade();i++){
2441 sprintf (menustring[7+i], "%s", campaigndescription[levelorder[i]]);
2442 startx[7+i]=30+120+campaignlocationx[levelorder[i]]*400/512;
2443 starty[7+i]=30+30+(512-campaignlocationy[levelorder[i]])*400/512;
2444 endx[7+i]=startx[7+i]+10;
2445 endy[7+i]=starty[7+i]+10;
2450 if(campaignchoicenum>0)
2451 for(i=accountactive->getCampaignChoicesMade();i<accountactive->getCampaignChoicesMade()+campaignchoicenum;i++){
2452 sprintf (menustring[7+i], "%s", campaigndescription[levelorder[i]]);
2453 startx[7+i]=30+120+campaignlocationx[campaignchoicewhich[i-(accountactive->getCampaignChoicesMade())]]*400/512;
2454 starty[7+i]=30+30+(512-campaignlocationy[campaignchoicewhich[i-(accountactive->getCampaignChoicesMade())]])*400/512;
2455 endx[7+i]=startx[7+i]+10;
2456 endy[7+i]=starty[7+i]+10;
2461 /*sprintf (menustring[7], "Dot");
2462 startx[7]=120+260*400/512;
2463 starty[7]=30+(512-184)*400/512;
2464 endx[7]=startx[7]+10;
2465 endy[7]=starty[7]+10;
2469 sprintf (menustring[8], "Dot");
2470 startx[8]=120+129*400/512;
2471 starty[8]=30+(512-284)*400/512;
2472 endx[8]=startx[8]+10;
2473 endy[8]=starty[8]+10;
2477 sprintf (menustring[9], "Dot");
2478 startx[9]=120+358*400/512;
2479 starty[9]=30+(512-235)*400/512;
2480 endx[9]=startx[9]+10;
2481 endy[9]=starty[9]+10;
2485 sprintf (menustring[10], "Dot");
2486 startx[10]=120+359*400/512;
2487 starty[10]=30+(512-308)*400/512;
2488 endx[10]=startx[10]+10;
2489 endy[10]=starty[10]+10;
2493 sprintf (menustring[11], "Dot");
2494 startx[11]=120+288*400/512;
2495 starty[11]=30+(512-277)*400/512;
2496 endx[11]=startx[11]+10;
2497 endy[11]=starty[11]+10;
2505 sprintf (menustring[0], "Are you sure you want to delete this user?");
2508 endx[0]=startx[0]+strlen(menustring[0])*10;
2509 endy[0]=starty[0]+20;
2513 sprintf (menustring[1], "Yes");
2516 endx[1]=startx[1]+strlen(menustring[1])*10;
2517 endy[1]=starty[1]+20;
2521 sprintf (menustring[2], "No");
2524 endx[2]=startx[2]+strlen(menustring[2])*10;
2525 endy[2]=starty[2]+20;
2529 sprintf (menustring[3], "Extra 4");
2532 endx[3]=startx[3]+strlen(menustring[3])*10;
2533 endy[3]=starty[3]+20;
2537 sprintf (menustring[4], "Extra 5");
2540 endx[4]=startx[4]+strlen(menustring[4])*10;
2541 endy[4]=starty[4]+20;
2545 sprintf (menustring[5], "Back");
2547 endx[5]=startx[5]+strlen(menustring[5])*10;
2549 endy[5]=starty[5]+20;
2555 nummenuitems=Account::getNbAccounts()+2;
2559 if(Account::getNbAccounts()<8)
2560 sprintf (menustring[0], "New User");
2562 sprintf (menustring[0], "No More Users");
2565 endx[0]=startx[0]+strlen(menustring[0])*10;
2566 endy[0]=starty[0]+20;
2575 for(i=0;i<Account::getNbAccounts();i++){
2576 sprintf (menustring[num], "%s",Account::get(i)->getName());
2578 starty[num]=360-20-20*num;
2579 endx[num]=startx[num]+strlen(menustring[num])*10;
2580 endy[num]=starty[num]+20;
2587 sprintf (menustring[num], "Back");
2589 endx[num]=startx[num]+strlen(menustring[num])*10;
2591 endy[num]=starty[num]+20;
2598 sprintf (menustring[0], "Easier");
2601 endx[0]=startx[0]+strlen(menustring[0])*10;
2602 endy[0]=starty[0]+20;
2606 sprintf (menustring[1], "Difficult");
2609 endx[1]=startx[1]+strlen(menustring[1])*10;
2610 endy[1]=starty[1]+20;
2614 sprintf (menustring[2], "Insane");
2617 endx[2]=startx[2]+strlen(menustring[2])*10;
2618 endy[2]=starty[2]+20;
2624 //tempncl=numchallengelevels;
2625 //numchallengelevels=9;
2626 nummenuitems=2+numchallengelevels;
2629 for(j=0;j<numchallengelevels;j++){
2630 for(i=0;i<255;i++)menustring[j][i]='\0';
2631 sprintf (temp, "Level %d",j+1);
2632 strcpy(menustring[j],temp);
2633 for(i=0;i<17;i++)if(menustring[j][i]=='\0')menustring[j][i]=' ';
2634 menustring[j][17]='\0';
2635 sprintf (temp, "%d",(int)accountactive->getHighScore(j));
2636 strcat(menustring[j],temp);
2637 for(i=18;i<32;i++)if(menustring[j][i]=='\0')menustring[j][i]=' ';
2638 menustring[j][32]='\0';
2639 sprintf (temp, "%d:",(int)(((int)accountactive->getFastTime(j)-(int)(accountactive->getFastTime(j))%60)/60));
2640 strcat(menustring[j],temp);
2641 if((int)(accountactive->getFastTime(j))%60<10)strcat(menustring[j],"0");
2642 sprintf (temp, "%d",(int)(accountactive->getFastTime(j))%60);
2643 strcat(menustring[j],temp);
2647 endx[j]=startx[j]+strlen(menustring[j])*10;
2648 endy[j]=starty[j]+20;
2653 sprintf (menustring[numchallengelevels], "Back");
2654 startx[numchallengelevels]=10;
2655 endx[numchallengelevels]=startx[numchallengelevels]+strlen(menustring[numchallengelevels])*10;
2656 starty[numchallengelevels]=10;
2657 endy[numchallengelevels]=starty[numchallengelevels]+20;
2658 movex[numchallengelevels]=0;
2659 movey[numchallengelevels]=0;
2661 sprintf (menustring[numchallengelevels+1], " High Score Best Time");
2662 startx[numchallengelevels+1]=10;
2663 starty[numchallengelevels+1]=440;
2664 endx[numchallengelevels+1]=startx[numchallengelevels+1]+strlen(menustring[numchallengelevels+1])*10;
2665 endy[numchallengelevels+1]=starty[numchallengelevels+1]+20;
2666 movex[numchallengelevels+1]=0;
2667 movey[numchallengelevels+1]=0;
2669 //numchallengelevels=tempncl;
2676 sprintf (menustring[0], "Congratulations!");
2679 endx[0]=startx[0]+strlen(menustring[0])*10;
2680 endy[0]=starty[0]+20;
2684 sprintf (menustring[1], "You have avenged your family and");
2687 endx[1]=startx[1]+strlen(menustring[1])*10;
2688 endy[1]=starty[1]+20;
2692 sprintf (menustring[2], "restored peace to the island of Lugaru.");
2695 endx[2]=startx[2]+strlen(menustring[2])*10;
2696 endy[2]=starty[2]+20;
2700 sprintf (menustring[3], "Back");
2702 endx[3]=startx[3]+strlen(menustring[3])*10;
2704 endy[3]=starty[3]+20;
2708 for(i=0;i<255;i++)menustring[4][i]='\0';
2709 sprintf (temp, "Your score:");
2710 strcpy(menustring[4],temp);
2711 for(i=0;i<20;i++)if(menustring[4][i]=='\0')menustring[4][i]=' ';
2712 menustring[4][20]='\0';
2713 sprintf (temp, "%d",(int)accountactive->getCampaignScore());
2714 strcat(menustring[4],temp);
2716 endx[4]=startx[4]+strlen(menustring[4])*10;
2718 endy[4]=starty[4]+20;
2722 for(i=0;i<255;i++)menustring[5][i]='\0';
2723 sprintf (temp, "Your time:");
2724 strcpy(menustring[5],temp);
2725 for(i=0;i<20;i++)if(menustring[5][i]=='\0')menustring[5][i]=' ';
2726 menustring[5][20]='\0';
2727 sprintf (temp, "%d",(int)accountcampaigntime[accountactive]);
2728 strcat(menustring[5],temp);
2730 endx[5]=startx[5]+strlen(menustring[5])*10;
2732 endy[5]=starty[5]+20;
2736 for(i=0;i<255;i++)menustring[5][i]='\0';
2737 sprintf (temp, "Highest score:");
2738 strcpy(menustring[5],temp);
2739 for(i=0;i<20;i++)if(menustring[5][i]=='\0')menustring[5][i]=' ';
2740 menustring[5][20]='\0';
2741 sprintf (temp, "%d",(int)accountactive->getCampaignHighScore());
2742 strcat(menustring[5],temp);
2744 endx[5]=startx[5]+strlen(menustring[5])*10;
2746 endy[5]=starty[5]+20;
2750 for(i=0;i<255;i++)menustring[7][i]='\0';
2751 sprintf (temp, "Lowest time:");
2752 strcpy(menustring[7],temp);
2753 for(i=0;i<20;i++)if(menustring[7][i]=='\0')menustring[7][i]=' ';
2754 menustring[7][20]='\0';
2755 sprintf (temp, "%d",(int)accountactive->getCampaignFasttime());
2756 strcat(menustring[7],temp);
2758 endx[7]=startx[7]+strlen(menustring[7])*10;
2760 endy[7]=starty[7]+20;
2766 sprintf (menustring[0], "Stereo mode: %s", StereoModeName(newstereomode));
2769 endx[0]=startx[0]+strlen(menustring[0])*10;
2770 endy[0]=starty[0]+20;
2774 sprintf (menustring[1], "Stereo separation: %.3f", stereoseparation);
2777 endx[1]=startx[1]+strlen(menustring[1])*10;
2778 endy[1]=starty[1]+20;
2782 sprintf (menustring[2], "Reverse stereo: %s", stereoreverse ? "Yes" : "No");
2785 endx[2]=startx[2]+strlen(menustring[2])*10;
2786 endy[2]=starty[2]+20;
2790 sprintf (menustring[3], "Back");
2792 endx[3]=startx[3]+strlen(menustring[3])*10;
2794 endy[3]=starty[3]+20;
2800 if(mainmenu==1||mainmenu==2){
2810 starty[1]=480-152-32;
2817 starty[2]=480-228-32;
2825 starty[3]=480-306-32;
2834 starty[3]=480-306-32;
2848 starty[4]=480-140-256;
2855 starty[5]=480-138-256;
2862 starty[6]=480-144-256;
2870 starty[4]=480-140-256;
2877 starty[5]=480-138-256;
2884 starty[6]=480-144-256;
2892 starty[4]=480-140-256;
2899 starty[5]=480-150-256;
2906 starty[6]=480-144-256;
2914 starty[4]=480-140-256;
2921 starty[5]=480-150-256;
2928 starty[6]=480-144-256;
2936 starty[4]=480-100-256;
2943 starty[5]=480-120-256;
2950 starty[6]=480-144-256;
2960 if(mainmenu==1||mainmenu==2)
2962 if((mousecoordh/screenwidth*640)>startx[i]&&(mousecoordh/screenwidth*640)<endx[i]&&480-(mousecoordv/screenheight*480)>starty[i]&&480-(mousecoordv/screenheight*480)<endy[i]){
2967 if(mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==8||mainmenu==9||mainmenu==10||mainmenu==18)
2968 for(i=0;i<nummenuitems;i++){
2969 if((mousecoordh/screenwidth*640)>startx[i]&&(mousecoordh/screenwidth*640)<endx[i]&&480-(mousecoordv/screenheight*480)>starty[i]&&480-(mousecoordv/screenheight*480)<endy[i]){
2970 if(mainmenu!=5)selected=i;
2971 if(mainmenu==5&&(i!=0&&i!=6))selected=i;
2972 if(mainmenu==9&&(i!=numchallengelevels+1))selected=i; // seem useless, if mainmenu==9 then mainmenu!=5, so selected==i.
2976 for(i=0;i<nummenuitems;i++){
2978 selectedlong[i]+=multiplier*5;
2979 if(selectedlong[i]>1) selectedlong[i]=1;
2981 selectedlong[i]-=multiplier*5;
2982 if(selectedlong[i]<0) selectedlong[i]=0;
2984 offsetx[i]=(startx[i]+endx[i])/2-(mousecoordh/screenwidth*640);
2985 offsety[i]=(starty[i]+endy[i])/2-(480-(mousecoordv/screenheight*480));
2990 if(i>=4&&(mainmenu==1||mainmenu==2)){
2992 offsetx[i]=(startx[i]+endx[i]+movex[i]*transition)/2-(640+190)/2;
2993 offsety[i]=(starty[i]+endy[i]+movey[i]*transition)/2-(336+150)/2;
2999 if(mainmenu==1||mainmenu==2){
3000 glClear(GL_DEPTH_BUFFER_BIT);
3001 glEnable(GL_ALPHA_TEST);
3002 glAlphaFunc(GL_GREATER, 0.001f);
3003 glEnable(GL_TEXTURE_2D);
3004 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3005 glDisable(GL_CULL_FACE);
3006 glDisable(GL_LIGHTING);
3008 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3009 glPushMatrix(); // Store The Projection Matrix
3010 glLoadIdentity(); // Reset The Projection Matrix
3011 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
3012 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3013 glPushMatrix(); // Store The Modelview Matrix
3014 glLoadIdentity(); // Reset The Modelview Matrix
3015 glTranslatef(screenwidth/2,screenheight/2,0);
3017 glScalef((float)screenwidth/2,(float)screenheight/2,1);
3018 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3019 glDisable(GL_BLEND);
3020 glColor4f(0,0,0,1.0);
3021 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
3022 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
3023 glDisable(GL_TEXTURE_2D);
3025 //glScalef(.25,.25,.25);
3028 glVertex3f(-1, -1, 0.0f);
3030 glVertex3f(1, -1, 0.0f);
3032 glVertex3f(1, 1, 0.0f);
3034 glVertex3f(-1, 1, 0.0f);
3038 glColor4f(0.4,0.4,0.4,1.0);
3039 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
3040 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
3041 glEnable(GL_TEXTURE_2D);
3042 glBindTexture( GL_TEXTURE_2D, Mainmenuitems[4]);
3044 //glScalef(.25,.25,.25);
3047 glVertex3f(-1, -1, 0.0f);
3049 glVertex3f(1, -1, 0.0f);
3051 glVertex3f(1, 1, 0.0f);
3053 glVertex3f(-1, 1, 0.0f);
3058 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3061 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3062 glPushMatrix(); // Store The Projection Matrix
3063 glLoadIdentity(); // Reset The Projection Matrix
3064 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3065 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3066 glPushMatrix(); // Store The Modelview Matrix
3067 glLoadIdentity(); // Reset The Modelview Matrix
3069 glDisable(GL_TEXTURE_2D);
3073 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3075 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3079 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3080 glPushMatrix(); // Store The Projection Matrix
3081 glLoadIdentity(); // Reset The Projection Matrix
3082 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3083 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3084 glPushMatrix(); // Store The Modelview Matrix
3085 glLoadIdentity(); // Reset The Modelview Matrix
3086 glEnable(GL_TEXTURE_2D);
3087 for(j=0;j<nummenuitems;j++)
3089 if(j<=3||(mainmenu!=1&&mainmenu!=2))
3091 //glDisable(GL_BLEND);
3092 glEnable(GL_ALPHA_TEST);
3094 //glDisable(GL_ALPHA_TEST);
3095 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3096 if(mainmenu==1||mainmenu==2)
3099 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3100 glBindTexture( GL_TEXTURE_2D, Mainmenuitems[j]);
3101 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
3102 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
3103 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3107 glVertex3f(startx[j]+movex[j]*transition, starty[j]+movey[j]*transition, 0.0f);
3109 glVertex3f(endx[j]+movex[j]*transition, starty[j]+movey[j]*transition, 0.0f);
3111 glVertex3f(endx[j]+movex[j]*transition, endy[j]+movey[j]*transition, 0.0f);
3113 glVertex3f(startx[j]+movex[j]*transition, endy[j]+movey[j]*transition, 0.0f);
3117 //glDisable(GL_ALPHA_TEST);
3118 if(j<4)glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3121 if(1-((float)i)/10-(1-selectedlong[j])>0)
3123 glColor4f(1,1,1,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3124 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3128 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);
3130 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);
3132 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);
3134 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);
3140 if(mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==8||mainmenu==9||mainmenu==10||mainmenu==18)
3142 if(mainmenu!=5||j<6)
3145 if(mainmenu==9&&j>accountactive->getProgress()&&j<numchallengelevels)glColor4f(0.5,0,0,1);
3146 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3148 if(mainmenu!=7||j!=0||!entername)
3149 text.glPrint(startx[j],starty[j],menustring[j],0,1,640,480);
3153 sprintf (string, "_");
3154 text.glPrint(startx[j]+(float)(displayselected)*10,starty[j],string,0,1,640,480);
3156 for(l=0;l<displaychars[0];l++){
3157 sprintf (string, "%c",displaytext[0][l]);
3158 text.glPrint(startx[j]+l*10,starty[j],string,0,1,640,480);
3163 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3166 if(1-((float)i)/15-(1-selectedlong[j])>0)
3168 glColor4f(1,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3169 if(mainmenu==9&&j>accountactive->getProgress()&&j<numchallengelevels)glColor4f(0.5,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3170 if(mainmenu==11&&j>accountactive->getProgress()&&j<numchallengelevels)glColor4f(0.5,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3171 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);
3172 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);
3173 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);
3174 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);
3175 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);
3176 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);
3177 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);
3178 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);
3179 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);
3185 glClear(GL_DEPTH_BUFFER_BIT);
3186 glEnable(GL_ALPHA_TEST);
3187 glAlphaFunc(GL_GREATER, 0.001f);
3188 glEnable(GL_TEXTURE_2D);
3189 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3190 glDisable(GL_CULL_FACE);
3191 glDisable(GL_LIGHTING);
3192 if(j==6)glColor4f(1,1,1,1);
3193 else glColor4f(1,0,0,1);
3195 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3196 glPushMatrix(); // Store The Projection Matrix
3197 glLoadIdentity(); // Reset The Projection Matrix
3198 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3199 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3200 glPushMatrix(); // Store The Modelview Matrix
3201 glLoadIdentity(); // Reset The Modelview Matrix
3204 //Draw world, draw map
3205 glTranslatef(2,-5,0);
3207 if(j>6&&j<nummenuitems-1)
3209 XYZ linestart,lineend,offset;
3216 //float linestartx,lineendx,linestarty,lineendy,offsetx,offsety;
3217 linestart.x=(startx[j]+endx[j])/2;
3218 linestart.y=(starty[j]+endy[j])/2;
3219 if(j>=6+accountactive->getCampaignChoicesMade()){
3220 linestart.x=(startx[6+accountactive->getCampaignChoicesMade()]+endx[6+accountactive->getCampaignChoicesMade()])/2;
3221 linestart.y=(starty[6+accountactive->getCampaignChoicesMade()]+endy[6+accountactive->getCampaignChoicesMade()])/2;
3223 lineend.x=(startx[j+1]+endx[j+1])/2;
3224 lineend.y=(starty[j+1]+endy[j+1])/2;
3225 offset=lineend-linestart;
3228 offset=DoRotation(offset,0,0,90);
3230 glDisable(GL_TEXTURE_2D);
3232 if(j<6+accountactive->getCampaignChoicesMade()){
3233 glColor4f(0.5,0,0,1);
3241 linestart+=fac*4*startsize;
3242 lineend-=fac*4*endsize;
3244 if(!(j>7+accountactive->getCampaignChoicesMade()+campaignchoicenum)){
3245 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3249 glVertex3f(linestart.x-offset.x*startsize, linestart.y-offset.y*startsize, 0.0f);
3251 glVertex3f(linestart.x+offset.x*startsize, linestart.y+offset.y*startsize, 0.0f);
3253 glVertex3f(lineend.x+offset.x*endsize, lineend.y+offset.y*endsize, 0.0f);
3255 glVertex3f(lineend.x-offset.x*endsize, lineend.y-offset.y*endsize, 0.0f);
3259 glEnable(GL_TEXTURE_2D);
3263 if(j==6)glBindTexture( GL_TEXTURE_2D, Mainmenuitems[7]);
3264 else glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
3265 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
3266 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
3267 if(j-7<accountactive->getCampaignChoicesMade())glColor4f(0.5,0,0,1);
3268 if(j-7>=accountactive->getCampaignChoicesMade())glColor4f(1,0,0,1);
3269 if(j==6)glColor4f(1,1,1,1);
3272 itemsize=abs(startx[j]-endx[j])/2;
3274 midpoint.x=(startx[j]+endx[j])/2;
3275 midpoint.y=(starty[j]+endy[j])/2;
3276 if(j>6&&(j-7<accountactive->getCampaignChoicesMade()))itemsize*=.5;
3277 if(!(j-7>accountactive->getCampaignChoicesMade()+campaignchoicenum))
3279 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3283 glVertex3f(midpoint.x-itemsize+movex[j]*transition, midpoint.y-itemsize+movey[j]*transition, 0.0f);
3285 glVertex3f(midpoint.x+itemsize+movex[j]*transition, midpoint.y-itemsize+movey[j]*transition, 0.0f);
3287 glVertex3f(midpoint.x+itemsize+movex[j]*transition, midpoint.y+itemsize+movey[j]*transition, 0.0f);
3289 glVertex3f(midpoint.x-itemsize+movex[j]*transition, midpoint.y+itemsize+movey[j]*transition, 0.0f);
3293 //glDisable(GL_ALPHA_TEST);
3294 if(j<4)glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3297 if(1-((float)i)/10-(1-selectedlong[j])>0)
3299 glColor4f(1,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3300 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3304 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);
3306 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);
3308 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);
3310 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);
3318 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3320 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3322 if(j-7>=accountactive->getCampaignChoicesMade()){
3323 text.glPrintOutlined(0.9,0,0,startx[j]+10,starty[j]-4,menustring[j],0,0.6,640,480);
3324 glDisable(GL_DEPTH_TEST);
3330 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3332 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3335 if(mainmenu==1||mainmenu==2)
3336 if(transition<.1||transition>.9){
3337 glClear(GL_DEPTH_BUFFER_BIT);
3338 glEnable(GL_ALPHA_TEST);
3339 glAlphaFunc(GL_GREATER, 0.001f);
3340 glEnable(GL_TEXTURE_2D);
3341 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3342 glDisable(GL_CULL_FACE);
3343 glDisable(GL_LIGHTING);
3345 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3346 glPushMatrix(); // Store The Projection Matrix
3347 glLoadIdentity(); // Reset The Projection Matrix
3348 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3349 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3350 glPushMatrix(); // Store The Modelview Matrix
3351 glLoadIdentity(); // Reset The Modelview Matrix
3353 glDisable(GL_TEXTURE_2D);
3355 glColor4f(1,0,0,1-(transition*10));
3357 glColor4f(1,0,0,1-((1-transition)*10));
3360 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3364 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3365 glPushMatrix(); // Store The Projection Matrix
3366 glLoadIdentity(); // Reset The Projection Matrix
3367 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
3368 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3369 glPushMatrix(); // Store The Modelview Matrix
3370 glLoadIdentity(); // Reset The Modelview Matrix
3371 glTranslatef(screenwidth/2,screenheight/2,0);
3373 glScalef((float)screenwidth/2,(float)screenheight/2,1);
3374 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3376 glEnable(GL_TEXTURE_2D);
3378 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
3379 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
3381 if(!waiting) { // hide the cursor while waiting for a key
3383 glTranslatef(mousecoordh-screenwidth/2,mousecoordv*-1+screenheight/2,0);
3384 glScalef((float)screenwidth/64,(float)screenwidth/64,1);
3385 glTranslatef(1,-1,0);
3386 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3388 glBindTexture( GL_TEXTURE_2D, cursortexture);
3390 //glScalef(.25,.25,.25);
3393 glVertex3f(-1, -1, 0.0f);
3395 glVertex3f(1, -1, 0.0f);
3397 glVertex3f(1, 1, 0.0f);
3399 glVertex3f(-1, 1, 0.0f);
3405 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3411 //printf("Flash amount: %f, delay %i\n", flashamount, flashdelay);
3412 if(flashamount>1)flashamount=1;
3413 if(flashdelay<=0)flashamount-=multiplier;
3415 if(flashamount<0)flashamount=0;
3416 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3417 glDisable(GL_CULL_FACE);
3418 glDisable(GL_LIGHTING);
3419 glDisable(GL_TEXTURE_2D);
3421 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3422 glPushMatrix(); // Store The Projection Matrix
3423 glLoadIdentity(); // Reset The Projection Matrix
3424 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
3425 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3426 glPushMatrix(); // Store The Modelview Matrix
3427 glLoadIdentity(); // Reset The Modelview Matrix
3428 glScalef(screenwidth,screenheight,1);
3429 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3431 glColor4f(flashr,flashg,flashb,flashamount);
3433 glVertex3f(0, 0, 0.0f);
3434 glVertex3f(256, 0, 0.0f);
3435 glVertex3f(256, 256, 0.0f);
3436 glVertex3f(0, 256, 0.0f);
3438 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3439 glPopMatrix(); // Restore The Old Projection Matrix
3440 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3441 glPopMatrix(); // Restore The Old Projection Matrix
3442 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
3443 glEnable(GL_CULL_FACE);
3444 glDisable(GL_BLEND);
3449 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)||(!gameon&&gamestarted)){
3450 tempmult=multiplier;
3455 if ( side == stereoRight || side == stereoCenter ) {
3456 if(drawmode!=motionblurmode||mainmenu){
3461 //myassert(glGetError() == GL_NO_ERROR);
3462 glDrawBuffer(GL_BACK);
3463 glReadBuffer(GL_BACK);
3468 if(drawtoggle==2)drawtoggle=0;
3470 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)){
3471 multiplier=tempmult;
3473 //Jordan fixed your warning!