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 bool gamestarted;
111 extern bool showdamagebar;
114 normalmode, motionblurmode, radialzoommode,
115 realmotionblurmode, doublevisionmode, glowmode,
118 void Game::flash() { // shouldn't be that way, these should be attributes and Person class should not change rendering.
125 /*********************> DrawGLScene() <*****/
126 int Game::DrawGLScene(StereoSide side)
128 static float texcoordwidth,texcoordheight;
129 static float texviewwidth, texviewheight;
131 static GLubyte color;
132 static XYZ checkpoint;
133 static float tempmult;
135 static char string[256]="";
136 static char string2[256]="";
137 static char string3[256]="";
139 if ( stereomode == stereoAnaglyph ) {
141 case stereoLeft: glColorMask( 0.0, 1.0, 1.0, 1.0 ); break;
142 case stereoRight: glColorMask( 1.0, 0.0, 0.0, 1.0 ); break;
145 glColorMask( 1.0, 1.0, 1.0, 1.0 );
147 if ( stereomode == stereoHorizontalInterlaced || stereomode == stereoVerticalInterlaced ) {
148 glStencilFunc(side == stereoLeft ? GL_NOTEQUAL : GL_EQUAL, 0x01, 0x01);
152 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)){
159 numboundaries=mapradius*2;
160 if(numboundaries>360)numboundaries=360;
161 for(i=0;i<numboundaries;i++){
164 boundary[i]=mapcenter+DoRotation(boundary[i]*mapradius,0,i*(360/((float)(numboundaries))),0);
173 olddrawmode=drawmode;
174 if(ismotionblur&&!loading){
175 if((findLengthfast(&player[0].velocity)>200)&&velocityblur&&!cameramode){
176 drawmode=motionblurmode;
177 motionbluramount=200/(findLengthfast(&player[0].velocity));
180 if(player[0].damage-player[0].superpermanentdamage>(player[0].damagetolerance-player[0].superpermanentdamage)*1/2&&damageeffects&&!cameramode){
181 drawmode=doublevisionmode;
188 drawmode=motionblurmode;
190 slomodelay-=multiplier;
191 if(slomodelay<0)slomo=0;
195 if((!changed&&!slomo)||loading){
197 if(ismotionblur&&(/*fps>100||*/alwaysblur)){
198 if(olddrawmode!=realmotionblurmode)change=1;
200 drawmode=realmotionblurmode;
202 else if(olddrawmode==realmotionblurmode)change=2;
206 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted))drawmode=normalmode;
207 if((freeze||winfreeze)&&ismotionblur&&!mainmenu)drawmode=radialzoommode;
209 if(winfreeze||mainmenu)drawmode=normalmode;
212 if(drawmode==glowmode){
217 DSpContext_FadeGamma(NULL,200,&color2);
221 if(drawtoggle!=2)drawtoggle=1-drawtoggle;
225 texviewwidth=kTextureSize;
226 if(texviewwidth>screenwidth)texviewwidth=screenwidth;
227 texviewheight=kTextureSize;
228 if(texviewheight>screenheight)texviewheight=screenheight;
230 texcoordwidth=screenwidth/kTextureSize;
231 texcoordheight=screenheight/kTextureSize;
232 if(texcoordwidth>1)texcoordwidth=1;
233 if(texcoordheight>1)texcoordheight=1;
236 glDrawBuffer(GL_BACK);
237 glReadBuffer(GL_BACK);
239 if(abs(blurness-targetblurness)<multiplier*10||abs(blurness-targetblurness)>2){
240 blurness=targetblurness;
241 targetblurness=(float)(abs(Random()%100))/40;
243 if(blurness<targetblurness)
244 blurness+=multiplier*5;
246 blurness-=multiplier*5;
249 static XYZ terrainlight;
250 static float distance;
251 if(drawmode==normalmode)ReSizeGLScene(90,.1f);
252 if(drawmode!=normalmode)glViewport(0,0,texviewwidth,texviewheight);
253 glDepthFunc(GL_LEQUAL);
255 glAlphaFunc(GL_GREATER, 0.0001f);
256 glEnable(GL_ALPHA_TEST);
257 glClearColor(0.25f, 0.25f, 0.25f, 1.0f);
258 glClear(GL_DEPTH_BUFFER_BIT);
260 glMatrixMode (GL_MODELVIEW);
261 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
264 // Move the camera for the current eye's point of view.
265 // Reverse the movement if we're reversing stereo
266 glTranslatef((stereoseparation/2) * side * (stereoreverse ? -1 : 1), 0, 0);
268 if(!cameramode&&!freeze&&!winfreeze){
269 glRotatef(float(Random()%100)/10*camerashake/*+(woozy*woozy)/10*/,0,0,1);
270 glRotatef(rotation2+sin(woozy/2)*(player[0].damage/player[0].damagetolerance)*5,1,0,0);
271 glRotatef(rotation+sin(woozy)*(player[0].damage/player[0].damagetolerance)*5,0,1,0);
273 if(cameramode||freeze||winfreeze){
274 glRotatef(rotation2,1,0,0);
275 glRotatef(rotation,0,1,0);
278 if(environment==desertenvironment){
279 glRotatef((float)(abs(Random()%100))/3000-1,1,0,0);
280 glRotatef((float)(abs(Random()%100))/3000-1,0,1,0);
282 SetUpLight(&light,0);
284 if(environment==desertenvironment&&detail==2)glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, blurness+.4 );
285 if(environment==desertenvironment){
286 glRotatef((float)(abs(Random()%100))/1000,1,0,0);
287 glRotatef((float)(abs(Random()%100))/1000,0,1,0);
290 glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0);
292 glTranslatef(-viewer.x,-viewer.y,-viewer.z);
293 frustum.GetFrustum();
297 static float size,opacity,rotation;
299 for(k=0;k<numplayers;k++){
300 if(!player[k].skeleton.free&&player[k].playerdetail&&player[k].howactive<typesleeping)
301 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)
302 for(i=0;i<player[k].skeleton.num_joints;i++){
303 if(player[k].skeleton.joints[i].label==leftknee||player[k].skeleton.joints[i].label==rightknee||player[k].skeleton.joints[i].label==groin){
304 point=DoRotation(player[k].skeleton.joints[i].position,0,player[k].rotation,0)*player[k].scale+player[k].coords;
306 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;
307 if(k!=0&&tutoriallevel==1){
308 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;
310 terrain.MakeDecal(shadowdecal,point,size,opacity,rotation);
311 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
312 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
313 if(objects.position[j].y<player[k].coords.y||objects.type[j]==tunneltype||objects.type[j]==weirdtype){
314 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);
317 if(k!=0&&tutoriallevel==1){
318 opacity=.2+.2*sin(smoketex*6+i);
320 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
325 if((player[k].skeleton.free||player[k].howactive>=typesleeping)&&player[k].playerdetail)
326 if(frustum.SphereInFrustum(player[k].coords.x,player[k].coords.y,player[k].coords.z,player[k].scale*5)&&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||player[k].skeleton.joints[i].label==leftelbow||player[k].skeleton.joints[i].label==rightelbow||player[k].skeleton.joints[i].label==neck){
329 if(player[k].skeleton.free)point=player[k].skeleton.joints[i].position*player[k].scale+player[k].coords;
330 else point=DoRotation(player[k].skeleton.joints[i].position,0,player[k].rotation,0)*player[k].scale+player[k].coords;
332 opacity=.4-player[k].skeleton.joints[i].position.y*player[k].scale/5-(player[k].coords.y-terrain.getHeight(player[k].coords.x,player[k].coords.z))/5;
333 if(k!=0&&tutoriallevel==1){
334 opacity=.2+.2*sin(smoketex*6+i)-player[k].skeleton.joints[i].position.y*player[k].scale/5-(player[k].coords.y-terrain.getHeight(player[k].coords.x,player[k].coords.z))/10;
336 terrain.MakeDecal(shadowdecal,point,size,opacity*.7,rotation);
337 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
338 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
339 if(objects.position[j].y<player[k].coords.y||objects.type[j]==tunneltype||objects.type[j]==weirdtype){
340 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);
341 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);
344 if(k!=0&&tutoriallevel==1){
345 opacity=.2+.2*sin(smoketex*6+i);
347 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
353 if(!player[k].playerdetail)
354 if(frustum.SphereInFrustum(player[k].coords.x,player[k].coords.y,player[k].coords.z,player[k].scale*5))
356 point=player[k].coords;
358 opacity=.4-(player[k].coords.y-terrain.getHeight(player[k].coords.x,player[k].coords.z))/5;
359 terrain.MakeDecal(shadowdecal,point,size,opacity*.7,rotation);
360 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
361 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
362 point=DoRotation(player[k].coords-objects.position[j],0,-objects.rotation[j],0);
365 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
371 glEnable(GL_TEXTURE_2D);
373 glEnable(GL_DEPTH_TEST);
374 glEnable(GL_CULL_FACE);
376 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
377 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
378 glBindTexture( GL_TEXTURE_2D, terraintexture);
380 glBindTexture( GL_TEXTURE_2D, terraintexture2);
382 //glBindTexture( GL_TEXTURE_2D, terraintexture3);
383 //glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
386 terrain.drawdecals();
389 glEnable(GL_CULL_FACE);
390 glEnable(GL_LIGHTING);
392 glEnable(GL_TEXTURE_2D);
395 glEnable(GL_COLOR_MATERIAL);
410 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
411 glEnable(GL_CULL_FACE);
412 glCullFace(GL_FRONT);
414 for(k=0;k<numplayers;k++){
415 if(k==0||tutoriallevel!=1){
417 glEnable(GL_LIGHTING);
418 terrainlight=terrain.getLighting(player[k].coords.x,player[k].coords.z);
419 distance=findDistancefast(&viewer,&player[k].coords);
420 distance=(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance;
421 glColor4f(terrainlight.x,terrainlight.y,terrainlight.z,distance);
422 if(distance>=1)glDisable(GL_BLEND);
424 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;
426 if(!player[k].occluded==0)i=checkcollide(viewer,checkpoint,player[k].lastoccluded);
427 if(i==-1||player[k].occluded==0)i=checkcollide(viewer,checkpoint);
429 player[k].occluded+=1;
430 player[k].lastoccluded=i;
432 else player[k].occluded=0;
433 if(player[k].occluded<25)player[k].DrawSkeleton();
439 if(!cameramode&&musictype==stream_fighttheme)playerdist=findDistancefastflat(&player[0].coords,&viewer);
440 else playerdist=-100;
443 glEnable(GL_TEXTURE_2D);
448 if(frustum.SphereInFrustum(realhawkcoords.x+hawk.boundingspherecenter.x,realhawkcoords.y+hawk.boundingspherecenter.y,realhawkcoords.z+hawk.boundingspherecenter.z,2)){
449 glAlphaFunc(GL_GREATER, 0.0001f);
451 glDisable(GL_CULL_FACE);
452 glDisable(GL_LIGHTING);
454 glTranslatef(hawkcoords.x,hawkcoords.y,hawkcoords.z);
455 glRotatef(hawkrotation,0,1,0);
456 glTranslatef(25,0,0);
457 distance=findDistancefast(&viewer,&realhawkcoords)*1.2;
458 glColor4f(light.color[0],light.color[1],light.color[2],(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance);
459 if((viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance>1)glColor4f(light.color[0],light.color[1],light.color[2],1);
460 if((viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance>0)
461 hawk.drawdifftex(hawktexture);
465 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
466 glEnable(GL_CULL_FACE);
467 glCullFace(GL_FRONT);
469 for(k=0;k<numplayers;k++){
470 if(!(k==0||tutoriallevel!=1)){
472 glEnable(GL_LIGHTING);
473 terrainlight=terrain.getLighting(player[k].coords.x,player[k].coords.z);
474 distance=findDistancefast(&viewer,&player[k].coords);
475 distance=(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance;
476 glColor4f(terrainlight.x,terrainlight.y,terrainlight.z,distance);
477 if(distance>=1)glDisable(GL_BLEND);
479 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;
481 if(!player[k].occluded==0)i=checkcollide(viewer,checkpoint,player[k].lastoccluded);
482 if(i==-1||player[k].occluded==0)i=checkcollide(viewer,checkpoint);
484 player[k].occluded+=1;
485 player[k].lastoccluded=i;
487 else player[k].occluded=0;
488 if(player[k].occluded<25)player[k].DrawSkeleton();
494 glEnable(GL_TEXTURE_2D);
499 glDisable(GL_COLOR_MATERIAL);
501 glDisable(GL_LIGHTING);
502 glDisable(GL_TEXTURE_2D);
510 glDisable(GL_LIGHTING);
511 glDisable(GL_TEXTURE_2D);
512 glDisable(GL_COLOR_MATERIAL);
515 for(k=0;k<numplayers;k++){
516 if(player[k].numwaypoints>1){
517 glBegin(GL_LINE_LOOP);
518 for(i=0;i<player[k].numwaypoints;i++){
519 glVertex3f(player[k].waypoints[i].x,player[k].waypoints[i].y+.5,player[k].waypoints[i].z);
528 for(k=0;k<numpathpoints;k++){
529 if(numpathpointconnect[k]){
530 for(i=0;i<numpathpointconnect[k];i++){
531 glBegin(GL_LINE_LOOP);
532 glVertex3f(pathpoint[k].x,pathpoint[k].y+.5,pathpoint[k].z);
533 glVertex3f(pathpoint[pathpointconnect[k][i]].x,pathpoint[pathpointconnect[k][i]].y+.5,pathpoint[pathpointconnect[k][i]].z);
541 glVertex3f(pathpoint[pathpointselected].x,pathpoint[pathpointselected].y+.5,pathpoint[pathpointselected].z);
548 glEnable(GL_TEXTURE_2D);
549 glColor4f(.5,.5,.5,1);
551 sprintf (string, " ",(int)(fps));
552 text.glPrint(10,30,string,0,.8,screenwidth,screenheight);
555 if(bonus>0&&bonustime<1&&!winfreeze&&indialogue==-1/*bonustime<4*/){
556 const char *bonus_name;
557 if (bonus < bonus_count)
558 bonus_name = bonus_names[bonus];
560 bonus_name = "Excellent!"; // When does this happen?
562 glColor4f(0,0,0,1-bonustime);
563 text.glPrintOutline(1024/2-10*strlen(bonus_name)-4,768/16-4+768*4/5,bonus_name,1,2.5,1024,768);
564 glColor4f(1,0,0,1-bonustime);
565 text.glPrint(1024/2-10*strlen(bonus_name),768/16+768*4/5,bonus_name,1,2,1024,768);
567 sprintf (string, "%d",(int)bonusvalue);
568 glColor4f(0,0,0,1-bonustime);
569 text.glPrintOutline(1024/2-10*strlen(string)-4,768/16-4-20+768*4/5,string,1,2.5*.8,1024,768);
570 glColor4f(1,0,0,1-bonustime);
571 text.glPrint(1024/2-10*strlen(string),768/16-20+768*4/5,string,1,2*.8,1024,768);
572 glColor4f(.5,.5,.5,1);
575 if(tutoriallevel==1){
576 tutorialopac=tutorialmaxtime-tutorialstagetime;
577 if(tutorialopac>1)tutorialopac=1;
578 if(tutorialopac<0)tutorialopac=0;
580 sprintf (string, " ");
581 sprintf (string2, " ");
582 sprintf (string3, " ");
583 if(tutorialstage==0){
584 sprintf (string, " ");
585 sprintf (string2, " ");
586 sprintf (string3, " ");
588 if(tutorialstage==1){
589 sprintf (string, "Welcome to the Lugaru training level!");
590 sprintf (string2, " ");
591 sprintf (string3, " ");
593 if(tutorialstage==2){
594 sprintf (string, "BASIC MOVEMENT:");
595 sprintf (string2, " ");
596 sprintf (string3, " ");
598 if(tutorialstage==3){
599 sprintf (string, "You can move the mouse to rotate the camera.");
600 sprintf (string2, " ");
601 sprintf (string3, " ");
603 if(tutorialstage==4){
604 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));
605 sprintf (string2, "All movement is relative to the camera.");
606 sprintf (string3, " ");
608 if(tutorialstage==5){
609 sprintf (string, "Please press %s to jump.",Input::keyToChar(jumpkey));
610 sprintf (string2, "You can hold it longer to jump higher.");
611 sprintf (string3, " ");
613 if(tutorialstage==6){
614 sprintf (string, "You can press %s to crouch.",Input::keyToChar(crouchkey));
615 sprintf (string2, "You can jump higher from a crouching position.");
616 sprintf (string3, " ");
618 if(tutorialstage==7){
619 sprintf (string, "While running, you can press %s to roll.",Input::keyToChar(crouchkey));
620 sprintf (string2, " ");
621 sprintf (string3, " ");
623 if(tutorialstage==8){
624 sprintf (string, "While crouching, you can sneak around silently");
625 sprintf (string2, "using the movement keys.");
626 sprintf (string3, " ");
628 if(tutorialstage==9){
629 sprintf (string, "Release the crouch key while sneaking and hold the movement keys");
630 sprintf (string2, "to run animal-style.");
631 sprintf (string3, " ");
633 if(tutorialstage==10){
634 sprintf (string, "ADVANCED MOVEMENT:");
635 sprintf (string2, " ");
636 sprintf (string3, " ");
638 if(tutorialstage==11){
639 sprintf (string, "When you jump at a wall, you can hold %s again",Input::keyToChar(jumpkey));
640 sprintf (string2, "during impact to perform a walljump.");
641 sprintf (string3, "Be sure to use the movement keys to press against the wall");
643 if(tutorialstage==12){
644 sprintf (string, "While in the air, you can press crouch to flip.",Input::keyToChar(jumpkey));
645 sprintf (string2, "Walljumps and flips confuse enemies and give you more control.");
646 sprintf (string3, " ");
648 if(tutorialstage==13){
649 sprintf (string, "BASIC COMBAT:");
650 sprintf (string2, " ");
651 sprintf (string3, " ");
653 if(tutorialstage==14){
654 sprintf (string, "There is now an imaginary enemy");
655 sprintf (string2, "in the middle of the training area.");
656 sprintf (string3, " ");
658 if(tutorialstage==15){
659 if(attackkey==MOUSEBUTTON1)sprintf (string, "Click to attack when you are near an enemy.");
660 else sprintf (string, "Press %s to attack when you are near an enemy.",Input::keyToChar(attackkey));
661 sprintf (string2, "You can punch by standing still near an enemy and attacking.");
662 sprintf (string3, " ");
664 if(tutorialstage==16){
665 sprintf (string, "If you are close, you will perform a weak punch.");
666 sprintf (string2, "The weak punch is excellent for starting attack combinations.");
667 sprintf (string3, " ");
669 if(tutorialstage==17){
670 sprintf (string, "Attacking while running results in a spin kick.");
671 sprintf (string2, "This is one of your most powerful ground attacks.");
672 sprintf (string3, " ");
674 if(tutorialstage==18){
675 sprintf (string, "Sweep the enemy's legs out by attacking while crouched.");
676 sprintf (string2, "This is a very fast attack, and easy to follow up.");
677 sprintf (string3, " ");
679 if(tutorialstage==19){
680 sprintf (string, "When an enemy is on the ground, you can deal some extra");
681 sprintf (string2, "damage by running up and drop-kicking him.");
682 sprintf (string3, "(Try knocking them down with a sweep first)");
684 if(tutorialstage==20){
685 sprintf (string, "Your most powerful individual attack is the rabbit kick.");
686 if(attackkey==MOUSEBUTTON1)sprintf (string2, "Run at the enemy while holding the mouse button, and press");
687 else sprintf (string2, "Run at the enemy while holding %s, and press", Input::keyToChar(attackkey));
688 sprintf (string3, "the jump key (%s) to attack.",Input::keyToChar(jumpkey));
690 if(tutorialstage==21){
691 sprintf (string, "This attack is devastating if timed correctly.");
692 sprintf (string2, "Even if timed incorrectly, it will knock the enemy over.");
693 if(againbonus)sprintf (string3, "Try rabbit-kicking the imaginary enemy again.");
694 else sprintf (string3, "Try rabbit-kicking the imaginary enemy.");
696 if(tutorialstage==22){
697 sprintf (string, "If you sneak behind an enemy unnoticed, you can kill");
698 sprintf (string2, "him instantly. Move close behind this enemy");
699 sprintf (string3, "and attack.");
701 if(tutorialstage==23){
702 sprintf (string, "Another important attack is the wall kick. When an enemy");
703 sprintf (string2, "is near a wall, perform a walljump nearby and hold");
704 sprintf (string3, "the attack key during impact with the wall.");
706 if(tutorialstage==24){
707 sprintf (string, "You can tackle enemies by running at them animal-style");
708 if(attackkey==MOUSEBUTTON1)sprintf (string2, "and pressing jump (%s) or attack(mouse button).",Input::keyToChar(jumpkey));
709 else sprintf (string2, "and pressing jump (%s) or attack(%s).",Input::keyToChar(jumpkey),Input::keyToChar(attackkey));
710 sprintf (string3, "This is especially useful when they are running away.");
712 if(tutorialstage==25){
713 sprintf (string, "Dodge by pressing back and attack. Dodging is essential");
714 sprintf (string2, "against enemies with swords or other long weapons.");
715 sprintf (string3, " ");
717 if(tutorialstage==26){
718 sprintf (string, "REVERSALS AND COUNTER-REVERSALS");
719 sprintf (string2, " ");
720 sprintf (string3, " ");
722 if(tutorialstage==27){
723 sprintf (string, "The enemy can now reverse your attacks.");
724 sprintf (string2, " ");
725 sprintf (string3, " ");
727 if(tutorialstage==28){
728 sprintf (string, "If you attack, you will notice that the enemy now sometimes");
729 sprintf (string2, "catches your attack and uses it against you. Hold");
730 sprintf (string3, "crouch (%s) after attacking to escape from reversals.",Input::keyToChar(crouchkey));
732 if(tutorialstage==29){
733 sprintf (string, "Try escaping from two more reversals in a row.");
734 sprintf (string2, " ");
735 sprintf (string3, " ");
737 if(tutorialstage==30){
738 sprintf (string, "Good!");
739 sprintf (string2, " ");
740 sprintf (string3, " ");
742 if(tutorialstage==31){
743 sprintf (string, "To reverse an attack, you must tap crouch (%s) during the",Input::keyToChar(crouchkey));
744 sprintf (string2, "enemy's attack. You must also be close to the enemy;");
745 sprintf (string3, "this is especially important against armed opponents.");
747 if(tutorialstage==32){
748 sprintf (string, "The enemy can attack in %d seconds.", (int)(tutorialmaxtime-tutorialstagetime));
749 sprintf (string2, "This imaginary opponents attacks will be highlighted");
750 sprintf (string3, "to make this easier.");
752 if(tutorialstage==33){
753 sprintf (string, "Reverse three enemy attacks!");
754 sprintf (string2, " ");
755 sprintf (string3, " ");
757 if(tutorialstage==34){
758 sprintf (string, "Reverse two more enemy attacks!");
759 sprintf (string2, " ");
760 sprintf (string3, " ");
762 if(tutorialstage==35){
763 sprintf (string, "Reverse one more enemy attack!");
764 sprintf (string2, " ");
765 sprintf (string3, " ");
767 if(tutorialstage==36){
768 sprintf (string, "Excellent!");
769 sprintf (string2, " ");
770 sprintf (string3, " ");
772 if(tutorialstage==37){
773 sprintf (string, "Now spar with the enemy for %d more seconds.", (int)(tutorialmaxtime-tutorialstagetime));
774 sprintf (string2, "Damage dealt: %d",(int)damagedealt);
775 sprintf (string3, "Damage taken: %d.",(int)damagetaken);
777 if(tutorialstage==38){
778 sprintf (string, "WEAPONS:");
779 sprintf (string2, " ");
780 sprintf (string3, " ");
782 if(tutorialstage==39){
783 sprintf (string, "There is now an imaginary knife");
784 sprintf (string2, "in the center of the training area.");
785 sprintf (string3, " ");
787 if(tutorialstage==40){
788 sprintf (string, "Stand, roll or handspring over the knife");
789 sprintf (string2, "while pressing %s to pick it up.",Input::keyToChar(throwkey));
790 sprintf (string3, "You can crouch and press the same key to drop it again.");
792 if(tutorialstage==41){
793 sprintf (string, "You can equip and unequip weapons using the %s key.",Input::keyToChar(drawkey));
794 sprintf (string2, "Sometimes it is best to keep them unequipped to");
795 sprintf (string3, "prevent enemies from taking them. ");
797 if(tutorialstage==42){
798 sprintf (string, "The knife is the smallest weapon and the least encumbering.");
799 sprintf (string2, "You can equip or unequip it while standing, crouching,");
800 sprintf (string3, "running or flipping.");
802 if(tutorialstage==43){
803 sprintf (string, "You perform weapon attacks the same way as unarmed attacks,");
804 sprintf (string2, "but sharp weapons cause permanent damage, instead of the");
805 sprintf (string3, "temporary trauma from blunt weapons, fists and feet.");
807 if(tutorialstage==44){
808 sprintf (string, "The enemy now has your knife!");
809 sprintf (string2, "Please reverse two of his knife attacks.");
810 sprintf (string3, " ");
812 if(tutorialstage==45){
813 sprintf (string, "Please reverse one more of his knife attacks.");
814 sprintf (string2, " ");
815 sprintf (string3, " ");
817 if(tutorialstage==46){
818 sprintf (string, "Now he has a sword!");
819 sprintf (string2, "The sword has longer reach than your arms, so you");
820 sprintf (string3, "must move close to reverse the sword slash.");
822 if(tutorialstage==47){
823 sprintf (string, "Long weapons like the sword and staff are also useful for defense;");
824 sprintf (string2, "you can parry enemy weapon attacks by pressing the attack key");
825 sprintf (string3, "at the right time. Please try parrying the enemy's attacks!");
827 if(tutorialstage==48){
828 sprintf (string, "The staff is like the sword, but has two main attacks.");
829 sprintf (string2, "The standing smash is fast and effective, and the running");
830 sprintf (string3, "spin smash is slower and more powerful.");
832 if(tutorialstage==49){
833 sprintf (string, "When facing an enemy, you can throw the knife with %s.",Input::keyToChar(throwkey));
834 sprintf (string2, "It is possible to throw the knife while flipping,");
835 sprintf (string3, "but it is very inaccurate.");
837 if(tutorialstage==50){
838 sprintf (string, "You now know everything you can learn from training.");
839 sprintf (string2, "Everything else you must learn from experience!");
840 sprintf (string3, " ");
842 if(tutorialstage==51){
843 sprintf (string, "Walk out of the training area to return to the main menu.");
844 sprintf (string2, " ");
845 sprintf (string3, " ");
848 glColor4f(0,0,0,tutorialopac);
849 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);
850 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);
851 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);
852 glColor4f(1,1,1,tutorialopac);
853 text.glPrint(screenwidth/2-7.6*strlen(string)*screenwidth/1024,screenheight/16+screenheight*4/5,string,1,1.5*screenwidth/1024,screenwidth,screenheight);
854 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);
855 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);
857 sprintf (string, "Press 'tab' to skip to the next item.",Input::keyToChar(jumpkey));
858 sprintf (string2, "Press escape at any time to");
859 sprintf (string3, "pause or exit the tutorial.");
862 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);
863 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);
864 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);
865 glColor4f(0.5,0.5,0.5,1);
866 text.glPrint(screenwidth/2-7.6*strlen(string)*screenwidth/1024*.8,0+screenheight*1/10,string,1,1.5*screenwidth/1024*.8,screenwidth,screenheight);
867 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);
868 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);
872 if(numhotspots&&(bonustime>=1||bonus<=0||bonustime<0)&&!tutoriallevel){
874 float closestdist=-1;
876 closest=currenthotspot;
877 for(i=0;i<numhotspots;i++){
878 distance=findDistancefast(&player[0].coords,&hotspot[i]);
879 if(closestdist==-1||distance<closestdist){
880 if(findDistancefast(&player[0].coords,&hotspot[i])<hotspotsize[i]&&((hotspottype[i]<=10&&hotspottype[i]>=0)||(hotspottype[i]<=40&&hotspottype[i]>=20))){
881 closestdist=distance;
887 currenthotspot=closest;
888 if(currenthotspot!=-1){
889 if(hotspottype[closest]<=10){
890 if(findDistancefast(&player[0].coords,&hotspot[closest])<hotspotsize[closest])
893 tutorialopac=tutorialmaxtime-tutorialstagetime;
894 if(tutorialopac>1)tutorialopac=1;
895 if(tutorialopac<0)tutorialopac=0;
897 sprintf (string, "%s", hotspottext[closest]);
904 if(string[i]=='\n'||string[i]>'z'||string[i]<' '||string[i]=='\0'){
905 glColor4f(0,0,0,tutorialopac);
906 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);
907 glColor4f(1,1,1,tutorialopac);
908 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);
911 if(string[i]=='\0')done=1;
917 else if (hotspottype[closest]>=20&&dialoguegonethrough[hotspottype[closest]-20]==0){
918 whichdialogue=hotspottype[closest]-20;
919 for(j=0;j<numdialogueboxes[whichdialogue];j++){
920 player[participantfocus[whichdialogue][j]].coords=participantlocation[whichdialogue][participantfocus[whichdialogue][j]];
921 player[participantfocus[whichdialogue][j]].rotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
922 player[participantfocus[whichdialogue][j]].targetrotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
923 player[participantfocus[whichdialogue][j]].velocity=0;
924 player[participantfocus[whichdialogue][j]].targetanimation=player[participantfocus[whichdialogue][j]].getIdle();
925 player[participantfocus[whichdialogue][j]].targetframe=0;
929 dialoguegonethrough[whichdialogue]++;
930 if(dialogueboxsound[whichdialogue][indialogue]!=0){
932 if(dialogueboxsound[whichdialogue][indialogue]==1)whichsoundplay=rabbitchitter;
933 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
934 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
935 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
936 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
937 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
938 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
939 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
940 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
941 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
942 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
943 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
944 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
945 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
946 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
947 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
948 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
949 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
950 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
951 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
952 emit_sound_at(whichsoundplay, player[participantfocus[whichdialogue][indialogue]].coords);
958 if(indialogue!=-1&&!mainmenu){
959 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
960 glDisable(GL_CULL_FACE);
961 glDisable(GL_LIGHTING);
962 glDisable(GL_TEXTURE_2D);
964 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
965 glPushMatrix(); // Store The Projection Matrix
966 glLoadIdentity(); // Reset The Projection Matrix
967 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
968 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
969 glPushMatrix(); // Store The Modelview Matrix
970 glLoadIdentity(); // Reset The Modelview Matrix
971 if(dialogueboxlocation[whichdialogue][indialogue]==1)glTranslatef(0,screenheight*3/4,0);
972 glScalef(screenwidth,screenheight/4,1);
973 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
976 glColor4f(dialogueboxcolor[whichdialogue][indialogue][0],dialogueboxcolor[whichdialogue][indialogue][1],dialogueboxcolor[whichdialogue][indialogue][2],0.7);
978 glVertex3f(0, 0, 0.0f);
979 glVertex3f(1, 0, 0.0f);
980 glVertex3f(1, 1, 0.0f);
981 glVertex3f(0, 1, 0.0f);
983 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
984 glPopMatrix(); // Restore The Old Projection Matrix
985 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
986 glPopMatrix(); // Restore The Old Projection Matrix
987 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
988 glEnable(GL_CULL_FACE);
991 glEnable(GL_TEXTURE_2D);
998 startx=screenwidth*1/5;
999 if(dialogueboxlocation[whichdialogue][indialogue]==1)starty=screenheight/16+screenheight*4/5;
1000 if(dialogueboxlocation[whichdialogue][indialogue]==2)starty=screenheight*1/5-screenheight/16;
1009 for(i=0;i<(int)strlen(dialoguename[whichdialogue][indialogue]);i++){
1010 tempname[tempnum]=dialoguename[whichdialogue][indialogue][i];
1012 if(dialoguename[whichdialogue][indialogue][i]=='#'||dialoguename[whichdialogue][indialogue][i]=='\0')goodchar=0;
1016 tempname[tempnum]='\0';
1019 sprintf (string, "%s: ", tempname);
1021 if(dialogueboxcolor[whichdialogue][indialogue][0]+dialogueboxcolor[whichdialogue][indialogue][1]+dialogueboxcolor[whichdialogue][indialogue][2]<1.5){
1022 glColor4f(0,0,0,tutorialopac);
1023 text.glPrintOutline(startx-2*7.6*strlen(string)*screenwidth/1024-4,starty-4,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight);
1024 glColor4f(0.7,0.7,0.7,tutorialopac);
1025 text.glPrint(startx-2*7.6*strlen(string)*screenwidth/1024,starty,string,1,1.5*screenwidth/1024,screenwidth,screenheight);
1029 glColor4f(0,0,0,tutorialopac);
1030 text.glPrintOutline(startx-2*7.6*strlen(string)*screenwidth/1024-4,starty-4,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight);
1034 for(i=0;i<(int)strlen(dialoguetext[whichdialogue][indialogue])+1;i++){
1035 tempname[tempnum]=dialoguetext[whichdialogue][indialogue][i];
1036 if(dialoguetext[whichdialogue][indialogue][i]!='#')tempnum++;
1039 sprintf (string, "%s", tempname);
1046 if(string[i]=='\n'||string[i]>'z'||string[i]<' '||string[i]=='\0'){
1047 if(dialogueboxcolor[whichdialogue][indialogue][0]+dialogueboxcolor[whichdialogue][indialogue][1]+dialogueboxcolor[whichdialogue][indialogue][2]<1.5){
1048 glColor4f(0,0,0,tutorialopac);
1049 text.glPrintOutline(startx/*-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);
1050 glColor4f(1,1,1,tutorialopac);
1051 text.glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/,starty-20*screenwidth/1024*line,string,1,1.5*screenwidth/1024,screenwidth,screenheight,lastline,i);
1055 glColor4f(0,0,0,tutorialopac);
1056 text.glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/,starty-20*screenwidth/1024*line,string,1,1.5*screenwidth/1024,screenwidth,screenheight,lastline,i);
1060 if(string[i]=='\0')done=1;
1067 if(!tutoriallevel&&!winfreeze&&indialogue==-1&&!mainmenu){
1070 sprintf (string, "Score: %d", (int)accountactive->getCampaignScore());
1072 sprintf (string, "Score: %d", (int)accountactive->getCampaignScore()+(int)bonustotal);
1074 if(!campaign)sprintf (string, "Score: %d", (int)bonustotal);
1076 text.glPrintOutline(1024/40-4,768/16-4+768*14/16,string,1,1.5*1.25,1024,768);
1078 text.glPrint(1024/40,768/16+768*14/16,string,1,1.5,1024,768);
1080 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1081 glDisable(GL_CULL_FACE);
1082 glDisable(GL_LIGHTING);
1083 glDisable(GL_TEXTURE_2D);
1085 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1086 glPushMatrix(); // Store The Projection Matrix
1087 glLoadIdentity(); // Reset The Projection Matrix
1088 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1089 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1090 glPushMatrix(); // Store The Modelview Matrix
1091 glLoadIdentity(); // Reset The Modelview Matrix
1092 glTranslatef(15,screenheight*17.5/20,0);
1093 glScalef(screenwidth/3+20,screenheight/20,1);
1094 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1096 glColor4f(0.0,0.4,0.0,0.7);
1097 float bar=((float)player[0].damage)/player[0].damagetolerance;
1099 glVertex3f((bar<1?bar:1),0,0.0f);
1100 glVertex3f(1,0,0.0f);
1101 glVertex3f(1,1,0.0f);
1102 glVertex3f((bar<1?bar:1),1,0.0f);
1104 glColor4f(0.1,0.0,0.0,1);
1105 bar = ((float)player[0].bloodloss)/player[0].damagetolerance;
1107 glVertex3f(0,0,0.0f);
1108 glVertex3f((bar<1?bar:1),0,0.0f);
1109 glVertex3f((bar<1?bar:1),1,0.0f);
1110 glVertex3f(0,1,0.0f);
1112 glColor4f(0.4,0.0,0.0,0.7);
1113 bar = ((float)player[0].damage)/player[0].damagetolerance;
1115 glVertex3f(0,0,0.0f);
1116 glVertex3f((bar<1?bar:1),0,0.0f);
1117 glVertex3f((bar<1?bar:1),1,0.0f);
1118 glVertex3f(0,1,0.0f);
1120 glColor4f(0.4,0.0,0.0,0.7);
1121 bar = ((float)player[0].permanentdamage)/player[0].damagetolerance;
1123 glVertex3f(0,0,0.0f);
1124 glVertex3f((bar<1?bar:1),0,0.0f);
1125 glVertex3f((bar<1?bar:1),1,0.0f);
1126 glVertex3f(0,1,0.0f);
1128 glColor4f(0.4,0.0,0.0,0.7);
1129 bar = ((float)player[0].superpermanentdamage)/player[0].damagetolerance;
1131 glVertex3f(0,0,0.0f);
1132 glVertex3f((bar<1?bar:1),0,0.0f);
1133 glVertex3f((bar<1?bar:1),1,0.0f);
1134 glVertex3f(0,1,0.0f);
1136 glColor4f(0.0,0.0,0.0,0.7);
1138 glBegin(GL_LINE_STRIP);
1139 glVertex3f(0,0,0.0f);
1140 glVertex3f(1,0,0.0f);
1141 glVertex3f(1,1,0.0f);
1142 glVertex3f(0,1,0.0f);
1143 glVertex3f(0,0,0.0f);
1146 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1147 glPopMatrix(); // Restore The Old Projection Matrix
1148 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1149 glPopMatrix(); // Restore The Old Projection Matrix
1150 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1151 glEnable(GL_CULL_FACE);
1152 glDisable(GL_BLEND);
1154 glEnable(GL_TEXTURE_2D);
1156 // writing the numbers :
1157 sprintf (string, "Damages : %d/%d (%d)",(int)(player[0].damage),(int)(player[0].damagetolerance),(int)(player[0].bloodloss));
1159 text.glPrintOutline(1024/40-4,768/16-4+768*14/16-40,string,1,1.5*1.25,1024,768);
1161 text.glPrint(1024/40,768/16+768*14/16-40,string,1,1.5,1024,768);
1165 glColor4f(.5,.5,.5,1);
1168 if((texttoggle||editorenabled)&&debugmode&&!mainmenu){
1169 sprintf (string, "The framespersecond is %d.",(int)(fps));
1170 text.glPrint(10,30,string,0,.8,1024,768);
1172 sprintf (string, "Name: %s", registrationname);
1173 text.glPrint(10,260,string,0,.8,1024,768);
1177 sprintf (string, "Map editor enabled.");
1179 sprintf (string, "Map editor disabled.");
1180 text.glPrint(10,60,string,0,.8,1024,768);
1182 sprintf (string, "Object size: %f",editorsize);
1183 text.glPrint(10,75,string,0,.8,1024,768);
1184 if(editorrotation>=0)sprintf (string, "Object rotation: %f",editorrotation);
1185 else sprintf (string, "Object rotation: Random");
1186 text.glPrint(10,90,string,0,.8,1024,768);
1187 if(editorrotation2>=0)sprintf (string, "Object rotation2: %f",editorrotation2);
1188 else sprintf (string, "Object rotation2: Random");
1189 text.glPrint(10,105,string,0,.8,1024,768);
1190 sprintf (string, "Object type: %d",editortype);
1191 text.glPrint(10,120,string,0,.8,1024,768);
1192 switch(editortype) {
1194 sprintf (string, "(box)");
1197 sprintf (string, "(tree)");
1200 sprintf (string, "(wall)");
1203 sprintf (string, "(weird)");
1206 sprintf (string, "(spike)");
1209 sprintf (string, "(rock)");
1212 sprintf (string, "(bush)");
1215 sprintf (string, "(tunnel)");
1218 sprintf (string, "(chimney)");
1221 sprintf (string, "(platform)");
1224 sprintf (string, "(cool)");
1227 sprintf (string, "(fire)");
1230 text.glPrint(130,120,string,0,.8,1024,768);
1232 sprintf (string, "Numplayers: %d",numplayers);
1233 text.glPrint(10,155,string,0,.8,1024,768);
1234 sprintf (string, "Player %d: numwaypoints: %d",numplayers,player[numplayers-1].numwaypoints);
1235 text.glPrint(10,140,string,0,.8,1024,768);
1237 sprintf (string, "Difficulty: %d",difficulty);
1238 text.glPrint(10,240,string,0,.8,1024,768);
1243 if(drawmode==glowmode){
1244 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1245 glDisable(GL_CULL_FACE);
1246 glDisable(GL_LIGHTING);
1247 glDisable(GL_TEXTURE_2D);
1249 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1250 glPushMatrix(); // Store The Projection Matrix
1251 glLoadIdentity(); // Reset The Projection Matrix
1252 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1253 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1254 glPushMatrix(); // Store The Modelview Matrix
1255 glLoadIdentity(); // Reset The Modelview Matrix
1256 glScalef(screenwidth,screenheight,1);
1257 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1259 glColor4f(0,0,0,.5);
1261 glVertex3f(0, 0, 0.0f);
1262 glVertex3f(256, 0, 0.0f);
1263 glVertex3f(256, 256, 0.0f);
1264 glVertex3f(0, 256, 0.0f);
1266 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1267 glPopMatrix(); // Restore The Old Projection Matrix
1268 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1269 glPopMatrix(); // Restore The Old Projection Matrix
1270 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1271 glEnable(GL_CULL_FACE);
1272 glDisable(GL_BLEND);
1276 if((((blackout&&damageeffects)||(player[0].bloodloss>0&&damageeffects&&player[0].blooddimamount>0)||player[0].dead)&&!cameramode)||console){
1277 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1278 glDisable(GL_CULL_FACE);
1279 glDisable(GL_LIGHTING);
1280 glDisable(GL_TEXTURE_2D);
1282 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1283 glPushMatrix(); // Store The Projection Matrix
1284 glLoadIdentity(); // Reset The Projection Matrix
1285 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1286 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1287 glPushMatrix(); // Store The Modelview Matrix
1288 glLoadIdentity(); // Reset The Modelview Matrix
1289 glScalef(screenwidth,screenheight,1);
1290 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1292 if(player[0].dead)blackout+=multiplier*3;
1293 if(player[0].dead==1)blackout=.4f;
1294 if(player[0].dead==2&&blackout>.6)blackout=.6;
1295 glColor4f(0,0,0,blackout);
1296 if(!player[0].dead){
1297 if((player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5))*.3<.3){
1298 glColor4f(0,0,0,player[0].blooddimamount*player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5)*.3);
1299 blackout=player[0].blooddimamount*player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5)*.3;
1302 glColor4f(0,0,0,player[0].blooddimamount*.3);
1303 blackout=player[0].blooddimamount*.3;
1306 if(console)glColor4f(.7,0,0,.2);
1308 glVertex3f(0, 0, 0.0f);
1309 glVertex3f(256, 0, 0.0f);
1310 glVertex3f(256, 256, 0.0f);
1311 glVertex3f(0, 256, 0.0f);
1313 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1314 glPopMatrix(); // Restore The Old Projection Matrix
1315 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1316 glPopMatrix(); // Restore The Old Projection Matrix
1317 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1318 glEnable(GL_CULL_FACE);
1319 glDisable(GL_BLEND);
1323 if(flashamount>0&&damageeffects){
1324 if(flashamount>1)flashamount=1;
1325 if(flashdelay<=0)flashamount-=multiplier;
1327 if(flashamount<0)flashamount=0;
1328 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1329 glDisable(GL_CULL_FACE);
1330 glDisable(GL_LIGHTING);
1332 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1333 glPushMatrix(); // Store The Projection Matrix
1334 glLoadIdentity(); // Reset The Projection Matrix
1335 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1336 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1337 glPushMatrix(); // Store The Modelview Matrix
1338 glLoadIdentity(); // Reset The Modelview Matrix
1339 glScalef(screenwidth,screenheight,1);
1340 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1342 glColor4f(flashr,flashg,flashb,flashamount);
1344 glVertex3f(0, 0, 0.0f);
1345 glVertex3f(256, 0, 0.0f);
1346 glVertex3f(256, 256, 0.0f);
1347 glVertex3f(0, 256, 0.0f);
1349 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1350 glPopMatrix(); // Restore The Old Projection Matrix
1351 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1352 glPopMatrix(); // Restore The Old Projection Matrix
1353 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1354 glEnable(GL_CULL_FACE);
1355 glDisable(GL_BLEND);
1361 glEnable(GL_TEXTURE_2D);
1364 sprintf (string, " ]");
1365 text.glPrint(10,30+screenheight-330,string,0,1,screenwidth,screenheight);
1367 sprintf (string, "_");
1368 text.glPrint(30+(float)(displayselected)*10,30+(screenheight-330),string,0,1,screenwidth,screenheight);
1372 if((i!=0||chatting)&&displaytime[i]<4)
1373 for(j=0;j<displaychars[i];j++){
1374 glColor4f(1,1,1,4-displaytime[i]);
1375 if(j<displaychars[i]){
1376 sprintf (string, "%c",displaytext[i][j]);
1377 text.glPrint(30+j*10,30+i*20+(screenheight-330),string,0,1,screenwidth,screenheight);
1383 if(minimap&&indialogue==-1){
1384 float mapviewdist = 20000;
1386 glDisable(GL_DEPTH_TEST);
1387 glColor3f (1.0, 1.0, 1.0); // no coloring
1389 glEnable(GL_TEXTURE_2D);
1390 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1391 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1392 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1393 glDisable(GL_CULL_FACE);
1394 glDisable(GL_LIGHTING);
1396 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1397 glPushMatrix(); // Store The Projection Matrix
1398 glLoadIdentity(); // Reset The Projection Matrix
1399 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1400 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1401 glPushMatrix(); // Store The Modelview Matrix
1402 glLoadIdentity(); // Reset The Modelview Matrix
1403 glScalef((float)screenwidth/2,(float)screenwidth/2,1);
1404 glTranslatef(1.75,.25,0);
1405 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1413 int numliveplayers=0;
1415 for(i=0;i<numplayers;i++){
1416 if(!player[i].dead) numliveplayers++;
1421 for(i=0;i<objects.numobjects;i++){
1422 if(objects.type[i]==treetrunktype||objects.type[i]==boxtype){
1423 center+=objects.position[i];
1427 for(i=0;i<numplayers;i++){
1428 if(!player[i].dead)center+=player[i].coords;
1430 center/=numadd+numliveplayers;
1432 center=player[0].coords;
1434 float maxdistance=0;
1436 //~ int whichclosest;
1437 for(i=0;i<objects.numobjects;i++){
1438 tempdist=findDistancefast(¢er,&objects.position[i]);
1439 if(tempdist>maxdistance){
1441 maxdistance=tempdist;
1444 for(i=0;i<numplayers;i++){
1445 if(!player[i].dead){
1446 tempdist=findDistancefast(¢er,&player[i].coords);
1447 if(tempdist>maxdistance){
1449 maxdistance=tempdist;
1453 radius=fast_sqrt(maxdistance);
1457 glScalef(.25/radius*256*terrain.scale*.4,.25/radius*256*terrain.scale*.4,1);
1459 glScalef(1/(1/radius*256*terrain.scale*.4),1/(1/radius*256*terrain.scale*.4),1);
1461 glRotatef(player[0].lookrotation*-1+180,0,0,1);
1462 glTranslatef(-(center.x/terrain.scale/256*-2+1),(center.z/terrain.scale/256*-2+1),0);
1463 for(i=0;i<objects.numobjects;i++){
1464 if(objects.type[i]==treetrunktype){
1465 distcheck=findDistancefast(&player[0].coords,&objects.position[i]);
1466 if(distcheck<mapviewdist){
1467 glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
1468 glColor4f(0,.3,0,opac*(1-distcheck/mapviewdist));
1470 glTranslatef(objects.position[i].x/terrain.scale/256*-2+1,objects.position[i].z/terrain.scale/256*2-1,0);
1471 glRotatef(objects.rotation[i],0,0,1);
1472 glScalef(.003,.003,.003);
1475 glVertex3f(-1, -1, 0.0f);
1477 glVertex3f(1, -1, 0.0f);
1479 glVertex3f(1, 1, 0.0f);
1481 glVertex3f(-1, 1, 0.0f);
1486 if(objects.type[i]==boxtype){
1487 distcheck=findDistancefast(&player[0].coords,&objects.position[i]);
1488 if(distcheck<mapviewdist){
1489 glBindTexture( GL_TEXTURE_2D, Mapboxtexture);
1490 glColor4f(.4,.4,.4,opac*(1-distcheck/mapviewdist));
1492 glTranslatef(objects.position[i].x/terrain.scale/256*-2+1,objects.position[i].z/terrain.scale/256*2-1,0);
1493 glRotatef(objects.rotation[i],0,0,1);
1494 glScalef(.01*objects.scale[i],.01*objects.scale[i],.01*objects.scale[i]);
1497 glVertex3f(-1, -1, 0.0f);
1499 glVertex3f(1, -1, 0.0f);
1501 glVertex3f(1, 1, 0.0f);
1503 glVertex3f(-1, 1, 0.0f);
1510 glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
1511 for(i=0;i<numboundaries;i++){
1512 glColor4f(0,0,0,opac/3);
1514 glTranslatef(boundary[i].x/terrain.scale/256*-2+1,boundary[i].z/terrain.scale/256*2-1,0);
1515 glScalef(.002,.002,.002);
1518 glVertex3f(-1, -1, 0.0f);
1520 glVertex3f(1, -1, 0.0f);
1522 glVertex3f(1, 1, 0.0f);
1524 glVertex3f(-1, 1, 0.0f);
1529 for(i=0;i<numplayers;i++){
1530 distcheck=findDistancefast(&player[0].coords,&player[i].coords);
1531 if(distcheck<mapviewdist){
1533 glBindTexture( GL_TEXTURE_2D, Maparrowtexture);
1534 if(i==0)glColor4f(1,1,1,opac);
1535 else if(player[i].dead==2||player[i].howactive>typesleeping)glColor4f(0,0,0,opac*(1-distcheck/mapviewdist));
1536 else if(player[i].dead)glColor4f(.3,.3,.3,opac*(1-distcheck/mapviewdist));
1537 else if(player[i].aitype==attacktypecutoff)glColor4f(1,0,0,opac*(1-distcheck/mapviewdist));
1538 else if(player[i].aitype==passivetype)glColor4f(0,1,0,opac*(1-distcheck/mapviewdist));
1539 else glColor4f(1,1,0,1);
1540 glTranslatef(player[i].coords.x/terrain.scale/256*-2+1,player[i].coords.z/terrain.scale/256*2-1,0);
1541 glRotatef(player[i].rotation+180,0,0,1);
1542 glScalef(.005,.005,.005);
1545 glVertex3f(-1, -1, 0.0f);
1547 glVertex3f(1, -1, 0.0f);
1549 glVertex3f(1, 1, 0.0f);
1551 glVertex3f(-1, 1, 0.0f);
1557 glDisable(GL_TEXTURE_2D);
1558 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1559 glPopMatrix(); // Restore The Old Projection Matrix
1560 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1561 glPopMatrix(); // Restore The Old Projection Matrix
1562 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1563 glEnable(GL_CULL_FACE);
1564 glDisable(GL_BLEND);
1568 if(loading&&!stealthloading&&(!campaign||player[0].dead)){
1569 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1570 glDisable(GL_CULL_FACE);
1571 glDisable(GL_LIGHTING);
1572 glDisable(GL_TEXTURE_2D);
1574 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1575 glPushMatrix(); // Store The Projection Matrix
1576 glLoadIdentity(); // Reset The Projection Matrix
1577 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1578 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1579 glPushMatrix(); // Store The Modelview Matrix
1580 glLoadIdentity(); // Reset The Modelview Matrix
1581 glScalef(screenwidth,screenheight,1);
1582 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1584 glColor4f(0,0,0,.7);
1586 glVertex3f(0, 0, 0.0f);
1587 glVertex3f(256, 0, 0.0f);
1588 glVertex3f(256, 256, 0.0f);
1589 glVertex3f(0, 256, 0.0f);
1591 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1592 glPopMatrix(); // Restore The Old Projection Matrix
1593 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1594 glPopMatrix(); // Restore The Old Projection Matrix
1595 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1596 glEnable(GL_CULL_FACE);
1597 glDisable(GL_BLEND);
1601 glDisable(GL_DEPTH_TEST);
1602 glColor3f (1.0, 1.0, 1.0); // no coloring
1604 glEnable(GL_TEXTURE_2D);
1609 glEnable(GL_TEXTURE_2D);
1611 sprintf (string, "Loading...");
1612 text.glPrint(1024/2-90,768/2,string,1,2,1024,768);
1615 //if(ismotionblur)drawmode=motionblurmode;
1616 drawmode=normalmode;
1619 if(winfreeze&&!campaign){
1620 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1621 glDisable(GL_CULL_FACE);
1622 glDisable(GL_LIGHTING);
1623 glDisable(GL_TEXTURE_2D);
1625 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1626 glPushMatrix(); // Store The Projection Matrix
1627 glLoadIdentity(); // Reset The Projection Matrix
1628 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1629 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1630 glPushMatrix(); // Store The Modelview Matrix
1631 glLoadIdentity(); // Reset The Modelview Matrix
1632 glScalef(screenwidth,screenheight,1);
1633 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1635 glColor4f(0,0,0,.4);
1637 glVertex3f(0, 0, 0.0f);
1638 glVertex3f(256, 0, 0.0f);
1639 glVertex3f(256, 256, 0.0f);
1640 glVertex3f(0, 256, 0.0f);
1642 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1643 glPopMatrix(); // Restore The Old Projection Matrix
1644 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1645 glPopMatrix(); // Restore The Old Projection Matrix
1646 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1647 glEnable(GL_CULL_FACE);
1648 glDisable(GL_BLEND);
1652 glDisable(GL_DEPTH_TEST);
1653 glColor3f (1.0, 1.0, 1.0); // no coloring
1655 glEnable(GL_TEXTURE_2D);
1657 //Win Screen Won Victory
1659 glEnable(GL_TEXTURE_2D);
1661 sprintf (string, "Level Cleared!");
1662 text.glPrintOutlined(1024/2-strlen(string)*10,768*7/8,string,1,2,1024,768);
1664 sprintf (string, "Score: %d",(int)(bonustotal-startbonustotal));
1665 text.glPrintOutlined(1024/30,768*6/8,string,1,2,1024,768);
1668 sprintf (string, "Press Escape or Space to continue");
1670 sprintf (string, "Press Escape to return to menu or Space to continue");
1671 text.glPrintOutlined(640/2-strlen(string)*5,480*1/16,string,1,1,640,480);
1675 for(i=0;i<255;i++)string[i]='\0';
1676 sprintf (temp, "Time: %d:",(int)(((int)leveltime-(int)(leveltime)%60)/60));
1677 strcat(string,temp);
1678 if((int)(leveltime)%60<10)strcat(string,"0");
1679 sprintf (temp, "%d",(int)(leveltime)%60);
1680 strcat(string,temp);
1681 text.glPrintOutlined(1024/30,768*6/8-40,string,1,2,1024,768);
1684 int awards[award_count];
1685 int numawards = award_awards(awards);
1687 for (i = 0; i < numawards && i < 6; i++)
1688 text.glPrintOutlined(1024/30,768*6/8-90-40*i,award_names[awards[i]],1,2,1024,768);
1691 if(drawmode!=normalmode){
1692 glEnable(GL_TEXTURE_2D);
1694 if(!drawtoggle||drawmode!=realmotionblurmode||(drawtoggle==2||change==1)){
1697 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
1698 GLfloat subtractColor[4] = { 0.5, 0.5, 0.5, 0.0 };
1699 glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, subtractColor);
1700 //glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_SUBTRACT);
1701 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE);
1702 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_CONSTANT_EXT);
1703 glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 2.0f);
1705 glBindTexture( GL_TEXTURE_2D, screentexture);
1706 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1709 if((drawtoggle||change==1)&&drawmode==realmotionblurmode){
1711 glBindTexture( GL_TEXTURE_2D, screentexture2);
1712 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1714 if(!screentexture2){
1715 glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
1717 glGenTextures( 1, &screentexture2 );
1718 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
1720 glEnable(GL_TEXTURE_2D);
1721 glBindTexture( GL_TEXTURE_2D, screentexture2);
1722 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
1723 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
1725 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
1731 glClear(GL_DEPTH_BUFFER_BIT);
1732 ReSizeGLScene(90,.1f);
1733 glViewport(0,0,screenwidth,screenheight);
1735 if(drawmode!=normalmode){
1736 glDisable(GL_DEPTH_TEST);
1737 if(drawmode==motionblurmode){
1738 glDrawBuffer(GL_FRONT);
1739 glReadBuffer(GL_BACK);
1741 glColor3f (1.0, 1.0, 1.0); // no coloring
1743 glEnable(GL_TEXTURE_2D);
1744 glBindTexture( GL_TEXTURE_2D, screentexture);
1745 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1746 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1747 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1748 glDisable(GL_CULL_FACE);
1749 glDisable(GL_LIGHTING);
1751 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1752 glPushMatrix(); // Store The Projection Matrix
1753 glLoadIdentity(); // Reset The Projection Matrix
1754 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1755 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1756 glPushMatrix(); // Store The Modelview Matrix
1757 glLoadIdentity(); // Reset The Modelview Matrix
1758 glScalef((float)screenwidth/2,(float)screenheight/2,1);
1759 glTranslatef(1,1,0);
1760 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1762 if(drawmode==motionblurmode){
1763 if(motionbluramount<.2)motionbluramount=.2;
1764 //glColor4f(1,1,1,fast_sqrt(multiplier)*2.9*motionbluramount);
1765 glColor4f(1,1,1,motionbluramount);
1769 glVertex3f(-1, -1, 0.0f);
1770 glTexCoord2f(texcoordwidth,0);
1771 glVertex3f(1, -1, 0.0f);
1772 glTexCoord2f(texcoordwidth,texcoordheight);
1773 glVertex3f(1, 1, 0.0f);
1774 glTexCoord2f(0,texcoordheight);
1775 glVertex3f(-1, 1, 0.0f);
1779 if(drawmode==realmotionblurmode){
1780 glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
1781 glClear(GL_COLOR_BUFFER_BIT);
1782 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
1783 glBindTexture( GL_TEXTURE_2D, screentexture);
1784 glColor4f(1,1,1,.5);
1788 glVertex3f(-1, -1, 0.0f);
1789 glTexCoord2f(texcoordwidth,0);
1790 glVertex3f(1, -1, 0.0f);
1791 glTexCoord2f(texcoordwidth,texcoordheight);
1792 glVertex3f(1, 1, 0.0f);
1793 glTexCoord2f(0,texcoordheight);
1794 glVertex3f(-1, 1, 0.0f);
1797 glBindTexture( GL_TEXTURE_2D, screentexture2);
1798 glColor4f(1,1,1,.5);
1802 glVertex3f(-1, -1, 0.0f);
1803 glTexCoord2f(texcoordwidth,0);
1804 glVertex3f(1, -1, 0.0f);
1805 glTexCoord2f(texcoordwidth,texcoordheight);
1806 glVertex3f(1, 1, 0.0f);
1807 glTexCoord2f(0,texcoordheight);
1808 glVertex3f(-1, 1, 0.0f);
1811 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1813 if(drawmode==doublevisionmode){
1814 static float crosseyedness;
1815 crosseyedness=abs(player[0].damage-player[0].superpermanentdamage-(player[0].damagetolerance-player[0].superpermanentdamage)*1/2)/30;
1816 if(crosseyedness>1)crosseyedness=1;
1817 if(crosseyedness<0)crosseyedness=0;
1819 glDisable(GL_BLEND);
1824 glVertex3f(-1, -1, 0.0f);
1825 glTexCoord2f(texcoordwidth,0);
1826 glVertex3f(1, -1, 0.0f);
1827 glTexCoord2f(texcoordwidth,texcoordheight);
1828 glVertex3f(1, 1, 0.0f);
1829 glTexCoord2f(0,texcoordheight);
1830 glVertex3f(-1, 1, 0.0f);
1834 glColor4f(1,1,1,.5);
1837 glTranslatef(.015*crosseyedness,0,0);
1841 glVertex3f(-1, -1, 0.0f);
1842 glTexCoord2f(texcoordwidth,0);
1843 glVertex3f(1, -1, 0.0f);
1844 glTexCoord2f(texcoordwidth,texcoordheight);
1845 glVertex3f(1, 1, 0.0f);
1846 glTexCoord2f(0,texcoordheight);
1847 glVertex3f(-1, 1, 0.0f);
1852 if(drawmode==glowmode){
1853 glColor4f(.5,.5,.5,.5);
1855 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
1857 glTranslatef(.01,0,0);
1860 glVertex3f(-1, -1, 0.0f);
1861 glTexCoord2f(texcoordwidth,0);
1862 glVertex3f(1, -1, 0.0f);
1863 glTexCoord2f(texcoordwidth,texcoordheight);
1864 glVertex3f(1, 1, 0.0f);
1865 glTexCoord2f(0,texcoordheight);
1866 glVertex3f(-1, 1, 0.0f);
1870 glTranslatef(-.01,0,0);
1873 glVertex3f(-1, -1, 0.0f);
1874 glTexCoord2f(texcoordwidth,0);
1875 glVertex3f(1, -1, 0.0f);
1876 glTexCoord2f(texcoordwidth,texcoordheight);
1877 glVertex3f(1, 1, 0.0f);
1878 glTexCoord2f(0,texcoordheight);
1879 glVertex3f(-1, 1, 0.0f);
1883 glTranslatef(.0,.01,0);
1886 glVertex3f(-1, -1, 0.0f);
1887 glTexCoord2f(texcoordwidth,0);
1888 glVertex3f(1, -1, 0.0f);
1889 glTexCoord2f(texcoordwidth,texcoordheight);
1890 glVertex3f(1, 1, 0.0f);
1891 glTexCoord2f(0,texcoordheight);
1892 glVertex3f(-1, 1, 0.0f);
1896 glTranslatef(0,-.01,0);
1899 glVertex3f(-1, -1, 0.0f);
1900 glTexCoord2f(texcoordwidth,0);
1901 glVertex3f(1, -1, 0.0f);
1902 glTexCoord2f(texcoordwidth,texcoordheight);
1903 glVertex3f(1, 1, 0.0f);
1904 glTexCoord2f(0,texcoordheight);
1905 glVertex3f(-1, 1, 0.0f);
1909 if(drawmode==radialzoommode){
1911 //glRotatef((float)i*.1,0,0,1);
1912 glColor4f(1,1,1,1/((float)i+1));
1914 glScalef(1+(float)i*.01,1+(float)i*.01,1);
1917 glVertex3f(-1, -1, 0.0f);
1918 glTexCoord2f(texcoordwidth,0);
1919 glVertex3f(1, -1, 0.0f);
1920 glTexCoord2f(texcoordwidth,texcoordheight);
1921 glVertex3f(1, 1, 0.0f);
1922 glTexCoord2f(0,texcoordheight);
1923 glVertex3f(-1, 1, 0.0f);
1928 glDisable(GL_TEXTURE_2D);
1929 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1930 glPopMatrix(); // Restore The Old Projection Matrix
1931 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1932 glPopMatrix(); // Restore The Old Projection Matrix
1933 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1934 glEnable(GL_CULL_FACE);
1935 glDisable(GL_BLEND);
1940 glEnable(GL_TEXTURE_2D);
1943 if(consoleselected>=60)
1944 offset=consoleselected-60;
1945 sprintf (string, " ]");
1946 text.glPrint(10,30,string,0,1,1024,768);
1948 sprintf (string, "_");
1949 text.glPrint(30+(float)(consoleselected)*10-offset*10,30,string,0,1,1024,768);
1952 for(j=0;j<consolechars[i];j++){
1953 glColor4f(1,1,1,1-(float)(i)/16);
1954 if(j<consolechars[i]){
1955 sprintf (string, "%c",consoletext[i][j]);
1956 text.glPrint(30+j*10-offset*10,30+i*20,string,0,1,1024,768);
1963 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)){
1964 multiplier=tempmult;
1971 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)){
1972 tempmult=multiplier;
1977 if ( side == stereoRight || side == stereoCenter ) {
1978 if(drawmode!=motionblurmode||mainmenu){
1983 //myassert(glGetError() == GL_NO_ERROR);
1984 glDrawBuffer(GL_BACK);
1985 glReadBuffer(GL_BACK);
1990 if(drawtoggle==2)drawtoggle=0;
1992 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)){
1993 multiplier=tempmult;
1995 //Jordan fixed your warning!
1999 void Game::LoadCampaign() {
2002 ifstream ipstream(ConvertFileName((":Data:Campaigns:"+accountactive->getCurrentCampaign()+".txt").c_str()));
2003 ipstream.ignore(256,':');
2004 ipstream >> campaignnumlevels;
2005 for(int i=0;i<campaignnumlevels;i++) {
2006 ipstream.ignore(256,':');
2007 ipstream.ignore(256,':');
2008 ipstream.ignore(256,' ');
2009 ipstream >> campaignmapname[i];
2010 ipstream.ignore(256,':');
2011 ipstream >> campaigndescription[i];
2012 for(int j=0;j<256;j++){
2013 if(campaigndescription[i][j]=='_')campaigndescription[i][j]=' ';
2015 ipstream.ignore(256,':');
2016 ipstream >> campaignchoosenext[i];
2017 ipstream.ignore(256,':');
2018 ipstream >> campaignnumnext[i];
2019 for(int j=0;j<campaignnumnext[i];j++){
2020 ipstream.ignore(256,':');
2021 ipstream >> campaignnextlevel[i][j];
2022 campaignnextlevel[i][j]-=1;
2024 ipstream.ignore(256,':');
2025 ipstream >> campaignlocationx[i];
2026 ipstream.ignore(256,':');
2027 ipstream >> campaignlocationy[i];
2031 for(int i=0;i<campaignnumlevels;i++){
2033 levelhighlight[i]=0;
2038 for(int i=0;i<accountactive->getCampaignChoicesMade();i++){
2039 levelorder[i+1]=campaignnextlevel[levelorder[i]][accountactive->getCampaignChoice(i)];
2040 levelvisible[levelorder[i+1]]=1;
2042 int whichlevelstart = accountactive->getCampaignChoicesMade()-1;
2043 if(whichlevelstart<0){
2044 accountactive->setCampaignScore(0);
2045 accountactive->resetFasttime();
2046 campaignchoicenum=1;
2047 campaignchoicewhich[0]=0;
2051 campaignchoicenum=campaignnumnext[levelorder[whichlevelstart]];
2052 for(int i=0;i<campaignchoicenum;i++){
2053 campaignchoicewhich[i]=campaignnextlevel[levelorder[whichlevelstart]][i];
2054 levelvisible[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
2055 levelhighlight[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
2060 void Game::DrawMenu()
2063 static float lastcheck;
2065 lastcheck+=multiplier;
2067 // !!! FIXME: hack: clamp framerate in menu so text input works correctly on fast systems.
2070 glDrawBuffer(GL_BACK);
2071 glReadBuffer(GL_BACK);
2072 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
2073 ReSizeGLScene(90,.1f);
2076 temptexdetail=texdetail;
2077 if(texdetail>2)texdetail=2;
2078 if(mainmenu!=oldmainmenu&&oldmainmenu!=0){
2080 LoadTexture(":Data:Textures:Newgame.png",&Mainmenuitems[1],0,0);
2081 LoadTexture(":Data:Textures:Quit.png",&Mainmenuitems[3],0,0);
2084 LoadTexture(":Data:Textures:Resume.png",&Mainmenuitems[1],0,0);
2085 LoadTexture(":Data:Textures:Endgame.png",&Mainmenuitems[3],0,0);
2088 if(lastcheck>.5||oldmainmenu!=mainmenu){
2097 texdetail=temptexdetail;
2099 oldmainmenu=mainmenu;
2101 if(mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==8||mainmenu==9||mainmenu==10||mainmenu==18){
2102 glClear(GL_DEPTH_BUFFER_BIT);
2103 glEnable(GL_ALPHA_TEST);
2104 glAlphaFunc(GL_GREATER, 0.001f);
2105 glEnable(GL_TEXTURE_2D);
2106 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
2107 glDisable(GL_CULL_FACE);
2108 glDisable(GL_LIGHTING);
2110 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2111 glPushMatrix(); // Store The Projection Matrix
2112 glLoadIdentity(); // Reset The Projection Matrix
2113 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
2114 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2115 glPushMatrix(); // Store The Modelview Matrix
2116 glLoadIdentity(); // Reset The Modelview Matrix
2117 glTranslatef(screenwidth/2,screenheight/2,0);
2119 glScalef((float)screenwidth/2,(float)screenheight/2,1);
2120 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
2121 glDisable(GL_BLEND);
2122 glColor4f(0,0,0,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 glDisable(GL_TEXTURE_2D);
2127 //glScalef(.25,.25,.25);
2130 glVertex3f(-1, -1, 0.0f);
2132 glVertex3f(1, -1, 0.0f);
2134 glVertex3f(1, 1, 0.0f);
2136 glVertex3f(-1, 1, 0.0f);
2140 glColor4f(0.4,0.4,0.4,1.0);
2141 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2142 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2143 glEnable(GL_TEXTURE_2D);
2144 glBindTexture( GL_TEXTURE_2D, Mainmenuitems[4]);
2146 //glScalef(.25,.25,.25);
2149 glVertex3f(-1, -1, 0.0f);
2151 glVertex3f(1, -1, 0.0f);
2153 glVertex3f(1, 1, 0.0f);
2155 glVertex3f(-1, 1, 0.0f);
2160 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2162 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2166 if((float)newscreenwidth>(float)newscreenheight*1.61||(float)newscreenwidth<(float)newscreenheight*1.59)sprintf (menustring[0], "Resolution: %d*%d",(int)newscreenwidth,(int)newscreenheight);
2167 else sprintf (menustring[0], "Resolution: %d*%d (widescreen)",(int)newscreenwidth,(int)newscreenheight);
2170 endx[0]=startx[0]+strlen(menustring[0])*10;
2171 endy[0]=starty[0]+20;
2173 if(newdetail==2)sprintf (menustring[1], "Detail: High");
2174 else if(newdetail==1)sprintf (menustring[1], "Detail: Medium");
2175 else sprintf (menustring[1], "Detail: Low");
2178 endx[1]=startx[1]+strlen(menustring[1])*10;
2179 endy[1]=starty[1]+20;
2181 if(bloodtoggle==2)sprintf (menustring[2], "Blood: On, high detail (slower)");
2182 if(bloodtoggle==1)sprintf (menustring[2], "Blood: On, low detail");
2183 if(bloodtoggle==0)sprintf (menustring[2], "Blood: Off");
2186 endx[2]=startx[2]+strlen(menustring[2])*10;
2187 endy[2]=starty[2]+20;
2189 if(difficulty==2)sprintf (menustring[3], "Difficulty: Insane");
2190 if(difficulty==1)sprintf (menustring[3], "Difficulty: Difficult");
2191 if(difficulty==0)sprintf (menustring[3], "Difficulty: Easier");
2192 startx[3]=10+20-1000;
2194 endx[3]=startx[3]+strlen(menustring[3])*10;
2195 endy[3]=starty[3]+20;
2197 if(ismotionblur==1)sprintf (menustring[4], "Blur Effects: Enabled (less compatible)");
2198 if(ismotionblur==0)sprintf (menustring[4], "Blur Effects: Disabled (more compatible)");
2201 endx[4]=startx[4]+strlen(menustring[4])*10;
2202 endy[4]=starty[4]+20;
2204 if(decals==1)sprintf (menustring[5], "Decals: Enabled (slower)");
2205 if(decals==0)sprintf (menustring[5], "Decals: Disabled");
2208 endx[5]=startx[5]+strlen(menustring[5])*10;
2209 endy[5]=starty[5]+20;
2211 if(musictoggle==1)sprintf (menustring[6], "Music: Enabled");
2212 if(musictoggle==0)sprintf (menustring[6], "Music: Disabled");
2215 endx[6]=startx[6]+strlen(menustring[6])*10;
2216 endy[6]=starty[6]+20;
2218 if(invertmouse==1)sprintf (menustring[9], "Invert mouse: Yes");
2219 if(invertmouse==0)sprintf (menustring[9], "Invert mouse: No");
2222 endx[9]=startx[9]+strlen(menustring[9])*10;
2223 endy[9]=starty[9]+20;
2225 sprintf (menustring[10], "Mouse Speed: %d", (int)(usermousesensitivity*5));
2228 endx[10]=startx[10]+strlen(menustring[10])*10;
2229 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;
2237 sprintf (menustring[13], "Damage Bar: %s",(showdamagebar?"on":"off"));
2240 endx[13]=startx[13]+strlen(menustring[13])*10;
2241 endy[13]=starty[13]+20;
2243 sprintf (menustring[7], "-Configure Controls-");
2246 endx[7]=startx[7]+strlen(menustring[7])*10;
2247 endy[7]=starty[7]+20;
2249 sprintf (menustring[12], "-Configure Stereo -");
2252 endx[12]=startx[12]+strlen(menustring[7])*10;
2253 endy[12]=starty[12]+20;
2255 if(newdetail==detail&&newscreenheight==(int)screenheight&&newscreenwidth==(int)screenwidth)sprintf (menustring[8], "Back");
2256 else sprintf (menustring[8], "Back (some changes take effect next time Lugaru is opened)");
2258 endx[8]=startx[8]+strlen(menustring[8])*10;
2260 endy[8]=starty[8]+20;
2265 if(keyselect!=0)sprintf (menustring[0], "Forwards: %s",Input::keyToChar(forwardkey));
2266 else sprintf (menustring[0], "Forwards: _");
2269 endx[0]=startx[0]+strlen(menustring[0])*10;
2270 endy[0]=starty[0]+20;
2272 if(keyselect!=1)sprintf (menustring[1], "Back: %s",Input::keyToChar(backkey));
2273 else sprintf (menustring[1], "Back: _");
2276 endx[1]=startx[1]+strlen(menustring[1])*10;
2277 endy[1]=starty[1]+20;
2279 if(keyselect!=2)sprintf (menustring[2], "Left: %s",Input::keyToChar(leftkey));
2280 else sprintf (menustring[2], "Left: _");
2283 endx[2]=startx[2]+strlen(menustring[2])*10;
2284 endy[2]=starty[2]+20;
2286 if(keyselect!=3)sprintf (menustring[3], "Right: %s",Input::keyToChar(rightkey));
2287 else sprintf (menustring[3], "Right: _");
2290 endx[3]=startx[3]+strlen(menustring[3])*10;
2291 endy[3]=starty[3]+20;
2293 if(keyselect!=4)sprintf (menustring[4], "Crouch: %s",Input::keyToChar(crouchkey));
2294 else sprintf (menustring[4], "Crouch: _");
2297 endx[4]=startx[4]+strlen(menustring[4])*10;
2298 endy[4]=starty[4]+20;
2300 if(keyselect!=5)sprintf (menustring[5], "Jump: %s",Input::keyToChar(jumpkey));
2301 else sprintf (menustring[5], "Jump: _");
2304 endx[5]=startx[5]+strlen(menustring[5])*10;
2305 endy[5]=starty[5]+20;
2307 if(keyselect!=6)sprintf (menustring[6], "Draw: %s",Input::keyToChar(drawkey));
2308 else sprintf (menustring[6], "Draw: _");
2311 endx[6]=startx[6]+strlen(menustring[6])*10;
2312 endy[6]=starty[6]+20;
2314 if(keyselect!=7)sprintf (menustring[7], "Throw: %s",Input::keyToChar(throwkey));
2315 else sprintf (menustring[7], "Throw: _");
2318 endx[7]=startx[7]+strlen(menustring[7])*10;
2319 endy[7]=starty[7]+20;
2321 if(keyselect!=8)sprintf (menustring[8], "Attack: %s",Input::keyToChar(attackkey));
2322 else sprintf (menustring[8], "Attack: _");
2325 endx[8]=startx[8]+strlen(menustring[8])*10;
2326 endy[8]=starty[8]+20;
2330 sprintf (menustring[9], "Back");
2332 endx[9]=startx[9]+strlen(menustring[9])*10;
2334 endy[9]=starty[9]+20;
2338 nummenuitems=7+(accountactive?accountactive->getCampaignChoicesMade():0)+campaignchoicenum;
2340 sprintf (menustring[0], "%s",accountactive->getName());
2343 endx[0]=startx[0]+strlen(menustring[0])*10;
2344 endy[0]=starty[0]+20;
2346 sprintf (menustring[1], "Tutorial");
2349 endx[1]=startx[1]+strlen(menustring[1])*10;
2350 endy[1]=starty[1]+20;
2352 sprintf (menustring[2], "Challenge");
2355 endx[2]=startx[2]+strlen(menustring[2])*10;
2356 endy[2]=starty[2]+20;
2358 sprintf (menustring[3], "Delete User");
2361 endx[3]=startx[3]+strlen(menustring[3])*10;
2362 endy[3]=starty[3]+20;
2364 sprintf (menustring[4], "Main Menu");
2367 endx[4]=startx[4]+strlen(menustring[4])*10;
2368 endy[4]=starty[4]+20;
2370 sprintf (menustring[5], "Change User");
2372 endx[5]=startx[5]+strlen(menustring[5])*10;
2374 endy[5]=starty[5]+20;
2378 sprintf (menustring[6], "World");
2380 starty[6]=30+480-400-50;
2381 endx[6]=startx[6]+400;
2384 if((accountactive?accountactive->getCampaignChoicesMade():0)) {
2385 for(i=0;i<(accountactive?accountactive->getCampaignChoicesMade():0);i++) {
2386 sprintf (menustring[7+i], "%s", campaigndescription[levelorder[i]]);
2387 startx[7+i]=30+120+campaignlocationx[levelorder[i]]*400/512;
2388 starty[7+i]=30+30+(512-campaignlocationy[levelorder[i]])*400/512;
2389 endx[7+i]=startx[7+i]+10;
2390 endy[7+i]=starty[7+i]+10;
2394 if(campaignchoicenum>0)
2395 for(i=(accountactive?accountactive->getCampaignChoicesMade():0);i<(accountactive?accountactive->getCampaignChoicesMade():0)+campaignchoicenum;i++){
2396 sprintf (menustring[7+i], "%s", campaigndescription[levelorder[i]]);
2397 startx[7+i]=30+120+campaignlocationx[campaignchoicewhich[i-((accountactive?accountactive->getCampaignChoicesMade():0))]]*400/512;
2398 starty[7+i]=30+30+(512-campaignlocationy[campaignchoicewhich[i-((accountactive?accountactive->getCampaignChoicesMade():0))]])*400/512;
2399 endx[7+i]=startx[7+i]+10;
2400 endy[7+i]=starty[7+i]+10;
2407 sprintf (menustring[0], "Are you sure you want to delete this user?");
2410 endx[0]=startx[0]+strlen(menustring[0])*10;
2411 endy[0]=starty[0]+20;
2413 sprintf (menustring[1], "Yes");
2416 endx[1]=startx[1]+strlen(menustring[1])*10;
2417 endy[1]=starty[1]+20;
2419 sprintf (menustring[2], "No");
2422 endx[2]=startx[2]+strlen(menustring[2])*10;
2423 endy[2]=starty[2]+20;
2425 sprintf (menustring[3], "Extra 4");
2428 endx[3]=startx[3]+strlen(menustring[3])*10;
2429 endy[3]=starty[3]+20;
2431 sprintf (menustring[4], "Extra 5");
2434 endx[4]=startx[4]+strlen(menustring[4])*10;
2435 endy[4]=starty[4]+20;
2437 sprintf (menustring[5], "Back");
2439 endx[5]=startx[5]+strlen(menustring[5])*10;
2441 endy[5]=starty[5]+20;
2445 nummenuitems=Account::getNbAccounts()+2;
2449 if(Account::getNbAccounts()<8)
2450 sprintf (menustring[0], "New User");
2452 sprintf (menustring[0], "No More Users");
2455 endx[0]=startx[0]+strlen(menustring[0])*10;
2456 endy[0]=starty[0]+20;
2463 for(i=0;i<Account::getNbAccounts();i++){
2464 sprintf (menustring[num], "%s",Account::get(i)->getName());
2466 starty[num]=360-20-20*num;
2467 endx[num]=startx[num]+strlen(menustring[num])*10;
2468 endy[num]=starty[num]+20;
2473 sprintf (menustring[num], "Back");
2475 endx[num]=startx[num]+strlen(menustring[num])*10;
2477 endy[num]=starty[num]+20;
2482 sprintf (menustring[0], "Easier");
2485 endx[0]=startx[0]+strlen(menustring[0])*10;
2486 endy[0]=starty[0]+20;
2488 sprintf (menustring[1], "Difficult");
2491 endx[1]=startx[1]+strlen(menustring[1])*10;
2492 endy[1]=starty[1]+20;
2494 sprintf (menustring[2], "Insane");
2497 endx[2]=startx[2]+strlen(menustring[2])*10;
2498 endy[2]=starty[2]+20;
2501 nummenuitems=2+numchallengelevels;
2504 for(j=0;j<numchallengelevels;j++){
2505 for(i=0;i<255;i++)menustring[j][i]='\0';
2506 sprintf (temp, "Level %d",j+1);
2507 strcpy(menustring[j],temp);
2508 for(i=0;i<17;i++)if(menustring[j][i]=='\0')menustring[j][i]=' ';
2509 menustring[j][17]='\0';
2510 sprintf (temp, "%d",(int)accountactive->getHighScore(j));
2511 strcat(menustring[j],temp);
2512 for(i=18;i<32;i++)if(menustring[j][i]=='\0')menustring[j][i]=' ';
2513 menustring[j][32]='\0';
2514 sprintf (temp, "%d:",(int)(((int)accountactive->getFastTime(j)-(int)(accountactive->getFastTime(j))%60)/60));
2515 strcat(menustring[j],temp);
2516 if((int)(accountactive->getFastTime(j))%60<10)strcat(menustring[j],"0");
2517 sprintf (temp, "%d",(int)(accountactive->getFastTime(j))%60);
2518 strcat(menustring[j],temp);
2522 endx[j]=startx[j]+strlen(menustring[j])*10;
2523 endy[j]=starty[j]+20;
2526 sprintf (menustring[numchallengelevels], "Back");
2527 startx[numchallengelevels]=10;
2528 endx[numchallengelevels]=startx[numchallengelevels]+strlen(menustring[numchallengelevels])*10;
2529 starty[numchallengelevels]=10;
2530 endy[numchallengelevels]=starty[numchallengelevels]+20;
2532 sprintf (menustring[numchallengelevels+1], " High Score Best Time");
2533 startx[numchallengelevels+1]=10;
2534 starty[numchallengelevels+1]=440;
2535 endx[numchallengelevels+1]=startx[numchallengelevels+1]+strlen(menustring[numchallengelevels+1])*10;
2536 endy[numchallengelevels+1]=starty[numchallengelevels+1]+20;
2538 //numchallengelevels=tempncl;
2545 sprintf (menustring[0], "Congratulations!");
2548 endx[0]=startx[0]+strlen(menustring[0])*10;
2549 endy[0]=starty[0]+20;
2551 sprintf (menustring[1], "You have avenged your family and");
2554 endx[1]=startx[1]+strlen(menustring[1])*10;
2555 endy[1]=starty[1]+20;
2557 sprintf (menustring[2], "restored peace to the island of Lugaru.");
2560 endx[2]=startx[2]+strlen(menustring[2])*10;
2561 endy[2]=starty[2]+20;
2563 sprintf (menustring[3], "Back");
2565 endx[3]=startx[3]+strlen(menustring[3])*10;
2567 endy[3]=starty[3]+20;
2569 for(i=0;i<255;i++)menustring[4][i]='\0';
2570 sprintf (temp, "Your score:");
2571 strcpy(menustring[4],temp);
2572 for(i=0;i<20;i++)if(menustring[4][i]=='\0')menustring[4][i]=' ';
2573 menustring[4][20]='\0';
2574 sprintf (temp, "%d",(int)accountactive->getCampaignScore());
2575 strcat(menustring[4],temp);
2577 endx[4]=startx[4]+strlen(menustring[4])*10;
2579 endy[4]=starty[4]+20;
2580 for(i=0;i<255;i++)menustring[5][i]='\0';
2581 sprintf (temp, "Highest score:");
2582 strcpy(menustring[5],temp);
2583 for(i=0;i<20;i++)if(menustring[5][i]=='\0')menustring[5][i]=' ';
2584 menustring[5][20]='\0';
2585 sprintf (temp, "%d",(int)accountactive->getCampaignHighScore());
2586 strcat(menustring[5],temp);
2588 endx[5]=startx[5]+strlen(menustring[5])*10;
2590 endy[5]=starty[5]+20;
2594 sprintf (menustring[0], "Stereo mode: %s", StereoModeName(newstereomode));
2597 endx[0]=startx[0]+strlen(menustring[0])*10;
2598 endy[0]=starty[0]+20;
2600 sprintf (menustring[1], "Stereo separation: %.3f", stereoseparation);
2603 endx[1]=startx[1]+strlen(menustring[1])*10;
2604 endy[1]=starty[1]+20;
2606 sprintf (menustring[2], "Reverse stereo: %s", stereoreverse ? "Yes" : "No");
2609 endx[2]=startx[2]+strlen(menustring[2])*10;
2610 endy[2]=starty[2]+20;
2612 sprintf (menustring[3], "Back");
2614 endx[3]=startx[3]+strlen(menustring[3])*10;
2616 endy[3]=starty[3]+20;
2620 if(mainmenu==1||mainmenu==2){
2628 starty[1]=480-152-32;
2633 starty[2]=480-228-32;
2639 starty[3]=480-306-32;
2646 starty[3]=480-306-32;
2655 for(i=0;i<nummenuitems;i++) {
2656 if((mousecoordh/screenwidth*640)>startx[i]&&(mousecoordh/screenwidth*640)<endx[i]&&480-(mousecoordv/screenheight*480)>starty[i]&&480-(mousecoordv/screenheight*480)<endy[i]) {
2657 if(mainmenu!=5) selected=i;
2658 else if( (i!=0) && (i!=6) ) selected=i;
2662 for(i=0;i<nummenuitems;i++){
2664 selectedlong[i]+=multiplier*5;
2665 if(selectedlong[i]>1) selectedlong[i]=1;
2667 selectedlong[i]-=multiplier*5;
2668 if(selectedlong[i]<0) selectedlong[i]=0;
2670 offsetx[i]=(startx[i]+endx[i])/2-(mousecoordh/screenwidth*640);
2671 offsety[i]=(starty[i]+endy[i])/2-(480-(mousecoordv/screenheight*480));
2678 if(mainmenu==1||mainmenu==2){
2679 glClear(GL_DEPTH_BUFFER_BIT);
2680 glEnable(GL_ALPHA_TEST);
2681 glAlphaFunc(GL_GREATER, 0.001f);
2682 glEnable(GL_TEXTURE_2D);
2683 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
2684 glDisable(GL_CULL_FACE);
2685 glDisable(GL_LIGHTING);
2687 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2688 glPushMatrix(); // Store The Projection Matrix
2689 glLoadIdentity(); // Reset The Projection Matrix
2690 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
2691 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2692 glPushMatrix(); // Store The Modelview Matrix
2693 glLoadIdentity(); // Reset The Modelview Matrix
2694 glTranslatef(screenwidth/2,screenheight/2,0);
2696 glScalef((float)screenwidth/2,(float)screenheight/2,1);
2697 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
2698 glDisable(GL_BLEND);
2699 glColor4f(0,0,0,1.0);
2700 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2701 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2702 glDisable(GL_TEXTURE_2D);
2704 //glScalef(.25,.25,.25);
2707 glVertex3f(-1, -1, 0.0f);
2709 glVertex3f(1, -1, 0.0f);
2711 glVertex3f(1, 1, 0.0f);
2713 glVertex3f(-1, 1, 0.0f);
2717 glColor4f(0.4,0.4,0.4,1.0);
2718 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2719 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2720 glEnable(GL_TEXTURE_2D);
2721 glBindTexture( GL_TEXTURE_2D, Mainmenuitems[4]);
2723 //glScalef(.25,.25,.25);
2726 glVertex3f(-1, -1, 0.0f);
2728 glVertex3f(1, -1, 0.0f);
2730 glVertex3f(1, 1, 0.0f);
2732 glVertex3f(-1, 1, 0.0f);
2737 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2740 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2741 glPushMatrix(); // Store The Projection Matrix
2742 glLoadIdentity(); // Reset The Projection Matrix
2743 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
2744 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2745 glPushMatrix(); // Store The Modelview Matrix
2746 glLoadIdentity(); // Reset The Modelview Matrix
2748 glDisable(GL_TEXTURE_2D);
2752 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2754 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2758 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2759 glPushMatrix(); // Store The Projection Matrix
2760 glLoadIdentity(); // Reset The Projection Matrix
2761 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
2762 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2763 glPushMatrix(); // Store The Modelview Matrix
2764 glLoadIdentity(); // Reset The Modelview Matrix
2765 glEnable(GL_TEXTURE_2D);
2766 for(j=0;j<nummenuitems;j++)
2768 //glDisable(GL_BLEND);
2769 glEnable(GL_ALPHA_TEST);
2771 //glDisable(GL_ALPHA_TEST);
2772 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
2773 if(mainmenu==1||mainmenu==2)
2776 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
2777 glBindTexture( GL_TEXTURE_2D, Mainmenuitems[j]);
2778 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
2779 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
2780 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2784 glVertex3f(startx[j], starty[j], 0.0f);
2786 glVertex3f(endx[j], starty[j], 0.0f);
2788 glVertex3f(endx[j], endy[j], 0.0f);
2790 glVertex3f(startx[j], endy[j], 0.0f);
2794 //glDisable(GL_ALPHA_TEST);
2795 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
2798 if(1-((float)i)/10-(1-selectedlong[j])>0)
2800 glColor4f(1,1,1,(1-((float)i)/10-(1-selectedlong[j]))*.25);
2801 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2805 glVertex3f(startx[j]-((float)i)*1/2+offsetx[j]*((float)i)/2, starty[j]-((float)i)*1/2+offsety[j]*((float)i)/2, 0.0f);
2807 glVertex3f(endx[j]+((float)i)*1/2+offsetx[j]*((float)i)/2, starty[j]-((float)i)*1/2+offsety[j]*((float)i)/2, 0.0f);
2809 glVertex3f(endx[j]+((float)i)*1/2+offsetx[j]*((float)i)/2, endy[j]+((float)i)*1/2+offsety[j]*((float)i)/2, 0.0f);
2811 glVertex3f(startx[j]-((float)i)*1/2+offsetx[j]*((float)i)/2, endy[j]+((float)i)*1/2+offsety[j]*((float)i)/2, 0.0f);
2817 if(mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==8||mainmenu==9||mainmenu==10||mainmenu==18)
2819 if(mainmenu!=5||j<6)
2822 if( (mainmenu==9) && j>accountactive->getProgress() && (j<numchallengelevels) )
2823 glColor4f(0.5,0,0,1);
2824 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2826 if(mainmenu!=7||j!=0||!entername)
2827 text.glPrint(startx[j],starty[j],menustring[j],0,1,640,480);
2832 //~ sprintf (string, "_");
2833 text.glPrint(startx[j]+(float)(displayselected)*10,starty[j],string,0,1,640,480);
2835 for(int l=0;l<displaychars[0];l++) {
2836 sprintf (string, "%c",displaytext[0][l]);
2837 text.glPrint(startx[j]+l*10,starty[j],string,0,1,640,480);
2842 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
2845 if(1-((float)i)/15-(1-selectedlong[j])>0)
2847 glColor4f(1,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
2848 if(mainmenu==9&&j>accountactive->getProgress()&&j<numchallengelevels)glColor4f(0.5,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
2849 if(mainmenu==11&&j>accountactive->getProgress()&&j<numchallengelevels)glColor4f(0.5,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
2850 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);
2851 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);
2852 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);
2853 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);
2854 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);
2855 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);
2856 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);
2857 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);
2858 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);
2865 //glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); // black background for the map
2866 glBlendFunc(GL_SRC_ALPHA,GL_ONE); // no background
2869 glClear(GL_DEPTH_BUFFER_BIT);
2870 glEnable(GL_ALPHA_TEST);
2871 glAlphaFunc(GL_GREATER, 0.001f);
2872 glEnable(GL_TEXTURE_2D);
2873 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
2874 glDisable(GL_CULL_FACE);
2875 glDisable(GL_LIGHTING);
2876 if(j==6) glColor4f(1,1,1,1);
2877 else glColor4f(1,0,0,1);ss
2879 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2880 glPushMatrix(); // Store The Projection Matrix
2881 glLoadIdentity(); // Reset The Projection Matrix
2882 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
2883 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2884 glPushMatrix(); // Store The Modelview Matrix
2885 glLoadIdentity(); // Reset The Modelview Matrix
2888 //Draw world, draw map
2889 glTranslatef(2,-5,0);
2891 if(j>6&&j<nummenuitems-1)
2893 XYZ linestart,lineend,offset;
2900 //float linestartx,lineendx,linestarty,lineendy,offsetx,offsety;
2901 linestart.x=(startx[j]+endx[j])/2;
2902 linestart.y=(starty[j]+endy[j])/2;
2903 if(j>=6+(accountactive?accountactive->getCampaignChoicesMade():0)){
2904 linestart.x=(startx[6+(accountactive?accountactive->getCampaignChoicesMade():0)]+endx[6+(accountactive?accountactive->getCampaignChoicesMade():0)])/2;
2905 linestart.y=(starty[6+(accountactive?accountactive->getCampaignChoicesMade():0)]+endy[6+(accountactive?accountactive->getCampaignChoicesMade():0)])/2;
2907 lineend.x=(startx[j+1]+endx[j+1])/2;
2908 lineend.y=(starty[j+1]+endy[j+1])/2;
2909 offset=lineend-linestart;
2912 offset=DoRotation(offset,0,0,90);
2914 glDisable(GL_TEXTURE_2D);
2916 if(j<6+(accountactive?accountactive->getCampaignChoicesMade():0)){
2917 glColor4f(0.5,0,0,1);
2925 linestart+=fac*4*startsize;
2926 lineend-=fac*4*endsize;
2928 if(!(j>7+(accountactive?accountactive->getCampaignChoicesMade():0)+campaignchoicenum)){
2929 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2933 glVertex3f(linestart.x-offset.x*startsize, linestart.y-offset.y*startsize, 0.0f);
2935 glVertex3f(linestart.x+offset.x*startsize, linestart.y+offset.y*startsize, 0.0f);
2937 glVertex3f(lineend.x+offset.x*endsize, lineend.y+offset.y*endsize, 0.0f);
2939 glVertex3f(lineend.x-offset.x*endsize, lineend.y-offset.y*endsize, 0.0f);
2943 glEnable(GL_TEXTURE_2D);
2947 if(j==6) glBindTexture( GL_TEXTURE_2D, Mainmenuitems[7]);
2948 else glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
2949 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
2950 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
2951 if(j-7<(accountactive?accountactive->getCampaignChoicesMade():0)) glColor4f(0.5,0,0,1);
2952 if(j-7>=(accountactive?accountactive->getCampaignChoicesMade():0)) glColor4f(1,0,0,1);
2953 if(j==6) glColor4f(1,1,1,1);
2956 itemsize=abs(startx[j]-endx[j])/2;
2958 midpoint.x=(startx[j]+endx[j])/2;
2959 midpoint.y=(starty[j]+endy[j])/2;
2960 if(j>6&&(j-7<(accountactive?accountactive->getCampaignChoicesMade():0)))itemsize*=.5;
2961 if(!(j-7>(accountactive?accountactive->getCampaignChoicesMade():0)+campaignchoicenum))
2963 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2967 glVertex3f(midpoint.x-itemsize, midpoint.y-itemsize, 0.0f);
2969 glVertex3f(midpoint.x+itemsize, midpoint.y-itemsize, 0.0f);
2971 glVertex3f(midpoint.x+itemsize, midpoint.y+itemsize, 0.0f);
2973 glVertex3f(midpoint.x-itemsize, midpoint.y+itemsize, 0.0f);
2977 //glDisable(GL_ALPHA_TEST);
2978 if(j<4)glBlendFunc(GL_SRC_ALPHA,GL_ONE);
2981 if(1-((float)i)/10-(1-selectedlong[j])>0)
2983 glColor4f(1,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
2984 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2988 glVertex3f(midpoint.x-itemsize-((float)i)*1/2+offsetx[j]*((float)i)/2, midpoint.y-itemsize-((float)i)*1/2+offsety[j]*((float)i)/2, 0.0f);
2990 glVertex3f(midpoint.x+itemsize+((float)i)*1/2+offsetx[j]*((float)i)/2, midpoint.y-itemsize-((float)i)*1/2+offsety[j]*((float)i)/2, 0.0f);
2992 glVertex3f(midpoint.x+itemsize+((float)i)*1/2+offsetx[j]*((float)i)/2, midpoint.y+itemsize+((float)i)*1/2+offsety[j]*((float)i)/2, 0.0f);
2994 glVertex3f(midpoint.x-itemsize-((float)i)*1/2+offsetx[j]*((float)i)/2, midpoint.y+itemsize+((float)i)*1/2+offsety[j]*((float)i)/2, 0.0f);
3002 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3004 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3006 if(j-7>=(accountactive?accountactive->getCampaignChoicesMade():0)){
3007 text.glPrintOutlined(0.9,0,0,startx[j]+10,starty[j]-4,menustring[j],0,0.6,640,480);
3008 glDisable(GL_DEPTH_TEST);
3013 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3015 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3018 if(mainmenu==1||mainmenu==2)
3019 //if(transition<.1||transition>.9){
3020 glClear(GL_DEPTH_BUFFER_BIT);
3021 glEnable(GL_ALPHA_TEST);
3022 glAlphaFunc(GL_GREATER, 0.001f);
3023 glEnable(GL_TEXTURE_2D);
3024 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3025 glDisable(GL_CULL_FACE);
3026 glDisable(GL_LIGHTING);
3028 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3029 glPushMatrix(); // Store The Projection Matrix
3030 glLoadIdentity(); // Reset The Projection Matrix
3031 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3032 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3033 glPushMatrix(); // Store The Modelview Matrix
3034 glLoadIdentity(); // Reset The Modelview Matrix
3036 glDisable(GL_TEXTURE_2D);
3038 //glColor4f(1,0,0,1-(transition*10));
3040 //glColor4f(1,0,0,1-((1-transition)*10));
3044 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3048 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3049 glPushMatrix(); // Store The Projection Matrix
3050 glLoadIdentity(); // Reset The Projection Matrix
3051 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
3052 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3053 glPushMatrix(); // Store The Modelview Matrix
3054 glLoadIdentity(); // Reset The Modelview Matrix
3055 glTranslatef(screenwidth/2,screenheight/2,0);
3057 glScalef((float)screenwidth/2,(float)screenheight/2,1);
3058 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3060 glEnable(GL_TEXTURE_2D);
3062 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
3063 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
3065 if(!waiting) { // hide the cursor while waiting for a key
3067 glTranslatef(mousecoordh-screenwidth/2,mousecoordv*-1+screenheight/2,0);
3068 glScalef((float)screenwidth/64,(float)screenwidth/64,1);
3069 glTranslatef(1,-1,0);
3070 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3072 glBindTexture( GL_TEXTURE_2D, cursortexture);
3074 //glScalef(.25,.25,.25);
3077 glVertex3f(-1, -1, 0.0f);
3079 glVertex3f(1, -1, 0.0f);
3081 glVertex3f(1, 1, 0.0f);
3083 glVertex3f(-1, 1, 0.0f);
3089 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3095 //printf("Flash amount: %f, delay %i\n", flashamount, flashdelay);
3096 if(flashamount>1)flashamount=1;
3097 if(flashdelay<=0)flashamount-=multiplier;
3099 if(flashamount<0)flashamount=0;
3100 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3101 glDisable(GL_CULL_FACE);
3102 glDisable(GL_LIGHTING);
3103 glDisable(GL_TEXTURE_2D);
3105 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3106 glPushMatrix(); // Store The Projection Matrix
3107 glLoadIdentity(); // Reset The Projection Matrix
3108 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
3109 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3110 glPushMatrix(); // Store The Modelview Matrix
3111 glLoadIdentity(); // Reset The Modelview Matrix
3112 glScalef(screenwidth,screenheight,1);
3113 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3115 glColor4f(flashr,flashg,flashb,flashamount);
3117 glVertex3f(0, 0, 0.0f);
3118 glVertex3f(256, 0, 0.0f);
3119 glVertex3f(256, 256, 0.0f);
3120 glVertex3f(0, 256, 0.0f);
3122 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3123 glPopMatrix(); // Restore The Old Projection Matrix
3124 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3125 glPopMatrix(); // Restore The Old Projection Matrix
3126 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
3127 glEnable(GL_CULL_FACE);
3128 glDisable(GL_BLEND);