2 Copyright (C) 2003, 2010 - Wolfire Games
4 This file is part of Lugaru.
6 Lugaru is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; either version 2
9 of the License, or (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 See the GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 #include "openal_wrapper.h"
30 extern int environment;
31 extern float texscale;
33 extern Terrain terrain;
34 //extern Sprites sprites;
35 extern float multiplier;
37 extern float viewdistance;
38 extern float fadestart;
39 extern float screenwidth,screenheight;
40 extern int kTextureSize;
41 extern FRUSTUM frustum;
43 extern Objects objects;
45 extern float usermousesensitivity;
47 extern float camerashake;
49 extern float slomodelay;
50 extern bool ismotionblur;
52 extern float blackout;
53 extern bool damageeffects;
55 extern bool texttoggle;
56 extern float blurness;
57 extern float targetblurness;
58 extern float playerdist;
59 extern bool cellophane;
61 extern float flashamount,flashr,flashg,flashb;
62 extern int flashdelay;
64 extern float motionbluramount;
66 extern bool alwaysblur;
68 extern bool tilt2weird;
69 extern bool tiltweird;
71 extern bool proportionweird;
72 extern bool vertexweird[6];
73 extern bool velocityblur;
74 extern bool debugmode;
76 extern int oldmainmenu;
77 extern int bloodtoggle;
78 extern int difficulty;
81 //extern int texdetail;
82 extern float texdetail;
83 extern bool musictoggle;
84 extern int tutoriallevel;
85 extern float smoketex;
86 extern float tutorialstagetime;
87 extern float tutorialmaxtime;
88 extern int tutorialstage;
89 extern bool againbonus;
90 extern float damagedealt;
91 extern bool invertmouse;
93 extern int numhotspots;
94 extern int winhotspot;
95 extern int killhotspot;
96 extern XYZ hotspot[40];
97 extern int hotspottype[40];
98 extern float hotspotsize[40];
99 extern char hotspottext[40][256];
100 extern int currenthotspot;;
102 extern bool campaign;
103 extern bool winfreeze;
105 extern float menupulse;
107 extern bool gamestart;
109 extern int numdialogues;
110 extern int numdialogueboxes[max_dialogues];
111 extern int dialoguetype[max_dialogues];
112 extern int dialogueboxlocation[max_dialogues][max_dialoguelength];
113 extern float dialogueboxcolor[max_dialogues][max_dialoguelength][3];
114 extern int dialogueboxsound[max_dialogues][max_dialoguelength];
115 extern char dialoguetext[max_dialogues][max_dialoguelength][128];
116 extern char dialoguename[max_dialogues][max_dialoguelength][64];
117 extern XYZ dialoguecamera[max_dialogues][max_dialoguelength];
118 extern XYZ participantlocation[max_dialogues][10];
119 extern int participantfocus[max_dialogues][max_dialoguelength];
120 extern int participantaction[max_dialogues][max_dialoguelength];
121 extern float participantrotation[max_dialogues][10];
122 extern XYZ participantfacing[max_dialogues][max_dialoguelength][10];
123 extern float dialoguecamerarotation[max_dialogues][max_dialoguelength];
124 extern float dialoguecamerarotation2[max_dialogues][max_dialoguelength];
125 extern int indialogue;
126 extern int whichdialogue;
127 extern int directing;
128 extern float dialoguetime;
129 extern int dialoguegonethrough[20];
131 extern bool gamestarted;
133 extern bool showdamagebar;
135 extern int channels[100];
137 void Game::flash() { // shouldn't be that way, these should be attributes and Person class should not change rendering.
144 /*********************> DrawGLScene() <*****/
145 int Game::DrawGLScene(StereoSide side)
147 static float texcoordwidth,texcoordheight;
148 static float texviewwidth, texviewheight;
150 static GLubyte color;
151 static float newbrightness;
152 static float changespeed;
153 static XYZ checkpoint;
154 static float tempmult;
156 static char string[256]="";
157 static char string2[256]="";
158 static char string3[256]="";
160 static float lastcheck;
162 lastcheck+=multiplier;
164 if ( stereomode == stereoAnaglyph ) {
166 case stereoLeft: glColorMask( 0.0, 1.0, 1.0, 1.0 ); break;
167 case stereoRight: glColorMask( 1.0, 0.0, 0.0, 1.0 ); break;
170 glColorMask( 1.0, 1.0, 1.0, 1.0 );
172 if ( stereomode == stereoHorizontalInterlaced || stereomode == stereoVerticalInterlaced ) {
173 glStencilFunc(side == stereoLeft ? GL_NOTEQUAL : GL_EQUAL, 0x01, 0x01);
177 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)){
184 numboundaries=mapradius*2;
185 if(numboundaries>360)numboundaries=360;
186 for(i=0;i<numboundaries;i++){
189 boundary[i]=mapcenter+DoRotation(boundary[i]*mapradius,0,i*(360/((float)(numboundaries))),0);
198 olddrawmode=drawmode;
199 if(ismotionblur&&!loading){
200 if((findLengthfast(&player[0].velocity)>200)&&velocityblur&&!cameramode){
201 drawmode=motionblurmode;
202 motionbluramount=200/(findLengthfast(&player[0].velocity));
205 if(player[0].damage-player[0].superpermanentdamage>(player[0].damagetolerance-player[0].superpermanentdamage)*1/2&&damageeffects&&!cameramode){
206 drawmode=doublevisionmode;
213 drawmode=motionblurmode;
215 slomodelay-=multiplier;
216 if(slomodelay<0)slomo=0;
220 if((!changed&&!slomo)||loading){
222 if(ismotionblur&&(/*fps>100||*/alwaysblur)){
223 if(olddrawmode!=realmotionblurmode)change=1;
225 drawmode=realmotionblurmode;
227 else if(olddrawmode==realmotionblurmode)change=2;
231 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted))drawmode=normalmode;
232 if((freeze||winfreeze)&&ismotionblur&&!mainmenu)drawmode=radialzoommode;
234 if(winfreeze||mainmenu)drawmode=normalmode;
237 if(drawmode==glowmode){
242 DSpContext_FadeGamma(NULL,200,&color2);
246 if(drawtoggle!=2)drawtoggle=1-drawtoggle;
250 texviewwidth=kTextureSize;
251 if(texviewwidth>screenwidth)texviewwidth=screenwidth;
252 texviewheight=kTextureSize;
253 if(texviewheight>screenheight)texviewheight=screenheight;
255 texcoordwidth=screenwidth/kTextureSize;
256 texcoordheight=screenheight/kTextureSize;
257 if(texcoordwidth>1)texcoordwidth=1;
258 if(texcoordheight>1)texcoordheight=1;
261 glDrawBuffer(GL_BACK);
262 glReadBuffer(GL_BACK);
264 if(abs(blurness-targetblurness)<multiplier*10||abs(blurness-targetblurness)>2){
265 blurness=targetblurness;
266 targetblurness=(float)(abs(Random()%100))/40;
268 if(blurness<targetblurness)
269 blurness+=multiplier*5;
271 blurness-=multiplier*5;
274 static XYZ terrainlight;
275 static float distance;
276 if(drawmode==normalmode)ReSizeGLScene(90,.1f);
277 if(drawmode!=normalmode)glViewport(0,0,texviewwidth,texviewheight);
278 glDepthFunc(GL_LEQUAL);
280 glAlphaFunc(GL_GREATER, 0.0001f);
281 glEnable(GL_ALPHA_TEST);
282 glClearColor(0.25f, 0.25f, 0.25f, 1.0f);
283 glClear(GL_DEPTH_BUFFER_BIT);
285 glMatrixMode (GL_MODELVIEW);
286 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
289 // Move the camera for the current eye's point of view.
290 // Reverse the movement if we're reversing stereo
291 glTranslatef((stereoseparation/2) * side * (stereoreverse ? -1 : 1), 0, 0);
293 if(!cameramode&&!freeze&&!winfreeze){
294 glRotatef(float(Random()%100)/10*camerashake/*+(woozy*woozy)/10*/,0,0,1);
295 glRotatef(rotation2+sin(woozy/2)*(player[0].damage/player[0].damagetolerance)*5,1,0,0);
296 glRotatef(rotation+sin(woozy)*(player[0].damage/player[0].damagetolerance)*5,0,1,0);
298 if(cameramode||freeze||winfreeze){
299 glRotatef(rotation2,1,0,0);
300 glRotatef(rotation,0,1,0);
303 if(environment==desertenvironment){
304 glRotatef((float)(abs(Random()%100))/3000-1,1,0,0);
305 glRotatef((float)(abs(Random()%100))/3000-1,0,1,0);
307 SetUpLight(&light,0);
309 if(environment==desertenvironment&&detail==2)glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, blurness+.4 );
310 if(environment==desertenvironment){
311 glRotatef((float)(abs(Random()%100))/1000,1,0,0);
312 glRotatef((float)(abs(Random()%100))/1000,0,1,0);
315 glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0);
317 glTranslatef(-viewer.x,-viewer.y,-viewer.z);
318 frustum.GetFrustum();
322 static float size,opacity,rotation;
324 for(k=0;k<numplayers;k++){
325 if(!player[k].skeleton.free&&player[k].playerdetail&&player[k].howactive<typesleeping)
326 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)
327 for(i=0;i<player[k].skeleton.num_joints;i++){
328 if(player[k].skeleton.joints[i].label==leftknee||player[k].skeleton.joints[i].label==rightknee||player[k].skeleton.joints[i].label==groin){
329 point=DoRotation(player[k].skeleton.joints[i].position,0,player[k].rotation,0)*player[k].scale+player[k].coords;
331 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;
332 if(k!=0&&tutoriallevel==1){
333 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;
335 terrain.MakeDecal(shadowdecal,point,size,opacity,rotation);
336 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
337 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
338 if(objects.position[j].y<player[k].coords.y||objects.type[j]==tunneltype||objects.type[j]==weirdtype){
339 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);
342 if(k!=0&&tutoriallevel==1){
343 opacity=.2+.2*sin(smoketex*6+i);
345 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
350 if((player[k].skeleton.free||player[k].howactive>=typesleeping)&&player[k].playerdetail)
351 if(frustum.SphereInFrustum(player[k].coords.x,player[k].coords.y,player[k].coords.z,player[k].scale*5)&&player[k].occluded<25)
352 for(i=0;i<player[k].skeleton.num_joints;i++){
353 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){
354 if(player[k].skeleton.free)point=player[k].skeleton.joints[i].position*player[k].scale+player[k].coords;
355 else point=DoRotation(player[k].skeleton.joints[i].position,0,player[k].rotation,0)*player[k].scale+player[k].coords;
357 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;
358 if(k!=0&&tutoriallevel==1){
359 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;
361 terrain.MakeDecal(shadowdecal,point,size,opacity*.7,rotation);
362 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
363 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
364 if(objects.position[j].y<player[k].coords.y||objects.type[j]==tunneltype||objects.type[j]==weirdtype){
365 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);
366 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);
369 if(k!=0&&tutoriallevel==1){
370 opacity=.2+.2*sin(smoketex*6+i);
372 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
378 if(!player[k].playerdetail)
379 if(frustum.SphereInFrustum(player[k].coords.x,player[k].coords.y,player[k].coords.z,player[k].scale*5))
381 point=player[k].coords;
383 opacity=.4-(player[k].coords.y-terrain.getHeight(player[k].coords.x,player[k].coords.z))/5;
384 terrain.MakeDecal(shadowdecal,point,size,opacity*.7,rotation);
385 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
386 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
387 point=DoRotation(player[k].coords-objects.position[j],0,-objects.rotation[j],0);
390 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
396 glEnable(GL_TEXTURE_2D);
398 glEnable(GL_DEPTH_TEST);
399 glEnable(GL_CULL_FACE);
401 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
402 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
403 glBindTexture( GL_TEXTURE_2D, terraintexture);
405 glBindTexture( GL_TEXTURE_2D, terraintexture2);
407 //glBindTexture( GL_TEXTURE_2D, terraintexture3);
408 //glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
411 terrain.drawdecals();
414 glEnable(GL_CULL_FACE);
415 glEnable(GL_LIGHTING);
417 glEnable(GL_TEXTURE_2D);
420 glEnable(GL_COLOR_MATERIAL);
435 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
436 glEnable(GL_CULL_FACE);
437 glCullFace(GL_FRONT);
439 for(k=0;k<numplayers;k++){
440 if(k==0||tutoriallevel!=1){
442 glEnable(GL_LIGHTING);
443 terrainlight=terrain.getLighting(player[k].coords.x,player[k].coords.z);
444 distance=findDistancefast(&viewer,&player[k].coords);
445 distance=(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance;
446 glColor4f(terrainlight.x,terrainlight.y,terrainlight.z,distance);
447 if(distance>=1)glDisable(GL_BLEND);
449 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;
451 if(!player[k].occluded==0)i=checkcollide(viewer,checkpoint,player[k].lastoccluded);
452 if(i==-1||player[k].occluded==0)i=checkcollide(viewer,checkpoint);
454 player[k].occluded+=1;
455 player[k].lastoccluded=i;
457 else player[k].occluded=0;
458 if(player[k].occluded<25)player[k].DrawSkeleton();
464 if(!cameramode&&musictype==stream_music2)playerdist=findDistancefastflat(&player[0].coords,&viewer);
465 else playerdist=-100;
468 glEnable(GL_TEXTURE_2D);
473 if(frustum.SphereInFrustum(realhawkcoords.x+hawk.boundingspherecenter.x,realhawkcoords.y+hawk.boundingspherecenter.y,realhawkcoords.z+hawk.boundingspherecenter.z,2)){
474 glAlphaFunc(GL_GREATER, 0.0001f);
476 glDisable(GL_CULL_FACE);
477 glDisable(GL_LIGHTING);
479 glTranslatef(hawkcoords.x,hawkcoords.y,hawkcoords.z);
480 glRotatef(hawkrotation,0,1,0);
481 glTranslatef(25,0,0);
482 distance=findDistancefast(&viewer,&realhawkcoords)*1.2;
483 glColor4f(light.color[0],light.color[1],light.color[2],(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance);
484 if((viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance>1)glColor4f(light.color[0],light.color[1],light.color[2],1);
485 if((viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance>0)
486 hawk.drawdifftex(hawktexture);
490 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
491 glEnable(GL_CULL_FACE);
492 glCullFace(GL_FRONT);
494 for(k=0;k<numplayers;k++){
495 if(!(k==0||tutoriallevel!=1)){
497 glEnable(GL_LIGHTING);
498 terrainlight=terrain.getLighting(player[k].coords.x,player[k].coords.z);
499 distance=findDistancefast(&viewer,&player[k].coords);
500 distance=(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance;
501 glColor4f(terrainlight.x,terrainlight.y,terrainlight.z,distance);
502 if(distance>=1)glDisable(GL_BLEND);
504 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;
506 if(!player[k].occluded==0)i=checkcollide(viewer,checkpoint,player[k].lastoccluded);
507 if(i==-1||player[k].occluded==0)i=checkcollide(viewer,checkpoint);
509 player[k].occluded+=1;
510 player[k].lastoccluded=i;
512 else player[k].occluded=0;
513 if(player[k].occluded<25)player[k].DrawSkeleton();
519 glEnable(GL_TEXTURE_2D);
524 glDisable(GL_COLOR_MATERIAL);
526 glDisable(GL_LIGHTING);
527 glDisable(GL_TEXTURE_2D);
535 glDisable(GL_LIGHTING);
536 glDisable(GL_TEXTURE_2D);
537 glDisable(GL_COLOR_MATERIAL);
540 for(k=0;k<numplayers;k++){
541 if(player[k].numwaypoints>1){
542 glBegin(GL_LINE_LOOP);
543 for(i=0;i<player[k].numwaypoints;i++){
544 glVertex3f(player[k].waypoints[i].x,player[k].waypoints[i].y+.5,player[k].waypoints[i].z);
553 for(k=0;k<numpathpoints;k++){
554 if(numpathpointconnect[k]){
555 for(i=0;i<numpathpointconnect[k];i++){
556 glBegin(GL_LINE_LOOP);
557 glVertex3f(pathpoint[k].x,pathpoint[k].y+.5,pathpoint[k].z);
558 glVertex3f(pathpoint[pathpointconnect[k][i]].x,pathpoint[pathpointconnect[k][i]].y+.5,pathpoint[pathpointconnect[k][i]].z);
566 glVertex3f(pathpoint[pathpointselected].x,pathpoint[pathpointselected].y+.5,pathpoint[pathpointselected].z);
573 glEnable(GL_TEXTURE_2D);
574 glColor4f(.5,.5,.5,1);
576 sprintf (string, " ",(int)(fps));
577 text.glPrint(10,30,string,0,.8,screenwidth,screenheight);
580 if(bonus>0&&bonustime<1&&!winfreeze&&indialogue==-1/*bonustime<4*/){
581 const char *bonus_name;
582 if (bonus < bonus_count)
583 bonus_name = bonus_names[bonus];
585 bonus_name = "Excellent!"; // When does this happen?
587 glColor4f(0,0,0,1-bonustime);
588 text.glPrintOutline(1024/2-10*strlen(bonus_name)-4,768/16-4+768*4/5,bonus_name,1,2.5,1024,768);
589 glColor4f(1,0,0,1-bonustime);
590 text.glPrint(1024/2-10*strlen(bonus_name),768/16+768*4/5,bonus_name,1,2,1024,768);
592 sprintf (string, "%d",(int)bonusvalue);
593 glColor4f(0,0,0,1-bonustime);
594 text.glPrintOutline(1024/2-10*strlen(string)-4,768/16-4-20+768*4/5,string,1,2.5*.8,1024,768);
595 glColor4f(1,0,0,1-bonustime);
596 text.glPrint(1024/2-10*strlen(string),768/16-20+768*4/5,string,1,2*.8,1024,768);
597 glColor4f(.5,.5,.5,1);
600 if(tutoriallevel==1){
601 tutorialopac=tutorialmaxtime-tutorialstagetime;
602 if(tutorialopac>1)tutorialopac=1;
603 if(tutorialopac<0)tutorialopac=0;
605 sprintf (string, " ");
606 sprintf (string2, " ");
607 sprintf (string3, " ");
608 if(tutorialstage==0){
609 sprintf (string, " ");
610 sprintf (string2, " ");
611 sprintf (string3, " ");
613 if(tutorialstage==1){
614 sprintf (string, "Welcome to the Lugaru training level!");
615 sprintf (string2, " ");
616 sprintf (string3, " ");
618 if(tutorialstage==2){
619 sprintf (string, "BASIC MOVEMENT:");
620 sprintf (string2, " ");
621 sprintf (string3, " ");
623 if(tutorialstage==3){
624 sprintf (string, "You can move the mouse to rotate the camera.");
625 sprintf (string2, " ");
626 sprintf (string3, " ");
628 if(tutorialstage==4){
629 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));
630 sprintf (string2, "All movement is relative to the camera.");
631 sprintf (string3, " ");
633 if(tutorialstage==5){
634 sprintf (string, "Please press %s to jump.",Input::keyToChar(jumpkey));
635 sprintf (string2, "You can hold it longer to jump higher.");
636 sprintf (string3, " ");
638 if(tutorialstage==6){
639 sprintf (string, "You can press %s to crouch.",Input::keyToChar(crouchkey));
640 sprintf (string2, "You can jump higher from a crouching position.");
641 sprintf (string3, " ");
643 if(tutorialstage==7){
644 sprintf (string, "While running, you can press %s to roll.",Input::keyToChar(crouchkey));
645 sprintf (string2, " ");
646 sprintf (string3, " ");
648 if(tutorialstage==8){
649 sprintf (string, "While crouching, you can sneak around silently");
650 sprintf (string2, "using the movement keys.");
651 sprintf (string3, " ");
653 if(tutorialstage==9){
654 sprintf (string, "Release the crouch key while sneaking and hold the movement keys");
655 sprintf (string2, "to run animal-style.");
656 sprintf (string3, " ");
658 if(tutorialstage==10){
659 sprintf (string, "ADVANCED MOVEMENT:");
660 sprintf (string2, " ");
661 sprintf (string3, " ");
663 if(tutorialstage==11){
664 sprintf (string, "When you jump at a wall, you can hold %s again",Input::keyToChar(jumpkey));
665 sprintf (string2, "during impact to perform a walljump.");
666 sprintf (string3, "Be sure to use the movement keys to press against the wall");
668 if(tutorialstage==12){
669 sprintf (string, "While in the air, you can press crouch to flip.",Input::keyToChar(jumpkey));
670 sprintf (string2, "Walljumps and flips confuse enemies and give you more control.");
671 sprintf (string3, " ");
673 if(tutorialstage==13){
674 sprintf (string, "BASIC COMBAT:");
675 sprintf (string2, " ");
676 sprintf (string3, " ");
678 if(tutorialstage==14){
679 sprintf (string, "There is now an imaginary enemy");
680 sprintf (string2, "in the middle of the training area.");
681 sprintf (string3, " ");
683 if(tutorialstage==15){
684 if(attackkey==MOUSEBUTTON1)sprintf (string, "Click to attack when you are near an enemy.");
685 else sprintf (string, "Press %s to attack when you are near an enemy.",Input::keyToChar(attackkey));
686 sprintf (string2, "You can punch by standing still near an enemy and attacking.");
687 sprintf (string3, " ");
689 if(tutorialstage==16){
690 sprintf (string, "If you are close, you will perform a weak punch.");
691 sprintf (string2, "The weak punch is excellent for starting attack combinations.");
692 sprintf (string3, " ");
694 if(tutorialstage==17){
695 sprintf (string, "Attacking while running results in a spin kick.");
696 sprintf (string2, "This is one of your most powerful ground attacks.");
697 sprintf (string3, " ");
699 if(tutorialstage==18){
700 sprintf (string, "Sweep the enemy's legs out by attacking while crouched.");
701 sprintf (string2, "This is a very fast attack, and easy to follow up.");
702 sprintf (string3, " ");
704 if(tutorialstage==19){
705 sprintf (string, "When an enemy is on the ground, you can deal some extra");
706 sprintf (string2, "damage by running up and drop-kicking him.");
707 sprintf (string3, "(Try knocking them down with a sweep first)");
709 if(tutorialstage==20){
710 sprintf (string, "Your most powerful individual attack is the rabbit kick.");
711 if(attackkey==MOUSEBUTTON1)sprintf (string2, "Run at the enemy while holding the mouse button, and press");
712 else sprintf (string2, "Run at the enemy while holding %s, and press", Input::keyToChar(attackkey));
713 sprintf (string3, "the jump key (%s) to attack.",Input::keyToChar(jumpkey));
715 if(tutorialstage==21){
716 sprintf (string, "This attack is devastating if timed correctly.");
717 sprintf (string2, "Even if timed incorrectly, it will knock the enemy over.");
718 if(againbonus)sprintf (string3, "Try rabbit-kicking the imaginary enemy again.");
719 else sprintf (string3, "Try rabbit-kicking the imaginary enemy.");
721 if(tutorialstage==22){
722 sprintf (string, "If you sneak behind an enemy unnoticed, you can kill");
723 sprintf (string2, "him instantly. Move close behind this enemy");
724 sprintf (string3, "and attack.");
726 if(tutorialstage==23){
727 sprintf (string, "Another important attack is the wall kick. When an enemy");
728 sprintf (string2, "is near a wall, perform a walljump nearby and hold");
729 sprintf (string3, "the attack key during impact with the wall.");
731 if(tutorialstage==24){
732 sprintf (string, "You can tackle enemies by running at them animal-style");
733 if(attackkey==MOUSEBUTTON1)sprintf (string2, "and pressing jump (%s) or attack(mouse button).",Input::keyToChar(jumpkey));
734 else sprintf (string2, "and pressing jump (%s) or attack(%s).",Input::keyToChar(jumpkey),Input::keyToChar(attackkey));
735 sprintf (string3, "This is especially useful when they are running away.");
737 if(tutorialstage==25){
738 sprintf (string, "Dodge by pressing back and attack. Dodging is essential");
739 sprintf (string2, "against enemies with swords or other long weapons.");
740 sprintf (string3, " ");
742 if(tutorialstage==26){
743 sprintf (string, "REVERSALS AND COUNTER-REVERSALS");
744 sprintf (string2, " ");
745 sprintf (string3, " ");
747 if(tutorialstage==27){
748 sprintf (string, "The enemy can now reverse your attacks.");
749 sprintf (string2, " ");
750 sprintf (string3, " ");
752 if(tutorialstage==28){
753 sprintf (string, "If you attack, you will notice that the enemy now sometimes");
754 sprintf (string2, "catches your attack and uses it against you. Hold");
755 sprintf (string3, "crouch (%s) after attacking to escape from reversals.",Input::keyToChar(crouchkey));
757 if(tutorialstage==29){
758 sprintf (string, "Try escaping from two more reversals in a row.");
759 sprintf (string2, " ");
760 sprintf (string3, " ");
762 if(tutorialstage==30){
763 sprintf (string, "Good!");
764 sprintf (string2, " ");
765 sprintf (string3, " ");
767 if(tutorialstage==31){
768 sprintf (string, "To reverse an attack, you must tap crouch (%s) during the",Input::keyToChar(crouchkey));
769 sprintf (string2, "enemy's attack. You must also be close to the enemy;");
770 sprintf (string3, "this is especially important against armed opponents.");
772 if(tutorialstage==32){
773 sprintf (string, "The enemy can attack in %d seconds.", (int)(tutorialmaxtime-tutorialstagetime));
774 sprintf (string2, "This imaginary opponents attacks will be highlighted");
775 sprintf (string3, "to make this easier.");
777 if(tutorialstage==33){
778 sprintf (string, "Reverse three enemy attacks!");
779 sprintf (string2, " ");
780 sprintf (string3, " ");
782 if(tutorialstage==34){
783 sprintf (string, "Reverse two more enemy attacks!");
784 sprintf (string2, " ");
785 sprintf (string3, " ");
787 if(tutorialstage==35){
788 sprintf (string, "Reverse one more enemy attack!");
789 sprintf (string2, " ");
790 sprintf (string3, " ");
792 if(tutorialstage==36){
793 sprintf (string, "Excellent!");
794 sprintf (string2, " ");
795 sprintf (string3, " ");
797 if(tutorialstage==37){
798 sprintf (string, "Now spar with the enemy for %d more seconds.", (int)(tutorialmaxtime-tutorialstagetime));
799 sprintf (string2, "Damage dealt: %d",(int)damagedealt);
800 sprintf (string3, "Damage taken: %d.",(int)damagetaken);
802 if(tutorialstage==38){
803 sprintf (string, "WEAPONS:");
804 sprintf (string2, " ");
805 sprintf (string3, " ");
807 if(tutorialstage==39){
808 sprintf (string, "There is now an imaginary knife");
809 sprintf (string2, "in the center of the training area.");
810 sprintf (string3, " ");
812 if(tutorialstage==40){
813 sprintf (string, "Stand, roll or handspring over the knife");
814 sprintf (string2, "while pressing %s to pick it up.",Input::keyToChar(throwkey));
815 sprintf (string3, "You can crouch and press the same key to drop it again.");
817 if(tutorialstage==41){
818 sprintf (string, "You can equip and unequip weapons using the %s key.",Input::keyToChar(drawkey));
819 sprintf (string2, "Sometimes it is best to keep them unequipped to");
820 sprintf (string3, "prevent enemies from taking them. ");
822 if(tutorialstage==42){
823 sprintf (string, "The knife is the smallest weapon and the least encumbering.");
824 sprintf (string2, "You can equip or unequip it while standing, crouching,");
825 sprintf (string3, "running or flipping.");
827 if(tutorialstage==43){
828 sprintf (string, "You perform weapon attacks the same way as unarmed attacks,");
829 sprintf (string2, "but sharp weapons cause permanent damage, instead of the");
830 sprintf (string3, "temporary trauma from blunt weapons, fists and feet.");
832 if(tutorialstage==44){
833 sprintf (string, "The enemy now has your knife!");
834 sprintf (string2, "Please reverse two of his knife attacks.");
835 sprintf (string3, " ");
837 if(tutorialstage==45){
838 sprintf (string, "Please reverse one more of his knife attacks.");
839 sprintf (string2, " ");
840 sprintf (string3, " ");
842 if(tutorialstage==46){
843 sprintf (string, "Now he has a sword!");
844 sprintf (string2, "The sword has longer reach than your arms, so you");
845 sprintf (string3, "must move close to reverse the sword slash.");
847 if(tutorialstage==47){
848 sprintf (string, "Long weapons like the sword and staff are also useful for defense;");
849 sprintf (string2, "you can parry enemy weapon attacks by pressing the attack key");
850 sprintf (string3, "at the right time. Please try parrying the enemy's attacks!");
852 if(tutorialstage==48){
853 sprintf (string, "The staff is like the sword, but has two main attacks.");
854 sprintf (string2, "The standing smash is fast and effective, and the running");
855 sprintf (string3, "spin smash is slower and more powerful.");
857 if(tutorialstage==49){
858 sprintf (string, "When facing an enemy, you can throw the knife with %s.",Input::keyToChar(throwkey));
859 sprintf (string2, "It is possible to throw the knife while flipping,");
860 sprintf (string3, "but it is very inaccurate.");
862 if(tutorialstage==50){
863 sprintf (string, "You now know everything you can learn from training.");
864 sprintf (string2, "Everything else you must learn from experience!");
865 sprintf (string3, " ");
867 if(tutorialstage==51){
868 sprintf (string, "Walk out of the training area to return to the main menu.");
869 sprintf (string2, " ");
870 sprintf (string3, " ");
873 glColor4f(0,0,0,tutorialopac);
874 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);
875 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);
876 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);
877 glColor4f(1,1,1,tutorialopac);
878 text.glPrint(screenwidth/2-7.6*strlen(string)*screenwidth/1024,screenheight/16+screenheight*4/5,string,1,1.5*screenwidth/1024,screenwidth,screenheight);
879 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);
880 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);
882 sprintf (string, "Press 'tab' to skip to the next item.",Input::keyToChar(jumpkey));
883 sprintf (string2, "Press escape at any time to");
884 sprintf (string3, "pause or exit the tutorial.");
887 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);
888 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);
889 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);
890 glColor4f(0.5,0.5,0.5,1);
891 text.glPrint(screenwidth/2-7.6*strlen(string)*screenwidth/1024*.8,0+screenheight*1/10,string,1,1.5*screenwidth/1024*.8,screenwidth,screenheight);
892 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);
893 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);
897 if(numhotspots&&(bonustime>=1||bonus<=0||bonustime<0)&&!tutoriallevel){
899 float closestdist=-1;
901 closest=currenthotspot;
902 for(i=0;i<numhotspots;i++){
903 distance=findDistancefast(&player[0].coords,&hotspot[i]);
904 if(closestdist==-1||distance<closestdist){
905 if(findDistancefast(&player[0].coords,&hotspot[i])<hotspotsize[i]&&((hotspottype[i]<=10&&hotspottype[i]>=0)||(hotspottype[i]<=40&&hotspottype[i]>=20))){
906 closestdist=distance;
912 currenthotspot=closest;
913 if(currenthotspot!=-1){
914 if(hotspottype[closest]<=10){
915 if(findDistancefast(&player[0].coords,&hotspot[closest])<hotspotsize[closest])
918 tutorialopac=tutorialmaxtime-tutorialstagetime;
919 if(tutorialopac>1)tutorialopac=1;
920 if(tutorialopac<0)tutorialopac=0;
922 sprintf (string, "%s", hotspottext[closest]);
929 if(string[i]=='\n'||string[i]>'z'||string[i]<' '||string[i]=='\0'){
930 glColor4f(0,0,0,tutorialopac);
931 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);
932 glColor4f(1,1,1,tutorialopac);
933 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);
936 if(string[i]=='\0')done=1;
942 else if (hotspottype[closest]>=20&&dialoguegonethrough[hotspottype[closest]-20]==0){
943 whichdialogue=hotspottype[closest]-20;
944 for(j=0;j<numdialogueboxes[whichdialogue];j++){
945 player[participantfocus[whichdialogue][j]].coords=participantlocation[whichdialogue][participantfocus[whichdialogue][j]];
946 player[participantfocus[whichdialogue][j]].rotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
947 player[participantfocus[whichdialogue][j]].targetrotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
948 player[participantfocus[whichdialogue][j]].velocity=0;
949 player[participantfocus[whichdialogue][j]].targetanimation=player[participantfocus[whichdialogue][j]].getIdle();
950 player[participantfocus[whichdialogue][j]].targetframe=0;
954 dialoguegonethrough[whichdialogue]++;
955 if(dialogueboxsound[whichdialogue][indialogue]!=0){
957 if(dialogueboxsound[whichdialogue][indialogue]==1)whichsoundplay=rabbitchitter;
958 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
959 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
960 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
961 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
962 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
963 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
964 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
965 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
966 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
967 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
968 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
969 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
970 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
971 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
972 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
973 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
974 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
975 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
976 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
977 emit_sound_at(whichsoundplay, player[participantfocus[whichdialogue][indialogue]].coords);
983 if(indialogue!=-1&&!mainmenu){
984 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
985 glDisable(GL_CULL_FACE);
986 glDisable(GL_LIGHTING);
987 glDisable(GL_TEXTURE_2D);
989 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
990 glPushMatrix(); // Store The Projection Matrix
991 glLoadIdentity(); // Reset The Projection Matrix
992 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
993 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
994 glPushMatrix(); // Store The Modelview Matrix
995 glLoadIdentity(); // Reset The Modelview Matrix
996 if(dialogueboxlocation[whichdialogue][indialogue]==1)glTranslatef(0,screenheight*3/4,0);
997 glScalef(screenwidth,screenheight/4,1);
998 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1001 glColor4f(dialogueboxcolor[whichdialogue][indialogue][0],dialogueboxcolor[whichdialogue][indialogue][1],dialogueboxcolor[whichdialogue][indialogue][2],0.7);
1003 glVertex3f(0, 0, 0.0f);
1004 glVertex3f(1, 0, 0.0f);
1005 glVertex3f(1, 1, 0.0f);
1006 glVertex3f(0, 1, 0.0f);
1008 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1009 glPopMatrix(); // Restore The Old Projection Matrix
1010 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1011 glPopMatrix(); // Restore The Old Projection Matrix
1012 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1013 glEnable(GL_CULL_FACE);
1014 glDisable(GL_BLEND);
1016 glEnable(GL_TEXTURE_2D);
1023 startx=screenwidth*1/5;
1024 if(dialogueboxlocation[whichdialogue][indialogue]==1)starty=screenheight/16+screenheight*4/5;
1025 if(dialogueboxlocation[whichdialogue][indialogue]==2)starty=screenheight*1/5-screenheight/16;
1034 for(i=0;i<(int)strlen(dialoguename[whichdialogue][indialogue]);i++){
1035 tempname[tempnum]=dialoguename[whichdialogue][indialogue][i];
1037 if(dialoguename[whichdialogue][indialogue][i]=='#'||dialoguename[whichdialogue][indialogue][i]=='\0')goodchar=0;
1041 tempname[tempnum]='\0';
1044 sprintf (string, "%s: ", tempname);
1046 if(dialogueboxcolor[whichdialogue][indialogue][0]+dialogueboxcolor[whichdialogue][indialogue][1]+dialogueboxcolor[whichdialogue][indialogue][2]<1.5){
1047 glColor4f(0,0,0,tutorialopac);
1048 text.glPrintOutline(startx-2*7.6*strlen(string)*screenwidth/1024-4,starty-4,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight);
1049 glColor4f(0.7,0.7,0.7,tutorialopac);
1050 text.glPrint(startx-2*7.6*strlen(string)*screenwidth/1024,starty,string,1,1.5*screenwidth/1024,screenwidth,screenheight);
1054 glColor4f(0,0,0,tutorialopac);
1055 text.glPrintOutline(startx-2*7.6*strlen(string)*screenwidth/1024-4,starty-4,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight);
1059 for(i=0;i<(int)strlen(dialoguetext[whichdialogue][indialogue])+1;i++){
1060 tempname[tempnum]=dialoguetext[whichdialogue][indialogue][i];
1061 if(dialoguetext[whichdialogue][indialogue][i]!='#')tempnum++;
1064 sprintf (string, "%s", tempname);
1071 if(string[i]=='\n'||string[i]>'z'||string[i]<' '||string[i]=='\0'){
1072 if(dialogueboxcolor[whichdialogue][indialogue][0]+dialogueboxcolor[whichdialogue][indialogue][1]+dialogueboxcolor[whichdialogue][indialogue][2]<1.5){
1073 glColor4f(0,0,0,tutorialopac);
1074 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);
1075 glColor4f(1,1,1,tutorialopac);
1076 text.glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/,starty-20*screenwidth/1024*line,string,1,1.5*screenwidth/1024,screenwidth,screenheight,lastline,i);
1080 glColor4f(0,0,0,tutorialopac);
1081 text.glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/,starty-20*screenwidth/1024*line,string,1,1.5*screenwidth/1024,screenwidth,screenheight,lastline,i);
1085 if(string[i]=='\0')done=1;
1092 if(!tutoriallevel&&!winfreeze&&indialogue==-1&&!mainmenu){
1095 sprintf (string, "Score: %d", (int)accountactive->getCampaignScore());
1097 sprintf (string, "Score: %d", (int)accountactive->getCampaignScore()+(int)bonustotal);
1099 if(!campaign)sprintf (string, "Score: %d", (int)bonustotal);
1101 text.glPrintOutline(1024/40-4,768/16-4+768*14/16,string,1,1.5*1.25,1024,768);
1103 text.glPrint(1024/40,768/16+768*14/16,string,1,1.5,1024,768);
1105 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1106 glDisable(GL_CULL_FACE);
1107 glDisable(GL_LIGHTING);
1108 glDisable(GL_TEXTURE_2D);
1110 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1111 glPushMatrix(); // Store The Projection Matrix
1112 glLoadIdentity(); // Reset The Projection Matrix
1113 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1114 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1115 glPushMatrix(); // Store The Modelview Matrix
1116 glLoadIdentity(); // Reset The Modelview Matrix
1117 glTranslatef(15,screenheight*17.5/20,0);
1118 glScalef(screenwidth/3+20,screenheight/20,1);
1119 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1121 glColor4f(0.0,0.4,0.0,0.7);
1122 float bar=((float)player[0].damage)/player[0].damagetolerance;
1124 glVertex3f((bar<1?bar:1),0,0.0f);
1125 glVertex3f(1,0,0.0f);
1126 glVertex3f(1,1,0.0f);
1127 glVertex3f((bar<1?bar:1),1,0.0f);
1129 glColor4f(0.1,0.0,0.0,1);
1130 bar = ((float)player[0].bloodloss)/player[0].damagetolerance;
1132 glVertex3f(0,0,0.0f);
1133 glVertex3f((bar<1?bar:1),0,0.0f);
1134 glVertex3f((bar<1?bar:1),1,0.0f);
1135 glVertex3f(0,1,0.0f);
1137 glColor4f(0.4,0.0,0.0,0.7);
1138 bar = ((float)player[0].damage)/player[0].damagetolerance;
1140 glVertex3f(0,0,0.0f);
1141 glVertex3f((bar<1?bar:1),0,0.0f);
1142 glVertex3f((bar<1?bar:1),1,0.0f);
1143 glVertex3f(0,1,0.0f);
1145 glColor4f(0.4,0.0,0.0,0.7);
1146 bar = ((float)player[0].permanentdamage)/player[0].damagetolerance;
1148 glVertex3f(0,0,0.0f);
1149 glVertex3f((bar<1?bar:1),0,0.0f);
1150 glVertex3f((bar<1?bar:1),1,0.0f);
1151 glVertex3f(0,1,0.0f);
1153 glColor4f(0.4,0.0,0.0,0.7);
1154 bar = ((float)player[0].superpermanentdamage)/player[0].damagetolerance;
1156 glVertex3f(0,0,0.0f);
1157 glVertex3f((bar<1?bar:1),0,0.0f);
1158 glVertex3f((bar<1?bar:1),1,0.0f);
1159 glVertex3f(0,1,0.0f);
1161 glColor4f(0.0,0.0,0.0,0.7);
1163 glBegin(GL_LINE_STRIP);
1164 glVertex3f(0,0,0.0f);
1165 glVertex3f(1,0,0.0f);
1166 glVertex3f(1,1,0.0f);
1167 glVertex3f(0,1,0.0f);
1168 glVertex3f(0,0,0.0f);
1171 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1172 glPopMatrix(); // Restore The Old Projection Matrix
1173 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1174 glPopMatrix(); // Restore The Old Projection Matrix
1175 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1176 glEnable(GL_CULL_FACE);
1177 glDisable(GL_BLEND);
1179 glEnable(GL_TEXTURE_2D);
1181 // writing the numbers :
1182 sprintf (string, "Damages : %d/%d (%d)",(int)(player[0].damage),(int)(player[0].damagetolerance),(int)(player[0].bloodloss));
1184 text.glPrintOutline(1024/40-4,768/16-4+768*14/16-40,string,1,1.5*1.25,1024,768);
1186 text.glPrint(1024/40,768/16+768*14/16-40,string,1,1.5,1024,768);
1190 glColor4f(.5,.5,.5,1);
1193 if((texttoggle||editorenabled)&&debugmode&&!mainmenu){
1194 sprintf (string, "The framespersecond is %d.",(int)(fps));
1195 text.glPrint(10,30,string,0,.8,1024,768);
1197 sprintf (string, "Name: %s", registrationname);
1198 text.glPrint(10,260,string,0,.8,1024,768);
1202 sprintf (string, "Map editor enabled.");
1204 sprintf (string, "Map editor disabled.");
1205 text.glPrint(10,60,string,0,.8,1024,768);
1207 sprintf (string, "Object size: %f",editorsize);
1208 text.glPrint(10,75,string,0,.8,1024,768);
1209 if(editorrotation>=0)sprintf (string, "Object rotation: %f",editorrotation);
1210 else sprintf (string, "Object rotation: Random");
1211 text.glPrint(10,90,string,0,.8,1024,768);
1212 if(editorrotation2>=0)sprintf (string, "Object rotation2: %f",editorrotation2);
1213 else sprintf (string, "Object rotation2: Random");
1214 text.glPrint(10,105,string,0,.8,1024,768);
1215 sprintf (string, "Object type: %d",editortype);
1216 text.glPrint(10,120,string,0,.8,1024,768);
1217 switch(editortype) {
1219 sprintf (string, "(box)");
1222 sprintf (string, "(tree)");
1225 sprintf (string, "(wall)");
1228 sprintf (string, "(weird)");
1231 sprintf (string, "(spike)");
1234 sprintf (string, "(rock)");
1237 sprintf (string, "(bush)");
1240 sprintf (string, "(tunnel)");
1243 sprintf (string, "(chimney)");
1246 sprintf (string, "(platform)");
1249 sprintf (string, "(cool)");
1252 sprintf (string, "(fire)");
1255 text.glPrint(130,120,string,0,.8,1024,768);
1257 sprintf (string, "Numplayers: %d",numplayers);
1258 text.glPrint(10,155,string,0,.8,1024,768);
1259 sprintf (string, "Player %d: numwaypoints: %d",numplayers,player[numplayers-1].numwaypoints);
1260 text.glPrint(10,140,string,0,.8,1024,768);
1262 sprintf (string, "Difficulty: %d",difficulty);
1263 text.glPrint(10,240,string,0,.8,1024,768);
1268 if(drawmode==glowmode){
1269 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1270 glDisable(GL_CULL_FACE);
1271 glDisable(GL_LIGHTING);
1272 glDisable(GL_TEXTURE_2D);
1274 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1275 glPushMatrix(); // Store The Projection Matrix
1276 glLoadIdentity(); // Reset The Projection Matrix
1277 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1278 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1279 glPushMatrix(); // Store The Modelview Matrix
1280 glLoadIdentity(); // Reset The Modelview Matrix
1281 glScalef(screenwidth,screenheight,1);
1282 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1284 glColor4f(0,0,0,.5);
1286 glVertex3f(0, 0, 0.0f);
1287 glVertex3f(256, 0, 0.0f);
1288 glVertex3f(256, 256, 0.0f);
1289 glVertex3f(0, 256, 0.0f);
1291 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1292 glPopMatrix(); // Restore The Old Projection Matrix
1293 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1294 glPopMatrix(); // Restore The Old Projection Matrix
1295 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1296 glEnable(GL_CULL_FACE);
1297 glDisable(GL_BLEND);
1301 if((((blackout&&damageeffects)||(player[0].bloodloss>0&&damageeffects&&player[0].blooddimamount>0)||player[0].dead)&&!cameramode)||console){
1302 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1303 glDisable(GL_CULL_FACE);
1304 glDisable(GL_LIGHTING);
1305 glDisable(GL_TEXTURE_2D);
1307 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1308 glPushMatrix(); // Store The Projection Matrix
1309 glLoadIdentity(); // Reset The Projection Matrix
1310 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1311 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1312 glPushMatrix(); // Store The Modelview Matrix
1313 glLoadIdentity(); // Reset The Modelview Matrix
1314 glScalef(screenwidth,screenheight,1);
1315 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1317 if(player[0].dead)blackout+=multiplier*3;
1318 if(player[0].dead==1)blackout=.4f;
1319 if(player[0].dead==2&&blackout>.6)blackout=.6;
1320 glColor4f(0,0,0,blackout);
1321 if(!player[0].dead){
1322 if((player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5))*.3<.3){
1323 glColor4f(0,0,0,player[0].blooddimamount*player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5)*.3);
1324 blackout=player[0].blooddimamount*player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5)*.3;
1327 glColor4f(0,0,0,player[0].blooddimamount*.3);
1328 blackout=player[0].blooddimamount*.3;
1331 if(console)glColor4f(.7,0,0,.2);
1333 glVertex3f(0, 0, 0.0f);
1334 glVertex3f(256, 0, 0.0f);
1335 glVertex3f(256, 256, 0.0f);
1336 glVertex3f(0, 256, 0.0f);
1338 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1339 glPopMatrix(); // Restore The Old Projection Matrix
1340 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1341 glPopMatrix(); // Restore The Old Projection Matrix
1342 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1343 glEnable(GL_CULL_FACE);
1344 glDisable(GL_BLEND);
1348 if(flashamount>0&&damageeffects){
1349 if(flashamount>1)flashamount=1;
1350 if(flashdelay<=0)flashamount-=multiplier;
1352 if(flashamount<0)flashamount=0;
1353 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1354 glDisable(GL_CULL_FACE);
1355 glDisable(GL_LIGHTING);
1357 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1358 glPushMatrix(); // Store The Projection Matrix
1359 glLoadIdentity(); // Reset The Projection Matrix
1360 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1361 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1362 glPushMatrix(); // Store The Modelview Matrix
1363 glLoadIdentity(); // Reset The Modelview Matrix
1364 glScalef(screenwidth,screenheight,1);
1365 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1367 glColor4f(flashr,flashg,flashb,flashamount);
1369 glVertex3f(0, 0, 0.0f);
1370 glVertex3f(256, 0, 0.0f);
1371 glVertex3f(256, 256, 0.0f);
1372 glVertex3f(0, 256, 0.0f);
1374 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1375 glPopMatrix(); // Restore The Old Projection Matrix
1376 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1377 glPopMatrix(); // Restore The Old Projection Matrix
1378 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1379 glEnable(GL_CULL_FACE);
1380 glDisable(GL_BLEND);
1386 glEnable(GL_TEXTURE_2D);
1389 sprintf (string, " ]");
1390 text.glPrint(10,30+screenheight-330,string,0,1,screenwidth,screenheight);
1392 sprintf (string, "_");
1393 text.glPrint(30+(float)(displayselected)*10,30+(screenheight-330),string,0,1,screenwidth,screenheight);
1397 if((i!=0||chatting)&&displaytime[i]<4)
1398 for(j=0;j<displaychars[i];j++){
1399 glColor4f(1,1,1,4-displaytime[i]);
1400 if(j<displaychars[i]){
1401 sprintf (string, "%c",displaytext[i][j]);
1402 text.glPrint(30+j*10,30+i*20+(screenheight-330),string,0,1,screenwidth,screenheight);
1408 if(minimap&&indialogue==-1){
1409 float mapviewdist = 20000;
1411 glDisable(GL_DEPTH_TEST);
1412 glColor3f (1.0, 1.0, 1.0); // no coloring
1414 glEnable(GL_TEXTURE_2D);
1415 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1416 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1417 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1418 glDisable(GL_CULL_FACE);
1419 glDisable(GL_LIGHTING);
1421 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1422 glPushMatrix(); // Store The Projection Matrix
1423 glLoadIdentity(); // Reset The Projection Matrix
1424 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1425 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1426 glPushMatrix(); // Store The Modelview Matrix
1427 glLoadIdentity(); // Reset The Modelview Matrix
1428 glScalef((float)screenwidth/2,(float)screenwidth/2,1);
1429 glTranslatef(1.75,.25,0);
1430 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1438 int numliveplayers=0;
1440 for(i=0;i<numplayers;i++){
1441 if(!player[i].dead) numliveplayers++;
1446 for(i=0;i<objects.numobjects;i++){
1447 if(objects.type[i]==treetrunktype||objects.type[i]==boxtype){
1448 center+=objects.position[i];
1452 for(i=0;i<numplayers;i++){
1453 if(!player[i].dead)center+=player[i].coords;
1455 center/=numadd+numliveplayers;
1457 center=player[0].coords;
1459 float maxdistance=0;
1462 for(i=0;i<objects.numobjects;i++){
1463 tempdist=findDistancefast(¢er,&objects.position[i]);
1464 if(tempdist>maxdistance){
1466 maxdistance=tempdist;
1469 for(i=0;i<numplayers;i++){
1470 if(!player[i].dead){
1471 tempdist=findDistancefast(¢er,&player[i].coords);
1472 if(tempdist>maxdistance){
1474 maxdistance=tempdist;
1478 radius=fast_sqrt(maxdistance);
1482 glScalef(.25/radius*256*terrain.scale*.4,.25/radius*256*terrain.scale*.4,1);
1484 glScalef(1/(1/radius*256*terrain.scale*.4),1/(1/radius*256*terrain.scale*.4),1);
1486 glRotatef(player[0].lookrotation*-1+180,0,0,1);
1487 glTranslatef(-(center.x/terrain.scale/256*-2+1),(center.z/terrain.scale/256*-2+1),0);
1488 for(i=0;i<objects.numobjects;i++){
1489 if(objects.type[i]==treetrunktype){
1490 distcheck=findDistancefast(&player[0].coords,&objects.position[i]);
1491 if(distcheck<mapviewdist){
1492 glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
1493 glColor4f(0,.3,0,opac*(1-distcheck/mapviewdist));
1495 glTranslatef(objects.position[i].x/terrain.scale/256*-2+1,objects.position[i].z/terrain.scale/256*2-1,0);
1496 glRotatef(objects.rotation[i],0,0,1);
1497 glScalef(.003,.003,.003);
1500 glVertex3f(-1, -1, 0.0f);
1502 glVertex3f(1, -1, 0.0f);
1504 glVertex3f(1, 1, 0.0f);
1506 glVertex3f(-1, 1, 0.0f);
1511 if(objects.type[i]==boxtype){
1512 distcheck=findDistancefast(&player[0].coords,&objects.position[i]);
1513 if(distcheck<mapviewdist){
1514 glBindTexture( GL_TEXTURE_2D, Mapboxtexture);
1515 glColor4f(.4,.4,.4,opac*(1-distcheck/mapviewdist));
1517 glTranslatef(objects.position[i].x/terrain.scale/256*-2+1,objects.position[i].z/terrain.scale/256*2-1,0);
1518 glRotatef(objects.rotation[i],0,0,1);
1519 glScalef(.01*objects.scale[i],.01*objects.scale[i],.01*objects.scale[i]);
1522 glVertex3f(-1, -1, 0.0f);
1524 glVertex3f(1, -1, 0.0f);
1526 glVertex3f(1, 1, 0.0f);
1528 glVertex3f(-1, 1, 0.0f);
1535 glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
1536 for(i=0;i<numboundaries;i++){
1537 glColor4f(0,0,0,opac/3);
1539 glTranslatef(boundary[i].x/terrain.scale/256*-2+1,boundary[i].z/terrain.scale/256*2-1,0);
1540 glScalef(.002,.002,.002);
1543 glVertex3f(-1, -1, 0.0f);
1545 glVertex3f(1, -1, 0.0f);
1547 glVertex3f(1, 1, 0.0f);
1549 glVertex3f(-1, 1, 0.0f);
1554 for(i=0;i<numplayers;i++){
1555 distcheck=findDistancefast(&player[0].coords,&player[i].coords);
1556 if(distcheck<mapviewdist){
1558 glBindTexture( GL_TEXTURE_2D, Maparrowtexture);
1559 if(i==0)glColor4f(1,1,1,opac);
1560 else if(player[i].dead==2||player[i].howactive>typesleeping)glColor4f(0,0,0,opac*(1-distcheck/mapviewdist));
1561 else if(player[i].dead)glColor4f(.3,.3,.3,opac*(1-distcheck/mapviewdist));
1562 else if(player[i].aitype==attacktypecutoff)glColor4f(1,0,0,opac*(1-distcheck/mapviewdist));
1563 else if(player[i].aitype==passivetype)glColor4f(0,1,0,opac*(1-distcheck/mapviewdist));
1564 else glColor4f(1,1,0,1);
1565 glTranslatef(player[i].coords.x/terrain.scale/256*-2+1,player[i].coords.z/terrain.scale/256*2-1,0);
1566 glRotatef(player[i].rotation+180,0,0,1);
1567 glScalef(.005,.005,.005);
1570 glVertex3f(-1, -1, 0.0f);
1572 glVertex3f(1, -1, 0.0f);
1574 glVertex3f(1, 1, 0.0f);
1576 glVertex3f(-1, 1, 0.0f);
1582 glDisable(GL_TEXTURE_2D);
1583 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1584 glPopMatrix(); // Restore The Old Projection Matrix
1585 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1586 glPopMatrix(); // Restore The Old Projection Matrix
1587 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1588 glEnable(GL_CULL_FACE);
1589 glDisable(GL_BLEND);
1593 if(loading&&!stealthloading&&(!campaign||player[0].dead)){
1594 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1595 glDisable(GL_CULL_FACE);
1596 glDisable(GL_LIGHTING);
1597 glDisable(GL_TEXTURE_2D);
1599 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1600 glPushMatrix(); // Store The Projection Matrix
1601 glLoadIdentity(); // Reset The Projection Matrix
1602 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1603 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1604 glPushMatrix(); // Store The Modelview Matrix
1605 glLoadIdentity(); // Reset The Modelview Matrix
1606 glScalef(screenwidth,screenheight,1);
1607 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1609 glColor4f(0,0,0,.7);
1611 glVertex3f(0, 0, 0.0f);
1612 glVertex3f(256, 0, 0.0f);
1613 glVertex3f(256, 256, 0.0f);
1614 glVertex3f(0, 256, 0.0f);
1616 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1617 glPopMatrix(); // Restore The Old Projection Matrix
1618 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1619 glPopMatrix(); // Restore The Old Projection Matrix
1620 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1621 glEnable(GL_CULL_FACE);
1622 glDisable(GL_BLEND);
1626 glDisable(GL_DEPTH_TEST);
1627 glColor3f (1.0, 1.0, 1.0); // no coloring
1629 glEnable(GL_TEXTURE_2D);
1634 glEnable(GL_TEXTURE_2D);
1636 sprintf (string, "Loading...");
1637 text.glPrint(1024/2-90,768/2,string,1,2,1024,768);
1640 //if(ismotionblur)drawmode=motionblurmode;
1641 drawmode=normalmode;
1644 if(winfreeze&&!campaign){
1645 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1646 glDisable(GL_CULL_FACE);
1647 glDisable(GL_LIGHTING);
1648 glDisable(GL_TEXTURE_2D);
1650 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1651 glPushMatrix(); // Store The Projection Matrix
1652 glLoadIdentity(); // Reset The Projection Matrix
1653 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1654 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1655 glPushMatrix(); // Store The Modelview Matrix
1656 glLoadIdentity(); // Reset The Modelview Matrix
1657 glScalef(screenwidth,screenheight,1);
1658 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1660 glColor4f(0,0,0,.4);
1662 glVertex3f(0, 0, 0.0f);
1663 glVertex3f(256, 0, 0.0f);
1664 glVertex3f(256, 256, 0.0f);
1665 glVertex3f(0, 256, 0.0f);
1667 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1668 glPopMatrix(); // Restore The Old Projection Matrix
1669 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1670 glPopMatrix(); // Restore The Old Projection Matrix
1671 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1672 glEnable(GL_CULL_FACE);
1673 glDisable(GL_BLEND);
1677 glDisable(GL_DEPTH_TEST);
1678 glColor3f (1.0, 1.0, 1.0); // no coloring
1680 glEnable(GL_TEXTURE_2D);
1682 //Win Screen Won Victory
1684 glEnable(GL_TEXTURE_2D);
1686 sprintf (string, "Level Cleared!");
1687 text.glPrintOutlined(1024/2-strlen(string)*10,768*7/8,string,1,2,1024,768);
1689 sprintf (string, "Score: %d",(int)(bonustotal-startbonustotal));
1690 text.glPrintOutlined(1024/30,768*6/8,string,1,2,1024,768);
1693 sprintf (string, "Press Escape or Space to continue");
1695 sprintf (string, "Press Escape to return to menu or Space to continue");
1696 text.glPrintOutlined(640/2-strlen(string)*5,480*1/16,string,1,1,640,480);
1700 for(i=0;i<255;i++)string[i]='\0';
1701 sprintf (temp, "Time: %d:",(int)(((int)leveltime-(int)(leveltime)%60)/60));
1702 strcat(string,temp);
1703 if((int)(leveltime)%60<10)strcat(string,"0");
1704 sprintf (temp, "%d",(int)(leveltime)%60);
1705 strcat(string,temp);
1706 text.glPrintOutlined(1024/30,768*6/8-40,string,1,2,1024,768);
1709 int awards[award_count];
1710 int numawards = award_awards(awards);
1712 for (i = 0; i < numawards && i < 6; i++)
1713 text.glPrintOutlined(1024/30,768*6/8-90-40*i,award_names[awards[i]],1,2,1024,768);
1716 if(drawmode!=normalmode){
1717 glEnable(GL_TEXTURE_2D);
1719 if(!drawtoggle||drawmode!=realmotionblurmode||(drawtoggle==2||change==1)){
1722 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
1723 GLfloat subtractColor[4] = { 0.5, 0.5, 0.5, 0.0 };
1724 glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, subtractColor);
1725 //glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_SUBTRACT);
1726 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE);
1727 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_CONSTANT_EXT);
1728 glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 2.0f);
1730 glBindTexture( GL_TEXTURE_2D, screentexture);
1731 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1734 if((drawtoggle||change==1)&&drawmode==realmotionblurmode){
1736 glBindTexture( GL_TEXTURE_2D, screentexture2);
1737 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1739 if(!screentexture2){
1740 glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
1742 glGenTextures( 1, &screentexture2 );
1743 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
1745 glEnable(GL_TEXTURE_2D);
1746 glBindTexture( GL_TEXTURE_2D, screentexture2);
1747 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
1748 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
1750 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
1756 glClear(GL_DEPTH_BUFFER_BIT);
1757 ReSizeGLScene(90,.1f);
1758 glViewport(0,0,screenwidth,screenheight);
1760 if(drawmode!=normalmode){
1761 glDisable(GL_DEPTH_TEST);
1762 if(drawmode==motionblurmode){
1763 glDrawBuffer(GL_FRONT);
1764 glReadBuffer(GL_BACK);
1766 glColor3f (1.0, 1.0, 1.0); // no coloring
1768 glEnable(GL_TEXTURE_2D);
1769 glBindTexture( GL_TEXTURE_2D, screentexture);
1770 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1771 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1772 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1773 glDisable(GL_CULL_FACE);
1774 glDisable(GL_LIGHTING);
1776 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1777 glPushMatrix(); // Store The Projection Matrix
1778 glLoadIdentity(); // Reset The Projection Matrix
1779 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1780 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1781 glPushMatrix(); // Store The Modelview Matrix
1782 glLoadIdentity(); // Reset The Modelview Matrix
1783 glScalef((float)screenwidth/2,(float)screenheight/2,1);
1784 glTranslatef(1,1,0);
1785 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1787 if(drawmode==motionblurmode){
1788 if(motionbluramount<.2)motionbluramount=.2;
1789 //glColor4f(1,1,1,fast_sqrt(multiplier)*2.9*motionbluramount);
1790 glColor4f(1,1,1,motionbluramount);
1794 glVertex3f(-1, -1, 0.0f);
1795 glTexCoord2f(texcoordwidth,0);
1796 glVertex3f(1, -1, 0.0f);
1797 glTexCoord2f(texcoordwidth,texcoordheight);
1798 glVertex3f(1, 1, 0.0f);
1799 glTexCoord2f(0,texcoordheight);
1800 glVertex3f(-1, 1, 0.0f);
1804 if(drawmode==realmotionblurmode){
1805 glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
1806 glClear(GL_COLOR_BUFFER_BIT);
1807 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
1808 glBindTexture( GL_TEXTURE_2D, screentexture);
1809 glColor4f(1,1,1,.5);
1813 glVertex3f(-1, -1, 0.0f);
1814 glTexCoord2f(texcoordwidth,0);
1815 glVertex3f(1, -1, 0.0f);
1816 glTexCoord2f(texcoordwidth,texcoordheight);
1817 glVertex3f(1, 1, 0.0f);
1818 glTexCoord2f(0,texcoordheight);
1819 glVertex3f(-1, 1, 0.0f);
1822 glBindTexture( GL_TEXTURE_2D, screentexture2);
1823 glColor4f(1,1,1,.5);
1827 glVertex3f(-1, -1, 0.0f);
1828 glTexCoord2f(texcoordwidth,0);
1829 glVertex3f(1, -1, 0.0f);
1830 glTexCoord2f(texcoordwidth,texcoordheight);
1831 glVertex3f(1, 1, 0.0f);
1832 glTexCoord2f(0,texcoordheight);
1833 glVertex3f(-1, 1, 0.0f);
1836 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1838 if(drawmode==doublevisionmode){
1839 static float crosseyedness;
1840 crosseyedness=abs(player[0].damage-player[0].superpermanentdamage-(player[0].damagetolerance-player[0].superpermanentdamage)*1/2)/30;
1841 if(crosseyedness>1)crosseyedness=1;
1842 if(crosseyedness<0)crosseyedness=0;
1844 glDisable(GL_BLEND);
1849 glVertex3f(-1, -1, 0.0f);
1850 glTexCoord2f(texcoordwidth,0);
1851 glVertex3f(1, -1, 0.0f);
1852 glTexCoord2f(texcoordwidth,texcoordheight);
1853 glVertex3f(1, 1, 0.0f);
1854 glTexCoord2f(0,texcoordheight);
1855 glVertex3f(-1, 1, 0.0f);
1859 glColor4f(1,1,1,.5);
1862 glTranslatef(.015*crosseyedness,0,0);
1866 glVertex3f(-1, -1, 0.0f);
1867 glTexCoord2f(texcoordwidth,0);
1868 glVertex3f(1, -1, 0.0f);
1869 glTexCoord2f(texcoordwidth,texcoordheight);
1870 glVertex3f(1, 1, 0.0f);
1871 glTexCoord2f(0,texcoordheight);
1872 glVertex3f(-1, 1, 0.0f);
1877 if(drawmode==glowmode){
1878 glColor4f(.5,.5,.5,.5);
1880 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
1882 glTranslatef(.01,0,0);
1885 glVertex3f(-1, -1, 0.0f);
1886 glTexCoord2f(texcoordwidth,0);
1887 glVertex3f(1, -1, 0.0f);
1888 glTexCoord2f(texcoordwidth,texcoordheight);
1889 glVertex3f(1, 1, 0.0f);
1890 glTexCoord2f(0,texcoordheight);
1891 glVertex3f(-1, 1, 0.0f);
1895 glTranslatef(-.01,0,0);
1898 glVertex3f(-1, -1, 0.0f);
1899 glTexCoord2f(texcoordwidth,0);
1900 glVertex3f(1, -1, 0.0f);
1901 glTexCoord2f(texcoordwidth,texcoordheight);
1902 glVertex3f(1, 1, 0.0f);
1903 glTexCoord2f(0,texcoordheight);
1904 glVertex3f(-1, 1, 0.0f);
1908 glTranslatef(.0,.01,0);
1911 glVertex3f(-1, -1, 0.0f);
1912 glTexCoord2f(texcoordwidth,0);
1913 glVertex3f(1, -1, 0.0f);
1914 glTexCoord2f(texcoordwidth,texcoordheight);
1915 glVertex3f(1, 1, 0.0f);
1916 glTexCoord2f(0,texcoordheight);
1917 glVertex3f(-1, 1, 0.0f);
1921 glTranslatef(0,-.01,0);
1924 glVertex3f(-1, -1, 0.0f);
1925 glTexCoord2f(texcoordwidth,0);
1926 glVertex3f(1, -1, 0.0f);
1927 glTexCoord2f(texcoordwidth,texcoordheight);
1928 glVertex3f(1, 1, 0.0f);
1929 glTexCoord2f(0,texcoordheight);
1930 glVertex3f(-1, 1, 0.0f);
1934 if(drawmode==radialzoommode){
1936 //glRotatef((float)i*.1,0,0,1);
1937 glColor4f(1,1,1,1/((float)i+1));
1939 glScalef(1+(float)i*.01,1+(float)i*.01,1);
1942 glVertex3f(-1, -1, 0.0f);
1943 glTexCoord2f(texcoordwidth,0);
1944 glVertex3f(1, -1, 0.0f);
1945 glTexCoord2f(texcoordwidth,texcoordheight);
1946 glVertex3f(1, 1, 0.0f);
1947 glTexCoord2f(0,texcoordheight);
1948 glVertex3f(-1, 1, 0.0f);
1953 glDisable(GL_TEXTURE_2D);
1954 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1955 glPopMatrix(); // Restore The Old Projection Matrix
1956 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1957 glPopMatrix(); // Restore The Old Projection Matrix
1958 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1959 glEnable(GL_CULL_FACE);
1960 glDisable(GL_BLEND);
1965 glEnable(GL_TEXTURE_2D);
1968 if(consoleselected>=60)
1969 offset=consoleselected-60;
1970 sprintf (string, " ]");
1971 text.glPrint(10,30,string,0,1,1024,768);
1973 sprintf (string, "_");
1974 text.glPrint(30+(float)(consoleselected)*10-offset*10,30,string,0,1,1024,768);
1977 for(j=0;j<consolechars[i];j++){
1978 glColor4f(1,1,1,1-(float)(i)/16);
1979 if(j<consolechars[i]){
1980 sprintf (string, "%c",consoletext[i][j]);
1981 text.glPrint(30+j*10-offset*10,30+i*20,string,0,1,1024,768);
1988 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)||(mainmenu&&gameon)||(!gameon&&gamestarted)||(!gameon&&gamestarted)){
1989 multiplier=tempmult;
1994 // !!! FIXME: hack: clamp framerate in menu so text input works correctly on fast systems.
1997 glDrawBuffer(GL_BACK);
1998 glReadBuffer(GL_BACK);
1999 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
2000 ReSizeGLScene(90,.1f);
2003 temptexdetail=texdetail;
2004 if(texdetail>2)texdetail=2;
2005 if(mainmenu!=oldmainmenu&&oldmainmenu!=0){
2007 LoadTexture(":Data:Textures:Newgame.png",&Mainmenuitems[1],0,0);
2008 LoadTexture(":Data:Textures:Quit.png",&Mainmenuitems[3],0,0);
2011 LoadTexture(":Data:Textures:Resume.png",&Mainmenuitems[1],0,0);
2012 LoadTexture(":Data:Textures:Endgame.png",&Mainmenuitems[3],0,0);
2015 if(lastcheck>.5||oldmainmenu!=mainmenu){
2017 ifstream ipstream(ConvertFileName(":Data:Campaigns:main.txt"));
2018 ipstream.ignore(256,':');
2019 ipstream >> campaignnumlevels;
2020 for(i=0;i<campaignnumlevels;i++){
2021 ipstream.ignore(256,':');
2022 ipstream.ignore(256,':');
2023 ipstream.ignore(256,' ');
2024 ipstream >> campaignmapname[i];
2025 ipstream.ignore(256,':');
2026 ipstream >> campaigndescription[i];
2028 if(campaigndescription[i][j]=='_')campaigndescription[i][j]=' ';
2030 ipstream.ignore(256,':');
2031 ipstream >> campaignchoosenext[i];
2032 ipstream.ignore(256,':');
2033 ipstream >> campaignnumnext[i];
2034 for(j=0;j<campaignnumnext[i];j++){
2035 ipstream.ignore(256,':');
2036 ipstream >> campaignnextlevel[i][j];
2037 campaignnextlevel[i][j]-=1;
2039 ipstream.ignore(256,':');
2040 ipstream >> campaignlocationx[i];
2041 ipstream.ignore(256,':');
2042 ipstream >> campaignlocationy[i];
2046 for(i=0;i<campaignnumlevels;i++){
2048 levelhighlight[i]=0;
2053 for(i=0;i<accountactive->getCampaignChoicesMade();i++){
2054 levelorder[i+1]=campaignnextlevel[levelorder[i]][accountactive->getCampaignChoice(i)];
2055 levelvisible[levelorder[i+1]]=1;
2057 int whichlevelstart = accountactive->getCampaignChoicesMade()-1;
2058 if(whichlevelstart<0){
2059 accountactive->setCampaignScore(0);
2060 accountactive->resetFasttime();
2061 campaignchoicenum=1;
2062 campaignchoicewhich[0]=0;
2066 campaignchoicenum=campaignnumnext[levelorder[whichlevelstart]];
2067 for(i=0;i<campaignchoicenum;i++){
2068 campaignchoicewhich[i]=campaignnextlevel[levelorder[whichlevelstart]][i];
2069 levelvisible[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
2070 levelhighlight[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
2079 texdetail=temptexdetail;
2081 oldmainmenu=mainmenu;
2083 if(mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==8||mainmenu==9||mainmenu==10||mainmenu==119||mainmenu==18){
2084 glClear(GL_DEPTH_BUFFER_BIT);
2085 glEnable(GL_ALPHA_TEST);
2086 glAlphaFunc(GL_GREATER, 0.001f);
2087 glEnable(GL_TEXTURE_2D);
2088 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
2089 glDisable(GL_CULL_FACE);
2090 glDisable(GL_LIGHTING);
2092 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2093 glPushMatrix(); // Store The Projection Matrix
2094 glLoadIdentity(); // Reset The Projection Matrix
2095 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
2096 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2097 glPushMatrix(); // Store The Modelview Matrix
2098 glLoadIdentity(); // Reset The Modelview Matrix
2099 glTranslatef(screenwidth/2,screenheight/2,0);
2101 glScalef((float)screenwidth/2,(float)screenheight/2,1);
2102 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
2103 glDisable(GL_BLEND);
2104 glColor4f(0,0,0,1.0);
2105 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2106 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2107 glDisable(GL_TEXTURE_2D);
2109 //glScalef(.25,.25,.25);
2112 glVertex3f(-1, -1, 0.0f);
2114 glVertex3f(1, -1, 0.0f);
2116 glVertex3f(1, 1, 0.0f);
2118 glVertex3f(-1, 1, 0.0f);
2122 glColor4f(0.4,0.4,0.4,1.0);
2123 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2124 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2125 glEnable(GL_TEXTURE_2D);
2126 glBindTexture( GL_TEXTURE_2D, Mainmenuitems[4]);
2128 //glScalef(.25,.25,.25);
2131 glVertex3f(-1, -1, 0.0f);
2133 glVertex3f(1, -1, 0.0f);
2135 glVertex3f(1, 1, 0.0f);
2137 glVertex3f(-1, 1, 0.0f);
2142 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2144 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2148 if((float)newscreenwidth>(float)newscreenheight*1.61||(float)newscreenwidth<(float)newscreenheight*1.59)sprintf (menustring[0], "Resolution: %d*%d",(int)newscreenwidth,(int)newscreenheight);
2149 else sprintf (menustring[0], "Resolution: %d*%d (widescreen)",(int)newscreenwidth,(int)newscreenheight);
2152 endx[0]=startx[0]+strlen(menustring[0])*10;
2153 endy[0]=starty[0]+20;
2157 if(newdetail==2)sprintf (menustring[1], "Detail: High");
2158 else if(newdetail==1)sprintf (menustring[1], "Detail: Medium");
2159 else sprintf (menustring[1], "Detail: Low");
2162 endx[1]=startx[1]+strlen(menustring[1])*10;
2163 endy[1]=starty[1]+20;
2167 if(bloodtoggle==2)sprintf (menustring[2], "Blood: On, high detail (slower)");
2168 if(bloodtoggle==1)sprintf (menustring[2], "Blood: On, low detail");
2169 if(bloodtoggle==0)sprintf (menustring[2], "Blood: Off");
2172 endx[2]=startx[2]+strlen(menustring[2])*10;
2173 endy[2]=starty[2]+20;
2177 if(difficulty==2)sprintf (menustring[3], "Difficulty: Insane");
2178 if(difficulty==1)sprintf (menustring[3], "Difficulty: Difficult");
2179 if(difficulty==0)sprintf (menustring[3], "Difficulty: Easier");
2180 startx[3]=10+20-1000;
2182 endx[3]=startx[3]+strlen(menustring[3])*10;
2183 endy[3]=starty[3]+20;
2187 if(ismotionblur==1)sprintf (menustring[4], "Blur Effects: Enabled (less compatible)");
2188 if(ismotionblur==0)sprintf (menustring[4], "Blur Effects: Disabled (more compatible)");
2191 endx[4]=startx[4]+strlen(menustring[4])*10;
2192 endy[4]=starty[4]+20;
2196 if(decals==1)sprintf (menustring[5], "Decals: Enabled (slower)");
2197 if(decals==0)sprintf (menustring[5], "Decals: Disabled");
2200 endx[5]=startx[5]+strlen(menustring[5])*10;
2201 endy[5]=starty[5]+20;
2205 if(musictoggle==1)sprintf (menustring[6], "Music: Enabled");
2206 if(musictoggle==0)sprintf (menustring[6], "Music: Disabled");
2209 endx[6]=startx[6]+strlen(menustring[6])*10;
2210 endy[6]=starty[6]+20;
2214 if(invertmouse==1)sprintf (menustring[9], "Invert mouse: Yes");
2215 if(invertmouse==0)sprintf (menustring[9], "Invert mouse: No");
2218 endx[9]=startx[9]+strlen(menustring[9])*10;
2219 endy[9]=starty[9]+20;
2223 sprintf (menustring[10], "Mouse Speed: %d", (int)(usermousesensitivity*5));
2226 endx[10]=startx[10]+strlen(menustring[10])*10;
2227 endy[10]=starty[10]+20;
2231 sprintf (menustring[11], "Volume: %d%%", (int)(volume*100));
2234 endx[11]=startx[11]+strlen(menustring[11])*10;
2235 endy[11]=starty[11]+20;
2239 sprintf (menustring[13], "Damage Bar: %s",(showdamagebar?"on":"off"));
2242 endx[13]=startx[13]+strlen(menustring[13])*10;
2243 endy[13]=starty[13]+20;
2247 sprintf (menustring[7], "-Configure Controls-");
2250 endx[7]=startx[7]+strlen(menustring[7])*10;
2251 endy[7]=starty[7]+20;
2255 sprintf (menustring[12], "-Configure Stereo -");
2258 endx[12]=startx[12]+strlen(menustring[7])*10;
2259 endy[12]=starty[12]+20;
2263 if(newdetail==detail&&newscreenheight==(int)screenheight&&newscreenwidth==(int)screenwidth)sprintf (menustring[8], "Back");
2264 else sprintf (menustring[8], "Back (some changes take effect next time Lugaru is opened)");
2266 endx[8]=startx[8]+strlen(menustring[8])*10;
2268 endy[8]=starty[8]+20;
2275 if(keyselect!=0)sprintf (menustring[0], "Forwards: %s",Input::keyToChar(forwardkey));
2276 else sprintf (menustring[0], "Forwards: _");
2279 endx[0]=startx[0]+strlen(menustring[0])*10;
2280 endy[0]=starty[0]+20;
2284 if(keyselect!=1)sprintf (menustring[1], "Back: %s",Input::keyToChar(backkey));
2285 else sprintf (menustring[1], "Back: _");
2288 endx[1]=startx[1]+strlen(menustring[1])*10;
2289 endy[1]=starty[1]+20;
2293 if(keyselect!=2)sprintf (menustring[2], "Left: %s",Input::keyToChar(leftkey));
2294 else sprintf (menustring[2], "Left: _");
2297 endx[2]=startx[2]+strlen(menustring[2])*10;
2298 endy[2]=starty[2]+20;
2302 if(keyselect!=3)sprintf (menustring[3], "Right: %s",Input::keyToChar(rightkey));
2303 else sprintf (menustring[3], "Right: _");
2306 endx[3]=startx[3]+strlen(menustring[3])*10;
2307 endy[3]=starty[3]+20;
2311 if(keyselect!=4)sprintf (menustring[4], "Crouch: %s",Input::keyToChar(crouchkey));
2312 else sprintf (menustring[4], "Crouch: _");
2315 endx[4]=startx[4]+strlen(menustring[4])*10;
2316 endy[4]=starty[4]+20;
2320 if(keyselect!=5)sprintf (menustring[5], "Jump: %s",Input::keyToChar(jumpkey));
2321 else sprintf (menustring[5], "Jump: _");
2324 endx[5]=startx[5]+strlen(menustring[5])*10;
2325 endy[5]=starty[5]+20;
2329 if(keyselect!=6)sprintf (menustring[6], "Draw: %s",Input::keyToChar(drawkey));
2330 else sprintf (menustring[6], "Draw: _");
2333 endx[6]=startx[6]+strlen(menustring[6])*10;
2334 endy[6]=starty[6]+20;
2338 if(keyselect!=7)sprintf (menustring[7], "Throw: %s",Input::keyToChar(throwkey));
2339 else sprintf (menustring[7], "Throw: _");
2342 endx[7]=startx[7]+strlen(menustring[7])*10;
2343 endy[7]=starty[7]+20;
2347 if(keyselect!=8)sprintf (menustring[8], "Attack: %s",Input::keyToChar(attackkey));
2348 else sprintf (menustring[8], "Attack: _");
2351 endx[8]=startx[8]+strlen(menustring[8])*10;
2352 endy[8]=starty[8]+20;
2358 sprintf (menustring[9], "Back");
2360 endx[9]=startx[9]+strlen(menustring[9])*10;
2362 endy[9]=starty[9]+20;
2367 nummenuitems=7+accountactive->getCampaignChoicesMade()+campaignchoicenum;
2369 sprintf (menustring[0], "%s",accountactive->getName());
2372 endx[0]=startx[0]+strlen(menustring[0])*10;
2373 endy[0]=starty[0]+20;
2377 sprintf (menustring[1], "Tutorial");
2380 endx[1]=startx[1]+strlen(menustring[1])*10;
2381 endy[1]=starty[1]+20;
2385 sprintf (menustring[2], "Challenge");
2388 endx[2]=startx[2]+strlen(menustring[2])*10;
2389 endy[2]=starty[2]+20;
2393 sprintf (menustring[3], "Delete User");
2396 endx[3]=startx[3]+strlen(menustring[3])*10;
2397 endy[3]=starty[3]+20;
2401 sprintf (menustring[4], "Main Menu");
2404 endx[4]=startx[4]+strlen(menustring[4])*10;
2405 endy[4]=starty[4]+20;
2409 sprintf (menustring[5], "Change User");
2411 endx[5]=startx[5]+strlen(menustring[5])*10;
2413 endy[5]=starty[5]+20;
2419 sprintf (menustring[6], "World");
2421 starty[6]=30+480-400-50;
2422 endx[6]=startx[6]+400;
2427 if(accountactive->getCampaignChoicesMade())
2428 for(i=0;i<accountactive->getCampaignChoicesMade();i++){
2429 sprintf (menustring[7+i], "%s", campaigndescription[levelorder[i]]);
2430 startx[7+i]=30+120+campaignlocationx[levelorder[i]]*400/512;
2431 starty[7+i]=30+30+(512-campaignlocationy[levelorder[i]])*400/512;
2432 endx[7+i]=startx[7+i]+10;
2433 endy[7+i]=starty[7+i]+10;
2438 if(campaignchoicenum>0)
2439 for(i=accountactive->getCampaignChoicesMade();i<accountactive->getCampaignChoicesMade()+campaignchoicenum;i++){
2440 sprintf (menustring[7+i], "%s", campaigndescription[levelorder[i]]);
2441 startx[7+i]=30+120+campaignlocationx[campaignchoicewhich[i-(accountactive->getCampaignChoicesMade())]]*400/512;
2442 starty[7+i]=30+30+(512-campaignlocationy[campaignchoicewhich[i-(accountactive->getCampaignChoicesMade())]])*400/512;
2443 endx[7+i]=startx[7+i]+10;
2444 endy[7+i]=starty[7+i]+10;
2449 /*sprintf (menustring[7], "Dot");
2450 startx[7]=120+260*400/512;
2451 starty[7]=30+(512-184)*400/512;
2452 endx[7]=startx[7]+10;
2453 endy[7]=starty[7]+10;
2457 sprintf (menustring[8], "Dot");
2458 startx[8]=120+129*400/512;
2459 starty[8]=30+(512-284)*400/512;
2460 endx[8]=startx[8]+10;
2461 endy[8]=starty[8]+10;
2465 sprintf (menustring[9], "Dot");
2466 startx[9]=120+358*400/512;
2467 starty[9]=30+(512-235)*400/512;
2468 endx[9]=startx[9]+10;
2469 endy[9]=starty[9]+10;
2473 sprintf (menustring[10], "Dot");
2474 startx[10]=120+359*400/512;
2475 starty[10]=30+(512-308)*400/512;
2476 endx[10]=startx[10]+10;
2477 endy[10]=starty[10]+10;
2481 sprintf (menustring[11], "Dot");
2482 startx[11]=120+288*400/512;
2483 starty[11]=30+(512-277)*400/512;
2484 endx[11]=startx[11]+10;
2485 endy[11]=starty[11]+10;
2493 sprintf (menustring[0], "Are you sure you want to delete this user?");
2496 endx[0]=startx[0]+strlen(menustring[0])*10;
2497 endy[0]=starty[0]+20;
2501 sprintf (menustring[1], "Yes");
2504 endx[1]=startx[1]+strlen(menustring[1])*10;
2505 endy[1]=starty[1]+20;
2509 sprintf (menustring[2], "No");
2512 endx[2]=startx[2]+strlen(menustring[2])*10;
2513 endy[2]=starty[2]+20;
2517 sprintf (menustring[3], "Extra 4");
2520 endx[3]=startx[3]+strlen(menustring[3])*10;
2521 endy[3]=starty[3]+20;
2525 sprintf (menustring[4], "Extra 5");
2528 endx[4]=startx[4]+strlen(menustring[4])*10;
2529 endy[4]=starty[4]+20;
2533 sprintf (menustring[5], "Back");
2535 endx[5]=startx[5]+strlen(menustring[5])*10;
2537 endy[5]=starty[5]+20;
2543 nummenuitems=Account::getNbAccounts()+2;
2547 if(Account::getNbAccounts()<8)
2548 sprintf (menustring[0], "New User");
2550 sprintf (menustring[0], "No More Users");
2553 endx[0]=startx[0]+strlen(menustring[0])*10;
2554 endy[0]=starty[0]+20;
2563 for(i=0;i<Account::getNbAccounts();i++){
2564 sprintf (menustring[num], "%s",Account::get(i)->getName());
2566 starty[num]=360-20-20*num;
2567 endx[num]=startx[num]+strlen(menustring[num])*10;
2568 endy[num]=starty[num]+20;
2575 sprintf (menustring[num], "Back");
2577 endx[num]=startx[num]+strlen(menustring[num])*10;
2579 endy[num]=starty[num]+20;
2586 sprintf (menustring[0], "Easier");
2589 endx[0]=startx[0]+strlen(menustring[0])*10;
2590 endy[0]=starty[0]+20;
2594 sprintf (menustring[1], "Difficult");
2597 endx[1]=startx[1]+strlen(menustring[1])*10;
2598 endy[1]=starty[1]+20;
2602 sprintf (menustring[2], "Insane");
2605 endx[2]=startx[2]+strlen(menustring[2])*10;
2606 endy[2]=starty[2]+20;
2612 //tempncl=numchallengelevels;
2613 //numchallengelevels=9;
2614 nummenuitems=2+numchallengelevels;
2617 for(j=0;j<numchallengelevels;j++){
2618 for(i=0;i<255;i++)menustring[j][i]='\0';
2619 sprintf (temp, "Level %d",j+1);
2620 strcpy(menustring[j],temp);
2621 for(i=0;i<17;i++)if(menustring[j][i]=='\0')menustring[j][i]=' ';
2622 menustring[j][17]='\0';
2623 sprintf (temp, "%d",(int)accountactive->getHighScore(j));
2624 strcat(menustring[j],temp);
2625 for(i=18;i<32;i++)if(menustring[j][i]=='\0')menustring[j][i]=' ';
2626 menustring[j][32]='\0';
2627 sprintf (temp, "%d:",(int)(((int)accountactive->getFastTime(j)-(int)(accountactive->getFastTime(j))%60)/60));
2628 strcat(menustring[j],temp);
2629 if((int)(accountactive->getFastTime(j))%60<10)strcat(menustring[j],"0");
2630 sprintf (temp, "%d",(int)(accountactive->getFastTime(j))%60);
2631 strcat(menustring[j],temp);
2635 endx[j]=startx[j]+strlen(menustring[j])*10;
2636 endy[j]=starty[j]+20;
2641 sprintf (menustring[numchallengelevels], "Back");
2642 startx[numchallengelevels]=10;
2643 endx[numchallengelevels]=startx[numchallengelevels]+strlen(menustring[numchallengelevels])*10;
2644 starty[numchallengelevels]=10;
2645 endy[numchallengelevels]=starty[numchallengelevels]+20;
2646 movex[numchallengelevels]=0;
2647 movey[numchallengelevels]=0;
2649 sprintf (menustring[numchallengelevels+1], " High Score Best Time");
2650 startx[numchallengelevels+1]=10;
2651 starty[numchallengelevels+1]=440;
2652 endx[numchallengelevels+1]=startx[numchallengelevels+1]+strlen(menustring[numchallengelevels+1])*10;
2653 endy[numchallengelevels+1]=starty[numchallengelevels+1]+20;
2654 movex[numchallengelevels+1]=0;
2655 movey[numchallengelevels+1]=0;
2657 //numchallengelevels=tempncl;
2664 sprintf (menustring[0], "Congratulations!");
2667 endx[0]=startx[0]+strlen(menustring[0])*10;
2668 endy[0]=starty[0]+20;
2672 sprintf (menustring[1], "You have avenged your family and");
2675 endx[1]=startx[1]+strlen(menustring[1])*10;
2676 endy[1]=starty[1]+20;
2680 sprintf (menustring[2], "restored peace to the island of Lugaru.");
2683 endx[2]=startx[2]+strlen(menustring[2])*10;
2684 endy[2]=starty[2]+20;
2688 sprintf (menustring[3], "Back");
2690 endx[3]=startx[3]+strlen(menustring[3])*10;
2692 endy[3]=starty[3]+20;
2696 for(i=0;i<255;i++)menustring[4][i]='\0';
2697 sprintf (temp, "Your score:");
2698 strcpy(menustring[4],temp);
2699 for(i=0;i<20;i++)if(menustring[4][i]=='\0')menustring[4][i]=' ';
2700 menustring[4][20]='\0';
2701 sprintf (temp, "%d",(int)accountactive->getCampaignScore());
2702 strcat(menustring[4],temp);
2704 endx[4]=startx[4]+strlen(menustring[4])*10;
2706 endy[4]=starty[4]+20;
2710 for(i=0;i<255;i++)menustring[5][i]='\0';
2711 sprintf (temp, "Your time:");
2712 strcpy(menustring[5],temp);
2713 for(i=0;i<20;i++)if(menustring[5][i]=='\0')menustring[5][i]=' ';
2714 menustring[5][20]='\0';
2715 sprintf (temp, "%d",(int)accountcampaigntime[accountactive]);
2716 strcat(menustring[5],temp);
2718 endx[5]=startx[5]+strlen(menustring[5])*10;
2720 endy[5]=starty[5]+20;
2724 for(i=0;i<255;i++)menustring[5][i]='\0';
2725 sprintf (temp, "Highest score:");
2726 strcpy(menustring[5],temp);
2727 for(i=0;i<20;i++)if(menustring[5][i]=='\0')menustring[5][i]=' ';
2728 menustring[5][20]='\0';
2729 sprintf (temp, "%d",(int)accountactive->getCampaignHighScore());
2730 strcat(menustring[5],temp);
2732 endx[5]=startx[5]+strlen(menustring[5])*10;
2734 endy[5]=starty[5]+20;
2738 for(i=0;i<255;i++)menustring[7][i]='\0';
2739 sprintf (temp, "Lowest time:");
2740 strcpy(menustring[7],temp);
2741 for(i=0;i<20;i++)if(menustring[7][i]=='\0')menustring[7][i]=' ';
2742 menustring[7][20]='\0';
2743 sprintf (temp, "%d",(int)accountactive->getCampaignFasttime());
2744 strcat(menustring[7],temp);
2746 endx[7]=startx[7]+strlen(menustring[7])*10;
2748 endy[7]=starty[7]+20;
2754 sprintf (menustring[0], "Stereo mode: %s", StereoModeName(newstereomode));
2757 endx[0]=startx[0]+strlen(menustring[0])*10;
2758 endy[0]=starty[0]+20;
2762 sprintf (menustring[1], "Stereo separation: %.3f", stereoseparation);
2765 endx[1]=startx[1]+strlen(menustring[1])*10;
2766 endy[1]=starty[1]+20;
2770 sprintf (menustring[2], "Reverse stereo: %s", stereoreverse ? "Yes" : "No");
2773 endx[2]=startx[2]+strlen(menustring[2])*10;
2774 endy[2]=starty[2]+20;
2778 sprintf (menustring[3], "Back");
2780 endx[3]=startx[3]+strlen(menustring[3])*10;
2782 endy[3]=starty[3]+20;
2788 if(mainmenu==1||mainmenu==2){
2798 starty[1]=480-152-32;
2805 starty[2]=480-228-32;
2813 starty[3]=480-306-32;
2822 starty[3]=480-306-32;
2836 starty[4]=480-140-256;
2843 starty[5]=480-138-256;
2850 starty[6]=480-144-256;
2858 starty[4]=480-140-256;
2865 starty[5]=480-138-256;
2872 starty[6]=480-144-256;
2880 starty[4]=480-140-256;
2887 starty[5]=480-150-256;
2894 starty[6]=480-144-256;
2902 starty[4]=480-140-256;
2909 starty[5]=480-150-256;
2916 starty[6]=480-144-256;
2924 starty[4]=480-100-256;
2931 starty[5]=480-120-256;
2938 starty[6]=480-144-256;
2948 if(mainmenu==1||mainmenu==2)
2950 if((mousecoordh/screenwidth*640)>startx[i]&&(mousecoordh/screenwidth*640)<endx[i]&&480-(mousecoordv/screenheight*480)>starty[i]&&480-(mousecoordv/screenheight*480)<endy[i]){
2955 if(mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==8||mainmenu==9||mainmenu==10||mainmenu==18)
2956 for(i=0;i<nummenuitems;i++){
2957 if((mousecoordh/screenwidth*640)>startx[i]&&(mousecoordh/screenwidth*640)<endx[i]&&480-(mousecoordv/screenheight*480)>starty[i]&&480-(mousecoordv/screenheight*480)<endy[i]){
2958 if(mainmenu!=5)selected=i;
2959 if(mainmenu==5&&(i!=0&&i!=6))selected=i;
2960 if(mainmenu==9&&(i!=numchallengelevels+1))selected=i; // seem useless, if mainmenu==9 then mainmenu!=5, so selected==i.
2964 for(i=0;i<nummenuitems;i++){
2966 selectedlong[i]+=multiplier*5;
2967 if(selectedlong[i]>1) selectedlong[i]=1;
2969 selectedlong[i]-=multiplier*5;
2970 if(selectedlong[i]<0) selectedlong[i]=0;
2972 offsetx[i]=(startx[i]+endx[i])/2-(mousecoordh/screenwidth*640);
2973 offsety[i]=(starty[i]+endy[i])/2-(480-(mousecoordv/screenheight*480));
2978 if(i>=4&&(mainmenu==1||mainmenu==2)){
2980 offsetx[i]=(startx[i]+endx[i]+movex[i]*transition)/2-(640+190)/2;
2981 offsety[i]=(starty[i]+endy[i]+movey[i]*transition)/2-(336+150)/2;
2987 if(mainmenu==1||mainmenu==2){
2988 glClear(GL_DEPTH_BUFFER_BIT);
2989 glEnable(GL_ALPHA_TEST);
2990 glAlphaFunc(GL_GREATER, 0.001f);
2991 glEnable(GL_TEXTURE_2D);
2992 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
2993 glDisable(GL_CULL_FACE);
2994 glDisable(GL_LIGHTING);
2996 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2997 glPushMatrix(); // Store The Projection Matrix
2998 glLoadIdentity(); // Reset The Projection Matrix
2999 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
3000 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3001 glPushMatrix(); // Store The Modelview Matrix
3002 glLoadIdentity(); // Reset The Modelview Matrix
3003 glTranslatef(screenwidth/2,screenheight/2,0);
3005 glScalef((float)screenwidth/2,(float)screenheight/2,1);
3006 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3007 glDisable(GL_BLEND);
3008 glColor4f(0,0,0,1.0);
3009 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
3010 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
3011 glDisable(GL_TEXTURE_2D);
3013 //glScalef(.25,.25,.25);
3016 glVertex3f(-1, -1, 0.0f);
3018 glVertex3f(1, -1, 0.0f);
3020 glVertex3f(1, 1, 0.0f);
3022 glVertex3f(-1, 1, 0.0f);
3026 glColor4f(0.4,0.4,0.4,1.0);
3027 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
3028 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
3029 glEnable(GL_TEXTURE_2D);
3030 glBindTexture( GL_TEXTURE_2D, Mainmenuitems[4]);
3032 //glScalef(.25,.25,.25);
3035 glVertex3f(-1, -1, 0.0f);
3037 glVertex3f(1, -1, 0.0f);
3039 glVertex3f(1, 1, 0.0f);
3041 glVertex3f(-1, 1, 0.0f);
3046 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3049 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3050 glPushMatrix(); // Store The Projection Matrix
3051 glLoadIdentity(); // Reset The Projection Matrix
3052 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3053 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3054 glPushMatrix(); // Store The Modelview Matrix
3055 glLoadIdentity(); // Reset The Modelview Matrix
3057 glDisable(GL_TEXTURE_2D);
3061 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3063 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3067 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3068 glPushMatrix(); // Store The Projection Matrix
3069 glLoadIdentity(); // Reset The Projection Matrix
3070 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3071 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3072 glPushMatrix(); // Store The Modelview Matrix
3073 glLoadIdentity(); // Reset The Modelview Matrix
3074 glEnable(GL_TEXTURE_2D);
3075 for(j=0;j<nummenuitems;j++)
3077 if(j<=3||(mainmenu!=1&&mainmenu!=2))
3079 //glDisable(GL_BLEND);
3080 glEnable(GL_ALPHA_TEST);
3082 //glDisable(GL_ALPHA_TEST);
3083 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3084 if(mainmenu==1||mainmenu==2)
3087 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3088 glBindTexture( GL_TEXTURE_2D, Mainmenuitems[j]);
3089 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
3090 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
3091 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3095 glVertex3f(startx[j]+movex[j]*transition, starty[j]+movey[j]*transition, 0.0f);
3097 glVertex3f(endx[j]+movex[j]*transition, starty[j]+movey[j]*transition, 0.0f);
3099 glVertex3f(endx[j]+movex[j]*transition, endy[j]+movey[j]*transition, 0.0f);
3101 glVertex3f(startx[j]+movex[j]*transition, endy[j]+movey[j]*transition, 0.0f);
3105 //glDisable(GL_ALPHA_TEST);
3106 if(j<4)glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3109 if(1-((float)i)/10-(1-selectedlong[j])>0)
3111 glColor4f(1,1,1,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3112 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3116 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);
3118 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);
3120 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);
3122 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);
3128 if(mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==8||mainmenu==9||mainmenu==10||mainmenu==18)
3130 if(mainmenu!=5||j<6)
3133 if(mainmenu==9&&j>accountactive->getProgress()&&j<numchallengelevels)glColor4f(0.5,0,0,1);
3134 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3136 if(mainmenu!=7||j!=0||!entername)
3137 text.glPrint(startx[j],starty[j],menustring[j],0,1,640,480);
3141 sprintf (string, "_");
3142 text.glPrint(startx[j]+(float)(displayselected)*10,starty[j],string,0,1,640,480);
3144 for(l=0;l<displaychars[0];l++){
3145 sprintf (string, "%c",displaytext[0][l]);
3146 text.glPrint(startx[j]+l*10,starty[j],string,0,1,640,480);
3151 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3154 if(1-((float)i)/15-(1-selectedlong[j])>0)
3156 glColor4f(1,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3157 if(mainmenu==9&&j>accountactive->getProgress()&&j<numchallengelevels)glColor4f(0.5,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3158 if(mainmenu==11&&j>accountactive->getProgress()&&j<numchallengelevels)glColor4f(0.5,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3159 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);
3160 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);
3161 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);
3162 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);
3163 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);
3164 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);
3165 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);
3166 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);
3167 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);
3173 glClear(GL_DEPTH_BUFFER_BIT);
3174 glEnable(GL_ALPHA_TEST);
3175 glAlphaFunc(GL_GREATER, 0.001f);
3176 glEnable(GL_TEXTURE_2D);
3177 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3178 glDisable(GL_CULL_FACE);
3179 glDisable(GL_LIGHTING);
3180 if(j==6)glColor4f(1,1,1,1);
3181 else glColor4f(1,0,0,1);
3183 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3184 glPushMatrix(); // Store The Projection Matrix
3185 glLoadIdentity(); // Reset The Projection Matrix
3186 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3187 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3188 glPushMatrix(); // Store The Modelview Matrix
3189 glLoadIdentity(); // Reset The Modelview Matrix
3192 //Draw world, draw map
3193 glTranslatef(2,-5,0);
3195 if(j>6&&j<nummenuitems-1)
3197 XYZ linestart,lineend,offset;
3204 //float linestartx,lineendx,linestarty,lineendy,offsetx,offsety;
3205 linestart.x=(startx[j]+endx[j])/2;
3206 linestart.y=(starty[j]+endy[j])/2;
3207 if(j>=6+accountactive->getCampaignChoicesMade()){
3208 linestart.x=(startx[6+accountactive->getCampaignChoicesMade()]+endx[6+accountactive->getCampaignChoicesMade()])/2;
3209 linestart.y=(starty[6+accountactive->getCampaignChoicesMade()]+endy[6+accountactive->getCampaignChoicesMade()])/2;
3211 lineend.x=(startx[j+1]+endx[j+1])/2;
3212 lineend.y=(starty[j+1]+endy[j+1])/2;
3213 offset=lineend-linestart;
3216 offset=DoRotation(offset,0,0,90);
3218 glDisable(GL_TEXTURE_2D);
3220 if(j<6+accountactive->getCampaignChoicesMade()){
3221 glColor4f(0.5,0,0,1);
3229 linestart+=fac*4*startsize;
3230 lineend-=fac*4*endsize;
3232 if(!(j>7+accountactive->getCampaignChoicesMade()+campaignchoicenum)){
3233 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3237 glVertex3f(linestart.x-offset.x*startsize, linestart.y-offset.y*startsize, 0.0f);
3239 glVertex3f(linestart.x+offset.x*startsize, linestart.y+offset.y*startsize, 0.0f);
3241 glVertex3f(lineend.x+offset.x*endsize, lineend.y+offset.y*endsize, 0.0f);
3243 glVertex3f(lineend.x-offset.x*endsize, lineend.y-offset.y*endsize, 0.0f);
3247 glEnable(GL_TEXTURE_2D);
3251 if(j==6)glBindTexture( GL_TEXTURE_2D, Mainmenuitems[7]);
3252 else glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
3253 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
3254 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
3255 if(j-7<accountactive->getCampaignChoicesMade())glColor4f(0.5,0,0,1);
3256 if(j-7>=accountactive->getCampaignChoicesMade())glColor4f(1,0,0,1);
3257 if(j==6)glColor4f(1,1,1,1);
3260 itemsize=abs(startx[j]-endx[j])/2;
3262 midpoint.x=(startx[j]+endx[j])/2;
3263 midpoint.y=(starty[j]+endy[j])/2;
3264 if(j>6&&(j-7<accountactive->getCampaignChoicesMade()))itemsize*=.5;
3265 if(!(j-7>accountactive->getCampaignChoicesMade()+campaignchoicenum))
3267 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
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);
3277 glVertex3f(midpoint.x-itemsize+movex[j]*transition, midpoint.y+itemsize+movey[j]*transition, 0.0f);
3281 //glDisable(GL_ALPHA_TEST);
3282 if(j<4)glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3285 if(1-((float)i)/10-(1-selectedlong[j])>0)
3287 glColor4f(1,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3288 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
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);
3298 glVertex3f(midpoint.x-itemsize-((float)i)*1/2+offsetx[j]*((float)i)/2+movex[j]*transition, midpoint.y+itemsize+((float)i)*1/2+offsety[j]*((float)i)/2+movey[j]*transition, 0.0f);
3306 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3308 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3310 if(j-7>=accountactive->getCampaignChoicesMade()){
3311 text.glPrintOutlined(0.9,0,0,startx[j]+10,starty[j]-4,menustring[j],0,0.6,640,480);
3312 glDisable(GL_DEPTH_TEST);
3318 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3320 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3323 if(mainmenu==1||mainmenu==2)
3324 if(transition<.1||transition>.9){
3325 glClear(GL_DEPTH_BUFFER_BIT);
3326 glEnable(GL_ALPHA_TEST);
3327 glAlphaFunc(GL_GREATER, 0.001f);
3328 glEnable(GL_TEXTURE_2D);
3329 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3330 glDisable(GL_CULL_FACE);
3331 glDisable(GL_LIGHTING);
3333 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3334 glPushMatrix(); // Store The Projection Matrix
3335 glLoadIdentity(); // Reset The Projection Matrix
3336 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3337 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3338 glPushMatrix(); // Store The Modelview Matrix
3339 glLoadIdentity(); // Reset The Modelview Matrix
3341 glDisable(GL_TEXTURE_2D);
3343 glColor4f(1,0,0,1-(transition*10));
3345 glColor4f(1,0,0,1-((1-transition)*10));
3348 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3352 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3353 glPushMatrix(); // Store The Projection Matrix
3354 glLoadIdentity(); // Reset The Projection Matrix
3355 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
3356 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3357 glPushMatrix(); // Store The Modelview Matrix
3358 glLoadIdentity(); // Reset The Modelview Matrix
3359 glTranslatef(screenwidth/2,screenheight/2,0);
3361 glScalef((float)screenwidth/2,(float)screenheight/2,1);
3362 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3364 glEnable(GL_TEXTURE_2D);
3366 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
3367 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
3369 if(!waiting) { // hide the cursor while waiting for a key
3371 glTranslatef(mousecoordh-screenwidth/2,mousecoordv*-1+screenheight/2,0);
3372 glScalef((float)screenwidth/64,(float)screenwidth/64,1);
3373 glTranslatef(1,-1,0);
3374 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3376 glBindTexture( GL_TEXTURE_2D, cursortexture);
3378 //glScalef(.25,.25,.25);
3381 glVertex3f(-1, -1, 0.0f);
3383 glVertex3f(1, -1, 0.0f);
3385 glVertex3f(1, 1, 0.0f);
3387 glVertex3f(-1, 1, 0.0f);
3393 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3399 //printf("Flash amount: %f, delay %i\n", flashamount, flashdelay);
3400 if(flashamount>1)flashamount=1;
3401 if(flashdelay<=0)flashamount-=multiplier;
3403 if(flashamount<0)flashamount=0;
3404 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3405 glDisable(GL_CULL_FACE);
3406 glDisable(GL_LIGHTING);
3407 glDisable(GL_TEXTURE_2D);
3409 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3410 glPushMatrix(); // Store The Projection Matrix
3411 glLoadIdentity(); // Reset The Projection Matrix
3412 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
3413 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3414 glPushMatrix(); // Store The Modelview Matrix
3415 glLoadIdentity(); // Reset The Modelview Matrix
3416 glScalef(screenwidth,screenheight,1);
3417 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3419 glColor4f(flashr,flashg,flashb,flashamount);
3421 glVertex3f(0, 0, 0.0f);
3422 glVertex3f(256, 0, 0.0f);
3423 glVertex3f(256, 256, 0.0f);
3424 glVertex3f(0, 256, 0.0f);
3426 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3427 glPopMatrix(); // Restore The Old Projection Matrix
3428 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3429 glPopMatrix(); // Restore The Old Projection Matrix
3430 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
3431 glEnable(GL_CULL_FACE);
3432 glDisable(GL_BLEND);
3437 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)||(!gameon&&gamestarted)){
3438 tempmult=multiplier;
3443 if ( side == stereoRight || side == stereoCenter ) {
3444 if(drawmode!=motionblurmode||mainmenu){
3449 //myassert(glGetError() == GL_NO_ERROR);
3450 glDrawBuffer(GL_BACK);
3451 glReadBuffer(GL_BACK);
3456 if(drawtoggle==2)drawtoggle=0;
3458 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)){
3459 multiplier=tempmult;
3461 //Jordan fixed your warning!