2 Copyright (C) 2003, 2010 - Wolfire Games
4 This file is part of Lugaru.
6 Lugaru is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; either version 2
9 of the License, or (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 See the GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 #include "openal_wrapper.h"
30 extern int environment;
31 extern float texscale;
33 extern Terrain terrain;
34 //extern Sprites sprites;
35 extern float multiplier;
37 extern float viewdistance;
38 extern float fadestart;
39 extern float screenwidth,screenheight;
40 extern int kTextureSize;
41 extern FRUSTUM frustum;
43 extern Objects objects;
45 extern float usermousesensitivity;
47 extern float camerashake;
49 extern float slomodelay;
50 extern bool ismotionblur;
52 extern float blackout;
53 extern bool damageeffects;
55 extern bool texttoggle;
56 extern float blurness;
57 extern float targetblurness;
58 extern float playerdist;
59 extern bool cellophane;
61 extern float flashamount,flashr,flashg,flashb;
62 extern int flashdelay;
64 extern float motionbluramount;
66 extern bool alwaysblur;
68 extern bool tilt2weird;
69 extern bool tiltweird;
71 extern bool proportionweird;
72 extern bool vertexweird[6];
73 extern bool velocityblur;
74 extern bool debugmode;
76 extern int oldmainmenu;
77 extern int bloodtoggle;
78 extern int difficulty;
81 //extern int texdetail;
82 extern float texdetail;
83 extern bool musictoggle;
84 extern int tutoriallevel;
85 extern float smoketex;
86 extern float tutorialstagetime;
87 extern float tutorialmaxtime;
88 extern int tutorialstage;
89 extern bool againbonus;
90 extern float damagedealt;
91 extern bool invertmouse;
93 extern int numhotspots;
94 extern int winhotspot;
95 extern int killhotspot;
96 extern XYZ hotspot[40];
97 extern int hotspottype[40];
98 extern float hotspotsize[40];
99 extern char hotspottext[40][256];
100 extern int currenthotspot;;
102 extern bool campaign;
103 extern bool winfreeze;
105 extern float menupulse;
107 extern bool gamestart;
109 extern int numdialogues;
110 extern int numdialogueboxes[max_dialogues];
111 extern int dialoguetype[max_dialogues];
112 extern int dialogueboxlocation[max_dialogues][max_dialoguelength];
113 extern float dialogueboxcolor[max_dialogues][max_dialoguelength][3];
114 extern int dialogueboxsound[max_dialogues][max_dialoguelength];
115 extern char dialoguetext[max_dialogues][max_dialoguelength][128];
116 extern char dialoguename[max_dialogues][max_dialoguelength][64];
117 extern XYZ dialoguecamera[max_dialogues][max_dialoguelength];
118 extern XYZ participantlocation[max_dialogues][10];
119 extern int participantfocus[max_dialogues][max_dialoguelength];
120 extern int participantaction[max_dialogues][max_dialoguelength];
121 extern float participantrotation[max_dialogues][10];
122 extern XYZ participantfacing[max_dialogues][max_dialoguelength][10];
123 extern float dialoguecamerarotation[max_dialogues][max_dialoguelength];
124 extern float dialoguecamerarotation2[max_dialogues][max_dialoguelength];
125 extern int indialogue;
126 extern int whichdialogue;
127 extern int directing;
128 extern float dialoguetime;
129 extern int dialoguegonethrough[20];
131 extern bool gamestarted;
133 extern bool showdamagebar;
135 extern int channels[100];
136 extern "C" void PlaySoundEx(int channel, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
138 void Game::flash() { // shouldn't be that way, these should be attributes and Person class should not change rendering.
145 /*********************> DrawGLScene() <*****/
146 int Game::DrawGLScene(StereoSide side)
148 static float texcoordwidth,texcoordheight;
149 static float texviewwidth, texviewheight;
151 static GLubyte color;
152 static float newbrightness;
153 static float changespeed;
154 static XYZ checkpoint;
155 static float tempmult;
157 static char string[256]="";
158 static char string2[256]="";
159 static char string3[256]="";
161 static float lastcheck;
163 lastcheck+=multiplier;
165 if ( stereomode == stereoAnaglyph ) {
167 case stereoLeft: glColorMask( 0.0, 1.0, 1.0, 1.0 ); break;
168 case stereoRight: glColorMask( 1.0, 0.0, 0.0, 1.0 ); break;
171 glColorMask( 1.0, 1.0, 1.0, 1.0 );
173 if ( stereomode == stereoHorizontalInterlaced || stereomode == stereoVerticalInterlaced ) {
174 glStencilFunc(side == stereoLeft ? GL_NOTEQUAL : GL_EQUAL, 0x01, 0x01);
178 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)){
185 numboundaries=mapradius*2;
186 if(numboundaries>360)numboundaries=360;
187 for(i=0;i<numboundaries;i++){
190 boundary[i]=mapcenter+DoRotation(boundary[i]*mapradius,0,i*(360/((float)(numboundaries))),0);
199 olddrawmode=drawmode;
200 if(ismotionblur&&!loading){
201 if((findLengthfast(&player[0].velocity)>200)&&velocityblur&&!cameramode){
202 drawmode=motionblurmode;
203 motionbluramount=200/(findLengthfast(&player[0].velocity));
206 if(player[0].damage-player[0].superpermanentdamage>(player[0].damagetolerance-player[0].superpermanentdamage)*1/2&&damageeffects&&!cameramode){
207 drawmode=doublevisionmode;
214 drawmode=motionblurmode;
216 slomodelay-=multiplier;
217 if(slomodelay<0)slomo=0;
221 if((!changed&&!slomo)||loading){
223 if(ismotionblur&&(/*fps>100||*/alwaysblur)){
224 if(olddrawmode!=realmotionblurmode)change=1;
226 drawmode=realmotionblurmode;
228 else if(olddrawmode==realmotionblurmode)change=2;
232 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted))drawmode=normalmode;
233 if((freeze||winfreeze)&&ismotionblur&&!mainmenu)drawmode=radialzoommode;
235 if(winfreeze||mainmenu)drawmode=normalmode;
238 if(drawmode==glowmode){
243 DSpContext_FadeGamma(NULL,200,&color2);
247 if(drawtoggle!=2)drawtoggle=1-drawtoggle;
251 texviewwidth=kTextureSize;
252 if(texviewwidth>screenwidth)texviewwidth=screenwidth;
253 texviewheight=kTextureSize;
254 if(texviewheight>screenheight)texviewheight=screenheight;
256 texcoordwidth=screenwidth/kTextureSize;
257 texcoordheight=screenheight/kTextureSize;
258 if(texcoordwidth>1)texcoordwidth=1;
259 if(texcoordheight>1)texcoordheight=1;
262 glDrawBuffer(GL_BACK);
263 glReadBuffer(GL_BACK);
265 if(abs(blurness-targetblurness)<multiplier*10||abs(blurness-targetblurness)>2){
266 blurness=targetblurness;
267 targetblurness=(float)(abs(Random()%100))/40;
269 if(blurness<targetblurness)
270 blurness+=multiplier*5;
272 blurness-=multiplier*5;
275 static XYZ terrainlight;
276 static float distance;
277 if(drawmode==normalmode)ReSizeGLScene(90,.1f);
278 if(drawmode!=normalmode)glViewport(0,0,texviewwidth,texviewheight);
279 glDepthFunc(GL_LEQUAL);
281 glAlphaFunc(GL_GREATER, 0.0001f);
282 glEnable(GL_ALPHA_TEST);
283 glClearColor(0.25f, 0.25f, 0.25f, 1.0f);
284 glClear(GL_DEPTH_BUFFER_BIT);
286 glMatrixMode (GL_MODELVIEW);
287 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
290 // Move the camera for the current eye's point of view.
291 // Reverse the movement if we're reversing stereo
292 glTranslatef((stereoseparation/2) * side * (stereoreverse ? -1 : 1), 0, 0);
294 if(!cameramode&&!freeze&&!winfreeze){
295 glRotatef(float(Random()%100)/10*camerashake/*+(woozy*woozy)/10*/,0,0,1);
296 glRotatef(rotation2+sin(woozy/2)*(player[0].damage/player[0].damagetolerance)*5,1,0,0);
297 glRotatef(rotation+sin(woozy)*(player[0].damage/player[0].damagetolerance)*5,0,1,0);
299 if(cameramode||freeze||winfreeze){
300 glRotatef(rotation2,1,0,0);
301 glRotatef(rotation,0,1,0);
304 if(environment==desertenvironment){
305 glRotatef((float)(abs(Random()%100))/3000-1,1,0,0);
306 glRotatef((float)(abs(Random()%100))/3000-1,0,1,0);
308 SetUpLight(&light,0);
310 if(environment==desertenvironment&&detail==2)glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, blurness+.4 );
311 if(environment==desertenvironment){
312 glRotatef((float)(abs(Random()%100))/1000,1,0,0);
313 glRotatef((float)(abs(Random()%100))/1000,0,1,0);
316 glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0);
318 glTranslatef(-viewer.x,-viewer.y,-viewer.z);
319 frustum.GetFrustum();
323 static float size,opacity,rotation;
325 for(k=0;k<numplayers;k++){
326 if(!player[k].skeleton.free&&player[k].playerdetail&&player[k].howactive<typesleeping)
327 if(frustum.SphereInFrustum(player[k].coords.x,player[k].coords.y+player[k].scale*3,player[k].coords.z,player[k].scale*7)&&player[k].occluded<25)
328 for(i=0;i<player[k].skeleton.num_joints;i++){
329 if(player[k].skeleton.joints[i].label==leftknee||player[k].skeleton.joints[i].label==rightknee||player[k].skeleton.joints[i].label==groin){
330 point=DoRotation(player[k].skeleton.joints[i].position,0,player[k].rotation,0)*player[k].scale+player[k].coords;
332 opacity=.4-player[k].skeleton.joints[i].position.y*player[k].scale/5-(player[k].coords.y-terrain.getHeight(player[k].coords.x,player[k].coords.z))/10;
333 if(k!=0&&tutoriallevel==1){
334 opacity=.2+.2*sin(smoketex*6+i)-player[k].skeleton.joints[i].position.y*player[k].scale/5-(player[k].coords.y-terrain.getHeight(player[k].coords.x,player[k].coords.z))/10;
336 terrain.MakeDecal(shadowdecal,point,size,opacity,rotation);
337 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
338 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
339 if(objects.position[j].y<player[k].coords.y||objects.type[j]==tunneltype||objects.type[j]==weirdtype){
340 point=DoRotation(DoRotation(player[k].skeleton.joints[i].position,0,player[k].rotation,0)*player[k].scale+player[k].coords-objects.position[j],0,-objects.rotation[j],0);
343 if(k!=0&&tutoriallevel==1){
344 opacity=.2+.2*sin(smoketex*6+i);
346 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
351 if((player[k].skeleton.free||player[k].howactive>=typesleeping)&&player[k].playerdetail)
352 if(frustum.SphereInFrustum(player[k].coords.x,player[k].coords.y,player[k].coords.z,player[k].scale*5)&&player[k].occluded<25)
353 for(i=0;i<player[k].skeleton.num_joints;i++){
354 if(player[k].skeleton.joints[i].label==leftknee||player[k].skeleton.joints[i].label==rightknee||player[k].skeleton.joints[i].label==groin||player[k].skeleton.joints[i].label==leftelbow||player[k].skeleton.joints[i].label==rightelbow||player[k].skeleton.joints[i].label==neck){
355 if(player[k].skeleton.free)point=player[k].skeleton.joints[i].position*player[k].scale+player[k].coords;
356 else point=DoRotation(player[k].skeleton.joints[i].position,0,player[k].rotation,0)*player[k].scale+player[k].coords;
358 opacity=.4-player[k].skeleton.joints[i].position.y*player[k].scale/5-(player[k].coords.y-terrain.getHeight(player[k].coords.x,player[k].coords.z))/5;
359 if(k!=0&&tutoriallevel==1){
360 opacity=.2+.2*sin(smoketex*6+i)-player[k].skeleton.joints[i].position.y*player[k].scale/5-(player[k].coords.y-terrain.getHeight(player[k].coords.x,player[k].coords.z))/10;
362 terrain.MakeDecal(shadowdecal,point,size,opacity*.7,rotation);
363 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
364 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
365 if(objects.position[j].y<player[k].coords.y||objects.type[j]==tunneltype||objects.type[j]==weirdtype){
366 if(player[k].skeleton.free)point=DoRotation(player[k].skeleton.joints[i].position*player[k].scale+player[k].coords-objects.position[j],0,-objects.rotation[j],0);
367 else point=DoRotation(DoRotation(player[k].skeleton.joints[i].position,0,player[k].rotation,0)*player[k].scale+player[k].coords-objects.position[j],0,-objects.rotation[j],0);
370 if(k!=0&&tutoriallevel==1){
371 opacity=.2+.2*sin(smoketex*6+i);
373 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
379 if(!player[k].playerdetail)
380 if(frustum.SphereInFrustum(player[k].coords.x,player[k].coords.y,player[k].coords.z,player[k].scale*5))
382 point=player[k].coords;
384 opacity=.4-(player[k].coords.y-terrain.getHeight(player[k].coords.x,player[k].coords.z))/5;
385 terrain.MakeDecal(shadowdecal,point,size,opacity*.7,rotation);
386 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
387 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
388 point=DoRotation(player[k].coords-objects.position[j],0,-objects.rotation[j],0);
391 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
397 glEnable(GL_TEXTURE_2D);
399 glEnable(GL_DEPTH_TEST);
400 glEnable(GL_CULL_FACE);
402 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
403 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
404 glBindTexture( GL_TEXTURE_2D, terraintexture);
406 glBindTexture( GL_TEXTURE_2D, terraintexture2);
408 //glBindTexture( GL_TEXTURE_2D, terraintexture3);
409 //glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
412 terrain.drawdecals();
415 glEnable(GL_CULL_FACE);
416 glEnable(GL_LIGHTING);
418 glEnable(GL_TEXTURE_2D);
421 glEnable(GL_COLOR_MATERIAL);
436 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
437 glEnable(GL_CULL_FACE);
438 glCullFace(GL_FRONT);
440 for(k=0;k<numplayers;k++){
441 if(k==0||tutoriallevel!=1){
443 glEnable(GL_LIGHTING);
444 terrainlight=terrain.getLighting(player[k].coords.x,player[k].coords.z);
445 distance=findDistancefast(&viewer,&player[k].coords);
446 distance=(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance;
447 glColor4f(terrainlight.x,terrainlight.y,terrainlight.z,distance);
448 if(distance>=1)glDisable(GL_BLEND);
450 checkpoint=DoRotation(player[k].skeleton.joints[abs(Random()%player[k].skeleton.num_joints)].position,0,player[k].rotation,0)*player[k].scale+player[k].coords;
452 if(!player[k].occluded==0)i=checkcollide(viewer,checkpoint,player[k].lastoccluded);
453 if(i==-1||player[k].occluded==0)i=checkcollide(viewer,checkpoint);
455 player[k].occluded+=1;
456 player[k].lastoccluded=i;
458 else player[k].occluded=0;
459 if(player[k].occluded<25)player[k].DrawSkeleton();
465 if(!cameramode&&musictype==stream_music2)playerdist=findDistancefastflat(&player[0].coords,&viewer);
466 else playerdist=-100;
469 glEnable(GL_TEXTURE_2D);
474 if(frustum.SphereInFrustum(realhawkcoords.x+hawk.boundingspherecenter.x,realhawkcoords.y+hawk.boundingspherecenter.y,realhawkcoords.z+hawk.boundingspherecenter.z,2)){
475 glAlphaFunc(GL_GREATER, 0.0001f);
477 glDisable(GL_CULL_FACE);
478 glDisable(GL_LIGHTING);
480 glTranslatef(hawkcoords.x,hawkcoords.y,hawkcoords.z);
481 glRotatef(hawkrotation,0,1,0);
482 glTranslatef(25,0,0);
483 distance=findDistancefast(&viewer,&realhawkcoords)*1.2;
484 glColor4f(light.color[0],light.color[1],light.color[2],(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance);
485 if((viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance>1)glColor4f(light.color[0],light.color[1],light.color[2],1);
486 if((viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance>0)
487 hawk.drawdifftex(hawktexture);
491 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
492 glEnable(GL_CULL_FACE);
493 glCullFace(GL_FRONT);
495 for(k=0;k<numplayers;k++){
496 if(!(k==0||tutoriallevel!=1)){
498 glEnable(GL_LIGHTING);
499 terrainlight=terrain.getLighting(player[k].coords.x,player[k].coords.z);
500 distance=findDistancefast(&viewer,&player[k].coords);
501 distance=(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance;
502 glColor4f(terrainlight.x,terrainlight.y,terrainlight.z,distance);
503 if(distance>=1)glDisable(GL_BLEND);
505 checkpoint=DoRotation(player[k].skeleton.joints[abs(Random()%player[k].skeleton.num_joints)].position,0,player[k].rotation,0)*player[k].scale+player[k].coords;
507 if(!player[k].occluded==0)i=checkcollide(viewer,checkpoint,player[k].lastoccluded);
508 if(i==-1||player[k].occluded==0)i=checkcollide(viewer,checkpoint);
510 player[k].occluded+=1;
511 player[k].lastoccluded=i;
513 else player[k].occluded=0;
514 if(player[k].occluded<25)player[k].DrawSkeleton();
520 glEnable(GL_TEXTURE_2D);
525 glDisable(GL_COLOR_MATERIAL);
527 glDisable(GL_LIGHTING);
528 glDisable(GL_TEXTURE_2D);
536 glDisable(GL_LIGHTING);
537 glDisable(GL_TEXTURE_2D);
538 glDisable(GL_COLOR_MATERIAL);
541 for(k=0;k<numplayers;k++){
542 if(player[k].numwaypoints>1){
543 glBegin(GL_LINE_LOOP);
544 for(i=0;i<player[k].numwaypoints;i++){
545 glVertex3f(player[k].waypoints[i].x,player[k].waypoints[i].y+.5,player[k].waypoints[i].z);
554 for(k=0;k<numpathpoints;k++){
555 if(numpathpointconnect[k]){
556 for(i=0;i<numpathpointconnect[k];i++){
557 glBegin(GL_LINE_LOOP);
558 glVertex3f(pathpoint[k].x,pathpoint[k].y+.5,pathpoint[k].z);
559 glVertex3f(pathpoint[pathpointconnect[k][i]].x,pathpoint[pathpointconnect[k][i]].y+.5,pathpoint[pathpointconnect[k][i]].z);
567 glVertex3f(pathpoint[pathpointselected].x,pathpoint[pathpointselected].y+.5,pathpoint[pathpointselected].z);
574 glEnable(GL_TEXTURE_2D);
575 glColor4f(.5,.5,.5,1);
577 sprintf (string, " ",(int)(fps));
578 text.glPrint(10,30,string,0,.8,screenwidth,screenheight);
581 if(bonus>0&&bonustime<1&&!winfreeze&&indialogue==-1/*bonustime<4*/){
582 const char *bonus_name;
583 if (bonus < bonus_count)
584 bonus_name = bonus_names[bonus];
586 bonus_name = "Excellent!"; // When does this happen?
588 glColor4f(0,0,0,1-bonustime);
589 text.glPrintOutline(1024/2-10*strlen(bonus_name)-4,768/16-4+768*4/5,bonus_name,1,2.5,1024,768);
590 glColor4f(1,0,0,1-bonustime);
591 text.glPrint(1024/2-10*strlen(bonus_name),768/16+768*4/5,bonus_name,1,2,1024,768);
593 sprintf (string, "%d",(int)bonusvalue);
594 glColor4f(0,0,0,1-bonustime);
595 text.glPrintOutline(1024/2-10*strlen(string)-4,768/16-4-20+768*4/5,string,1,2.5*.8,1024,768);
596 glColor4f(1,0,0,1-bonustime);
597 text.glPrint(1024/2-10*strlen(string),768/16-20+768*4/5,string,1,2*.8,1024,768);
598 glColor4f(.5,.5,.5,1);
601 if(tutoriallevel==1){
602 tutorialopac=tutorialmaxtime-tutorialstagetime;
603 if(tutorialopac>1)tutorialopac=1;
604 if(tutorialopac<0)tutorialopac=0;
606 sprintf (string, " ");
607 sprintf (string2, " ");
608 sprintf (string3, " ");
609 if(tutorialstage==0){
610 sprintf (string, " ");
611 sprintf (string2, " ");
612 sprintf (string3, " ");
614 if(tutorialstage==1){
615 sprintf (string, "Welcome to the Lugaru training level!");
616 sprintf (string2, " ");
617 sprintf (string3, " ");
619 if(tutorialstage==2){
620 sprintf (string, "BASIC MOVEMENT:");
621 sprintf (string2, " ");
622 sprintf (string3, " ");
624 if(tutorialstage==3){
625 sprintf (string, "You can move the mouse to rotate the camera.");
626 sprintf (string2, " ");
627 sprintf (string3, " ");
629 if(tutorialstage==4){
630 sprintf (string, "Try using the %s, %s, %s and %s keys to move around.",Input::keyToChar(forwardkey),Input::keyToChar(leftkey),Input::keyToChar(backkey),Input::keyToChar(rightkey));
631 sprintf (string2, "All movement is relative to the camera.");
632 sprintf (string3, " ");
634 if(tutorialstage==5){
635 sprintf (string, "Please press %s to jump.",Input::keyToChar(jumpkey));
636 sprintf (string2, "You can hold it longer to jump higher.");
637 sprintf (string3, " ");
639 if(tutorialstage==6){
640 sprintf (string, "You can press %s to crouch.",Input::keyToChar(crouchkey));
641 sprintf (string2, "You can jump higher from a crouching position.");
642 sprintf (string3, " ");
644 if(tutorialstage==7){
645 sprintf (string, "While running, you can press %s to roll.",Input::keyToChar(crouchkey));
646 sprintf (string2, " ");
647 sprintf (string3, " ");
649 if(tutorialstage==8){
650 sprintf (string, "While crouching, you can sneak around silently");
651 sprintf (string2, "using the movement keys.");
652 sprintf (string3, " ");
654 if(tutorialstage==9){
655 sprintf (string, "Release the crouch key while sneaking and hold the movement keys");
656 sprintf (string2, "to run animal-style.");
657 sprintf (string3, " ");
659 if(tutorialstage==10){
660 sprintf (string, "ADVANCED MOVEMENT:");
661 sprintf (string2, " ");
662 sprintf (string3, " ");
664 if(tutorialstage==11){
665 sprintf (string, "When you jump at a wall, you can hold %s again",Input::keyToChar(jumpkey));
666 sprintf (string2, "during impact to perform a walljump.");
667 sprintf (string3, "Be sure to use the movement keys to press against the wall");
669 if(tutorialstage==12){
670 sprintf (string, "While in the air, you can press crouch to flip.",Input::keyToChar(jumpkey));
671 sprintf (string2, "Walljumps and flips confuse enemies and give you more control.");
672 sprintf (string3, " ");
674 if(tutorialstage==13){
675 sprintf (string, "BASIC COMBAT:");
676 sprintf (string2, " ");
677 sprintf (string3, " ");
679 if(tutorialstage==14){
680 sprintf (string, "There is now an imaginary enemy");
681 sprintf (string2, "in the middle of the training area.");
682 sprintf (string3, " ");
684 if(tutorialstage==15){
685 if(attackkey==MOUSEBUTTON1)sprintf (string, "Click to attack when you are near an enemy.");
686 else sprintf (string, "Press %s to attack when you are near an enemy.",Input::keyToChar(attackkey));
687 sprintf (string2, "You can punch by standing still near an enemy and attacking.");
688 sprintf (string3, " ");
690 if(tutorialstage==16){
691 sprintf (string, "If you are close, you will perform a weak punch.");
692 sprintf (string2, "The weak punch is excellent for starting attack combinations.");
693 sprintf (string3, " ");
695 if(tutorialstage==17){
696 sprintf (string, "Attacking while running results in a spin kick.");
697 sprintf (string2, "This is one of your most powerful ground attacks.");
698 sprintf (string3, " ");
700 if(tutorialstage==18){
701 sprintf (string, "Sweep the enemy's legs out by attacking while crouched.");
702 sprintf (string2, "This is a very fast attack, and easy to follow up.");
703 sprintf (string3, " ");
705 if(tutorialstage==19){
706 sprintf (string, "When an enemy is on the ground, you can deal some extra");
707 sprintf (string2, "damage by running up and drop-kicking him.");
708 sprintf (string3, "(Try knocking them down with a sweep first)");
710 if(tutorialstage==20){
711 sprintf (string, "Your most powerful individual attack is the rabbit kick.");
712 if(attackkey==MOUSEBUTTON1)sprintf (string2, "Run at the enemy while holding the mouse button, and press");
713 else sprintf (string2, "Run at the enemy while holding %s, and press", Input::keyToChar(attackkey));
714 sprintf (string3, "the jump key (%s) to attack.",Input::keyToChar(jumpkey));
716 if(tutorialstage==21){
717 sprintf (string, "This attack is devastating if timed correctly.");
718 sprintf (string2, "Even if timed incorrectly, it will knock the enemy over.");
719 if(againbonus)sprintf (string3, "Try rabbit-kicking the imaginary enemy again.");
720 else sprintf (string3, "Try rabbit-kicking the imaginary enemy.");
722 if(tutorialstage==22){
723 sprintf (string, "If you sneak behind an enemy unnoticed, you can kill");
724 sprintf (string2, "him instantly. Move close behind this enemy");
725 sprintf (string3, "and attack.");
727 if(tutorialstage==23){
728 sprintf (string, "Another important attack is the wall kick. When an enemy");
729 sprintf (string2, "is near a wall, perform a walljump nearby and hold");
730 sprintf (string3, "the attack key during impact with the wall.");
732 if(tutorialstage==24){
733 sprintf (string, "You can tackle enemies by running at them animal-style");
734 if(attackkey==MOUSEBUTTON1)sprintf (string2, "and pressing jump (%s) or attack(mouse button).",Input::keyToChar(jumpkey));
735 else sprintf (string2, "and pressing jump (%s) or attack(%s).",Input::keyToChar(jumpkey),Input::keyToChar(attackkey));
736 sprintf (string3, "This is especially useful when they are running away.");
738 if(tutorialstage==25){
739 sprintf (string, "Dodge by pressing back and attack. Dodging is essential");
740 sprintf (string2, "against enemies with swords or other long weapons.");
741 sprintf (string3, " ");
743 if(tutorialstage==26){
744 sprintf (string, "REVERSALS AND COUNTER-REVERSALS");
745 sprintf (string2, " ");
746 sprintf (string3, " ");
748 if(tutorialstage==27){
749 sprintf (string, "The enemy can now reverse your attacks.");
750 sprintf (string2, " ");
751 sprintf (string3, " ");
753 if(tutorialstage==28){
754 sprintf (string, "If you attack, you will notice that the enemy now sometimes");
755 sprintf (string2, "catches your attack and uses it against you. Hold");
756 sprintf (string3, "crouch (%s) after attacking to escape from reversals.",Input::keyToChar(crouchkey));
758 if(tutorialstage==29){
759 sprintf (string, "Try escaping from two more reversals in a row.");
760 sprintf (string2, " ");
761 sprintf (string3, " ");
763 if(tutorialstage==30){
764 sprintf (string, "Good!");
765 sprintf (string2, " ");
766 sprintf (string3, " ");
768 if(tutorialstage==31){
769 sprintf (string, "To reverse an attack, you must tap crouch (%s) during the",Input::keyToChar(crouchkey));
770 sprintf (string2, "enemy's attack. You must also be close to the enemy;");
771 sprintf (string3, "this is especially important against armed opponents.");
773 if(tutorialstage==32){
774 sprintf (string, "The enemy can attack in %d seconds.", (int)(tutorialmaxtime-tutorialstagetime));
775 sprintf (string2, "This imaginary opponents attacks will be highlighted");
776 sprintf (string3, "to make this easier.");
778 if(tutorialstage==33){
779 sprintf (string, "Reverse three enemy attacks!");
780 sprintf (string2, " ");
781 sprintf (string3, " ");
783 if(tutorialstage==34){
784 sprintf (string, "Reverse two more enemy attacks!");
785 sprintf (string2, " ");
786 sprintf (string3, " ");
788 if(tutorialstage==35){
789 sprintf (string, "Reverse one more enemy attack!");
790 sprintf (string2, " ");
791 sprintf (string3, " ");
793 if(tutorialstage==36){
794 sprintf (string, "Excellent!");
795 sprintf (string2, " ");
796 sprintf (string3, " ");
798 if(tutorialstage==37){
799 sprintf (string, "Now spar with the enemy for %d more seconds.", (int)(tutorialmaxtime-tutorialstagetime));
800 sprintf (string2, "Damage dealt: %d",(int)damagedealt);
801 sprintf (string3, "Damage taken: %d.",(int)damagetaken);
803 if(tutorialstage==38){
804 sprintf (string, "WEAPONS:");
805 sprintf (string2, " ");
806 sprintf (string3, " ");
808 if(tutorialstage==39){
809 sprintf (string, "There is now an imaginary knife");
810 sprintf (string2, "in the center of the training area.");
811 sprintf (string3, " ");
813 if(tutorialstage==40){
814 sprintf (string, "Stand, roll or handspring over the knife");
815 sprintf (string2, "while pressing %s to pick it up.",Input::keyToChar(throwkey));
816 sprintf (string3, "You can crouch and press the same key to drop it again.");
818 if(tutorialstage==41){
819 sprintf (string, "You can equip and unequip weapons using the %s key.",Input::keyToChar(drawkey));
820 sprintf (string2, "Sometimes it is best to keep them unequipped to");
821 sprintf (string3, "prevent enemies from taking them. ");
823 if(tutorialstage==42){
824 sprintf (string, "The knife is the smallest weapon and the least encumbering.");
825 sprintf (string2, "You can equip or unequip it while standing, crouching,");
826 sprintf (string3, "running or flipping.");
828 if(tutorialstage==43){
829 sprintf (string, "You perform weapon attacks the same way as unarmed attacks,");
830 sprintf (string2, "but sharp weapons cause permanent damage, instead of the");
831 sprintf (string3, "temporary trauma from blunt weapons, fists and feet.");
833 if(tutorialstage==44){
834 sprintf (string, "The enemy now has your knife!");
835 sprintf (string2, "Please reverse two of his knife attacks.");
836 sprintf (string3, " ");
838 if(tutorialstage==45){
839 sprintf (string, "Please reverse one more of his knife attacks.");
840 sprintf (string2, " ");
841 sprintf (string3, " ");
843 if(tutorialstage==46){
844 sprintf (string, "Now he has a sword!");
845 sprintf (string2, "The sword has longer reach than your arms, so you");
846 sprintf (string3, "must move close to reverse the sword slash.");
848 if(tutorialstage==47){
849 sprintf (string, "Long weapons like the sword and staff are also useful for defense;");
850 sprintf (string2, "you can parry enemy weapon attacks by pressing the attack key");
851 sprintf (string3, "at the right time. Please try parrying the enemy's attacks!");
853 if(tutorialstage==48){
854 sprintf (string, "The staff is like the sword, but has two main attacks.");
855 sprintf (string2, "The standing smash is fast and effective, and the running");
856 sprintf (string3, "spin smash is slower and more powerful.");
858 if(tutorialstage==49){
859 sprintf (string, "When facing an enemy, you can throw the knife with %s.",Input::keyToChar(throwkey));
860 sprintf (string2, "It is possible to throw the knife while flipping,");
861 sprintf (string3, "but it is very inaccurate.");
863 if(tutorialstage==50){
864 sprintf (string, "You now know everything you can learn from training.");
865 sprintf (string2, "Everything else you must learn from experience!");
866 sprintf (string3, " ");
868 if(tutorialstage==51){
869 sprintf (string, "Walk out of the training area to return to the main menu.");
870 sprintf (string2, " ");
871 sprintf (string3, " ");
874 glColor4f(0,0,0,tutorialopac);
875 text.glPrintOutline(screenwidth/2-7.6*strlen(string)*screenwidth/1024-4,screenheight/16-4+screenheight*4/5,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight);
876 text.glPrintOutline(screenwidth/2-7.6*strlen(string2)*screenwidth/1024-4,screenheight/16-4+screenheight*4/5-20*screenwidth/1024,string2,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight);
877 text.glPrintOutline(screenwidth/2-7.6*strlen(string3)*screenwidth/1024-4,screenheight/16-4+screenheight*4/5-40*screenwidth/1024,string3,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight);
878 glColor4f(1,1,1,tutorialopac);
879 text.glPrint(screenwidth/2-7.6*strlen(string)*screenwidth/1024,screenheight/16+screenheight*4/5,string,1,1.5*screenwidth/1024,screenwidth,screenheight);
880 text.glPrint(screenwidth/2-7.6*strlen(string2)*screenwidth/1024,screenheight/16+screenheight*4/5-20*screenwidth/1024,string2,1,1.5*screenwidth/1024,screenwidth,screenheight);
881 text.glPrint(screenwidth/2-7.6*strlen(string3)*screenwidth/1024,screenheight/16+screenheight*4/5-40*screenwidth/1024,string3,1,1.5*screenwidth/1024,screenwidth,screenheight);
883 sprintf (string, "Press 'tab' to skip to the next item.",Input::keyToChar(jumpkey));
884 sprintf (string2, "Press escape at any time to");
885 sprintf (string3, "pause or exit the tutorial.");
888 text.glPrintOutline(screenwidth/2-7.6*strlen(string)*screenwidth/1024*.8-4,0-4+screenheight*1/10,string,1,1.5*1.25*screenwidth/1024*.8,screenwidth,screenheight);
889 text.glPrintOutline(screenwidth/2-7.6*strlen(string2)*screenwidth/1024*.8-4,0-4+screenheight*1/10-20*.8*screenwidth/1024,string2,1,1.5*1.25*screenwidth/1024*.8,screenwidth,screenheight);
890 text.glPrintOutline(screenwidth/2-7.6*strlen(string3)*screenwidth/1024*.8-4,0-4+screenheight*1/10-40*.8*screenwidth/1024,string3,1,1.5*1.25*screenwidth/1024*.8,screenwidth,screenheight);
891 glColor4f(0.5,0.5,0.5,1);
892 text.glPrint(screenwidth/2-7.6*strlen(string)*screenwidth/1024*.8,0+screenheight*1/10,string,1,1.5*screenwidth/1024*.8,screenwidth,screenheight);
893 text.glPrint(screenwidth/2-7.6*strlen(string2)*screenwidth/1024*.8,0+screenheight*1/10-20*.8*screenwidth/1024,string2,1,1.5*screenwidth/1024*.8,screenwidth,screenheight);
894 text.glPrint(screenwidth/2-7.6*strlen(string3)*screenwidth/1024*.8,0+screenheight*1/10-40*.8*screenwidth/1024,string3,1,1.5*screenwidth/1024*.8,screenwidth,screenheight);
898 if(numhotspots&&(bonustime>=1||bonus<=0||bonustime<0)&&!tutoriallevel){
900 float closestdist=-1;
902 closest=currenthotspot;
903 for(i=0;i<numhotspots;i++){
904 distance=findDistancefast(&player[0].coords,&hotspot[i]);
905 if(closestdist==-1||distance<closestdist){
906 if(findDistancefast(&player[0].coords,&hotspot[i])<hotspotsize[i]&&((hotspottype[i]<=10&&hotspottype[i]>=0)||(hotspottype[i]<=40&&hotspottype[i]>=20))){
907 closestdist=distance;
913 currenthotspot=closest;
914 if(currenthotspot!=-1){
915 if(hotspottype[closest]<=10){
916 if(findDistancefast(&player[0].coords,&hotspot[closest])<hotspotsize[closest])
919 tutorialopac=tutorialmaxtime-tutorialstagetime;
920 if(tutorialopac>1)tutorialopac=1;
921 if(tutorialopac<0)tutorialopac=0;
923 sprintf (string, "%s", hotspottext[closest]);
930 if(string[i]=='\n'||string[i]>'z'||string[i]<' '||string[i]=='\0'){
931 glColor4f(0,0,0,tutorialopac);
932 text.glPrintOutline(screenwidth/2-7.6*(i-lastline)*screenwidth/1024-4,screenheight/16-4+screenheight*4/5-20*screenwidth/1024*line,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight,lastline,i);
933 glColor4f(1,1,1,tutorialopac);
934 text.glPrint(screenwidth/2-7.6*(i-lastline)*screenwidth/1024,screenheight/16+screenheight*4/5-20*screenwidth/1024*line,string,1,1.5*screenwidth/1024,screenwidth,screenheight,lastline,i);
937 if(string[i]=='\0')done=1;
943 else if (hotspottype[closest]>=20&&dialoguegonethrough[hotspottype[closest]-20]==0){
944 whichdialogue=hotspottype[closest]-20;
945 for(j=0;j<numdialogueboxes[whichdialogue];j++){
946 player[participantfocus[whichdialogue][j]].coords=participantlocation[whichdialogue][participantfocus[whichdialogue][j]];
947 player[participantfocus[whichdialogue][j]].rotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
948 player[participantfocus[whichdialogue][j]].targetrotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
949 player[participantfocus[whichdialogue][j]].velocity=0;
950 player[participantfocus[whichdialogue][j]].targetanimation=player[participantfocus[whichdialogue][j]].getIdle();
951 player[participantfocus[whichdialogue][j]].targetframe=0;
955 dialoguegonethrough[whichdialogue]++;
956 if(dialogueboxsound[whichdialogue][indialogue]!=0){
958 if(dialogueboxsound[whichdialogue][indialogue]==1)whichsoundplay=rabbitchitter;
959 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
960 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
961 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
962 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
963 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
964 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
965 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
966 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
967 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
968 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
969 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
970 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
971 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
972 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
973 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
974 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
975 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
976 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
977 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
978 emit_sound_at(whichsoundplay, player[participantfocus[whichdialogue][indialogue]].coords);
984 if(indialogue!=-1&&!mainmenu){
985 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
986 glDisable(GL_CULL_FACE);
987 glDisable(GL_LIGHTING);
988 glDisable(GL_TEXTURE_2D);
990 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
991 glPushMatrix(); // Store The Projection Matrix
992 glLoadIdentity(); // Reset The Projection Matrix
993 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
994 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
995 glPushMatrix(); // Store The Modelview Matrix
996 glLoadIdentity(); // Reset The Modelview Matrix
997 if(dialogueboxlocation[whichdialogue][indialogue]==1)glTranslatef(0,screenheight*3/4,0);
998 glScalef(screenwidth,screenheight/4,1);
999 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1002 glColor4f(dialogueboxcolor[whichdialogue][indialogue][0],dialogueboxcolor[whichdialogue][indialogue][1],dialogueboxcolor[whichdialogue][indialogue][2],0.7);
1004 glVertex3f(0, 0, 0.0f);
1005 glVertex3f(1, 0, 0.0f);
1006 glVertex3f(1, 1, 0.0f);
1007 glVertex3f(0, 1, 0.0f);
1009 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1010 glPopMatrix(); // Restore The Old Projection Matrix
1011 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1012 glPopMatrix(); // Restore The Old Projection Matrix
1013 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1014 glEnable(GL_CULL_FACE);
1015 glDisable(GL_BLEND);
1017 glEnable(GL_TEXTURE_2D);
1024 startx=screenwidth*1/5;
1025 if(dialogueboxlocation[whichdialogue][indialogue]==1)starty=screenheight/16+screenheight*4/5;
1026 if(dialogueboxlocation[whichdialogue][indialogue]==2)starty=screenheight*1/5-screenheight/16;
1035 for(i=0;i<(int)strlen(dialoguename[whichdialogue][indialogue]);i++){
1036 tempname[tempnum]=dialoguename[whichdialogue][indialogue][i];
1038 if(dialoguename[whichdialogue][indialogue][i]=='#'||dialoguename[whichdialogue][indialogue][i]=='\0')goodchar=0;
1042 tempname[tempnum]='\0';
1045 sprintf (string, "%s: ", tempname);
1047 if(dialogueboxcolor[whichdialogue][indialogue][0]+dialogueboxcolor[whichdialogue][indialogue][1]+dialogueboxcolor[whichdialogue][indialogue][2]<1.5){
1048 glColor4f(0,0,0,tutorialopac);
1049 text.glPrintOutline(startx-2*7.6*strlen(string)*screenwidth/1024-4,starty-4,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight);
1050 glColor4f(0.7,0.7,0.7,tutorialopac);
1051 text.glPrint(startx-2*7.6*strlen(string)*screenwidth/1024,starty,string,1,1.5*screenwidth/1024,screenwidth,screenheight);
1055 glColor4f(0,0,0,tutorialopac);
1056 text.glPrintOutline(startx-2*7.6*strlen(string)*screenwidth/1024-4,starty-4,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight);
1060 for(i=0;i<(int)strlen(dialoguetext[whichdialogue][indialogue])+1;i++){
1061 tempname[tempnum]=dialoguetext[whichdialogue][indialogue][i];
1062 if(dialoguetext[whichdialogue][indialogue][i]!='#')tempnum++;
1065 sprintf (string, "%s", tempname);
1072 if(string[i]=='\n'||string[i]>'z'||string[i]<' '||string[i]=='\0'){
1073 if(dialogueboxcolor[whichdialogue][indialogue][0]+dialogueboxcolor[whichdialogue][indialogue][1]+dialogueboxcolor[whichdialogue][indialogue][2]<1.5){
1074 glColor4f(0,0,0,tutorialopac);
1075 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);
1076 glColor4f(1,1,1,tutorialopac);
1077 text.glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/,starty-20*screenwidth/1024*line,string,1,1.5*screenwidth/1024,screenwidth,screenheight,lastline,i);
1081 glColor4f(0,0,0,tutorialopac);
1082 text.glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/,starty-20*screenwidth/1024*line,string,1,1.5*screenwidth/1024,screenwidth,screenheight,lastline,i);
1086 if(string[i]=='\0')done=1;
1093 if(!tutoriallevel&&!winfreeze&&indialogue==-1&&!mainmenu){
1096 sprintf (string, "Score: %d", (int)accountactive->getCampaignScore());
1098 sprintf (string, "Score: %d", (int)accountactive->getCampaignScore()+(int)bonustotal);
1100 if(!campaign)sprintf (string, "Score: %d", (int)bonustotal);
1102 text.glPrintOutline(1024/40-4,768/16-4+768*14/16,string,1,1.5*1.25,1024,768);
1104 text.glPrint(1024/40,768/16+768*14/16,string,1,1.5,1024,768);
1106 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1107 glDisable(GL_CULL_FACE);
1108 glDisable(GL_LIGHTING);
1109 glDisable(GL_TEXTURE_2D);
1111 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1112 glPushMatrix(); // Store The Projection Matrix
1113 glLoadIdentity(); // Reset The Projection Matrix
1114 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1115 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1116 glPushMatrix(); // Store The Modelview Matrix
1117 glLoadIdentity(); // Reset The Modelview Matrix
1118 glTranslatef(15,screenheight*17.5/20,0);
1119 glScalef(screenwidth/3+20,screenheight/20,1);
1120 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1122 glColor4f(0.0,0.4,0.0,0.7);
1123 float bar=((float)player[0].damage)/player[0].damagetolerance;
1125 glVertex3f((bar<1?bar:1),0,0.0f);
1126 glVertex3f(1,0,0.0f);
1127 glVertex3f(1,1,0.0f);
1128 glVertex3f((bar<1?bar:1),1,0.0f);
1130 glColor4f(0.1,0.0,0.0,1);
1131 bar = ((float)player[0].bloodloss)/player[0].damagetolerance;
1133 glVertex3f(0,0,0.0f);
1134 glVertex3f((bar<1?bar:1),0,0.0f);
1135 glVertex3f((bar<1?bar:1),1,0.0f);
1136 glVertex3f(0,1,0.0f);
1138 glColor4f(0.4,0.0,0.0,0.7);
1139 bar = ((float)player[0].damage)/player[0].damagetolerance;
1141 glVertex3f(0,0,0.0f);
1142 glVertex3f((bar<1?bar:1),0,0.0f);
1143 glVertex3f((bar<1?bar:1),1,0.0f);
1144 glVertex3f(0,1,0.0f);
1146 glColor4f(0.4,0.0,0.0,0.7);
1147 bar = ((float)player[0].permanentdamage)/player[0].damagetolerance;
1149 glVertex3f(0,0,0.0f);
1150 glVertex3f((bar<1?bar:1),0,0.0f);
1151 glVertex3f((bar<1?bar:1),1,0.0f);
1152 glVertex3f(0,1,0.0f);
1154 glColor4f(0.4,0.0,0.0,0.7);
1155 bar = ((float)player[0].superpermanentdamage)/player[0].damagetolerance;
1157 glVertex3f(0,0,0.0f);
1158 glVertex3f((bar<1?bar:1),0,0.0f);
1159 glVertex3f((bar<1?bar:1),1,0.0f);
1160 glVertex3f(0,1,0.0f);
1162 glColor4f(0.0,0.0,0.0,0.7);
1164 glBegin(GL_LINE_STRIP);
1165 glVertex3f(0,0,0.0f);
1166 glVertex3f(1,0,0.0f);
1167 glVertex3f(1,1,0.0f);
1168 glVertex3f(0,1,0.0f);
1169 glVertex3f(0,0,0.0f);
1172 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1173 glPopMatrix(); // Restore The Old Projection Matrix
1174 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1175 glPopMatrix(); // Restore The Old Projection Matrix
1176 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1177 glEnable(GL_CULL_FACE);
1178 glDisable(GL_BLEND);
1180 glEnable(GL_TEXTURE_2D);
1182 // writing the numbers :
1183 sprintf (string, "Damages : %d/%d (%d)",(int)(player[0].damage),(int)(player[0].damagetolerance),(int)(player[0].bloodloss));
1185 text.glPrintOutline(1024/40-4,768/16-4+768*14/16-40,string,1,1.5*1.25,1024,768);
1187 text.glPrint(1024/40,768/16+768*14/16-40,string,1,1.5,1024,768);
1191 glColor4f(.5,.5,.5,1);
1194 if((texttoggle||editorenabled)&&debugmode&&!mainmenu){
1195 sprintf (string, "The framespersecond is %d.",(int)(fps));
1196 text.glPrint(10,30,string,0,.8,1024,768);
1198 sprintf (string, "Name: %s", registrationname);
1199 text.glPrint(10,260,string,0,.8,1024,768);
1203 sprintf (string, "Map editor enabled.");
1205 sprintf (string, "Map editor disabled.");
1206 text.glPrint(10,60,string,0,.8,1024,768);
1208 sprintf (string, "Object size: %f",editorsize);
1209 text.glPrint(10,75,string,0,.8,1024,768);
1210 if(editorrotation>=0)sprintf (string, "Object rotation: %f",editorrotation);
1211 else sprintf (string, "Object rotation: Random");
1212 text.glPrint(10,90,string,0,.8,1024,768);
1213 if(editorrotation2>=0)sprintf (string, "Object rotation2: %f",editorrotation2);
1214 else sprintf (string, "Object rotation2: Random");
1215 text.glPrint(10,105,string,0,.8,1024,768);
1216 sprintf (string, "Object type: %d",editortype);
1217 text.glPrint(10,120,string,0,.8,1024,768);
1218 switch(editortype) {
1220 sprintf (string, "(box)");
1223 sprintf (string, "(tree)");
1226 sprintf (string, "(wall)");
1229 sprintf (string, "(weird)");
1232 sprintf (string, "(spike)");
1235 sprintf (string, "(rock)");
1238 sprintf (string, "(bush)");
1241 sprintf (string, "(tunnel)");
1244 sprintf (string, "(chimney)");
1247 sprintf (string, "(platform)");
1250 sprintf (string, "(cool)");
1253 sprintf (string, "(fire)");
1256 text.glPrint(130,120,string,0,.8,1024,768);
1258 sprintf (string, "Numplayers: %d",numplayers);
1259 text.glPrint(10,155,string,0,.8,1024,768);
1260 sprintf (string, "Player %d: numwaypoints: %d",numplayers,player[numplayers-1].numwaypoints);
1261 text.glPrint(10,140,string,0,.8,1024,768);
1263 sprintf (string, "Difficulty: %d",difficulty);
1264 text.glPrint(10,240,string,0,.8,1024,768);
1269 if(drawmode==glowmode){
1270 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1271 glDisable(GL_CULL_FACE);
1272 glDisable(GL_LIGHTING);
1273 glDisable(GL_TEXTURE_2D);
1275 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1276 glPushMatrix(); // Store The Projection Matrix
1277 glLoadIdentity(); // Reset The Projection Matrix
1278 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1279 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1280 glPushMatrix(); // Store The Modelview Matrix
1281 glLoadIdentity(); // Reset The Modelview Matrix
1282 glScalef(screenwidth,screenheight,1);
1283 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1285 glColor4f(0,0,0,.5);
1287 glVertex3f(0, 0, 0.0f);
1288 glVertex3f(256, 0, 0.0f);
1289 glVertex3f(256, 256, 0.0f);
1290 glVertex3f(0, 256, 0.0f);
1292 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1293 glPopMatrix(); // Restore The Old Projection Matrix
1294 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1295 glPopMatrix(); // Restore The Old Projection Matrix
1296 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1297 glEnable(GL_CULL_FACE);
1298 glDisable(GL_BLEND);
1302 if((((blackout&&damageeffects)||(player[0].bloodloss>0&&damageeffects&&player[0].blooddimamount>0)||player[0].dead)&&!cameramode)||console){
1303 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1304 glDisable(GL_CULL_FACE);
1305 glDisable(GL_LIGHTING);
1306 glDisable(GL_TEXTURE_2D);
1308 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1309 glPushMatrix(); // Store The Projection Matrix
1310 glLoadIdentity(); // Reset The Projection Matrix
1311 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1312 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1313 glPushMatrix(); // Store The Modelview Matrix
1314 glLoadIdentity(); // Reset The Modelview Matrix
1315 glScalef(screenwidth,screenheight,1);
1316 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1318 if(player[0].dead)blackout+=multiplier*3;
1319 if(player[0].dead==1)blackout=.4f;
1320 if(player[0].dead==2&&blackout>.6)blackout=.6;
1321 glColor4f(0,0,0,blackout);
1322 if(!player[0].dead){
1323 if((player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5))*.3<.3){
1324 glColor4f(0,0,0,player[0].blooddimamount*player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5)*.3);
1325 blackout=player[0].blooddimamount*player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5)*.3;
1328 glColor4f(0,0,0,player[0].blooddimamount*.3);
1329 blackout=player[0].blooddimamount*.3;
1332 if(console)glColor4f(.7,0,0,.2);
1334 glVertex3f(0, 0, 0.0f);
1335 glVertex3f(256, 0, 0.0f);
1336 glVertex3f(256, 256, 0.0f);
1337 glVertex3f(0, 256, 0.0f);
1339 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1340 glPopMatrix(); // Restore The Old Projection Matrix
1341 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1342 glPopMatrix(); // Restore The Old Projection Matrix
1343 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1344 glEnable(GL_CULL_FACE);
1345 glDisable(GL_BLEND);
1349 if(flashamount>0&&damageeffects){
1350 if(flashamount>1)flashamount=1;
1351 if(flashdelay<=0)flashamount-=multiplier;
1353 if(flashamount<0)flashamount=0;
1354 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1355 glDisable(GL_CULL_FACE);
1356 glDisable(GL_LIGHTING);
1358 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1359 glPushMatrix(); // Store The Projection Matrix
1360 glLoadIdentity(); // Reset The Projection Matrix
1361 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1362 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1363 glPushMatrix(); // Store The Modelview Matrix
1364 glLoadIdentity(); // Reset The Modelview Matrix
1365 glScalef(screenwidth,screenheight,1);
1366 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1368 glColor4f(flashr,flashg,flashb,flashamount);
1370 glVertex3f(0, 0, 0.0f);
1371 glVertex3f(256, 0, 0.0f);
1372 glVertex3f(256, 256, 0.0f);
1373 glVertex3f(0, 256, 0.0f);
1375 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1376 glPopMatrix(); // Restore The Old Projection Matrix
1377 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1378 glPopMatrix(); // Restore The Old Projection Matrix
1379 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1380 glEnable(GL_CULL_FACE);
1381 glDisable(GL_BLEND);
1387 glEnable(GL_TEXTURE_2D);
1390 sprintf (string, " ]");
1391 text.glPrint(10,30+screenheight-330,string,0,1,screenwidth,screenheight);
1393 sprintf (string, "_");
1394 text.glPrint(30+(float)(displayselected)*10,30+(screenheight-330),string,0,1,screenwidth,screenheight);
1398 if((i!=0||chatting)&&displaytime[i]<4)
1399 for(j=0;j<displaychars[i];j++){
1400 glColor4f(1,1,1,4-displaytime[i]);
1401 if(j<displaychars[i]){
1402 sprintf (string, "%c",displaytext[i][j]);
1403 text.glPrint(30+j*10,30+i*20+(screenheight-330),string,0,1,screenwidth,screenheight);
1409 if(minimap&&indialogue==-1){
1410 float mapviewdist = 20000;
1412 glDisable(GL_DEPTH_TEST);
1413 glColor3f (1.0, 1.0, 1.0); // no coloring
1415 glEnable(GL_TEXTURE_2D);
1416 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1417 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1418 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1419 glDisable(GL_CULL_FACE);
1420 glDisable(GL_LIGHTING);
1422 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1423 glPushMatrix(); // Store The Projection Matrix
1424 glLoadIdentity(); // Reset The Projection Matrix
1425 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1426 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1427 glPushMatrix(); // Store The Modelview Matrix
1428 glLoadIdentity(); // Reset The Modelview Matrix
1429 glScalef((float)screenwidth/2,(float)screenwidth/2,1);
1430 glTranslatef(1.75,.25,0);
1431 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1439 int numliveplayers=0;
1441 for(i=0;i<numplayers;i++){
1442 if(!player[i].dead) numliveplayers++;
1447 for(i=0;i<objects.numobjects;i++){
1448 if(objects.type[i]==treetrunktype||objects.type[i]==boxtype){
1449 center+=objects.position[i];
1453 for(i=0;i<numplayers;i++){
1454 if(!player[i].dead)center+=player[i].coords;
1456 center/=numadd+numliveplayers;
1458 center=player[0].coords;
1460 float maxdistance=0;
1463 for(i=0;i<objects.numobjects;i++){
1464 tempdist=findDistancefast(¢er,&objects.position[i]);
1465 if(tempdist>maxdistance){
1467 maxdistance=tempdist;
1470 for(i=0;i<numplayers;i++){
1471 if(!player[i].dead){
1472 tempdist=findDistancefast(¢er,&player[i].coords);
1473 if(tempdist>maxdistance){
1475 maxdistance=tempdist;
1479 radius=fast_sqrt(maxdistance);
1483 glScalef(.25/radius*256*terrain.scale*.4,.25/radius*256*terrain.scale*.4,1);
1485 glScalef(1/(1/radius*256*terrain.scale*.4),1/(1/radius*256*terrain.scale*.4),1);
1487 glRotatef(player[0].lookrotation*-1+180,0,0,1);
1488 glTranslatef(-(center.x/terrain.scale/256*-2+1),(center.z/terrain.scale/256*-2+1),0);
1489 for(i=0;i<objects.numobjects;i++){
1490 if(objects.type[i]==treetrunktype){
1491 distcheck=findDistancefast(&player[0].coords,&objects.position[i]);
1492 if(distcheck<mapviewdist){
1493 glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
1494 glColor4f(0,.3,0,opac*(1-distcheck/mapviewdist));
1496 glTranslatef(objects.position[i].x/terrain.scale/256*-2+1,objects.position[i].z/terrain.scale/256*2-1,0);
1497 glRotatef(objects.rotation[i],0,0,1);
1498 glScalef(.003,.003,.003);
1501 glVertex3f(-1, -1, 0.0f);
1503 glVertex3f(1, -1, 0.0f);
1505 glVertex3f(1, 1, 0.0f);
1507 glVertex3f(-1, 1, 0.0f);
1512 if(objects.type[i]==boxtype){
1513 distcheck=findDistancefast(&player[0].coords,&objects.position[i]);
1514 if(distcheck<mapviewdist){
1515 glBindTexture( GL_TEXTURE_2D, Mapboxtexture);
1516 glColor4f(.4,.4,.4,opac*(1-distcheck/mapviewdist));
1518 glTranslatef(objects.position[i].x/terrain.scale/256*-2+1,objects.position[i].z/terrain.scale/256*2-1,0);
1519 glRotatef(objects.rotation[i],0,0,1);
1520 glScalef(.01*objects.scale[i],.01*objects.scale[i],.01*objects.scale[i]);
1523 glVertex3f(-1, -1, 0.0f);
1525 glVertex3f(1, -1, 0.0f);
1527 glVertex3f(1, 1, 0.0f);
1529 glVertex3f(-1, 1, 0.0f);
1536 glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
1537 for(i=0;i<numboundaries;i++){
1538 glColor4f(0,0,0,opac/3);
1540 glTranslatef(boundary[i].x/terrain.scale/256*-2+1,boundary[i].z/terrain.scale/256*2-1,0);
1541 glScalef(.002,.002,.002);
1544 glVertex3f(-1, -1, 0.0f);
1546 glVertex3f(1, -1, 0.0f);
1548 glVertex3f(1, 1, 0.0f);
1550 glVertex3f(-1, 1, 0.0f);
1555 for(i=0;i<numplayers;i++){
1556 distcheck=findDistancefast(&player[0].coords,&player[i].coords);
1557 if(distcheck<mapviewdist){
1559 glBindTexture( GL_TEXTURE_2D, Maparrowtexture);
1560 if(i==0)glColor4f(1,1,1,opac);
1561 else if(player[i].dead==2||player[i].howactive>typesleeping)glColor4f(0,0,0,opac*(1-distcheck/mapviewdist));
1562 else if(player[i].dead)glColor4f(.3,.3,.3,opac*(1-distcheck/mapviewdist));
1563 else if(player[i].aitype==attacktypecutoff)glColor4f(1,0,0,opac*(1-distcheck/mapviewdist));
1564 else if(player[i].aitype==passivetype)glColor4f(0,1,0,opac*(1-distcheck/mapviewdist));
1565 else glColor4f(1,1,0,1);
1566 glTranslatef(player[i].coords.x/terrain.scale/256*-2+1,player[i].coords.z/terrain.scale/256*2-1,0);
1567 glRotatef(player[i].rotation+180,0,0,1);
1568 glScalef(.005,.005,.005);
1571 glVertex3f(-1, -1, 0.0f);
1573 glVertex3f(1, -1, 0.0f);
1575 glVertex3f(1, 1, 0.0f);
1577 glVertex3f(-1, 1, 0.0f);
1583 glDisable(GL_TEXTURE_2D);
1584 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1585 glPopMatrix(); // Restore The Old Projection Matrix
1586 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1587 glPopMatrix(); // Restore The Old Projection Matrix
1588 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1589 glEnable(GL_CULL_FACE);
1590 glDisable(GL_BLEND);
1594 if(loading&&!stealthloading&&(!campaign||player[0].dead)){
1595 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1596 glDisable(GL_CULL_FACE);
1597 glDisable(GL_LIGHTING);
1598 glDisable(GL_TEXTURE_2D);
1600 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1601 glPushMatrix(); // Store The Projection Matrix
1602 glLoadIdentity(); // Reset The Projection Matrix
1603 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1604 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1605 glPushMatrix(); // Store The Modelview Matrix
1606 glLoadIdentity(); // Reset The Modelview Matrix
1607 glScalef(screenwidth,screenheight,1);
1608 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1610 glColor4f(0,0,0,.7);
1612 glVertex3f(0, 0, 0.0f);
1613 glVertex3f(256, 0, 0.0f);
1614 glVertex3f(256, 256, 0.0f);
1615 glVertex3f(0, 256, 0.0f);
1617 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1618 glPopMatrix(); // Restore The Old Projection Matrix
1619 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1620 glPopMatrix(); // Restore The Old Projection Matrix
1621 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1622 glEnable(GL_CULL_FACE);
1623 glDisable(GL_BLEND);
1627 glDisable(GL_DEPTH_TEST);
1628 glColor3f (1.0, 1.0, 1.0); // no coloring
1630 glEnable(GL_TEXTURE_2D);
1635 glEnable(GL_TEXTURE_2D);
1637 sprintf (string, "Loading...");
1638 text.glPrint(1024/2-90,768/2,string,1,2,1024,768);
1641 //if(ismotionblur)drawmode=motionblurmode;
1642 drawmode=normalmode;
1645 if(winfreeze&&!campaign){
1646 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1647 glDisable(GL_CULL_FACE);
1648 glDisable(GL_LIGHTING);
1649 glDisable(GL_TEXTURE_2D);
1651 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1652 glPushMatrix(); // Store The Projection Matrix
1653 glLoadIdentity(); // Reset The Projection Matrix
1654 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1655 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1656 glPushMatrix(); // Store The Modelview Matrix
1657 glLoadIdentity(); // Reset The Modelview Matrix
1658 glScalef(screenwidth,screenheight,1);
1659 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1661 glColor4f(0,0,0,.4);
1663 glVertex3f(0, 0, 0.0f);
1664 glVertex3f(256, 0, 0.0f);
1665 glVertex3f(256, 256, 0.0f);
1666 glVertex3f(0, 256, 0.0f);
1668 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1669 glPopMatrix(); // Restore The Old Projection Matrix
1670 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1671 glPopMatrix(); // Restore The Old Projection Matrix
1672 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1673 glEnable(GL_CULL_FACE);
1674 glDisable(GL_BLEND);
1678 glDisable(GL_DEPTH_TEST);
1679 glColor3f (1.0, 1.0, 1.0); // no coloring
1681 glEnable(GL_TEXTURE_2D);
1683 //Win Screen Won Victory
1685 glEnable(GL_TEXTURE_2D);
1687 sprintf (string, "Level Cleared!");
1688 text.glPrintOutlined(1024/2-strlen(string)*10,768*7/8,string,1,2,1024,768);
1690 sprintf (string, "Score: %d",(int)(bonustotal-startbonustotal));
1691 text.glPrintOutlined(1024/30,768*6/8,string,1,2,1024,768);
1694 sprintf (string, "Press Escape or Space to continue");
1696 sprintf (string, "Press Escape to return to menu or Space to continue");
1697 text.glPrintOutlined(640/2-strlen(string)*5,480*1/16,string,1,1,640,480);
1701 for(i=0;i<255;i++)string[i]='\0';
1702 sprintf (temp, "Time: %d:",(int)(((int)leveltime-(int)(leveltime)%60)/60));
1703 strcat(string,temp);
1704 if((int)(leveltime)%60<10)strcat(string,"0");
1705 sprintf (temp, "%d",(int)(leveltime)%60);
1706 strcat(string,temp);
1707 text.glPrintOutlined(1024/30,768*6/8-40,string,1,2,1024,768);
1710 int awards[award_count];
1711 int numawards = award_awards(awards);
1713 for (i = 0; i < numawards && i < 6; i++)
1714 text.glPrintOutlined(1024/30,768*6/8-90-40*i,award_names[awards[i]],1,2,1024,768);
1717 if(drawmode!=normalmode){
1718 glEnable(GL_TEXTURE_2D);
1720 if(!drawtoggle||drawmode!=realmotionblurmode||(drawtoggle==2||change==1)){
1723 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
1724 GLfloat subtractColor[4] = { 0.5, 0.5, 0.5, 0.0 };
1725 glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, subtractColor);
1726 //glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_SUBTRACT);
1727 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE);
1728 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_CONSTANT_EXT);
1729 glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 2.0f);
1731 glBindTexture( GL_TEXTURE_2D, screentexture);
1732 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1735 if((drawtoggle||change==1)&&drawmode==realmotionblurmode){
1737 glBindTexture( GL_TEXTURE_2D, screentexture2);
1738 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1740 if(!screentexture2){
1741 glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
1743 glGenTextures( 1, &screentexture2 );
1744 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
1746 glEnable(GL_TEXTURE_2D);
1747 glBindTexture( GL_TEXTURE_2D, screentexture2);
1748 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
1749 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
1751 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
1757 glClear(GL_DEPTH_BUFFER_BIT);
1758 ReSizeGLScene(90,.1f);
1759 glViewport(0,0,screenwidth,screenheight);
1761 if(drawmode!=normalmode){
1762 glDisable(GL_DEPTH_TEST);
1763 if(drawmode==motionblurmode){
1764 glDrawBuffer(GL_FRONT);
1765 glReadBuffer(GL_BACK);
1767 glColor3f (1.0, 1.0, 1.0); // no coloring
1769 glEnable(GL_TEXTURE_2D);
1770 glBindTexture( GL_TEXTURE_2D, screentexture);
1771 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1772 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1773 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1774 glDisable(GL_CULL_FACE);
1775 glDisable(GL_LIGHTING);
1777 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1778 glPushMatrix(); // Store The Projection Matrix
1779 glLoadIdentity(); // Reset The Projection Matrix
1780 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1781 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1782 glPushMatrix(); // Store The Modelview Matrix
1783 glLoadIdentity(); // Reset The Modelview Matrix
1784 glScalef((float)screenwidth/2,(float)screenheight/2,1);
1785 glTranslatef(1,1,0);
1786 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1788 if(drawmode==motionblurmode){
1789 if(motionbluramount<.2)motionbluramount=.2;
1790 //glColor4f(1,1,1,fast_sqrt(multiplier)*2.9*motionbluramount);
1791 glColor4f(1,1,1,motionbluramount);
1795 glVertex3f(-1, -1, 0.0f);
1796 glTexCoord2f(texcoordwidth,0);
1797 glVertex3f(1, -1, 0.0f);
1798 glTexCoord2f(texcoordwidth,texcoordheight);
1799 glVertex3f(1, 1, 0.0f);
1800 glTexCoord2f(0,texcoordheight);
1801 glVertex3f(-1, 1, 0.0f);
1805 if(drawmode==realmotionblurmode){
1806 glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
1807 glClear(GL_COLOR_BUFFER_BIT);
1808 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
1809 glBindTexture( GL_TEXTURE_2D, screentexture);
1810 glColor4f(1,1,1,.5);
1814 glVertex3f(-1, -1, 0.0f);
1815 glTexCoord2f(texcoordwidth,0);
1816 glVertex3f(1, -1, 0.0f);
1817 glTexCoord2f(texcoordwidth,texcoordheight);
1818 glVertex3f(1, 1, 0.0f);
1819 glTexCoord2f(0,texcoordheight);
1820 glVertex3f(-1, 1, 0.0f);
1823 glBindTexture( GL_TEXTURE_2D, screentexture2);
1824 glColor4f(1,1,1,.5);
1828 glVertex3f(-1, -1, 0.0f);
1829 glTexCoord2f(texcoordwidth,0);
1830 glVertex3f(1, -1, 0.0f);
1831 glTexCoord2f(texcoordwidth,texcoordheight);
1832 glVertex3f(1, 1, 0.0f);
1833 glTexCoord2f(0,texcoordheight);
1834 glVertex3f(-1, 1, 0.0f);
1837 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1839 if(drawmode==doublevisionmode){
1840 static float crosseyedness;
1841 crosseyedness=abs(player[0].damage-player[0].superpermanentdamage-(player[0].damagetolerance-player[0].superpermanentdamage)*1/2)/30;
1842 if(crosseyedness>1)crosseyedness=1;
1843 if(crosseyedness<0)crosseyedness=0;
1845 glDisable(GL_BLEND);
1850 glVertex3f(-1, -1, 0.0f);
1851 glTexCoord2f(texcoordwidth,0);
1852 glVertex3f(1, -1, 0.0f);
1853 glTexCoord2f(texcoordwidth,texcoordheight);
1854 glVertex3f(1, 1, 0.0f);
1855 glTexCoord2f(0,texcoordheight);
1856 glVertex3f(-1, 1, 0.0f);
1860 glColor4f(1,1,1,.5);
1863 glTranslatef(.015*crosseyedness,0,0);
1867 glVertex3f(-1, -1, 0.0f);
1868 glTexCoord2f(texcoordwidth,0);
1869 glVertex3f(1, -1, 0.0f);
1870 glTexCoord2f(texcoordwidth,texcoordheight);
1871 glVertex3f(1, 1, 0.0f);
1872 glTexCoord2f(0,texcoordheight);
1873 glVertex3f(-1, 1, 0.0f);
1878 if(drawmode==glowmode){
1879 glColor4f(.5,.5,.5,.5);
1881 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
1883 glTranslatef(.01,0,0);
1886 glVertex3f(-1, -1, 0.0f);
1887 glTexCoord2f(texcoordwidth,0);
1888 glVertex3f(1, -1, 0.0f);
1889 glTexCoord2f(texcoordwidth,texcoordheight);
1890 glVertex3f(1, 1, 0.0f);
1891 glTexCoord2f(0,texcoordheight);
1892 glVertex3f(-1, 1, 0.0f);
1896 glTranslatef(-.01,0,0);
1899 glVertex3f(-1, -1, 0.0f);
1900 glTexCoord2f(texcoordwidth,0);
1901 glVertex3f(1, -1, 0.0f);
1902 glTexCoord2f(texcoordwidth,texcoordheight);
1903 glVertex3f(1, 1, 0.0f);
1904 glTexCoord2f(0,texcoordheight);
1905 glVertex3f(-1, 1, 0.0f);
1909 glTranslatef(.0,.01,0);
1912 glVertex3f(-1, -1, 0.0f);
1913 glTexCoord2f(texcoordwidth,0);
1914 glVertex3f(1, -1, 0.0f);
1915 glTexCoord2f(texcoordwidth,texcoordheight);
1916 glVertex3f(1, 1, 0.0f);
1917 glTexCoord2f(0,texcoordheight);
1918 glVertex3f(-1, 1, 0.0f);
1922 glTranslatef(0,-.01,0);
1925 glVertex3f(-1, -1, 0.0f);
1926 glTexCoord2f(texcoordwidth,0);
1927 glVertex3f(1, -1, 0.0f);
1928 glTexCoord2f(texcoordwidth,texcoordheight);
1929 glVertex3f(1, 1, 0.0f);
1930 glTexCoord2f(0,texcoordheight);
1931 glVertex3f(-1, 1, 0.0f);
1935 if(drawmode==radialzoommode){
1937 //glRotatef((float)i*.1,0,0,1);
1938 glColor4f(1,1,1,1/((float)i+1));
1940 glScalef(1+(float)i*.01,1+(float)i*.01,1);
1943 glVertex3f(-1, -1, 0.0f);
1944 glTexCoord2f(texcoordwidth,0);
1945 glVertex3f(1, -1, 0.0f);
1946 glTexCoord2f(texcoordwidth,texcoordheight);
1947 glVertex3f(1, 1, 0.0f);
1948 glTexCoord2f(0,texcoordheight);
1949 glVertex3f(-1, 1, 0.0f);
1954 glDisable(GL_TEXTURE_2D);
1955 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1956 glPopMatrix(); // Restore The Old Projection Matrix
1957 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1958 glPopMatrix(); // Restore The Old Projection Matrix
1959 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1960 glEnable(GL_CULL_FACE);
1961 glDisable(GL_BLEND);
1966 glEnable(GL_TEXTURE_2D);
1969 if(consoleselected>=60)
1970 offset=consoleselected-60;
1971 sprintf (string, " ]");
1972 text.glPrint(10,30,string,0,1,1024,768);
1974 sprintf (string, "_");
1975 text.glPrint(30+(float)(consoleselected)*10-offset*10,30,string,0,1,1024,768);
1978 for(j=0;j<consolechars[i];j++){
1979 glColor4f(1,1,1,1-(float)(i)/16);
1980 if(j<consolechars[i]){
1981 sprintf (string, "%c",consoletext[i][j]);
1982 text.glPrint(30+j*10-offset*10,30+i*20,string,0,1,1024,768);
1989 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)||(mainmenu&&gameon)||(!gameon&&gamestarted)||(!gameon&&gamestarted)){
1990 multiplier=tempmult;
1995 // !!! FIXME: hack: clamp framerate in menu so text input works correctly on fast systems.
1998 glDrawBuffer(GL_BACK);
1999 glReadBuffer(GL_BACK);
2000 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
2001 ReSizeGLScene(90,.1f);
2004 temptexdetail=texdetail;
2005 if(texdetail>2)texdetail=2;
2006 if(mainmenu!=oldmainmenu&&oldmainmenu!=0){
2008 LoadTexture(":Data:Textures:Newgame.png",&Mainmenuitems[1],0,0);
2009 LoadTexture(":Data:Textures:Quit.png",&Mainmenuitems[3],0,0);
2012 LoadTexture(":Data:Textures:Resume.png",&Mainmenuitems[1],0,0);
2013 LoadTexture(":Data:Textures:Endgame.png",&Mainmenuitems[3],0,0);
2016 if(lastcheck>.5||oldmainmenu!=mainmenu){
2018 ifstream ipstream(ConvertFileName(":Data:Campaigns:main.txt"));
2019 ipstream.ignore(256,':');
2020 ipstream >> campaignnumlevels;
2021 for(i=0;i<campaignnumlevels;i++){
2022 ipstream.ignore(256,':');
2023 ipstream.ignore(256,':');
2024 ipstream.ignore(256,' ');
2025 ipstream >> campaignmapname[i];
2026 ipstream.ignore(256,':');
2027 ipstream >> campaigndescription[i];
2029 if(campaigndescription[i][j]=='_')campaigndescription[i][j]=' ';
2031 ipstream.ignore(256,':');
2032 ipstream >> campaignchoosenext[i];
2033 ipstream.ignore(256,':');
2034 ipstream >> campaignnumnext[i];
2035 for(j=0;j<campaignnumnext[i];j++){
2036 ipstream.ignore(256,':');
2037 ipstream >> campaignnextlevel[i][j];
2038 campaignnextlevel[i][j]-=1;
2040 ipstream.ignore(256,':');
2041 ipstream >> campaignlocationx[i];
2042 ipstream.ignore(256,':');
2043 ipstream >> campaignlocationy[i];
2047 for(i=0;i<campaignnumlevels;i++){
2049 levelhighlight[i]=0;
2054 for(i=0;i<accountactive->getCampaignChoicesMade();i++){
2055 levelorder[i+1]=campaignnextlevel[levelorder[i]][accountactive->getCampaignChoice(i)];
2056 levelvisible[levelorder[i+1]]=1;
2058 int whichlevelstart = accountactive->getCampaignChoicesMade()-1;
2059 if(whichlevelstart<0){
2060 accountactive->setCampaignScore(0);
2061 accountactive->resetFasttime();
2062 campaignchoicenum=1;
2063 campaignchoicewhich[0]=0;
2067 campaignchoicenum=campaignnumnext[levelorder[whichlevelstart]];
2068 for(i=0;i<campaignchoicenum;i++){
2069 campaignchoicewhich[i]=campaignnextlevel[levelorder[whichlevelstart]][i];
2070 levelvisible[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
2071 levelhighlight[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
2080 texdetail=temptexdetail;
2082 oldmainmenu=mainmenu;
2084 if(mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==8||mainmenu==9||mainmenu==10||mainmenu==119||mainmenu==18){
2085 glClear(GL_DEPTH_BUFFER_BIT);
2086 glEnable(GL_ALPHA_TEST);
2087 glAlphaFunc(GL_GREATER, 0.001f);
2088 glEnable(GL_TEXTURE_2D);
2089 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
2090 glDisable(GL_CULL_FACE);
2091 glDisable(GL_LIGHTING);
2093 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2094 glPushMatrix(); // Store The Projection Matrix
2095 glLoadIdentity(); // Reset The Projection Matrix
2096 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
2097 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2098 glPushMatrix(); // Store The Modelview Matrix
2099 glLoadIdentity(); // Reset The Modelview Matrix
2100 glTranslatef(screenwidth/2,screenheight/2,0);
2102 glScalef((float)screenwidth/2,(float)screenheight/2,1);
2103 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
2104 glDisable(GL_BLEND);
2105 glColor4f(0,0,0,1.0);
2106 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2107 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2108 glDisable(GL_TEXTURE_2D);
2110 //glScalef(.25,.25,.25);
2113 glVertex3f(-1, -1, 0.0f);
2115 glVertex3f(1, -1, 0.0f);
2117 glVertex3f(1, 1, 0.0f);
2119 glVertex3f(-1, 1, 0.0f);
2123 glColor4f(0.4,0.4,0.4,1.0);
2124 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2125 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2126 glEnable(GL_TEXTURE_2D);
2127 glBindTexture( GL_TEXTURE_2D, Mainmenuitems[4]);
2129 //glScalef(.25,.25,.25);
2132 glVertex3f(-1, -1, 0.0f);
2134 glVertex3f(1, -1, 0.0f);
2136 glVertex3f(1, 1, 0.0f);
2138 glVertex3f(-1, 1, 0.0f);
2143 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2145 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2149 if((float)newscreenwidth>(float)newscreenheight*1.61||(float)newscreenwidth<(float)newscreenheight*1.59)sprintf (menustring[0], "Resolution: %d*%d",(int)newscreenwidth,(int)newscreenheight);
2150 else sprintf (menustring[0], "Resolution: %d*%d (widescreen)",(int)newscreenwidth,(int)newscreenheight);
2153 endx[0]=startx[0]+strlen(menustring[0])*10;
2154 endy[0]=starty[0]+20;
2158 if(newdetail==2)sprintf (menustring[1], "Detail: High");
2159 else if(newdetail==1)sprintf (menustring[1], "Detail: Medium");
2160 else sprintf (menustring[1], "Detail: Low");
2163 endx[1]=startx[1]+strlen(menustring[1])*10;
2164 endy[1]=starty[1]+20;
2168 if(bloodtoggle==2)sprintf (menustring[2], "Blood: On, high detail (slower)");
2169 if(bloodtoggle==1)sprintf (menustring[2], "Blood: On, low detail");
2170 if(bloodtoggle==0)sprintf (menustring[2], "Blood: Off");
2173 endx[2]=startx[2]+strlen(menustring[2])*10;
2174 endy[2]=starty[2]+20;
2178 if(difficulty==2)sprintf (menustring[3], "Difficulty: Insane");
2179 if(difficulty==1)sprintf (menustring[3], "Difficulty: Difficult");
2180 if(difficulty==0)sprintf (menustring[3], "Difficulty: Easier");
2181 startx[3]=10+20-1000;
2183 endx[3]=startx[3]+strlen(menustring[3])*10;
2184 endy[3]=starty[3]+20;
2188 if(ismotionblur==1)sprintf (menustring[4], "Blur Effects: Enabled (less compatible)");
2189 if(ismotionblur==0)sprintf (menustring[4], "Blur Effects: Disabled (more compatible)");
2192 endx[4]=startx[4]+strlen(menustring[4])*10;
2193 endy[4]=starty[4]+20;
2197 if(decals==1)sprintf (menustring[5], "Decals: Enabled (slower)");
2198 if(decals==0)sprintf (menustring[5], "Decals: Disabled");
2201 endx[5]=startx[5]+strlen(menustring[5])*10;
2202 endy[5]=starty[5]+20;
2206 if(musictoggle==1)sprintf (menustring[6], "Music: Enabled");
2207 if(musictoggle==0)sprintf (menustring[6], "Music: Disabled");
2210 endx[6]=startx[6]+strlen(menustring[6])*10;
2211 endy[6]=starty[6]+20;
2215 if(invertmouse==1)sprintf (menustring[9], "Invert mouse: Yes");
2216 if(invertmouse==0)sprintf (menustring[9], "Invert mouse: No");
2219 endx[9]=startx[9]+strlen(menustring[9])*10;
2220 endy[9]=starty[9]+20;
2224 sprintf (menustring[10], "Mouse Speed: %d", (int)(usermousesensitivity*5));
2227 endx[10]=startx[10]+strlen(menustring[10])*10;
2228 endy[10]=starty[10]+20;
2232 sprintf (menustring[11], "Volume: %d%%", (int)(volume*100));
2235 endx[11]=startx[11]+strlen(menustring[11])*10;
2236 endy[11]=starty[11]+20;
2240 sprintf (menustring[13], "Damage Bar: %s",(showdamagebar?"on":"off"));
2243 endx[13]=startx[13]+strlen(menustring[13])*10;
2244 endy[13]=starty[13]+20;
2248 sprintf (menustring[7], "-Configure Controls-");
2251 endx[7]=startx[7]+strlen(menustring[7])*10;
2252 endy[7]=starty[7]+20;
2256 sprintf (menustring[12], "-Configure Stereo -");
2259 endx[12]=startx[12]+strlen(menustring[7])*10;
2260 endy[12]=starty[12]+20;
2264 if(newdetail==detail&&newscreenheight==(int)screenheight&&newscreenwidth==(int)screenwidth)sprintf (menustring[8], "Back");
2265 else sprintf (menustring[8], "Back (some changes take effect next time Lugaru is opened)");
2267 endx[8]=startx[8]+strlen(menustring[8])*10;
2269 endy[8]=starty[8]+20;
2276 if(keyselect!=0)sprintf (menustring[0], "Forwards: %s",Input::keyToChar(forwardkey));
2277 else sprintf (menustring[0], "Forwards: _");
2280 endx[0]=startx[0]+strlen(menustring[0])*10;
2281 endy[0]=starty[0]+20;
2285 if(keyselect!=1)sprintf (menustring[1], "Back: %s",Input::keyToChar(backkey));
2286 else sprintf (menustring[1], "Back: _");
2289 endx[1]=startx[1]+strlen(menustring[1])*10;
2290 endy[1]=starty[1]+20;
2294 if(keyselect!=2)sprintf (menustring[2], "Left: %s",Input::keyToChar(leftkey));
2295 else sprintf (menustring[2], "Left: _");
2298 endx[2]=startx[2]+strlen(menustring[2])*10;
2299 endy[2]=starty[2]+20;
2303 if(keyselect!=3)sprintf (menustring[3], "Right: %s",Input::keyToChar(rightkey));
2304 else sprintf (menustring[3], "Right: _");
2307 endx[3]=startx[3]+strlen(menustring[3])*10;
2308 endy[3]=starty[3]+20;
2312 if(keyselect!=4)sprintf (menustring[4], "Crouch: %s",Input::keyToChar(crouchkey));
2313 else sprintf (menustring[4], "Crouch: _");
2316 endx[4]=startx[4]+strlen(menustring[4])*10;
2317 endy[4]=starty[4]+20;
2321 if(keyselect!=5)sprintf (menustring[5], "Jump: %s",Input::keyToChar(jumpkey));
2322 else sprintf (menustring[5], "Jump: _");
2325 endx[5]=startx[5]+strlen(menustring[5])*10;
2326 endy[5]=starty[5]+20;
2330 if(keyselect!=6)sprintf (menustring[6], "Draw: %s",Input::keyToChar(drawkey));
2331 else sprintf (menustring[6], "Draw: _");
2334 endx[6]=startx[6]+strlen(menustring[6])*10;
2335 endy[6]=starty[6]+20;
2339 if(keyselect!=7)sprintf (menustring[7], "Throw: %s",Input::keyToChar(throwkey));
2340 else sprintf (menustring[7], "Throw: _");
2343 endx[7]=startx[7]+strlen(menustring[7])*10;
2344 endy[7]=starty[7]+20;
2348 if(keyselect!=8)sprintf (menustring[8], "Attack: %s",Input::keyToChar(attackkey));
2349 else sprintf (menustring[8], "Attack: _");
2352 endx[8]=startx[8]+strlen(menustring[8])*10;
2353 endy[8]=starty[8]+20;
2359 sprintf (menustring[9], "Back");
2361 endx[9]=startx[9]+strlen(menustring[9])*10;
2363 endy[9]=starty[9]+20;
2368 nummenuitems=7+accountactive->getCampaignChoicesMade()+campaignchoicenum;
2370 sprintf (menustring[0], "%s",accountactive->getName());
2373 endx[0]=startx[0]+strlen(menustring[0])*10;
2374 endy[0]=starty[0]+20;
2378 sprintf (menustring[1], "Tutorial");
2381 endx[1]=startx[1]+strlen(menustring[1])*10;
2382 endy[1]=starty[1]+20;
2386 sprintf (menustring[2], "Challenge");
2389 endx[2]=startx[2]+strlen(menustring[2])*10;
2390 endy[2]=starty[2]+20;
2394 sprintf (menustring[3], "Delete User");
2397 endx[3]=startx[3]+strlen(menustring[3])*10;
2398 endy[3]=starty[3]+20;
2402 sprintf (menustring[4], "Main Menu");
2405 endx[4]=startx[4]+strlen(menustring[4])*10;
2406 endy[4]=starty[4]+20;
2410 sprintf (menustring[5], "Change User");
2412 endx[5]=startx[5]+strlen(menustring[5])*10;
2414 endy[5]=starty[5]+20;
2420 sprintf (menustring[6], "World");
2422 starty[6]=30+480-400-50;
2423 endx[6]=startx[6]+400;
2428 if(accountactive->getCampaignChoicesMade())
2429 for(i=0;i<accountactive->getCampaignChoicesMade();i++){
2430 sprintf (menustring[7+i], "%s", campaigndescription[levelorder[i]]);
2431 startx[7+i]=30+120+campaignlocationx[levelorder[i]]*400/512;
2432 starty[7+i]=30+30+(512-campaignlocationy[levelorder[i]])*400/512;
2433 endx[7+i]=startx[7+i]+10;
2434 endy[7+i]=starty[7+i]+10;
2439 if(campaignchoicenum>0)
2440 for(i=accountactive->getCampaignChoicesMade();i<accountactive->getCampaignChoicesMade()+campaignchoicenum;i++){
2441 sprintf (menustring[7+i], "%s", campaigndescription[levelorder[i]]);
2442 startx[7+i]=30+120+campaignlocationx[campaignchoicewhich[i-(accountactive->getCampaignChoicesMade())]]*400/512;
2443 starty[7+i]=30+30+(512-campaignlocationy[campaignchoicewhich[i-(accountactive->getCampaignChoicesMade())]])*400/512;
2444 endx[7+i]=startx[7+i]+10;
2445 endy[7+i]=starty[7+i]+10;
2450 /*sprintf (menustring[7], "Dot");
2451 startx[7]=120+260*400/512;
2452 starty[7]=30+(512-184)*400/512;
2453 endx[7]=startx[7]+10;
2454 endy[7]=starty[7]+10;
2458 sprintf (menustring[8], "Dot");
2459 startx[8]=120+129*400/512;
2460 starty[8]=30+(512-284)*400/512;
2461 endx[8]=startx[8]+10;
2462 endy[8]=starty[8]+10;
2466 sprintf (menustring[9], "Dot");
2467 startx[9]=120+358*400/512;
2468 starty[9]=30+(512-235)*400/512;
2469 endx[9]=startx[9]+10;
2470 endy[9]=starty[9]+10;
2474 sprintf (menustring[10], "Dot");
2475 startx[10]=120+359*400/512;
2476 starty[10]=30+(512-308)*400/512;
2477 endx[10]=startx[10]+10;
2478 endy[10]=starty[10]+10;
2482 sprintf (menustring[11], "Dot");
2483 startx[11]=120+288*400/512;
2484 starty[11]=30+(512-277)*400/512;
2485 endx[11]=startx[11]+10;
2486 endy[11]=starty[11]+10;
2494 sprintf (menustring[0], "Are you sure you want to delete this user?");
2497 endx[0]=startx[0]+strlen(menustring[0])*10;
2498 endy[0]=starty[0]+20;
2502 sprintf (menustring[1], "Yes");
2505 endx[1]=startx[1]+strlen(menustring[1])*10;
2506 endy[1]=starty[1]+20;
2510 sprintf (menustring[2], "No");
2513 endx[2]=startx[2]+strlen(menustring[2])*10;
2514 endy[2]=starty[2]+20;
2518 sprintf (menustring[3], "Extra 4");
2521 endx[3]=startx[3]+strlen(menustring[3])*10;
2522 endy[3]=starty[3]+20;
2526 sprintf (menustring[4], "Extra 5");
2529 endx[4]=startx[4]+strlen(menustring[4])*10;
2530 endy[4]=starty[4]+20;
2534 sprintf (menustring[5], "Back");
2536 endx[5]=startx[5]+strlen(menustring[5])*10;
2538 endy[5]=starty[5]+20;
2544 nummenuitems=Account::getNbAccounts()+2;
2548 if(Account::getNbAccounts()<8)
2549 sprintf (menustring[0], "New User");
2551 sprintf (menustring[0], "No More Users");
2554 endx[0]=startx[0]+strlen(menustring[0])*10;
2555 endy[0]=starty[0]+20;
2564 for(i=0;i<Account::getNbAccounts();i++){
2565 sprintf (menustring[num], "%s",Account::get(i)->getName());
2567 starty[num]=360-20-20*num;
2568 endx[num]=startx[num]+strlen(menustring[num])*10;
2569 endy[num]=starty[num]+20;
2576 sprintf (menustring[num], "Back");
2578 endx[num]=startx[num]+strlen(menustring[num])*10;
2580 endy[num]=starty[num]+20;
2587 sprintf (menustring[0], "Easier");
2590 endx[0]=startx[0]+strlen(menustring[0])*10;
2591 endy[0]=starty[0]+20;
2595 sprintf (menustring[1], "Difficult");
2598 endx[1]=startx[1]+strlen(menustring[1])*10;
2599 endy[1]=starty[1]+20;
2603 sprintf (menustring[2], "Insane");
2606 endx[2]=startx[2]+strlen(menustring[2])*10;
2607 endy[2]=starty[2]+20;
2613 //tempncl=numchallengelevels;
2614 //numchallengelevels=9;
2615 nummenuitems=2+numchallengelevels;
2618 for(j=0;j<numchallengelevels;j++){
2619 for(i=0;i<255;i++)menustring[j][i]='\0';
2620 sprintf (temp, "Level %d",j+1);
2621 strcpy(menustring[j],temp);
2622 for(i=0;i<17;i++)if(menustring[j][i]=='\0')menustring[j][i]=' ';
2623 menustring[j][17]='\0';
2624 sprintf (temp, "%d",(int)accountactive->getHighScore(j));
2625 strcat(menustring[j],temp);
2626 for(i=18;i<32;i++)if(menustring[j][i]=='\0')menustring[j][i]=' ';
2627 menustring[j][32]='\0';
2628 sprintf (temp, "%d:",(int)(((int)accountactive->getFastTime(j)-(int)(accountactive->getFastTime(j))%60)/60));
2629 strcat(menustring[j],temp);
2630 if((int)(accountactive->getFastTime(j))%60<10)strcat(menustring[j],"0");
2631 sprintf (temp, "%d",(int)(accountactive->getFastTime(j))%60);
2632 strcat(menustring[j],temp);
2636 endx[j]=startx[j]+strlen(menustring[j])*10;
2637 endy[j]=starty[j]+20;
2642 sprintf (menustring[numchallengelevels], "Back");
2643 startx[numchallengelevels]=10;
2644 endx[numchallengelevels]=startx[numchallengelevels]+strlen(menustring[numchallengelevels])*10;
2645 starty[numchallengelevels]=10;
2646 endy[numchallengelevels]=starty[numchallengelevels]+20;
2647 movex[numchallengelevels]=0;
2648 movey[numchallengelevels]=0;
2650 sprintf (menustring[numchallengelevels+1], " High Score Best Time");
2651 startx[numchallengelevels+1]=10;
2652 starty[numchallengelevels+1]=440;
2653 endx[numchallengelevels+1]=startx[numchallengelevels+1]+strlen(menustring[numchallengelevels+1])*10;
2654 endy[numchallengelevels+1]=starty[numchallengelevels+1]+20;
2655 movex[numchallengelevels+1]=0;
2656 movey[numchallengelevels+1]=0;
2658 //numchallengelevels=tempncl;
2665 sprintf (menustring[0], "Congratulations!");
2668 endx[0]=startx[0]+strlen(menustring[0])*10;
2669 endy[0]=starty[0]+20;
2673 sprintf (menustring[1], "You have avenged your family and");
2676 endx[1]=startx[1]+strlen(menustring[1])*10;
2677 endy[1]=starty[1]+20;
2681 sprintf (menustring[2], "restored peace to the island of Lugaru.");
2684 endx[2]=startx[2]+strlen(menustring[2])*10;
2685 endy[2]=starty[2]+20;
2689 sprintf (menustring[3], "Back");
2691 endx[3]=startx[3]+strlen(menustring[3])*10;
2693 endy[3]=starty[3]+20;
2697 for(i=0;i<255;i++)menustring[4][i]='\0';
2698 sprintf (temp, "Your score:");
2699 strcpy(menustring[4],temp);
2700 for(i=0;i<20;i++)if(menustring[4][i]=='\0')menustring[4][i]=' ';
2701 menustring[4][20]='\0';
2702 sprintf (temp, "%d",(int)accountactive->getCampaignScore());
2703 strcat(menustring[4],temp);
2705 endx[4]=startx[4]+strlen(menustring[4])*10;
2707 endy[4]=starty[4]+20;
2711 for(i=0;i<255;i++)menustring[5][i]='\0';
2712 sprintf (temp, "Your time:");
2713 strcpy(menustring[5],temp);
2714 for(i=0;i<20;i++)if(menustring[5][i]=='\0')menustring[5][i]=' ';
2715 menustring[5][20]='\0';
2716 sprintf (temp, "%d",(int)accountcampaigntime[accountactive]);
2717 strcat(menustring[5],temp);
2719 endx[5]=startx[5]+strlen(menustring[5])*10;
2721 endy[5]=starty[5]+20;
2725 for(i=0;i<255;i++)menustring[5][i]='\0';
2726 sprintf (temp, "Highest score:");
2727 strcpy(menustring[5],temp);
2728 for(i=0;i<20;i++)if(menustring[5][i]=='\0')menustring[5][i]=' ';
2729 menustring[5][20]='\0';
2730 sprintf (temp, "%d",(int)accountactive->getCampaignHighScore());
2731 strcat(menustring[5],temp);
2733 endx[5]=startx[5]+strlen(menustring[5])*10;
2735 endy[5]=starty[5]+20;
2739 for(i=0;i<255;i++)menustring[7][i]='\0';
2740 sprintf (temp, "Lowest time:");
2741 strcpy(menustring[7],temp);
2742 for(i=0;i<20;i++)if(menustring[7][i]=='\0')menustring[7][i]=' ';
2743 menustring[7][20]='\0';
2744 sprintf (temp, "%d",(int)accountactive->getCampaignFasttime());
2745 strcat(menustring[7],temp);
2747 endx[7]=startx[7]+strlen(menustring[7])*10;
2749 endy[7]=starty[7]+20;
2755 sprintf (menustring[0], "Stereo mode: %s", StereoModeName(newstereomode));
2758 endx[0]=startx[0]+strlen(menustring[0])*10;
2759 endy[0]=starty[0]+20;
2763 sprintf (menustring[1], "Stereo separation: %.3f", stereoseparation);
2766 endx[1]=startx[1]+strlen(menustring[1])*10;
2767 endy[1]=starty[1]+20;
2771 sprintf (menustring[2], "Reverse stereo: %s", stereoreverse ? "Yes" : "No");
2774 endx[2]=startx[2]+strlen(menustring[2])*10;
2775 endy[2]=starty[2]+20;
2779 sprintf (menustring[3], "Back");
2781 endx[3]=startx[3]+strlen(menustring[3])*10;
2783 endy[3]=starty[3]+20;
2789 if(mainmenu==1||mainmenu==2){
2799 starty[1]=480-152-32;
2806 starty[2]=480-228-32;
2814 starty[3]=480-306-32;
2823 starty[3]=480-306-32;
2837 starty[4]=480-140-256;
2844 starty[5]=480-138-256;
2851 starty[6]=480-144-256;
2859 starty[4]=480-140-256;
2866 starty[5]=480-138-256;
2873 starty[6]=480-144-256;
2881 starty[4]=480-140-256;
2888 starty[5]=480-150-256;
2895 starty[6]=480-144-256;
2903 starty[4]=480-140-256;
2910 starty[5]=480-150-256;
2917 starty[6]=480-144-256;
2925 starty[4]=480-100-256;
2932 starty[5]=480-120-256;
2939 starty[6]=480-144-256;
2949 if(mainmenu==1||mainmenu==2)
2951 if((mousecoordh/screenwidth*640)>startx[i]&&(mousecoordh/screenwidth*640)<endx[i]&&480-(mousecoordv/screenheight*480)>starty[i]&&480-(mousecoordv/screenheight*480)<endy[i]){
2956 if(mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==8||mainmenu==9||mainmenu==10||mainmenu==18)
2957 for(i=0;i<nummenuitems;i++){
2958 if((mousecoordh/screenwidth*640)>startx[i]&&(mousecoordh/screenwidth*640)<endx[i]&&480-(mousecoordv/screenheight*480)>starty[i]&&480-(mousecoordv/screenheight*480)<endy[i]){
2959 if(mainmenu!=5)selected=i;
2960 if(mainmenu==5&&(i!=0&&i!=6))selected=i;
2961 if(mainmenu==9&&(i!=numchallengelevels+1))selected=i; // seem useless, if mainmenu==9 then mainmenu!=5, so selected==i.
2965 for(i=0;i<nummenuitems;i++){
2967 selectedlong[i]+=multiplier*5;
2968 if(selectedlong[i]>1) selectedlong[i]=1;
2970 selectedlong[i]-=multiplier*5;
2971 if(selectedlong[i]<0) selectedlong[i]=0;
2973 offsetx[i]=(startx[i]+endx[i])/2-(mousecoordh/screenwidth*640);
2974 offsety[i]=(starty[i]+endy[i])/2-(480-(mousecoordv/screenheight*480));
2979 if(i>=4&&(mainmenu==1||mainmenu==2)){
2981 offsetx[i]=(startx[i]+endx[i]+movex[i]*transition)/2-(640+190)/2;
2982 offsety[i]=(starty[i]+endy[i]+movey[i]*transition)/2-(336+150)/2;
2988 if(mainmenu==1||mainmenu==2){
2989 glClear(GL_DEPTH_BUFFER_BIT);
2990 glEnable(GL_ALPHA_TEST);
2991 glAlphaFunc(GL_GREATER, 0.001f);
2992 glEnable(GL_TEXTURE_2D);
2993 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
2994 glDisable(GL_CULL_FACE);
2995 glDisable(GL_LIGHTING);
2997 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2998 glPushMatrix(); // Store The Projection Matrix
2999 glLoadIdentity(); // Reset The Projection Matrix
3000 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
3001 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3002 glPushMatrix(); // Store The Modelview Matrix
3003 glLoadIdentity(); // Reset The Modelview Matrix
3004 glTranslatef(screenwidth/2,screenheight/2,0);
3006 glScalef((float)screenwidth/2,(float)screenheight/2,1);
3007 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3008 glDisable(GL_BLEND);
3009 glColor4f(0,0,0,1.0);
3010 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
3011 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
3012 glDisable(GL_TEXTURE_2D);
3014 //glScalef(.25,.25,.25);
3017 glVertex3f(-1, -1, 0.0f);
3019 glVertex3f(1, -1, 0.0f);
3021 glVertex3f(1, 1, 0.0f);
3023 glVertex3f(-1, 1, 0.0f);
3027 glColor4f(0.4,0.4,0.4,1.0);
3028 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
3029 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
3030 glEnable(GL_TEXTURE_2D);
3031 glBindTexture( GL_TEXTURE_2D, Mainmenuitems[4]);
3033 //glScalef(.25,.25,.25);
3036 glVertex3f(-1, -1, 0.0f);
3038 glVertex3f(1, -1, 0.0f);
3040 glVertex3f(1, 1, 0.0f);
3042 glVertex3f(-1, 1, 0.0f);
3047 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3050 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3051 glPushMatrix(); // Store The Projection Matrix
3052 glLoadIdentity(); // Reset The Projection Matrix
3053 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3054 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3055 glPushMatrix(); // Store The Modelview Matrix
3056 glLoadIdentity(); // Reset The Modelview Matrix
3058 glDisable(GL_TEXTURE_2D);
3062 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3064 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3068 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3069 glPushMatrix(); // Store The Projection Matrix
3070 glLoadIdentity(); // Reset The Projection Matrix
3071 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3072 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3073 glPushMatrix(); // Store The Modelview Matrix
3074 glLoadIdentity(); // Reset The Modelview Matrix
3075 glEnable(GL_TEXTURE_2D);
3076 for(j=0;j<nummenuitems;j++)
3078 if(j<=3||(mainmenu!=1&&mainmenu!=2))
3080 //glDisable(GL_BLEND);
3081 glEnable(GL_ALPHA_TEST);
3083 //glDisable(GL_ALPHA_TEST);
3084 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3085 if(mainmenu==1||mainmenu==2)
3088 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3089 glBindTexture( GL_TEXTURE_2D, Mainmenuitems[j]);
3090 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
3091 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
3092 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3096 glVertex3f(startx[j]+movex[j]*transition, starty[j]+movey[j]*transition, 0.0f);
3098 glVertex3f(endx[j]+movex[j]*transition, starty[j]+movey[j]*transition, 0.0f);
3100 glVertex3f(endx[j]+movex[j]*transition, endy[j]+movey[j]*transition, 0.0f);
3102 glVertex3f(startx[j]+movex[j]*transition, endy[j]+movey[j]*transition, 0.0f);
3106 //glDisable(GL_ALPHA_TEST);
3107 if(j<4)glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3110 if(1-((float)i)/10-(1-selectedlong[j])>0)
3112 glColor4f(1,1,1,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3113 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3117 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);
3119 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);
3121 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);
3123 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);
3129 if(mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==8||mainmenu==9||mainmenu==10||mainmenu==18)
3131 if(mainmenu!=5||j<6)
3134 if(mainmenu==9&&j>accountactive->getProgress()&&j<numchallengelevels)glColor4f(0.5,0,0,1);
3135 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3137 if(mainmenu!=7||j!=0||!entername)
3138 text.glPrint(startx[j],starty[j],menustring[j],0,1,640,480);
3142 sprintf (string, "_");
3143 text.glPrint(startx[j]+(float)(displayselected)*10,starty[j],string,0,1,640,480);
3145 for(l=0;l<displaychars[0];l++){
3146 sprintf (string, "%c",displaytext[0][l]);
3147 text.glPrint(startx[j]+l*10,starty[j],string,0,1,640,480);
3152 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3155 if(1-((float)i)/15-(1-selectedlong[j])>0)
3157 glColor4f(1,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3158 if(mainmenu==9&&j>accountactive->getProgress()&&j<numchallengelevels)glColor4f(0.5,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3159 if(mainmenu==11&&j>accountactive->getProgress()&&j<numchallengelevels)glColor4f(0.5,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3160 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);
3161 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);
3162 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);
3163 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);
3164 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);
3165 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);
3166 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);
3167 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);
3168 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);
3174 glClear(GL_DEPTH_BUFFER_BIT);
3175 glEnable(GL_ALPHA_TEST);
3176 glAlphaFunc(GL_GREATER, 0.001f);
3177 glEnable(GL_TEXTURE_2D);
3178 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3179 glDisable(GL_CULL_FACE);
3180 glDisable(GL_LIGHTING);
3181 if(j==6)glColor4f(1,1,1,1);
3182 else glColor4f(1,0,0,1);
3184 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3185 glPushMatrix(); // Store The Projection Matrix
3186 glLoadIdentity(); // Reset The Projection Matrix
3187 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3188 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3189 glPushMatrix(); // Store The Modelview Matrix
3190 glLoadIdentity(); // Reset The Modelview Matrix
3193 //Draw world, draw map
3194 glTranslatef(2,-5,0);
3196 if(j>6&&j<nummenuitems-1)
3198 XYZ linestart,lineend,offset;
3205 //float linestartx,lineendx,linestarty,lineendy,offsetx,offsety;
3206 linestart.x=(startx[j]+endx[j])/2;
3207 linestart.y=(starty[j]+endy[j])/2;
3208 if(j>=6+accountactive->getCampaignChoicesMade()){
3209 linestart.x=(startx[6+accountactive->getCampaignChoicesMade()]+endx[6+accountactive->getCampaignChoicesMade()])/2;
3210 linestart.y=(starty[6+accountactive->getCampaignChoicesMade()]+endy[6+accountactive->getCampaignChoicesMade()])/2;
3212 lineend.x=(startx[j+1]+endx[j+1])/2;
3213 lineend.y=(starty[j+1]+endy[j+1])/2;
3214 offset=lineend-linestart;
3217 offset=DoRotation(offset,0,0,90);
3219 glDisable(GL_TEXTURE_2D);
3221 if(j<6+accountactive->getCampaignChoicesMade()){
3222 glColor4f(0.5,0,0,1);
3230 linestart+=fac*4*startsize;
3231 lineend-=fac*4*endsize;
3233 if(!(j>7+accountactive->getCampaignChoicesMade()+campaignchoicenum)){
3234 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3238 glVertex3f(linestart.x-offset.x*startsize, linestart.y-offset.y*startsize, 0.0f);
3240 glVertex3f(linestart.x+offset.x*startsize, linestart.y+offset.y*startsize, 0.0f);
3242 glVertex3f(lineend.x+offset.x*endsize, lineend.y+offset.y*endsize, 0.0f);
3244 glVertex3f(lineend.x-offset.x*endsize, lineend.y-offset.y*endsize, 0.0f);
3248 glEnable(GL_TEXTURE_2D);
3252 if(j==6)glBindTexture( GL_TEXTURE_2D, Mainmenuitems[7]);
3253 else glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
3254 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
3255 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
3256 if(j-7<accountactive->getCampaignChoicesMade())glColor4f(0.5,0,0,1);
3257 if(j-7>=accountactive->getCampaignChoicesMade())glColor4f(1,0,0,1);
3258 if(j==6)glColor4f(1,1,1,1);
3261 itemsize=abs(startx[j]-endx[j])/2;
3263 midpoint.x=(startx[j]+endx[j])/2;
3264 midpoint.y=(starty[j]+endy[j])/2;
3265 if(j>6&&(j-7<accountactive->getCampaignChoicesMade()))itemsize*=.5;
3266 if(!(j-7>accountactive->getCampaignChoicesMade()+campaignchoicenum))
3268 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3272 glVertex3f(midpoint.x-itemsize+movex[j]*transition, midpoint.y-itemsize+movey[j]*transition, 0.0f);
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);
3282 //glDisable(GL_ALPHA_TEST);
3283 if(j<4)glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3286 if(1-((float)i)/10-(1-selectedlong[j])>0)
3288 glColor4f(1,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3289 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3293 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);
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);
3307 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3309 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3311 if(j-7>=accountactive->getCampaignChoicesMade()){
3312 text.glPrintOutlined(0.9,0,0,startx[j]+10,starty[j]-4,menustring[j],0,0.6,640,480);
3313 glDisable(GL_DEPTH_TEST);
3319 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3321 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3324 if(mainmenu==1||mainmenu==2)
3325 if(transition<.1||transition>.9){
3326 glClear(GL_DEPTH_BUFFER_BIT);
3327 glEnable(GL_ALPHA_TEST);
3328 glAlphaFunc(GL_GREATER, 0.001f);
3329 glEnable(GL_TEXTURE_2D);
3330 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3331 glDisable(GL_CULL_FACE);
3332 glDisable(GL_LIGHTING);
3334 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3335 glPushMatrix(); // Store The Projection Matrix
3336 glLoadIdentity(); // Reset The Projection Matrix
3337 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3338 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3339 glPushMatrix(); // Store The Modelview Matrix
3340 glLoadIdentity(); // Reset The Modelview Matrix
3342 glDisable(GL_TEXTURE_2D);
3344 glColor4f(1,0,0,1-(transition*10));
3346 glColor4f(1,0,0,1-((1-transition)*10));
3349 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3353 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3354 glPushMatrix(); // Store The Projection Matrix
3355 glLoadIdentity(); // Reset The Projection Matrix
3356 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
3357 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3358 glPushMatrix(); // Store The Modelview Matrix
3359 glLoadIdentity(); // Reset The Modelview Matrix
3360 glTranslatef(screenwidth/2,screenheight/2,0);
3362 glScalef((float)screenwidth/2,(float)screenheight/2,1);
3363 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3365 glEnable(GL_TEXTURE_2D);
3367 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
3368 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
3370 if(!waiting) { // hide the cursor while waiting for a key
3372 glTranslatef(mousecoordh-screenwidth/2,mousecoordv*-1+screenheight/2,0);
3373 glScalef((float)screenwidth/64,(float)screenwidth/64,1);
3374 glTranslatef(1,-1,0);
3375 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3377 glBindTexture( GL_TEXTURE_2D, cursortexture);
3379 //glScalef(.25,.25,.25);
3382 glVertex3f(-1, -1, 0.0f);
3384 glVertex3f(1, -1, 0.0f);
3386 glVertex3f(1, 1, 0.0f);
3388 glVertex3f(-1, 1, 0.0f);
3394 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3400 //printf("Flash amount: %f, delay %i\n", flashamount, flashdelay);
3401 if(flashamount>1)flashamount=1;
3402 if(flashdelay<=0)flashamount-=multiplier;
3404 if(flashamount<0)flashamount=0;
3405 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3406 glDisable(GL_CULL_FACE);
3407 glDisable(GL_LIGHTING);
3408 glDisable(GL_TEXTURE_2D);
3410 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3411 glPushMatrix(); // Store The Projection Matrix
3412 glLoadIdentity(); // Reset The Projection Matrix
3413 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
3414 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3415 glPushMatrix(); // Store The Modelview Matrix
3416 glLoadIdentity(); // Reset The Modelview Matrix
3417 glScalef(screenwidth,screenheight,1);
3418 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3420 glColor4f(flashr,flashg,flashb,flashamount);
3422 glVertex3f(0, 0, 0.0f);
3423 glVertex3f(256, 0, 0.0f);
3424 glVertex3f(256, 256, 0.0f);
3425 glVertex3f(0, 256, 0.0f);
3427 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3428 glPopMatrix(); // Restore The Old Projection Matrix
3429 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3430 glPopMatrix(); // Restore The Old Projection Matrix
3431 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
3432 glEnable(GL_CULL_FACE);
3433 glDisable(GL_BLEND);
3438 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)||(!gameon&&gamestarted)){
3439 tempmult=multiplier;
3444 if ( side == stereoRight || side == stereoCenter ) {
3445 if(drawmode!=motionblurmode||mainmenu){
3450 //myassert(glGetError() == GL_NO_ERROR);
3451 glDrawBuffer(GL_BACK);
3452 glReadBuffer(GL_BACK);
3457 if(drawtoggle==2)drawtoggle=0;
3459 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)){
3460 multiplier=tempmult;
3462 //Jordan fixed your warning!