2 Copyright (C) 2003, 2010 - Wolfire Games
4 This file is part of Lugaru.
6 Lugaru is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; either version 2
9 of the License, or (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 See the GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 #include "openal_wrapper.h"
30 extern int environment;
31 extern float texscale;
33 extern Terrain terrain;
34 //extern Sprites sprites;
35 extern float multiplier;
37 extern float viewdistance;
38 extern float fadestart;
39 extern float screenwidth,screenheight;
40 extern int kTextureSize;
41 extern FRUSTUM frustum;
43 extern Objects objects;
45 extern float usermousesensitivity;
47 extern float camerashake;
49 extern float slomodelay;
50 extern bool ismotionblur;
52 extern float blackout;
53 extern bool damageeffects;
55 extern bool texttoggle;
56 extern float blurness;
57 extern float targetblurness;
58 extern float playerdist;
59 extern bool cellophane;
61 extern float flashamount,flashr,flashg,flashb;
62 extern int flashdelay;
64 extern float motionbluramount;
66 extern bool alwaysblur;
68 extern bool tilt2weird;
69 extern bool tiltweird;
71 extern bool proportionweird;
72 extern bool vertexweird[6];
73 extern bool velocityblur;
74 extern bool debugmode;
76 extern int oldmainmenu;
77 extern int bloodtoggle;
78 extern int difficulty;
81 //extern int texdetail;
82 extern float texdetail;
83 extern bool musictoggle;
85 extern float bonusvalue;
86 extern float bonustotal;
87 extern float bonustime;
89 extern float startbonustotal;
90 extern float bonusnum[100];
91 extern int tutoriallevel;
92 extern float smoketex;
93 extern float tutorialstagetime;
94 extern float tutorialmaxtime;
95 extern int tutorialstage;
96 extern bool againbonus;
97 extern float damagedealt;
98 extern bool invertmouse;
100 extern int numhotspots;
101 extern int winhotspot;
102 extern int killhotspot;
103 extern XYZ hotspot[40];
104 extern int hotspottype[40];
105 extern float hotspotsize[40];
106 extern char hotspottext[40][256];
107 extern int currenthotspot;;
109 extern bool campaign;
110 extern bool winfreeze;
112 extern float menupulse;
114 extern bool gamestart;
116 extern int numdialogues;
117 extern int numdialogueboxes[max_dialogues];
118 extern int dialoguetype[max_dialogues];
119 extern int dialogueboxlocation[max_dialogues][max_dialoguelength];
120 extern float dialogueboxcolor[max_dialogues][max_dialoguelength][3];
121 extern int dialogueboxsound[max_dialogues][max_dialoguelength];
122 extern char dialoguetext[max_dialogues][max_dialoguelength][128];
123 extern char dialoguename[max_dialogues][max_dialoguelength][64];
124 extern XYZ dialoguecamera[max_dialogues][max_dialoguelength];
125 extern XYZ participantlocation[max_dialogues][10];
126 extern int participantfocus[max_dialogues][max_dialoguelength];
127 extern int participantaction[max_dialogues][max_dialoguelength];
128 extern float participantrotation[max_dialogues][10];
129 extern XYZ participantfacing[max_dialogues][max_dialoguelength][10];
130 extern float dialoguecamerarotation[max_dialogues][max_dialoguelength];
131 extern float dialoguecamerarotation2[max_dialogues][max_dialoguelength];
132 extern int indialogue;
133 extern int whichdialogue;
134 extern int directing;
135 extern float dialoguetime;
136 extern int dialoguegonethrough[20];
138 extern bool gamestarted;
140 extern bool showdamagebar;
142 extern int channels[100];
143 extern "C" void PlaySoundEx(int channel, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
145 void Game::flash() { // shouldn't be that way, these should be attributes and Person class should not change rendering.
152 /*********************> DrawGLScene() <*****/
153 int Game::DrawGLScene(StereoSide side)
155 static float texcoordwidth,texcoordheight;
156 static float texviewwidth, texviewheight;
158 static GLubyte color;
159 static float newbrightness;
160 static float changespeed;
161 static XYZ checkpoint;
162 static float tempmult;
164 static char string[256]="";
165 static char string2[256]="";
166 static char string3[256]="";
168 static float lastcheck;
170 lastcheck+=multiplier;
172 if ( stereomode == stereoAnaglyph ) {
174 case stereoLeft: glColorMask( 0.0, 1.0, 1.0, 1.0 ); break;
175 case stereoRight: glColorMask( 1.0, 0.0, 0.0, 1.0 ); break;
178 glColorMask( 1.0, 1.0, 1.0, 1.0 );
180 if ( stereomode == stereoHorizontalInterlaced || stereomode == stereoVerticalInterlaced ) {
181 glStencilFunc(side == stereoLeft ? GL_NOTEQUAL : GL_EQUAL, 0x01, 0x01);
185 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)){
192 numboundaries=mapradius*2;
193 if(numboundaries>360)numboundaries=360;
194 for(i=0;i<numboundaries;i++){
197 boundary[i]=mapcenter+DoRotation(boundary[i]*mapradius,0,i*(360/((float)(numboundaries))),0);
206 olddrawmode=drawmode;
207 if(ismotionblur&&!loading){
208 if((findLengthfast(&player[0].velocity)>200)&&velocityblur&&!cameramode){
209 drawmode=motionblurmode;
210 motionbluramount=200/(findLengthfast(&player[0].velocity));
213 if(player[0].damage-player[0].superpermanentdamage>(player[0].damagetolerance-player[0].superpermanentdamage)*1/2&&damageeffects&&!cameramode){
214 drawmode=doublevisionmode;
221 drawmode=motionblurmode;
223 slomodelay-=multiplier;
224 if(slomodelay<0)slomo=0;
228 if((!changed&&!slomo)||loading){
230 if(ismotionblur&&(/*fps>100||*/alwaysblur)){
231 if(olddrawmode!=realmotionblurmode)change=1;
233 drawmode=realmotionblurmode;
235 else if(olddrawmode==realmotionblurmode)change=2;
239 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted))drawmode=normalmode;
240 if((freeze||winfreeze)&&ismotionblur&&!mainmenu)drawmode=radialzoommode;
242 if(winfreeze||mainmenu)drawmode=normalmode;
245 if(drawmode==glowmode){
250 DSpContext_FadeGamma(NULL,200,&color2);
254 if(drawtoggle!=2)drawtoggle=1-drawtoggle;
258 texviewwidth=kTextureSize;
259 if(texviewwidth>screenwidth)texviewwidth=screenwidth;
260 texviewheight=kTextureSize;
261 if(texviewheight>screenheight)texviewheight=screenheight;
263 texcoordwidth=screenwidth/kTextureSize;
264 texcoordheight=screenheight/kTextureSize;
265 if(texcoordwidth>1)texcoordwidth=1;
266 if(texcoordheight>1)texcoordheight=1;
269 glDrawBuffer(GL_BACK);
270 glReadBuffer(GL_BACK);
272 if(abs(blurness-targetblurness)<multiplier*10||abs(blurness-targetblurness)>2){
273 blurness=targetblurness;
274 targetblurness=(float)(abs(Random()%100))/40;
276 if(blurness<targetblurness)
277 blurness+=multiplier*5;
279 blurness-=multiplier*5;
282 static XYZ terrainlight;
283 static float distance;
284 if(drawmode==normalmode)ReSizeGLScene(90,.1f);
285 if(drawmode!=normalmode)glViewport(0,0,texviewwidth,texviewheight);
286 glDepthFunc(GL_LEQUAL);
288 glAlphaFunc(GL_GREATER, 0.0001f);
289 glEnable(GL_ALPHA_TEST);
290 glClearColor(0.25f, 0.25f, 0.25f, 1.0f);
291 glClear(GL_DEPTH_BUFFER_BIT);
293 glMatrixMode (GL_MODELVIEW);
294 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
297 // Move the camera for the current eye's point of view.
298 // Reverse the movement if we're reversing stereo
299 glTranslatef((stereoseparation/2) * side * (stereoreverse ? -1 : 1), 0, 0);
301 if(!cameramode&&!freeze&&!winfreeze){
302 glRotatef(float(Random()%100)/10*camerashake/*+(woozy*woozy)/10*/,0,0,1);
303 glRotatef(rotation2+sin(woozy/2)*(player[0].damage/player[0].damagetolerance)*5,1,0,0);
304 glRotatef(rotation+sin(woozy)*(player[0].damage/player[0].damagetolerance)*5,0,1,0);
306 if(cameramode||freeze||winfreeze){
307 glRotatef(rotation2,1,0,0);
308 glRotatef(rotation,0,1,0);
311 if(environment==desertenvironment){
312 glRotatef((float)(abs(Random()%100))/3000-1,1,0,0);
313 glRotatef((float)(abs(Random()%100))/3000-1,0,1,0);
315 SetUpLight(&light,0);
317 if(environment==desertenvironment&&detail==2)glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, blurness+.4 );
318 if(environment==desertenvironment){
319 glRotatef((float)(abs(Random()%100))/1000,1,0,0);
320 glRotatef((float)(abs(Random()%100))/1000,0,1,0);
323 glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0);
325 glTranslatef(-viewer.x,-viewer.y,-viewer.z);
326 frustum.GetFrustum();
330 static float size,opacity,rotation;
332 for(k=0;k<numplayers;k++){
333 if(!player[k].skeleton.free&&player[k].playerdetail&&player[k].howactive<typesleeping)
334 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)
335 for(i=0;i<player[k].skeleton.num_joints;i++){
336 if(player[k].skeleton.joints[i].label==leftknee||player[k].skeleton.joints[i].label==rightknee||player[k].skeleton.joints[i].label==groin){
337 point=DoRotation(player[k].skeleton.joints[i].position,0,player[k].rotation,0)*player[k].scale+player[k].coords;
339 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;
340 if(k!=0&&tutoriallevel==1){
341 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;
343 terrain.MakeDecal(shadowdecal,point,size,opacity,rotation);
344 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
345 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
346 if(objects.position[j].y<player[k].coords.y||objects.type[j]==tunneltype||objects.type[j]==weirdtype){
347 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);
350 if(k!=0&&tutoriallevel==1){
351 opacity=.2+.2*sin(smoketex*6+i);
353 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
358 if((player[k].skeleton.free||player[k].howactive>=typesleeping)&&player[k].playerdetail)
359 if(frustum.SphereInFrustum(player[k].coords.x,player[k].coords.y,player[k].coords.z,player[k].scale*5)&&player[k].occluded<25)
360 for(i=0;i<player[k].skeleton.num_joints;i++){
361 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){
362 if(player[k].skeleton.free)point=player[k].skeleton.joints[i].position*player[k].scale+player[k].coords;
363 else point=DoRotation(player[k].skeleton.joints[i].position,0,player[k].rotation,0)*player[k].scale+player[k].coords;
365 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;
366 if(k!=0&&tutoriallevel==1){
367 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;
369 terrain.MakeDecal(shadowdecal,point,size,opacity*.7,rotation);
370 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
371 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
372 if(objects.position[j].y<player[k].coords.y||objects.type[j]==tunneltype||objects.type[j]==weirdtype){
373 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);
374 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);
377 if(k!=0&&tutoriallevel==1){
378 opacity=.2+.2*sin(smoketex*6+i);
380 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
386 if(!player[k].playerdetail)
387 if(frustum.SphereInFrustum(player[k].coords.x,player[k].coords.y,player[k].coords.z,player[k].scale*5))
389 point=player[k].coords;
391 opacity=.4-(player[k].coords.y-terrain.getHeight(player[k].coords.x,player[k].coords.z))/5;
392 terrain.MakeDecal(shadowdecal,point,size,opacity*.7,rotation);
393 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
394 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
395 point=DoRotation(player[k].coords-objects.position[j],0,-objects.rotation[j],0);
398 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
404 glEnable(GL_TEXTURE_2D);
406 glEnable(GL_DEPTH_TEST);
407 glEnable(GL_CULL_FACE);
409 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
410 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
411 glBindTexture( GL_TEXTURE_2D, terraintexture);
413 glBindTexture( GL_TEXTURE_2D, terraintexture2);
415 //glBindTexture( GL_TEXTURE_2D, terraintexture3);
416 //glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
419 terrain.drawdecals();
422 glEnable(GL_CULL_FACE);
423 glEnable(GL_LIGHTING);
425 glEnable(GL_TEXTURE_2D);
428 glEnable(GL_COLOR_MATERIAL);
443 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
444 glEnable(GL_CULL_FACE);
445 glCullFace(GL_FRONT);
447 for(k=0;k<numplayers;k++){
448 if(k==0||tutoriallevel!=1){
450 glEnable(GL_LIGHTING);
451 terrainlight=terrain.getLighting(player[k].coords.x,player[k].coords.z);
452 distance=findDistancefast(&viewer,&player[k].coords);
453 distance=(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance;
454 glColor4f(terrainlight.x,terrainlight.y,terrainlight.z,distance);
455 if(distance>=1)glDisable(GL_BLEND);
457 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;
459 if(!player[k].occluded==0)i=checkcollide(viewer,checkpoint,player[k].lastoccluded);
460 if(i==-1||player[k].occluded==0)i=checkcollide(viewer,checkpoint);
462 player[k].occluded+=1;
463 player[k].lastoccluded=i;
465 else player[k].occluded=0;
466 if(player[k].occluded<25)player[k].DrawSkeleton();
472 if(!cameramode&&musictype==stream_music2)playerdist=findDistancefastflat(&player[0].coords,&viewer);
473 else playerdist=-100;
476 glEnable(GL_TEXTURE_2D);
481 if(frustum.SphereInFrustum(realhawkcoords.x+hawk.boundingspherecenter.x,realhawkcoords.y+hawk.boundingspherecenter.y,realhawkcoords.z+hawk.boundingspherecenter.z,2)){
482 glAlphaFunc(GL_GREATER, 0.0001f);
484 glDisable(GL_CULL_FACE);
485 glDisable(GL_LIGHTING);
487 glTranslatef(hawkcoords.x,hawkcoords.y,hawkcoords.z);
488 glRotatef(hawkrotation,0,1,0);
489 glTranslatef(25,0,0);
490 distance=findDistancefast(&viewer,&realhawkcoords)*1.2;
491 glColor4f(light.color[0],light.color[1],light.color[2],(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance);
492 if((viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance>1)glColor4f(light.color[0],light.color[1],light.color[2],1);
493 if((viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance>0)
494 hawk.drawdifftex(hawktexture);
498 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
499 glEnable(GL_CULL_FACE);
500 glCullFace(GL_FRONT);
502 for(k=0;k<numplayers;k++){
503 if(!(k==0||tutoriallevel!=1)){
505 glEnable(GL_LIGHTING);
506 terrainlight=terrain.getLighting(player[k].coords.x,player[k].coords.z);
507 distance=findDistancefast(&viewer,&player[k].coords);
508 distance=(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance;
509 glColor4f(terrainlight.x,terrainlight.y,terrainlight.z,distance);
510 if(distance>=1)glDisable(GL_BLEND);
512 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;
514 if(!player[k].occluded==0)i=checkcollide(viewer,checkpoint,player[k].lastoccluded);
515 if(i==-1||player[k].occluded==0)i=checkcollide(viewer,checkpoint);
517 player[k].occluded+=1;
518 player[k].lastoccluded=i;
520 else player[k].occluded=0;
521 if(player[k].occluded<25)player[k].DrawSkeleton();
527 glEnable(GL_TEXTURE_2D);
532 glDisable(GL_COLOR_MATERIAL);
534 glDisable(GL_LIGHTING);
535 glDisable(GL_TEXTURE_2D);
543 glDisable(GL_LIGHTING);
544 glDisable(GL_TEXTURE_2D);
545 glDisable(GL_COLOR_MATERIAL);
548 for(k=0;k<numplayers;k++){
549 if(player[k].numwaypoints>1){
550 glBegin(GL_LINE_LOOP);
551 for(i=0;i<player[k].numwaypoints;i++){
552 glVertex3f(player[k].waypoints[i].x,player[k].waypoints[i].y+.5,player[k].waypoints[i].z);
561 for(k=0;k<numpathpoints;k++){
562 if(numpathpointconnect[k]){
563 for(i=0;i<numpathpointconnect[k];i++){
564 glBegin(GL_LINE_LOOP);
565 glVertex3f(pathpoint[k].x,pathpoint[k].y+.5,pathpoint[k].z);
566 glVertex3f(pathpoint[pathpointconnect[k][i]].x,pathpoint[pathpointconnect[k][i]].y+.5,pathpoint[pathpointconnect[k][i]].z);
574 glVertex3f(pathpoint[pathpointselected].x,pathpoint[pathpointselected].y+.5,pathpoint[pathpointselected].z);
581 glEnable(GL_TEXTURE_2D);
582 glColor4f(.5,.5,.5,1);
584 sprintf (string, " ",(int)(fps));
585 text.glPrint(10,30,string,0,.8,screenwidth,screenheight);
588 if(bonus>0&&bonustime<1&&!winfreeze&&indialogue==-1/*bonustime<4*/){
589 const char *bonus_name;
590 if (bonus < bonus_count)
591 bonus_name = bonus_names[bonus];
593 bonus_name = "Excellent!"; // When does this happen?
595 glColor4f(0,0,0,1-bonustime);
596 text.glPrintOutline(1024/2-10*strlen(bonus_name)-4,768/16-4+768*4/5,bonus_name,1,2.5,1024,768);
597 glColor4f(1,0,0,1-bonustime);
598 text.glPrint(1024/2-10*strlen(bonus_name),768/16+768*4/5,bonus_name,1,2,1024,768);
600 sprintf (string, "%d",(int)bonusvalue);
601 glColor4f(0,0,0,1-bonustime);
602 text.glPrintOutline(1024/2-10*strlen(string)-4,768/16-4-20+768*4/5,string,1,2.5*.8,1024,768);
603 glColor4f(1,0,0,1-bonustime);
604 text.glPrint(1024/2-10*strlen(string),768/16-20+768*4/5,string,1,2*.8,1024,768);
605 glColor4f(.5,.5,.5,1);
608 if(tutoriallevel==1){
609 tutorialopac=tutorialmaxtime-tutorialstagetime;
610 if(tutorialopac>1)tutorialopac=1;
611 if(tutorialopac<0)tutorialopac=0;
613 sprintf (string, " ");
614 sprintf (string2, " ");
615 sprintf (string3, " ");
616 if(tutorialstage==0){
617 sprintf (string, " ");
618 sprintf (string2, " ");
619 sprintf (string3, " ");
621 if(tutorialstage==1){
622 sprintf (string, "Welcome to the Lugaru training level!");
623 sprintf (string2, " ");
624 sprintf (string3, " ");
626 if(tutorialstage==2){
627 sprintf (string, "BASIC MOVEMENT:");
628 sprintf (string2, " ");
629 sprintf (string3, " ");
631 if(tutorialstage==3){
632 sprintf (string, "You can move the mouse to rotate the camera.");
633 sprintf (string2, " ");
634 sprintf (string3, " ");
636 if(tutorialstage==4){
637 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));
638 sprintf (string2, "All movement is relative to the camera.");
639 sprintf (string3, " ");
641 if(tutorialstage==5){
642 sprintf (string, "Please press %s to jump.",Input::keyToChar(jumpkey));
643 sprintf (string2, "You can hold it longer to jump higher.");
644 sprintf (string3, " ");
646 if(tutorialstage==6){
647 sprintf (string, "You can press %s to crouch.",Input::keyToChar(crouchkey));
648 sprintf (string2, "You can jump higher from a crouching position.");
649 sprintf (string3, " ");
651 if(tutorialstage==7){
652 sprintf (string, "While running, you can press %s to roll.",Input::keyToChar(crouchkey));
653 sprintf (string2, " ");
654 sprintf (string3, " ");
656 if(tutorialstage==8){
657 sprintf (string, "While crouching, you can sneak around silently");
658 sprintf (string2, "using the movement keys.");
659 sprintf (string3, " ");
661 if(tutorialstage==9){
662 sprintf (string, "Release the crouch key while sneaking and hold the movement keys");
663 sprintf (string2, "to run animal-style.");
664 sprintf (string3, " ");
666 if(tutorialstage==10){
667 sprintf (string, "ADVANCED MOVEMENT:");
668 sprintf (string2, " ");
669 sprintf (string3, " ");
671 if(tutorialstage==11){
672 sprintf (string, "When you jump at a wall, you can hold %s again",Input::keyToChar(jumpkey));
673 sprintf (string2, "during impact to perform a walljump.");
674 sprintf (string3, "Be sure to use the movement keys to press against the wall");
676 if(tutorialstage==12){
677 sprintf (string, "While in the air, you can press crouch to flip.",Input::keyToChar(jumpkey));
678 sprintf (string2, "Walljumps and flips confuse enemies and give you more control.");
679 sprintf (string3, " ");
681 if(tutorialstage==13){
682 sprintf (string, "BASIC COMBAT:");
683 sprintf (string2, " ");
684 sprintf (string3, " ");
686 if(tutorialstage==14){
687 sprintf (string, "There is now an imaginary enemy");
688 sprintf (string2, "in the middle of the training area.");
689 sprintf (string3, " ");
691 if(tutorialstage==15){
692 if(attackkey==MOUSEBUTTON1)sprintf (string, "Click to attack when you are near an enemy.");
693 else sprintf (string, "Press %s to attack when you are near an enemy.",Input::keyToChar(attackkey));
694 sprintf (string2, "You can punch by standing still near an enemy and attacking.");
695 sprintf (string3, " ");
697 if(tutorialstage==16){
698 sprintf (string, "If you are close, you will perform a weak punch.");
699 sprintf (string2, "The weak punch is excellent for starting attack combinations.");
700 sprintf (string3, " ");
702 if(tutorialstage==17){
703 sprintf (string, "Attacking while running results in a spin kick.");
704 sprintf (string2, "This is one of your most powerful ground attacks.");
705 sprintf (string3, " ");
707 if(tutorialstage==18){
708 sprintf (string, "Sweep the enemy's legs out by attacking while crouched.");
709 sprintf (string2, "This is a very fast attack, and easy to follow up.");
710 sprintf (string3, " ");
712 if(tutorialstage==19){
713 sprintf (string, "When an enemy is on the ground, you can deal some extra");
714 sprintf (string2, "damage by running up and drop-kicking him.");
715 sprintf (string3, "(Try knocking them down with a sweep first)");
717 if(tutorialstage==20){
718 sprintf (string, "Your most powerful individual attack is the rabbit kick.");
719 if(attackkey==MOUSEBUTTON1)sprintf (string2, "Run at the enemy while holding the mouse button, and press");
720 else sprintf (string2, "Run at the enemy while holding %s, and press", Input::keyToChar(attackkey));
721 sprintf (string3, "the jump key (%s) to attack.",Input::keyToChar(jumpkey));
723 if(tutorialstage==21){
724 sprintf (string, "This attack is devastating if timed correctly.");
725 sprintf (string2, "Even if timed incorrectly, it will knock the enemy over.");
726 if(againbonus)sprintf (string3, "Try rabbit-kicking the imaginary enemy again.");
727 else sprintf (string3, "Try rabbit-kicking the imaginary enemy.");
729 if(tutorialstage==22){
730 sprintf (string, "If you sneak behind an enemy unnoticed, you can kill");
731 sprintf (string2, "him instantly. Move close behind this enemy");
732 sprintf (string3, "and attack.");
734 if(tutorialstage==23){
735 sprintf (string, "Another important attack is the wall kick. When an enemy");
736 sprintf (string2, "is near a wall, perform a walljump nearby and hold");
737 sprintf (string3, "the attack key during impact with the wall.");
739 if(tutorialstage==24){
740 sprintf (string, "You can tackle enemies by running at them animal-style");
741 if(attackkey==MOUSEBUTTON1)sprintf (string2, "and pressing jump (%s) or attack(mouse button).",Input::keyToChar(jumpkey));
742 else sprintf (string2, "and pressing jump (%s) or attack(%s).",Input::keyToChar(jumpkey),Input::keyToChar(attackkey));
743 sprintf (string3, "This is especially useful when they are running away.");
745 if(tutorialstage==25){
746 sprintf (string, "Dodge by pressing back and attack. Dodging is essential");
747 sprintf (string2, "against enemies with swords or other long weapons.");
748 sprintf (string3, " ");
750 if(tutorialstage==26){
751 sprintf (string, "REVERSALS AND COUNTER-REVERSALS");
752 sprintf (string2, " ");
753 sprintf (string3, " ");
755 if(tutorialstage==27){
756 sprintf (string, "The enemy can now reverse your attacks.");
757 sprintf (string2, " ");
758 sprintf (string3, " ");
760 if(tutorialstage==28){
761 sprintf (string, "If you attack, you will notice that the enemy now sometimes");
762 sprintf (string2, "catches your attack and uses it against you. Hold");
763 sprintf (string3, "crouch (%s) after attacking to escape from reversals.",Input::keyToChar(crouchkey));
765 if(tutorialstage==29){
766 sprintf (string, "Try escaping from two more reversals in a row.");
767 sprintf (string2, " ");
768 sprintf (string3, " ");
770 if(tutorialstage==30){
771 sprintf (string, "Good!");
772 sprintf (string2, " ");
773 sprintf (string3, " ");
775 if(tutorialstage==31){
776 sprintf (string, "To reverse an attack, you must tap crouch (%s) during the",Input::keyToChar(crouchkey));
777 sprintf (string2, "enemy's attack. You must also be close to the enemy;");
778 sprintf (string3, "this is especially important against armed opponents.");
780 if(tutorialstage==32){
781 sprintf (string, "The enemy can attack in %d seconds.", (int)(tutorialmaxtime-tutorialstagetime));
782 sprintf (string2, "This imaginary opponents attacks will be highlighted");
783 sprintf (string3, "to make this easier.");
785 if(tutorialstage==33){
786 sprintf (string, "Reverse three enemy attacks!");
787 sprintf (string2, " ");
788 sprintf (string3, " ");
790 if(tutorialstage==34){
791 sprintf (string, "Reverse two more enemy attacks!");
792 sprintf (string2, " ");
793 sprintf (string3, " ");
795 if(tutorialstage==35){
796 sprintf (string, "Reverse one more enemy attack!");
797 sprintf (string2, " ");
798 sprintf (string3, " ");
800 if(tutorialstage==36){
801 sprintf (string, "Excellent!");
802 sprintf (string2, " ");
803 sprintf (string3, " ");
805 if(tutorialstage==37){
806 sprintf (string, "Now spar with the enemy for %d more seconds.", (int)(tutorialmaxtime-tutorialstagetime));
807 sprintf (string2, "Damage dealt: %d",(int)damagedealt);
808 sprintf (string3, "Damage taken: %d.",(int)damagetaken);
810 if(tutorialstage==38){
811 sprintf (string, "WEAPONS:");
812 sprintf (string2, " ");
813 sprintf (string3, " ");
815 if(tutorialstage==39){
816 sprintf (string, "There is now an imaginary knife");
817 sprintf (string2, "in the center of the training area.");
818 sprintf (string3, " ");
820 if(tutorialstage==40){
821 sprintf (string, "Stand, roll or handspring over the knife");
822 sprintf (string2, "while pressing %s to pick it up.",Input::keyToChar(throwkey));
823 sprintf (string3, "You can crouch and press the same key to drop it again.");
825 if(tutorialstage==41){
826 sprintf (string, "You can equip and unequip weapons using the %s key.",Input::keyToChar(drawkey));
827 sprintf (string2, "Sometimes it is best to keep them unequipped to");
828 sprintf (string3, "prevent enemies from taking them. ");
830 if(tutorialstage==42){
831 sprintf (string, "The knife is the smallest weapon and the least encumbering.");
832 sprintf (string2, "You can equip or unequip it while standing, crouching,");
833 sprintf (string3, "running or flipping.");
835 if(tutorialstage==43){
836 sprintf (string, "You perform weapon attacks the same way as unarmed attacks,");
837 sprintf (string2, "but sharp weapons cause permanent damage, instead of the");
838 sprintf (string3, "temporary trauma from blunt weapons, fists and feet.");
840 if(tutorialstage==44){
841 sprintf (string, "The enemy now has your knife!");
842 sprintf (string2, "Please reverse two of his knife attacks.");
843 sprintf (string3, " ");
845 if(tutorialstage==45){
846 sprintf (string, "Please reverse one more of his knife attacks.");
847 sprintf (string2, " ");
848 sprintf (string3, " ");
850 if(tutorialstage==46){
851 sprintf (string, "Now he has a sword!");
852 sprintf (string2, "The sword has longer reach than your arms, so you");
853 sprintf (string3, "must move close to reverse the sword slash.");
855 if(tutorialstage==47){
856 sprintf (string, "Long weapons like the sword and staff are also useful for defense;");
857 sprintf (string2, "you can parry enemy weapon attacks by pressing the attack key");
858 sprintf (string3, "at the right time. Please try parrying the enemy's attacks!");
860 if(tutorialstage==48){
861 sprintf (string, "The staff is like the sword, but has two main attacks.");
862 sprintf (string2, "The standing smash is fast and effective, and the running");
863 sprintf (string3, "spin smash is slower and more powerful.");
865 if(tutorialstage==49){
866 sprintf (string, "When facing an enemy, you can throw the knife with %s.",Input::keyToChar(throwkey));
867 sprintf (string2, "It is possible to throw the knife while flipping,");
868 sprintf (string3, "but it is very inaccurate.");
870 if(tutorialstage==50){
871 sprintf (string, "You now know everything you can learn from training.");
872 sprintf (string2, "Everything else you must learn from experience!");
873 sprintf (string3, " ");
875 if(tutorialstage==51){
876 sprintf (string, "Walk out of the training area to return to the main menu.");
877 sprintf (string2, " ");
878 sprintf (string3, " ");
881 glColor4f(0,0,0,tutorialopac);
882 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);
883 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);
884 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);
885 glColor4f(1,1,1,tutorialopac);
886 text.glPrint(screenwidth/2-7.6*strlen(string)*screenwidth/1024,screenheight/16+screenheight*4/5,string,1,1.5*screenwidth/1024,screenwidth,screenheight);
887 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);
888 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);
890 sprintf (string, "Press 'tab' to skip to the next item.",Input::keyToChar(jumpkey));
891 sprintf (string2, "Press escape at any time to");
892 sprintf (string3, "pause or exit the tutorial.");
895 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);
896 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);
897 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);
898 glColor4f(0.5,0.5,0.5,1);
899 text.glPrint(screenwidth/2-7.6*strlen(string)*screenwidth/1024*.8,0+screenheight*1/10,string,1,1.5*screenwidth/1024*.8,screenwidth,screenheight);
900 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);
901 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);
905 if(numhotspots&&(bonustime>=1||bonus<=0||bonustime<0)&&!tutoriallevel){
907 float closestdist=-1;
909 closest=currenthotspot;
910 for(i=0;i<numhotspots;i++){
911 distance=findDistancefast(&player[0].coords,&hotspot[i]);
912 if(closestdist==-1||distance<closestdist){
913 if(findDistancefast(&player[0].coords,&hotspot[i])<hotspotsize[i]&&((hotspottype[i]<=10&&hotspottype[i]>=0)||(hotspottype[i]<=40&&hotspottype[i]>=20))){
914 closestdist=distance;
920 currenthotspot=closest;
921 if(currenthotspot!=-1){
922 if(hotspottype[closest]<=10){
923 if(findDistancefast(&player[0].coords,&hotspot[closest])<hotspotsize[closest])
926 tutorialopac=tutorialmaxtime-tutorialstagetime;
927 if(tutorialopac>1)tutorialopac=1;
928 if(tutorialopac<0)tutorialopac=0;
930 sprintf (string, "%s", hotspottext[closest]);
937 if(string[i]=='\n'||string[i]>'z'||string[i]<' '||string[i]=='\0'){
938 glColor4f(0,0,0,tutorialopac);
939 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);
940 glColor4f(1,1,1,tutorialopac);
941 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);
944 if(string[i]=='\0')done=1;
950 else if (hotspottype[closest]>=20&&dialoguegonethrough[hotspottype[closest]-20]==0){
951 whichdialogue=hotspottype[closest]-20;
952 for(j=0;j<numdialogueboxes[whichdialogue];j++){
953 player[participantfocus[whichdialogue][j]].coords=participantlocation[whichdialogue][participantfocus[whichdialogue][j]];
954 player[participantfocus[whichdialogue][j]].rotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
955 player[participantfocus[whichdialogue][j]].targetrotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
956 player[participantfocus[whichdialogue][j]].velocity=0;
957 player[participantfocus[whichdialogue][j]].targetanimation=player[participantfocus[whichdialogue][j]].getIdle();
958 player[participantfocus[whichdialogue][j]].targetframe=0;
962 dialoguegonethrough[whichdialogue]++;
963 if(dialogueboxsound[whichdialogue][indialogue]!=0){
964 static float gLoc[3];
966 gLoc[0]=player[participantfocus[whichdialogue][indialogue]].coords.x;
967 gLoc[1]=player[participantfocus[whichdialogue][indialogue]].coords.y;
968 gLoc[2]=player[participantfocus[whichdialogue][indialogue]].coords.z;
973 if(dialogueboxsound[whichdialogue][indialogue]==1)whichsoundplay=rabbitchitter;
974 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
975 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
976 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
977 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
978 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
979 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
980 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
981 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
982 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
983 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
984 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
985 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
986 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
987 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
988 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
989 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
990 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
991 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
992 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
993 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, true);
994 OPENAL_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
995 OPENAL_SetVolume(channels[whichsoundplay], 256);
996 OPENAL_SetPaused(channels[whichsoundplay], false);
1002 if(indialogue!=-1&&!mainmenu){
1003 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1004 glDisable(GL_CULL_FACE);
1005 glDisable(GL_LIGHTING);
1006 glDisable(GL_TEXTURE_2D);
1008 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1009 glPushMatrix(); // Store The Projection Matrix
1010 glLoadIdentity(); // Reset The Projection Matrix
1011 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1012 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1013 glPushMatrix(); // Store The Modelview Matrix
1014 glLoadIdentity(); // Reset The Modelview Matrix
1015 if(dialogueboxlocation[whichdialogue][indialogue]==1)glTranslatef(0,screenheight*3/4,0);
1016 glScalef(screenwidth,screenheight/4,1);
1017 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1020 glColor4f(dialogueboxcolor[whichdialogue][indialogue][0],dialogueboxcolor[whichdialogue][indialogue][1],dialogueboxcolor[whichdialogue][indialogue][2],0.7);
1022 glVertex3f(0, 0, 0.0f);
1023 glVertex3f(1, 0, 0.0f);
1024 glVertex3f(1, 1, 0.0f);
1025 glVertex3f(0, 1, 0.0f);
1027 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1028 glPopMatrix(); // Restore The Old Projection Matrix
1029 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1030 glPopMatrix(); // Restore The Old Projection Matrix
1031 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1032 glEnable(GL_CULL_FACE);
1033 glDisable(GL_BLEND);
1035 glEnable(GL_TEXTURE_2D);
1042 startx=screenwidth*1/5;
1043 if(dialogueboxlocation[whichdialogue][indialogue]==1)starty=screenheight/16+screenheight*4/5;
1044 if(dialogueboxlocation[whichdialogue][indialogue]==2)starty=screenheight*1/5-screenheight/16;
1053 for(i=0;i<(int)strlen(dialoguename[whichdialogue][indialogue]);i++){
1054 tempname[tempnum]=dialoguename[whichdialogue][indialogue][i];
1056 if(dialoguename[whichdialogue][indialogue][i]=='#'||dialoguename[whichdialogue][indialogue][i]=='\0')goodchar=0;
1060 tempname[tempnum]='\0';
1063 sprintf (string, "%s: ", tempname);
1065 if(dialogueboxcolor[whichdialogue][indialogue][0]+dialogueboxcolor[whichdialogue][indialogue][1]+dialogueboxcolor[whichdialogue][indialogue][2]<1.5){
1066 glColor4f(0,0,0,tutorialopac);
1067 text.glPrintOutline(startx-2*7.6*strlen(string)*screenwidth/1024-4,starty-4,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight);
1068 glColor4f(0.7,0.7,0.7,tutorialopac);
1069 text.glPrint(startx-2*7.6*strlen(string)*screenwidth/1024,starty,string,1,1.5*screenwidth/1024,screenwidth,screenheight);
1073 glColor4f(0,0,0,tutorialopac);
1074 text.glPrintOutline(startx-2*7.6*strlen(string)*screenwidth/1024-4,starty-4,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight);
1078 for(i=0;i<(int)strlen(dialoguetext[whichdialogue][indialogue])+1;i++){
1079 tempname[tempnum]=dialoguetext[whichdialogue][indialogue][i];
1080 if(dialoguetext[whichdialogue][indialogue][i]!='#')tempnum++;
1083 sprintf (string, "%s", tempname);
1090 if(string[i]=='\n'||string[i]>'z'||string[i]<' '||string[i]=='\0'){
1091 if(dialogueboxcolor[whichdialogue][indialogue][0]+dialogueboxcolor[whichdialogue][indialogue][1]+dialogueboxcolor[whichdialogue][indialogue][2]<1.5){
1092 glColor4f(0,0,0,tutorialopac);
1093 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);
1094 glColor4f(1,1,1,tutorialopac);
1095 text.glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/,starty-20*screenwidth/1024*line,string,1,1.5*screenwidth/1024,screenwidth,screenheight,lastline,i);
1099 glColor4f(0,0,0,tutorialopac);
1100 text.glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/,starty-20*screenwidth/1024*line,string,1,1.5*screenwidth/1024,screenwidth,screenheight,lastline,i);
1104 if(string[i]=='\0')done=1;
1111 if(!tutoriallevel&&!winfreeze&&indialogue==-1&&!mainmenu){
1114 sprintf (string, "Score: %d", (int)accountactive->getCampaignScore());
1116 sprintf (string, "Score: %d", (int)accountactive->getCampaignScore()+(int)bonustotal);
1118 if(!campaign)sprintf (string, "Score: %d", (int)bonustotal);
1120 text.glPrintOutline(1024/40-4,768/16-4+768*14/16,string,1,1.5*1.25,1024,768);
1122 text.glPrint(1024/40,768/16+768*14/16,string,1,1.5,1024,768);
1124 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1125 glDisable(GL_CULL_FACE);
1126 glDisable(GL_LIGHTING);
1127 glDisable(GL_TEXTURE_2D);
1129 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1130 glPushMatrix(); // Store The Projection Matrix
1131 glLoadIdentity(); // Reset The Projection Matrix
1132 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1133 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1134 glPushMatrix(); // Store The Modelview Matrix
1135 glLoadIdentity(); // Reset The Modelview Matrix
1136 glTranslatef(15,screenheight*17.5/20,0);
1137 glScalef(screenwidth/3+20,screenheight/20,1);
1138 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1140 glColor4f(0.0,0.4,0.0,0.7);
1141 float bar=((float)player[0].damage)/player[0].damagetolerance;
1143 glVertex3f((bar<1?bar:1),0,0.0f);
1144 glVertex3f(1,0,0.0f);
1145 glVertex3f(1,1,0.0f);
1146 glVertex3f((bar<1?bar:1),1,0.0f);
1148 glColor4f(0.1,0.0,0.0,1);
1149 bar = ((float)player[0].bloodloss)/player[0].damagetolerance;
1151 glVertex3f(0,0,0.0f);
1152 glVertex3f((bar<1?bar:1),0,0.0f);
1153 glVertex3f((bar<1?bar:1),1,0.0f);
1154 glVertex3f(0,1,0.0f);
1156 glColor4f(0.4,0.0,0.0,0.7);
1157 bar = ((float)player[0].damage)/player[0].damagetolerance;
1159 glVertex3f(0,0,0.0f);
1160 glVertex3f((bar<1?bar:1),0,0.0f);
1161 glVertex3f((bar<1?bar:1),1,0.0f);
1162 glVertex3f(0,1,0.0f);
1164 glColor4f(0.4,0.0,0.0,0.7);
1165 bar = ((float)player[0].permanentdamage)/player[0].damagetolerance;
1167 glVertex3f(0,0,0.0f);
1168 glVertex3f((bar<1?bar:1),0,0.0f);
1169 glVertex3f((bar<1?bar:1),1,0.0f);
1170 glVertex3f(0,1,0.0f);
1172 glColor4f(0.4,0.0,0.0,0.7);
1173 bar = ((float)player[0].superpermanentdamage)/player[0].damagetolerance;
1175 glVertex3f(0,0,0.0f);
1176 glVertex3f((bar<1?bar:1),0,0.0f);
1177 glVertex3f((bar<1?bar:1),1,0.0f);
1178 glVertex3f(0,1,0.0f);
1180 glColor4f(0.0,0.0,0.0,0.7);
1182 glBegin(GL_LINE_STRIP);
1183 glVertex3f(0,0,0.0f);
1184 glVertex3f(1,0,0.0f);
1185 glVertex3f(1,1,0.0f);
1186 glVertex3f(0,1,0.0f);
1187 glVertex3f(0,0,0.0f);
1190 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1191 glPopMatrix(); // Restore The Old Projection Matrix
1192 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1193 glPopMatrix(); // Restore The Old Projection Matrix
1194 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1195 glEnable(GL_CULL_FACE);
1196 glDisable(GL_BLEND);
1198 glEnable(GL_TEXTURE_2D);
1200 // writing the numbers :
1201 sprintf (string, "Damages : %d/%d (%d)",(int)(player[0].damage),(int)(player[0].damagetolerance),(int)(player[0].bloodloss));
1203 text.glPrintOutline(1024/40-4,768/16-4+768*14/16-40,string,1,1.5*1.25,1024,768);
1205 text.glPrint(1024/40,768/16+768*14/16-40,string,1,1.5,1024,768);
1209 glColor4f(.5,.5,.5,1);
1212 if((texttoggle||editorenabled)&&debugmode&&!mainmenu){
1213 sprintf (string, "The framespersecond is %d.",(int)(fps));
1214 text.glPrint(10,30,string,0,.8,1024,768);
1216 sprintf (string, "Name: %s", registrationname);
1217 text.glPrint(10,260,string,0,.8,1024,768);
1221 sprintf (string, "Map editor enabled.");
1223 sprintf (string, "Map editor disabled.");
1224 text.glPrint(10,60,string,0,.8,1024,768);
1226 sprintf (string, "Object size: %f",editorsize);
1227 text.glPrint(10,75,string,0,.8,1024,768);
1228 if(editorrotation>=0)sprintf (string, "Object rotation: %f",editorrotation);
1229 else sprintf (string, "Object rotation: Random");
1230 text.glPrint(10,90,string,0,.8,1024,768);
1231 if(editorrotation2>=0)sprintf (string, "Object rotation2: %f",editorrotation2);
1232 else sprintf (string, "Object rotation2: Random");
1233 text.glPrint(10,105,string,0,.8,1024,768);
1234 sprintf (string, "Object type: %d",editortype);
1235 text.glPrint(10,120,string,0,.8,1024,768);
1236 switch(editortype) {
1238 sprintf (string, "(box)");
1241 sprintf (string, "(tree)");
1244 sprintf (string, "(wall)");
1247 sprintf (string, "(weird)");
1250 sprintf (string, "(spike)");
1253 sprintf (string, "(rock)");
1256 sprintf (string, "(bush)");
1259 sprintf (string, "(tunnel)");
1262 sprintf (string, "(chimney)");
1265 sprintf (string, "(platform)");
1268 sprintf (string, "(cool)");
1271 sprintf (string, "(fire)");
1274 text.glPrint(130,120,string,0,.8,1024,768);
1276 sprintf (string, "Numplayers: %d",numplayers);
1277 text.glPrint(10,155,string,0,.8,1024,768);
1278 sprintf (string, "Player %d: numwaypoints: %d",numplayers,player[numplayers-1].numwaypoints);
1279 text.glPrint(10,140,string,0,.8,1024,768);
1281 sprintf (string, "Difficulty: %d",difficulty);
1282 text.glPrint(10,240,string,0,.8,1024,768);
1287 if(drawmode==glowmode){
1288 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1289 glDisable(GL_CULL_FACE);
1290 glDisable(GL_LIGHTING);
1291 glDisable(GL_TEXTURE_2D);
1293 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1294 glPushMatrix(); // Store The Projection Matrix
1295 glLoadIdentity(); // Reset The Projection Matrix
1296 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1297 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1298 glPushMatrix(); // Store The Modelview Matrix
1299 glLoadIdentity(); // Reset The Modelview Matrix
1300 glScalef(screenwidth,screenheight,1);
1301 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1303 glColor4f(0,0,0,.5);
1305 glVertex3f(0, 0, 0.0f);
1306 glVertex3f(256, 0, 0.0f);
1307 glVertex3f(256, 256, 0.0f);
1308 glVertex3f(0, 256, 0.0f);
1310 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1311 glPopMatrix(); // Restore The Old Projection Matrix
1312 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1313 glPopMatrix(); // Restore The Old Projection Matrix
1314 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1315 glEnable(GL_CULL_FACE);
1316 glDisable(GL_BLEND);
1320 if((((blackout&&damageeffects)||(player[0].bloodloss>0&&damageeffects&&player[0].blooddimamount>0)||player[0].dead)&&!cameramode)||console){
1321 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1322 glDisable(GL_CULL_FACE);
1323 glDisable(GL_LIGHTING);
1324 glDisable(GL_TEXTURE_2D);
1326 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1327 glPushMatrix(); // Store The Projection Matrix
1328 glLoadIdentity(); // Reset The Projection Matrix
1329 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1330 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1331 glPushMatrix(); // Store The Modelview Matrix
1332 glLoadIdentity(); // Reset The Modelview Matrix
1333 glScalef(screenwidth,screenheight,1);
1334 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1336 if(player[0].dead)blackout+=multiplier*3;
1337 if(player[0].dead==1)blackout=.4f;
1338 if(player[0].dead==2&&blackout>.6)blackout=.6;
1339 glColor4f(0,0,0,blackout);
1340 if(!player[0].dead){
1341 if((player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5))*.3<.3){
1342 glColor4f(0,0,0,player[0].blooddimamount*player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5)*.3);
1343 blackout=player[0].blooddimamount*player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5)*.3;
1346 glColor4f(0,0,0,player[0].blooddimamount*.3);
1347 blackout=player[0].blooddimamount*.3;
1350 if(console)glColor4f(.7,0,0,.2);
1352 glVertex3f(0, 0, 0.0f);
1353 glVertex3f(256, 0, 0.0f);
1354 glVertex3f(256, 256, 0.0f);
1355 glVertex3f(0, 256, 0.0f);
1357 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1358 glPopMatrix(); // Restore The Old Projection Matrix
1359 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1360 glPopMatrix(); // Restore The Old Projection Matrix
1361 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1362 glEnable(GL_CULL_FACE);
1363 glDisable(GL_BLEND);
1367 if(flashamount>0&&damageeffects){
1368 if(flashamount>1)flashamount=1;
1369 if(flashdelay<=0)flashamount-=multiplier;
1371 if(flashamount<0)flashamount=0;
1372 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1373 glDisable(GL_CULL_FACE);
1374 glDisable(GL_LIGHTING);
1376 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1377 glPushMatrix(); // Store The Projection Matrix
1378 glLoadIdentity(); // Reset The Projection Matrix
1379 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1380 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1381 glPushMatrix(); // Store The Modelview Matrix
1382 glLoadIdentity(); // Reset The Modelview Matrix
1383 glScalef(screenwidth,screenheight,1);
1384 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1386 glColor4f(flashr,flashg,flashb,flashamount);
1388 glVertex3f(0, 0, 0.0f);
1389 glVertex3f(256, 0, 0.0f);
1390 glVertex3f(256, 256, 0.0f);
1391 glVertex3f(0, 256, 0.0f);
1393 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1394 glPopMatrix(); // Restore The Old Projection Matrix
1395 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1396 glPopMatrix(); // Restore The Old Projection Matrix
1397 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1398 glEnable(GL_CULL_FACE);
1399 glDisable(GL_BLEND);
1405 glEnable(GL_TEXTURE_2D);
1408 sprintf (string, " ]");
1409 text.glPrint(10,30+screenheight-330,string,0,1,screenwidth,screenheight);
1411 sprintf (string, "_");
1412 text.glPrint(30+(float)(displayselected)*10,30+(screenheight-330),string,0,1,screenwidth,screenheight);
1416 if((i!=0||chatting)&&displaytime[i]<4)
1417 for(j=0;j<displaychars[i];j++){
1418 glColor4f(1,1,1,4-displaytime[i]);
1419 if(j<displaychars[i]){
1420 sprintf (string, "%c",displaytext[i][j]);
1421 text.glPrint(30+j*10,30+i*20+(screenheight-330),string,0,1,screenwidth,screenheight);
1427 if(minimap&&indialogue==-1){
1428 float mapviewdist = 20000;
1430 glDisable(GL_DEPTH_TEST);
1431 glColor3f (1.0, 1.0, 1.0); // no coloring
1433 glEnable(GL_TEXTURE_2D);
1434 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1435 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1436 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1437 glDisable(GL_CULL_FACE);
1438 glDisable(GL_LIGHTING);
1440 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1441 glPushMatrix(); // Store The Projection Matrix
1442 glLoadIdentity(); // Reset The Projection Matrix
1443 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1444 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1445 glPushMatrix(); // Store The Modelview Matrix
1446 glLoadIdentity(); // Reset The Modelview Matrix
1447 glScalef((float)screenwidth/2,(float)screenwidth/2,1);
1448 glTranslatef(1.75,.25,0);
1449 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1457 int numliveplayers=0;
1459 for(i=0;i<numplayers;i++){
1460 if(!player[i].dead) numliveplayers++;
1465 for(i=0;i<objects.numobjects;i++){
1466 if(objects.type[i]==treetrunktype||objects.type[i]==boxtype){
1467 center+=objects.position[i];
1471 for(i=0;i<numplayers;i++){
1472 if(!player[i].dead)center+=player[i].coords;
1474 center/=numadd+numliveplayers;
1476 center=player[0].coords;
1478 float maxdistance=0;
1481 for(i=0;i<objects.numobjects;i++){
1482 tempdist=findDistancefast(¢er,&objects.position[i]);
1483 if(tempdist>maxdistance){
1485 maxdistance=tempdist;
1488 for(i=0;i<numplayers;i++){
1489 if(!player[i].dead){
1490 tempdist=findDistancefast(¢er,&player[i].coords);
1491 if(tempdist>maxdistance){
1493 maxdistance=tempdist;
1497 radius=fast_sqrt(maxdistance);
1501 glScalef(.25/radius*256*terrain.scale*.4,.25/radius*256*terrain.scale*.4,1);
1503 glScalef(1/(1/radius*256*terrain.scale*.4),1/(1/radius*256*terrain.scale*.4),1);
1505 glRotatef(player[0].lookrotation*-1+180,0,0,1);
1506 glTranslatef(-(center.x/terrain.scale/256*-2+1),(center.z/terrain.scale/256*-2+1),0);
1507 for(i=0;i<objects.numobjects;i++){
1508 if(objects.type[i]==treetrunktype){
1509 distcheck=findDistancefast(&player[0].coords,&objects.position[i]);
1510 if(distcheck<mapviewdist){
1511 glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
1512 glColor4f(0,.3,0,opac*(1-distcheck/mapviewdist));
1514 glTranslatef(objects.position[i].x/terrain.scale/256*-2+1,objects.position[i].z/terrain.scale/256*2-1,0);
1515 glRotatef(objects.rotation[i],0,0,1);
1516 glScalef(.003,.003,.003);
1519 glVertex3f(-1, -1, 0.0f);
1521 glVertex3f(1, -1, 0.0f);
1523 glVertex3f(1, 1, 0.0f);
1525 glVertex3f(-1, 1, 0.0f);
1530 if(objects.type[i]==boxtype){
1531 distcheck=findDistancefast(&player[0].coords,&objects.position[i]);
1532 if(distcheck<mapviewdist){
1533 glBindTexture( GL_TEXTURE_2D, Mapboxtexture);
1534 glColor4f(.4,.4,.4,opac*(1-distcheck/mapviewdist));
1536 glTranslatef(objects.position[i].x/terrain.scale/256*-2+1,objects.position[i].z/terrain.scale/256*2-1,0);
1537 glRotatef(objects.rotation[i],0,0,1);
1538 glScalef(.01*objects.scale[i],.01*objects.scale[i],.01*objects.scale[i]);
1541 glVertex3f(-1, -1, 0.0f);
1543 glVertex3f(1, -1, 0.0f);
1545 glVertex3f(1, 1, 0.0f);
1547 glVertex3f(-1, 1, 0.0f);
1554 glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
1555 for(i=0;i<numboundaries;i++){
1556 glColor4f(0,0,0,opac/3);
1558 glTranslatef(boundary[i].x/terrain.scale/256*-2+1,boundary[i].z/terrain.scale/256*2-1,0);
1559 glScalef(.002,.002,.002);
1562 glVertex3f(-1, -1, 0.0f);
1564 glVertex3f(1, -1, 0.0f);
1566 glVertex3f(1, 1, 0.0f);
1568 glVertex3f(-1, 1, 0.0f);
1573 for(i=0;i<numplayers;i++){
1574 distcheck=findDistancefast(&player[0].coords,&player[i].coords);
1575 if(distcheck<mapviewdist){
1577 glBindTexture( GL_TEXTURE_2D, Maparrowtexture);
1578 if(i==0)glColor4f(1,1,1,opac);
1579 else if(player[i].dead==2||player[i].howactive>typesleeping)glColor4f(0,0,0,opac*(1-distcheck/mapviewdist));
1580 else if(player[i].dead)glColor4f(.3,.3,.3,opac*(1-distcheck/mapviewdist));
1581 else if(player[i].aitype==attacktypecutoff)glColor4f(1,0,0,opac*(1-distcheck/mapviewdist));
1582 else if(player[i].aitype==passivetype)glColor4f(0,1,0,opac*(1-distcheck/mapviewdist));
1583 else glColor4f(1,1,0,1);
1584 glTranslatef(player[i].coords.x/terrain.scale/256*-2+1,player[i].coords.z/terrain.scale/256*2-1,0);
1585 glRotatef(player[i].rotation+180,0,0,1);
1586 glScalef(.005,.005,.005);
1589 glVertex3f(-1, -1, 0.0f);
1591 glVertex3f(1, -1, 0.0f);
1593 glVertex3f(1, 1, 0.0f);
1595 glVertex3f(-1, 1, 0.0f);
1601 glDisable(GL_TEXTURE_2D);
1602 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1603 glPopMatrix(); // Restore The Old Projection Matrix
1604 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1605 glPopMatrix(); // Restore The Old Projection Matrix
1606 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1607 glEnable(GL_CULL_FACE);
1608 glDisable(GL_BLEND);
1612 if(loading&&!stealthloading&&(!campaign||player[0].dead)){
1613 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1614 glDisable(GL_CULL_FACE);
1615 glDisable(GL_LIGHTING);
1616 glDisable(GL_TEXTURE_2D);
1618 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1619 glPushMatrix(); // Store The Projection Matrix
1620 glLoadIdentity(); // Reset The Projection Matrix
1621 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1622 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1623 glPushMatrix(); // Store The Modelview Matrix
1624 glLoadIdentity(); // Reset The Modelview Matrix
1625 glScalef(screenwidth,screenheight,1);
1626 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1628 glColor4f(0,0,0,.7);
1630 glVertex3f(0, 0, 0.0f);
1631 glVertex3f(256, 0, 0.0f);
1632 glVertex3f(256, 256, 0.0f);
1633 glVertex3f(0, 256, 0.0f);
1635 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1636 glPopMatrix(); // Restore The Old Projection Matrix
1637 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1638 glPopMatrix(); // Restore The Old Projection Matrix
1639 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1640 glEnable(GL_CULL_FACE);
1641 glDisable(GL_BLEND);
1645 glDisable(GL_DEPTH_TEST);
1646 glColor3f (1.0, 1.0, 1.0); // no coloring
1648 glEnable(GL_TEXTURE_2D);
1653 glEnable(GL_TEXTURE_2D);
1655 sprintf (string, "Loading...");
1656 text.glPrint(1024/2-90,768/2,string,1,2,1024,768);
1659 //if(ismotionblur)drawmode=motionblurmode;
1660 drawmode=normalmode;
1663 if(winfreeze&&!campaign){
1664 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1665 glDisable(GL_CULL_FACE);
1666 glDisable(GL_LIGHTING);
1667 glDisable(GL_TEXTURE_2D);
1669 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1670 glPushMatrix(); // Store The Projection Matrix
1671 glLoadIdentity(); // Reset The Projection Matrix
1672 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1673 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1674 glPushMatrix(); // Store The Modelview Matrix
1675 glLoadIdentity(); // Reset The Modelview Matrix
1676 glScalef(screenwidth,screenheight,1);
1677 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1679 glColor4f(0,0,0,.4);
1681 glVertex3f(0, 0, 0.0f);
1682 glVertex3f(256, 0, 0.0f);
1683 glVertex3f(256, 256, 0.0f);
1684 glVertex3f(0, 256, 0.0f);
1686 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1687 glPopMatrix(); // Restore The Old Projection Matrix
1688 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1689 glPopMatrix(); // Restore The Old Projection Matrix
1690 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1691 glEnable(GL_CULL_FACE);
1692 glDisable(GL_BLEND);
1696 glDisable(GL_DEPTH_TEST);
1697 glColor3f (1.0, 1.0, 1.0); // no coloring
1699 glEnable(GL_TEXTURE_2D);
1701 //Win Screen Won Victory
1703 glEnable(GL_TEXTURE_2D);
1705 sprintf (string, "Level Cleared!");
1706 text.glPrintOutlined(1024/2-strlen(string)*10,768*7/8,string,1,2,1024,768);
1708 sprintf (string, "Score: %d",(int)(bonustotal-startbonustotal));
1709 text.glPrintOutlined(1024/30,768*6/8,string,1,2,1024,768);
1712 sprintf (string, "Press Escape or Space to continue");
1714 sprintf (string, "Press Escape to return to menu or Space to continue");
1715 text.glPrintOutlined(640/2-strlen(string)*5,480*1/16,string,1,1,640,480);
1719 for(i=0;i<255;i++)string[i]='\0';
1720 sprintf (temp, "Time: %d:",(int)(((int)leveltime-(int)(leveltime)%60)/60));
1721 strcat(string,temp);
1722 if((int)(leveltime)%60<10)strcat(string,"0");
1723 sprintf (temp, "%d",(int)(leveltime)%60);
1724 strcat(string,temp);
1725 text.glPrintOutlined(1024/30,768*6/8-40,string,1,2,1024,768);
1728 int awards[award_count];
1729 int numawards = award_awards(awards);
1731 for (i = 0; i < numawards && i < 6; i++)
1732 text.glPrintOutlined(1024/30,768*6/8-90-40*i,award_names[awards[i]],1,2,1024,768);
1735 if(drawmode!=normalmode){
1736 glEnable(GL_TEXTURE_2D);
1738 if(!drawtoggle||drawmode!=realmotionblurmode||(drawtoggle==2||change==1)){
1741 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
1742 GLfloat subtractColor[4] = { 0.5, 0.5, 0.5, 0.0 };
1743 glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, subtractColor);
1744 //glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_SUBTRACT);
1745 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE);
1746 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_CONSTANT_EXT);
1747 glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 2.0f);
1749 glBindTexture( GL_TEXTURE_2D, screentexture);
1750 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1753 if((drawtoggle||change==1)&&drawmode==realmotionblurmode){
1755 glBindTexture( GL_TEXTURE_2D, screentexture2);
1756 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1758 if(!screentexture2){
1759 glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
1761 glGenTextures( 1, &screentexture2 );
1762 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
1764 glEnable(GL_TEXTURE_2D);
1765 glBindTexture( GL_TEXTURE_2D, screentexture2);
1766 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
1767 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
1769 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
1775 glClear(GL_DEPTH_BUFFER_BIT);
1776 ReSizeGLScene(90,.1f);
1777 glViewport(0,0,screenwidth,screenheight);
1779 if(drawmode!=normalmode){
1780 glDisable(GL_DEPTH_TEST);
1781 if(drawmode==motionblurmode){
1782 glDrawBuffer(GL_FRONT);
1783 glReadBuffer(GL_BACK);
1785 glColor3f (1.0, 1.0, 1.0); // no coloring
1787 glEnable(GL_TEXTURE_2D);
1788 glBindTexture( GL_TEXTURE_2D, screentexture);
1789 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1790 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1791 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1792 glDisable(GL_CULL_FACE);
1793 glDisable(GL_LIGHTING);
1795 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1796 glPushMatrix(); // Store The Projection Matrix
1797 glLoadIdentity(); // Reset The Projection Matrix
1798 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1799 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1800 glPushMatrix(); // Store The Modelview Matrix
1801 glLoadIdentity(); // Reset The Modelview Matrix
1802 glScalef((float)screenwidth/2,(float)screenheight/2,1);
1803 glTranslatef(1,1,0);
1804 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1806 if(drawmode==motionblurmode){
1807 if(motionbluramount<.2)motionbluramount=.2;
1808 //glColor4f(1,1,1,fast_sqrt(multiplier)*2.9*motionbluramount);
1809 glColor4f(1,1,1,motionbluramount);
1813 glVertex3f(-1, -1, 0.0f);
1814 glTexCoord2f(texcoordwidth,0);
1815 glVertex3f(1, -1, 0.0f);
1816 glTexCoord2f(texcoordwidth,texcoordheight);
1817 glVertex3f(1, 1, 0.0f);
1818 glTexCoord2f(0,texcoordheight);
1819 glVertex3f(-1, 1, 0.0f);
1823 if(drawmode==realmotionblurmode){
1824 glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
1825 glClear(GL_COLOR_BUFFER_BIT);
1826 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
1827 glBindTexture( GL_TEXTURE_2D, screentexture);
1828 glColor4f(1,1,1,.5);
1832 glVertex3f(-1, -1, 0.0f);
1833 glTexCoord2f(texcoordwidth,0);
1834 glVertex3f(1, -1, 0.0f);
1835 glTexCoord2f(texcoordwidth,texcoordheight);
1836 glVertex3f(1, 1, 0.0f);
1837 glTexCoord2f(0,texcoordheight);
1838 glVertex3f(-1, 1, 0.0f);
1841 glBindTexture( GL_TEXTURE_2D, screentexture2);
1842 glColor4f(1,1,1,.5);
1846 glVertex3f(-1, -1, 0.0f);
1847 glTexCoord2f(texcoordwidth,0);
1848 glVertex3f(1, -1, 0.0f);
1849 glTexCoord2f(texcoordwidth,texcoordheight);
1850 glVertex3f(1, 1, 0.0f);
1851 glTexCoord2f(0,texcoordheight);
1852 glVertex3f(-1, 1, 0.0f);
1855 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1857 if(drawmode==doublevisionmode){
1858 static float crosseyedness;
1859 crosseyedness=abs(player[0].damage-player[0].superpermanentdamage-(player[0].damagetolerance-player[0].superpermanentdamage)*1/2)/30;
1860 if(crosseyedness>1)crosseyedness=1;
1861 if(crosseyedness<0)crosseyedness=0;
1863 glDisable(GL_BLEND);
1868 glVertex3f(-1, -1, 0.0f);
1869 glTexCoord2f(texcoordwidth,0);
1870 glVertex3f(1, -1, 0.0f);
1871 glTexCoord2f(texcoordwidth,texcoordheight);
1872 glVertex3f(1, 1, 0.0f);
1873 glTexCoord2f(0,texcoordheight);
1874 glVertex3f(-1, 1, 0.0f);
1878 glColor4f(1,1,1,.5);
1881 glTranslatef(.015*crosseyedness,0,0);
1885 glVertex3f(-1, -1, 0.0f);
1886 glTexCoord2f(texcoordwidth,0);
1887 glVertex3f(1, -1, 0.0f);
1888 glTexCoord2f(texcoordwidth,texcoordheight);
1889 glVertex3f(1, 1, 0.0f);
1890 glTexCoord2f(0,texcoordheight);
1891 glVertex3f(-1, 1, 0.0f);
1896 if(drawmode==glowmode){
1897 glColor4f(.5,.5,.5,.5);
1899 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
1901 glTranslatef(.01,0,0);
1904 glVertex3f(-1, -1, 0.0f);
1905 glTexCoord2f(texcoordwidth,0);
1906 glVertex3f(1, -1, 0.0f);
1907 glTexCoord2f(texcoordwidth,texcoordheight);
1908 glVertex3f(1, 1, 0.0f);
1909 glTexCoord2f(0,texcoordheight);
1910 glVertex3f(-1, 1, 0.0f);
1914 glTranslatef(-.01,0,0);
1917 glVertex3f(-1, -1, 0.0f);
1918 glTexCoord2f(texcoordwidth,0);
1919 glVertex3f(1, -1, 0.0f);
1920 glTexCoord2f(texcoordwidth,texcoordheight);
1921 glVertex3f(1, 1, 0.0f);
1922 glTexCoord2f(0,texcoordheight);
1923 glVertex3f(-1, 1, 0.0f);
1927 glTranslatef(.0,.01,0);
1930 glVertex3f(-1, -1, 0.0f);
1931 glTexCoord2f(texcoordwidth,0);
1932 glVertex3f(1, -1, 0.0f);
1933 glTexCoord2f(texcoordwidth,texcoordheight);
1934 glVertex3f(1, 1, 0.0f);
1935 glTexCoord2f(0,texcoordheight);
1936 glVertex3f(-1, 1, 0.0f);
1940 glTranslatef(0,-.01,0);
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);
1953 if(drawmode==radialzoommode){
1955 //glRotatef((float)i*.1,0,0,1);
1956 glColor4f(1,1,1,1/((float)i+1));
1958 glScalef(1+(float)i*.01,1+(float)i*.01,1);
1961 glVertex3f(-1, -1, 0.0f);
1962 glTexCoord2f(texcoordwidth,0);
1963 glVertex3f(1, -1, 0.0f);
1964 glTexCoord2f(texcoordwidth,texcoordheight);
1965 glVertex3f(1, 1, 0.0f);
1966 glTexCoord2f(0,texcoordheight);
1967 glVertex3f(-1, 1, 0.0f);
1972 glDisable(GL_TEXTURE_2D);
1973 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1974 glPopMatrix(); // Restore The Old Projection Matrix
1975 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1976 glPopMatrix(); // Restore The Old Projection Matrix
1977 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1978 glEnable(GL_CULL_FACE);
1979 glDisable(GL_BLEND);
1984 glEnable(GL_TEXTURE_2D);
1987 if(consoleselected>=60)
1988 offset=consoleselected-60;
1989 sprintf (string, " ]");
1990 text.glPrint(10,30,string,0,1,1024,768);
1992 sprintf (string, "_");
1993 text.glPrint(30+(float)(consoleselected)*10-offset*10,30,string,0,1,1024,768);
1996 for(j=0;j<consolechars[i];j++){
1997 glColor4f(1,1,1,1-(float)(i)/16);
1998 if(j<consolechars[i]){
1999 sprintf (string, "%c",consoletext[i][j]);
2000 text.glPrint(30+j*10-offset*10,30+i*20,string,0,1,1024,768);
2007 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)||(mainmenu&&gameon)||(!gameon&&gamestarted)||(!gameon&&gamestarted)){
2008 multiplier=tempmult;
2013 // !!! FIXME: hack: clamp framerate in menu so text input works correctly on fast systems.
2016 glDrawBuffer(GL_BACK);
2017 glReadBuffer(GL_BACK);
2018 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
2019 ReSizeGLScene(90,.1f);
2022 temptexdetail=texdetail;
2023 if(texdetail>2)texdetail=2;
2024 if(mainmenu!=oldmainmenu&&oldmainmenu!=0){
2026 LoadTexture(":Data:Textures:Newgame.png",&Mainmenuitems[1],0,0);
2027 LoadTexture(":Data:Textures:Quit.png",&Mainmenuitems[3],0,0);
2030 LoadTexture(":Data:Textures:Resume.png",&Mainmenuitems[1],0,0);
2031 LoadTexture(":Data:Textures:Endgame.png",&Mainmenuitems[3],0,0);
2034 if(lastcheck>.5||oldmainmenu!=mainmenu){
2036 ifstream ipstream(ConvertFileName(":Data:Campaigns:main.txt"));
2037 ipstream.ignore(256,':');
2038 ipstream >> campaignnumlevels;
2039 for(i=0;i<campaignnumlevels;i++){
2040 ipstream.ignore(256,':');
2041 ipstream.ignore(256,':');
2042 ipstream.ignore(256,' ');
2043 ipstream >> campaignmapname[i];
2044 ipstream.ignore(256,':');
2045 ipstream >> campaigndescription[i];
2047 if(campaigndescription[i][j]=='_')campaigndescription[i][j]=' ';
2049 ipstream.ignore(256,':');
2050 ipstream >> campaignchoosenext[i];
2051 ipstream.ignore(256,':');
2052 ipstream >> campaignnumnext[i];
2053 for(j=0;j<campaignnumnext[i];j++){
2054 ipstream.ignore(256,':');
2055 ipstream >> campaignnextlevel[i][j];
2056 campaignnextlevel[i][j]-=1;
2058 ipstream.ignore(256,':');
2059 ipstream >> campaignlocationx[i];
2060 ipstream.ignore(256,':');
2061 ipstream >> campaignlocationy[i];
2065 for(i=0;i<campaignnumlevels;i++){
2067 levelhighlight[i]=0;
2072 for(i=0;i<accountactive->getCampaignChoicesMade();i++){
2073 levelorder[i+1]=campaignnextlevel[levelorder[i]][accountactive->getCampaignChoice(i)];
2074 levelvisible[levelorder[i+1]]=1;
2076 int whichlevelstart = accountactive->getCampaignChoicesMade()-1;
2077 if(whichlevelstart<0){
2078 accountactive->setCampaignScore(0);
2079 accountactive->resetFasttime();
2080 campaignchoicenum=1;
2081 campaignchoicewhich[0]=0;
2085 campaignchoicenum=campaignnumnext[levelorder[whichlevelstart]];
2086 for(i=0;i<campaignchoicenum;i++){
2087 campaignchoicewhich[i]=campaignnextlevel[levelorder[whichlevelstart]][i];
2088 levelvisible[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
2089 levelhighlight[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
2098 texdetail=temptexdetail;
2100 oldmainmenu=mainmenu;
2102 if(mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==8||mainmenu==9||mainmenu==10||mainmenu==119||mainmenu==18){
2103 glClear(GL_DEPTH_BUFFER_BIT);
2104 glEnable(GL_ALPHA_TEST);
2105 glAlphaFunc(GL_GREATER, 0.001f);
2106 glEnable(GL_TEXTURE_2D);
2107 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
2108 glDisable(GL_CULL_FACE);
2109 glDisable(GL_LIGHTING);
2111 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2112 glPushMatrix(); // Store The Projection Matrix
2113 glLoadIdentity(); // Reset The Projection Matrix
2114 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
2115 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2116 glPushMatrix(); // Store The Modelview Matrix
2117 glLoadIdentity(); // Reset The Modelview Matrix
2118 glTranslatef(screenwidth/2,screenheight/2,0);
2120 glScalef((float)screenwidth/2,(float)screenheight/2,1);
2121 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
2122 glDisable(GL_BLEND);
2123 glColor4f(0,0,0,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 glDisable(GL_TEXTURE_2D);
2128 //glScalef(.25,.25,.25);
2131 glVertex3f(-1, -1, 0.0f);
2133 glVertex3f(1, -1, 0.0f);
2135 glVertex3f(1, 1, 0.0f);
2137 glVertex3f(-1, 1, 0.0f);
2141 glColor4f(0.4,0.4,0.4,1.0);
2142 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2143 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2144 glEnable(GL_TEXTURE_2D);
2145 glBindTexture( GL_TEXTURE_2D, Mainmenuitems[4]);
2147 //glScalef(.25,.25,.25);
2150 glVertex3f(-1, -1, 0.0f);
2152 glVertex3f(1, -1, 0.0f);
2154 glVertex3f(1, 1, 0.0f);
2156 glVertex3f(-1, 1, 0.0f);
2161 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2163 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2167 if((float)newscreenwidth>(float)newscreenheight*1.61||(float)newscreenwidth<(float)newscreenheight*1.59)sprintf (menustring[0], "Resolution: %d*%d",(int)newscreenwidth,(int)newscreenheight);
2168 else sprintf (menustring[0], "Resolution: %d*%d (widescreen)",(int)newscreenwidth,(int)newscreenheight);
2171 endx[0]=startx[0]+strlen(menustring[0])*10;
2172 endy[0]=starty[0]+20;
2176 if(newdetail==2)sprintf (menustring[1], "Detail: High");
2177 else if(newdetail==1)sprintf (menustring[1], "Detail: Medium");
2178 else sprintf (menustring[1], "Detail: Low");
2181 endx[1]=startx[1]+strlen(menustring[1])*10;
2182 endy[1]=starty[1]+20;
2186 if(bloodtoggle==2)sprintf (menustring[2], "Blood: On, high detail (slower)");
2187 if(bloodtoggle==1)sprintf (menustring[2], "Blood: On, low detail");
2188 if(bloodtoggle==0)sprintf (menustring[2], "Blood: Off");
2191 endx[2]=startx[2]+strlen(menustring[2])*10;
2192 endy[2]=starty[2]+20;
2196 if(difficulty==2)sprintf (menustring[3], "Difficulty: Insane");
2197 if(difficulty==1)sprintf (menustring[3], "Difficulty: Difficult");
2198 if(difficulty==0)sprintf (menustring[3], "Difficulty: Easier");
2199 startx[3]=10+20-1000;
2201 endx[3]=startx[3]+strlen(menustring[3])*10;
2202 endy[3]=starty[3]+20;
2206 if(ismotionblur==1)sprintf (menustring[4], "Blur Effects: Enabled (less compatible)");
2207 if(ismotionblur==0)sprintf (menustring[4], "Blur Effects: Disabled (more compatible)");
2210 endx[4]=startx[4]+strlen(menustring[4])*10;
2211 endy[4]=starty[4]+20;
2215 if(decals==1)sprintf (menustring[5], "Decals: Enabled (slower)");
2216 if(decals==0)sprintf (menustring[5], "Decals: Disabled");
2219 endx[5]=startx[5]+strlen(menustring[5])*10;
2220 endy[5]=starty[5]+20;
2224 if(musictoggle==1)sprintf (menustring[6], "Music: Enabled");
2225 if(musictoggle==0)sprintf (menustring[6], "Music: Disabled");
2228 endx[6]=startx[6]+strlen(menustring[6])*10;
2229 endy[6]=starty[6]+20;
2233 if(invertmouse==1)sprintf (menustring[9], "Invert mouse: Yes");
2234 if(invertmouse==0)sprintf (menustring[9], "Invert mouse: No");
2237 endx[9]=startx[9]+strlen(menustring[9])*10;
2238 endy[9]=starty[9]+20;
2242 sprintf (menustring[10], "Mouse Speed: %d", (int)(usermousesensitivity*5));
2245 endx[10]=startx[10]+strlen(menustring[10])*10;
2246 endy[10]=starty[10]+20;
2250 sprintf (menustring[11], "Volume: %d%%", (int)(volume*100));
2253 endx[11]=startx[11]+strlen(menustring[11])*10;
2254 endy[11]=starty[11]+20;
2258 sprintf (menustring[13], "Damage Bar: %s",(showdamagebar?"on":"off"));
2261 endx[13]=startx[13]+strlen(menustring[13])*10;
2262 endy[13]=starty[13]+20;
2266 sprintf (menustring[7], "-Configure Controls-");
2269 endx[7]=startx[7]+strlen(menustring[7])*10;
2270 endy[7]=starty[7]+20;
2274 sprintf (menustring[12], "-Configure Stereo -");
2277 endx[12]=startx[12]+strlen(menustring[7])*10;
2278 endy[12]=starty[12]+20;
2282 if(newdetail==detail&&newscreenheight==(int)screenheight&&newscreenwidth==(int)screenwidth)sprintf (menustring[8], "Back");
2283 else sprintf (menustring[8], "Back (some changes take effect next time Lugaru is opened)");
2285 endx[8]=startx[8]+strlen(menustring[8])*10;
2287 endy[8]=starty[8]+20;
2294 if(keyselect!=0)sprintf (menustring[0], "Forwards: %s",Input::keyToChar(forwardkey));
2295 else sprintf (menustring[0], "Forwards: _");
2298 endx[0]=startx[0]+strlen(menustring[0])*10;
2299 endy[0]=starty[0]+20;
2303 if(keyselect!=1)sprintf (menustring[1], "Back: %s",Input::keyToChar(backkey));
2304 else sprintf (menustring[1], "Back: _");
2307 endx[1]=startx[1]+strlen(menustring[1])*10;
2308 endy[1]=starty[1]+20;
2312 if(keyselect!=2)sprintf (menustring[2], "Left: %s",Input::keyToChar(leftkey));
2313 else sprintf (menustring[2], "Left: _");
2316 endx[2]=startx[2]+strlen(menustring[2])*10;
2317 endy[2]=starty[2]+20;
2321 if(keyselect!=3)sprintf (menustring[3], "Right: %s",Input::keyToChar(rightkey));
2322 else sprintf (menustring[3], "Right: _");
2325 endx[3]=startx[3]+strlen(menustring[3])*10;
2326 endy[3]=starty[3]+20;
2330 if(keyselect!=4)sprintf (menustring[4], "Crouch: %s",Input::keyToChar(crouchkey));
2331 else sprintf (menustring[4], "Crouch: _");
2334 endx[4]=startx[4]+strlen(menustring[4])*10;
2335 endy[4]=starty[4]+20;
2339 if(keyselect!=5)sprintf (menustring[5], "Jump: %s",Input::keyToChar(jumpkey));
2340 else sprintf (menustring[5], "Jump: _");
2343 endx[5]=startx[5]+strlen(menustring[5])*10;
2344 endy[5]=starty[5]+20;
2348 if(keyselect!=6)sprintf (menustring[6], "Draw: %s",Input::keyToChar(drawkey));
2349 else sprintf (menustring[6], "Draw: _");
2352 endx[6]=startx[6]+strlen(menustring[6])*10;
2353 endy[6]=starty[6]+20;
2357 if(keyselect!=7)sprintf (menustring[7], "Throw: %s",Input::keyToChar(throwkey));
2358 else sprintf (menustring[7], "Throw: _");
2361 endx[7]=startx[7]+strlen(menustring[7])*10;
2362 endy[7]=starty[7]+20;
2366 if(keyselect!=8)sprintf (menustring[8], "Attack: %s",Input::keyToChar(attackkey));
2367 else sprintf (menustring[8], "Attack: _");
2370 endx[8]=startx[8]+strlen(menustring[8])*10;
2371 endy[8]=starty[8]+20;
2377 sprintf (menustring[9], "Back");
2379 endx[9]=startx[9]+strlen(menustring[9])*10;
2381 endy[9]=starty[9]+20;
2386 nummenuitems=7+accountactive->getCampaignChoicesMade()+campaignchoicenum;
2388 sprintf (menustring[0], "%s",accountactive->getName());
2391 endx[0]=startx[0]+strlen(menustring[0])*10;
2392 endy[0]=starty[0]+20;
2396 sprintf (menustring[1], "Tutorial");
2399 endx[1]=startx[1]+strlen(menustring[1])*10;
2400 endy[1]=starty[1]+20;
2404 sprintf (menustring[2], "Challenge");
2407 endx[2]=startx[2]+strlen(menustring[2])*10;
2408 endy[2]=starty[2]+20;
2412 sprintf (menustring[3], "Delete User");
2415 endx[3]=startx[3]+strlen(menustring[3])*10;
2416 endy[3]=starty[3]+20;
2420 sprintf (menustring[4], "Main Menu");
2423 endx[4]=startx[4]+strlen(menustring[4])*10;
2424 endy[4]=starty[4]+20;
2428 sprintf (menustring[5], "Change User");
2430 endx[5]=startx[5]+strlen(menustring[5])*10;
2432 endy[5]=starty[5]+20;
2438 sprintf (menustring[6], "World");
2440 starty[6]=30+480-400-50;
2441 endx[6]=startx[6]+400;
2446 if(accountactive->getCampaignChoicesMade())
2447 for(i=0;i<accountactive->getCampaignChoicesMade();i++){
2448 sprintf (menustring[7+i], "%s", campaigndescription[levelorder[i]]);
2449 startx[7+i]=30+120+campaignlocationx[levelorder[i]]*400/512;
2450 starty[7+i]=30+30+(512-campaignlocationy[levelorder[i]])*400/512;
2451 endx[7+i]=startx[7+i]+10;
2452 endy[7+i]=starty[7+i]+10;
2457 if(campaignchoicenum>0)
2458 for(i=accountactive->getCampaignChoicesMade();i<accountactive->getCampaignChoicesMade()+campaignchoicenum;i++){
2459 sprintf (menustring[7+i], "%s", campaigndescription[levelorder[i]]);
2460 startx[7+i]=30+120+campaignlocationx[campaignchoicewhich[i-(accountactive->getCampaignChoicesMade())]]*400/512;
2461 starty[7+i]=30+30+(512-campaignlocationy[campaignchoicewhich[i-(accountactive->getCampaignChoicesMade())]])*400/512;
2462 endx[7+i]=startx[7+i]+10;
2463 endy[7+i]=starty[7+i]+10;
2468 /*sprintf (menustring[7], "Dot");
2469 startx[7]=120+260*400/512;
2470 starty[7]=30+(512-184)*400/512;
2471 endx[7]=startx[7]+10;
2472 endy[7]=starty[7]+10;
2476 sprintf (menustring[8], "Dot");
2477 startx[8]=120+129*400/512;
2478 starty[8]=30+(512-284)*400/512;
2479 endx[8]=startx[8]+10;
2480 endy[8]=starty[8]+10;
2484 sprintf (menustring[9], "Dot");
2485 startx[9]=120+358*400/512;
2486 starty[9]=30+(512-235)*400/512;
2487 endx[9]=startx[9]+10;
2488 endy[9]=starty[9]+10;
2492 sprintf (menustring[10], "Dot");
2493 startx[10]=120+359*400/512;
2494 starty[10]=30+(512-308)*400/512;
2495 endx[10]=startx[10]+10;
2496 endy[10]=starty[10]+10;
2500 sprintf (menustring[11], "Dot");
2501 startx[11]=120+288*400/512;
2502 starty[11]=30+(512-277)*400/512;
2503 endx[11]=startx[11]+10;
2504 endy[11]=starty[11]+10;
2512 sprintf (menustring[0], "Are you sure you want to delete this user?");
2515 endx[0]=startx[0]+strlen(menustring[0])*10;
2516 endy[0]=starty[0]+20;
2520 sprintf (menustring[1], "Yes");
2523 endx[1]=startx[1]+strlen(menustring[1])*10;
2524 endy[1]=starty[1]+20;
2528 sprintf (menustring[2], "No");
2531 endx[2]=startx[2]+strlen(menustring[2])*10;
2532 endy[2]=starty[2]+20;
2536 sprintf (menustring[3], "Extra 4");
2539 endx[3]=startx[3]+strlen(menustring[3])*10;
2540 endy[3]=starty[3]+20;
2544 sprintf (menustring[4], "Extra 5");
2547 endx[4]=startx[4]+strlen(menustring[4])*10;
2548 endy[4]=starty[4]+20;
2552 sprintf (menustring[5], "Back");
2554 endx[5]=startx[5]+strlen(menustring[5])*10;
2556 endy[5]=starty[5]+20;
2562 nummenuitems=Account::getNbAccounts()+2;
2566 if(Account::getNbAccounts()<8)
2567 sprintf (menustring[0], "New User");
2569 sprintf (menustring[0], "No More Users");
2572 endx[0]=startx[0]+strlen(menustring[0])*10;
2573 endy[0]=starty[0]+20;
2582 for(i=0;i<Account::getNbAccounts();i++){
2583 sprintf (menustring[num], "%s",Account::get(i)->getName());
2585 starty[num]=360-20-20*num;
2586 endx[num]=startx[num]+strlen(menustring[num])*10;
2587 endy[num]=starty[num]+20;
2594 sprintf (menustring[num], "Back");
2596 endx[num]=startx[num]+strlen(menustring[num])*10;
2598 endy[num]=starty[num]+20;
2605 sprintf (menustring[0], "Easier");
2608 endx[0]=startx[0]+strlen(menustring[0])*10;
2609 endy[0]=starty[0]+20;
2613 sprintf (menustring[1], "Difficult");
2616 endx[1]=startx[1]+strlen(menustring[1])*10;
2617 endy[1]=starty[1]+20;
2621 sprintf (menustring[2], "Insane");
2624 endx[2]=startx[2]+strlen(menustring[2])*10;
2625 endy[2]=starty[2]+20;
2631 //tempncl=numchallengelevels;
2632 //numchallengelevels=9;
2633 nummenuitems=2+numchallengelevels;
2636 for(j=0;j<numchallengelevels;j++){
2637 for(i=0;i<255;i++)menustring[j][i]='\0';
2638 sprintf (temp, "Level %d",j+1);
2639 strcpy(menustring[j],temp);
2640 for(i=0;i<17;i++)if(menustring[j][i]=='\0')menustring[j][i]=' ';
2641 menustring[j][17]='\0';
2642 sprintf (temp, "%d",(int)accountactive->getHighScore(j));
2643 strcat(menustring[j],temp);
2644 for(i=18;i<32;i++)if(menustring[j][i]=='\0')menustring[j][i]=' ';
2645 menustring[j][32]='\0';
2646 sprintf (temp, "%d:",(int)(((int)accountactive->getFastTime(j)-(int)(accountactive->getFastTime(j))%60)/60));
2647 strcat(menustring[j],temp);
2648 if((int)(accountactive->getFastTime(j))%60<10)strcat(menustring[j],"0");
2649 sprintf (temp, "%d",(int)(accountactive->getFastTime(j))%60);
2650 strcat(menustring[j],temp);
2654 endx[j]=startx[j]+strlen(menustring[j])*10;
2655 endy[j]=starty[j]+20;
2660 sprintf (menustring[numchallengelevels], "Back");
2661 startx[numchallengelevels]=10;
2662 endx[numchallengelevels]=startx[numchallengelevels]+strlen(menustring[numchallengelevels])*10;
2663 starty[numchallengelevels]=10;
2664 endy[numchallengelevels]=starty[numchallengelevels]+20;
2665 movex[numchallengelevels]=0;
2666 movey[numchallengelevels]=0;
2668 sprintf (menustring[numchallengelevels+1], " High Score Best Time");
2669 startx[numchallengelevels+1]=10;
2670 starty[numchallengelevels+1]=440;
2671 endx[numchallengelevels+1]=startx[numchallengelevels+1]+strlen(menustring[numchallengelevels+1])*10;
2672 endy[numchallengelevels+1]=starty[numchallengelevels+1]+20;
2673 movex[numchallengelevels+1]=0;
2674 movey[numchallengelevels+1]=0;
2676 //numchallengelevels=tempncl;
2683 sprintf (menustring[0], "Congratulations!");
2686 endx[0]=startx[0]+strlen(menustring[0])*10;
2687 endy[0]=starty[0]+20;
2691 sprintf (menustring[1], "You have avenged your family and");
2694 endx[1]=startx[1]+strlen(menustring[1])*10;
2695 endy[1]=starty[1]+20;
2699 sprintf (menustring[2], "restored peace to the island of Lugaru.");
2702 endx[2]=startx[2]+strlen(menustring[2])*10;
2703 endy[2]=starty[2]+20;
2707 sprintf (menustring[3], "Back");
2709 endx[3]=startx[3]+strlen(menustring[3])*10;
2711 endy[3]=starty[3]+20;
2715 for(i=0;i<255;i++)menustring[4][i]='\0';
2716 sprintf (temp, "Your score:");
2717 strcpy(menustring[4],temp);
2718 for(i=0;i<20;i++)if(menustring[4][i]=='\0')menustring[4][i]=' ';
2719 menustring[4][20]='\0';
2720 sprintf (temp, "%d",(int)accountactive->getCampaignScore());
2721 strcat(menustring[4],temp);
2723 endx[4]=startx[4]+strlen(menustring[4])*10;
2725 endy[4]=starty[4]+20;
2729 for(i=0;i<255;i++)menustring[5][i]='\0';
2730 sprintf (temp, "Your time:");
2731 strcpy(menustring[5],temp);
2732 for(i=0;i<20;i++)if(menustring[5][i]=='\0')menustring[5][i]=' ';
2733 menustring[5][20]='\0';
2734 sprintf (temp, "%d",(int)accountcampaigntime[accountactive]);
2735 strcat(menustring[5],temp);
2737 endx[5]=startx[5]+strlen(menustring[5])*10;
2739 endy[5]=starty[5]+20;
2743 for(i=0;i<255;i++)menustring[5][i]='\0';
2744 sprintf (temp, "Highest score:");
2745 strcpy(menustring[5],temp);
2746 for(i=0;i<20;i++)if(menustring[5][i]=='\0')menustring[5][i]=' ';
2747 menustring[5][20]='\0';
2748 sprintf (temp, "%d",(int)accountactive->getCampaignHighScore());
2749 strcat(menustring[5],temp);
2751 endx[5]=startx[5]+strlen(menustring[5])*10;
2753 endy[5]=starty[5]+20;
2757 for(i=0;i<255;i++)menustring[7][i]='\0';
2758 sprintf (temp, "Lowest time:");
2759 strcpy(menustring[7],temp);
2760 for(i=0;i<20;i++)if(menustring[7][i]=='\0')menustring[7][i]=' ';
2761 menustring[7][20]='\0';
2762 sprintf (temp, "%d",(int)accountactive->getCampaignFasttime());
2763 strcat(menustring[7],temp);
2765 endx[7]=startx[7]+strlen(menustring[7])*10;
2767 endy[7]=starty[7]+20;
2773 sprintf (menustring[0], "Stereo mode: %s", StereoModeName(newstereomode));
2776 endx[0]=startx[0]+strlen(menustring[0])*10;
2777 endy[0]=starty[0]+20;
2781 sprintf (menustring[1], "Stereo separation: %.3f", stereoseparation);
2784 endx[1]=startx[1]+strlen(menustring[1])*10;
2785 endy[1]=starty[1]+20;
2789 sprintf (menustring[2], "Reverse stereo: %s", stereoreverse ? "Yes" : "No");
2792 endx[2]=startx[2]+strlen(menustring[2])*10;
2793 endy[2]=starty[2]+20;
2797 sprintf (menustring[3], "Back");
2799 endx[3]=startx[3]+strlen(menustring[3])*10;
2801 endy[3]=starty[3]+20;
2807 if(mainmenu==1||mainmenu==2){
2817 starty[1]=480-152-32;
2824 starty[2]=480-228-32;
2832 starty[3]=480-306-32;
2841 starty[3]=480-306-32;
2855 starty[4]=480-140-256;
2862 starty[5]=480-138-256;
2869 starty[6]=480-144-256;
2877 starty[4]=480-140-256;
2884 starty[5]=480-138-256;
2891 starty[6]=480-144-256;
2899 starty[4]=480-140-256;
2906 starty[5]=480-150-256;
2913 starty[6]=480-144-256;
2921 starty[4]=480-140-256;
2928 starty[5]=480-150-256;
2935 starty[6]=480-144-256;
2943 starty[4]=480-100-256;
2950 starty[5]=480-120-256;
2957 starty[6]=480-144-256;
2967 if(mainmenu==1||mainmenu==2)
2969 if((mousecoordh/screenwidth*640)>startx[i]&&(mousecoordh/screenwidth*640)<endx[i]&&480-(mousecoordv/screenheight*480)>starty[i]&&480-(mousecoordv/screenheight*480)<endy[i]){
2974 if(mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==8||mainmenu==9||mainmenu==10||mainmenu==18)
2975 for(i=0;i<nummenuitems;i++){
2976 if((mousecoordh/screenwidth*640)>startx[i]&&(mousecoordh/screenwidth*640)<endx[i]&&480-(mousecoordv/screenheight*480)>starty[i]&&480-(mousecoordv/screenheight*480)<endy[i]){
2977 if(mainmenu!=5)selected=i;
2978 if(mainmenu==5&&(i!=0&&i!=6))selected=i;
2979 if(mainmenu==9&&(i!=numchallengelevels+1))selected=i; // seem useless, if mainmenu==9 then mainmenu!=5, so selected==i.
2983 for(i=0;i<nummenuitems;i++){
2985 selectedlong[i]+=multiplier*5;
2986 if(selectedlong[i]>1) selectedlong[i]=1;
2988 selectedlong[i]-=multiplier*5;
2989 if(selectedlong[i]<0) selectedlong[i]=0;
2991 offsetx[i]=(startx[i]+endx[i])/2-(mousecoordh/screenwidth*640);
2992 offsety[i]=(starty[i]+endy[i])/2-(480-(mousecoordv/screenheight*480));
2997 if(i>=4&&(mainmenu==1||mainmenu==2)){
2999 offsetx[i]=(startx[i]+endx[i]+movex[i]*transition)/2-(640+190)/2;
3000 offsety[i]=(starty[i]+endy[i]+movey[i]*transition)/2-(336+150)/2;
3006 if(mainmenu==1||mainmenu==2){
3007 glClear(GL_DEPTH_BUFFER_BIT);
3008 glEnable(GL_ALPHA_TEST);
3009 glAlphaFunc(GL_GREATER, 0.001f);
3010 glEnable(GL_TEXTURE_2D);
3011 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3012 glDisable(GL_CULL_FACE);
3013 glDisable(GL_LIGHTING);
3015 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3016 glPushMatrix(); // Store The Projection Matrix
3017 glLoadIdentity(); // Reset The Projection Matrix
3018 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
3019 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3020 glPushMatrix(); // Store The Modelview Matrix
3021 glLoadIdentity(); // Reset The Modelview Matrix
3022 glTranslatef(screenwidth/2,screenheight/2,0);
3024 glScalef((float)screenwidth/2,(float)screenheight/2,1);
3025 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3026 glDisable(GL_BLEND);
3027 glColor4f(0,0,0,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 glDisable(GL_TEXTURE_2D);
3032 //glScalef(.25,.25,.25);
3035 glVertex3f(-1, -1, 0.0f);
3037 glVertex3f(1, -1, 0.0f);
3039 glVertex3f(1, 1, 0.0f);
3041 glVertex3f(-1, 1, 0.0f);
3045 glColor4f(0.4,0.4,0.4,1.0);
3046 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
3047 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
3048 glEnable(GL_TEXTURE_2D);
3049 glBindTexture( GL_TEXTURE_2D, Mainmenuitems[4]);
3051 //glScalef(.25,.25,.25);
3054 glVertex3f(-1, -1, 0.0f);
3056 glVertex3f(1, -1, 0.0f);
3058 glVertex3f(1, 1, 0.0f);
3060 glVertex3f(-1, 1, 0.0f);
3065 glMatrixMode(GL_PROJECTION); // Select The Projection 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
3076 glDisable(GL_TEXTURE_2D);
3080 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3082 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3086 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3087 glPushMatrix(); // Store The Projection Matrix
3088 glLoadIdentity(); // Reset The Projection Matrix
3089 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3090 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3091 glPushMatrix(); // Store The Modelview Matrix
3092 glLoadIdentity(); // Reset The Modelview Matrix
3093 glEnable(GL_TEXTURE_2D);
3094 for(j=0;j<nummenuitems;j++)
3096 if(j<=3||(mainmenu!=1&&mainmenu!=2))
3098 //glDisable(GL_BLEND);
3099 glEnable(GL_ALPHA_TEST);
3101 //glDisable(GL_ALPHA_TEST);
3102 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3103 if(mainmenu==1||mainmenu==2)
3106 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3107 glBindTexture( GL_TEXTURE_2D, Mainmenuitems[j]);
3108 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
3109 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
3110 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3114 glVertex3f(startx[j]+movex[j]*transition, starty[j]+movey[j]*transition, 0.0f);
3116 glVertex3f(endx[j]+movex[j]*transition, starty[j]+movey[j]*transition, 0.0f);
3118 glVertex3f(endx[j]+movex[j]*transition, endy[j]+movey[j]*transition, 0.0f);
3120 glVertex3f(startx[j]+movex[j]*transition, endy[j]+movey[j]*transition, 0.0f);
3124 //glDisable(GL_ALPHA_TEST);
3125 if(j<4)glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3128 if(1-((float)i)/10-(1-selectedlong[j])>0)
3130 glColor4f(1,1,1,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3131 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3135 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);
3137 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);
3139 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);
3141 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);
3147 if(mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==8||mainmenu==9||mainmenu==10||mainmenu==18)
3149 if(mainmenu!=5||j<6)
3152 if(mainmenu==9&&j>accountactive->getProgress()&&j<numchallengelevels)glColor4f(0.5,0,0,1);
3153 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3155 if(mainmenu!=7||j!=0||!entername)
3156 text.glPrint(startx[j],starty[j],menustring[j],0,1,640,480);
3160 sprintf (string, "_");
3161 text.glPrint(startx[j]+(float)(displayselected)*10,starty[j],string,0,1,640,480);
3163 for(l=0;l<displaychars[0];l++){
3164 sprintf (string, "%c",displaytext[0][l]);
3165 text.glPrint(startx[j]+l*10,starty[j],string,0,1,640,480);
3170 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3173 if(1-((float)i)/15-(1-selectedlong[j])>0)
3175 glColor4f(1,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3176 if(mainmenu==9&&j>accountactive->getProgress()&&j<numchallengelevels)glColor4f(0.5,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3177 if(mainmenu==11&&j>accountactive->getProgress()&&j<numchallengelevels)glColor4f(0.5,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3178 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);
3179 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);
3180 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);
3181 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);
3182 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);
3183 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);
3184 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);
3185 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);
3186 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);
3192 glClear(GL_DEPTH_BUFFER_BIT);
3193 glEnable(GL_ALPHA_TEST);
3194 glAlphaFunc(GL_GREATER, 0.001f);
3195 glEnable(GL_TEXTURE_2D);
3196 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3197 glDisable(GL_CULL_FACE);
3198 glDisable(GL_LIGHTING);
3199 if(j==6)glColor4f(1,1,1,1);
3200 else glColor4f(1,0,0,1);
3202 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3203 glPushMatrix(); // Store The Projection Matrix
3204 glLoadIdentity(); // Reset The Projection Matrix
3205 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3206 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3207 glPushMatrix(); // Store The Modelview Matrix
3208 glLoadIdentity(); // Reset The Modelview Matrix
3211 //Draw world, draw map
3212 glTranslatef(2,-5,0);
3214 if(j>6&&j<nummenuitems-1)
3216 XYZ linestart,lineend,offset;
3223 //float linestartx,lineendx,linestarty,lineendy,offsetx,offsety;
3224 linestart.x=(startx[j]+endx[j])/2;
3225 linestart.y=(starty[j]+endy[j])/2;
3226 if(j>=6+accountactive->getCampaignChoicesMade()){
3227 linestart.x=(startx[6+accountactive->getCampaignChoicesMade()]+endx[6+accountactive->getCampaignChoicesMade()])/2;
3228 linestart.y=(starty[6+accountactive->getCampaignChoicesMade()]+endy[6+accountactive->getCampaignChoicesMade()])/2;
3230 lineend.x=(startx[j+1]+endx[j+1])/2;
3231 lineend.y=(starty[j+1]+endy[j+1])/2;
3232 offset=lineend-linestart;
3235 offset=DoRotation(offset,0,0,90);
3237 glDisable(GL_TEXTURE_2D);
3239 if(j<6+accountactive->getCampaignChoicesMade()){
3240 glColor4f(0.5,0,0,1);
3248 linestart+=fac*4*startsize;
3249 lineend-=fac*4*endsize;
3251 if(!(j>7+accountactive->getCampaignChoicesMade()+campaignchoicenum)){
3252 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3256 glVertex3f(linestart.x-offset.x*startsize, linestart.y-offset.y*startsize, 0.0f);
3258 glVertex3f(linestart.x+offset.x*startsize, linestart.y+offset.y*startsize, 0.0f);
3260 glVertex3f(lineend.x+offset.x*endsize, lineend.y+offset.y*endsize, 0.0f);
3262 glVertex3f(lineend.x-offset.x*endsize, lineend.y-offset.y*endsize, 0.0f);
3266 glEnable(GL_TEXTURE_2D);
3270 if(j==6)glBindTexture( GL_TEXTURE_2D, Mainmenuitems[7]);
3271 else glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
3272 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
3273 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
3274 if(j-7<accountactive->getCampaignChoicesMade())glColor4f(0.5,0,0,1);
3275 if(j-7>=accountactive->getCampaignChoicesMade())glColor4f(1,0,0,1);
3276 if(j==6)glColor4f(1,1,1,1);
3279 itemsize=abs(startx[j]-endx[j])/2;
3281 midpoint.x=(startx[j]+endx[j])/2;
3282 midpoint.y=(starty[j]+endy[j])/2;
3283 if(j>6&&(j-7<accountactive->getCampaignChoicesMade()))itemsize*=.5;
3284 if(!(j-7>accountactive->getCampaignChoicesMade()+campaignchoicenum))
3286 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3290 glVertex3f(midpoint.x-itemsize+movex[j]*transition, midpoint.y-itemsize+movey[j]*transition, 0.0f);
3292 glVertex3f(midpoint.x+itemsize+movex[j]*transition, midpoint.y-itemsize+movey[j]*transition, 0.0f);
3294 glVertex3f(midpoint.x+itemsize+movex[j]*transition, midpoint.y+itemsize+movey[j]*transition, 0.0f);
3296 glVertex3f(midpoint.x-itemsize+movex[j]*transition, midpoint.y+itemsize+movey[j]*transition, 0.0f);
3300 //glDisable(GL_ALPHA_TEST);
3301 if(j<4)glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3304 if(1-((float)i)/10-(1-selectedlong[j])>0)
3306 glColor4f(1,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3307 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3311 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);
3313 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);
3315 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);
3317 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);
3325 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3327 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3329 if(j-7>=accountactive->getCampaignChoicesMade()){
3330 text.glPrintOutlined(0.9,0,0,startx[j]+10,starty[j]-4,menustring[j],0,0.6,640,480);
3331 glDisable(GL_DEPTH_TEST);
3337 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3339 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3342 if(mainmenu==1||mainmenu==2)
3343 if(transition<.1||transition>.9){
3344 glClear(GL_DEPTH_BUFFER_BIT);
3345 glEnable(GL_ALPHA_TEST);
3346 glAlphaFunc(GL_GREATER, 0.001f);
3347 glEnable(GL_TEXTURE_2D);
3348 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3349 glDisable(GL_CULL_FACE);
3350 glDisable(GL_LIGHTING);
3352 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3353 glPushMatrix(); // Store The Projection Matrix
3354 glLoadIdentity(); // Reset The Projection Matrix
3355 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3356 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3357 glPushMatrix(); // Store The Modelview Matrix
3358 glLoadIdentity(); // Reset The Modelview Matrix
3360 glDisable(GL_TEXTURE_2D);
3362 glColor4f(1,0,0,1-(transition*10));
3364 glColor4f(1,0,0,1-((1-transition)*10));
3367 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3371 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3372 glPushMatrix(); // Store The Projection Matrix
3373 glLoadIdentity(); // Reset The Projection Matrix
3374 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
3375 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3376 glPushMatrix(); // Store The Modelview Matrix
3377 glLoadIdentity(); // Reset The Modelview Matrix
3378 glTranslatef(screenwidth/2,screenheight/2,0);
3380 glScalef((float)screenwidth/2,(float)screenheight/2,1);
3381 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3383 glEnable(GL_TEXTURE_2D);
3385 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
3386 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
3388 if(!waiting) { // hide the cursor while waiting for a key
3390 glTranslatef(mousecoordh-screenwidth/2,mousecoordv*-1+screenheight/2,0);
3391 glScalef((float)screenwidth/64,(float)screenwidth/64,1);
3392 glTranslatef(1,-1,0);
3393 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3395 glBindTexture( GL_TEXTURE_2D, cursortexture);
3397 //glScalef(.25,.25,.25);
3400 glVertex3f(-1, -1, 0.0f);
3402 glVertex3f(1, -1, 0.0f);
3404 glVertex3f(1, 1, 0.0f);
3406 glVertex3f(-1, 1, 0.0f);
3412 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3418 //printf("Flash amount: %f, delay %i\n", flashamount, flashdelay);
3419 if(flashamount>1)flashamount=1;
3420 if(flashdelay<=0)flashamount-=multiplier;
3422 if(flashamount<0)flashamount=0;
3423 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3424 glDisable(GL_CULL_FACE);
3425 glDisable(GL_LIGHTING);
3426 glDisable(GL_TEXTURE_2D);
3428 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3429 glPushMatrix(); // Store The Projection Matrix
3430 glLoadIdentity(); // Reset The Projection Matrix
3431 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
3432 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3433 glPushMatrix(); // Store The Modelview Matrix
3434 glLoadIdentity(); // Reset The Modelview Matrix
3435 glScalef(screenwidth,screenheight,1);
3436 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3438 glColor4f(flashr,flashg,flashb,flashamount);
3440 glVertex3f(0, 0, 0.0f);
3441 glVertex3f(256, 0, 0.0f);
3442 glVertex3f(256, 256, 0.0f);
3443 glVertex3f(0, 256, 0.0f);
3445 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3446 glPopMatrix(); // Restore The Old Projection Matrix
3447 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3448 glPopMatrix(); // Restore The Old Projection Matrix
3449 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
3450 glEnable(GL_CULL_FACE);
3451 glDisable(GL_BLEND);
3456 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)||(!gameon&&gamestarted)){
3457 tempmult=multiplier;
3462 if ( side == stereoRight || side == stereoCenter ) {
3463 if(drawmode!=motionblurmode||mainmenu){
3468 //myassert(glGetError() == GL_NO_ERROR);
3469 glDrawBuffer(GL_BACK);
3470 glReadBuffer(GL_BACK);
3475 if(drawtoggle==2)drawtoggle=0;
3477 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)){
3478 multiplier=tempmult;
3480 //Jordan fixed your warning!