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;
136 normalmode, motionblurmode, radialzoommode,
137 realmotionblurmode, doublevisionmode, glowmode,
140 void Game::flash() { // shouldn't be that way, these should be attributes and Person class should not change rendering.
147 /*********************> DrawGLScene() <*****/
148 int Game::DrawGLScene(StereoSide side)
150 static float texcoordwidth,texcoordheight;
151 static float texviewwidth, texviewheight;
153 static GLubyte color;
154 static float newbrightness;
155 static float changespeed;
156 static XYZ checkpoint;
157 static float tempmult;
159 static char string[256]="";
160 static char string2[256]="";
161 static char string3[256]="";
163 static float lastcheck;
165 lastcheck+=multiplier;
167 if ( stereomode == stereoAnaglyph ) {
169 case stereoLeft: glColorMask( 0.0, 1.0, 1.0, 1.0 ); break;
170 case stereoRight: glColorMask( 1.0, 0.0, 0.0, 1.0 ); break;
173 glColorMask( 1.0, 1.0, 1.0, 1.0 );
175 if ( stereomode == stereoHorizontalInterlaced || stereomode == stereoVerticalInterlaced ) {
176 glStencilFunc(side == stereoLeft ? GL_NOTEQUAL : GL_EQUAL, 0x01, 0x01);
180 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)){
187 numboundaries=mapradius*2;
188 if(numboundaries>360)numboundaries=360;
189 for(i=0;i<numboundaries;i++){
192 boundary[i]=mapcenter+DoRotation(boundary[i]*mapradius,0,i*(360/((float)(numboundaries))),0);
201 olddrawmode=drawmode;
202 if(ismotionblur&&!loading){
203 if((findLengthfast(&player[0].velocity)>200)&&velocityblur&&!cameramode){
204 drawmode=motionblurmode;
205 motionbluramount=200/(findLengthfast(&player[0].velocity));
208 if(player[0].damage-player[0].superpermanentdamage>(player[0].damagetolerance-player[0].superpermanentdamage)*1/2&&damageeffects&&!cameramode){
209 drawmode=doublevisionmode;
216 drawmode=motionblurmode;
218 slomodelay-=multiplier;
219 if(slomodelay<0)slomo=0;
223 if((!changed&&!slomo)||loading){
225 if(ismotionblur&&(/*fps>100||*/alwaysblur)){
226 if(olddrawmode!=realmotionblurmode)change=1;
228 drawmode=realmotionblurmode;
230 else if(olddrawmode==realmotionblurmode)change=2;
234 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted))drawmode=normalmode;
235 if((freeze||winfreeze)&&ismotionblur&&!mainmenu)drawmode=radialzoommode;
237 if(winfreeze||mainmenu)drawmode=normalmode;
240 if(drawmode==glowmode){
245 DSpContext_FadeGamma(NULL,200,&color2);
249 if(drawtoggle!=2)drawtoggle=1-drawtoggle;
253 texviewwidth=kTextureSize;
254 if(texviewwidth>screenwidth)texviewwidth=screenwidth;
255 texviewheight=kTextureSize;
256 if(texviewheight>screenheight)texviewheight=screenheight;
258 texcoordwidth=screenwidth/kTextureSize;
259 texcoordheight=screenheight/kTextureSize;
260 if(texcoordwidth>1)texcoordwidth=1;
261 if(texcoordheight>1)texcoordheight=1;
264 glDrawBuffer(GL_BACK);
265 glReadBuffer(GL_BACK);
267 if(abs(blurness-targetblurness)<multiplier*10||abs(blurness-targetblurness)>2){
268 blurness=targetblurness;
269 targetblurness=(float)(abs(Random()%100))/40;
271 if(blurness<targetblurness)
272 blurness+=multiplier*5;
274 blurness-=multiplier*5;
277 static XYZ terrainlight;
278 static float distance;
279 if(drawmode==normalmode)ReSizeGLScene(90,.1f);
280 if(drawmode!=normalmode)glViewport(0,0,texviewwidth,texviewheight);
281 glDepthFunc(GL_LEQUAL);
283 glAlphaFunc(GL_GREATER, 0.0001f);
284 glEnable(GL_ALPHA_TEST);
285 glClearColor(0.25f, 0.25f, 0.25f, 1.0f);
286 glClear(GL_DEPTH_BUFFER_BIT);
288 glMatrixMode (GL_MODELVIEW);
289 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
292 // Move the camera for the current eye's point of view.
293 // Reverse the movement if we're reversing stereo
294 glTranslatef((stereoseparation/2) * side * (stereoreverse ? -1 : 1), 0, 0);
296 if(!cameramode&&!freeze&&!winfreeze){
297 glRotatef(float(Random()%100)/10*camerashake/*+(woozy*woozy)/10*/,0,0,1);
298 glRotatef(rotation2+sin(woozy/2)*(player[0].damage/player[0].damagetolerance)*5,1,0,0);
299 glRotatef(rotation+sin(woozy)*(player[0].damage/player[0].damagetolerance)*5,0,1,0);
301 if(cameramode||freeze||winfreeze){
302 glRotatef(rotation2,1,0,0);
303 glRotatef(rotation,0,1,0);
306 if(environment==desertenvironment){
307 glRotatef((float)(abs(Random()%100))/3000-1,1,0,0);
308 glRotatef((float)(abs(Random()%100))/3000-1,0,1,0);
310 SetUpLight(&light,0);
312 if(environment==desertenvironment&&detail==2)glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, blurness+.4 );
313 if(environment==desertenvironment){
314 glRotatef((float)(abs(Random()%100))/1000,1,0,0);
315 glRotatef((float)(abs(Random()%100))/1000,0,1,0);
318 glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0);
320 glTranslatef(-viewer.x,-viewer.y,-viewer.z);
321 frustum.GetFrustum();
325 static float size,opacity,rotation;
327 for(k=0;k<numplayers;k++){
328 if(!player[k].skeleton.free&&player[k].playerdetail&&player[k].howactive<typesleeping)
329 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)
330 for(i=0;i<player[k].skeleton.num_joints;i++){
331 if(player[k].skeleton.joints[i].label==leftknee||player[k].skeleton.joints[i].label==rightknee||player[k].skeleton.joints[i].label==groin){
332 point=DoRotation(player[k].skeleton.joints[i].position,0,player[k].rotation,0)*player[k].scale+player[k].coords;
334 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;
335 if(k!=0&&tutoriallevel==1){
336 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;
338 terrain.MakeDecal(shadowdecal,point,size,opacity,rotation);
339 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
340 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
341 if(objects.position[j].y<player[k].coords.y||objects.type[j]==tunneltype||objects.type[j]==weirdtype){
342 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);
345 if(k!=0&&tutoriallevel==1){
346 opacity=.2+.2*sin(smoketex*6+i);
348 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
353 if((player[k].skeleton.free||player[k].howactive>=typesleeping)&&player[k].playerdetail)
354 if(frustum.SphereInFrustum(player[k].coords.x,player[k].coords.y,player[k].coords.z,player[k].scale*5)&&player[k].occluded<25)
355 for(i=0;i<player[k].skeleton.num_joints;i++){
356 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){
357 if(player[k].skeleton.free)point=player[k].skeleton.joints[i].position*player[k].scale+player[k].coords;
358 else point=DoRotation(player[k].skeleton.joints[i].position,0,player[k].rotation,0)*player[k].scale+player[k].coords;
360 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;
361 if(k!=0&&tutoriallevel==1){
362 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;
364 terrain.MakeDecal(shadowdecal,point,size,opacity*.7,rotation);
365 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
366 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
367 if(objects.position[j].y<player[k].coords.y||objects.type[j]==tunneltype||objects.type[j]==weirdtype){
368 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);
369 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);
372 if(k!=0&&tutoriallevel==1){
373 opacity=.2+.2*sin(smoketex*6+i);
375 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
381 if(!player[k].playerdetail)
382 if(frustum.SphereInFrustum(player[k].coords.x,player[k].coords.y,player[k].coords.z,player[k].scale*5))
384 point=player[k].coords;
386 opacity=.4-(player[k].coords.y-terrain.getHeight(player[k].coords.x,player[k].coords.z))/5;
387 terrain.MakeDecal(shadowdecal,point,size,opacity*.7,rotation);
388 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
389 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
390 point=DoRotation(player[k].coords-objects.position[j],0,-objects.rotation[j],0);
393 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
399 glEnable(GL_TEXTURE_2D);
401 glEnable(GL_DEPTH_TEST);
402 glEnable(GL_CULL_FACE);
404 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
405 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
406 glBindTexture( GL_TEXTURE_2D, terraintexture);
408 glBindTexture( GL_TEXTURE_2D, terraintexture2);
410 //glBindTexture( GL_TEXTURE_2D, terraintexture3);
411 //glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
414 terrain.drawdecals();
417 glEnable(GL_CULL_FACE);
418 glEnable(GL_LIGHTING);
420 glEnable(GL_TEXTURE_2D);
423 glEnable(GL_COLOR_MATERIAL);
438 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
439 glEnable(GL_CULL_FACE);
440 glCullFace(GL_FRONT);
442 for(k=0;k<numplayers;k++){
443 if(k==0||tutoriallevel!=1){
445 glEnable(GL_LIGHTING);
446 terrainlight=terrain.getLighting(player[k].coords.x,player[k].coords.z);
447 distance=findDistancefast(&viewer,&player[k].coords);
448 distance=(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance;
449 glColor4f(terrainlight.x,terrainlight.y,terrainlight.z,distance);
450 if(distance>=1)glDisable(GL_BLEND);
452 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;
454 if(!player[k].occluded==0)i=checkcollide(viewer,checkpoint,player[k].lastoccluded);
455 if(i==-1||player[k].occluded==0)i=checkcollide(viewer,checkpoint);
457 player[k].occluded+=1;
458 player[k].lastoccluded=i;
460 else player[k].occluded=0;
461 if(player[k].occluded<25)player[k].DrawSkeleton();
467 if(!cameramode&&musictype==stream_music2)playerdist=findDistancefastflat(&player[0].coords,&viewer);
468 else playerdist=-100;
471 glEnable(GL_TEXTURE_2D);
476 if(frustum.SphereInFrustum(realhawkcoords.x+hawk.boundingspherecenter.x,realhawkcoords.y+hawk.boundingspherecenter.y,realhawkcoords.z+hawk.boundingspherecenter.z,2)){
477 glAlphaFunc(GL_GREATER, 0.0001f);
479 glDisable(GL_CULL_FACE);
480 glDisable(GL_LIGHTING);
482 glTranslatef(hawkcoords.x,hawkcoords.y,hawkcoords.z);
483 glRotatef(hawkrotation,0,1,0);
484 glTranslatef(25,0,0);
485 distance=findDistancefast(&viewer,&realhawkcoords)*1.2;
486 glColor4f(light.color[0],light.color[1],light.color[2],(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance);
487 if((viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance>1)glColor4f(light.color[0],light.color[1],light.color[2],1);
488 if((viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance>0)
489 hawk.drawdifftex(hawktexture);
493 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
494 glEnable(GL_CULL_FACE);
495 glCullFace(GL_FRONT);
497 for(k=0;k<numplayers;k++){
498 if(!(k==0||tutoriallevel!=1)){
500 glEnable(GL_LIGHTING);
501 terrainlight=terrain.getLighting(player[k].coords.x,player[k].coords.z);
502 distance=findDistancefast(&viewer,&player[k].coords);
503 distance=(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance;
504 glColor4f(terrainlight.x,terrainlight.y,terrainlight.z,distance);
505 if(distance>=1)glDisable(GL_BLEND);
507 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;
509 if(!player[k].occluded==0)i=checkcollide(viewer,checkpoint,player[k].lastoccluded);
510 if(i==-1||player[k].occluded==0)i=checkcollide(viewer,checkpoint);
512 player[k].occluded+=1;
513 player[k].lastoccluded=i;
515 else player[k].occluded=0;
516 if(player[k].occluded<25)player[k].DrawSkeleton();
522 glEnable(GL_TEXTURE_2D);
527 glDisable(GL_COLOR_MATERIAL);
529 glDisable(GL_LIGHTING);
530 glDisable(GL_TEXTURE_2D);
538 glDisable(GL_LIGHTING);
539 glDisable(GL_TEXTURE_2D);
540 glDisable(GL_COLOR_MATERIAL);
543 for(k=0;k<numplayers;k++){
544 if(player[k].numwaypoints>1){
545 glBegin(GL_LINE_LOOP);
546 for(i=0;i<player[k].numwaypoints;i++){
547 glVertex3f(player[k].waypoints[i].x,player[k].waypoints[i].y+.5,player[k].waypoints[i].z);
556 for(k=0;k<numpathpoints;k++){
557 if(numpathpointconnect[k]){
558 for(i=0;i<numpathpointconnect[k];i++){
559 glBegin(GL_LINE_LOOP);
560 glVertex3f(pathpoint[k].x,pathpoint[k].y+.5,pathpoint[k].z);
561 glVertex3f(pathpoint[pathpointconnect[k][i]].x,pathpoint[pathpointconnect[k][i]].y+.5,pathpoint[pathpointconnect[k][i]].z);
569 glVertex3f(pathpoint[pathpointselected].x,pathpoint[pathpointselected].y+.5,pathpoint[pathpointselected].z);
576 glEnable(GL_TEXTURE_2D);
577 glColor4f(.5,.5,.5,1);
579 sprintf (string, " ",(int)(fps));
580 text.glPrint(10,30,string,0,.8,screenwidth,screenheight);
583 if(bonus>0&&bonustime<1&&!winfreeze&&indialogue==-1/*bonustime<4*/){
584 const char *bonus_name;
585 if (bonus < bonus_count)
586 bonus_name = bonus_names[bonus];
588 bonus_name = "Excellent!"; // When does this happen?
590 glColor4f(0,0,0,1-bonustime);
591 text.glPrintOutline(1024/2-10*strlen(bonus_name)-4,768/16-4+768*4/5,bonus_name,1,2.5,1024,768);
592 glColor4f(1,0,0,1-bonustime);
593 text.glPrint(1024/2-10*strlen(bonus_name),768/16+768*4/5,bonus_name,1,2,1024,768);
595 sprintf (string, "%d",(int)bonusvalue);
596 glColor4f(0,0,0,1-bonustime);
597 text.glPrintOutline(1024/2-10*strlen(string)-4,768/16-4-20+768*4/5,string,1,2.5*.8,1024,768);
598 glColor4f(1,0,0,1-bonustime);
599 text.glPrint(1024/2-10*strlen(string),768/16-20+768*4/5,string,1,2*.8,1024,768);
600 glColor4f(.5,.5,.5,1);
603 if(tutoriallevel==1){
604 tutorialopac=tutorialmaxtime-tutorialstagetime;
605 if(tutorialopac>1)tutorialopac=1;
606 if(tutorialopac<0)tutorialopac=0;
608 sprintf (string, " ");
609 sprintf (string2, " ");
610 sprintf (string3, " ");
611 if(tutorialstage==0){
612 sprintf (string, " ");
613 sprintf (string2, " ");
614 sprintf (string3, " ");
616 if(tutorialstage==1){
617 sprintf (string, "Welcome to the Lugaru training level!");
618 sprintf (string2, " ");
619 sprintf (string3, " ");
621 if(tutorialstage==2){
622 sprintf (string, "BASIC MOVEMENT:");
623 sprintf (string2, " ");
624 sprintf (string3, " ");
626 if(tutorialstage==3){
627 sprintf (string, "You can move the mouse to rotate the camera.");
628 sprintf (string2, " ");
629 sprintf (string3, " ");
631 if(tutorialstage==4){
632 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));
633 sprintf (string2, "All movement is relative to the camera.");
634 sprintf (string3, " ");
636 if(tutorialstage==5){
637 sprintf (string, "Please press %s to jump.",Input::keyToChar(jumpkey));
638 sprintf (string2, "You can hold it longer to jump higher.");
639 sprintf (string3, " ");
641 if(tutorialstage==6){
642 sprintf (string, "You can press %s to crouch.",Input::keyToChar(crouchkey));
643 sprintf (string2, "You can jump higher from a crouching position.");
644 sprintf (string3, " ");
646 if(tutorialstage==7){
647 sprintf (string, "While running, you can press %s to roll.",Input::keyToChar(crouchkey));
648 sprintf (string2, " ");
649 sprintf (string3, " ");
651 if(tutorialstage==8){
652 sprintf (string, "While crouching, you can sneak around silently");
653 sprintf (string2, "using the movement keys.");
654 sprintf (string3, " ");
656 if(tutorialstage==9){
657 sprintf (string, "Release the crouch key while sneaking and hold the movement keys");
658 sprintf (string2, "to run animal-style.");
659 sprintf (string3, " ");
661 if(tutorialstage==10){
662 sprintf (string, "ADVANCED MOVEMENT:");
663 sprintf (string2, " ");
664 sprintf (string3, " ");
666 if(tutorialstage==11){
667 sprintf (string, "When you jump at a wall, you can hold %s again",Input::keyToChar(jumpkey));
668 sprintf (string2, "during impact to perform a walljump.");
669 sprintf (string3, "Be sure to use the movement keys to press against the wall");
671 if(tutorialstage==12){
672 sprintf (string, "While in the air, you can press crouch to flip.",Input::keyToChar(jumpkey));
673 sprintf (string2, "Walljumps and flips confuse enemies and give you more control.");
674 sprintf (string3, " ");
676 if(tutorialstage==13){
677 sprintf (string, "BASIC COMBAT:");
678 sprintf (string2, " ");
679 sprintf (string3, " ");
681 if(tutorialstage==14){
682 sprintf (string, "There is now an imaginary enemy");
683 sprintf (string2, "in the middle of the training area.");
684 sprintf (string3, " ");
686 if(tutorialstage==15){
687 if(attackkey==MOUSEBUTTON1)sprintf (string, "Click to attack when you are near an enemy.");
688 else sprintf (string, "Press %s to attack when you are near an enemy.",Input::keyToChar(attackkey));
689 sprintf (string2, "You can punch by standing still near an enemy and attacking.");
690 sprintf (string3, " ");
692 if(tutorialstage==16){
693 sprintf (string, "If you are close, you will perform a weak punch.");
694 sprintf (string2, "The weak punch is excellent for starting attack combinations.");
695 sprintf (string3, " ");
697 if(tutorialstage==17){
698 sprintf (string, "Attacking while running results in a spin kick.");
699 sprintf (string2, "This is one of your most powerful ground attacks.");
700 sprintf (string3, " ");
702 if(tutorialstage==18){
703 sprintf (string, "Sweep the enemy's legs out by attacking while crouched.");
704 sprintf (string2, "This is a very fast attack, and easy to follow up.");
705 sprintf (string3, " ");
707 if(tutorialstage==19){
708 sprintf (string, "When an enemy is on the ground, you can deal some extra");
709 sprintf (string2, "damage by running up and drop-kicking him.");
710 sprintf (string3, "(Try knocking them down with a sweep first)");
712 if(tutorialstage==20){
713 sprintf (string, "Your most powerful individual attack is the rabbit kick.");
714 if(attackkey==MOUSEBUTTON1)sprintf (string2, "Run at the enemy while holding the mouse button, and press");
715 else sprintf (string2, "Run at the enemy while holding %s, and press", Input::keyToChar(attackkey));
716 sprintf (string3, "the jump key (%s) to attack.",Input::keyToChar(jumpkey));
718 if(tutorialstage==21){
719 sprintf (string, "This attack is devastating if timed correctly.");
720 sprintf (string2, "Even if timed incorrectly, it will knock the enemy over.");
721 if(againbonus)sprintf (string3, "Try rabbit-kicking the imaginary enemy again.");
722 else sprintf (string3, "Try rabbit-kicking the imaginary enemy.");
724 if(tutorialstage==22){
725 sprintf (string, "If you sneak behind an enemy unnoticed, you can kill");
726 sprintf (string2, "him instantly. Move close behind this enemy");
727 sprintf (string3, "and attack.");
729 if(tutorialstage==23){
730 sprintf (string, "Another important attack is the wall kick. When an enemy");
731 sprintf (string2, "is near a wall, perform a walljump nearby and hold");
732 sprintf (string3, "the attack key during impact with the wall.");
734 if(tutorialstage==24){
735 sprintf (string, "You can tackle enemies by running at them animal-style");
736 if(attackkey==MOUSEBUTTON1)sprintf (string2, "and pressing jump (%s) or attack(mouse button).",Input::keyToChar(jumpkey));
737 else sprintf (string2, "and pressing jump (%s) or attack(%s).",Input::keyToChar(jumpkey),Input::keyToChar(attackkey));
738 sprintf (string3, "This is especially useful when they are running away.");
740 if(tutorialstage==25){
741 sprintf (string, "Dodge by pressing back and attack. Dodging is essential");
742 sprintf (string2, "against enemies with swords or other long weapons.");
743 sprintf (string3, " ");
745 if(tutorialstage==26){
746 sprintf (string, "REVERSALS AND COUNTER-REVERSALS");
747 sprintf (string2, " ");
748 sprintf (string3, " ");
750 if(tutorialstage==27){
751 sprintf (string, "The enemy can now reverse your attacks.");
752 sprintf (string2, " ");
753 sprintf (string3, " ");
755 if(tutorialstage==28){
756 sprintf (string, "If you attack, you will notice that the enemy now sometimes");
757 sprintf (string2, "catches your attack and uses it against you. Hold");
758 sprintf (string3, "crouch (%s) after attacking to escape from reversals.",Input::keyToChar(crouchkey));
760 if(tutorialstage==29){
761 sprintf (string, "Try escaping from two more reversals in a row.");
762 sprintf (string2, " ");
763 sprintf (string3, " ");
765 if(tutorialstage==30){
766 sprintf (string, "Good!");
767 sprintf (string2, " ");
768 sprintf (string3, " ");
770 if(tutorialstage==31){
771 sprintf (string, "To reverse an attack, you must tap crouch (%s) during the",Input::keyToChar(crouchkey));
772 sprintf (string2, "enemy's attack. You must also be close to the enemy;");
773 sprintf (string3, "this is especially important against armed opponents.");
775 if(tutorialstage==32){
776 sprintf (string, "The enemy can attack in %d seconds.", (int)(tutorialmaxtime-tutorialstagetime));
777 sprintf (string2, "This imaginary opponents attacks will be highlighted");
778 sprintf (string3, "to make this easier.");
780 if(tutorialstage==33){
781 sprintf (string, "Reverse three enemy attacks!");
782 sprintf (string2, " ");
783 sprintf (string3, " ");
785 if(tutorialstage==34){
786 sprintf (string, "Reverse two more enemy attacks!");
787 sprintf (string2, " ");
788 sprintf (string3, " ");
790 if(tutorialstage==35){
791 sprintf (string, "Reverse one more enemy attack!");
792 sprintf (string2, " ");
793 sprintf (string3, " ");
795 if(tutorialstage==36){
796 sprintf (string, "Excellent!");
797 sprintf (string2, " ");
798 sprintf (string3, " ");
800 if(tutorialstage==37){
801 sprintf (string, "Now spar with the enemy for %d more seconds.", (int)(tutorialmaxtime-tutorialstagetime));
802 sprintf (string2, "Damage dealt: %d",(int)damagedealt);
803 sprintf (string3, "Damage taken: %d.",(int)damagetaken);
805 if(tutorialstage==38){
806 sprintf (string, "WEAPONS:");
807 sprintf (string2, " ");
808 sprintf (string3, " ");
810 if(tutorialstage==39){
811 sprintf (string, "There is now an imaginary knife");
812 sprintf (string2, "in the center of the training area.");
813 sprintf (string3, " ");
815 if(tutorialstage==40){
816 sprintf (string, "Stand, roll or handspring over the knife");
817 sprintf (string2, "while pressing %s to pick it up.",Input::keyToChar(throwkey));
818 sprintf (string3, "You can crouch and press the same key to drop it again.");
820 if(tutorialstage==41){
821 sprintf (string, "You can equip and unequip weapons using the %s key.",Input::keyToChar(drawkey));
822 sprintf (string2, "Sometimes it is best to keep them unequipped to");
823 sprintf (string3, "prevent enemies from taking them. ");
825 if(tutorialstage==42){
826 sprintf (string, "The knife is the smallest weapon and the least encumbering.");
827 sprintf (string2, "You can equip or unequip it while standing, crouching,");
828 sprintf (string3, "running or flipping.");
830 if(tutorialstage==43){
831 sprintf (string, "You perform weapon attacks the same way as unarmed attacks,");
832 sprintf (string2, "but sharp weapons cause permanent damage, instead of the");
833 sprintf (string3, "temporary trauma from blunt weapons, fists and feet.");
835 if(tutorialstage==44){
836 sprintf (string, "The enemy now has your knife!");
837 sprintf (string2, "Please reverse two of his knife attacks.");
838 sprintf (string3, " ");
840 if(tutorialstage==45){
841 sprintf (string, "Please reverse one more of his knife attacks.");
842 sprintf (string2, " ");
843 sprintf (string3, " ");
845 if(tutorialstage==46){
846 sprintf (string, "Now he has a sword!");
847 sprintf (string2, "The sword has longer reach than your arms, so you");
848 sprintf (string3, "must move close to reverse the sword slash.");
850 if(tutorialstage==47){
851 sprintf (string, "Long weapons like the sword and staff are also useful for defense;");
852 sprintf (string2, "you can parry enemy weapon attacks by pressing the attack key");
853 sprintf (string3, "at the right time. Please try parrying the enemy's attacks!");
855 if(tutorialstage==48){
856 sprintf (string, "The staff is like the sword, but has two main attacks.");
857 sprintf (string2, "The standing smash is fast and effective, and the running");
858 sprintf (string3, "spin smash is slower and more powerful.");
860 if(tutorialstage==49){
861 sprintf (string, "When facing an enemy, you can throw the knife with %s.",Input::keyToChar(throwkey));
862 sprintf (string2, "It is possible to throw the knife while flipping,");
863 sprintf (string3, "but it is very inaccurate.");
865 if(tutorialstage==50){
866 sprintf (string, "You now know everything you can learn from training.");
867 sprintf (string2, "Everything else you must learn from experience!");
868 sprintf (string3, " ");
870 if(tutorialstage==51){
871 sprintf (string, "Walk out of the training area to return to the main menu.");
872 sprintf (string2, " ");
873 sprintf (string3, " ");
876 glColor4f(0,0,0,tutorialopac);
877 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);
878 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);
879 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);
880 glColor4f(1,1,1,tutorialopac);
881 text.glPrint(screenwidth/2-7.6*strlen(string)*screenwidth/1024,screenheight/16+screenheight*4/5,string,1,1.5*screenwidth/1024,screenwidth,screenheight);
882 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);
883 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);
885 sprintf (string, "Press 'tab' to skip to the next item.",Input::keyToChar(jumpkey));
886 sprintf (string2, "Press escape at any time to");
887 sprintf (string3, "pause or exit the tutorial.");
890 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);
891 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);
892 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);
893 glColor4f(0.5,0.5,0.5,1);
894 text.glPrint(screenwidth/2-7.6*strlen(string)*screenwidth/1024*.8,0+screenheight*1/10,string,1,1.5*screenwidth/1024*.8,screenwidth,screenheight);
895 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);
896 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);
900 if(numhotspots&&(bonustime>=1||bonus<=0||bonustime<0)&&!tutoriallevel){
902 float closestdist=-1;
904 closest=currenthotspot;
905 for(i=0;i<numhotspots;i++){
906 distance=findDistancefast(&player[0].coords,&hotspot[i]);
907 if(closestdist==-1||distance<closestdist){
908 if(findDistancefast(&player[0].coords,&hotspot[i])<hotspotsize[i]&&((hotspottype[i]<=10&&hotspottype[i]>=0)||(hotspottype[i]<=40&&hotspottype[i]>=20))){
909 closestdist=distance;
915 currenthotspot=closest;
916 if(currenthotspot!=-1){
917 if(hotspottype[closest]<=10){
918 if(findDistancefast(&player[0].coords,&hotspot[closest])<hotspotsize[closest])
921 tutorialopac=tutorialmaxtime-tutorialstagetime;
922 if(tutorialopac>1)tutorialopac=1;
923 if(tutorialopac<0)tutorialopac=0;
925 sprintf (string, "%s", hotspottext[closest]);
932 if(string[i]=='\n'||string[i]>'z'||string[i]<' '||string[i]=='\0'){
933 glColor4f(0,0,0,tutorialopac);
934 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);
935 glColor4f(1,1,1,tutorialopac);
936 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);
939 if(string[i]=='\0')done=1;
945 else if (hotspottype[closest]>=20&&dialoguegonethrough[hotspottype[closest]-20]==0){
946 whichdialogue=hotspottype[closest]-20;
947 for(j=0;j<numdialogueboxes[whichdialogue];j++){
948 player[participantfocus[whichdialogue][j]].coords=participantlocation[whichdialogue][participantfocus[whichdialogue][j]];
949 player[participantfocus[whichdialogue][j]].rotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
950 player[participantfocus[whichdialogue][j]].targetrotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
951 player[participantfocus[whichdialogue][j]].velocity=0;
952 player[participantfocus[whichdialogue][j]].targetanimation=player[participantfocus[whichdialogue][j]].getIdle();
953 player[participantfocus[whichdialogue][j]].targetframe=0;
957 dialoguegonethrough[whichdialogue]++;
958 if(dialogueboxsound[whichdialogue][indialogue]!=0){
960 if(dialogueboxsound[whichdialogue][indialogue]==1)whichsoundplay=rabbitchitter;
961 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
962 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
963 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
964 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
965 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
966 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
967 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
968 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
969 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
970 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
971 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
972 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
973 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
974 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
975 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
976 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
977 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
978 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
979 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
980 emit_sound_at(whichsoundplay, player[participantfocus[whichdialogue][indialogue]].coords);
986 if(indialogue!=-1&&!mainmenu){
987 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
988 glDisable(GL_CULL_FACE);
989 glDisable(GL_LIGHTING);
990 glDisable(GL_TEXTURE_2D);
992 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
993 glPushMatrix(); // Store The Projection Matrix
994 glLoadIdentity(); // Reset The Projection Matrix
995 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
996 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
997 glPushMatrix(); // Store The Modelview Matrix
998 glLoadIdentity(); // Reset The Modelview Matrix
999 if(dialogueboxlocation[whichdialogue][indialogue]==1)glTranslatef(0,screenheight*3/4,0);
1000 glScalef(screenwidth,screenheight/4,1);
1001 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1004 glColor4f(dialogueboxcolor[whichdialogue][indialogue][0],dialogueboxcolor[whichdialogue][indialogue][1],dialogueboxcolor[whichdialogue][indialogue][2],0.7);
1006 glVertex3f(0, 0, 0.0f);
1007 glVertex3f(1, 0, 0.0f);
1008 glVertex3f(1, 1, 0.0f);
1009 glVertex3f(0, 1, 0.0f);
1011 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1012 glPopMatrix(); // Restore The Old Projection Matrix
1013 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1014 glPopMatrix(); // Restore The Old Projection Matrix
1015 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1016 glEnable(GL_CULL_FACE);
1017 glDisable(GL_BLEND);
1019 glEnable(GL_TEXTURE_2D);
1026 startx=screenwidth*1/5;
1027 if(dialogueboxlocation[whichdialogue][indialogue]==1)starty=screenheight/16+screenheight*4/5;
1028 if(dialogueboxlocation[whichdialogue][indialogue]==2)starty=screenheight*1/5-screenheight/16;
1037 for(i=0;i<(int)strlen(dialoguename[whichdialogue][indialogue]);i++){
1038 tempname[tempnum]=dialoguename[whichdialogue][indialogue][i];
1040 if(dialoguename[whichdialogue][indialogue][i]=='#'||dialoguename[whichdialogue][indialogue][i]=='\0')goodchar=0;
1044 tempname[tempnum]='\0';
1047 sprintf (string, "%s: ", tempname);
1049 if(dialogueboxcolor[whichdialogue][indialogue][0]+dialogueboxcolor[whichdialogue][indialogue][1]+dialogueboxcolor[whichdialogue][indialogue][2]<1.5){
1050 glColor4f(0,0,0,tutorialopac);
1051 text.glPrintOutline(startx-2*7.6*strlen(string)*screenwidth/1024-4,starty-4,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight);
1052 glColor4f(0.7,0.7,0.7,tutorialopac);
1053 text.glPrint(startx-2*7.6*strlen(string)*screenwidth/1024,starty,string,1,1.5*screenwidth/1024,screenwidth,screenheight);
1057 glColor4f(0,0,0,tutorialopac);
1058 text.glPrintOutline(startx-2*7.6*strlen(string)*screenwidth/1024-4,starty-4,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight);
1062 for(i=0;i<(int)strlen(dialoguetext[whichdialogue][indialogue])+1;i++){
1063 tempname[tempnum]=dialoguetext[whichdialogue][indialogue][i];
1064 if(dialoguetext[whichdialogue][indialogue][i]!='#')tempnum++;
1067 sprintf (string, "%s", tempname);
1074 if(string[i]=='\n'||string[i]>'z'||string[i]<' '||string[i]=='\0'){
1075 if(dialogueboxcolor[whichdialogue][indialogue][0]+dialogueboxcolor[whichdialogue][indialogue][1]+dialogueboxcolor[whichdialogue][indialogue][2]<1.5){
1076 glColor4f(0,0,0,tutorialopac);
1077 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);
1078 glColor4f(1,1,1,tutorialopac);
1079 text.glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/,starty-20*screenwidth/1024*line,string,1,1.5*screenwidth/1024,screenwidth,screenheight,lastline,i);
1083 glColor4f(0,0,0,tutorialopac);
1084 text.glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/,starty-20*screenwidth/1024*line,string,1,1.5*screenwidth/1024,screenwidth,screenheight,lastline,i);
1088 if(string[i]=='\0')done=1;
1095 if(!tutoriallevel&&!winfreeze&&indialogue==-1&&!mainmenu){
1098 sprintf (string, "Score: %d", (int)accountactive->getCampaignScore());
1100 sprintf (string, "Score: %d", (int)accountactive->getCampaignScore()+(int)bonustotal);
1102 if(!campaign)sprintf (string, "Score: %d", (int)bonustotal);
1104 text.glPrintOutline(1024/40-4,768/16-4+768*14/16,string,1,1.5*1.25,1024,768);
1106 text.glPrint(1024/40,768/16+768*14/16,string,1,1.5,1024,768);
1108 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1109 glDisable(GL_CULL_FACE);
1110 glDisable(GL_LIGHTING);
1111 glDisable(GL_TEXTURE_2D);
1113 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1114 glPushMatrix(); // Store The Projection Matrix
1115 glLoadIdentity(); // Reset The Projection Matrix
1116 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1117 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1118 glPushMatrix(); // Store The Modelview Matrix
1119 glLoadIdentity(); // Reset The Modelview Matrix
1120 glTranslatef(15,screenheight*17.5/20,0);
1121 glScalef(screenwidth/3+20,screenheight/20,1);
1122 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1124 glColor4f(0.0,0.4,0.0,0.7);
1125 float bar=((float)player[0].damage)/player[0].damagetolerance;
1127 glVertex3f((bar<1?bar:1),0,0.0f);
1128 glVertex3f(1,0,0.0f);
1129 glVertex3f(1,1,0.0f);
1130 glVertex3f((bar<1?bar:1),1,0.0f);
1132 glColor4f(0.1,0.0,0.0,1);
1133 bar = ((float)player[0].bloodloss)/player[0].damagetolerance;
1135 glVertex3f(0,0,0.0f);
1136 glVertex3f((bar<1?bar:1),0,0.0f);
1137 glVertex3f((bar<1?bar:1),1,0.0f);
1138 glVertex3f(0,1,0.0f);
1140 glColor4f(0.4,0.0,0.0,0.7);
1141 bar = ((float)player[0].damage)/player[0].damagetolerance;
1143 glVertex3f(0,0,0.0f);
1144 glVertex3f((bar<1?bar:1),0,0.0f);
1145 glVertex3f((bar<1?bar:1),1,0.0f);
1146 glVertex3f(0,1,0.0f);
1148 glColor4f(0.4,0.0,0.0,0.7);
1149 bar = ((float)player[0].permanentdamage)/player[0].damagetolerance;
1151 glVertex3f(0,0,0.0f);
1152 glVertex3f((bar<1?bar:1),0,0.0f);
1153 glVertex3f((bar<1?bar:1),1,0.0f);
1154 glVertex3f(0,1,0.0f);
1156 glColor4f(0.4,0.0,0.0,0.7);
1157 bar = ((float)player[0].superpermanentdamage)/player[0].damagetolerance;
1159 glVertex3f(0,0,0.0f);
1160 glVertex3f((bar<1?bar:1),0,0.0f);
1161 glVertex3f((bar<1?bar:1),1,0.0f);
1162 glVertex3f(0,1,0.0f);
1164 glColor4f(0.0,0.0,0.0,0.7);
1166 glBegin(GL_LINE_STRIP);
1167 glVertex3f(0,0,0.0f);
1168 glVertex3f(1,0,0.0f);
1169 glVertex3f(1,1,0.0f);
1170 glVertex3f(0,1,0.0f);
1171 glVertex3f(0,0,0.0f);
1174 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1175 glPopMatrix(); // Restore The Old Projection Matrix
1176 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1177 glPopMatrix(); // Restore The Old Projection Matrix
1178 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1179 glEnable(GL_CULL_FACE);
1180 glDisable(GL_BLEND);
1182 glEnable(GL_TEXTURE_2D);
1184 // writing the numbers :
1185 sprintf (string, "Damages : %d/%d (%d)",(int)(player[0].damage),(int)(player[0].damagetolerance),(int)(player[0].bloodloss));
1187 text.glPrintOutline(1024/40-4,768/16-4+768*14/16-40,string,1,1.5*1.25,1024,768);
1189 text.glPrint(1024/40,768/16+768*14/16-40,string,1,1.5,1024,768);
1193 glColor4f(.5,.5,.5,1);
1196 if((texttoggle||editorenabled)&&debugmode&&!mainmenu){
1197 sprintf (string, "The framespersecond is %d.",(int)(fps));
1198 text.glPrint(10,30,string,0,.8,1024,768);
1200 sprintf (string, "Name: %s", registrationname);
1201 text.glPrint(10,260,string,0,.8,1024,768);
1205 sprintf (string, "Map editor enabled.");
1207 sprintf (string, "Map editor disabled.");
1208 text.glPrint(10,60,string,0,.8,1024,768);
1210 sprintf (string, "Object size: %f",editorsize);
1211 text.glPrint(10,75,string,0,.8,1024,768);
1212 if(editorrotation>=0)sprintf (string, "Object rotation: %f",editorrotation);
1213 else sprintf (string, "Object rotation: Random");
1214 text.glPrint(10,90,string,0,.8,1024,768);
1215 if(editorrotation2>=0)sprintf (string, "Object rotation2: %f",editorrotation2);
1216 else sprintf (string, "Object rotation2: Random");
1217 text.glPrint(10,105,string,0,.8,1024,768);
1218 sprintf (string, "Object type: %d",editortype);
1219 text.glPrint(10,120,string,0,.8,1024,768);
1220 switch(editortype) {
1222 sprintf (string, "(box)");
1225 sprintf (string, "(tree)");
1228 sprintf (string, "(wall)");
1231 sprintf (string, "(weird)");
1234 sprintf (string, "(spike)");
1237 sprintf (string, "(rock)");
1240 sprintf (string, "(bush)");
1243 sprintf (string, "(tunnel)");
1246 sprintf (string, "(chimney)");
1249 sprintf (string, "(platform)");
1252 sprintf (string, "(cool)");
1255 sprintf (string, "(fire)");
1258 text.glPrint(130,120,string,0,.8,1024,768);
1260 sprintf (string, "Numplayers: %d",numplayers);
1261 text.glPrint(10,155,string,0,.8,1024,768);
1262 sprintf (string, "Player %d: numwaypoints: %d",numplayers,player[numplayers-1].numwaypoints);
1263 text.glPrint(10,140,string,0,.8,1024,768);
1265 sprintf (string, "Difficulty: %d",difficulty);
1266 text.glPrint(10,240,string,0,.8,1024,768);
1271 if(drawmode==glowmode){
1272 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1273 glDisable(GL_CULL_FACE);
1274 glDisable(GL_LIGHTING);
1275 glDisable(GL_TEXTURE_2D);
1277 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1278 glPushMatrix(); // Store The Projection Matrix
1279 glLoadIdentity(); // Reset The Projection Matrix
1280 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1281 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1282 glPushMatrix(); // Store The Modelview Matrix
1283 glLoadIdentity(); // Reset The Modelview Matrix
1284 glScalef(screenwidth,screenheight,1);
1285 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1287 glColor4f(0,0,0,.5);
1289 glVertex3f(0, 0, 0.0f);
1290 glVertex3f(256, 0, 0.0f);
1291 glVertex3f(256, 256, 0.0f);
1292 glVertex3f(0, 256, 0.0f);
1294 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1295 glPopMatrix(); // Restore The Old Projection Matrix
1296 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1297 glPopMatrix(); // Restore The Old Projection Matrix
1298 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1299 glEnable(GL_CULL_FACE);
1300 glDisable(GL_BLEND);
1304 if((((blackout&&damageeffects)||(player[0].bloodloss>0&&damageeffects&&player[0].blooddimamount>0)||player[0].dead)&&!cameramode)||console){
1305 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1306 glDisable(GL_CULL_FACE);
1307 glDisable(GL_LIGHTING);
1308 glDisable(GL_TEXTURE_2D);
1310 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1311 glPushMatrix(); // Store The Projection Matrix
1312 glLoadIdentity(); // Reset The Projection Matrix
1313 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1314 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1315 glPushMatrix(); // Store The Modelview Matrix
1316 glLoadIdentity(); // Reset The Modelview Matrix
1317 glScalef(screenwidth,screenheight,1);
1318 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1320 if(player[0].dead)blackout+=multiplier*3;
1321 if(player[0].dead==1)blackout=.4f;
1322 if(player[0].dead==2&&blackout>.6)blackout=.6;
1323 glColor4f(0,0,0,blackout);
1324 if(!player[0].dead){
1325 if((player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5))*.3<.3){
1326 glColor4f(0,0,0,player[0].blooddimamount*player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5)*.3);
1327 blackout=player[0].blooddimamount*player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5)*.3;
1330 glColor4f(0,0,0,player[0].blooddimamount*.3);
1331 blackout=player[0].blooddimamount*.3;
1334 if(console)glColor4f(.7,0,0,.2);
1336 glVertex3f(0, 0, 0.0f);
1337 glVertex3f(256, 0, 0.0f);
1338 glVertex3f(256, 256, 0.0f);
1339 glVertex3f(0, 256, 0.0f);
1341 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1342 glPopMatrix(); // Restore The Old Projection Matrix
1343 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1344 glPopMatrix(); // Restore The Old Projection Matrix
1345 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1346 glEnable(GL_CULL_FACE);
1347 glDisable(GL_BLEND);
1351 if(flashamount>0&&damageeffects){
1352 if(flashamount>1)flashamount=1;
1353 if(flashdelay<=0)flashamount-=multiplier;
1355 if(flashamount<0)flashamount=0;
1356 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1357 glDisable(GL_CULL_FACE);
1358 glDisable(GL_LIGHTING);
1360 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1361 glPushMatrix(); // Store The Projection Matrix
1362 glLoadIdentity(); // Reset The Projection Matrix
1363 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1364 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1365 glPushMatrix(); // Store The Modelview Matrix
1366 glLoadIdentity(); // Reset The Modelview Matrix
1367 glScalef(screenwidth,screenheight,1);
1368 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1370 glColor4f(flashr,flashg,flashb,flashamount);
1372 glVertex3f(0, 0, 0.0f);
1373 glVertex3f(256, 0, 0.0f);
1374 glVertex3f(256, 256, 0.0f);
1375 glVertex3f(0, 256, 0.0f);
1377 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1378 glPopMatrix(); // Restore The Old Projection Matrix
1379 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1380 glPopMatrix(); // Restore The Old Projection Matrix
1381 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1382 glEnable(GL_CULL_FACE);
1383 glDisable(GL_BLEND);
1389 glEnable(GL_TEXTURE_2D);
1392 sprintf (string, " ]");
1393 text.glPrint(10,30+screenheight-330,string,0,1,screenwidth,screenheight);
1395 sprintf (string, "_");
1396 text.glPrint(30+(float)(displayselected)*10,30+(screenheight-330),string,0,1,screenwidth,screenheight);
1400 if((i!=0||chatting)&&displaytime[i]<4)
1401 for(j=0;j<displaychars[i];j++){
1402 glColor4f(1,1,1,4-displaytime[i]);
1403 if(j<displaychars[i]){
1404 sprintf (string, "%c",displaytext[i][j]);
1405 text.glPrint(30+j*10,30+i*20+(screenheight-330),string,0,1,screenwidth,screenheight);
1411 if(minimap&&indialogue==-1){
1412 float mapviewdist = 20000;
1414 glDisable(GL_DEPTH_TEST);
1415 glColor3f (1.0, 1.0, 1.0); // no coloring
1417 glEnable(GL_TEXTURE_2D);
1418 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1419 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1420 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1421 glDisable(GL_CULL_FACE);
1422 glDisable(GL_LIGHTING);
1424 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1425 glPushMatrix(); // Store The Projection Matrix
1426 glLoadIdentity(); // Reset The Projection Matrix
1427 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1428 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1429 glPushMatrix(); // Store The Modelview Matrix
1430 glLoadIdentity(); // Reset The Modelview Matrix
1431 glScalef((float)screenwidth/2,(float)screenwidth/2,1);
1432 glTranslatef(1.75,.25,0);
1433 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1441 int numliveplayers=0;
1443 for(i=0;i<numplayers;i++){
1444 if(!player[i].dead) numliveplayers++;
1449 for(i=0;i<objects.numobjects;i++){
1450 if(objects.type[i]==treetrunktype||objects.type[i]==boxtype){
1451 center+=objects.position[i];
1455 for(i=0;i<numplayers;i++){
1456 if(!player[i].dead)center+=player[i].coords;
1458 center/=numadd+numliveplayers;
1460 center=player[0].coords;
1462 float maxdistance=0;
1465 for(i=0;i<objects.numobjects;i++){
1466 tempdist=findDistancefast(¢er,&objects.position[i]);
1467 if(tempdist>maxdistance){
1469 maxdistance=tempdist;
1472 for(i=0;i<numplayers;i++){
1473 if(!player[i].dead){
1474 tempdist=findDistancefast(¢er,&player[i].coords);
1475 if(tempdist>maxdistance){
1477 maxdistance=tempdist;
1481 radius=fast_sqrt(maxdistance);
1485 glScalef(.25/radius*256*terrain.scale*.4,.25/radius*256*terrain.scale*.4,1);
1487 glScalef(1/(1/radius*256*terrain.scale*.4),1/(1/radius*256*terrain.scale*.4),1);
1489 glRotatef(player[0].lookrotation*-1+180,0,0,1);
1490 glTranslatef(-(center.x/terrain.scale/256*-2+1),(center.z/terrain.scale/256*-2+1),0);
1491 for(i=0;i<objects.numobjects;i++){
1492 if(objects.type[i]==treetrunktype){
1493 distcheck=findDistancefast(&player[0].coords,&objects.position[i]);
1494 if(distcheck<mapviewdist){
1495 glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
1496 glColor4f(0,.3,0,opac*(1-distcheck/mapviewdist));
1498 glTranslatef(objects.position[i].x/terrain.scale/256*-2+1,objects.position[i].z/terrain.scale/256*2-1,0);
1499 glRotatef(objects.rotation[i],0,0,1);
1500 glScalef(.003,.003,.003);
1503 glVertex3f(-1, -1, 0.0f);
1505 glVertex3f(1, -1, 0.0f);
1507 glVertex3f(1, 1, 0.0f);
1509 glVertex3f(-1, 1, 0.0f);
1514 if(objects.type[i]==boxtype){
1515 distcheck=findDistancefast(&player[0].coords,&objects.position[i]);
1516 if(distcheck<mapviewdist){
1517 glBindTexture( GL_TEXTURE_2D, Mapboxtexture);
1518 glColor4f(.4,.4,.4,opac*(1-distcheck/mapviewdist));
1520 glTranslatef(objects.position[i].x/terrain.scale/256*-2+1,objects.position[i].z/terrain.scale/256*2-1,0);
1521 glRotatef(objects.rotation[i],0,0,1);
1522 glScalef(.01*objects.scale[i],.01*objects.scale[i],.01*objects.scale[i]);
1525 glVertex3f(-1, -1, 0.0f);
1527 glVertex3f(1, -1, 0.0f);
1529 glVertex3f(1, 1, 0.0f);
1531 glVertex3f(-1, 1, 0.0f);
1538 glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
1539 for(i=0;i<numboundaries;i++){
1540 glColor4f(0,0,0,opac/3);
1542 glTranslatef(boundary[i].x/terrain.scale/256*-2+1,boundary[i].z/terrain.scale/256*2-1,0);
1543 glScalef(.002,.002,.002);
1546 glVertex3f(-1, -1, 0.0f);
1548 glVertex3f(1, -1, 0.0f);
1550 glVertex3f(1, 1, 0.0f);
1552 glVertex3f(-1, 1, 0.0f);
1557 for(i=0;i<numplayers;i++){
1558 distcheck=findDistancefast(&player[0].coords,&player[i].coords);
1559 if(distcheck<mapviewdist){
1561 glBindTexture( GL_TEXTURE_2D, Maparrowtexture);
1562 if(i==0)glColor4f(1,1,1,opac);
1563 else if(player[i].dead==2||player[i].howactive>typesleeping)glColor4f(0,0,0,opac*(1-distcheck/mapviewdist));
1564 else if(player[i].dead)glColor4f(.3,.3,.3,opac*(1-distcheck/mapviewdist));
1565 else if(player[i].aitype==attacktypecutoff)glColor4f(1,0,0,opac*(1-distcheck/mapviewdist));
1566 else if(player[i].aitype==passivetype)glColor4f(0,1,0,opac*(1-distcheck/mapviewdist));
1567 else glColor4f(1,1,0,1);
1568 glTranslatef(player[i].coords.x/terrain.scale/256*-2+1,player[i].coords.z/terrain.scale/256*2-1,0);
1569 glRotatef(player[i].rotation+180,0,0,1);
1570 glScalef(.005,.005,.005);
1573 glVertex3f(-1, -1, 0.0f);
1575 glVertex3f(1, -1, 0.0f);
1577 glVertex3f(1, 1, 0.0f);
1579 glVertex3f(-1, 1, 0.0f);
1585 glDisable(GL_TEXTURE_2D);
1586 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1587 glPopMatrix(); // Restore The Old Projection Matrix
1588 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1589 glPopMatrix(); // Restore The Old Projection Matrix
1590 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1591 glEnable(GL_CULL_FACE);
1592 glDisable(GL_BLEND);
1596 if(loading&&!stealthloading&&(!campaign||player[0].dead)){
1597 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1598 glDisable(GL_CULL_FACE);
1599 glDisable(GL_LIGHTING);
1600 glDisable(GL_TEXTURE_2D);
1602 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1603 glPushMatrix(); // Store The Projection Matrix
1604 glLoadIdentity(); // Reset The Projection Matrix
1605 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1606 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1607 glPushMatrix(); // Store The Modelview Matrix
1608 glLoadIdentity(); // Reset The Modelview Matrix
1609 glScalef(screenwidth,screenheight,1);
1610 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1612 glColor4f(0,0,0,.7);
1614 glVertex3f(0, 0, 0.0f);
1615 glVertex3f(256, 0, 0.0f);
1616 glVertex3f(256, 256, 0.0f);
1617 glVertex3f(0, 256, 0.0f);
1619 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1620 glPopMatrix(); // Restore The Old Projection Matrix
1621 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1622 glPopMatrix(); // Restore The Old Projection Matrix
1623 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1624 glEnable(GL_CULL_FACE);
1625 glDisable(GL_BLEND);
1629 glDisable(GL_DEPTH_TEST);
1630 glColor3f (1.0, 1.0, 1.0); // no coloring
1632 glEnable(GL_TEXTURE_2D);
1637 glEnable(GL_TEXTURE_2D);
1639 sprintf (string, "Loading...");
1640 text.glPrint(1024/2-90,768/2,string,1,2,1024,768);
1643 //if(ismotionblur)drawmode=motionblurmode;
1644 drawmode=normalmode;
1647 if(winfreeze&&!campaign){
1648 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1649 glDisable(GL_CULL_FACE);
1650 glDisable(GL_LIGHTING);
1651 glDisable(GL_TEXTURE_2D);
1653 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1654 glPushMatrix(); // Store The Projection Matrix
1655 glLoadIdentity(); // Reset The Projection Matrix
1656 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1657 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1658 glPushMatrix(); // Store The Modelview Matrix
1659 glLoadIdentity(); // Reset The Modelview Matrix
1660 glScalef(screenwidth,screenheight,1);
1661 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1663 glColor4f(0,0,0,.4);
1665 glVertex3f(0, 0, 0.0f);
1666 glVertex3f(256, 0, 0.0f);
1667 glVertex3f(256, 256, 0.0f);
1668 glVertex3f(0, 256, 0.0f);
1670 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1671 glPopMatrix(); // Restore The Old Projection Matrix
1672 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1673 glPopMatrix(); // Restore The Old Projection Matrix
1674 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1675 glEnable(GL_CULL_FACE);
1676 glDisable(GL_BLEND);
1680 glDisable(GL_DEPTH_TEST);
1681 glColor3f (1.0, 1.0, 1.0); // no coloring
1683 glEnable(GL_TEXTURE_2D);
1685 //Win Screen Won Victory
1687 glEnable(GL_TEXTURE_2D);
1689 sprintf (string, "Level Cleared!");
1690 text.glPrintOutlined(1024/2-strlen(string)*10,768*7/8,string,1,2,1024,768);
1692 sprintf (string, "Score: %d",(int)(bonustotal-startbonustotal));
1693 text.glPrintOutlined(1024/30,768*6/8,string,1,2,1024,768);
1696 sprintf (string, "Press Escape or Space to continue");
1698 sprintf (string, "Press Escape to return to menu or Space to continue");
1699 text.glPrintOutlined(640/2-strlen(string)*5,480*1/16,string,1,1,640,480);
1703 for(i=0;i<255;i++)string[i]='\0';
1704 sprintf (temp, "Time: %d:",(int)(((int)leveltime-(int)(leveltime)%60)/60));
1705 strcat(string,temp);
1706 if((int)(leveltime)%60<10)strcat(string,"0");
1707 sprintf (temp, "%d",(int)(leveltime)%60);
1708 strcat(string,temp);
1709 text.glPrintOutlined(1024/30,768*6/8-40,string,1,2,1024,768);
1712 int awards[award_count];
1713 int numawards = award_awards(awards);
1715 for (i = 0; i < numawards && i < 6; i++)
1716 text.glPrintOutlined(1024/30,768*6/8-90-40*i,award_names[awards[i]],1,2,1024,768);
1719 if(drawmode!=normalmode){
1720 glEnable(GL_TEXTURE_2D);
1722 if(!drawtoggle||drawmode!=realmotionblurmode||(drawtoggle==2||change==1)){
1725 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
1726 GLfloat subtractColor[4] = { 0.5, 0.5, 0.5, 0.0 };
1727 glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, subtractColor);
1728 //glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_SUBTRACT);
1729 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE);
1730 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_CONSTANT_EXT);
1731 glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 2.0f);
1733 glBindTexture( GL_TEXTURE_2D, screentexture);
1734 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1737 if((drawtoggle||change==1)&&drawmode==realmotionblurmode){
1739 glBindTexture( GL_TEXTURE_2D, screentexture2);
1740 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1742 if(!screentexture2){
1743 glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
1745 glGenTextures( 1, &screentexture2 );
1746 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
1748 glEnable(GL_TEXTURE_2D);
1749 glBindTexture( GL_TEXTURE_2D, screentexture2);
1750 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
1751 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
1753 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
1759 glClear(GL_DEPTH_BUFFER_BIT);
1760 ReSizeGLScene(90,.1f);
1761 glViewport(0,0,screenwidth,screenheight);
1763 if(drawmode!=normalmode){
1764 glDisable(GL_DEPTH_TEST);
1765 if(drawmode==motionblurmode){
1766 glDrawBuffer(GL_FRONT);
1767 glReadBuffer(GL_BACK);
1769 glColor3f (1.0, 1.0, 1.0); // no coloring
1771 glEnable(GL_TEXTURE_2D);
1772 glBindTexture( GL_TEXTURE_2D, screentexture);
1773 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1774 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1775 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1776 glDisable(GL_CULL_FACE);
1777 glDisable(GL_LIGHTING);
1779 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1780 glPushMatrix(); // Store The Projection Matrix
1781 glLoadIdentity(); // Reset The Projection Matrix
1782 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1783 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1784 glPushMatrix(); // Store The Modelview Matrix
1785 glLoadIdentity(); // Reset The Modelview Matrix
1786 glScalef((float)screenwidth/2,(float)screenheight/2,1);
1787 glTranslatef(1,1,0);
1788 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1790 if(drawmode==motionblurmode){
1791 if(motionbluramount<.2)motionbluramount=.2;
1792 //glColor4f(1,1,1,fast_sqrt(multiplier)*2.9*motionbluramount);
1793 glColor4f(1,1,1,motionbluramount);
1797 glVertex3f(-1, -1, 0.0f);
1798 glTexCoord2f(texcoordwidth,0);
1799 glVertex3f(1, -1, 0.0f);
1800 glTexCoord2f(texcoordwidth,texcoordheight);
1801 glVertex3f(1, 1, 0.0f);
1802 glTexCoord2f(0,texcoordheight);
1803 glVertex3f(-1, 1, 0.0f);
1807 if(drawmode==realmotionblurmode){
1808 glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
1809 glClear(GL_COLOR_BUFFER_BIT);
1810 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
1811 glBindTexture( GL_TEXTURE_2D, screentexture);
1812 glColor4f(1,1,1,.5);
1816 glVertex3f(-1, -1, 0.0f);
1817 glTexCoord2f(texcoordwidth,0);
1818 glVertex3f(1, -1, 0.0f);
1819 glTexCoord2f(texcoordwidth,texcoordheight);
1820 glVertex3f(1, 1, 0.0f);
1821 glTexCoord2f(0,texcoordheight);
1822 glVertex3f(-1, 1, 0.0f);
1825 glBindTexture( GL_TEXTURE_2D, screentexture2);
1826 glColor4f(1,1,1,.5);
1830 glVertex3f(-1, -1, 0.0f);
1831 glTexCoord2f(texcoordwidth,0);
1832 glVertex3f(1, -1, 0.0f);
1833 glTexCoord2f(texcoordwidth,texcoordheight);
1834 glVertex3f(1, 1, 0.0f);
1835 glTexCoord2f(0,texcoordheight);
1836 glVertex3f(-1, 1, 0.0f);
1839 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1841 if(drawmode==doublevisionmode){
1842 static float crosseyedness;
1843 crosseyedness=abs(player[0].damage-player[0].superpermanentdamage-(player[0].damagetolerance-player[0].superpermanentdamage)*1/2)/30;
1844 if(crosseyedness>1)crosseyedness=1;
1845 if(crosseyedness<0)crosseyedness=0;
1847 glDisable(GL_BLEND);
1852 glVertex3f(-1, -1, 0.0f);
1853 glTexCoord2f(texcoordwidth,0);
1854 glVertex3f(1, -1, 0.0f);
1855 glTexCoord2f(texcoordwidth,texcoordheight);
1856 glVertex3f(1, 1, 0.0f);
1857 glTexCoord2f(0,texcoordheight);
1858 glVertex3f(-1, 1, 0.0f);
1862 glColor4f(1,1,1,.5);
1865 glTranslatef(.015*crosseyedness,0,0);
1869 glVertex3f(-1, -1, 0.0f);
1870 glTexCoord2f(texcoordwidth,0);
1871 glVertex3f(1, -1, 0.0f);
1872 glTexCoord2f(texcoordwidth,texcoordheight);
1873 glVertex3f(1, 1, 0.0f);
1874 glTexCoord2f(0,texcoordheight);
1875 glVertex3f(-1, 1, 0.0f);
1880 if(drawmode==glowmode){
1881 glColor4f(.5,.5,.5,.5);
1883 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
1885 glTranslatef(.01,0,0);
1888 glVertex3f(-1, -1, 0.0f);
1889 glTexCoord2f(texcoordwidth,0);
1890 glVertex3f(1, -1, 0.0f);
1891 glTexCoord2f(texcoordwidth,texcoordheight);
1892 glVertex3f(1, 1, 0.0f);
1893 glTexCoord2f(0,texcoordheight);
1894 glVertex3f(-1, 1, 0.0f);
1898 glTranslatef(-.01,0,0);
1901 glVertex3f(-1, -1, 0.0f);
1902 glTexCoord2f(texcoordwidth,0);
1903 glVertex3f(1, -1, 0.0f);
1904 glTexCoord2f(texcoordwidth,texcoordheight);
1905 glVertex3f(1, 1, 0.0f);
1906 glTexCoord2f(0,texcoordheight);
1907 glVertex3f(-1, 1, 0.0f);
1911 glTranslatef(.0,.01,0);
1914 glVertex3f(-1, -1, 0.0f);
1915 glTexCoord2f(texcoordwidth,0);
1916 glVertex3f(1, -1, 0.0f);
1917 glTexCoord2f(texcoordwidth,texcoordheight);
1918 glVertex3f(1, 1, 0.0f);
1919 glTexCoord2f(0,texcoordheight);
1920 glVertex3f(-1, 1, 0.0f);
1924 glTranslatef(0,-.01,0);
1927 glVertex3f(-1, -1, 0.0f);
1928 glTexCoord2f(texcoordwidth,0);
1929 glVertex3f(1, -1, 0.0f);
1930 glTexCoord2f(texcoordwidth,texcoordheight);
1931 glVertex3f(1, 1, 0.0f);
1932 glTexCoord2f(0,texcoordheight);
1933 glVertex3f(-1, 1, 0.0f);
1937 if(drawmode==radialzoommode){
1939 //glRotatef((float)i*.1,0,0,1);
1940 glColor4f(1,1,1,1/((float)i+1));
1942 glScalef(1+(float)i*.01,1+(float)i*.01,1);
1945 glVertex3f(-1, -1, 0.0f);
1946 glTexCoord2f(texcoordwidth,0);
1947 glVertex3f(1, -1, 0.0f);
1948 glTexCoord2f(texcoordwidth,texcoordheight);
1949 glVertex3f(1, 1, 0.0f);
1950 glTexCoord2f(0,texcoordheight);
1951 glVertex3f(-1, 1, 0.0f);
1956 glDisable(GL_TEXTURE_2D);
1957 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1958 glPopMatrix(); // Restore The Old Projection Matrix
1959 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1960 glPopMatrix(); // Restore The Old Projection Matrix
1961 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1962 glEnable(GL_CULL_FACE);
1963 glDisable(GL_BLEND);
1968 glEnable(GL_TEXTURE_2D);
1971 if(consoleselected>=60)
1972 offset=consoleselected-60;
1973 sprintf (string, " ]");
1974 text.glPrint(10,30,string,0,1,1024,768);
1976 sprintf (string, "_");
1977 text.glPrint(30+(float)(consoleselected)*10-offset*10,30,string,0,1,1024,768);
1980 for(j=0;j<consolechars[i];j++){
1981 glColor4f(1,1,1,1-(float)(i)/16);
1982 if(j<consolechars[i]){
1983 sprintf (string, "%c",consoletext[i][j]);
1984 text.glPrint(30+j*10-offset*10,30+i*20,string,0,1,1024,768);
1991 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)||(mainmenu&&gameon)||(!gameon&&gamestarted)||(!gameon&&gamestarted)){
1992 multiplier=tempmult;
1997 // !!! FIXME: hack: clamp framerate in menu so text input works correctly on fast systems.
2000 glDrawBuffer(GL_BACK);
2001 glReadBuffer(GL_BACK);
2002 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
2003 ReSizeGLScene(90,.1f);
2006 temptexdetail=texdetail;
2007 if(texdetail>2)texdetail=2;
2008 if(mainmenu!=oldmainmenu&&oldmainmenu!=0){
2010 LoadTexture(":Data:Textures:Newgame.png",&Mainmenuitems[1],0,0);
2011 LoadTexture(":Data:Textures:Quit.png",&Mainmenuitems[3],0,0);
2014 LoadTexture(":Data:Textures:Resume.png",&Mainmenuitems[1],0,0);
2015 LoadTexture(":Data:Textures:Endgame.png",&Mainmenuitems[3],0,0);
2018 if(lastcheck>.5||oldmainmenu!=mainmenu){
2020 ifstream ipstream(ConvertFileName(":Data:Campaigns:main.txt"));
2021 ipstream.ignore(256,':');
2022 ipstream >> campaignnumlevels;
2023 for(i=0;i<campaignnumlevels;i++){
2024 ipstream.ignore(256,':');
2025 ipstream.ignore(256,':');
2026 ipstream.ignore(256,' ');
2027 ipstream >> campaignmapname[i];
2028 ipstream.ignore(256,':');
2029 ipstream >> campaigndescription[i];
2031 if(campaigndescription[i][j]=='_')campaigndescription[i][j]=' ';
2033 ipstream.ignore(256,':');
2034 ipstream >> campaignchoosenext[i];
2035 ipstream.ignore(256,':');
2036 ipstream >> campaignnumnext[i];
2037 for(j=0;j<campaignnumnext[i];j++){
2038 ipstream.ignore(256,':');
2039 ipstream >> campaignnextlevel[i][j];
2040 campaignnextlevel[i][j]-=1;
2042 ipstream.ignore(256,':');
2043 ipstream >> campaignlocationx[i];
2044 ipstream.ignore(256,':');
2045 ipstream >> campaignlocationy[i];
2049 for(i=0;i<campaignnumlevels;i++){
2051 levelhighlight[i]=0;
2056 for(i=0;i<accountactive->getCampaignChoicesMade();i++){
2057 levelorder[i+1]=campaignnextlevel[levelorder[i]][accountactive->getCampaignChoice(i)];
2058 levelvisible[levelorder[i+1]]=1;
2060 int whichlevelstart = accountactive->getCampaignChoicesMade()-1;
2061 if(whichlevelstart<0){
2062 accountactive->setCampaignScore(0);
2063 accountactive->resetFasttime();
2064 campaignchoicenum=1;
2065 campaignchoicewhich[0]=0;
2069 campaignchoicenum=campaignnumnext[levelorder[whichlevelstart]];
2070 for(i=0;i<campaignchoicenum;i++){
2071 campaignchoicewhich[i]=campaignnextlevel[levelorder[whichlevelstart]][i];
2072 levelvisible[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
2073 levelhighlight[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
2082 texdetail=temptexdetail;
2084 oldmainmenu=mainmenu;
2086 if(mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==8||mainmenu==9||mainmenu==10||mainmenu==119||mainmenu==18){
2087 glClear(GL_DEPTH_BUFFER_BIT);
2088 glEnable(GL_ALPHA_TEST);
2089 glAlphaFunc(GL_GREATER, 0.001f);
2090 glEnable(GL_TEXTURE_2D);
2091 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
2092 glDisable(GL_CULL_FACE);
2093 glDisable(GL_LIGHTING);
2095 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2096 glPushMatrix(); // Store The Projection Matrix
2097 glLoadIdentity(); // Reset The Projection Matrix
2098 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
2099 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2100 glPushMatrix(); // Store The Modelview Matrix
2101 glLoadIdentity(); // Reset The Modelview Matrix
2102 glTranslatef(screenwidth/2,screenheight/2,0);
2104 glScalef((float)screenwidth/2,(float)screenheight/2,1);
2105 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
2106 glDisable(GL_BLEND);
2107 glColor4f(0,0,0,1.0);
2108 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2109 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2110 glDisable(GL_TEXTURE_2D);
2112 //glScalef(.25,.25,.25);
2115 glVertex3f(-1, -1, 0.0f);
2117 glVertex3f(1, -1, 0.0f);
2119 glVertex3f(1, 1, 0.0f);
2121 glVertex3f(-1, 1, 0.0f);
2125 glColor4f(0.4,0.4,0.4,1.0);
2126 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2127 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2128 glEnable(GL_TEXTURE_2D);
2129 glBindTexture( GL_TEXTURE_2D, Mainmenuitems[4]);
2131 //glScalef(.25,.25,.25);
2134 glVertex3f(-1, -1, 0.0f);
2136 glVertex3f(1, -1, 0.0f);
2138 glVertex3f(1, 1, 0.0f);
2140 glVertex3f(-1, 1, 0.0f);
2145 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2147 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2151 if((float)newscreenwidth>(float)newscreenheight*1.61||(float)newscreenwidth<(float)newscreenheight*1.59)sprintf (menustring[0], "Resolution: %d*%d",(int)newscreenwidth,(int)newscreenheight);
2152 else sprintf (menustring[0], "Resolution: %d*%d (widescreen)",(int)newscreenwidth,(int)newscreenheight);
2155 endx[0]=startx[0]+strlen(menustring[0])*10;
2156 endy[0]=starty[0]+20;
2160 if(newdetail==2)sprintf (menustring[1], "Detail: High");
2161 else if(newdetail==1)sprintf (menustring[1], "Detail: Medium");
2162 else sprintf (menustring[1], "Detail: Low");
2165 endx[1]=startx[1]+strlen(menustring[1])*10;
2166 endy[1]=starty[1]+20;
2170 if(bloodtoggle==2)sprintf (menustring[2], "Blood: On, high detail (slower)");
2171 if(bloodtoggle==1)sprintf (menustring[2], "Blood: On, low detail");
2172 if(bloodtoggle==0)sprintf (menustring[2], "Blood: Off");
2175 endx[2]=startx[2]+strlen(menustring[2])*10;
2176 endy[2]=starty[2]+20;
2180 if(difficulty==2)sprintf (menustring[3], "Difficulty: Insane");
2181 if(difficulty==1)sprintf (menustring[3], "Difficulty: Difficult");
2182 if(difficulty==0)sprintf (menustring[3], "Difficulty: Easier");
2183 startx[3]=10+20-1000;
2185 endx[3]=startx[3]+strlen(menustring[3])*10;
2186 endy[3]=starty[3]+20;
2190 if(ismotionblur==1)sprintf (menustring[4], "Blur Effects: Enabled (less compatible)");
2191 if(ismotionblur==0)sprintf (menustring[4], "Blur Effects: Disabled (more compatible)");
2194 endx[4]=startx[4]+strlen(menustring[4])*10;
2195 endy[4]=starty[4]+20;
2199 if(decals==1)sprintf (menustring[5], "Decals: Enabled (slower)");
2200 if(decals==0)sprintf (menustring[5], "Decals: Disabled");
2203 endx[5]=startx[5]+strlen(menustring[5])*10;
2204 endy[5]=starty[5]+20;
2208 if(musictoggle==1)sprintf (menustring[6], "Music: Enabled");
2209 if(musictoggle==0)sprintf (menustring[6], "Music: Disabled");
2212 endx[6]=startx[6]+strlen(menustring[6])*10;
2213 endy[6]=starty[6]+20;
2217 if(invertmouse==1)sprintf (menustring[9], "Invert mouse: Yes");
2218 if(invertmouse==0)sprintf (menustring[9], "Invert mouse: No");
2221 endx[9]=startx[9]+strlen(menustring[9])*10;
2222 endy[9]=starty[9]+20;
2226 sprintf (menustring[10], "Mouse Speed: %d", (int)(usermousesensitivity*5));
2229 endx[10]=startx[10]+strlen(menustring[10])*10;
2230 endy[10]=starty[10]+20;
2234 sprintf (menustring[11], "Volume: %d%%", (int)(volume*100));
2237 endx[11]=startx[11]+strlen(menustring[11])*10;
2238 endy[11]=starty[11]+20;
2242 sprintf (menustring[13], "Damage Bar: %s",(showdamagebar?"on":"off"));
2245 endx[13]=startx[13]+strlen(menustring[13])*10;
2246 endy[13]=starty[13]+20;
2250 sprintf (menustring[7], "-Configure Controls-");
2253 endx[7]=startx[7]+strlen(menustring[7])*10;
2254 endy[7]=starty[7]+20;
2258 sprintf (menustring[12], "-Configure Stereo -");
2261 endx[12]=startx[12]+strlen(menustring[7])*10;
2262 endy[12]=starty[12]+20;
2266 if(newdetail==detail&&newscreenheight==(int)screenheight&&newscreenwidth==(int)screenwidth)sprintf (menustring[8], "Back");
2267 else sprintf (menustring[8], "Back (some changes take effect next time Lugaru is opened)");
2269 endx[8]=startx[8]+strlen(menustring[8])*10;
2271 endy[8]=starty[8]+20;
2278 if(keyselect!=0)sprintf (menustring[0], "Forwards: %s",Input::keyToChar(forwardkey));
2279 else sprintf (menustring[0], "Forwards: _");
2282 endx[0]=startx[0]+strlen(menustring[0])*10;
2283 endy[0]=starty[0]+20;
2287 if(keyselect!=1)sprintf (menustring[1], "Back: %s",Input::keyToChar(backkey));
2288 else sprintf (menustring[1], "Back: _");
2291 endx[1]=startx[1]+strlen(menustring[1])*10;
2292 endy[1]=starty[1]+20;
2296 if(keyselect!=2)sprintf (menustring[2], "Left: %s",Input::keyToChar(leftkey));
2297 else sprintf (menustring[2], "Left: _");
2300 endx[2]=startx[2]+strlen(menustring[2])*10;
2301 endy[2]=starty[2]+20;
2305 if(keyselect!=3)sprintf (menustring[3], "Right: %s",Input::keyToChar(rightkey));
2306 else sprintf (menustring[3], "Right: _");
2309 endx[3]=startx[3]+strlen(menustring[3])*10;
2310 endy[3]=starty[3]+20;
2314 if(keyselect!=4)sprintf (menustring[4], "Crouch: %s",Input::keyToChar(crouchkey));
2315 else sprintf (menustring[4], "Crouch: _");
2318 endx[4]=startx[4]+strlen(menustring[4])*10;
2319 endy[4]=starty[4]+20;
2323 if(keyselect!=5)sprintf (menustring[5], "Jump: %s",Input::keyToChar(jumpkey));
2324 else sprintf (menustring[5], "Jump: _");
2327 endx[5]=startx[5]+strlen(menustring[5])*10;
2328 endy[5]=starty[5]+20;
2332 if(keyselect!=6)sprintf (menustring[6], "Draw: %s",Input::keyToChar(drawkey));
2333 else sprintf (menustring[6], "Draw: _");
2336 endx[6]=startx[6]+strlen(menustring[6])*10;
2337 endy[6]=starty[6]+20;
2341 if(keyselect!=7)sprintf (menustring[7], "Throw: %s",Input::keyToChar(throwkey));
2342 else sprintf (menustring[7], "Throw: _");
2345 endx[7]=startx[7]+strlen(menustring[7])*10;
2346 endy[7]=starty[7]+20;
2350 if(keyselect!=8)sprintf (menustring[8], "Attack: %s",Input::keyToChar(attackkey));
2351 else sprintf (menustring[8], "Attack: _");
2354 endx[8]=startx[8]+strlen(menustring[8])*10;
2355 endy[8]=starty[8]+20;
2361 sprintf (menustring[9], "Back");
2363 endx[9]=startx[9]+strlen(menustring[9])*10;
2365 endy[9]=starty[9]+20;
2370 nummenuitems=7+accountactive->getCampaignChoicesMade()+campaignchoicenum;
2372 sprintf (menustring[0], "%s",accountactive->getName());
2375 endx[0]=startx[0]+strlen(menustring[0])*10;
2376 endy[0]=starty[0]+20;
2380 sprintf (menustring[1], "Tutorial");
2383 endx[1]=startx[1]+strlen(menustring[1])*10;
2384 endy[1]=starty[1]+20;
2388 sprintf (menustring[2], "Challenge");
2391 endx[2]=startx[2]+strlen(menustring[2])*10;
2392 endy[2]=starty[2]+20;
2396 sprintf (menustring[3], "Delete User");
2399 endx[3]=startx[3]+strlen(menustring[3])*10;
2400 endy[3]=starty[3]+20;
2404 sprintf (menustring[4], "Main Menu");
2407 endx[4]=startx[4]+strlen(menustring[4])*10;
2408 endy[4]=starty[4]+20;
2412 sprintf (menustring[5], "Change User");
2414 endx[5]=startx[5]+strlen(menustring[5])*10;
2416 endy[5]=starty[5]+20;
2422 sprintf (menustring[6], "World");
2424 starty[6]=30+480-400-50;
2425 endx[6]=startx[6]+400;
2430 if(accountactive->getCampaignChoicesMade())
2431 for(i=0;i<accountactive->getCampaignChoicesMade();i++){
2432 sprintf (menustring[7+i], "%s", campaigndescription[levelorder[i]]);
2433 startx[7+i]=30+120+campaignlocationx[levelorder[i]]*400/512;
2434 starty[7+i]=30+30+(512-campaignlocationy[levelorder[i]])*400/512;
2435 endx[7+i]=startx[7+i]+10;
2436 endy[7+i]=starty[7+i]+10;
2441 if(campaignchoicenum>0)
2442 for(i=accountactive->getCampaignChoicesMade();i<accountactive->getCampaignChoicesMade()+campaignchoicenum;i++){
2443 sprintf (menustring[7+i], "%s", campaigndescription[levelorder[i]]);
2444 startx[7+i]=30+120+campaignlocationx[campaignchoicewhich[i-(accountactive->getCampaignChoicesMade())]]*400/512;
2445 starty[7+i]=30+30+(512-campaignlocationy[campaignchoicewhich[i-(accountactive->getCampaignChoicesMade())]])*400/512;
2446 endx[7+i]=startx[7+i]+10;
2447 endy[7+i]=starty[7+i]+10;
2452 /*sprintf (menustring[7], "Dot");
2453 startx[7]=120+260*400/512;
2454 starty[7]=30+(512-184)*400/512;
2455 endx[7]=startx[7]+10;
2456 endy[7]=starty[7]+10;
2460 sprintf (menustring[8], "Dot");
2461 startx[8]=120+129*400/512;
2462 starty[8]=30+(512-284)*400/512;
2463 endx[8]=startx[8]+10;
2464 endy[8]=starty[8]+10;
2468 sprintf (menustring[9], "Dot");
2469 startx[9]=120+358*400/512;
2470 starty[9]=30+(512-235)*400/512;
2471 endx[9]=startx[9]+10;
2472 endy[9]=starty[9]+10;
2476 sprintf (menustring[10], "Dot");
2477 startx[10]=120+359*400/512;
2478 starty[10]=30+(512-308)*400/512;
2479 endx[10]=startx[10]+10;
2480 endy[10]=starty[10]+10;
2484 sprintf (menustring[11], "Dot");
2485 startx[11]=120+288*400/512;
2486 starty[11]=30+(512-277)*400/512;
2487 endx[11]=startx[11]+10;
2488 endy[11]=starty[11]+10;
2496 sprintf (menustring[0], "Are you sure you want to delete this user?");
2499 endx[0]=startx[0]+strlen(menustring[0])*10;
2500 endy[0]=starty[0]+20;
2504 sprintf (menustring[1], "Yes");
2507 endx[1]=startx[1]+strlen(menustring[1])*10;
2508 endy[1]=starty[1]+20;
2512 sprintf (menustring[2], "No");
2515 endx[2]=startx[2]+strlen(menustring[2])*10;
2516 endy[2]=starty[2]+20;
2520 sprintf (menustring[3], "Extra 4");
2523 endx[3]=startx[3]+strlen(menustring[3])*10;
2524 endy[3]=starty[3]+20;
2528 sprintf (menustring[4], "Extra 5");
2531 endx[4]=startx[4]+strlen(menustring[4])*10;
2532 endy[4]=starty[4]+20;
2536 sprintf (menustring[5], "Back");
2538 endx[5]=startx[5]+strlen(menustring[5])*10;
2540 endy[5]=starty[5]+20;
2546 nummenuitems=Account::getNbAccounts()+2;
2550 if(Account::getNbAccounts()<8)
2551 sprintf (menustring[0], "New User");
2553 sprintf (menustring[0], "No More Users");
2556 endx[0]=startx[0]+strlen(menustring[0])*10;
2557 endy[0]=starty[0]+20;
2566 for(i=0;i<Account::getNbAccounts();i++){
2567 sprintf (menustring[num], "%s",Account::get(i)->getName());
2569 starty[num]=360-20-20*num;
2570 endx[num]=startx[num]+strlen(menustring[num])*10;
2571 endy[num]=starty[num]+20;
2578 sprintf (menustring[num], "Back");
2580 endx[num]=startx[num]+strlen(menustring[num])*10;
2582 endy[num]=starty[num]+20;
2589 sprintf (menustring[0], "Easier");
2592 endx[0]=startx[0]+strlen(menustring[0])*10;
2593 endy[0]=starty[0]+20;
2597 sprintf (menustring[1], "Difficult");
2600 endx[1]=startx[1]+strlen(menustring[1])*10;
2601 endy[1]=starty[1]+20;
2605 sprintf (menustring[2], "Insane");
2608 endx[2]=startx[2]+strlen(menustring[2])*10;
2609 endy[2]=starty[2]+20;
2615 //tempncl=numchallengelevels;
2616 //numchallengelevels=9;
2617 nummenuitems=2+numchallengelevels;
2620 for(j=0;j<numchallengelevels;j++){
2621 for(i=0;i<255;i++)menustring[j][i]='\0';
2622 sprintf (temp, "Level %d",j+1);
2623 strcpy(menustring[j],temp);
2624 for(i=0;i<17;i++)if(menustring[j][i]=='\0')menustring[j][i]=' ';
2625 menustring[j][17]='\0';
2626 sprintf (temp, "%d",(int)accountactive->getHighScore(j));
2627 strcat(menustring[j],temp);
2628 for(i=18;i<32;i++)if(menustring[j][i]=='\0')menustring[j][i]=' ';
2629 menustring[j][32]='\0';
2630 sprintf (temp, "%d:",(int)(((int)accountactive->getFastTime(j)-(int)(accountactive->getFastTime(j))%60)/60));
2631 strcat(menustring[j],temp);
2632 if((int)(accountactive->getFastTime(j))%60<10)strcat(menustring[j],"0");
2633 sprintf (temp, "%d",(int)(accountactive->getFastTime(j))%60);
2634 strcat(menustring[j],temp);
2638 endx[j]=startx[j]+strlen(menustring[j])*10;
2639 endy[j]=starty[j]+20;
2644 sprintf (menustring[numchallengelevels], "Back");
2645 startx[numchallengelevels]=10;
2646 endx[numchallengelevels]=startx[numchallengelevels]+strlen(menustring[numchallengelevels])*10;
2647 starty[numchallengelevels]=10;
2648 endy[numchallengelevels]=starty[numchallengelevels]+20;
2649 movex[numchallengelevels]=0;
2650 movey[numchallengelevels]=0;
2652 sprintf (menustring[numchallengelevels+1], " High Score Best Time");
2653 startx[numchallengelevels+1]=10;
2654 starty[numchallengelevels+1]=440;
2655 endx[numchallengelevels+1]=startx[numchallengelevels+1]+strlen(menustring[numchallengelevels+1])*10;
2656 endy[numchallengelevels+1]=starty[numchallengelevels+1]+20;
2657 movex[numchallengelevels+1]=0;
2658 movey[numchallengelevels+1]=0;
2660 //numchallengelevels=tempncl;
2667 sprintf (menustring[0], "Congratulations!");
2670 endx[0]=startx[0]+strlen(menustring[0])*10;
2671 endy[0]=starty[0]+20;
2675 sprintf (menustring[1], "You have avenged your family and");
2678 endx[1]=startx[1]+strlen(menustring[1])*10;
2679 endy[1]=starty[1]+20;
2683 sprintf (menustring[2], "restored peace to the island of Lugaru.");
2686 endx[2]=startx[2]+strlen(menustring[2])*10;
2687 endy[2]=starty[2]+20;
2691 sprintf (menustring[3], "Back");
2693 endx[3]=startx[3]+strlen(menustring[3])*10;
2695 endy[3]=starty[3]+20;
2699 for(i=0;i<255;i++)menustring[4][i]='\0';
2700 sprintf (temp, "Your score:");
2701 strcpy(menustring[4],temp);
2702 for(i=0;i<20;i++)if(menustring[4][i]=='\0')menustring[4][i]=' ';
2703 menustring[4][20]='\0';
2704 sprintf (temp, "%d",(int)accountactive->getCampaignScore());
2705 strcat(menustring[4],temp);
2707 endx[4]=startx[4]+strlen(menustring[4])*10;
2709 endy[4]=starty[4]+20;
2713 for(i=0;i<255;i++)menustring[5][i]='\0';
2714 sprintf (temp, "Your time:");
2715 strcpy(menustring[5],temp);
2716 for(i=0;i<20;i++)if(menustring[5][i]=='\0')menustring[5][i]=' ';
2717 menustring[5][20]='\0';
2718 sprintf (temp, "%d",(int)accountcampaigntime[accountactive]);
2719 strcat(menustring[5],temp);
2721 endx[5]=startx[5]+strlen(menustring[5])*10;
2723 endy[5]=starty[5]+20;
2727 for(i=0;i<255;i++)menustring[5][i]='\0';
2728 sprintf (temp, "Highest score:");
2729 strcpy(menustring[5],temp);
2730 for(i=0;i<20;i++)if(menustring[5][i]=='\0')menustring[5][i]=' ';
2731 menustring[5][20]='\0';
2732 sprintf (temp, "%d",(int)accountactive->getCampaignHighScore());
2733 strcat(menustring[5],temp);
2735 endx[5]=startx[5]+strlen(menustring[5])*10;
2737 endy[5]=starty[5]+20;
2741 for(i=0;i<255;i++)menustring[7][i]='\0';
2742 sprintf (temp, "Lowest time:");
2743 strcpy(menustring[7],temp);
2744 for(i=0;i<20;i++)if(menustring[7][i]=='\0')menustring[7][i]=' ';
2745 menustring[7][20]='\0';
2746 sprintf (temp, "%d",(int)accountactive->getCampaignFasttime());
2747 strcat(menustring[7],temp);
2749 endx[7]=startx[7]+strlen(menustring[7])*10;
2751 endy[7]=starty[7]+20;
2757 sprintf (menustring[0], "Stereo mode: %s", StereoModeName(newstereomode));
2760 endx[0]=startx[0]+strlen(menustring[0])*10;
2761 endy[0]=starty[0]+20;
2765 sprintf (menustring[1], "Stereo separation: %.3f", stereoseparation);
2768 endx[1]=startx[1]+strlen(menustring[1])*10;
2769 endy[1]=starty[1]+20;
2773 sprintf (menustring[2], "Reverse stereo: %s", stereoreverse ? "Yes" : "No");
2776 endx[2]=startx[2]+strlen(menustring[2])*10;
2777 endy[2]=starty[2]+20;
2781 sprintf (menustring[3], "Back");
2783 endx[3]=startx[3]+strlen(menustring[3])*10;
2785 endy[3]=starty[3]+20;
2791 if(mainmenu==1||mainmenu==2){
2801 starty[1]=480-152-32;
2808 starty[2]=480-228-32;
2816 starty[3]=480-306-32;
2825 starty[3]=480-306-32;
2839 starty[4]=480-140-256;
2846 starty[5]=480-138-256;
2853 starty[6]=480-144-256;
2861 starty[4]=480-140-256;
2868 starty[5]=480-138-256;
2875 starty[6]=480-144-256;
2883 starty[4]=480-140-256;
2890 starty[5]=480-150-256;
2897 starty[6]=480-144-256;
2905 starty[4]=480-140-256;
2912 starty[5]=480-150-256;
2919 starty[6]=480-144-256;
2927 starty[4]=480-100-256;
2934 starty[5]=480-120-256;
2941 starty[6]=480-144-256;
2951 if(mainmenu==1||mainmenu==2)
2953 if((mousecoordh/screenwidth*640)>startx[i]&&(mousecoordh/screenwidth*640)<endx[i]&&480-(mousecoordv/screenheight*480)>starty[i]&&480-(mousecoordv/screenheight*480)<endy[i]){
2958 if(mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==8||mainmenu==9||mainmenu==10||mainmenu==18)
2959 for(i=0;i<nummenuitems;i++){
2960 if((mousecoordh/screenwidth*640)>startx[i]&&(mousecoordh/screenwidth*640)<endx[i]&&480-(mousecoordv/screenheight*480)>starty[i]&&480-(mousecoordv/screenheight*480)<endy[i]){
2961 if(mainmenu!=5)selected=i;
2962 if(mainmenu==5&&(i!=0&&i!=6))selected=i;
2963 if(mainmenu==9&&(i!=numchallengelevels+1))selected=i; // seem useless, if mainmenu==9 then mainmenu!=5, so selected==i.
2967 for(i=0;i<nummenuitems;i++){
2969 selectedlong[i]+=multiplier*5;
2970 if(selectedlong[i]>1) selectedlong[i]=1;
2972 selectedlong[i]-=multiplier*5;
2973 if(selectedlong[i]<0) selectedlong[i]=0;
2975 offsetx[i]=(startx[i]+endx[i])/2-(mousecoordh/screenwidth*640);
2976 offsety[i]=(starty[i]+endy[i])/2-(480-(mousecoordv/screenheight*480));
2981 if(i>=4&&(mainmenu==1||mainmenu==2)){
2983 offsetx[i]=(startx[i]+endx[i]+movex[i]*transition)/2-(640+190)/2;
2984 offsety[i]=(starty[i]+endy[i]+movey[i]*transition)/2-(336+150)/2;
2990 if(mainmenu==1||mainmenu==2){
2991 glClear(GL_DEPTH_BUFFER_BIT);
2992 glEnable(GL_ALPHA_TEST);
2993 glAlphaFunc(GL_GREATER, 0.001f);
2994 glEnable(GL_TEXTURE_2D);
2995 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
2996 glDisable(GL_CULL_FACE);
2997 glDisable(GL_LIGHTING);
2999 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3000 glPushMatrix(); // Store The Projection Matrix
3001 glLoadIdentity(); // Reset The Projection Matrix
3002 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
3003 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3004 glPushMatrix(); // Store The Modelview Matrix
3005 glLoadIdentity(); // Reset The Modelview Matrix
3006 glTranslatef(screenwidth/2,screenheight/2,0);
3008 glScalef((float)screenwidth/2,(float)screenheight/2,1);
3009 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3010 glDisable(GL_BLEND);
3011 glColor4f(0,0,0,1.0);
3012 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
3013 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
3014 glDisable(GL_TEXTURE_2D);
3016 //glScalef(.25,.25,.25);
3019 glVertex3f(-1, -1, 0.0f);
3021 glVertex3f(1, -1, 0.0f);
3023 glVertex3f(1, 1, 0.0f);
3025 glVertex3f(-1, 1, 0.0f);
3029 glColor4f(0.4,0.4,0.4,1.0);
3030 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
3031 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
3032 glEnable(GL_TEXTURE_2D);
3033 glBindTexture( GL_TEXTURE_2D, Mainmenuitems[4]);
3035 //glScalef(.25,.25,.25);
3038 glVertex3f(-1, -1, 0.0f);
3040 glVertex3f(1, -1, 0.0f);
3042 glVertex3f(1, 1, 0.0f);
3044 glVertex3f(-1, 1, 0.0f);
3049 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3052 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3053 glPushMatrix(); // Store The Projection Matrix
3054 glLoadIdentity(); // Reset The Projection Matrix
3055 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3056 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3057 glPushMatrix(); // Store The Modelview Matrix
3058 glLoadIdentity(); // Reset The Modelview Matrix
3060 glDisable(GL_TEXTURE_2D);
3064 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3066 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3070 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3071 glPushMatrix(); // Store The Projection Matrix
3072 glLoadIdentity(); // Reset The Projection Matrix
3073 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3074 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3075 glPushMatrix(); // Store The Modelview Matrix
3076 glLoadIdentity(); // Reset The Modelview Matrix
3077 glEnable(GL_TEXTURE_2D);
3078 for(j=0;j<nummenuitems;j++)
3080 if(j<=3||(mainmenu!=1&&mainmenu!=2))
3082 //glDisable(GL_BLEND);
3083 glEnable(GL_ALPHA_TEST);
3085 //glDisable(GL_ALPHA_TEST);
3086 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3087 if(mainmenu==1||mainmenu==2)
3090 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3091 glBindTexture( GL_TEXTURE_2D, Mainmenuitems[j]);
3092 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
3093 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
3094 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3098 glVertex3f(startx[j]+movex[j]*transition, starty[j]+movey[j]*transition, 0.0f);
3100 glVertex3f(endx[j]+movex[j]*transition, starty[j]+movey[j]*transition, 0.0f);
3102 glVertex3f(endx[j]+movex[j]*transition, endy[j]+movey[j]*transition, 0.0f);
3104 glVertex3f(startx[j]+movex[j]*transition, endy[j]+movey[j]*transition, 0.0f);
3108 //glDisable(GL_ALPHA_TEST);
3109 if(j<4)glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3112 if(1-((float)i)/10-(1-selectedlong[j])>0)
3114 glColor4f(1,1,1,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3115 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3119 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);
3121 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);
3123 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);
3125 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);
3131 if(mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==8||mainmenu==9||mainmenu==10||mainmenu==18)
3133 if(mainmenu!=5||j<6)
3136 if(mainmenu==9&&j>accountactive->getProgress()&&j<numchallengelevels)glColor4f(0.5,0,0,1);
3137 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3139 if(mainmenu!=7||j!=0||!entername)
3140 text.glPrint(startx[j],starty[j],menustring[j],0,1,640,480);
3144 sprintf (string, "_");
3145 text.glPrint(startx[j]+(float)(displayselected)*10,starty[j],string,0,1,640,480);
3147 for(l=0;l<displaychars[0];l++){
3148 sprintf (string, "%c",displaytext[0][l]);
3149 text.glPrint(startx[j]+l*10,starty[j],string,0,1,640,480);
3154 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3157 if(1-((float)i)/15-(1-selectedlong[j])>0)
3159 glColor4f(1,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3160 if(mainmenu==9&&j>accountactive->getProgress()&&j<numchallengelevels)glColor4f(0.5,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3161 if(mainmenu==11&&j>accountactive->getProgress()&&j<numchallengelevels)glColor4f(0.5,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3162 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);
3163 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);
3164 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);
3165 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);
3166 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);
3167 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);
3168 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);
3169 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);
3170 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);
3176 glClear(GL_DEPTH_BUFFER_BIT);
3177 glEnable(GL_ALPHA_TEST);
3178 glAlphaFunc(GL_GREATER, 0.001f);
3179 glEnable(GL_TEXTURE_2D);
3180 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3181 glDisable(GL_CULL_FACE);
3182 glDisable(GL_LIGHTING);
3183 if(j==6)glColor4f(1,1,1,1);
3184 else glColor4f(1,0,0,1);
3186 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3187 glPushMatrix(); // Store The Projection Matrix
3188 glLoadIdentity(); // Reset The Projection Matrix
3189 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3190 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3191 glPushMatrix(); // Store The Modelview Matrix
3192 glLoadIdentity(); // Reset The Modelview Matrix
3195 //Draw world, draw map
3196 glTranslatef(2,-5,0);
3198 if(j>6&&j<nummenuitems-1)
3200 XYZ linestart,lineend,offset;
3207 //float linestartx,lineendx,linestarty,lineendy,offsetx,offsety;
3208 linestart.x=(startx[j]+endx[j])/2;
3209 linestart.y=(starty[j]+endy[j])/2;
3210 if(j>=6+accountactive->getCampaignChoicesMade()){
3211 linestart.x=(startx[6+accountactive->getCampaignChoicesMade()]+endx[6+accountactive->getCampaignChoicesMade()])/2;
3212 linestart.y=(starty[6+accountactive->getCampaignChoicesMade()]+endy[6+accountactive->getCampaignChoicesMade()])/2;
3214 lineend.x=(startx[j+1]+endx[j+1])/2;
3215 lineend.y=(starty[j+1]+endy[j+1])/2;
3216 offset=lineend-linestart;
3219 offset=DoRotation(offset,0,0,90);
3221 glDisable(GL_TEXTURE_2D);
3223 if(j<6+accountactive->getCampaignChoicesMade()){
3224 glColor4f(0.5,0,0,1);
3232 linestart+=fac*4*startsize;
3233 lineend-=fac*4*endsize;
3235 if(!(j>7+accountactive->getCampaignChoicesMade()+campaignchoicenum)){
3236 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3240 glVertex3f(linestart.x-offset.x*startsize, linestart.y-offset.y*startsize, 0.0f);
3242 glVertex3f(linestart.x+offset.x*startsize, linestart.y+offset.y*startsize, 0.0f);
3244 glVertex3f(lineend.x+offset.x*endsize, lineend.y+offset.y*endsize, 0.0f);
3246 glVertex3f(lineend.x-offset.x*endsize, lineend.y-offset.y*endsize, 0.0f);
3250 glEnable(GL_TEXTURE_2D);
3254 if(j==6)glBindTexture( GL_TEXTURE_2D, Mainmenuitems[7]);
3255 else glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
3256 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
3257 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
3258 if(j-7<accountactive->getCampaignChoicesMade())glColor4f(0.5,0,0,1);
3259 if(j-7>=accountactive->getCampaignChoicesMade())glColor4f(1,0,0,1);
3260 if(j==6)glColor4f(1,1,1,1);
3263 itemsize=abs(startx[j]-endx[j])/2;
3265 midpoint.x=(startx[j]+endx[j])/2;
3266 midpoint.y=(starty[j]+endy[j])/2;
3267 if(j>6&&(j-7<accountactive->getCampaignChoicesMade()))itemsize*=.5;
3268 if(!(j-7>accountactive->getCampaignChoicesMade()+campaignchoicenum))
3270 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3274 glVertex3f(midpoint.x-itemsize+movex[j]*transition, midpoint.y-itemsize+movey[j]*transition, 0.0f);
3276 glVertex3f(midpoint.x+itemsize+movex[j]*transition, midpoint.y-itemsize+movey[j]*transition, 0.0f);
3278 glVertex3f(midpoint.x+itemsize+movex[j]*transition, midpoint.y+itemsize+movey[j]*transition, 0.0f);
3280 glVertex3f(midpoint.x-itemsize+movex[j]*transition, midpoint.y+itemsize+movey[j]*transition, 0.0f);
3284 //glDisable(GL_ALPHA_TEST);
3285 if(j<4)glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3288 if(1-((float)i)/10-(1-selectedlong[j])>0)
3290 glColor4f(1,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3291 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3295 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);
3297 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);
3299 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);
3301 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);
3309 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3311 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3313 if(j-7>=accountactive->getCampaignChoicesMade()){
3314 text.glPrintOutlined(0.9,0,0,startx[j]+10,starty[j]-4,menustring[j],0,0.6,640,480);
3315 glDisable(GL_DEPTH_TEST);
3321 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3323 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3326 if(mainmenu==1||mainmenu==2)
3327 if(transition<.1||transition>.9){
3328 glClear(GL_DEPTH_BUFFER_BIT);
3329 glEnable(GL_ALPHA_TEST);
3330 glAlphaFunc(GL_GREATER, 0.001f);
3331 glEnable(GL_TEXTURE_2D);
3332 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3333 glDisable(GL_CULL_FACE);
3334 glDisable(GL_LIGHTING);
3336 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3337 glPushMatrix(); // Store The Projection Matrix
3338 glLoadIdentity(); // Reset The Projection Matrix
3339 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3340 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3341 glPushMatrix(); // Store The Modelview Matrix
3342 glLoadIdentity(); // Reset The Modelview Matrix
3344 glDisable(GL_TEXTURE_2D);
3346 glColor4f(1,0,0,1-(transition*10));
3348 glColor4f(1,0,0,1-((1-transition)*10));
3351 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3355 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3356 glPushMatrix(); // Store The Projection Matrix
3357 glLoadIdentity(); // Reset The Projection Matrix
3358 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
3359 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3360 glPushMatrix(); // Store The Modelview Matrix
3361 glLoadIdentity(); // Reset The Modelview Matrix
3362 glTranslatef(screenwidth/2,screenheight/2,0);
3364 glScalef((float)screenwidth/2,(float)screenheight/2,1);
3365 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3367 glEnable(GL_TEXTURE_2D);
3369 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
3370 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
3372 if(!waiting) { // hide the cursor while waiting for a key
3374 glTranslatef(mousecoordh-screenwidth/2,mousecoordv*-1+screenheight/2,0);
3375 glScalef((float)screenwidth/64,(float)screenwidth/64,1);
3376 glTranslatef(1,-1,0);
3377 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3379 glBindTexture( GL_TEXTURE_2D, cursortexture);
3381 //glScalef(.25,.25,.25);
3384 glVertex3f(-1, -1, 0.0f);
3386 glVertex3f(1, -1, 0.0f);
3388 glVertex3f(1, 1, 0.0f);
3390 glVertex3f(-1, 1, 0.0f);
3396 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3402 //printf("Flash amount: %f, delay %i\n", flashamount, flashdelay);
3403 if(flashamount>1)flashamount=1;
3404 if(flashdelay<=0)flashamount-=multiplier;
3406 if(flashamount<0)flashamount=0;
3407 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3408 glDisable(GL_CULL_FACE);
3409 glDisable(GL_LIGHTING);
3410 glDisable(GL_TEXTURE_2D);
3412 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3413 glPushMatrix(); // Store The Projection Matrix
3414 glLoadIdentity(); // Reset The Projection Matrix
3415 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
3416 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3417 glPushMatrix(); // Store The Modelview Matrix
3418 glLoadIdentity(); // Reset The Modelview Matrix
3419 glScalef(screenwidth,screenheight,1);
3420 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3422 glColor4f(flashr,flashg,flashb,flashamount);
3424 glVertex3f(0, 0, 0.0f);
3425 glVertex3f(256, 0, 0.0f);
3426 glVertex3f(256, 256, 0.0f);
3427 glVertex3f(0, 256, 0.0f);
3429 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3430 glPopMatrix(); // Restore The Old Projection Matrix
3431 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3432 glPopMatrix(); // Restore The Old Projection Matrix
3433 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
3434 glEnable(GL_CULL_FACE);
3435 glDisable(GL_BLEND);
3440 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)||(!gameon&&gamestarted)){
3441 tempmult=multiplier;
3446 if ( side == stereoRight || side == stereoCenter ) {
3447 if(drawmode!=motionblurmode||mainmenu){
3452 //myassert(glGetError() == GL_NO_ERROR);
3453 glDrawBuffer(GL_BACK);
3454 glReadBuffer(GL_BACK);
3459 if(drawtoggle==2)drawtoggle=0;
3461 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)){
3462 multiplier=tempmult;
3464 //Jordan fixed your warning!