2 Copyright (C) 2003, 2010 - Wolfire Games
4 This file is part of Lugaru.
6 Lugaru is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; either version 2
9 of the License, or (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 See the GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 #include "openal_wrapper.h"
30 extern int environment;
31 extern float texscale;
33 extern Terrain terrain;
34 //extern Sprites sprites;
35 extern float multiplier;
37 extern float viewdistance;
38 extern float fadestart;
39 extern float screenwidth,screenheight;
40 extern int kTextureSize;
41 extern FRUSTUM frustum;
43 extern Objects objects;
45 extern float usermousesensitivity;
47 extern float camerashake;
49 extern float slomodelay;
50 extern bool ismotionblur;
52 extern float blackout;
53 extern bool damageeffects;
55 extern bool texttoggle;
56 extern float blurness;
57 extern float targetblurness;
58 extern float playerdist;
59 extern bool cellophane;
61 extern float flashamount,flashr,flashg,flashb;
62 extern int flashdelay;
64 extern float motionbluramount;
66 extern bool alwaysblur;
68 extern bool tilt2weird;
69 extern bool tiltweird;
71 extern bool proportionweird;
72 extern bool vertexweird[6];
73 extern bool velocityblur;
74 extern bool debugmode;
76 extern int oldmainmenu;
77 extern int bloodtoggle;
78 extern int difficulty;
81 //extern int texdetail;
82 extern float texdetail;
83 extern bool musictoggle;
84 extern int tutoriallevel;
85 extern float smoketex;
86 extern float tutorialstagetime;
87 extern float tutorialmaxtime;
88 extern int tutorialstage;
89 extern bool againbonus;
90 extern float damagedealt;
91 extern bool invertmouse;
93 extern int numhotspots;
94 extern int winhotspot;
95 extern int killhotspot;
96 extern XYZ hotspot[40];
97 extern int hotspottype[40];
98 extern float hotspotsize[40];
99 extern char hotspottext[40][256];
100 extern int currenthotspot;;
102 extern bool campaign;
103 extern bool winfreeze;
105 extern float menupulse;
107 extern bool gamestart;
109 extern int numdialogues;
110 extern int numdialogueboxes[max_dialogues];
111 extern int dialoguetype[max_dialogues];
112 extern int dialogueboxlocation[max_dialogues][max_dialoguelength];
113 extern float dialogueboxcolor[max_dialogues][max_dialoguelength][3];
114 extern int dialogueboxsound[max_dialogues][max_dialoguelength];
115 extern char dialoguetext[max_dialogues][max_dialoguelength][128];
116 extern char dialoguename[max_dialogues][max_dialoguelength][64];
117 extern XYZ dialoguecamera[max_dialogues][max_dialoguelength];
118 extern XYZ participantlocation[max_dialogues][10];
119 extern int participantfocus[max_dialogues][max_dialoguelength];
120 extern int participantaction[max_dialogues][max_dialoguelength];
121 extern float participantrotation[max_dialogues][10];
122 extern XYZ participantfacing[max_dialogues][max_dialoguelength][10];
123 extern float dialoguecamerarotation[max_dialogues][max_dialoguelength];
124 extern float dialoguecamerarotation2[max_dialogues][max_dialoguelength];
125 extern int indialogue;
126 extern int whichdialogue;
127 extern int directing;
128 extern float dialoguetime;
129 extern int dialoguegonethrough[20];
131 extern bool gamestarted;
133 extern bool showdamagebar;
135 void Game::flash() { // shouldn't be that way, these should be attributes and Person class should not change rendering.
142 /*********************> DrawGLScene() <*****/
143 int Game::DrawGLScene(StereoSide side)
145 static float texcoordwidth,texcoordheight;
146 static float texviewwidth, texviewheight;
148 static GLubyte color;
149 static float newbrightness;
150 static float changespeed;
151 static XYZ checkpoint;
152 static float tempmult;
154 static char string[256]="";
155 static char string2[256]="";
156 static char string3[256]="";
158 static float lastcheck;
160 lastcheck+=multiplier;
162 if ( stereomode == stereoAnaglyph ) {
164 case stereoLeft: glColorMask( 0.0, 1.0, 1.0, 1.0 ); break;
165 case stereoRight: glColorMask( 1.0, 0.0, 0.0, 1.0 ); break;
168 glColorMask( 1.0, 1.0, 1.0, 1.0 );
170 if ( stereomode == stereoHorizontalInterlaced || stereomode == stereoVerticalInterlaced ) {
171 glStencilFunc(side == stereoLeft ? GL_NOTEQUAL : GL_EQUAL, 0x01, 0x01);
175 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)){
182 numboundaries=mapradius*2;
183 if(numboundaries>360)numboundaries=360;
184 for(i=0;i<numboundaries;i++){
187 boundary[i]=mapcenter+DoRotation(boundary[i]*mapradius,0,i*(360/((float)(numboundaries))),0);
196 olddrawmode=drawmode;
197 if(ismotionblur&&!loading){
198 if((findLengthfast(&player[0].velocity)>200)&&velocityblur&&!cameramode){
199 drawmode=motionblurmode;
200 motionbluramount=200/(findLengthfast(&player[0].velocity));
203 if(player[0].damage-player[0].superpermanentdamage>(player[0].damagetolerance-player[0].superpermanentdamage)*1/2&&damageeffects&&!cameramode){
204 drawmode=doublevisionmode;
211 drawmode=motionblurmode;
213 slomodelay-=multiplier;
214 if(slomodelay<0)slomo=0;
218 if((!changed&&!slomo)||loading){
220 if(ismotionblur&&(/*fps>100||*/alwaysblur)){
221 if(olddrawmode!=realmotionblurmode)change=1;
223 drawmode=realmotionblurmode;
225 else if(olddrawmode==realmotionblurmode)change=2;
229 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted))drawmode=normalmode;
230 if((freeze||winfreeze)&&ismotionblur&&!mainmenu)drawmode=radialzoommode;
232 if(winfreeze||mainmenu)drawmode=normalmode;
235 if(drawmode==glowmode){
240 DSpContext_FadeGamma(NULL,200,&color2);
244 if(drawtoggle!=2)drawtoggle=1-drawtoggle;
248 texviewwidth=kTextureSize;
249 if(texviewwidth>screenwidth)texviewwidth=screenwidth;
250 texviewheight=kTextureSize;
251 if(texviewheight>screenheight)texviewheight=screenheight;
253 texcoordwidth=screenwidth/kTextureSize;
254 texcoordheight=screenheight/kTextureSize;
255 if(texcoordwidth>1)texcoordwidth=1;
256 if(texcoordheight>1)texcoordheight=1;
259 glDrawBuffer(GL_BACK);
260 glReadBuffer(GL_BACK);
262 if(abs(blurness-targetblurness)<multiplier*10||abs(blurness-targetblurness)>2){
263 blurness=targetblurness;
264 targetblurness=(float)(abs(Random()%100))/40;
266 if(blurness<targetblurness)
267 blurness+=multiplier*5;
269 blurness-=multiplier*5;
272 static XYZ terrainlight;
273 static float distance;
274 if(drawmode==normalmode)ReSizeGLScene(90,.1f);
275 if(drawmode!=normalmode)glViewport(0,0,texviewwidth,texviewheight);
276 glDepthFunc(GL_LEQUAL);
278 glAlphaFunc(GL_GREATER, 0.0001f);
279 glEnable(GL_ALPHA_TEST);
280 glClearColor(0.25f, 0.25f, 0.25f, 1.0f);
281 glClear(GL_DEPTH_BUFFER_BIT);
283 glMatrixMode (GL_MODELVIEW);
284 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
287 // Move the camera for the current eye's point of view.
288 // Reverse the movement if we're reversing stereo
289 glTranslatef((stereoseparation/2) * side * (stereoreverse ? -1 : 1), 0, 0);
291 if(!cameramode&&!freeze&&!winfreeze){
292 glRotatef(float(Random()%100)/10*camerashake/*+(woozy*woozy)/10*/,0,0,1);
293 glRotatef(rotation2+sin(woozy/2)*(player[0].damage/player[0].damagetolerance)*5,1,0,0);
294 glRotatef(rotation+sin(woozy)*(player[0].damage/player[0].damagetolerance)*5,0,1,0);
296 if(cameramode||freeze||winfreeze){
297 glRotatef(rotation2,1,0,0);
298 glRotatef(rotation,0,1,0);
301 if(environment==desertenvironment){
302 glRotatef((float)(abs(Random()%100))/3000-1,1,0,0);
303 glRotatef((float)(abs(Random()%100))/3000-1,0,1,0);
305 SetUpLight(&light,0);
307 if(environment==desertenvironment&&detail==2)glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, blurness+.4 );
308 if(environment==desertenvironment){
309 glRotatef((float)(abs(Random()%100))/1000,1,0,0);
310 glRotatef((float)(abs(Random()%100))/1000,0,1,0);
313 glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0);
315 glTranslatef(-viewer.x,-viewer.y,-viewer.z);
316 frustum.GetFrustum();
320 static float size,opacity,rotation;
322 for(k=0;k<numplayers;k++){
323 if(!player[k].skeleton.free&&player[k].playerdetail&&player[k].howactive<typesleeping)
324 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)
325 for(i=0;i<player[k].skeleton.num_joints;i++){
326 if(player[k].skeleton.joints[i].label==leftknee||player[k].skeleton.joints[i].label==rightknee||player[k].skeleton.joints[i].label==groin){
327 point=DoRotation(player[k].skeleton.joints[i].position,0,player[k].rotation,0)*player[k].scale+player[k].coords;
329 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;
330 if(k!=0&&tutoriallevel==1){
331 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;
333 terrain.MakeDecal(shadowdecal,point,size,opacity,rotation);
334 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
335 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
336 if(objects.position[j].y<player[k].coords.y||objects.type[j]==tunneltype||objects.type[j]==weirdtype){
337 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);
340 if(k!=0&&tutoriallevel==1){
341 opacity=.2+.2*sin(smoketex*6+i);
343 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
348 if((player[k].skeleton.free||player[k].howactive>=typesleeping)&&player[k].playerdetail)
349 if(frustum.SphereInFrustum(player[k].coords.x,player[k].coords.y,player[k].coords.z,player[k].scale*5)&&player[k].occluded<25)
350 for(i=0;i<player[k].skeleton.num_joints;i++){
351 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){
352 if(player[k].skeleton.free)point=player[k].skeleton.joints[i].position*player[k].scale+player[k].coords;
353 else point=DoRotation(player[k].skeleton.joints[i].position,0,player[k].rotation,0)*player[k].scale+player[k].coords;
355 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;
356 if(k!=0&&tutoriallevel==1){
357 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;
359 terrain.MakeDecal(shadowdecal,point,size,opacity*.7,rotation);
360 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
361 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
362 if(objects.position[j].y<player[k].coords.y||objects.type[j]==tunneltype||objects.type[j]==weirdtype){
363 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);
364 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);
367 if(k!=0&&tutoriallevel==1){
368 opacity=.2+.2*sin(smoketex*6+i);
370 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
376 if(!player[k].playerdetail)
377 if(frustum.SphereInFrustum(player[k].coords.x,player[k].coords.y,player[k].coords.z,player[k].scale*5))
379 point=player[k].coords;
381 opacity=.4-(player[k].coords.y-terrain.getHeight(player[k].coords.x,player[k].coords.z))/5;
382 terrain.MakeDecal(shadowdecal,point,size,opacity*.7,rotation);
383 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
384 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
385 point=DoRotation(player[k].coords-objects.position[j],0,-objects.rotation[j],0);
388 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
394 glEnable(GL_TEXTURE_2D);
396 glEnable(GL_DEPTH_TEST);
397 glEnable(GL_CULL_FACE);
399 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
400 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
401 glBindTexture( GL_TEXTURE_2D, terraintexture);
403 glBindTexture( GL_TEXTURE_2D, terraintexture2);
405 //glBindTexture( GL_TEXTURE_2D, terraintexture3);
406 //glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
409 terrain.drawdecals();
412 glEnable(GL_CULL_FACE);
413 glEnable(GL_LIGHTING);
415 glEnable(GL_TEXTURE_2D);
418 glEnable(GL_COLOR_MATERIAL);
433 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
434 glEnable(GL_CULL_FACE);
435 glCullFace(GL_FRONT);
437 for(k=0;k<numplayers;k++){
438 if(k==0||tutoriallevel!=1){
440 glEnable(GL_LIGHTING);
441 terrainlight=terrain.getLighting(player[k].coords.x,player[k].coords.z);
442 distance=findDistancefast(&viewer,&player[k].coords);
443 distance=(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance;
444 glColor4f(terrainlight.x,terrainlight.y,terrainlight.z,distance);
445 if(distance>=1)glDisable(GL_BLEND);
447 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;
449 if(!player[k].occluded==0)i=checkcollide(viewer,checkpoint,player[k].lastoccluded);
450 if(i==-1||player[k].occluded==0)i=checkcollide(viewer,checkpoint);
452 player[k].occluded+=1;
453 player[k].lastoccluded=i;
455 else player[k].occluded=0;
456 if(player[k].occluded<25)player[k].DrawSkeleton();
462 if(!cameramode&&musictype==stream_music2)playerdist=findDistancefastflat(&player[0].coords,&viewer);
463 else playerdist=-100;
466 glEnable(GL_TEXTURE_2D);
471 if(frustum.SphereInFrustum(realhawkcoords.x+hawk.boundingspherecenter.x,realhawkcoords.y+hawk.boundingspherecenter.y,realhawkcoords.z+hawk.boundingspherecenter.z,2)){
472 glAlphaFunc(GL_GREATER, 0.0001f);
474 glDisable(GL_CULL_FACE);
475 glDisable(GL_LIGHTING);
477 glTranslatef(hawkcoords.x,hawkcoords.y,hawkcoords.z);
478 glRotatef(hawkrotation,0,1,0);
479 glTranslatef(25,0,0);
480 distance=findDistancefast(&viewer,&realhawkcoords)*1.2;
481 glColor4f(light.color[0],light.color[1],light.color[2],(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance);
482 if((viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance>1)glColor4f(light.color[0],light.color[1],light.color[2],1);
483 if((viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance>0)
484 hawk.drawdifftex(hawktexture);
488 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
489 glEnable(GL_CULL_FACE);
490 glCullFace(GL_FRONT);
492 for(k=0;k<numplayers;k++){
493 if(!(k==0||tutoriallevel!=1)){
495 glEnable(GL_LIGHTING);
496 terrainlight=terrain.getLighting(player[k].coords.x,player[k].coords.z);
497 distance=findDistancefast(&viewer,&player[k].coords);
498 distance=(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance;
499 glColor4f(terrainlight.x,terrainlight.y,terrainlight.z,distance);
500 if(distance>=1)glDisable(GL_BLEND);
502 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;
504 if(!player[k].occluded==0)i=checkcollide(viewer,checkpoint,player[k].lastoccluded);
505 if(i==-1||player[k].occluded==0)i=checkcollide(viewer,checkpoint);
507 player[k].occluded+=1;
508 player[k].lastoccluded=i;
510 else player[k].occluded=0;
511 if(player[k].occluded<25)player[k].DrawSkeleton();
517 glEnable(GL_TEXTURE_2D);
522 glDisable(GL_COLOR_MATERIAL);
524 glDisable(GL_LIGHTING);
525 glDisable(GL_TEXTURE_2D);
533 glDisable(GL_LIGHTING);
534 glDisable(GL_TEXTURE_2D);
535 glDisable(GL_COLOR_MATERIAL);
538 for(k=0;k<numplayers;k++){
539 if(player[k].numwaypoints>1){
540 glBegin(GL_LINE_LOOP);
541 for(i=0;i<player[k].numwaypoints;i++){
542 glVertex3f(player[k].waypoints[i].x,player[k].waypoints[i].y+.5,player[k].waypoints[i].z);
551 for(k=0;k<numpathpoints;k++){
552 if(numpathpointconnect[k]){
553 for(i=0;i<numpathpointconnect[k];i++){
554 glBegin(GL_LINE_LOOP);
555 glVertex3f(pathpoint[k].x,pathpoint[k].y+.5,pathpoint[k].z);
556 glVertex3f(pathpoint[pathpointconnect[k][i]].x,pathpoint[pathpointconnect[k][i]].y+.5,pathpoint[pathpointconnect[k][i]].z);
564 glVertex3f(pathpoint[pathpointselected].x,pathpoint[pathpointselected].y+.5,pathpoint[pathpointselected].z);
571 glEnable(GL_TEXTURE_2D);
572 glColor4f(.5,.5,.5,1);
574 sprintf (string, " ",(int)(fps));
575 text.glPrint(10,30,string,0,.8,screenwidth,screenheight);
578 if(bonus>0&&bonustime<1&&!winfreeze&&indialogue==-1/*bonustime<4*/){
579 const char *bonus_name;
580 if (bonus < bonus_count)
581 bonus_name = bonus_names[bonus];
583 bonus_name = "Excellent!"; // When does this happen?
585 glColor4f(0,0,0,1-bonustime);
586 text.glPrintOutline(1024/2-10*strlen(bonus_name)-4,768/16-4+768*4/5,bonus_name,1,2.5,1024,768);
587 glColor4f(1,0,0,1-bonustime);
588 text.glPrint(1024/2-10*strlen(bonus_name),768/16+768*4/5,bonus_name,1,2,1024,768);
590 sprintf (string, "%d",(int)bonusvalue);
591 glColor4f(0,0,0,1-bonustime);
592 text.glPrintOutline(1024/2-10*strlen(string)-4,768/16-4-20+768*4/5,string,1,2.5*.8,1024,768);
593 glColor4f(1,0,0,1-bonustime);
594 text.glPrint(1024/2-10*strlen(string),768/16-20+768*4/5,string,1,2*.8,1024,768);
595 glColor4f(.5,.5,.5,1);
598 if(tutoriallevel==1){
599 tutorialopac=tutorialmaxtime-tutorialstagetime;
600 if(tutorialopac>1)tutorialopac=1;
601 if(tutorialopac<0)tutorialopac=0;
603 sprintf (string, " ");
604 sprintf (string2, " ");
605 sprintf (string3, " ");
606 if(tutorialstage==0){
607 sprintf (string, " ");
608 sprintf (string2, " ");
609 sprintf (string3, " ");
611 if(tutorialstage==1){
612 sprintf (string, "Welcome to the Lugaru training level!");
613 sprintf (string2, " ");
614 sprintf (string3, " ");
616 if(tutorialstage==2){
617 sprintf (string, "BASIC MOVEMENT:");
618 sprintf (string2, " ");
619 sprintf (string3, " ");
621 if(tutorialstage==3){
622 sprintf (string, "You can move the mouse to rotate the camera.");
623 sprintf (string2, " ");
624 sprintf (string3, " ");
626 if(tutorialstage==4){
627 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));
628 sprintf (string2, "All movement is relative to the camera.");
629 sprintf (string3, " ");
631 if(tutorialstage==5){
632 sprintf (string, "Please press %s to jump.",Input::keyToChar(jumpkey));
633 sprintf (string2, "You can hold it longer to jump higher.");
634 sprintf (string3, " ");
636 if(tutorialstage==6){
637 sprintf (string, "You can press %s to crouch.",Input::keyToChar(crouchkey));
638 sprintf (string2, "You can jump higher from a crouching position.");
639 sprintf (string3, " ");
641 if(tutorialstage==7){
642 sprintf (string, "While running, you can press %s to roll.",Input::keyToChar(crouchkey));
643 sprintf (string2, " ");
644 sprintf (string3, " ");
646 if(tutorialstage==8){
647 sprintf (string, "While crouching, you can sneak around silently");
648 sprintf (string2, "using the movement keys.");
649 sprintf (string3, " ");
651 if(tutorialstage==9){
652 sprintf (string, "Release the crouch key while sneaking and hold the movement keys");
653 sprintf (string2, "to run animal-style.");
654 sprintf (string3, " ");
656 if(tutorialstage==10){
657 sprintf (string, "ADVANCED MOVEMENT:");
658 sprintf (string2, " ");
659 sprintf (string3, " ");
661 if(tutorialstage==11){
662 sprintf (string, "When you jump at a wall, you can hold %s again",Input::keyToChar(jumpkey));
663 sprintf (string2, "during impact to perform a walljump.");
664 sprintf (string3, "Be sure to use the movement keys to press against the wall");
666 if(tutorialstage==12){
667 sprintf (string, "While in the air, you can press crouch to flip.",Input::keyToChar(jumpkey));
668 sprintf (string2, "Walljumps and flips confuse enemies and give you more control.");
669 sprintf (string3, " ");
671 if(tutorialstage==13){
672 sprintf (string, "BASIC COMBAT:");
673 sprintf (string2, " ");
674 sprintf (string3, " ");
676 if(tutorialstage==14){
677 sprintf (string, "There is now an imaginary enemy");
678 sprintf (string2, "in the middle of the training area.");
679 sprintf (string3, " ");
681 if(tutorialstage==15){
682 if(attackkey==MOUSEBUTTON1)sprintf (string, "Click to attack when you are near an enemy.");
683 else sprintf (string, "Press %s to attack when you are near an enemy.",Input::keyToChar(attackkey));
684 sprintf (string2, "You can punch by standing still near an enemy and attacking.");
685 sprintf (string3, " ");
687 if(tutorialstage==16){
688 sprintf (string, "If you are close, you will perform a weak punch.");
689 sprintf (string2, "The weak punch is excellent for starting attack combinations.");
690 sprintf (string3, " ");
692 if(tutorialstage==17){
693 sprintf (string, "Attacking while running results in a spin kick.");
694 sprintf (string2, "This is one of your most powerful ground attacks.");
695 sprintf (string3, " ");
697 if(tutorialstage==18){
698 sprintf (string, "Sweep the enemy's legs out by attacking while crouched.");
699 sprintf (string2, "This is a very fast attack, and easy to follow up.");
700 sprintf (string3, " ");
702 if(tutorialstage==19){
703 sprintf (string, "When an enemy is on the ground, you can deal some extra");
704 sprintf (string2, "damage by running up and drop-kicking him.");
705 sprintf (string3, "(Try knocking them down with a sweep first)");
707 if(tutorialstage==20){
708 sprintf (string, "Your most powerful individual attack is the rabbit kick.");
709 if(attackkey==MOUSEBUTTON1)sprintf (string2, "Run at the enemy while holding the mouse button, and press");
710 else sprintf (string2, "Run at the enemy while holding %s, and press", Input::keyToChar(attackkey));
711 sprintf (string3, "the jump key (%s) to attack.",Input::keyToChar(jumpkey));
713 if(tutorialstage==21){
714 sprintf (string, "This attack is devastating if timed correctly.");
715 sprintf (string2, "Even if timed incorrectly, it will knock the enemy over.");
716 if(againbonus)sprintf (string3, "Try rabbit-kicking the imaginary enemy again.");
717 else sprintf (string3, "Try rabbit-kicking the imaginary enemy.");
719 if(tutorialstage==22){
720 sprintf (string, "If you sneak behind an enemy unnoticed, you can kill");
721 sprintf (string2, "him instantly. Move close behind this enemy");
722 sprintf (string3, "and attack.");
724 if(tutorialstage==23){
725 sprintf (string, "Another important attack is the wall kick. When an enemy");
726 sprintf (string2, "is near a wall, perform a walljump nearby and hold");
727 sprintf (string3, "the attack key during impact with the wall.");
729 if(tutorialstage==24){
730 sprintf (string, "You can tackle enemies by running at them animal-style");
731 if(attackkey==MOUSEBUTTON1)sprintf (string2, "and pressing jump (%s) or attack(mouse button).",Input::keyToChar(jumpkey));
732 else sprintf (string2, "and pressing jump (%s) or attack(%s).",Input::keyToChar(jumpkey),Input::keyToChar(attackkey));
733 sprintf (string3, "This is especially useful when they are running away.");
735 if(tutorialstage==25){
736 sprintf (string, "Dodge by pressing back and attack. Dodging is essential");
737 sprintf (string2, "against enemies with swords or other long weapons.");
738 sprintf (string3, " ");
740 if(tutorialstage==26){
741 sprintf (string, "REVERSALS AND COUNTER-REVERSALS");
742 sprintf (string2, " ");
743 sprintf (string3, " ");
745 if(tutorialstage==27){
746 sprintf (string, "The enemy can now reverse your attacks.");
747 sprintf (string2, " ");
748 sprintf (string3, " ");
750 if(tutorialstage==28){
751 sprintf (string, "If you attack, you will notice that the enemy now sometimes");
752 sprintf (string2, "catches your attack and uses it against you. Hold");
753 sprintf (string3, "crouch (%s) after attacking to escape from reversals.",Input::keyToChar(crouchkey));
755 if(tutorialstage==29){
756 sprintf (string, "Try escaping from two more reversals in a row.");
757 sprintf (string2, " ");
758 sprintf (string3, " ");
760 if(tutorialstage==30){
761 sprintf (string, "Good!");
762 sprintf (string2, " ");
763 sprintf (string3, " ");
765 if(tutorialstage==31){
766 sprintf (string, "To reverse an attack, you must tap crouch (%s) during the",Input::keyToChar(crouchkey));
767 sprintf (string2, "enemy's attack. You must also be close to the enemy;");
768 sprintf (string3, "this is especially important against armed opponents.");
770 if(tutorialstage==32){
771 sprintf (string, "The enemy can attack in %d seconds.", (int)(tutorialmaxtime-tutorialstagetime));
772 sprintf (string2, "This imaginary opponents attacks will be highlighted");
773 sprintf (string3, "to make this easier.");
775 if(tutorialstage==33){
776 sprintf (string, "Reverse three enemy attacks!");
777 sprintf (string2, " ");
778 sprintf (string3, " ");
780 if(tutorialstage==34){
781 sprintf (string, "Reverse two more enemy attacks!");
782 sprintf (string2, " ");
783 sprintf (string3, " ");
785 if(tutorialstage==35){
786 sprintf (string, "Reverse one more enemy attack!");
787 sprintf (string2, " ");
788 sprintf (string3, " ");
790 if(tutorialstage==36){
791 sprintf (string, "Excellent!");
792 sprintf (string2, " ");
793 sprintf (string3, " ");
795 if(tutorialstage==37){
796 sprintf (string, "Now spar with the enemy for %d more seconds.", (int)(tutorialmaxtime-tutorialstagetime));
797 sprintf (string2, "Damage dealt: %d",(int)damagedealt);
798 sprintf (string3, "Damage taken: %d.",(int)damagetaken);
800 if(tutorialstage==38){
801 sprintf (string, "WEAPONS:");
802 sprintf (string2, " ");
803 sprintf (string3, " ");
805 if(tutorialstage==39){
806 sprintf (string, "There is now an imaginary knife");
807 sprintf (string2, "in the center of the training area.");
808 sprintf (string3, " ");
810 if(tutorialstage==40){
811 sprintf (string, "Stand, roll or handspring over the knife");
812 sprintf (string2, "while pressing %s to pick it up.",Input::keyToChar(throwkey));
813 sprintf (string3, "You can crouch and press the same key to drop it again.");
815 if(tutorialstage==41){
816 sprintf (string, "You can equip and unequip weapons using the %s key.",Input::keyToChar(drawkey));
817 sprintf (string2, "Sometimes it is best to keep them unequipped to");
818 sprintf (string3, "prevent enemies from taking them. ");
820 if(tutorialstage==42){
821 sprintf (string, "The knife is the smallest weapon and the least encumbering.");
822 sprintf (string2, "You can equip or unequip it while standing, crouching,");
823 sprintf (string3, "running or flipping.");
825 if(tutorialstage==43){
826 sprintf (string, "You perform weapon attacks the same way as unarmed attacks,");
827 sprintf (string2, "but sharp weapons cause permanent damage, instead of the");
828 sprintf (string3, "temporary trauma from blunt weapons, fists and feet.");
830 if(tutorialstage==44){
831 sprintf (string, "The enemy now has your knife!");
832 sprintf (string2, "Please reverse two of his knife attacks.");
833 sprintf (string3, " ");
835 if(tutorialstage==45){
836 sprintf (string, "Please reverse one more of his knife attacks.");
837 sprintf (string2, " ");
838 sprintf (string3, " ");
840 if(tutorialstage==46){
841 sprintf (string, "Now he has a sword!");
842 sprintf (string2, "The sword has longer reach than your arms, so you");
843 sprintf (string3, "must move close to reverse the sword slash.");
845 if(tutorialstage==47){
846 sprintf (string, "Long weapons like the sword and staff are also useful for defense;");
847 sprintf (string2, "you can parry enemy weapon attacks by pressing the attack key");
848 sprintf (string3, "at the right time. Please try parrying the enemy's attacks!");
850 if(tutorialstage==48){
851 sprintf (string, "The staff is like the sword, but has two main attacks.");
852 sprintf (string2, "The standing smash is fast and effective, and the running");
853 sprintf (string3, "spin smash is slower and more powerful.");
855 if(tutorialstage==49){
856 sprintf (string, "When facing an enemy, you can throw the knife with %s.",Input::keyToChar(throwkey));
857 sprintf (string2, "It is possible to throw the knife while flipping,");
858 sprintf (string3, "but it is very inaccurate.");
860 if(tutorialstage==50){
861 sprintf (string, "You now know everything you can learn from training.");
862 sprintf (string2, "Everything else you must learn from experience!");
863 sprintf (string3, " ");
865 if(tutorialstage==51){
866 sprintf (string, "Walk out of the training area to return to the main menu.");
867 sprintf (string2, " ");
868 sprintf (string3, " ");
871 glColor4f(0,0,0,tutorialopac);
872 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);
873 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);
874 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);
875 glColor4f(1,1,1,tutorialopac);
876 text.glPrint(screenwidth/2-7.6*strlen(string)*screenwidth/1024,screenheight/16+screenheight*4/5,string,1,1.5*screenwidth/1024,screenwidth,screenheight);
877 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);
878 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);
880 sprintf (string, "Press 'tab' to skip to the next item.",Input::keyToChar(jumpkey));
881 sprintf (string2, "Press escape at any time to");
882 sprintf (string3, "pause or exit the tutorial.");
885 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);
886 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);
887 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);
888 glColor4f(0.5,0.5,0.5,1);
889 text.glPrint(screenwidth/2-7.6*strlen(string)*screenwidth/1024*.8,0+screenheight*1/10,string,1,1.5*screenwidth/1024*.8,screenwidth,screenheight);
890 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);
891 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);
895 if(numhotspots&&(bonustime>=1||bonus<=0||bonustime<0)&&!tutoriallevel){
897 float closestdist=-1;
899 closest=currenthotspot;
900 for(i=0;i<numhotspots;i++){
901 distance=findDistancefast(&player[0].coords,&hotspot[i]);
902 if(closestdist==-1||distance<closestdist){
903 if(findDistancefast(&player[0].coords,&hotspot[i])<hotspotsize[i]&&((hotspottype[i]<=10&&hotspottype[i]>=0)||(hotspottype[i]<=40&&hotspottype[i]>=20))){
904 closestdist=distance;
910 currenthotspot=closest;
911 if(currenthotspot!=-1){
912 if(hotspottype[closest]<=10){
913 if(findDistancefast(&player[0].coords,&hotspot[closest])<hotspotsize[closest])
916 tutorialopac=tutorialmaxtime-tutorialstagetime;
917 if(tutorialopac>1)tutorialopac=1;
918 if(tutorialopac<0)tutorialopac=0;
920 sprintf (string, "%s", hotspottext[closest]);
927 if(string[i]=='\n'||string[i]>'z'||string[i]<' '||string[i]=='\0'){
928 glColor4f(0,0,0,tutorialopac);
929 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);
930 glColor4f(1,1,1,tutorialopac);
931 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);
934 if(string[i]=='\0')done=1;
940 else if (hotspottype[closest]>=20&&dialoguegonethrough[hotspottype[closest]-20]==0){
941 whichdialogue=hotspottype[closest]-20;
942 for(j=0;j<numdialogueboxes[whichdialogue];j++){
943 player[participantfocus[whichdialogue][j]].coords=participantlocation[whichdialogue][participantfocus[whichdialogue][j]];
944 player[participantfocus[whichdialogue][j]].rotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
945 player[participantfocus[whichdialogue][j]].targetrotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
946 player[participantfocus[whichdialogue][j]].velocity=0;
947 player[participantfocus[whichdialogue][j]].targetanimation=player[participantfocus[whichdialogue][j]].getIdle();
948 player[participantfocus[whichdialogue][j]].targetframe=0;
952 dialoguegonethrough[whichdialogue]++;
953 if(dialogueboxsound[whichdialogue][indialogue]!=0){
955 if(dialogueboxsound[whichdialogue][indialogue]==1)whichsoundplay=rabbitchitter;
956 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
957 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
958 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
959 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
960 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
961 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
962 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
963 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
964 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
965 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
966 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
967 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
968 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
969 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
970 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
971 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
972 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
973 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
974 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
975 emit_sound_at(whichsoundplay, player[participantfocus[whichdialogue][indialogue]].coords);
981 if(indialogue!=-1&&!mainmenu){
982 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
983 glDisable(GL_CULL_FACE);
984 glDisable(GL_LIGHTING);
985 glDisable(GL_TEXTURE_2D);
987 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
988 glPushMatrix(); // Store The Projection Matrix
989 glLoadIdentity(); // Reset The Projection Matrix
990 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
991 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
992 glPushMatrix(); // Store The Modelview Matrix
993 glLoadIdentity(); // Reset The Modelview Matrix
994 if(dialogueboxlocation[whichdialogue][indialogue]==1)glTranslatef(0,screenheight*3/4,0);
995 glScalef(screenwidth,screenheight/4,1);
996 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
999 glColor4f(dialogueboxcolor[whichdialogue][indialogue][0],dialogueboxcolor[whichdialogue][indialogue][1],dialogueboxcolor[whichdialogue][indialogue][2],0.7);
1001 glVertex3f(0, 0, 0.0f);
1002 glVertex3f(1, 0, 0.0f);
1003 glVertex3f(1, 1, 0.0f);
1004 glVertex3f(0, 1, 0.0f);
1006 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1007 glPopMatrix(); // Restore The Old Projection Matrix
1008 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1009 glPopMatrix(); // Restore The Old Projection Matrix
1010 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1011 glEnable(GL_CULL_FACE);
1012 glDisable(GL_BLEND);
1014 glEnable(GL_TEXTURE_2D);
1021 startx=screenwidth*1/5;
1022 if(dialogueboxlocation[whichdialogue][indialogue]==1)starty=screenheight/16+screenheight*4/5;
1023 if(dialogueboxlocation[whichdialogue][indialogue]==2)starty=screenheight*1/5-screenheight/16;
1032 for(i=0;i<(int)strlen(dialoguename[whichdialogue][indialogue]);i++){
1033 tempname[tempnum]=dialoguename[whichdialogue][indialogue][i];
1035 if(dialoguename[whichdialogue][indialogue][i]=='#'||dialoguename[whichdialogue][indialogue][i]=='\0')goodchar=0;
1039 tempname[tempnum]='\0';
1042 sprintf (string, "%s: ", tempname);
1044 if(dialogueboxcolor[whichdialogue][indialogue][0]+dialogueboxcolor[whichdialogue][indialogue][1]+dialogueboxcolor[whichdialogue][indialogue][2]<1.5){
1045 glColor4f(0,0,0,tutorialopac);
1046 text.glPrintOutline(startx-2*7.6*strlen(string)*screenwidth/1024-4,starty-4,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight);
1047 glColor4f(0.7,0.7,0.7,tutorialopac);
1048 text.glPrint(startx-2*7.6*strlen(string)*screenwidth/1024,starty,string,1,1.5*screenwidth/1024,screenwidth,screenheight);
1052 glColor4f(0,0,0,tutorialopac);
1053 text.glPrintOutline(startx-2*7.6*strlen(string)*screenwidth/1024-4,starty-4,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight);
1057 for(i=0;i<(int)strlen(dialoguetext[whichdialogue][indialogue])+1;i++){
1058 tempname[tempnum]=dialoguetext[whichdialogue][indialogue][i];
1059 if(dialoguetext[whichdialogue][indialogue][i]!='#')tempnum++;
1062 sprintf (string, "%s", tempname);
1069 if(string[i]=='\n'||string[i]>'z'||string[i]<' '||string[i]=='\0'){
1070 if(dialogueboxcolor[whichdialogue][indialogue][0]+dialogueboxcolor[whichdialogue][indialogue][1]+dialogueboxcolor[whichdialogue][indialogue][2]<1.5){
1071 glColor4f(0,0,0,tutorialopac);
1072 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);
1073 glColor4f(1,1,1,tutorialopac);
1074 text.glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/,starty-20*screenwidth/1024*line,string,1,1.5*screenwidth/1024,screenwidth,screenheight,lastline,i);
1078 glColor4f(0,0,0,tutorialopac);
1079 text.glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/,starty-20*screenwidth/1024*line,string,1,1.5*screenwidth/1024,screenwidth,screenheight,lastline,i);
1083 if(string[i]=='\0')done=1;
1090 if(!tutoriallevel&&!winfreeze&&indialogue==-1&&!mainmenu){
1093 sprintf (string, "Score: %d", (int)accountactive->getCampaignScore());
1095 sprintf (string, "Score: %d", (int)accountactive->getCampaignScore()+(int)bonustotal);
1097 if(!campaign)sprintf (string, "Score: %d", (int)bonustotal);
1099 text.glPrintOutline(1024/40-4,768/16-4+768*14/16,string,1,1.5*1.25,1024,768);
1101 text.glPrint(1024/40,768/16+768*14/16,string,1,1.5,1024,768);
1103 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1104 glDisable(GL_CULL_FACE);
1105 glDisable(GL_LIGHTING);
1106 glDisable(GL_TEXTURE_2D);
1108 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1109 glPushMatrix(); // Store The Projection Matrix
1110 glLoadIdentity(); // Reset The Projection Matrix
1111 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1112 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1113 glPushMatrix(); // Store The Modelview Matrix
1114 glLoadIdentity(); // Reset The Modelview Matrix
1115 glTranslatef(15,screenheight*17.5/20,0);
1116 glScalef(screenwidth/3+20,screenheight/20,1);
1117 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1119 glColor4f(0.0,0.4,0.0,0.7);
1120 float bar=((float)player[0].damage)/player[0].damagetolerance;
1122 glVertex3f((bar<1?bar:1),0,0.0f);
1123 glVertex3f(1,0,0.0f);
1124 glVertex3f(1,1,0.0f);
1125 glVertex3f((bar<1?bar:1),1,0.0f);
1127 glColor4f(0.1,0.0,0.0,1);
1128 bar = ((float)player[0].bloodloss)/player[0].damagetolerance;
1130 glVertex3f(0,0,0.0f);
1131 glVertex3f((bar<1?bar:1),0,0.0f);
1132 glVertex3f((bar<1?bar:1),1,0.0f);
1133 glVertex3f(0,1,0.0f);
1135 glColor4f(0.4,0.0,0.0,0.7);
1136 bar = ((float)player[0].damage)/player[0].damagetolerance;
1138 glVertex3f(0,0,0.0f);
1139 glVertex3f((bar<1?bar:1),0,0.0f);
1140 glVertex3f((bar<1?bar:1),1,0.0f);
1141 glVertex3f(0,1,0.0f);
1143 glColor4f(0.4,0.0,0.0,0.7);
1144 bar = ((float)player[0].permanentdamage)/player[0].damagetolerance;
1146 glVertex3f(0,0,0.0f);
1147 glVertex3f((bar<1?bar:1),0,0.0f);
1148 glVertex3f((bar<1?bar:1),1,0.0f);
1149 glVertex3f(0,1,0.0f);
1151 glColor4f(0.4,0.0,0.0,0.7);
1152 bar = ((float)player[0].superpermanentdamage)/player[0].damagetolerance;
1154 glVertex3f(0,0,0.0f);
1155 glVertex3f((bar<1?bar:1),0,0.0f);
1156 glVertex3f((bar<1?bar:1),1,0.0f);
1157 glVertex3f(0,1,0.0f);
1159 glColor4f(0.0,0.0,0.0,0.7);
1161 glBegin(GL_LINE_STRIP);
1162 glVertex3f(0,0,0.0f);
1163 glVertex3f(1,0,0.0f);
1164 glVertex3f(1,1,0.0f);
1165 glVertex3f(0,1,0.0f);
1166 glVertex3f(0,0,0.0f);
1169 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1170 glPopMatrix(); // Restore The Old Projection Matrix
1171 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1172 glPopMatrix(); // Restore The Old Projection Matrix
1173 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1174 glEnable(GL_CULL_FACE);
1175 glDisable(GL_BLEND);
1177 glEnable(GL_TEXTURE_2D);
1179 // writing the numbers :
1180 sprintf (string, "Damages : %d/%d (%d)",(int)(player[0].damage),(int)(player[0].damagetolerance),(int)(player[0].bloodloss));
1182 text.glPrintOutline(1024/40-4,768/16-4+768*14/16-40,string,1,1.5*1.25,1024,768);
1184 text.glPrint(1024/40,768/16+768*14/16-40,string,1,1.5,1024,768);
1188 glColor4f(.5,.5,.5,1);
1191 if((texttoggle||editorenabled)&&debugmode&&!mainmenu){
1192 sprintf (string, "The framespersecond is %d.",(int)(fps));
1193 text.glPrint(10,30,string,0,.8,1024,768);
1195 sprintf (string, "Name: %s", registrationname);
1196 text.glPrint(10,260,string,0,.8,1024,768);
1200 sprintf (string, "Map editor enabled.");
1202 sprintf (string, "Map editor disabled.");
1203 text.glPrint(10,60,string,0,.8,1024,768);
1205 sprintf (string, "Object size: %f",editorsize);
1206 text.glPrint(10,75,string,0,.8,1024,768);
1207 if(editorrotation>=0)sprintf (string, "Object rotation: %f",editorrotation);
1208 else sprintf (string, "Object rotation: Random");
1209 text.glPrint(10,90,string,0,.8,1024,768);
1210 if(editorrotation2>=0)sprintf (string, "Object rotation2: %f",editorrotation2);
1211 else sprintf (string, "Object rotation2: Random");
1212 text.glPrint(10,105,string,0,.8,1024,768);
1213 sprintf (string, "Object type: %d",editortype);
1214 text.glPrint(10,120,string,0,.8,1024,768);
1215 switch(editortype) {
1217 sprintf (string, "(box)");
1220 sprintf (string, "(tree)");
1223 sprintf (string, "(wall)");
1226 sprintf (string, "(weird)");
1229 sprintf (string, "(spike)");
1232 sprintf (string, "(rock)");
1235 sprintf (string, "(bush)");
1238 sprintf (string, "(tunnel)");
1241 sprintf (string, "(chimney)");
1244 sprintf (string, "(platform)");
1247 sprintf (string, "(cool)");
1250 sprintf (string, "(fire)");
1253 text.glPrint(130,120,string,0,.8,1024,768);
1255 sprintf (string, "Numplayers: %d",numplayers);
1256 text.glPrint(10,155,string,0,.8,1024,768);
1257 sprintf (string, "Player %d: numwaypoints: %d",numplayers,player[numplayers-1].numwaypoints);
1258 text.glPrint(10,140,string,0,.8,1024,768);
1260 sprintf (string, "Difficulty: %d",difficulty);
1261 text.glPrint(10,240,string,0,.8,1024,768);
1266 if(drawmode==glowmode){
1267 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1268 glDisable(GL_CULL_FACE);
1269 glDisable(GL_LIGHTING);
1270 glDisable(GL_TEXTURE_2D);
1272 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1273 glPushMatrix(); // Store The Projection Matrix
1274 glLoadIdentity(); // Reset The Projection Matrix
1275 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1276 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1277 glPushMatrix(); // Store The Modelview Matrix
1278 glLoadIdentity(); // Reset The Modelview Matrix
1279 glScalef(screenwidth,screenheight,1);
1280 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1282 glColor4f(0,0,0,.5);
1284 glVertex3f(0, 0, 0.0f);
1285 glVertex3f(256, 0, 0.0f);
1286 glVertex3f(256, 256, 0.0f);
1287 glVertex3f(0, 256, 0.0f);
1289 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1290 glPopMatrix(); // Restore The Old Projection Matrix
1291 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1292 glPopMatrix(); // Restore The Old Projection Matrix
1293 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1294 glEnable(GL_CULL_FACE);
1295 glDisable(GL_BLEND);
1299 if((((blackout&&damageeffects)||(player[0].bloodloss>0&&damageeffects&&player[0].blooddimamount>0)||player[0].dead)&&!cameramode)||console){
1300 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1301 glDisable(GL_CULL_FACE);
1302 glDisable(GL_LIGHTING);
1303 glDisable(GL_TEXTURE_2D);
1305 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1306 glPushMatrix(); // Store The Projection Matrix
1307 glLoadIdentity(); // Reset The Projection Matrix
1308 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1309 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1310 glPushMatrix(); // Store The Modelview Matrix
1311 glLoadIdentity(); // Reset The Modelview Matrix
1312 glScalef(screenwidth,screenheight,1);
1313 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1315 if(player[0].dead)blackout+=multiplier*3;
1316 if(player[0].dead==1)blackout=.4f;
1317 if(player[0].dead==2&&blackout>.6)blackout=.6;
1318 glColor4f(0,0,0,blackout);
1319 if(!player[0].dead){
1320 if((player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5))*.3<.3){
1321 glColor4f(0,0,0,player[0].blooddimamount*player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5)*.3);
1322 blackout=player[0].blooddimamount*player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5)*.3;
1325 glColor4f(0,0,0,player[0].blooddimamount*.3);
1326 blackout=player[0].blooddimamount*.3;
1329 if(console)glColor4f(.7,0,0,.2);
1331 glVertex3f(0, 0, 0.0f);
1332 glVertex3f(256, 0, 0.0f);
1333 glVertex3f(256, 256, 0.0f);
1334 glVertex3f(0, 256, 0.0f);
1336 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1337 glPopMatrix(); // Restore The Old Projection Matrix
1338 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1339 glPopMatrix(); // Restore The Old Projection Matrix
1340 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1341 glEnable(GL_CULL_FACE);
1342 glDisable(GL_BLEND);
1346 if(flashamount>0&&damageeffects){
1347 if(flashamount>1)flashamount=1;
1348 if(flashdelay<=0)flashamount-=multiplier;
1350 if(flashamount<0)flashamount=0;
1351 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1352 glDisable(GL_CULL_FACE);
1353 glDisable(GL_LIGHTING);
1355 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1356 glPushMatrix(); // Store The Projection Matrix
1357 glLoadIdentity(); // Reset The Projection Matrix
1358 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1359 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1360 glPushMatrix(); // Store The Modelview Matrix
1361 glLoadIdentity(); // Reset The Modelview Matrix
1362 glScalef(screenwidth,screenheight,1);
1363 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1365 glColor4f(flashr,flashg,flashb,flashamount);
1367 glVertex3f(0, 0, 0.0f);
1368 glVertex3f(256, 0, 0.0f);
1369 glVertex3f(256, 256, 0.0f);
1370 glVertex3f(0, 256, 0.0f);
1372 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1373 glPopMatrix(); // Restore The Old Projection Matrix
1374 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1375 glPopMatrix(); // Restore The Old Projection Matrix
1376 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1377 glEnable(GL_CULL_FACE);
1378 glDisable(GL_BLEND);
1384 glEnable(GL_TEXTURE_2D);
1387 sprintf (string, " ]");
1388 text.glPrint(10,30+screenheight-330,string,0,1,screenwidth,screenheight);
1390 sprintf (string, "_");
1391 text.glPrint(30+(float)(displayselected)*10,30+(screenheight-330),string,0,1,screenwidth,screenheight);
1395 if((i!=0||chatting)&&displaytime[i]<4)
1396 for(j=0;j<displaychars[i];j++){
1397 glColor4f(1,1,1,4-displaytime[i]);
1398 if(j<displaychars[i]){
1399 sprintf (string, "%c",displaytext[i][j]);
1400 text.glPrint(30+j*10,30+i*20+(screenheight-330),string,0,1,screenwidth,screenheight);
1406 if(minimap&&indialogue==-1){
1407 float mapviewdist = 20000;
1409 glDisable(GL_DEPTH_TEST);
1410 glColor3f (1.0, 1.0, 1.0); // no coloring
1412 glEnable(GL_TEXTURE_2D);
1413 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1414 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1415 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1416 glDisable(GL_CULL_FACE);
1417 glDisable(GL_LIGHTING);
1419 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1420 glPushMatrix(); // Store The Projection Matrix
1421 glLoadIdentity(); // Reset The Projection Matrix
1422 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1423 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1424 glPushMatrix(); // Store The Modelview Matrix
1425 glLoadIdentity(); // Reset The Modelview Matrix
1426 glScalef((float)screenwidth/2,(float)screenwidth/2,1);
1427 glTranslatef(1.75,.25,0);
1428 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1436 int numliveplayers=0;
1438 for(i=0;i<numplayers;i++){
1439 if(!player[i].dead) numliveplayers++;
1444 for(i=0;i<objects.numobjects;i++){
1445 if(objects.type[i]==treetrunktype||objects.type[i]==boxtype){
1446 center+=objects.position[i];
1450 for(i=0;i<numplayers;i++){
1451 if(!player[i].dead)center+=player[i].coords;
1453 center/=numadd+numliveplayers;
1455 center=player[0].coords;
1457 float maxdistance=0;
1460 for(i=0;i<objects.numobjects;i++){
1461 tempdist=findDistancefast(¢er,&objects.position[i]);
1462 if(tempdist>maxdistance){
1464 maxdistance=tempdist;
1467 for(i=0;i<numplayers;i++){
1468 if(!player[i].dead){
1469 tempdist=findDistancefast(¢er,&player[i].coords);
1470 if(tempdist>maxdistance){
1472 maxdistance=tempdist;
1476 radius=fast_sqrt(maxdistance);
1480 glScalef(.25/radius*256*terrain.scale*.4,.25/radius*256*terrain.scale*.4,1);
1482 glScalef(1/(1/radius*256*terrain.scale*.4),1/(1/radius*256*terrain.scale*.4),1);
1484 glRotatef(player[0].lookrotation*-1+180,0,0,1);
1485 glTranslatef(-(center.x/terrain.scale/256*-2+1),(center.z/terrain.scale/256*-2+1),0);
1486 for(i=0;i<objects.numobjects;i++){
1487 if(objects.type[i]==treetrunktype){
1488 distcheck=findDistancefast(&player[0].coords,&objects.position[i]);
1489 if(distcheck<mapviewdist){
1490 glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
1491 glColor4f(0,.3,0,opac*(1-distcheck/mapviewdist));
1493 glTranslatef(objects.position[i].x/terrain.scale/256*-2+1,objects.position[i].z/terrain.scale/256*2-1,0);
1494 glRotatef(objects.rotation[i],0,0,1);
1495 glScalef(.003,.003,.003);
1498 glVertex3f(-1, -1, 0.0f);
1500 glVertex3f(1, -1, 0.0f);
1502 glVertex3f(1, 1, 0.0f);
1504 glVertex3f(-1, 1, 0.0f);
1509 if(objects.type[i]==boxtype){
1510 distcheck=findDistancefast(&player[0].coords,&objects.position[i]);
1511 if(distcheck<mapviewdist){
1512 glBindTexture( GL_TEXTURE_2D, Mapboxtexture);
1513 glColor4f(.4,.4,.4,opac*(1-distcheck/mapviewdist));
1515 glTranslatef(objects.position[i].x/terrain.scale/256*-2+1,objects.position[i].z/terrain.scale/256*2-1,0);
1516 glRotatef(objects.rotation[i],0,0,1);
1517 glScalef(.01*objects.scale[i],.01*objects.scale[i],.01*objects.scale[i]);
1520 glVertex3f(-1, -1, 0.0f);
1522 glVertex3f(1, -1, 0.0f);
1524 glVertex3f(1, 1, 0.0f);
1526 glVertex3f(-1, 1, 0.0f);
1533 glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
1534 for(i=0;i<numboundaries;i++){
1535 glColor4f(0,0,0,opac/3);
1537 glTranslatef(boundary[i].x/terrain.scale/256*-2+1,boundary[i].z/terrain.scale/256*2-1,0);
1538 glScalef(.002,.002,.002);
1541 glVertex3f(-1, -1, 0.0f);
1543 glVertex3f(1, -1, 0.0f);
1545 glVertex3f(1, 1, 0.0f);
1547 glVertex3f(-1, 1, 0.0f);
1552 for(i=0;i<numplayers;i++){
1553 distcheck=findDistancefast(&player[0].coords,&player[i].coords);
1554 if(distcheck<mapviewdist){
1556 glBindTexture( GL_TEXTURE_2D, Maparrowtexture);
1557 if(i==0)glColor4f(1,1,1,opac);
1558 else if(player[i].dead==2||player[i].howactive>typesleeping)glColor4f(0,0,0,opac*(1-distcheck/mapviewdist));
1559 else if(player[i].dead)glColor4f(.3,.3,.3,opac*(1-distcheck/mapviewdist));
1560 else if(player[i].aitype==attacktypecutoff)glColor4f(1,0,0,opac*(1-distcheck/mapviewdist));
1561 else if(player[i].aitype==passivetype)glColor4f(0,1,0,opac*(1-distcheck/mapviewdist));
1562 else glColor4f(1,1,0,1);
1563 glTranslatef(player[i].coords.x/terrain.scale/256*-2+1,player[i].coords.z/terrain.scale/256*2-1,0);
1564 glRotatef(player[i].rotation+180,0,0,1);
1565 glScalef(.005,.005,.005);
1568 glVertex3f(-1, -1, 0.0f);
1570 glVertex3f(1, -1, 0.0f);
1572 glVertex3f(1, 1, 0.0f);
1574 glVertex3f(-1, 1, 0.0f);
1580 glDisable(GL_TEXTURE_2D);
1581 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1582 glPopMatrix(); // Restore The Old Projection Matrix
1583 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1584 glPopMatrix(); // Restore The Old Projection Matrix
1585 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1586 glEnable(GL_CULL_FACE);
1587 glDisable(GL_BLEND);
1591 if(loading&&!stealthloading&&(!campaign||player[0].dead)){
1592 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1593 glDisable(GL_CULL_FACE);
1594 glDisable(GL_LIGHTING);
1595 glDisable(GL_TEXTURE_2D);
1597 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1598 glPushMatrix(); // Store The Projection Matrix
1599 glLoadIdentity(); // Reset The Projection Matrix
1600 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1601 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1602 glPushMatrix(); // Store The Modelview Matrix
1603 glLoadIdentity(); // Reset The Modelview Matrix
1604 glScalef(screenwidth,screenheight,1);
1605 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1607 glColor4f(0,0,0,.7);
1609 glVertex3f(0, 0, 0.0f);
1610 glVertex3f(256, 0, 0.0f);
1611 glVertex3f(256, 256, 0.0f);
1612 glVertex3f(0, 256, 0.0f);
1614 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1615 glPopMatrix(); // Restore The Old Projection Matrix
1616 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1617 glPopMatrix(); // Restore The Old Projection Matrix
1618 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1619 glEnable(GL_CULL_FACE);
1620 glDisable(GL_BLEND);
1624 glDisable(GL_DEPTH_TEST);
1625 glColor3f (1.0, 1.0, 1.0); // no coloring
1627 glEnable(GL_TEXTURE_2D);
1632 glEnable(GL_TEXTURE_2D);
1634 sprintf (string, "Loading...");
1635 text.glPrint(1024/2-90,768/2,string,1,2,1024,768);
1638 //if(ismotionblur)drawmode=motionblurmode;
1639 drawmode=normalmode;
1642 if(winfreeze&&!campaign){
1643 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1644 glDisable(GL_CULL_FACE);
1645 glDisable(GL_LIGHTING);
1646 glDisable(GL_TEXTURE_2D);
1648 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1649 glPushMatrix(); // Store The Projection Matrix
1650 glLoadIdentity(); // Reset The Projection Matrix
1651 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1652 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1653 glPushMatrix(); // Store The Modelview Matrix
1654 glLoadIdentity(); // Reset The Modelview Matrix
1655 glScalef(screenwidth,screenheight,1);
1656 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1658 glColor4f(0,0,0,.4);
1660 glVertex3f(0, 0, 0.0f);
1661 glVertex3f(256, 0, 0.0f);
1662 glVertex3f(256, 256, 0.0f);
1663 glVertex3f(0, 256, 0.0f);
1665 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1666 glPopMatrix(); // Restore The Old Projection Matrix
1667 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1668 glPopMatrix(); // Restore The Old Projection Matrix
1669 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1670 glEnable(GL_CULL_FACE);
1671 glDisable(GL_BLEND);
1675 glDisable(GL_DEPTH_TEST);
1676 glColor3f (1.0, 1.0, 1.0); // no coloring
1678 glEnable(GL_TEXTURE_2D);
1680 //Win Screen Won Victory
1682 glEnable(GL_TEXTURE_2D);
1684 sprintf (string, "Level Cleared!");
1685 text.glPrintOutlined(1024/2-strlen(string)*10,768*7/8,string,1,2,1024,768);
1687 sprintf (string, "Score: %d",(int)(bonustotal-startbonustotal));
1688 text.glPrintOutlined(1024/30,768*6/8,string,1,2,1024,768);
1691 sprintf (string, "Press Escape or Space to continue");
1693 sprintf (string, "Press Escape to return to menu or Space to continue");
1694 text.glPrintOutlined(640/2-strlen(string)*5,480*1/16,string,1,1,640,480);
1698 for(i=0;i<255;i++)string[i]='\0';
1699 sprintf (temp, "Time: %d:",(int)(((int)leveltime-(int)(leveltime)%60)/60));
1700 strcat(string,temp);
1701 if((int)(leveltime)%60<10)strcat(string,"0");
1702 sprintf (temp, "%d",(int)(leveltime)%60);
1703 strcat(string,temp);
1704 text.glPrintOutlined(1024/30,768*6/8-40,string,1,2,1024,768);
1707 int awards[award_count];
1708 int numawards = award_awards(awards);
1710 for (i = 0; i < numawards && i < 6; i++)
1711 text.glPrintOutlined(1024/30,768*6/8-90-40*i,award_names[awards[i]],1,2,1024,768);
1714 if(drawmode!=normalmode){
1715 glEnable(GL_TEXTURE_2D);
1717 if(!drawtoggle||drawmode!=realmotionblurmode||(drawtoggle==2||change==1)){
1720 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
1721 GLfloat subtractColor[4] = { 0.5, 0.5, 0.5, 0.0 };
1722 glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, subtractColor);
1723 //glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_SUBTRACT);
1724 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE);
1725 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_CONSTANT_EXT);
1726 glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 2.0f);
1728 glBindTexture( GL_TEXTURE_2D, screentexture);
1729 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1732 if((drawtoggle||change==1)&&drawmode==realmotionblurmode){
1734 glBindTexture( GL_TEXTURE_2D, screentexture2);
1735 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1737 if(!screentexture2){
1738 glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
1740 glGenTextures( 1, &screentexture2 );
1741 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
1743 glEnable(GL_TEXTURE_2D);
1744 glBindTexture( GL_TEXTURE_2D, screentexture2);
1745 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
1746 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
1748 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
1754 glClear(GL_DEPTH_BUFFER_BIT);
1755 ReSizeGLScene(90,.1f);
1756 glViewport(0,0,screenwidth,screenheight);
1758 if(drawmode!=normalmode){
1759 glDisable(GL_DEPTH_TEST);
1760 if(drawmode==motionblurmode){
1761 glDrawBuffer(GL_FRONT);
1762 glReadBuffer(GL_BACK);
1764 glColor3f (1.0, 1.0, 1.0); // no coloring
1766 glEnable(GL_TEXTURE_2D);
1767 glBindTexture( GL_TEXTURE_2D, screentexture);
1768 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1769 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1770 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1771 glDisable(GL_CULL_FACE);
1772 glDisable(GL_LIGHTING);
1774 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1775 glPushMatrix(); // Store The Projection Matrix
1776 glLoadIdentity(); // Reset The Projection Matrix
1777 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1778 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1779 glPushMatrix(); // Store The Modelview Matrix
1780 glLoadIdentity(); // Reset The Modelview Matrix
1781 glScalef((float)screenwidth/2,(float)screenheight/2,1);
1782 glTranslatef(1,1,0);
1783 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1785 if(drawmode==motionblurmode){
1786 if(motionbluramount<.2)motionbluramount=.2;
1787 //glColor4f(1,1,1,fast_sqrt(multiplier)*2.9*motionbluramount);
1788 glColor4f(1,1,1,motionbluramount);
1792 glVertex3f(-1, -1, 0.0f);
1793 glTexCoord2f(texcoordwidth,0);
1794 glVertex3f(1, -1, 0.0f);
1795 glTexCoord2f(texcoordwidth,texcoordheight);
1796 glVertex3f(1, 1, 0.0f);
1797 glTexCoord2f(0,texcoordheight);
1798 glVertex3f(-1, 1, 0.0f);
1802 if(drawmode==realmotionblurmode){
1803 glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
1804 glClear(GL_COLOR_BUFFER_BIT);
1805 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
1806 glBindTexture( GL_TEXTURE_2D, screentexture);
1807 glColor4f(1,1,1,.5);
1811 glVertex3f(-1, -1, 0.0f);
1812 glTexCoord2f(texcoordwidth,0);
1813 glVertex3f(1, -1, 0.0f);
1814 glTexCoord2f(texcoordwidth,texcoordheight);
1815 glVertex3f(1, 1, 0.0f);
1816 glTexCoord2f(0,texcoordheight);
1817 glVertex3f(-1, 1, 0.0f);
1820 glBindTexture( GL_TEXTURE_2D, screentexture2);
1821 glColor4f(1,1,1,.5);
1825 glVertex3f(-1, -1, 0.0f);
1826 glTexCoord2f(texcoordwidth,0);
1827 glVertex3f(1, -1, 0.0f);
1828 glTexCoord2f(texcoordwidth,texcoordheight);
1829 glVertex3f(1, 1, 0.0f);
1830 glTexCoord2f(0,texcoordheight);
1831 glVertex3f(-1, 1, 0.0f);
1834 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1836 if(drawmode==doublevisionmode){
1837 static float crosseyedness;
1838 crosseyedness=abs(player[0].damage-player[0].superpermanentdamage-(player[0].damagetolerance-player[0].superpermanentdamage)*1/2)/30;
1839 if(crosseyedness>1)crosseyedness=1;
1840 if(crosseyedness<0)crosseyedness=0;
1842 glDisable(GL_BLEND);
1847 glVertex3f(-1, -1, 0.0f);
1848 glTexCoord2f(texcoordwidth,0);
1849 glVertex3f(1, -1, 0.0f);
1850 glTexCoord2f(texcoordwidth,texcoordheight);
1851 glVertex3f(1, 1, 0.0f);
1852 glTexCoord2f(0,texcoordheight);
1853 glVertex3f(-1, 1, 0.0f);
1857 glColor4f(1,1,1,.5);
1860 glTranslatef(.015*crosseyedness,0,0);
1864 glVertex3f(-1, -1, 0.0f);
1865 glTexCoord2f(texcoordwidth,0);
1866 glVertex3f(1, -1, 0.0f);
1867 glTexCoord2f(texcoordwidth,texcoordheight);
1868 glVertex3f(1, 1, 0.0f);
1869 glTexCoord2f(0,texcoordheight);
1870 glVertex3f(-1, 1, 0.0f);
1875 if(drawmode==glowmode){
1876 glColor4f(.5,.5,.5,.5);
1878 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
1880 glTranslatef(.01,0,0);
1883 glVertex3f(-1, -1, 0.0f);
1884 glTexCoord2f(texcoordwidth,0);
1885 glVertex3f(1, -1, 0.0f);
1886 glTexCoord2f(texcoordwidth,texcoordheight);
1887 glVertex3f(1, 1, 0.0f);
1888 glTexCoord2f(0,texcoordheight);
1889 glVertex3f(-1, 1, 0.0f);
1893 glTranslatef(-.01,0,0);
1896 glVertex3f(-1, -1, 0.0f);
1897 glTexCoord2f(texcoordwidth,0);
1898 glVertex3f(1, -1, 0.0f);
1899 glTexCoord2f(texcoordwidth,texcoordheight);
1900 glVertex3f(1, 1, 0.0f);
1901 glTexCoord2f(0,texcoordheight);
1902 glVertex3f(-1, 1, 0.0f);
1906 glTranslatef(.0,.01,0);
1909 glVertex3f(-1, -1, 0.0f);
1910 glTexCoord2f(texcoordwidth,0);
1911 glVertex3f(1, -1, 0.0f);
1912 glTexCoord2f(texcoordwidth,texcoordheight);
1913 glVertex3f(1, 1, 0.0f);
1914 glTexCoord2f(0,texcoordheight);
1915 glVertex3f(-1, 1, 0.0f);
1919 glTranslatef(0,-.01,0);
1922 glVertex3f(-1, -1, 0.0f);
1923 glTexCoord2f(texcoordwidth,0);
1924 glVertex3f(1, -1, 0.0f);
1925 glTexCoord2f(texcoordwidth,texcoordheight);
1926 glVertex3f(1, 1, 0.0f);
1927 glTexCoord2f(0,texcoordheight);
1928 glVertex3f(-1, 1, 0.0f);
1932 if(drawmode==radialzoommode){
1934 //glRotatef((float)i*.1,0,0,1);
1935 glColor4f(1,1,1,1/((float)i+1));
1937 glScalef(1+(float)i*.01,1+(float)i*.01,1);
1940 glVertex3f(-1, -1, 0.0f);
1941 glTexCoord2f(texcoordwidth,0);
1942 glVertex3f(1, -1, 0.0f);
1943 glTexCoord2f(texcoordwidth,texcoordheight);
1944 glVertex3f(1, 1, 0.0f);
1945 glTexCoord2f(0,texcoordheight);
1946 glVertex3f(-1, 1, 0.0f);
1951 glDisable(GL_TEXTURE_2D);
1952 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1953 glPopMatrix(); // Restore The Old Projection Matrix
1954 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1955 glPopMatrix(); // Restore The Old Projection Matrix
1956 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1957 glEnable(GL_CULL_FACE);
1958 glDisable(GL_BLEND);
1963 glEnable(GL_TEXTURE_2D);
1966 if(consoleselected>=60)
1967 offset=consoleselected-60;
1968 sprintf (string, " ]");
1969 text.glPrint(10,30,string,0,1,1024,768);
1971 sprintf (string, "_");
1972 text.glPrint(30+(float)(consoleselected)*10-offset*10,30,string,0,1,1024,768);
1975 for(j=0;j<consolechars[i];j++){
1976 glColor4f(1,1,1,1-(float)(i)/16);
1977 if(j<consolechars[i]){
1978 sprintf (string, "%c",consoletext[i][j]);
1979 text.glPrint(30+j*10-offset*10,30+i*20,string,0,1,1024,768);
1986 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)||(mainmenu&&gameon)||(!gameon&&gamestarted)||(!gameon&&gamestarted)){
1987 multiplier=tempmult;
1992 // !!! FIXME: hack: clamp framerate in menu so text input works correctly on fast systems.
1995 glDrawBuffer(GL_BACK);
1996 glReadBuffer(GL_BACK);
1997 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
1998 ReSizeGLScene(90,.1f);
2001 temptexdetail=texdetail;
2002 if(texdetail>2)texdetail=2;
2003 if(mainmenu!=oldmainmenu&&oldmainmenu!=0){
2005 LoadTexture(":Data:Textures:Newgame.png",&Mainmenuitems[1],0,0);
2006 LoadTexture(":Data:Textures:Quit.png",&Mainmenuitems[3],0,0);
2009 LoadTexture(":Data:Textures:Resume.png",&Mainmenuitems[1],0,0);
2010 LoadTexture(":Data:Textures:Endgame.png",&Mainmenuitems[3],0,0);
2013 if(lastcheck>.5||oldmainmenu!=mainmenu){
2015 ifstream ipstream(ConvertFileName(":Data:Campaigns:main.txt"));
2016 ipstream.ignore(256,':');
2017 ipstream >> campaignnumlevels;
2018 for(i=0;i<campaignnumlevels;i++){
2019 ipstream.ignore(256,':');
2020 ipstream.ignore(256,':');
2021 ipstream.ignore(256,' ');
2022 ipstream >> campaignmapname[i];
2023 ipstream.ignore(256,':');
2024 ipstream >> campaigndescription[i];
2026 if(campaigndescription[i][j]=='_')campaigndescription[i][j]=' ';
2028 ipstream.ignore(256,':');
2029 ipstream >> campaignchoosenext[i];
2030 ipstream.ignore(256,':');
2031 ipstream >> campaignnumnext[i];
2032 for(j=0;j<campaignnumnext[i];j++){
2033 ipstream.ignore(256,':');
2034 ipstream >> campaignnextlevel[i][j];
2035 campaignnextlevel[i][j]-=1;
2037 ipstream.ignore(256,':');
2038 ipstream >> campaignlocationx[i];
2039 ipstream.ignore(256,':');
2040 ipstream >> campaignlocationy[i];
2044 for(i=0;i<campaignnumlevels;i++){
2046 levelhighlight[i]=0;
2051 for(i=0;i<accountactive->getCampaignChoicesMade();i++){
2052 levelorder[i+1]=campaignnextlevel[levelorder[i]][accountactive->getCampaignChoice(i)];
2053 levelvisible[levelorder[i+1]]=1;
2055 int whichlevelstart = accountactive->getCampaignChoicesMade()-1;
2056 if(whichlevelstart<0){
2057 accountactive->setCampaignScore(0);
2058 accountactive->resetFasttime();
2059 campaignchoicenum=1;
2060 campaignchoicewhich[0]=0;
2064 campaignchoicenum=campaignnumnext[levelorder[whichlevelstart]];
2065 for(i=0;i<campaignchoicenum;i++){
2066 campaignchoicewhich[i]=campaignnextlevel[levelorder[whichlevelstart]][i];
2067 levelvisible[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
2068 levelhighlight[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
2077 texdetail=temptexdetail;
2079 oldmainmenu=mainmenu;
2081 if(mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==8||mainmenu==9||mainmenu==10||mainmenu==119||mainmenu==18){
2082 glClear(GL_DEPTH_BUFFER_BIT);
2083 glEnable(GL_ALPHA_TEST);
2084 glAlphaFunc(GL_GREATER, 0.001f);
2085 glEnable(GL_TEXTURE_2D);
2086 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
2087 glDisable(GL_CULL_FACE);
2088 glDisable(GL_LIGHTING);
2090 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2091 glPushMatrix(); // Store The Projection Matrix
2092 glLoadIdentity(); // Reset The Projection Matrix
2093 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
2094 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2095 glPushMatrix(); // Store The Modelview Matrix
2096 glLoadIdentity(); // Reset The Modelview Matrix
2097 glTranslatef(screenwidth/2,screenheight/2,0);
2099 glScalef((float)screenwidth/2,(float)screenheight/2,1);
2100 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
2101 glDisable(GL_BLEND);
2102 glColor4f(0,0,0,1.0);
2103 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2104 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2105 glDisable(GL_TEXTURE_2D);
2107 //glScalef(.25,.25,.25);
2110 glVertex3f(-1, -1, 0.0f);
2112 glVertex3f(1, -1, 0.0f);
2114 glVertex3f(1, 1, 0.0f);
2116 glVertex3f(-1, 1, 0.0f);
2120 glColor4f(0.4,0.4,0.4,1.0);
2121 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2122 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2123 glEnable(GL_TEXTURE_2D);
2124 glBindTexture( GL_TEXTURE_2D, Mainmenuitems[4]);
2126 //glScalef(.25,.25,.25);
2129 glVertex3f(-1, -1, 0.0f);
2131 glVertex3f(1, -1, 0.0f);
2133 glVertex3f(1, 1, 0.0f);
2135 glVertex3f(-1, 1, 0.0f);
2140 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2142 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2146 if((float)newscreenwidth>(float)newscreenheight*1.61||(float)newscreenwidth<(float)newscreenheight*1.59)sprintf (menustring[0], "Resolution: %d*%d",(int)newscreenwidth,(int)newscreenheight);
2147 else sprintf (menustring[0], "Resolution: %d*%d (widescreen)",(int)newscreenwidth,(int)newscreenheight);
2150 endx[0]=startx[0]+strlen(menustring[0])*10;
2151 endy[0]=starty[0]+20;
2155 if(newdetail==2)sprintf (menustring[1], "Detail: High");
2156 else if(newdetail==1)sprintf (menustring[1], "Detail: Medium");
2157 else sprintf (menustring[1], "Detail: Low");
2160 endx[1]=startx[1]+strlen(menustring[1])*10;
2161 endy[1]=starty[1]+20;
2165 if(bloodtoggle==2)sprintf (menustring[2], "Blood: On, high detail (slower)");
2166 if(bloodtoggle==1)sprintf (menustring[2], "Blood: On, low detail");
2167 if(bloodtoggle==0)sprintf (menustring[2], "Blood: Off");
2170 endx[2]=startx[2]+strlen(menustring[2])*10;
2171 endy[2]=starty[2]+20;
2175 if(difficulty==2)sprintf (menustring[3], "Difficulty: Insane");
2176 if(difficulty==1)sprintf (menustring[3], "Difficulty: Difficult");
2177 if(difficulty==0)sprintf (menustring[3], "Difficulty: Easier");
2178 startx[3]=10+20-1000;
2180 endx[3]=startx[3]+strlen(menustring[3])*10;
2181 endy[3]=starty[3]+20;
2185 if(ismotionblur==1)sprintf (menustring[4], "Blur Effects: Enabled (less compatible)");
2186 if(ismotionblur==0)sprintf (menustring[4], "Blur Effects: Disabled (more compatible)");
2189 endx[4]=startx[4]+strlen(menustring[4])*10;
2190 endy[4]=starty[4]+20;
2194 if(decals==1)sprintf (menustring[5], "Decals: Enabled (slower)");
2195 if(decals==0)sprintf (menustring[5], "Decals: Disabled");
2198 endx[5]=startx[5]+strlen(menustring[5])*10;
2199 endy[5]=starty[5]+20;
2203 if(musictoggle==1)sprintf (menustring[6], "Music: Enabled");
2204 if(musictoggle==0)sprintf (menustring[6], "Music: Disabled");
2207 endx[6]=startx[6]+strlen(menustring[6])*10;
2208 endy[6]=starty[6]+20;
2212 if(invertmouse==1)sprintf (menustring[9], "Invert mouse: Yes");
2213 if(invertmouse==0)sprintf (menustring[9], "Invert mouse: No");
2216 endx[9]=startx[9]+strlen(menustring[9])*10;
2217 endy[9]=starty[9]+20;
2221 sprintf (menustring[10], "Mouse Speed: %d", (int)(usermousesensitivity*5));
2224 endx[10]=startx[10]+strlen(menustring[10])*10;
2225 endy[10]=starty[10]+20;
2229 sprintf (menustring[11], "Volume: %d%%", (int)(volume*100));
2232 endx[11]=startx[11]+strlen(menustring[11])*10;
2233 endy[11]=starty[11]+20;
2237 sprintf (menustring[13], "Damage Bar: %s",(showdamagebar?"on":"off"));
2240 endx[13]=startx[13]+strlen(menustring[13])*10;
2241 endy[13]=starty[13]+20;
2245 sprintf (menustring[7], "-Configure Controls-");
2248 endx[7]=startx[7]+strlen(menustring[7])*10;
2249 endy[7]=starty[7]+20;
2253 sprintf (menustring[12], "-Configure Stereo -");
2256 endx[12]=startx[12]+strlen(menustring[7])*10;
2257 endy[12]=starty[12]+20;
2261 if(newdetail==detail&&newscreenheight==(int)screenheight&&newscreenwidth==(int)screenwidth)sprintf (menustring[8], "Back");
2262 else sprintf (menustring[8], "Back (some changes take effect next time Lugaru is opened)");
2264 endx[8]=startx[8]+strlen(menustring[8])*10;
2266 endy[8]=starty[8]+20;
2273 if(keyselect!=0)sprintf (menustring[0], "Forwards: %s",Input::keyToChar(forwardkey));
2274 else sprintf (menustring[0], "Forwards: _");
2277 endx[0]=startx[0]+strlen(menustring[0])*10;
2278 endy[0]=starty[0]+20;
2282 if(keyselect!=1)sprintf (menustring[1], "Back: %s",Input::keyToChar(backkey));
2283 else sprintf (menustring[1], "Back: _");
2286 endx[1]=startx[1]+strlen(menustring[1])*10;
2287 endy[1]=starty[1]+20;
2291 if(keyselect!=2)sprintf (menustring[2], "Left: %s",Input::keyToChar(leftkey));
2292 else sprintf (menustring[2], "Left: _");
2295 endx[2]=startx[2]+strlen(menustring[2])*10;
2296 endy[2]=starty[2]+20;
2300 if(keyselect!=3)sprintf (menustring[3], "Right: %s",Input::keyToChar(rightkey));
2301 else sprintf (menustring[3], "Right: _");
2304 endx[3]=startx[3]+strlen(menustring[3])*10;
2305 endy[3]=starty[3]+20;
2309 if(keyselect!=4)sprintf (menustring[4], "Crouch: %s",Input::keyToChar(crouchkey));
2310 else sprintf (menustring[4], "Crouch: _");
2313 endx[4]=startx[4]+strlen(menustring[4])*10;
2314 endy[4]=starty[4]+20;
2318 if(keyselect!=5)sprintf (menustring[5], "Jump: %s",Input::keyToChar(jumpkey));
2319 else sprintf (menustring[5], "Jump: _");
2322 endx[5]=startx[5]+strlen(menustring[5])*10;
2323 endy[5]=starty[5]+20;
2327 if(keyselect!=6)sprintf (menustring[6], "Draw: %s",Input::keyToChar(drawkey));
2328 else sprintf (menustring[6], "Draw: _");
2331 endx[6]=startx[6]+strlen(menustring[6])*10;
2332 endy[6]=starty[6]+20;
2336 if(keyselect!=7)sprintf (menustring[7], "Throw: %s",Input::keyToChar(throwkey));
2337 else sprintf (menustring[7], "Throw: _");
2340 endx[7]=startx[7]+strlen(menustring[7])*10;
2341 endy[7]=starty[7]+20;
2345 if(keyselect!=8)sprintf (menustring[8], "Attack: %s",Input::keyToChar(attackkey));
2346 else sprintf (menustring[8], "Attack: _");
2349 endx[8]=startx[8]+strlen(menustring[8])*10;
2350 endy[8]=starty[8]+20;
2356 sprintf (menustring[9], "Back");
2358 endx[9]=startx[9]+strlen(menustring[9])*10;
2360 endy[9]=starty[9]+20;
2365 nummenuitems=7+accountactive->getCampaignChoicesMade()+campaignchoicenum;
2367 sprintf (menustring[0], "%s",accountactive->getName());
2370 endx[0]=startx[0]+strlen(menustring[0])*10;
2371 endy[0]=starty[0]+20;
2375 sprintf (menustring[1], "Tutorial");
2378 endx[1]=startx[1]+strlen(menustring[1])*10;
2379 endy[1]=starty[1]+20;
2383 sprintf (menustring[2], "Challenge");
2386 endx[2]=startx[2]+strlen(menustring[2])*10;
2387 endy[2]=starty[2]+20;
2391 sprintf (menustring[3], "Delete User");
2394 endx[3]=startx[3]+strlen(menustring[3])*10;
2395 endy[3]=starty[3]+20;
2399 sprintf (menustring[4], "Main Menu");
2402 endx[4]=startx[4]+strlen(menustring[4])*10;
2403 endy[4]=starty[4]+20;
2407 sprintf (menustring[5], "Change User");
2409 endx[5]=startx[5]+strlen(menustring[5])*10;
2411 endy[5]=starty[5]+20;
2417 sprintf (menustring[6], "World");
2419 starty[6]=30+480-400-50;
2420 endx[6]=startx[6]+400;
2425 if(accountactive->getCampaignChoicesMade())
2426 for(i=0;i<accountactive->getCampaignChoicesMade();i++){
2427 sprintf (menustring[7+i], "%s", campaigndescription[levelorder[i]]);
2428 startx[7+i]=30+120+campaignlocationx[levelorder[i]]*400/512;
2429 starty[7+i]=30+30+(512-campaignlocationy[levelorder[i]])*400/512;
2430 endx[7+i]=startx[7+i]+10;
2431 endy[7+i]=starty[7+i]+10;
2436 if(campaignchoicenum>0)
2437 for(i=accountactive->getCampaignChoicesMade();i<accountactive->getCampaignChoicesMade()+campaignchoicenum;i++){
2438 sprintf (menustring[7+i], "%s", campaigndescription[levelorder[i]]);
2439 startx[7+i]=30+120+campaignlocationx[campaignchoicewhich[i-(accountactive->getCampaignChoicesMade())]]*400/512;
2440 starty[7+i]=30+30+(512-campaignlocationy[campaignchoicewhich[i-(accountactive->getCampaignChoicesMade())]])*400/512;
2441 endx[7+i]=startx[7+i]+10;
2442 endy[7+i]=starty[7+i]+10;
2447 /*sprintf (menustring[7], "Dot");
2448 startx[7]=120+260*400/512;
2449 starty[7]=30+(512-184)*400/512;
2450 endx[7]=startx[7]+10;
2451 endy[7]=starty[7]+10;
2455 sprintf (menustring[8], "Dot");
2456 startx[8]=120+129*400/512;
2457 starty[8]=30+(512-284)*400/512;
2458 endx[8]=startx[8]+10;
2459 endy[8]=starty[8]+10;
2463 sprintf (menustring[9], "Dot");
2464 startx[9]=120+358*400/512;
2465 starty[9]=30+(512-235)*400/512;
2466 endx[9]=startx[9]+10;
2467 endy[9]=starty[9]+10;
2471 sprintf (menustring[10], "Dot");
2472 startx[10]=120+359*400/512;
2473 starty[10]=30+(512-308)*400/512;
2474 endx[10]=startx[10]+10;
2475 endy[10]=starty[10]+10;
2479 sprintf (menustring[11], "Dot");
2480 startx[11]=120+288*400/512;
2481 starty[11]=30+(512-277)*400/512;
2482 endx[11]=startx[11]+10;
2483 endy[11]=starty[11]+10;
2491 sprintf (menustring[0], "Are you sure you want to delete this user?");
2494 endx[0]=startx[0]+strlen(menustring[0])*10;
2495 endy[0]=starty[0]+20;
2499 sprintf (menustring[1], "Yes");
2502 endx[1]=startx[1]+strlen(menustring[1])*10;
2503 endy[1]=starty[1]+20;
2507 sprintf (menustring[2], "No");
2510 endx[2]=startx[2]+strlen(menustring[2])*10;
2511 endy[2]=starty[2]+20;
2515 sprintf (menustring[3], "Extra 4");
2518 endx[3]=startx[3]+strlen(menustring[3])*10;
2519 endy[3]=starty[3]+20;
2523 sprintf (menustring[4], "Extra 5");
2526 endx[4]=startx[4]+strlen(menustring[4])*10;
2527 endy[4]=starty[4]+20;
2531 sprintf (menustring[5], "Back");
2533 endx[5]=startx[5]+strlen(menustring[5])*10;
2535 endy[5]=starty[5]+20;
2541 nummenuitems=Account::getNbAccounts()+2;
2545 if(Account::getNbAccounts()<8)
2546 sprintf (menustring[0], "New User");
2548 sprintf (menustring[0], "No More Users");
2551 endx[0]=startx[0]+strlen(menustring[0])*10;
2552 endy[0]=starty[0]+20;
2561 for(i=0;i<Account::getNbAccounts();i++){
2562 sprintf (menustring[num], "%s",Account::get(i)->getName());
2564 starty[num]=360-20-20*num;
2565 endx[num]=startx[num]+strlen(menustring[num])*10;
2566 endy[num]=starty[num]+20;
2573 sprintf (menustring[num], "Back");
2575 endx[num]=startx[num]+strlen(menustring[num])*10;
2577 endy[num]=starty[num]+20;
2584 sprintf (menustring[0], "Easier");
2587 endx[0]=startx[0]+strlen(menustring[0])*10;
2588 endy[0]=starty[0]+20;
2592 sprintf (menustring[1], "Difficult");
2595 endx[1]=startx[1]+strlen(menustring[1])*10;
2596 endy[1]=starty[1]+20;
2600 sprintf (menustring[2], "Insane");
2603 endx[2]=startx[2]+strlen(menustring[2])*10;
2604 endy[2]=starty[2]+20;
2610 //tempncl=numchallengelevels;
2611 //numchallengelevels=9;
2612 nummenuitems=2+numchallengelevels;
2615 for(j=0;j<numchallengelevels;j++){
2616 for(i=0;i<255;i++)menustring[j][i]='\0';
2617 sprintf (temp, "Level %d",j+1);
2618 strcpy(menustring[j],temp);
2619 for(i=0;i<17;i++)if(menustring[j][i]=='\0')menustring[j][i]=' ';
2620 menustring[j][17]='\0';
2621 sprintf (temp, "%d",(int)accountactive->getHighScore(j));
2622 strcat(menustring[j],temp);
2623 for(i=18;i<32;i++)if(menustring[j][i]=='\0')menustring[j][i]=' ';
2624 menustring[j][32]='\0';
2625 sprintf (temp, "%d:",(int)(((int)accountactive->getFastTime(j)-(int)(accountactive->getFastTime(j))%60)/60));
2626 strcat(menustring[j],temp);
2627 if((int)(accountactive->getFastTime(j))%60<10)strcat(menustring[j],"0");
2628 sprintf (temp, "%d",(int)(accountactive->getFastTime(j))%60);
2629 strcat(menustring[j],temp);
2633 endx[j]=startx[j]+strlen(menustring[j])*10;
2634 endy[j]=starty[j]+20;
2639 sprintf (menustring[numchallengelevels], "Back");
2640 startx[numchallengelevels]=10;
2641 endx[numchallengelevels]=startx[numchallengelevels]+strlen(menustring[numchallengelevels])*10;
2642 starty[numchallengelevels]=10;
2643 endy[numchallengelevels]=starty[numchallengelevels]+20;
2644 movex[numchallengelevels]=0;
2645 movey[numchallengelevels]=0;
2647 sprintf (menustring[numchallengelevels+1], " High Score Best Time");
2648 startx[numchallengelevels+1]=10;
2649 starty[numchallengelevels+1]=440;
2650 endx[numchallengelevels+1]=startx[numchallengelevels+1]+strlen(menustring[numchallengelevels+1])*10;
2651 endy[numchallengelevels+1]=starty[numchallengelevels+1]+20;
2652 movex[numchallengelevels+1]=0;
2653 movey[numchallengelevels+1]=0;
2655 //numchallengelevels=tempncl;
2662 sprintf (menustring[0], "Congratulations!");
2665 endx[0]=startx[0]+strlen(menustring[0])*10;
2666 endy[0]=starty[0]+20;
2670 sprintf (menustring[1], "You have avenged your family and");
2673 endx[1]=startx[1]+strlen(menustring[1])*10;
2674 endy[1]=starty[1]+20;
2678 sprintf (menustring[2], "restored peace to the island of Lugaru.");
2681 endx[2]=startx[2]+strlen(menustring[2])*10;
2682 endy[2]=starty[2]+20;
2686 sprintf (menustring[3], "Back");
2688 endx[3]=startx[3]+strlen(menustring[3])*10;
2690 endy[3]=starty[3]+20;
2694 for(i=0;i<255;i++)menustring[4][i]='\0';
2695 sprintf (temp, "Your score:");
2696 strcpy(menustring[4],temp);
2697 for(i=0;i<20;i++)if(menustring[4][i]=='\0')menustring[4][i]=' ';
2698 menustring[4][20]='\0';
2699 sprintf (temp, "%d",(int)accountactive->getCampaignScore());
2700 strcat(menustring[4],temp);
2702 endx[4]=startx[4]+strlen(menustring[4])*10;
2704 endy[4]=starty[4]+20;
2708 for(i=0;i<255;i++)menustring[5][i]='\0';
2709 sprintf (temp, "Your time:");
2710 strcpy(menustring[5],temp);
2711 for(i=0;i<20;i++)if(menustring[5][i]=='\0')menustring[5][i]=' ';
2712 menustring[5][20]='\0';
2713 sprintf (temp, "%d",(int)accountcampaigntime[accountactive]);
2714 strcat(menustring[5],temp);
2716 endx[5]=startx[5]+strlen(menustring[5])*10;
2718 endy[5]=starty[5]+20;
2722 for(i=0;i<255;i++)menustring[5][i]='\0';
2723 sprintf (temp, "Highest score:");
2724 strcpy(menustring[5],temp);
2725 for(i=0;i<20;i++)if(menustring[5][i]=='\0')menustring[5][i]=' ';
2726 menustring[5][20]='\0';
2727 sprintf (temp, "%d",(int)accountactive->getCampaignHighScore());
2728 strcat(menustring[5],temp);
2730 endx[5]=startx[5]+strlen(menustring[5])*10;
2732 endy[5]=starty[5]+20;
2736 for(i=0;i<255;i++)menustring[7][i]='\0';
2737 sprintf (temp, "Lowest time:");
2738 strcpy(menustring[7],temp);
2739 for(i=0;i<20;i++)if(menustring[7][i]=='\0')menustring[7][i]=' ';
2740 menustring[7][20]='\0';
2741 sprintf (temp, "%d",(int)accountactive->getCampaignFasttime());
2742 strcat(menustring[7],temp);
2744 endx[7]=startx[7]+strlen(menustring[7])*10;
2746 endy[7]=starty[7]+20;
2752 sprintf (menustring[0], "Stereo mode: %s", StereoModeName(newstereomode));
2755 endx[0]=startx[0]+strlen(menustring[0])*10;
2756 endy[0]=starty[0]+20;
2760 sprintf (menustring[1], "Stereo separation: %.3f", stereoseparation);
2763 endx[1]=startx[1]+strlen(menustring[1])*10;
2764 endy[1]=starty[1]+20;
2768 sprintf (menustring[2], "Reverse stereo: %s", stereoreverse ? "Yes" : "No");
2771 endx[2]=startx[2]+strlen(menustring[2])*10;
2772 endy[2]=starty[2]+20;
2776 sprintf (menustring[3], "Back");
2778 endx[3]=startx[3]+strlen(menustring[3])*10;
2780 endy[3]=starty[3]+20;
2786 if(mainmenu==1||mainmenu==2){
2796 starty[1]=480-152-32;
2803 starty[2]=480-228-32;
2811 starty[3]=480-306-32;
2820 starty[3]=480-306-32;
2834 starty[4]=480-140-256;
2841 starty[5]=480-138-256;
2848 starty[6]=480-144-256;
2856 starty[4]=480-140-256;
2863 starty[5]=480-138-256;
2870 starty[6]=480-144-256;
2878 starty[4]=480-140-256;
2885 starty[5]=480-150-256;
2892 starty[6]=480-144-256;
2900 starty[4]=480-140-256;
2907 starty[5]=480-150-256;
2914 starty[6]=480-144-256;
2922 starty[4]=480-100-256;
2929 starty[5]=480-120-256;
2936 starty[6]=480-144-256;
2946 if(mainmenu==1||mainmenu==2)
2948 if((mousecoordh/screenwidth*640)>startx[i]&&(mousecoordh/screenwidth*640)<endx[i]&&480-(mousecoordv/screenheight*480)>starty[i]&&480-(mousecoordv/screenheight*480)<endy[i]){
2953 if(mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==8||mainmenu==9||mainmenu==10||mainmenu==18)
2954 for(i=0;i<nummenuitems;i++){
2955 if((mousecoordh/screenwidth*640)>startx[i]&&(mousecoordh/screenwidth*640)<endx[i]&&480-(mousecoordv/screenheight*480)>starty[i]&&480-(mousecoordv/screenheight*480)<endy[i]){
2956 if(mainmenu!=5)selected=i;
2957 if(mainmenu==5&&(i!=0&&i!=6))selected=i;
2958 if(mainmenu==9&&(i!=numchallengelevels+1))selected=i; // seem useless, if mainmenu==9 then mainmenu!=5, so selected==i.
2962 for(i=0;i<nummenuitems;i++){
2964 selectedlong[i]+=multiplier*5;
2965 if(selectedlong[i]>1) selectedlong[i]=1;
2967 selectedlong[i]-=multiplier*5;
2968 if(selectedlong[i]<0) selectedlong[i]=0;
2970 offsetx[i]=(startx[i]+endx[i])/2-(mousecoordh/screenwidth*640);
2971 offsety[i]=(starty[i]+endy[i])/2-(480-(mousecoordv/screenheight*480));
2976 if(i>=4&&(mainmenu==1||mainmenu==2)){
2978 offsetx[i]=(startx[i]+endx[i]+movex[i]*transition)/2-(640+190)/2;
2979 offsety[i]=(starty[i]+endy[i]+movey[i]*transition)/2-(336+150)/2;
2985 if(mainmenu==1||mainmenu==2){
2986 glClear(GL_DEPTH_BUFFER_BIT);
2987 glEnable(GL_ALPHA_TEST);
2988 glAlphaFunc(GL_GREATER, 0.001f);
2989 glEnable(GL_TEXTURE_2D);
2990 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
2991 glDisable(GL_CULL_FACE);
2992 glDisable(GL_LIGHTING);
2994 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2995 glPushMatrix(); // Store The Projection Matrix
2996 glLoadIdentity(); // Reset The Projection Matrix
2997 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
2998 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2999 glPushMatrix(); // Store The Modelview Matrix
3000 glLoadIdentity(); // Reset The Modelview Matrix
3001 glTranslatef(screenwidth/2,screenheight/2,0);
3003 glScalef((float)screenwidth/2,(float)screenheight/2,1);
3004 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3005 glDisable(GL_BLEND);
3006 glColor4f(0,0,0,1.0);
3007 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
3008 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
3009 glDisable(GL_TEXTURE_2D);
3011 //glScalef(.25,.25,.25);
3014 glVertex3f(-1, -1, 0.0f);
3016 glVertex3f(1, -1, 0.0f);
3018 glVertex3f(1, 1, 0.0f);
3020 glVertex3f(-1, 1, 0.0f);
3024 glColor4f(0.4,0.4,0.4,1.0);
3025 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
3026 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
3027 glEnable(GL_TEXTURE_2D);
3028 glBindTexture( GL_TEXTURE_2D, Mainmenuitems[4]);
3030 //glScalef(.25,.25,.25);
3033 glVertex3f(-1, -1, 0.0f);
3035 glVertex3f(1, -1, 0.0f);
3037 glVertex3f(1, 1, 0.0f);
3039 glVertex3f(-1, 1, 0.0f);
3044 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3047 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3048 glPushMatrix(); // Store The Projection Matrix
3049 glLoadIdentity(); // Reset The Projection Matrix
3050 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3051 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3052 glPushMatrix(); // Store The Modelview Matrix
3053 glLoadIdentity(); // Reset The Modelview Matrix
3055 glDisable(GL_TEXTURE_2D);
3059 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3061 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3065 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3066 glPushMatrix(); // Store The Projection Matrix
3067 glLoadIdentity(); // Reset The Projection Matrix
3068 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3069 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3070 glPushMatrix(); // Store The Modelview Matrix
3071 glLoadIdentity(); // Reset The Modelview Matrix
3072 glEnable(GL_TEXTURE_2D);
3073 for(j=0;j<nummenuitems;j++)
3075 if(j<=3||(mainmenu!=1&&mainmenu!=2))
3077 //glDisable(GL_BLEND);
3078 glEnable(GL_ALPHA_TEST);
3080 //glDisable(GL_ALPHA_TEST);
3081 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3082 if(mainmenu==1||mainmenu==2)
3085 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3086 glBindTexture( GL_TEXTURE_2D, Mainmenuitems[j]);
3087 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
3088 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
3089 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3093 glVertex3f(startx[j]+movex[j]*transition, starty[j]+movey[j]*transition, 0.0f);
3095 glVertex3f(endx[j]+movex[j]*transition, starty[j]+movey[j]*transition, 0.0f);
3097 glVertex3f(endx[j]+movex[j]*transition, endy[j]+movey[j]*transition, 0.0f);
3099 glVertex3f(startx[j]+movex[j]*transition, endy[j]+movey[j]*transition, 0.0f);
3103 //glDisable(GL_ALPHA_TEST);
3104 if(j<4)glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3107 if(1-((float)i)/10-(1-selectedlong[j])>0)
3109 glColor4f(1,1,1,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3110 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3114 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);
3116 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);
3118 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);
3120 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);
3126 if(mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==8||mainmenu==9||mainmenu==10||mainmenu==18)
3128 if(mainmenu!=5||j<6)
3131 if(mainmenu==9&&j>accountactive->getProgress()&&j<numchallengelevels)glColor4f(0.5,0,0,1);
3132 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3134 if(mainmenu!=7||j!=0||!entername)
3135 text.glPrint(startx[j],starty[j],menustring[j],0,1,640,480);
3139 sprintf (string, "_");
3140 text.glPrint(startx[j]+(float)(displayselected)*10,starty[j],string,0,1,640,480);
3142 for(l=0;l<displaychars[0];l++){
3143 sprintf (string, "%c",displaytext[0][l]);
3144 text.glPrint(startx[j]+l*10,starty[j],string,0,1,640,480);
3149 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3152 if(1-((float)i)/15-(1-selectedlong[j])>0)
3154 glColor4f(1,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3155 if(mainmenu==9&&j>accountactive->getProgress()&&j<numchallengelevels)glColor4f(0.5,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3156 if(mainmenu==11&&j>accountactive->getProgress()&&j<numchallengelevels)glColor4f(0.5,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3157 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);
3158 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);
3159 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);
3160 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);
3161 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);
3162 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);
3163 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);
3164 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);
3165 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);
3171 glClear(GL_DEPTH_BUFFER_BIT);
3172 glEnable(GL_ALPHA_TEST);
3173 glAlphaFunc(GL_GREATER, 0.001f);
3174 glEnable(GL_TEXTURE_2D);
3175 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3176 glDisable(GL_CULL_FACE);
3177 glDisable(GL_LIGHTING);
3178 if(j==6)glColor4f(1,1,1,1);
3179 else glColor4f(1,0,0,1);
3181 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3182 glPushMatrix(); // Store The Projection Matrix
3183 glLoadIdentity(); // Reset The Projection Matrix
3184 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3185 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3186 glPushMatrix(); // Store The Modelview Matrix
3187 glLoadIdentity(); // Reset The Modelview Matrix
3190 //Draw world, draw map
3191 glTranslatef(2,-5,0);
3193 if(j>6&&j<nummenuitems-1)
3195 XYZ linestart,lineend,offset;
3202 //float linestartx,lineendx,linestarty,lineendy,offsetx,offsety;
3203 linestart.x=(startx[j]+endx[j])/2;
3204 linestart.y=(starty[j]+endy[j])/2;
3205 if(j>=6+accountactive->getCampaignChoicesMade()){
3206 linestart.x=(startx[6+accountactive->getCampaignChoicesMade()]+endx[6+accountactive->getCampaignChoicesMade()])/2;
3207 linestart.y=(starty[6+accountactive->getCampaignChoicesMade()]+endy[6+accountactive->getCampaignChoicesMade()])/2;
3209 lineend.x=(startx[j+1]+endx[j+1])/2;
3210 lineend.y=(starty[j+1]+endy[j+1])/2;
3211 offset=lineend-linestart;
3214 offset=DoRotation(offset,0,0,90);
3216 glDisable(GL_TEXTURE_2D);
3218 if(j<6+accountactive->getCampaignChoicesMade()){
3219 glColor4f(0.5,0,0,1);
3227 linestart+=fac*4*startsize;
3228 lineend-=fac*4*endsize;
3230 if(!(j>7+accountactive->getCampaignChoicesMade()+campaignchoicenum)){
3231 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3235 glVertex3f(linestart.x-offset.x*startsize, linestart.y-offset.y*startsize, 0.0f);
3237 glVertex3f(linestart.x+offset.x*startsize, linestart.y+offset.y*startsize, 0.0f);
3239 glVertex3f(lineend.x+offset.x*endsize, lineend.y+offset.y*endsize, 0.0f);
3241 glVertex3f(lineend.x-offset.x*endsize, lineend.y-offset.y*endsize, 0.0f);
3245 glEnable(GL_TEXTURE_2D);
3249 if(j==6)glBindTexture( GL_TEXTURE_2D, Mainmenuitems[7]);
3250 else glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
3251 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
3252 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
3253 if(j-7<accountactive->getCampaignChoicesMade())glColor4f(0.5,0,0,1);
3254 if(j-7>=accountactive->getCampaignChoicesMade())glColor4f(1,0,0,1);
3255 if(j==6)glColor4f(1,1,1,1);
3258 itemsize=abs(startx[j]-endx[j])/2;
3260 midpoint.x=(startx[j]+endx[j])/2;
3261 midpoint.y=(starty[j]+endy[j])/2;
3262 if(j>6&&(j-7<accountactive->getCampaignChoicesMade()))itemsize*=.5;
3263 if(!(j-7>accountactive->getCampaignChoicesMade()+campaignchoicenum))
3265 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3269 glVertex3f(midpoint.x-itemsize+movex[j]*transition, midpoint.y-itemsize+movey[j]*transition, 0.0f);
3271 glVertex3f(midpoint.x+itemsize+movex[j]*transition, midpoint.y-itemsize+movey[j]*transition, 0.0f);
3273 glVertex3f(midpoint.x+itemsize+movex[j]*transition, midpoint.y+itemsize+movey[j]*transition, 0.0f);
3275 glVertex3f(midpoint.x-itemsize+movex[j]*transition, midpoint.y+itemsize+movey[j]*transition, 0.0f);
3279 //glDisable(GL_ALPHA_TEST);
3280 if(j<4)glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3283 if(1-((float)i)/10-(1-selectedlong[j])>0)
3285 glColor4f(1,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3286 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3290 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);
3292 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);
3294 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);
3296 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);
3304 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3306 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3308 if(j-7>=accountactive->getCampaignChoicesMade()){
3309 text.glPrintOutlined(0.9,0,0,startx[j]+10,starty[j]-4,menustring[j],0,0.6,640,480);
3310 glDisable(GL_DEPTH_TEST);
3316 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3318 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3321 if(mainmenu==1||mainmenu==2)
3322 if(transition<.1||transition>.9){
3323 glClear(GL_DEPTH_BUFFER_BIT);
3324 glEnable(GL_ALPHA_TEST);
3325 glAlphaFunc(GL_GREATER, 0.001f);
3326 glEnable(GL_TEXTURE_2D);
3327 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3328 glDisable(GL_CULL_FACE);
3329 glDisable(GL_LIGHTING);
3331 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3332 glPushMatrix(); // Store The Projection Matrix
3333 glLoadIdentity(); // Reset The Projection Matrix
3334 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3335 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3336 glPushMatrix(); // Store The Modelview Matrix
3337 glLoadIdentity(); // Reset The Modelview Matrix
3339 glDisable(GL_TEXTURE_2D);
3341 glColor4f(1,0,0,1-(transition*10));
3343 glColor4f(1,0,0,1-((1-transition)*10));
3346 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3350 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3351 glPushMatrix(); // Store The Projection Matrix
3352 glLoadIdentity(); // Reset The Projection Matrix
3353 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
3354 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3355 glPushMatrix(); // Store The Modelview Matrix
3356 glLoadIdentity(); // Reset The Modelview Matrix
3357 glTranslatef(screenwidth/2,screenheight/2,0);
3359 glScalef((float)screenwidth/2,(float)screenheight/2,1);
3360 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3362 glEnable(GL_TEXTURE_2D);
3364 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
3365 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
3367 if(!waiting) { // hide the cursor while waiting for a key
3369 glTranslatef(mousecoordh-screenwidth/2,mousecoordv*-1+screenheight/2,0);
3370 glScalef((float)screenwidth/64,(float)screenwidth/64,1);
3371 glTranslatef(1,-1,0);
3372 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3374 glBindTexture( GL_TEXTURE_2D, cursortexture);
3376 //glScalef(.25,.25,.25);
3379 glVertex3f(-1, -1, 0.0f);
3381 glVertex3f(1, -1, 0.0f);
3383 glVertex3f(1, 1, 0.0f);
3385 glVertex3f(-1, 1, 0.0f);
3391 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3397 //printf("Flash amount: %f, delay %i\n", flashamount, flashdelay);
3398 if(flashamount>1)flashamount=1;
3399 if(flashdelay<=0)flashamount-=multiplier;
3401 if(flashamount<0)flashamount=0;
3402 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3403 glDisable(GL_CULL_FACE);
3404 glDisable(GL_LIGHTING);
3405 glDisable(GL_TEXTURE_2D);
3407 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3408 glPushMatrix(); // Store The Projection Matrix
3409 glLoadIdentity(); // Reset The Projection Matrix
3410 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
3411 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3412 glPushMatrix(); // Store The Modelview Matrix
3413 glLoadIdentity(); // Reset The Modelview Matrix
3414 glScalef(screenwidth,screenheight,1);
3415 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3417 glColor4f(flashr,flashg,flashb,flashamount);
3419 glVertex3f(0, 0, 0.0f);
3420 glVertex3f(256, 0, 0.0f);
3421 glVertex3f(256, 256, 0.0f);
3422 glVertex3f(0, 256, 0.0f);
3424 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3425 glPopMatrix(); // Restore The Old Projection Matrix
3426 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3427 glPopMatrix(); // Restore The Old Projection Matrix
3428 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
3429 glEnable(GL_CULL_FACE);
3430 glDisable(GL_BLEND);
3435 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)||(!gameon&&gamestarted)){
3436 tempmult=multiplier;
3441 if ( side == stereoRight || side == stereoCenter ) {
3442 if(drawmode!=motionblurmode||mainmenu){
3447 //myassert(glGetError() == GL_NO_ERROR);
3448 glDrawBuffer(GL_BACK);
3449 glReadBuffer(GL_BACK);
3454 if(drawtoggle==2)drawtoggle=0;
3456 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)){
3457 multiplier=tempmult;
3459 //Jordan fixed your warning!