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;
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() {
2000 ifstream ipstream(ConvertFileName(":Data:Campaigns:main.txt"));
2001 ipstream.ignore(256,':');
2002 ipstream >> campaignnumlevels;
2003 for(int i=0;i<campaignnumlevels;i++){
2004 ipstream.ignore(256,':');
2005 ipstream.ignore(256,':');
2006 ipstream.ignore(256,' ');
2007 ipstream >> campaignmapname[i];
2008 ipstream.ignore(256,':');
2009 ipstream >> campaigndescription[i];
2010 for(int j=0;j<256;j++){
2011 if(campaigndescription[i][j]=='_')campaigndescription[i][j]=' ';
2013 ipstream.ignore(256,':');
2014 ipstream >> campaignchoosenext[i];
2015 ipstream.ignore(256,':');
2016 ipstream >> campaignnumnext[i];
2017 for(int j=0;j<campaignnumnext[i];j++){
2018 ipstream.ignore(256,':');
2019 ipstream >> campaignnextlevel[i][j];
2020 campaignnextlevel[i][j]-=1;
2022 ipstream.ignore(256,':');
2023 ipstream >> campaignlocationx[i];
2024 ipstream.ignore(256,':');
2025 ipstream >> campaignlocationy[i];
2029 for(int i=0;i<campaignnumlevels;i++){
2031 levelhighlight[i]=0;
2036 for(int i=0;i<accountactive->getCampaignChoicesMade();i++){
2037 levelorder[i+1]=campaignnextlevel[levelorder[i]][accountactive->getCampaignChoice(i)];
2038 levelvisible[levelorder[i+1]]=1;
2040 int whichlevelstart = (accountactive?accountactive->getCampaignChoicesMade():0)-1;
2041 if(whichlevelstart<0){
2043 accountactive->setCampaignScore(0);
2044 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==119||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;
2175 if(newdetail==2)sprintf (menustring[1], "Detail: High");
2176 else if(newdetail==1)sprintf (menustring[1], "Detail: Medium");
2177 else sprintf (menustring[1], "Detail: Low");
2180 endx[1]=startx[1]+strlen(menustring[1])*10;
2181 endy[1]=starty[1]+20;
2185 if(bloodtoggle==2)sprintf (menustring[2], "Blood: On, high detail (slower)");
2186 if(bloodtoggle==1)sprintf (menustring[2], "Blood: On, low detail");
2187 if(bloodtoggle==0)sprintf (menustring[2], "Blood: Off");
2190 endx[2]=startx[2]+strlen(menustring[2])*10;
2191 endy[2]=starty[2]+20;
2195 if(difficulty==2)sprintf (menustring[3], "Difficulty: Insane");
2196 if(difficulty==1)sprintf (menustring[3], "Difficulty: Difficult");
2197 if(difficulty==0)sprintf (menustring[3], "Difficulty: Easier");
2198 startx[3]=10+20-1000;
2200 endx[3]=startx[3]+strlen(menustring[3])*10;
2201 endy[3]=starty[3]+20;
2205 if(ismotionblur==1)sprintf (menustring[4], "Blur Effects: Enabled (less compatible)");
2206 if(ismotionblur==0)sprintf (menustring[4], "Blur Effects: Disabled (more compatible)");
2209 endx[4]=startx[4]+strlen(menustring[4])*10;
2210 endy[4]=starty[4]+20;
2214 if(decals==1)sprintf (menustring[5], "Decals: Enabled (slower)");
2215 if(decals==0)sprintf (menustring[5], "Decals: Disabled");
2218 endx[5]=startx[5]+strlen(menustring[5])*10;
2219 endy[5]=starty[5]+20;
2223 if(musictoggle==1)sprintf (menustring[6], "Music: Enabled");
2224 if(musictoggle==0)sprintf (menustring[6], "Music: Disabled");
2227 endx[6]=startx[6]+strlen(menustring[6])*10;
2228 endy[6]=starty[6]+20;
2232 if(invertmouse==1)sprintf (menustring[9], "Invert mouse: Yes");
2233 if(invertmouse==0)sprintf (menustring[9], "Invert mouse: No");
2236 endx[9]=startx[9]+strlen(menustring[9])*10;
2237 endy[9]=starty[9]+20;
2241 sprintf (menustring[10], "Mouse Speed: %d", (int)(usermousesensitivity*5));
2244 endx[10]=startx[10]+strlen(menustring[10])*10;
2245 endy[10]=starty[10]+20;
2249 sprintf (menustring[11], "Volume: %d%%", (int)(volume*100));
2252 endx[11]=startx[11]+strlen(menustring[11])*10;
2253 endy[11]=starty[11]+20;
2257 sprintf (menustring[13], "Damage Bar: %s",(showdamagebar?"on":"off"));
2260 endx[13]=startx[13]+strlen(menustring[13])*10;
2261 endy[13]=starty[13]+20;
2265 sprintf (menustring[7], "-Configure Controls-");
2268 endx[7]=startx[7]+strlen(menustring[7])*10;
2269 endy[7]=starty[7]+20;
2273 sprintf (menustring[12], "-Configure Stereo -");
2276 endx[12]=startx[12]+strlen(menustring[7])*10;
2277 endy[12]=starty[12]+20;
2281 if(newdetail==detail&&newscreenheight==(int)screenheight&&newscreenwidth==(int)screenwidth)sprintf (menustring[8], "Back");
2282 else sprintf (menustring[8], "Back (some changes take effect next time Lugaru is opened)");
2284 endx[8]=startx[8]+strlen(menustring[8])*10;
2286 endy[8]=starty[8]+20;
2293 if(keyselect!=0)sprintf (menustring[0], "Forwards: %s",Input::keyToChar(forwardkey));
2294 else sprintf (menustring[0], "Forwards: _");
2297 endx[0]=startx[0]+strlen(menustring[0])*10;
2298 endy[0]=starty[0]+20;
2302 if(keyselect!=1)sprintf (menustring[1], "Back: %s",Input::keyToChar(backkey));
2303 else sprintf (menustring[1], "Back: _");
2306 endx[1]=startx[1]+strlen(menustring[1])*10;
2307 endy[1]=starty[1]+20;
2311 if(keyselect!=2)sprintf (menustring[2], "Left: %s",Input::keyToChar(leftkey));
2312 else sprintf (menustring[2], "Left: _");
2315 endx[2]=startx[2]+strlen(menustring[2])*10;
2316 endy[2]=starty[2]+20;
2320 if(keyselect!=3)sprintf (menustring[3], "Right: %s",Input::keyToChar(rightkey));
2321 else sprintf (menustring[3], "Right: _");
2324 endx[3]=startx[3]+strlen(menustring[3])*10;
2325 endy[3]=starty[3]+20;
2329 if(keyselect!=4)sprintf (menustring[4], "Crouch: %s",Input::keyToChar(crouchkey));
2330 else sprintf (menustring[4], "Crouch: _");
2333 endx[4]=startx[4]+strlen(menustring[4])*10;
2334 endy[4]=starty[4]+20;
2338 if(keyselect!=5)sprintf (menustring[5], "Jump: %s",Input::keyToChar(jumpkey));
2339 else sprintf (menustring[5], "Jump: _");
2342 endx[5]=startx[5]+strlen(menustring[5])*10;
2343 endy[5]=starty[5]+20;
2347 if(keyselect!=6)sprintf (menustring[6], "Draw: %s",Input::keyToChar(drawkey));
2348 else sprintf (menustring[6], "Draw: _");
2351 endx[6]=startx[6]+strlen(menustring[6])*10;
2352 endy[6]=starty[6]+20;
2356 if(keyselect!=7)sprintf (menustring[7], "Throw: %s",Input::keyToChar(throwkey));
2357 else sprintf (menustring[7], "Throw: _");
2360 endx[7]=startx[7]+strlen(menustring[7])*10;
2361 endy[7]=starty[7]+20;
2365 if(keyselect!=8)sprintf (menustring[8], "Attack: %s",Input::keyToChar(attackkey));
2366 else sprintf (menustring[8], "Attack: _");
2369 endx[8]=startx[8]+strlen(menustring[8])*10;
2370 endy[8]=starty[8]+20;
2376 sprintf (menustring[9], "Back");
2378 endx[9]=startx[9]+strlen(menustring[9])*10;
2380 endy[9]=starty[9]+20;
2385 nummenuitems=7+(accountactive?accountactive->getCampaignChoicesMade():0)+campaignchoicenum;
2387 sprintf (menustring[0], "%s",accountactive->getName());
2390 endx[0]=startx[0]+strlen(menustring[0])*10;
2391 endy[0]=starty[0]+20;
2395 sprintf (menustring[1], "Tutorial");
2398 endx[1]=startx[1]+strlen(menustring[1])*10;
2399 endy[1]=starty[1]+20;
2403 sprintf (menustring[2], "Challenge");
2406 endx[2]=startx[2]+strlen(menustring[2])*10;
2407 endy[2]=starty[2]+20;
2411 sprintf (menustring[3], "Delete User");
2414 endx[3]=startx[3]+strlen(menustring[3])*10;
2415 endy[3]=starty[3]+20;
2419 sprintf (menustring[4], "Main Menu");
2422 endx[4]=startx[4]+strlen(menustring[4])*10;
2423 endy[4]=starty[4]+20;
2427 sprintf (menustring[5], "Change User");
2429 endx[5]=startx[5]+strlen(menustring[5])*10;
2431 endy[5]=starty[5]+20;
2437 sprintf (menustring[6], "World");
2439 starty[6]=30+480-400-50;
2440 endx[6]=startx[6]+400;
2445 if((accountactive?accountactive->getCampaignChoicesMade():0)) {
2446 for(i=0;i<(accountactive?accountactive->getCampaignChoicesMade():0);i++) {
2447 sprintf (menustring[7+i], "%s", campaigndescription[levelorder[i]]);
2448 startx[7+i]=30+120+campaignlocationx[levelorder[i]]*400/512;
2449 starty[7+i]=30+30+(512-campaignlocationy[levelorder[i]])*400/512;
2450 endx[7+i]=startx[7+i]+10;
2451 endy[7+i]=starty[7+i]+10;
2457 if(campaignchoicenum>0)
2458 for(i=(accountactive?accountactive->getCampaignChoicesMade():0);i<(accountactive?accountactive->getCampaignChoicesMade():0)+campaignchoicenum;i++){
2459 sprintf (menustring[7+i], "%s", campaigndescription[levelorder[i]]);
2460 startx[7+i]=30+120+campaignlocationx[campaignchoicewhich[i-((accountactive?accountactive->getCampaignChoicesMade():0))]]*400/512;
2461 starty[7+i]=30+30+(512-campaignlocationy[campaignchoicewhich[i-((accountactive?accountactive->getCampaignChoicesMade():0))]])*400/512;
2462 endx[7+i]=startx[7+i]+10;
2463 endy[7+i]=starty[7+i]+10;
2472 sprintf (menustring[0], "Are you sure you want to delete this user?");
2475 endx[0]=startx[0]+strlen(menustring[0])*10;
2476 endy[0]=starty[0]+20;
2480 sprintf (menustring[1], "Yes");
2483 endx[1]=startx[1]+strlen(menustring[1])*10;
2484 endy[1]=starty[1]+20;
2488 sprintf (menustring[2], "No");
2491 endx[2]=startx[2]+strlen(menustring[2])*10;
2492 endy[2]=starty[2]+20;
2496 sprintf (menustring[3], "Extra 4");
2499 endx[3]=startx[3]+strlen(menustring[3])*10;
2500 endy[3]=starty[3]+20;
2504 sprintf (menustring[4], "Extra 5");
2507 endx[4]=startx[4]+strlen(menustring[4])*10;
2508 endy[4]=starty[4]+20;
2512 sprintf (menustring[5], "Back");
2514 endx[5]=startx[5]+strlen(menustring[5])*10;
2516 endy[5]=starty[5]+20;
2522 nummenuitems=Account::getNbAccounts()+2;
2526 if(Account::getNbAccounts()<8)
2527 sprintf (menustring[0], "New User");
2529 sprintf (menustring[0], "No More Users");
2532 endx[0]=startx[0]+strlen(menustring[0])*10;
2533 endy[0]=starty[0]+20;
2542 for(i=0;i<Account::getNbAccounts();i++){
2543 sprintf (menustring[num], "%s",Account::get(i)->getName());
2545 starty[num]=360-20-20*num;
2546 endx[num]=startx[num]+strlen(menustring[num])*10;
2547 endy[num]=starty[num]+20;
2554 sprintf (menustring[num], "Back");
2556 endx[num]=startx[num]+strlen(menustring[num])*10;
2558 endy[num]=starty[num]+20;
2565 sprintf (menustring[0], "Easier");
2568 endx[0]=startx[0]+strlen(menustring[0])*10;
2569 endy[0]=starty[0]+20;
2573 sprintf (menustring[1], "Difficult");
2576 endx[1]=startx[1]+strlen(menustring[1])*10;
2577 endy[1]=starty[1]+20;
2581 sprintf (menustring[2], "Insane");
2584 endx[2]=startx[2]+strlen(menustring[2])*10;
2585 endy[2]=starty[2]+20;
2590 nummenuitems=2+numchallengelevels;
2593 for(j=0;j<numchallengelevels;j++){
2594 for(i=0;i<255;i++)menustring[j][i]='\0';
2595 sprintf (temp, "Level %d",j+1);
2596 strcpy(menustring[j],temp);
2597 for(i=0;i<17;i++)if(menustring[j][i]=='\0')menustring[j][i]=' ';
2598 menustring[j][17]='\0';
2599 sprintf (temp, "%d",(int)accountactive->getHighScore(j));
2600 strcat(menustring[j],temp);
2601 for(i=18;i<32;i++)if(menustring[j][i]=='\0')menustring[j][i]=' ';
2602 menustring[j][32]='\0';
2603 sprintf (temp, "%d:",(int)(((int)accountactive->getFastTime(j)-(int)(accountactive->getFastTime(j))%60)/60));
2604 strcat(menustring[j],temp);
2605 if((int)(accountactive->getFastTime(j))%60<10)strcat(menustring[j],"0");
2606 sprintf (temp, "%d",(int)(accountactive->getFastTime(j))%60);
2607 strcat(menustring[j],temp);
2611 endx[j]=startx[j]+strlen(menustring[j])*10;
2612 endy[j]=starty[j]+20;
2617 sprintf (menustring[numchallengelevels], "Back");
2618 startx[numchallengelevels]=10;
2619 endx[numchallengelevels]=startx[numchallengelevels]+strlen(menustring[numchallengelevels])*10;
2620 starty[numchallengelevels]=10;
2621 endy[numchallengelevels]=starty[numchallengelevels]+20;
2622 movex[numchallengelevels]=0;
2623 movey[numchallengelevels]=0;
2625 sprintf (menustring[numchallengelevels+1], " High Score Best Time");
2626 startx[numchallengelevels+1]=10;
2627 starty[numchallengelevels+1]=440;
2628 endx[numchallengelevels+1]=startx[numchallengelevels+1]+strlen(menustring[numchallengelevels+1])*10;
2629 endy[numchallengelevels+1]=starty[numchallengelevels+1]+20;
2630 movex[numchallengelevels+1]=0;
2631 movey[numchallengelevels+1]=0;
2633 //numchallengelevels=tempncl;
2640 sprintf (menustring[0], "Congratulations!");
2643 endx[0]=startx[0]+strlen(menustring[0])*10;
2644 endy[0]=starty[0]+20;
2648 sprintf (menustring[1], "You have avenged your family and");
2651 endx[1]=startx[1]+strlen(menustring[1])*10;
2652 endy[1]=starty[1]+20;
2656 sprintf (menustring[2], "restored peace to the island of Lugaru.");
2659 endx[2]=startx[2]+strlen(menustring[2])*10;
2660 endy[2]=starty[2]+20;
2664 sprintf (menustring[3], "Back");
2666 endx[3]=startx[3]+strlen(menustring[3])*10;
2668 endy[3]=starty[3]+20;
2672 for(i=0;i<255;i++)menustring[4][i]='\0';
2673 sprintf (temp, "Your score:");
2674 strcpy(menustring[4],temp);
2675 for(i=0;i<20;i++)if(menustring[4][i]=='\0')menustring[4][i]=' ';
2676 menustring[4][20]='\0';
2677 sprintf (temp, "%d",(int)accountactive->getCampaignScore());
2678 strcat(menustring[4],temp);
2680 endx[4]=startx[4]+strlen(menustring[4])*10;
2682 endy[4]=starty[4]+20;
2685 for(i=0;i<255;i++)menustring[5][i]='\0';
2686 sprintf (temp, "Highest score:");
2687 strcpy(menustring[5],temp);
2688 for(i=0;i<20;i++)if(menustring[5][i]=='\0')menustring[5][i]=' ';
2689 menustring[5][20]='\0';
2690 sprintf (temp, "%d",(int)accountactive->getCampaignHighScore());
2691 strcat(menustring[5],temp);
2693 endx[5]=startx[5]+strlen(menustring[5])*10;
2695 endy[5]=starty[5]+20;
2701 sprintf (menustring[0], "Stereo mode: %s", StereoModeName(newstereomode));
2704 endx[0]=startx[0]+strlen(menustring[0])*10;
2705 endy[0]=starty[0]+20;
2709 sprintf (menustring[1], "Stereo separation: %.3f", stereoseparation);
2712 endx[1]=startx[1]+strlen(menustring[1])*10;
2713 endy[1]=starty[1]+20;
2717 sprintf (menustring[2], "Reverse stereo: %s", stereoreverse ? "Yes" : "No");
2720 endx[2]=startx[2]+strlen(menustring[2])*10;
2721 endy[2]=starty[2]+20;
2725 sprintf (menustring[3], "Back");
2727 endx[3]=startx[3]+strlen(menustring[3])*10;
2729 endy[3]=starty[3]+20;
2735 if(mainmenu==1||mainmenu==2){
2745 starty[1]=480-152-32;
2752 starty[2]=480-228-32;
2760 starty[3]=480-306-32;
2769 starty[3]=480-306-32;
2783 starty[4]=480-140-256;
2790 starty[5]=480-138-256;
2797 starty[6]=480-144-256;
2805 starty[4]=480-140-256;
2812 starty[5]=480-138-256;
2819 starty[6]=480-144-256;
2827 starty[4]=480-140-256;
2834 starty[5]=480-150-256;
2841 starty[6]=480-144-256;
2849 starty[4]=480-140-256;
2856 starty[5]=480-150-256;
2863 starty[6]=480-144-256;
2871 starty[4]=480-100-256;
2878 starty[5]=480-120-256;
2885 starty[6]=480-144-256;
2895 if(mainmenu==1||mainmenu==2)
2897 if((mousecoordh/screenwidth*640)>startx[i]&&(mousecoordh/screenwidth*640)<endx[i]&&480-(mousecoordv/screenheight*480)>starty[i]&&480-(mousecoordv/screenheight*480)<endy[i]){
2902 if(mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==8||mainmenu==9||mainmenu==10||mainmenu==18)
2903 for(i=0;i<nummenuitems;i++){
2904 if((mousecoordh/screenwidth*640)>startx[i]&&(mousecoordh/screenwidth*640)<endx[i]&&480-(mousecoordv/screenheight*480)>starty[i]&&480-(mousecoordv/screenheight*480)<endy[i]){
2905 if(mainmenu!=5)selected=i;
2906 if(mainmenu==5&&(i!=0&&i!=6))selected=i;
2907 if(mainmenu==9&&(i!=numchallengelevels+1))selected=i; // seem useless, if mainmenu==9 then mainmenu!=5, so selected==i.
2911 for(i=0;i<nummenuitems;i++){
2913 selectedlong[i]+=multiplier*5;
2914 if(selectedlong[i]>1) selectedlong[i]=1;
2916 selectedlong[i]-=multiplier*5;
2917 if(selectedlong[i]<0) selectedlong[i]=0;
2919 offsetx[i]=(startx[i]+endx[i])/2-(mousecoordh/screenwidth*640);
2920 offsety[i]=(starty[i]+endy[i])/2-(480-(mousecoordv/screenheight*480));
2925 if(i>=4&&(mainmenu==1||mainmenu==2)){
2927 offsetx[i]=(startx[i]+endx[i]+movex[i]*transition)/2-(640+190)/2;
2928 offsety[i]=(starty[i]+endy[i]+movey[i]*transition)/2-(336+150)/2;
2934 if(mainmenu==1||mainmenu==2){
2935 glClear(GL_DEPTH_BUFFER_BIT);
2936 glEnable(GL_ALPHA_TEST);
2937 glAlphaFunc(GL_GREATER, 0.001f);
2938 glEnable(GL_TEXTURE_2D);
2939 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
2940 glDisable(GL_CULL_FACE);
2941 glDisable(GL_LIGHTING);
2943 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2944 glPushMatrix(); // Store The Projection Matrix
2945 glLoadIdentity(); // Reset The Projection Matrix
2946 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
2947 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2948 glPushMatrix(); // Store The Modelview Matrix
2949 glLoadIdentity(); // Reset The Modelview Matrix
2950 glTranslatef(screenwidth/2,screenheight/2,0);
2952 glScalef((float)screenwidth/2,(float)screenheight/2,1);
2953 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
2954 glDisable(GL_BLEND);
2955 glColor4f(0,0,0,1.0);
2956 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2957 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2958 glDisable(GL_TEXTURE_2D);
2960 //glScalef(.25,.25,.25);
2963 glVertex3f(-1, -1, 0.0f);
2965 glVertex3f(1, -1, 0.0f);
2967 glVertex3f(1, 1, 0.0f);
2969 glVertex3f(-1, 1, 0.0f);
2973 glColor4f(0.4,0.4,0.4,1.0);
2974 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2975 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2976 glEnable(GL_TEXTURE_2D);
2977 glBindTexture( GL_TEXTURE_2D, Mainmenuitems[4]);
2979 //glScalef(.25,.25,.25);
2982 glVertex3f(-1, -1, 0.0f);
2984 glVertex3f(1, -1, 0.0f);
2986 glVertex3f(1, 1, 0.0f);
2988 glVertex3f(-1, 1, 0.0f);
2993 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2996 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2997 glPushMatrix(); // Store The Projection Matrix
2998 glLoadIdentity(); // Reset The Projection Matrix
2999 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3000 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3001 glPushMatrix(); // Store The Modelview Matrix
3002 glLoadIdentity(); // Reset The Modelview Matrix
3004 glDisable(GL_TEXTURE_2D);
3008 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3010 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3014 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3015 glPushMatrix(); // Store The Projection Matrix
3016 glLoadIdentity(); // Reset The Projection Matrix
3017 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3018 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3019 glPushMatrix(); // Store The Modelview Matrix
3020 glLoadIdentity(); // Reset The Modelview Matrix
3021 glEnable(GL_TEXTURE_2D);
3022 for(j=0;j<nummenuitems;j++)
3024 if(j>3 && (mainmenu==1||mainmenu==2))
3026 //glDisable(GL_BLEND);
3027 glEnable(GL_ALPHA_TEST);
3029 //glDisable(GL_ALPHA_TEST);
3030 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3031 if(mainmenu==1||mainmenu==2)
3034 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3035 glBindTexture( GL_TEXTURE_2D, Mainmenuitems[j]);
3036 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
3037 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
3038 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3042 glVertex3f(startx[j]+movex[j]*transition, starty[j]+movey[j]*transition, 0.0f);
3044 glVertex3f(endx[j]+movex[j]*transition, starty[j]+movey[j]*transition, 0.0f);
3046 glVertex3f(endx[j]+movex[j]*transition, endy[j]+movey[j]*transition, 0.0f);
3048 glVertex3f(startx[j]+movex[j]*transition, endy[j]+movey[j]*transition, 0.0f);
3052 //glDisable(GL_ALPHA_TEST);
3053 if(j<4)glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3056 if(1-((float)i)/10-(1-selectedlong[j])>0)
3058 glColor4f(1,1,1,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3059 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3063 glVertex3f(startx[j]-((float)i)*1/2+offsetx[j]*((float)i)/2+movex[j]*transition, starty[j]-((float)i)*1/2+offsety[j]*((float)i)/2+movey[j]*transition, 0.0f);
3065 glVertex3f(endx[j]+((float)i)*1/2+offsetx[j]*((float)i)/2+movex[j]*transition, starty[j]-((float)i)*1/2+offsety[j]*((float)i)/2+movey[j]*transition, 0.0f);
3067 glVertex3f(endx[j]+((float)i)*1/2+offsetx[j]*((float)i)/2+movex[j]*transition, endy[j]+((float)i)*1/2+offsety[j]*((float)i)/2+movey[j]*transition, 0.0f);
3069 glVertex3f(startx[j]-((float)i)*1/2+offsetx[j]*((float)i)/2+movex[j]*transition, endy[j]+((float)i)*1/2+offsety[j]*((float)i)/2+movey[j]*transition, 0.0f);
3075 if(mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==8||mainmenu==9||mainmenu==10||mainmenu==18)
3077 if(mainmenu!=5||j<6)
3080 if( (mainmenu==9) && j>accountactive->getProgress() && (j<numchallengelevels) )
3081 glColor4f(0.5,0,0,1);
3082 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3084 if(mainmenu!=7||j!=0||!entername)
3085 text.glPrint(startx[j],starty[j],menustring[j],0,1,640,480);
3090 //~ sprintf (string, "_");
3091 text.glPrint(startx[j]+(float)(displayselected)*10,starty[j],string,0,1,640,480);
3093 for(int l=0;l<displaychars[0];l++) {
3094 sprintf (string, "%c",displaytext[0][l]);
3095 text.glPrint(startx[j]+l*10,starty[j],string,0,1,640,480);
3100 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3103 if(1-((float)i)/15-(1-selectedlong[j])>0)
3105 glColor4f(1,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3106 if(mainmenu==9&&j>accountactive->getProgress()&&j<numchallengelevels)glColor4f(0.5,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3107 if(mainmenu==11&&j>accountactive->getProgress()&&j<numchallengelevels)glColor4f(0.5,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3108 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);
3109 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);
3110 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);
3111 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);
3112 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);
3113 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);
3114 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);
3115 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);
3116 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);
3122 glClear(GL_DEPTH_BUFFER_BIT);
3123 glEnable(GL_ALPHA_TEST);
3124 glAlphaFunc(GL_GREATER, 0.001f);
3125 glEnable(GL_TEXTURE_2D);
3126 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3127 glDisable(GL_CULL_FACE);
3128 glDisable(GL_LIGHTING);
3129 if(j==6)glColor4f(1,1,1,1);
3130 else glColor4f(1,0,0,1);
3132 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3133 glPushMatrix(); // Store The Projection Matrix
3134 glLoadIdentity(); // Reset The Projection Matrix
3135 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3136 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3137 glPushMatrix(); // Store The Modelview Matrix
3138 glLoadIdentity(); // Reset The Modelview Matrix
3141 //Draw world, draw map
3142 glTranslatef(2,-5,0);
3144 if(j>6&&j<nummenuitems-1)
3146 XYZ linestart,lineend,offset;
3153 //float linestartx,lineendx,linestarty,lineendy,offsetx,offsety;
3154 linestart.x=(startx[j]+endx[j])/2;
3155 linestart.y=(starty[j]+endy[j])/2;
3156 if(j>=6+(accountactive?accountactive->getCampaignChoicesMade():0)){
3157 linestart.x=(startx[6+(accountactive?accountactive->getCampaignChoicesMade():0)]+endx[6+(accountactive?accountactive->getCampaignChoicesMade():0)])/2;
3158 linestart.y=(starty[6+(accountactive?accountactive->getCampaignChoicesMade():0)]+endy[6+(accountactive?accountactive->getCampaignChoicesMade():0)])/2;
3160 lineend.x=(startx[j+1]+endx[j+1])/2;
3161 lineend.y=(starty[j+1]+endy[j+1])/2;
3162 offset=lineend-linestart;
3165 offset=DoRotation(offset,0,0,90);
3167 glDisable(GL_TEXTURE_2D);
3169 if(j<6+(accountactive?accountactive->getCampaignChoicesMade():0)){
3170 glColor4f(0.5,0,0,1);
3178 linestart+=fac*4*startsize;
3179 lineend-=fac*4*endsize;
3181 if(!(j>7+(accountactive?accountactive->getCampaignChoicesMade():0)+campaignchoicenum)){
3182 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3186 glVertex3f(linestart.x-offset.x*startsize, linestart.y-offset.y*startsize, 0.0f);
3188 glVertex3f(linestart.x+offset.x*startsize, linestart.y+offset.y*startsize, 0.0f);
3190 glVertex3f(lineend.x+offset.x*endsize, lineend.y+offset.y*endsize, 0.0f);
3192 glVertex3f(lineend.x-offset.x*endsize, lineend.y-offset.y*endsize, 0.0f);
3196 glEnable(GL_TEXTURE_2D);
3200 if(j==6)glBindTexture( GL_TEXTURE_2D, Mainmenuitems[7]);
3201 else glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
3202 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
3203 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
3204 if(j-7<(accountactive?accountactive->getCampaignChoicesMade():0))glColor4f(0.5,0,0,1);
3205 if(j-7>=(accountactive?accountactive->getCampaignChoicesMade():0))glColor4f(1,0,0,1);
3206 if(j==6)glColor4f(1,1,1,1);
3209 itemsize=abs(startx[j]-endx[j])/2;
3211 midpoint.x=(startx[j]+endx[j])/2;
3212 midpoint.y=(starty[j]+endy[j])/2;
3213 if(j>6&&(j-7<(accountactive?accountactive->getCampaignChoicesMade():0)))itemsize*=.5;
3214 if(!(j-7>(accountactive?accountactive->getCampaignChoicesMade():0)+campaignchoicenum))
3216 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3220 glVertex3f(midpoint.x-itemsize+movex[j]*transition, midpoint.y-itemsize+movey[j]*transition, 0.0f);
3222 glVertex3f(midpoint.x+itemsize+movex[j]*transition, midpoint.y-itemsize+movey[j]*transition, 0.0f);
3224 glVertex3f(midpoint.x+itemsize+movex[j]*transition, midpoint.y+itemsize+movey[j]*transition, 0.0f);
3226 glVertex3f(midpoint.x-itemsize+movex[j]*transition, midpoint.y+itemsize+movey[j]*transition, 0.0f);
3230 //glDisable(GL_ALPHA_TEST);
3231 if(j<4)glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3234 if(1-((float)i)/10-(1-selectedlong[j])>0)
3236 glColor4f(1,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3237 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3241 glVertex3f(midpoint.x-itemsize-((float)i)*1/2+offsetx[j]*((float)i)/2+movex[j]*transition, midpoint.y-itemsize-((float)i)*1/2+offsety[j]*((float)i)/2+movey[j]*transition, 0.0f);
3243 glVertex3f(midpoint.x+itemsize+((float)i)*1/2+offsetx[j]*((float)i)/2+movex[j]*transition, midpoint.y-itemsize-((float)i)*1/2+offsety[j]*((float)i)/2+movey[j]*transition, 0.0f);
3245 glVertex3f(midpoint.x+itemsize+((float)i)*1/2+offsetx[j]*((float)i)/2+movex[j]*transition, midpoint.y+itemsize+((float)i)*1/2+offsety[j]*((float)i)/2+movey[j]*transition, 0.0f);
3247 glVertex3f(midpoint.x-itemsize-((float)i)*1/2+offsetx[j]*((float)i)/2+movex[j]*transition, midpoint.y+itemsize+((float)i)*1/2+offsety[j]*((float)i)/2+movey[j]*transition, 0.0f);
3255 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3257 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3259 if(j-7>=(accountactive?accountactive->getCampaignChoicesMade():0)){
3260 text.glPrintOutlined(0.9,0,0,startx[j]+10,starty[j]-4,menustring[j],0,0.6,640,480);
3261 glDisable(GL_DEPTH_TEST);
3266 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3268 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3271 if(mainmenu==1||mainmenu==2)
3272 if(transition<.1||transition>.9){
3273 glClear(GL_DEPTH_BUFFER_BIT);
3274 glEnable(GL_ALPHA_TEST);
3275 glAlphaFunc(GL_GREATER, 0.001f);
3276 glEnable(GL_TEXTURE_2D);
3277 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3278 glDisable(GL_CULL_FACE);
3279 glDisable(GL_LIGHTING);
3281 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3282 glPushMatrix(); // Store The Projection Matrix
3283 glLoadIdentity(); // Reset The Projection Matrix
3284 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3285 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3286 glPushMatrix(); // Store The Modelview Matrix
3287 glLoadIdentity(); // Reset The Modelview Matrix
3289 glDisable(GL_TEXTURE_2D);
3291 glColor4f(1,0,0,1-(transition*10));
3293 glColor4f(1,0,0,1-((1-transition)*10));
3296 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3300 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3301 glPushMatrix(); // Store The Projection Matrix
3302 glLoadIdentity(); // Reset The Projection Matrix
3303 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
3304 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3305 glPushMatrix(); // Store The Modelview Matrix
3306 glLoadIdentity(); // Reset The Modelview Matrix
3307 glTranslatef(screenwidth/2,screenheight/2,0);
3309 glScalef((float)screenwidth/2,(float)screenheight/2,1);
3310 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3312 glEnable(GL_TEXTURE_2D);
3314 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
3315 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
3317 if(!waiting) { // hide the cursor while waiting for a key
3319 glTranslatef(mousecoordh-screenwidth/2,mousecoordv*-1+screenheight/2,0);
3320 glScalef((float)screenwidth/64,(float)screenwidth/64,1);
3321 glTranslatef(1,-1,0);
3322 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3324 glBindTexture( GL_TEXTURE_2D, cursortexture);
3326 //glScalef(.25,.25,.25);
3329 glVertex3f(-1, -1, 0.0f);
3331 glVertex3f(1, -1, 0.0f);
3333 glVertex3f(1, 1, 0.0f);
3335 glVertex3f(-1, 1, 0.0f);
3341 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3347 //printf("Flash amount: %f, delay %i\n", flashamount, flashdelay);
3348 if(flashamount>1)flashamount=1;
3349 if(flashdelay<=0)flashamount-=multiplier;
3351 if(flashamount<0)flashamount=0;
3352 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3353 glDisable(GL_CULL_FACE);
3354 glDisable(GL_LIGHTING);
3355 glDisable(GL_TEXTURE_2D);
3357 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3358 glPushMatrix(); // Store The Projection Matrix
3359 glLoadIdentity(); // Reset The Projection Matrix
3360 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
3361 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3362 glPushMatrix(); // Store The Modelview Matrix
3363 glLoadIdentity(); // Reset The Modelview Matrix
3364 glScalef(screenwidth,screenheight,1);
3365 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3367 glColor4f(flashr,flashg,flashb,flashamount);
3369 glVertex3f(0, 0, 0.0f);
3370 glVertex3f(256, 0, 0.0f);
3371 glVertex3f(256, 256, 0.0f);
3372 glVertex3f(0, 256, 0.0f);
3374 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3375 glPopMatrix(); // Restore The Old Projection Matrix
3376 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3377 glPopMatrix(); // Restore The Old Projection Matrix
3378 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
3379 glEnable(GL_CULL_FACE);
3380 glDisable(GL_BLEND);