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"
32 extern int environment;
33 extern float texscale;
35 extern Terrain terrain;
36 //extern Sprites sprites;
37 extern float multiplier;
39 extern float viewdistance;
40 extern float fadestart;
41 extern float screenwidth,screenheight;
42 extern int kTextureSize;
43 extern FRUSTUM frustum;
45 extern Objects objects;
47 extern float usermousesensitivity;
49 extern float camerashake;
51 extern float slomodelay;
52 extern bool ismotionblur;
54 extern float blackout;
55 extern bool damageeffects;
57 extern bool texttoggle;
58 extern float blurness;
59 extern float targetblurness;
60 extern float playerdist;
61 extern bool cellophane;
63 extern float flashamount,flashr,flashg,flashb;
64 extern int flashdelay;
66 extern float motionbluramount;
68 extern bool alwaysblur;
70 extern bool tilt2weird;
71 extern bool tiltweird;
73 extern bool proportionweird;
74 extern bool vertexweird[6];
75 extern bool velocityblur;
76 extern bool debugmode;
78 extern int oldmainmenu;
79 extern int bloodtoggle;
80 extern int difficulty;
83 //extern int texdetail;
84 extern float texdetail;
85 extern bool musictoggle;
86 extern int tutoriallevel;
87 extern float smoketex;
88 extern float tutorialstagetime;
89 extern float tutorialmaxtime;
90 extern int tutorialstage;
91 extern bool againbonus;
92 extern float damagedealt;
93 extern bool invertmouse;
95 extern int numhotspots;
96 extern int winhotspot;
97 extern int killhotspot;
98 extern XYZ hotspot[40];
99 extern int hotspottype[40];
100 extern float hotspotsize[40];
101 extern char hotspottext[40][256];
102 extern int currenthotspot;;
104 extern bool campaign;
105 extern bool winfreeze;
107 extern float menupulse;
109 extern bool gamestart;
111 extern bool gamestarted;
113 extern bool showdamagebar;
116 normalmode, motionblurmode, radialzoommode,
117 realmotionblurmode, doublevisionmode, glowmode,
120 void Game::flash() { // shouldn't be that way, these should be attributes and Person class should not change rendering.
127 /*********************> DrawGLScene() <*****/
128 int Game::DrawGLScene(StereoSide side)
130 static float texcoordwidth,texcoordheight;
131 static float texviewwidth, texviewheight;
133 static GLubyte color;
134 static XYZ checkpoint;
135 static float tempmult;
137 static char string[256]="";
138 static char string2[256]="";
139 static char string3[256]="";
141 if ( stereomode == stereoAnaglyph ) {
143 case stereoLeft: glColorMask( 0.0, 1.0, 1.0, 1.0 ); break;
144 case stereoRight: glColorMask( 1.0, 0.0, 0.0, 1.0 ); break;
147 glColorMask( 1.0, 1.0, 1.0, 1.0 );
149 if ( stereomode == stereoHorizontalInterlaced || stereomode == stereoVerticalInterlaced ) {
150 glStencilFunc(side == stereoLeft ? GL_NOTEQUAL : GL_EQUAL, 0x01, 0x01);
154 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)){
161 numboundaries=mapradius*2;
162 if(numboundaries>360)numboundaries=360;
163 for(i=0;i<numboundaries;i++){
166 boundary[i]=mapcenter+DoRotation(boundary[i]*mapradius,0,i*(360/((float)(numboundaries))),0);
175 olddrawmode=drawmode;
176 if(ismotionblur&&!loading){
177 if((findLengthfast(&player[0].velocity)>200)&&velocityblur&&!cameramode){
178 drawmode=motionblurmode;
179 motionbluramount=200/(findLengthfast(&player[0].velocity));
182 if(player[0].damage-player[0].superpermanentdamage>(player[0].damagetolerance-player[0].superpermanentdamage)*1/2&&damageeffects&&!cameramode){
183 drawmode=doublevisionmode;
190 drawmode=motionblurmode;
192 slomodelay-=multiplier;
193 if(slomodelay<0)slomo=0;
197 if((!changed&&!slomo)||loading){
199 if(ismotionblur&&(/*fps>100||*/alwaysblur)){
200 if(olddrawmode!=realmotionblurmode)change=1;
202 drawmode=realmotionblurmode;
204 else if(olddrawmode==realmotionblurmode)change=2;
208 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted))drawmode=normalmode;
209 if((freeze||winfreeze)&&ismotionblur&&!mainmenu)drawmode=radialzoommode;
211 if(winfreeze||mainmenu)drawmode=normalmode;
214 if(drawmode==glowmode){
219 DSpContext_FadeGamma(NULL,200,&color2);
223 if(drawtoggle!=2)drawtoggle=1-drawtoggle;
227 texviewwidth=kTextureSize;
228 if(texviewwidth>screenwidth)texviewwidth=screenwidth;
229 texviewheight=kTextureSize;
230 if(texviewheight>screenheight)texviewheight=screenheight;
232 texcoordwidth=screenwidth/kTextureSize;
233 texcoordheight=screenheight/kTextureSize;
234 if(texcoordwidth>1)texcoordwidth=1;
235 if(texcoordheight>1)texcoordheight=1;
238 glDrawBuffer(GL_BACK);
239 glReadBuffer(GL_BACK);
241 if(abs(blurness-targetblurness)<multiplier*10||abs(blurness-targetblurness)>2){
242 blurness=targetblurness;
243 targetblurness=(float)(abs(Random()%100))/40;
245 if(blurness<targetblurness)
246 blurness+=multiplier*5;
248 blurness-=multiplier*5;
251 static XYZ terrainlight;
252 static float distance;
253 if(drawmode==normalmode)ReSizeGLScene(90,.1f);
254 if(drawmode!=normalmode)glViewport(0,0,texviewwidth,texviewheight);
255 glDepthFunc(GL_LEQUAL);
257 glAlphaFunc(GL_GREATER, 0.0001f);
258 glEnable(GL_ALPHA_TEST);
259 glClearColor(0.25f, 0.25f, 0.25f, 1.0f);
260 glClear(GL_DEPTH_BUFFER_BIT);
262 glMatrixMode (GL_MODELVIEW);
263 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
266 // Move the camera for the current eye's point of view.
267 // Reverse the movement if we're reversing stereo
268 glTranslatef((stereoseparation/2) * side * (stereoreverse ? -1 : 1), 0, 0);
270 if(!cameramode&&!freeze&&!winfreeze){
271 glRotatef(float(Random()%100)/10*camerashake/*+(woozy*woozy)/10*/,0,0,1);
272 glRotatef(rotation2+sin(woozy/2)*(player[0].damage/player[0].damagetolerance)*5,1,0,0);
273 glRotatef(rotation+sin(woozy)*(player[0].damage/player[0].damagetolerance)*5,0,1,0);
275 if(cameramode||freeze||winfreeze){
276 glRotatef(rotation2,1,0,0);
277 glRotatef(rotation,0,1,0);
280 if(environment==desertenvironment){
281 glRotatef((float)(abs(Random()%100))/3000-1,1,0,0);
282 glRotatef((float)(abs(Random()%100))/3000-1,0,1,0);
284 SetUpLight(&light,0);
286 if(environment==desertenvironment&&detail==2)glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, blurness+.4 );
287 if(environment==desertenvironment){
288 glRotatef((float)(abs(Random()%100))/1000,1,0,0);
289 glRotatef((float)(abs(Random()%100))/1000,0,1,0);
292 glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0);
294 glTranslatef(-viewer.x,-viewer.y,-viewer.z);
295 frustum.GetFrustum();
299 static float size,opacity,rotation;
301 for(k=0;k<numplayers;k++){
302 if(!player[k].skeleton.free&&player[k].playerdetail&&player[k].howactive<typesleeping)
303 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)
304 for(i=0;i<player[k].skeleton.num_joints;i++){
305 if(player[k].skeleton.joints[i].label==leftknee||player[k].skeleton.joints[i].label==rightknee||player[k].skeleton.joints[i].label==groin){
306 point=DoRotation(player[k].skeleton.joints[i].position,0,player[k].rotation,0)*player[k].scale+player[k].coords;
308 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;
309 if(k!=0&&tutoriallevel==1){
310 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;
312 terrain.MakeDecal(shadowdecal,point,size,opacity,rotation);
313 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
314 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
315 if(objects.position[j].y<player[k].coords.y||objects.type[j]==tunneltype||objects.type[j]==weirdtype){
316 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);
319 if(k!=0&&tutoriallevel==1){
320 opacity=.2+.2*sin(smoketex*6+i);
322 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
327 if((player[k].skeleton.free||player[k].howactive>=typesleeping)&&player[k].playerdetail)
328 if(frustum.SphereInFrustum(player[k].coords.x,player[k].coords.y,player[k].coords.z,player[k].scale*5)&&player[k].occluded<25)
329 for(i=0;i<player[k].skeleton.num_joints;i++){
330 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){
331 if(player[k].skeleton.free)point=player[k].skeleton.joints[i].position*player[k].scale+player[k].coords;
332 else point=DoRotation(player[k].skeleton.joints[i].position,0,player[k].rotation,0)*player[k].scale+player[k].coords;
334 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;
335 if(k!=0&&tutoriallevel==1){
336 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;
338 terrain.MakeDecal(shadowdecal,point,size,opacity*.7,rotation);
339 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
340 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
341 if(objects.position[j].y<player[k].coords.y||objects.type[j]==tunneltype||objects.type[j]==weirdtype){
342 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);
343 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);
346 if(k!=0&&tutoriallevel==1){
347 opacity=.2+.2*sin(smoketex*6+i);
349 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
355 if(!player[k].playerdetail)
356 if(frustum.SphereInFrustum(player[k].coords.x,player[k].coords.y,player[k].coords.z,player[k].scale*5))
358 point=player[k].coords;
360 opacity=.4-(player[k].coords.y-terrain.getHeight(player[k].coords.x,player[k].coords.z))/5;
361 terrain.MakeDecal(shadowdecal,point,size,opacity*.7,rotation);
362 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
363 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
364 point=DoRotation(player[k].coords-objects.position[j],0,-objects.rotation[j],0);
367 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
373 glEnable(GL_TEXTURE_2D);
375 glEnable(GL_DEPTH_TEST);
376 glEnable(GL_CULL_FACE);
378 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
379 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
380 glBindTexture( GL_TEXTURE_2D, terraintexture);
382 glBindTexture( GL_TEXTURE_2D, terraintexture2);
384 //glBindTexture( GL_TEXTURE_2D, terraintexture3);
385 //glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
388 terrain.drawdecals();
391 glEnable(GL_CULL_FACE);
392 glEnable(GL_LIGHTING);
394 glEnable(GL_TEXTURE_2D);
397 glEnable(GL_COLOR_MATERIAL);
412 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
413 glEnable(GL_CULL_FACE);
414 glCullFace(GL_FRONT);
416 for(k=0;k<numplayers;k++){
417 if(k==0||tutoriallevel!=1){
419 glEnable(GL_LIGHTING);
420 terrainlight=terrain.getLighting(player[k].coords.x,player[k].coords.z);
421 distance=findDistancefast(&viewer,&player[k].coords);
422 distance=(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance;
423 glColor4f(terrainlight.x,terrainlight.y,terrainlight.z,distance);
424 if(distance>=1)glDisable(GL_BLEND);
426 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;
428 if(!player[k].occluded==0)i=checkcollide(viewer,checkpoint,player[k].lastoccluded);
429 if(i==-1||player[k].occluded==0)i=checkcollide(viewer,checkpoint);
431 player[k].occluded+=1;
432 player[k].lastoccluded=i;
434 else player[k].occluded=0;
435 if(player[k].occluded<25)player[k].DrawSkeleton();
441 if(!cameramode&&musictype==stream_fighttheme)playerdist=findDistancefastflat(&player[0].coords,&viewer);
442 else playerdist=-100;
445 glEnable(GL_TEXTURE_2D);
450 if(frustum.SphereInFrustum(realhawkcoords.x+hawk.boundingspherecenter.x,realhawkcoords.y+hawk.boundingspherecenter.y,realhawkcoords.z+hawk.boundingspherecenter.z,2)){
451 glAlphaFunc(GL_GREATER, 0.0001f);
453 glDisable(GL_CULL_FACE);
454 glDisable(GL_LIGHTING);
456 glTranslatef(hawkcoords.x,hawkcoords.y,hawkcoords.z);
457 glRotatef(hawkrotation,0,1,0);
458 glTranslatef(25,0,0);
459 distance=findDistancefast(&viewer,&realhawkcoords)*1.2;
460 glColor4f(light.color[0],light.color[1],light.color[2],(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance);
461 if((viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance>1)glColor4f(light.color[0],light.color[1],light.color[2],1);
462 if((viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance>0)
463 hawk.drawdifftex(hawktexture);
467 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
468 glEnable(GL_CULL_FACE);
469 glCullFace(GL_FRONT);
471 for(k=0;k<numplayers;k++){
472 if(!(k==0||tutoriallevel!=1)){
474 glEnable(GL_LIGHTING);
475 terrainlight=terrain.getLighting(player[k].coords.x,player[k].coords.z);
476 distance=findDistancefast(&viewer,&player[k].coords);
477 distance=(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance;
478 glColor4f(terrainlight.x,terrainlight.y,terrainlight.z,distance);
479 if(distance>=1)glDisable(GL_BLEND);
481 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;
483 if(!player[k].occluded==0)i=checkcollide(viewer,checkpoint,player[k].lastoccluded);
484 if(i==-1||player[k].occluded==0)i=checkcollide(viewer,checkpoint);
486 player[k].occluded+=1;
487 player[k].lastoccluded=i;
489 else player[k].occluded=0;
490 if(player[k].occluded<25)player[k].DrawSkeleton();
496 glEnable(GL_TEXTURE_2D);
501 glDisable(GL_COLOR_MATERIAL);
503 glDisable(GL_LIGHTING);
504 glDisable(GL_TEXTURE_2D);
512 glDisable(GL_LIGHTING);
513 glDisable(GL_TEXTURE_2D);
514 glDisable(GL_COLOR_MATERIAL);
517 for(k=0;k<numplayers;k++){
518 if(player[k].numwaypoints>1){
519 glBegin(GL_LINE_LOOP);
520 for(i=0;i<player[k].numwaypoints;i++){
521 glVertex3f(player[k].waypoints[i].x,player[k].waypoints[i].y+.5,player[k].waypoints[i].z);
530 for(k=0;k<numpathpoints;k++){
531 if(numpathpointconnect[k]){
532 for(i=0;i<numpathpointconnect[k];i++){
533 glBegin(GL_LINE_LOOP);
534 glVertex3f(pathpoint[k].x,pathpoint[k].y+.5,pathpoint[k].z);
535 glVertex3f(pathpoint[pathpointconnect[k][i]].x,pathpoint[pathpointconnect[k][i]].y+.5,pathpoint[pathpointconnect[k][i]].z);
543 glVertex3f(pathpoint[pathpointselected].x,pathpoint[pathpointselected].y+.5,pathpoint[pathpointselected].z);
550 glEnable(GL_TEXTURE_2D);
551 glColor4f(.5,.5,.5,1);
553 sprintf (string, " ",(int)(fps));
554 text.glPrint(10,30,string,0,.8,screenwidth,screenheight);
557 if(bonus>0&&bonustime<1&&!winfreeze&&indialogue==-1/*bonustime<4*/){
558 const char *bonus_name;
559 if (bonus < bonus_count)
560 bonus_name = bonus_names[bonus];
562 bonus_name = "Excellent!"; // When does this happen?
564 glColor4f(0,0,0,1-bonustime);
565 text.glPrintOutline(1024/2-10*strlen(bonus_name)-4,768/16-4+768*4/5,bonus_name,1,2.5,1024,768);
566 glColor4f(1,0,0,1-bonustime);
567 text.glPrint(1024/2-10*strlen(bonus_name),768/16+768*4/5,bonus_name,1,2,1024,768);
569 sprintf (string, "%d",(int)bonusvalue);
570 glColor4f(0,0,0,1-bonustime);
571 text.glPrintOutline(1024/2-10*strlen(string)-4,768/16-4-20+768*4/5,string,1,2.5*.8,1024,768);
572 glColor4f(1,0,0,1-bonustime);
573 text.glPrint(1024/2-10*strlen(string),768/16-20+768*4/5,string,1,2*.8,1024,768);
574 glColor4f(.5,.5,.5,1);
577 if(tutoriallevel==1){
578 tutorialopac=tutorialmaxtime-tutorialstagetime;
579 if(tutorialopac>1)tutorialopac=1;
580 if(tutorialopac<0)tutorialopac=0;
582 sprintf (string, " ");
583 sprintf (string2, " ");
584 sprintf (string3, " ");
585 if(tutorialstage==0){
586 sprintf (string, " ");
587 sprintf (string2, " ");
588 sprintf (string3, " ");
590 if(tutorialstage==1){
591 sprintf (string, "Welcome to the Lugaru training level!");
592 sprintf (string2, " ");
593 sprintf (string3, " ");
595 if(tutorialstage==2){
596 sprintf (string, "BASIC MOVEMENT:");
597 sprintf (string2, " ");
598 sprintf (string3, " ");
600 if(tutorialstage==3){
601 sprintf (string, "You can move the mouse to rotate the camera.");
602 sprintf (string2, " ");
603 sprintf (string3, " ");
605 if(tutorialstage==4){
606 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));
607 sprintf (string2, "All movement is relative to the camera.");
608 sprintf (string3, " ");
610 if(tutorialstage==5){
611 sprintf (string, "Please press %s to jump.",Input::keyToChar(jumpkey));
612 sprintf (string2, "You can hold it longer to jump higher.");
613 sprintf (string3, " ");
615 if(tutorialstage==6){
616 sprintf (string, "You can press %s to crouch.",Input::keyToChar(crouchkey));
617 sprintf (string2, "You can jump higher from a crouching position.");
618 sprintf (string3, " ");
620 if(tutorialstage==7){
621 sprintf (string, "While running, you can press %s to roll.",Input::keyToChar(crouchkey));
622 sprintf (string2, " ");
623 sprintf (string3, " ");
625 if(tutorialstage==8){
626 sprintf (string, "While crouching, you can sneak around silently");
627 sprintf (string2, "using the movement keys.");
628 sprintf (string3, " ");
630 if(tutorialstage==9){
631 sprintf (string, "Release the crouch key while sneaking and hold the movement keys");
632 sprintf (string2, "to run animal-style.");
633 sprintf (string3, " ");
635 if(tutorialstage==10){
636 sprintf (string, "ADVANCED MOVEMENT:");
637 sprintf (string2, " ");
638 sprintf (string3, " ");
640 if(tutorialstage==11){
641 sprintf (string, "When you jump at a wall, you can hold %s again",Input::keyToChar(jumpkey));
642 sprintf (string2, "during impact to perform a walljump.");
643 sprintf (string3, "Be sure to use the movement keys to press against the wall");
645 if(tutorialstage==12){
646 sprintf (string, "While in the air, you can press crouch to flip.",Input::keyToChar(jumpkey));
647 sprintf (string2, "Walljumps and flips confuse enemies and give you more control.");
648 sprintf (string3, " ");
650 if(tutorialstage==13){
651 sprintf (string, "BASIC COMBAT:");
652 sprintf (string2, " ");
653 sprintf (string3, " ");
655 if(tutorialstage==14){
656 sprintf (string, "There is now an imaginary enemy");
657 sprintf (string2, "in the middle of the training area.");
658 sprintf (string3, " ");
660 if(tutorialstage==15){
661 if(attackkey==MOUSEBUTTON1)sprintf (string, "Click to attack when you are near an enemy.");
662 else sprintf (string, "Press %s to attack when you are near an enemy.",Input::keyToChar(attackkey));
663 sprintf (string2, "You can punch by standing still near an enemy and attacking.");
664 sprintf (string3, " ");
666 if(tutorialstage==16){
667 sprintf (string, "If you are close, you will perform a weak punch.");
668 sprintf (string2, "The weak punch is excellent for starting attack combinations.");
669 sprintf (string3, " ");
671 if(tutorialstage==17){
672 sprintf (string, "Attacking while running results in a spin kick.");
673 sprintf (string2, "This is one of your most powerful ground attacks.");
674 sprintf (string3, " ");
676 if(tutorialstage==18){
677 sprintf (string, "Sweep the enemy's legs out by attacking while crouched.");
678 sprintf (string2, "This is a very fast attack, and easy to follow up.");
679 sprintf (string3, " ");
681 if(tutorialstage==19){
682 sprintf (string, "When an enemy is on the ground, you can deal some extra");
683 sprintf (string2, "damage by running up and drop-kicking him.");
684 sprintf (string3, "(Try knocking them down with a sweep first)");
686 if(tutorialstage==20){
687 sprintf (string, "Your most powerful individual attack is the rabbit kick.");
688 if(attackkey==MOUSEBUTTON1)sprintf (string2, "Run at the enemy while holding the mouse button, and press");
689 else sprintf (string2, "Run at the enemy while holding %s, and press", Input::keyToChar(attackkey));
690 sprintf (string3, "the jump key (%s) to attack.",Input::keyToChar(jumpkey));
692 if(tutorialstage==21){
693 sprintf (string, "This attack is devastating if timed correctly.");
694 sprintf (string2, "Even if timed incorrectly, it will knock the enemy over.");
695 if(againbonus)sprintf (string3, "Try rabbit-kicking the imaginary enemy again.");
696 else sprintf (string3, "Try rabbit-kicking the imaginary enemy.");
698 if(tutorialstage==22){
699 sprintf (string, "If you sneak behind an enemy unnoticed, you can kill");
700 sprintf (string2, "him instantly. Move close behind this enemy");
701 sprintf (string3, "and attack.");
703 if(tutorialstage==23){
704 sprintf (string, "Another important attack is the wall kick. When an enemy");
705 sprintf (string2, "is near a wall, perform a walljump nearby and hold");
706 sprintf (string3, "the attack key during impact with the wall.");
708 if(tutorialstage==24){
709 sprintf (string, "You can tackle enemies by running at them animal-style");
710 if(attackkey==MOUSEBUTTON1)sprintf (string2, "and pressing jump (%s) or attack(mouse button).",Input::keyToChar(jumpkey));
711 else sprintf (string2, "and pressing jump (%s) or attack(%s).",Input::keyToChar(jumpkey),Input::keyToChar(attackkey));
712 sprintf (string3, "This is especially useful when they are running away.");
714 if(tutorialstage==25){
715 sprintf (string, "Dodge by pressing back and attack. Dodging is essential");
716 sprintf (string2, "against enemies with swords or other long weapons.");
717 sprintf (string3, " ");
719 if(tutorialstage==26){
720 sprintf (string, "REVERSALS AND COUNTER-REVERSALS");
721 sprintf (string2, " ");
722 sprintf (string3, " ");
724 if(tutorialstage==27){
725 sprintf (string, "The enemy can now reverse your attacks.");
726 sprintf (string2, " ");
727 sprintf (string3, " ");
729 if(tutorialstage==28){
730 sprintf (string, "If you attack, you will notice that the enemy now sometimes");
731 sprintf (string2, "catches your attack and uses it against you. Hold");
732 sprintf (string3, "crouch (%s) after attacking to escape from reversals.",Input::keyToChar(crouchkey));
734 if(tutorialstage==29){
735 sprintf (string, "Try escaping from two more reversals in a row.");
736 sprintf (string2, " ");
737 sprintf (string3, " ");
739 if(tutorialstage==30){
740 sprintf (string, "Good!");
741 sprintf (string2, " ");
742 sprintf (string3, " ");
744 if(tutorialstage==31){
745 sprintf (string, "To reverse an attack, you must tap crouch (%s) during the",Input::keyToChar(crouchkey));
746 sprintf (string2, "enemy's attack. You must also be close to the enemy;");
747 sprintf (string3, "this is especially important against armed opponents.");
749 if(tutorialstage==32){
750 sprintf (string, "The enemy can attack in %d seconds.", (int)(tutorialmaxtime-tutorialstagetime));
751 sprintf (string2, "This imaginary opponents attacks will be highlighted");
752 sprintf (string3, "to make this easier.");
754 if(tutorialstage==33){
755 sprintf (string, "Reverse three enemy attacks!");
756 sprintf (string2, " ");
757 sprintf (string3, " ");
759 if(tutorialstage==34){
760 sprintf (string, "Reverse two more enemy attacks!");
761 sprintf (string2, " ");
762 sprintf (string3, " ");
764 if(tutorialstage==35){
765 sprintf (string, "Reverse one more enemy attack!");
766 sprintf (string2, " ");
767 sprintf (string3, " ");
769 if(tutorialstage==36){
770 sprintf (string, "Excellent!");
771 sprintf (string2, " ");
772 sprintf (string3, " ");
774 if(tutorialstage==37){
775 sprintf (string, "Now spar with the enemy for %d more seconds.", (int)(tutorialmaxtime-tutorialstagetime));
776 sprintf (string2, "Damage dealt: %d",(int)damagedealt);
777 sprintf (string3, "Damage taken: %d.",(int)damagetaken);
779 if(tutorialstage==38){
780 sprintf (string, "WEAPONS:");
781 sprintf (string2, " ");
782 sprintf (string3, " ");
784 if(tutorialstage==39){
785 sprintf (string, "There is now an imaginary knife");
786 sprintf (string2, "in the center of the training area.");
787 sprintf (string3, " ");
789 if(tutorialstage==40){
790 sprintf (string, "Stand, roll or handspring over the knife");
791 sprintf (string2, "while pressing %s to pick it up.",Input::keyToChar(throwkey));
792 sprintf (string3, "You can crouch and press the same key to drop it again.");
794 if(tutorialstage==41){
795 sprintf (string, "You can equip and unequip weapons using the %s key.",Input::keyToChar(drawkey));
796 sprintf (string2, "Sometimes it is best to keep them unequipped to");
797 sprintf (string3, "prevent enemies from taking them. ");
799 if(tutorialstage==42){
800 sprintf (string, "The knife is the smallest weapon and the least encumbering.");
801 sprintf (string2, "You can equip or unequip it while standing, crouching,");
802 sprintf (string3, "running or flipping.");
804 if(tutorialstage==43){
805 sprintf (string, "You perform weapon attacks the same way as unarmed attacks,");
806 sprintf (string2, "but sharp weapons cause permanent damage, instead of the");
807 sprintf (string3, "temporary trauma from blunt weapons, fists and feet.");
809 if(tutorialstage==44){
810 sprintf (string, "The enemy now has your knife!");
811 sprintf (string2, "Please reverse two of his knife attacks.");
812 sprintf (string3, " ");
814 if(tutorialstage==45){
815 sprintf (string, "Please reverse one more of his knife attacks.");
816 sprintf (string2, " ");
817 sprintf (string3, " ");
819 if(tutorialstage==46){
820 sprintf (string, "Now he has a sword!");
821 sprintf (string2, "The sword has longer reach than your arms, so you");
822 sprintf (string3, "must move close to reverse the sword slash.");
824 if(tutorialstage==47){
825 sprintf (string, "Long weapons like the sword and staff are also useful for defense;");
826 sprintf (string2, "you can parry enemy weapon attacks by pressing the attack key");
827 sprintf (string3, "at the right time. Please try parrying the enemy's attacks!");
829 if(tutorialstage==48){
830 sprintf (string, "The staff is like the sword, but has two main attacks.");
831 sprintf (string2, "The standing smash is fast and effective, and the running");
832 sprintf (string3, "spin smash is slower and more powerful.");
834 if(tutorialstage==49){
835 sprintf (string, "When facing an enemy, you can throw the knife with %s.",Input::keyToChar(throwkey));
836 sprintf (string2, "It is possible to throw the knife while flipping,");
837 sprintf (string3, "but it is very inaccurate.");
839 if(tutorialstage==50){
840 sprintf (string, "You now know everything you can learn from training.");
841 sprintf (string2, "Everything else you must learn from experience!");
842 sprintf (string3, " ");
844 if(tutorialstage==51){
845 sprintf (string, "Walk out of the training area to return to the main menu.");
846 sprintf (string2, " ");
847 sprintf (string3, " ");
850 glColor4f(0,0,0,tutorialopac);
851 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);
852 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);
853 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);
854 glColor4f(1,1,1,tutorialopac);
855 text.glPrint(screenwidth/2-7.6*strlen(string)*screenwidth/1024,screenheight/16+screenheight*4/5,string,1,1.5*screenwidth/1024,screenwidth,screenheight);
856 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);
857 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);
859 sprintf (string, "Press 'tab' to skip to the next item.",Input::keyToChar(jumpkey));
860 sprintf (string2, "Press escape at any time to");
861 sprintf (string3, "pause or exit the tutorial.");
864 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);
865 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);
866 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);
867 glColor4f(0.5,0.5,0.5,1);
868 text.glPrint(screenwidth/2-7.6*strlen(string)*screenwidth/1024*.8,0+screenheight*1/10,string,1,1.5*screenwidth/1024*.8,screenwidth,screenheight);
869 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);
870 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);
874 if(numhotspots&&(bonustime>=1||bonus<=0||bonustime<0)&&!tutoriallevel){
876 float closestdist=-1;
878 closest=currenthotspot;
879 for(i=0;i<numhotspots;i++){
880 distance=findDistancefast(&player[0].coords,&hotspot[i]);
881 if(closestdist==-1||distance<closestdist){
882 if(findDistancefast(&player[0].coords,&hotspot[i])<hotspotsize[i]&&((hotspottype[i]<=10&&hotspottype[i]>=0)||(hotspottype[i]<=40&&hotspottype[i]>=20))){
883 closestdist=distance;
889 currenthotspot=closest;
890 if(currenthotspot!=-1){
891 if(hotspottype[closest]<=10){
892 if(findDistancefast(&player[0].coords,&hotspot[closest])<hotspotsize[closest])
895 tutorialopac=tutorialmaxtime-tutorialstagetime;
896 if(tutorialopac>1)tutorialopac=1;
897 if(tutorialopac<0)tutorialopac=0;
899 sprintf (string, "%s", hotspottext[closest]);
906 if(string[i]=='\n'||string[i]>'z'||string[i]<' '||string[i]=='\0'){
907 glColor4f(0,0,0,tutorialopac);
908 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);
909 glColor4f(1,1,1,tutorialopac);
910 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);
913 if(string[i]=='\0')done=1;
919 else if (hotspottype[closest]>=20&&dialoguegonethrough[hotspottype[closest]-20]==0){
920 whichdialogue=hotspottype[closest]-20;
921 for(j=0;j<numdialogueboxes[whichdialogue];j++){
922 player[participantfocus[whichdialogue][j]].coords=participantlocation[whichdialogue][participantfocus[whichdialogue][j]];
923 player[participantfocus[whichdialogue][j]].rotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
924 player[participantfocus[whichdialogue][j]].targetrotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
925 player[participantfocus[whichdialogue][j]].velocity=0;
926 player[participantfocus[whichdialogue][j]].targetanimation=player[participantfocus[whichdialogue][j]].getIdle();
927 player[participantfocus[whichdialogue][j]].targetframe=0;
931 dialoguegonethrough[whichdialogue]++;
932 if(dialogueboxsound[whichdialogue][indialogue]!=0){
934 if(dialogueboxsound[whichdialogue][indialogue]==1)whichsoundplay=rabbitchitter;
935 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
936 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
937 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
938 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
939 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
940 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
941 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
942 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
943 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
944 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
945 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
946 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
947 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
948 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
949 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
950 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
951 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
952 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
953 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
954 emit_sound_at(whichsoundplay, player[participantfocus[whichdialogue][indialogue]].coords);
960 if(indialogue!=-1&&!mainmenu){
961 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
962 glDisable(GL_CULL_FACE);
963 glDisable(GL_LIGHTING);
964 glDisable(GL_TEXTURE_2D);
966 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
967 glPushMatrix(); // Store The Projection Matrix
968 glLoadIdentity(); // Reset The Projection Matrix
969 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
970 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
971 glPushMatrix(); // Store The Modelview Matrix
972 glLoadIdentity(); // Reset The Modelview Matrix
973 if(dialogueboxlocation[whichdialogue][indialogue]==1)glTranslatef(0,screenheight*3/4,0);
974 glScalef(screenwidth,screenheight/4,1);
975 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
978 glColor4f(dialogueboxcolor[whichdialogue][indialogue][0],dialogueboxcolor[whichdialogue][indialogue][1],dialogueboxcolor[whichdialogue][indialogue][2],0.7);
980 glVertex3f(0, 0, 0.0f);
981 glVertex3f(1, 0, 0.0f);
982 glVertex3f(1, 1, 0.0f);
983 glVertex3f(0, 1, 0.0f);
985 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
986 glPopMatrix(); // Restore The Old Projection Matrix
987 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
988 glPopMatrix(); // Restore The Old Projection Matrix
989 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
990 glEnable(GL_CULL_FACE);
993 glEnable(GL_TEXTURE_2D);
1000 startx=screenwidth*1/5;
1001 if(dialogueboxlocation[whichdialogue][indialogue]==1)starty=screenheight/16+screenheight*4/5;
1002 if(dialogueboxlocation[whichdialogue][indialogue]==2)starty=screenheight*1/5-screenheight/16;
1011 for(i=0;i<(int)strlen(dialoguename[whichdialogue][indialogue]);i++){
1012 tempname[tempnum]=dialoguename[whichdialogue][indialogue][i];
1014 if(dialoguename[whichdialogue][indialogue][i]=='#'||dialoguename[whichdialogue][indialogue][i]=='\0')goodchar=0;
1018 tempname[tempnum]='\0';
1021 sprintf (string, "%s: ", tempname);
1023 if(dialogueboxcolor[whichdialogue][indialogue][0]+dialogueboxcolor[whichdialogue][indialogue][1]+dialogueboxcolor[whichdialogue][indialogue][2]<1.5){
1024 glColor4f(0,0,0,tutorialopac);
1025 text.glPrintOutline(startx-2*7.6*strlen(string)*screenwidth/1024-4,starty-4,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight);
1026 glColor4f(0.7,0.7,0.7,tutorialopac);
1027 text.glPrint(startx-2*7.6*strlen(string)*screenwidth/1024,starty,string,1,1.5*screenwidth/1024,screenwidth,screenheight);
1031 glColor4f(0,0,0,tutorialopac);
1032 text.glPrintOutline(startx-2*7.6*strlen(string)*screenwidth/1024-4,starty-4,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight);
1036 for(i=0;i<(int)strlen(dialoguetext[whichdialogue][indialogue])+1;i++){
1037 tempname[tempnum]=dialoguetext[whichdialogue][indialogue][i];
1038 if(dialoguetext[whichdialogue][indialogue][i]!='#')tempnum++;
1041 sprintf (string, "%s", tempname);
1048 if(string[i]=='\n'||string[i]>'z'||string[i]<' '||string[i]=='\0'){
1049 if(dialogueboxcolor[whichdialogue][indialogue][0]+dialogueboxcolor[whichdialogue][indialogue][1]+dialogueboxcolor[whichdialogue][indialogue][2]<1.5){
1050 glColor4f(0,0,0,tutorialopac);
1051 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);
1052 glColor4f(1,1,1,tutorialopac);
1053 text.glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/,starty-20*screenwidth/1024*line,string,1,1.5*screenwidth/1024,screenwidth,screenheight,lastline,i);
1057 glColor4f(0,0,0,tutorialopac);
1058 text.glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/,starty-20*screenwidth/1024*line,string,1,1.5*screenwidth/1024,screenwidth,screenheight,lastline,i);
1062 if(string[i]=='\0')done=1;
1069 if(!tutoriallevel&&!winfreeze&&indialogue==-1&&!mainmenu){
1072 sprintf (string, "Score: %d", (int)accountactive->getCampaignScore());
1074 sprintf (string, "Score: %d", (int)accountactive->getCampaignScore()+(int)bonustotal);
1076 if(!campaign)sprintf (string, "Score: %d", (int)bonustotal);
1078 text.glPrintOutline(1024/40-4,768/16-4+768*14/16,string,1,1.5*1.25,1024,768);
1080 text.glPrint(1024/40,768/16+768*14/16,string,1,1.5,1024,768);
1082 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1083 glDisable(GL_CULL_FACE);
1084 glDisable(GL_LIGHTING);
1085 glDisable(GL_TEXTURE_2D);
1087 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1088 glPushMatrix(); // Store The Projection Matrix
1089 glLoadIdentity(); // Reset The Projection Matrix
1090 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1091 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1092 glPushMatrix(); // Store The Modelview Matrix
1093 glLoadIdentity(); // Reset The Modelview Matrix
1094 glTranslatef(15,screenheight*17.5/20,0);
1095 glScalef(screenwidth/3+20,screenheight/20,1);
1096 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1098 glColor4f(0.0,0.4,0.0,0.7);
1099 float bar=((float)player[0].damage)/player[0].damagetolerance;
1101 glVertex3f((bar<1?bar:1),0,0.0f);
1102 glVertex3f(1,0,0.0f);
1103 glVertex3f(1,1,0.0f);
1104 glVertex3f((bar<1?bar:1),1,0.0f);
1106 glColor4f(0.1,0.0,0.0,1);
1107 bar = ((float)player[0].bloodloss)/player[0].damagetolerance;
1109 glVertex3f(0,0,0.0f);
1110 glVertex3f((bar<1?bar:1),0,0.0f);
1111 glVertex3f((bar<1?bar:1),1,0.0f);
1112 glVertex3f(0,1,0.0f);
1114 glColor4f(0.4,0.0,0.0,0.7);
1115 bar = ((float)player[0].damage)/player[0].damagetolerance;
1117 glVertex3f(0,0,0.0f);
1118 glVertex3f((bar<1?bar:1),0,0.0f);
1119 glVertex3f((bar<1?bar:1),1,0.0f);
1120 glVertex3f(0,1,0.0f);
1122 glColor4f(0.4,0.0,0.0,0.7);
1123 bar = ((float)player[0].permanentdamage)/player[0].damagetolerance;
1125 glVertex3f(0,0,0.0f);
1126 glVertex3f((bar<1?bar:1),0,0.0f);
1127 glVertex3f((bar<1?bar:1),1,0.0f);
1128 glVertex3f(0,1,0.0f);
1130 glColor4f(0.4,0.0,0.0,0.7);
1131 bar = ((float)player[0].superpermanentdamage)/player[0].damagetolerance;
1133 glVertex3f(0,0,0.0f);
1134 glVertex3f((bar<1?bar:1),0,0.0f);
1135 glVertex3f((bar<1?bar:1),1,0.0f);
1136 glVertex3f(0,1,0.0f);
1138 glColor4f(0.0,0.0,0.0,0.7);
1140 glBegin(GL_LINE_STRIP);
1141 glVertex3f(0,0,0.0f);
1142 glVertex3f(1,0,0.0f);
1143 glVertex3f(1,1,0.0f);
1144 glVertex3f(0,1,0.0f);
1145 glVertex3f(0,0,0.0f);
1148 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1149 glPopMatrix(); // Restore The Old Projection Matrix
1150 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1151 glPopMatrix(); // Restore The Old Projection Matrix
1152 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1153 glEnable(GL_CULL_FACE);
1154 glDisable(GL_BLEND);
1156 glEnable(GL_TEXTURE_2D);
1158 // writing the numbers :
1159 sprintf (string, "Damages : %d/%d (%d)",(int)(player[0].damage),(int)(player[0].damagetolerance),(int)(player[0].bloodloss));
1161 text.glPrintOutline(1024/40-4,768/16-4+768*14/16-40,string,1,1.5*1.25,1024,768);
1163 text.glPrint(1024/40,768/16+768*14/16-40,string,1,1.5,1024,768);
1167 glColor4f(.5,.5,.5,1);
1170 if((texttoggle||editorenabled)&&debugmode&&!mainmenu){
1171 sprintf (string, "The framespersecond is %d.",(int)(fps));
1172 text.glPrint(10,30,string,0,.8,1024,768);
1174 sprintf (string, "Name: %s", registrationname);
1175 text.glPrint(10,260,string,0,.8,1024,768);
1179 sprintf (string, "Map editor enabled.");
1181 sprintf (string, "Map editor disabled.");
1182 text.glPrint(10,60,string,0,.8,1024,768);
1184 sprintf (string, "Object size: %f",editorsize);
1185 text.glPrint(10,75,string,0,.8,1024,768);
1186 if(editorrotation>=0)sprintf (string, "Object rotation: %f",editorrotation);
1187 else sprintf (string, "Object rotation: Random");
1188 text.glPrint(10,90,string,0,.8,1024,768);
1189 if(editorrotation2>=0)sprintf (string, "Object rotation2: %f",editorrotation2);
1190 else sprintf (string, "Object rotation2: Random");
1191 text.glPrint(10,105,string,0,.8,1024,768);
1192 sprintf (string, "Object type: %d",editortype);
1193 text.glPrint(10,120,string,0,.8,1024,768);
1194 switch(editortype) {
1196 sprintf (string, "(box)");
1199 sprintf (string, "(tree)");
1202 sprintf (string, "(wall)");
1205 sprintf (string, "(weird)");
1208 sprintf (string, "(spike)");
1211 sprintf (string, "(rock)");
1214 sprintf (string, "(bush)");
1217 sprintf (string, "(tunnel)");
1220 sprintf (string, "(chimney)");
1223 sprintf (string, "(platform)");
1226 sprintf (string, "(cool)");
1229 sprintf (string, "(fire)");
1232 text.glPrint(130,120,string,0,.8,1024,768);
1234 sprintf (string, "Numplayers: %d",numplayers);
1235 text.glPrint(10,155,string,0,.8,1024,768);
1236 sprintf (string, "Player %d: numwaypoints: %d",numplayers,player[numplayers-1].numwaypoints);
1237 text.glPrint(10,140,string,0,.8,1024,768);
1239 sprintf (string, "Difficulty: %d",difficulty);
1240 text.glPrint(10,240,string,0,.8,1024,768);
1245 if(drawmode==glowmode){
1246 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1247 glDisable(GL_CULL_FACE);
1248 glDisable(GL_LIGHTING);
1249 glDisable(GL_TEXTURE_2D);
1251 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1252 glPushMatrix(); // Store The Projection Matrix
1253 glLoadIdentity(); // Reset The Projection Matrix
1254 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1255 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1256 glPushMatrix(); // Store The Modelview Matrix
1257 glLoadIdentity(); // Reset The Modelview Matrix
1258 glScalef(screenwidth,screenheight,1);
1259 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1261 glColor4f(0,0,0,.5);
1263 glVertex3f(0, 0, 0.0f);
1264 glVertex3f(256, 0, 0.0f);
1265 glVertex3f(256, 256, 0.0f);
1266 glVertex3f(0, 256, 0.0f);
1268 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1269 glPopMatrix(); // Restore The Old Projection Matrix
1270 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1271 glPopMatrix(); // Restore The Old Projection Matrix
1272 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1273 glEnable(GL_CULL_FACE);
1274 glDisable(GL_BLEND);
1278 if((((blackout&&damageeffects)||(player[0].bloodloss>0&&damageeffects&&player[0].blooddimamount>0)||player[0].dead)&&!cameramode)||console){
1279 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1280 glDisable(GL_CULL_FACE);
1281 glDisable(GL_LIGHTING);
1282 glDisable(GL_TEXTURE_2D);
1284 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1285 glPushMatrix(); // Store The Projection Matrix
1286 glLoadIdentity(); // Reset The Projection Matrix
1287 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1288 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1289 glPushMatrix(); // Store The Modelview Matrix
1290 glLoadIdentity(); // Reset The Modelview Matrix
1291 glScalef(screenwidth,screenheight,1);
1292 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1294 if(player[0].dead)blackout+=multiplier*3;
1295 if(player[0].dead==1)blackout=.4f;
1296 if(player[0].dead==2&&blackout>.6)blackout=.6;
1297 glColor4f(0,0,0,blackout);
1298 if(!player[0].dead){
1299 if((player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5))*.3<.3){
1300 glColor4f(0,0,0,player[0].blooddimamount*player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5)*.3);
1301 blackout=player[0].blooddimamount*player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5)*.3;
1304 glColor4f(0,0,0,player[0].blooddimamount*.3);
1305 blackout=player[0].blooddimamount*.3;
1308 if(console)glColor4f(.7,0,0,.2);
1310 glVertex3f(0, 0, 0.0f);
1311 glVertex3f(256, 0, 0.0f);
1312 glVertex3f(256, 256, 0.0f);
1313 glVertex3f(0, 256, 0.0f);
1315 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1316 glPopMatrix(); // Restore The Old Projection Matrix
1317 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1318 glPopMatrix(); // Restore The Old Projection Matrix
1319 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1320 glEnable(GL_CULL_FACE);
1321 glDisable(GL_BLEND);
1325 if(flashamount>0&&damageeffects){
1326 if(flashamount>1)flashamount=1;
1327 if(flashdelay<=0)flashamount-=multiplier;
1329 if(flashamount<0)flashamount=0;
1330 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1331 glDisable(GL_CULL_FACE);
1332 glDisable(GL_LIGHTING);
1334 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1335 glPushMatrix(); // Store The Projection Matrix
1336 glLoadIdentity(); // Reset The Projection Matrix
1337 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1338 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1339 glPushMatrix(); // Store The Modelview Matrix
1340 glLoadIdentity(); // Reset The Modelview Matrix
1341 glScalef(screenwidth,screenheight,1);
1342 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1344 glColor4f(flashr,flashg,flashb,flashamount);
1346 glVertex3f(0, 0, 0.0f);
1347 glVertex3f(256, 0, 0.0f);
1348 glVertex3f(256, 256, 0.0f);
1349 glVertex3f(0, 256, 0.0f);
1351 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1352 glPopMatrix(); // Restore The Old Projection Matrix
1353 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1354 glPopMatrix(); // Restore The Old Projection Matrix
1355 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1356 glEnable(GL_CULL_FACE);
1357 glDisable(GL_BLEND);
1363 glEnable(GL_TEXTURE_2D);
1366 sprintf (string, " ]");
1367 text.glPrint(10,30+screenheight-330,string,0,1,screenwidth,screenheight);
1369 sprintf (string, "_");
1370 text.glPrint(30+(float)(displayselected)*10,30+(screenheight-330),string,0,1,screenwidth,screenheight);
1374 if((i!=0||chatting)&&displaytime[i]<4)
1375 for(j=0;j<displaychars[i];j++){
1376 glColor4f(1,1,1,4-displaytime[i]);
1377 if(j<displaychars[i]){
1378 sprintf (string, "%c",displaytext[i][j]);
1379 text.glPrint(30+j*10,30+i*20+(screenheight-330),string,0,1,screenwidth,screenheight);
1385 if(minimap&&indialogue==-1){
1386 float mapviewdist = 20000;
1388 glDisable(GL_DEPTH_TEST);
1389 glColor3f (1.0, 1.0, 1.0); // no coloring
1391 glEnable(GL_TEXTURE_2D);
1392 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1393 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1394 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1395 glDisable(GL_CULL_FACE);
1396 glDisable(GL_LIGHTING);
1398 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1399 glPushMatrix(); // Store The Projection Matrix
1400 glLoadIdentity(); // Reset The Projection Matrix
1401 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1402 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1403 glPushMatrix(); // Store The Modelview Matrix
1404 glLoadIdentity(); // Reset The Modelview Matrix
1405 glScalef((float)screenwidth/2,(float)screenwidth/2,1);
1406 glTranslatef(1.75,.25,0);
1407 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1415 int numliveplayers=0;
1417 for(i=0;i<numplayers;i++){
1418 if(!player[i].dead) numliveplayers++;
1423 for(i=0;i<objects.numobjects;i++){
1424 if(objects.type[i]==treetrunktype||objects.type[i]==boxtype){
1425 center+=objects.position[i];
1429 for(i=0;i<numplayers;i++){
1430 if(!player[i].dead)center+=player[i].coords;
1432 center/=numadd+numliveplayers;
1434 center=player[0].coords;
1436 float maxdistance=0;
1438 //~ int whichclosest;
1439 for(i=0;i<objects.numobjects;i++){
1440 tempdist=findDistancefast(¢er,&objects.position[i]);
1441 if(tempdist>maxdistance){
1443 maxdistance=tempdist;
1446 for(i=0;i<numplayers;i++){
1447 if(!player[i].dead){
1448 tempdist=findDistancefast(¢er,&player[i].coords);
1449 if(tempdist>maxdistance){
1451 maxdistance=tempdist;
1455 radius=fast_sqrt(maxdistance);
1459 glScalef(.25/radius*256*terrain.scale*.4,.25/radius*256*terrain.scale*.4,1);
1461 glScalef(1/(1/radius*256*terrain.scale*.4),1/(1/radius*256*terrain.scale*.4),1);
1463 glRotatef(player[0].lookrotation*-1+180,0,0,1);
1464 glTranslatef(-(center.x/terrain.scale/256*-2+1),(center.z/terrain.scale/256*-2+1),0);
1465 for(i=0;i<objects.numobjects;i++){
1466 if(objects.type[i]==treetrunktype){
1467 distcheck=findDistancefast(&player[0].coords,&objects.position[i]);
1468 if(distcheck<mapviewdist){
1469 glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
1470 glColor4f(0,.3,0,opac*(1-distcheck/mapviewdist));
1472 glTranslatef(objects.position[i].x/terrain.scale/256*-2+1,objects.position[i].z/terrain.scale/256*2-1,0);
1473 glRotatef(objects.rotation[i],0,0,1);
1474 glScalef(.003,.003,.003);
1477 glVertex3f(-1, -1, 0.0f);
1479 glVertex3f(1, -1, 0.0f);
1481 glVertex3f(1, 1, 0.0f);
1483 glVertex3f(-1, 1, 0.0f);
1488 if(objects.type[i]==boxtype){
1489 distcheck=findDistancefast(&player[0].coords,&objects.position[i]);
1490 if(distcheck<mapviewdist){
1491 glBindTexture( GL_TEXTURE_2D, Mapboxtexture);
1492 glColor4f(.4,.4,.4,opac*(1-distcheck/mapviewdist));
1494 glTranslatef(objects.position[i].x/terrain.scale/256*-2+1,objects.position[i].z/terrain.scale/256*2-1,0);
1495 glRotatef(objects.rotation[i],0,0,1);
1496 glScalef(.01*objects.scale[i],.01*objects.scale[i],.01*objects.scale[i]);
1499 glVertex3f(-1, -1, 0.0f);
1501 glVertex3f(1, -1, 0.0f);
1503 glVertex3f(1, 1, 0.0f);
1505 glVertex3f(-1, 1, 0.0f);
1512 glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
1513 for(i=0;i<numboundaries;i++){
1514 glColor4f(0,0,0,opac/3);
1516 glTranslatef(boundary[i].x/terrain.scale/256*-2+1,boundary[i].z/terrain.scale/256*2-1,0);
1517 glScalef(.002,.002,.002);
1520 glVertex3f(-1, -1, 0.0f);
1522 glVertex3f(1, -1, 0.0f);
1524 glVertex3f(1, 1, 0.0f);
1526 glVertex3f(-1, 1, 0.0f);
1531 for(i=0;i<numplayers;i++){
1532 distcheck=findDistancefast(&player[0].coords,&player[i].coords);
1533 if(distcheck<mapviewdist){
1535 glBindTexture( GL_TEXTURE_2D, Maparrowtexture);
1536 if(i==0)glColor4f(1,1,1,opac);
1537 else if(player[i].dead==2||player[i].howactive>typesleeping)glColor4f(0,0,0,opac*(1-distcheck/mapviewdist));
1538 else if(player[i].dead)glColor4f(.3,.3,.3,opac*(1-distcheck/mapviewdist));
1539 else if(player[i].aitype==attacktypecutoff)glColor4f(1,0,0,opac*(1-distcheck/mapviewdist));
1540 else if(player[i].aitype==passivetype)glColor4f(0,1,0,opac*(1-distcheck/mapviewdist));
1541 else glColor4f(1,1,0,1);
1542 glTranslatef(player[i].coords.x/terrain.scale/256*-2+1,player[i].coords.z/terrain.scale/256*2-1,0);
1543 glRotatef(player[i].rotation+180,0,0,1);
1544 glScalef(.005,.005,.005);
1547 glVertex3f(-1, -1, 0.0f);
1549 glVertex3f(1, -1, 0.0f);
1551 glVertex3f(1, 1, 0.0f);
1553 glVertex3f(-1, 1, 0.0f);
1559 glDisable(GL_TEXTURE_2D);
1560 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1561 glPopMatrix(); // Restore The Old Projection Matrix
1562 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1563 glPopMatrix(); // Restore The Old Projection Matrix
1564 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1565 glEnable(GL_CULL_FACE);
1566 glDisable(GL_BLEND);
1570 if(loading&&!stealthloading&&(!campaign||player[0].dead)){
1571 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1572 glDisable(GL_CULL_FACE);
1573 glDisable(GL_LIGHTING);
1574 glDisable(GL_TEXTURE_2D);
1576 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1577 glPushMatrix(); // Store The Projection Matrix
1578 glLoadIdentity(); // Reset The Projection Matrix
1579 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1580 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1581 glPushMatrix(); // Store The Modelview Matrix
1582 glLoadIdentity(); // Reset The Modelview Matrix
1583 glScalef(screenwidth,screenheight,1);
1584 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1586 glColor4f(0,0,0,.7);
1588 glVertex3f(0, 0, 0.0f);
1589 glVertex3f(256, 0, 0.0f);
1590 glVertex3f(256, 256, 0.0f);
1591 glVertex3f(0, 256, 0.0f);
1593 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1594 glPopMatrix(); // Restore The Old Projection Matrix
1595 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1596 glPopMatrix(); // Restore The Old Projection Matrix
1597 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1598 glEnable(GL_CULL_FACE);
1599 glDisable(GL_BLEND);
1603 glDisable(GL_DEPTH_TEST);
1604 glColor3f (1.0, 1.0, 1.0); // no coloring
1606 glEnable(GL_TEXTURE_2D);
1611 glEnable(GL_TEXTURE_2D);
1613 sprintf (string, "Loading...");
1614 text.glPrint(1024/2-90,768/2,string,1,2,1024,768);
1617 //if(ismotionblur)drawmode=motionblurmode;
1618 drawmode=normalmode;
1621 if(winfreeze&&!campaign){
1622 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1623 glDisable(GL_CULL_FACE);
1624 glDisable(GL_LIGHTING);
1625 glDisable(GL_TEXTURE_2D);
1627 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1628 glPushMatrix(); // Store The Projection Matrix
1629 glLoadIdentity(); // Reset The Projection Matrix
1630 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1631 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1632 glPushMatrix(); // Store The Modelview Matrix
1633 glLoadIdentity(); // Reset The Modelview Matrix
1634 glScalef(screenwidth,screenheight,1);
1635 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1637 glColor4f(0,0,0,.4);
1639 glVertex3f(0, 0, 0.0f);
1640 glVertex3f(256, 0, 0.0f);
1641 glVertex3f(256, 256, 0.0f);
1642 glVertex3f(0, 256, 0.0f);
1644 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1645 glPopMatrix(); // Restore The Old Projection Matrix
1646 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1647 glPopMatrix(); // Restore The Old Projection Matrix
1648 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1649 glEnable(GL_CULL_FACE);
1650 glDisable(GL_BLEND);
1654 glDisable(GL_DEPTH_TEST);
1655 glColor3f (1.0, 1.0, 1.0); // no coloring
1657 glEnable(GL_TEXTURE_2D);
1659 //Win Screen Won Victory
1661 glEnable(GL_TEXTURE_2D);
1663 sprintf (string, "Level Cleared!");
1664 text.glPrintOutlined(1024/2-strlen(string)*10,768*7/8,string,1,2,1024,768);
1666 sprintf (string, "Score: %d",(int)(bonustotal-startbonustotal));
1667 text.glPrintOutlined(1024/30,768*6/8,string,1,2,1024,768);
1670 sprintf (string, "Press Escape or Space to continue");
1672 sprintf (string, "Press Escape to return to menu or Space to continue");
1673 text.glPrintOutlined(640/2-strlen(string)*5,480*1/16,string,1,1,640,480);
1677 for(i=0;i<255;i++)string[i]='\0';
1678 sprintf (temp, "Time: %d:",(int)(((int)leveltime-(int)(leveltime)%60)/60));
1679 strcat(string,temp);
1680 if((int)(leveltime)%60<10)strcat(string,"0");
1681 sprintf (temp, "%d",(int)(leveltime)%60);
1682 strcat(string,temp);
1683 text.glPrintOutlined(1024/30,768*6/8-40,string,1,2,1024,768);
1686 int awards[award_count];
1687 int numawards = award_awards(awards);
1689 for (i = 0; i < numawards && i < 6; i++)
1690 text.glPrintOutlined(1024/30,768*6/8-90-40*i,award_names[awards[i]],1,2,1024,768);
1693 if(drawmode!=normalmode){
1694 glEnable(GL_TEXTURE_2D);
1696 if(!drawtoggle||drawmode!=realmotionblurmode||(drawtoggle==2||change==1)){
1699 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
1700 GLfloat subtractColor[4] = { 0.5, 0.5, 0.5, 0.0 };
1701 glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, subtractColor);
1702 //glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_SUBTRACT);
1703 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE);
1704 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_CONSTANT_EXT);
1705 glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 2.0f);
1707 glBindTexture( GL_TEXTURE_2D, screentexture);
1708 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1711 if((drawtoggle||change==1)&&drawmode==realmotionblurmode){
1713 glBindTexture( GL_TEXTURE_2D, screentexture2);
1714 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1716 if(!screentexture2){
1717 glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
1719 glGenTextures( 1, &screentexture2 );
1720 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
1722 glEnable(GL_TEXTURE_2D);
1723 glBindTexture( GL_TEXTURE_2D, screentexture2);
1724 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
1725 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
1727 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
1733 glClear(GL_DEPTH_BUFFER_BIT);
1734 ReSizeGLScene(90,.1f);
1735 glViewport(0,0,screenwidth,screenheight);
1737 if(drawmode!=normalmode){
1738 glDisable(GL_DEPTH_TEST);
1739 if(drawmode==motionblurmode){
1740 glDrawBuffer(GL_FRONT);
1741 glReadBuffer(GL_BACK);
1743 glColor3f (1.0, 1.0, 1.0); // no coloring
1745 glEnable(GL_TEXTURE_2D);
1746 glBindTexture( GL_TEXTURE_2D, screentexture);
1747 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1748 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1749 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1750 glDisable(GL_CULL_FACE);
1751 glDisable(GL_LIGHTING);
1753 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1754 glPushMatrix(); // Store The Projection Matrix
1755 glLoadIdentity(); // Reset The Projection Matrix
1756 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1757 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1758 glPushMatrix(); // Store The Modelview Matrix
1759 glLoadIdentity(); // Reset The Modelview Matrix
1760 glScalef((float)screenwidth/2,(float)screenheight/2,1);
1761 glTranslatef(1,1,0);
1762 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1764 if(drawmode==motionblurmode){
1765 if(motionbluramount<.2)motionbluramount=.2;
1766 //glColor4f(1,1,1,fast_sqrt(multiplier)*2.9*motionbluramount);
1767 glColor4f(1,1,1,motionbluramount);
1771 glVertex3f(-1, -1, 0.0f);
1772 glTexCoord2f(texcoordwidth,0);
1773 glVertex3f(1, -1, 0.0f);
1774 glTexCoord2f(texcoordwidth,texcoordheight);
1775 glVertex3f(1, 1, 0.0f);
1776 glTexCoord2f(0,texcoordheight);
1777 glVertex3f(-1, 1, 0.0f);
1781 if(drawmode==realmotionblurmode){
1782 glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
1783 glClear(GL_COLOR_BUFFER_BIT);
1784 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
1785 glBindTexture( GL_TEXTURE_2D, screentexture);
1786 glColor4f(1,1,1,.5);
1790 glVertex3f(-1, -1, 0.0f);
1791 glTexCoord2f(texcoordwidth,0);
1792 glVertex3f(1, -1, 0.0f);
1793 glTexCoord2f(texcoordwidth,texcoordheight);
1794 glVertex3f(1, 1, 0.0f);
1795 glTexCoord2f(0,texcoordheight);
1796 glVertex3f(-1, 1, 0.0f);
1799 glBindTexture( GL_TEXTURE_2D, screentexture2);
1800 glColor4f(1,1,1,.5);
1804 glVertex3f(-1, -1, 0.0f);
1805 glTexCoord2f(texcoordwidth,0);
1806 glVertex3f(1, -1, 0.0f);
1807 glTexCoord2f(texcoordwidth,texcoordheight);
1808 glVertex3f(1, 1, 0.0f);
1809 glTexCoord2f(0,texcoordheight);
1810 glVertex3f(-1, 1, 0.0f);
1813 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1815 if(drawmode==doublevisionmode){
1816 static float crosseyedness;
1817 crosseyedness=abs(player[0].damage-player[0].superpermanentdamage-(player[0].damagetolerance-player[0].superpermanentdamage)*1/2)/30;
1818 if(crosseyedness>1)crosseyedness=1;
1819 if(crosseyedness<0)crosseyedness=0;
1821 glDisable(GL_BLEND);
1826 glVertex3f(-1, -1, 0.0f);
1827 glTexCoord2f(texcoordwidth,0);
1828 glVertex3f(1, -1, 0.0f);
1829 glTexCoord2f(texcoordwidth,texcoordheight);
1830 glVertex3f(1, 1, 0.0f);
1831 glTexCoord2f(0,texcoordheight);
1832 glVertex3f(-1, 1, 0.0f);
1836 glColor4f(1,1,1,.5);
1839 glTranslatef(.015*crosseyedness,0,0);
1843 glVertex3f(-1, -1, 0.0f);
1844 glTexCoord2f(texcoordwidth,0);
1845 glVertex3f(1, -1, 0.0f);
1846 glTexCoord2f(texcoordwidth,texcoordheight);
1847 glVertex3f(1, 1, 0.0f);
1848 glTexCoord2f(0,texcoordheight);
1849 glVertex3f(-1, 1, 0.0f);
1854 if(drawmode==glowmode){
1855 glColor4f(.5,.5,.5,.5);
1857 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
1859 glTranslatef(.01,0,0);
1862 glVertex3f(-1, -1, 0.0f);
1863 glTexCoord2f(texcoordwidth,0);
1864 glVertex3f(1, -1, 0.0f);
1865 glTexCoord2f(texcoordwidth,texcoordheight);
1866 glVertex3f(1, 1, 0.0f);
1867 glTexCoord2f(0,texcoordheight);
1868 glVertex3f(-1, 1, 0.0f);
1872 glTranslatef(-.01,0,0);
1875 glVertex3f(-1, -1, 0.0f);
1876 glTexCoord2f(texcoordwidth,0);
1877 glVertex3f(1, -1, 0.0f);
1878 glTexCoord2f(texcoordwidth,texcoordheight);
1879 glVertex3f(1, 1, 0.0f);
1880 glTexCoord2f(0,texcoordheight);
1881 glVertex3f(-1, 1, 0.0f);
1885 glTranslatef(.0,.01,0);
1888 glVertex3f(-1, -1, 0.0f);
1889 glTexCoord2f(texcoordwidth,0);
1890 glVertex3f(1, -1, 0.0f);
1891 glTexCoord2f(texcoordwidth,texcoordheight);
1892 glVertex3f(1, 1, 0.0f);
1893 glTexCoord2f(0,texcoordheight);
1894 glVertex3f(-1, 1, 0.0f);
1898 glTranslatef(0,-.01,0);
1901 glVertex3f(-1, -1, 0.0f);
1902 glTexCoord2f(texcoordwidth,0);
1903 glVertex3f(1, -1, 0.0f);
1904 glTexCoord2f(texcoordwidth,texcoordheight);
1905 glVertex3f(1, 1, 0.0f);
1906 glTexCoord2f(0,texcoordheight);
1907 glVertex3f(-1, 1, 0.0f);
1911 if(drawmode==radialzoommode){
1913 //glRotatef((float)i*.1,0,0,1);
1914 glColor4f(1,1,1,1/((float)i+1));
1916 glScalef(1+(float)i*.01,1+(float)i*.01,1);
1919 glVertex3f(-1, -1, 0.0f);
1920 glTexCoord2f(texcoordwidth,0);
1921 glVertex3f(1, -1, 0.0f);
1922 glTexCoord2f(texcoordwidth,texcoordheight);
1923 glVertex3f(1, 1, 0.0f);
1924 glTexCoord2f(0,texcoordheight);
1925 glVertex3f(-1, 1, 0.0f);
1930 glDisable(GL_TEXTURE_2D);
1931 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1932 glPopMatrix(); // Restore The Old Projection Matrix
1933 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1934 glPopMatrix(); // Restore The Old Projection Matrix
1935 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1936 glEnable(GL_CULL_FACE);
1937 glDisable(GL_BLEND);
1942 glEnable(GL_TEXTURE_2D);
1945 if(consoleselected>=60)
1946 offset=consoleselected-60;
1947 sprintf (string, " ]");
1948 text.glPrint(10,30,string,0,1,1024,768);
1950 sprintf (string, "_");
1951 text.glPrint(30+(float)(consoleselected)*10-offset*10,30,string,0,1,1024,768);
1954 for(j=0;j<consolechars[i];j++){
1955 glColor4f(1,1,1,1-(float)(i)/16);
1956 if(j<consolechars[i]){
1957 sprintf (string, "%c",consoletext[i][j]);
1958 text.glPrint(30+j*10-offset*10,30+i*20,string,0,1,1024,768);
1965 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)){
1966 multiplier=tempmult;
1973 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)){
1974 tempmult=multiplier;
1979 if ( side == stereoRight || side == stereoCenter ) {
1980 if(drawmode!=motionblurmode||mainmenu){
1985 //myassert(glGetError() == GL_NO_ERROR);
1986 glDrawBuffer(GL_BACK);
1987 glReadBuffer(GL_BACK);
1992 if(drawtoggle==2)drawtoggle=0;
1994 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)){
1995 multiplier=tempmult;
1997 //Jordan fixed your warning!
2001 vector<string> Game::ListCampaigns() {
2002 DIR *campaigns = opendir(ConvertFileName(":Data:Campaigns"));
2003 struct dirent *campaign = NULL;
2005 perror("Problem while loading campaigns");
2006 cerr << "campaign folder was : " << ConvertFileName(":Data:Campaigns") << endl;
2009 vector<string> campaignNames;
2010 while ((campaign = readdir(campaigns)) != NULL) {
2011 string name(campaign->d_name);
2014 if(!name.compare(name.length()-4,4,".txt")) {
2015 campaignNames.push_back(name.substr(0,name.length()-4));
2018 return campaignNames;
2021 void Game::LoadCampaign() {
2024 ifstream ipstream(ConvertFileName((":Data:Campaigns:"+accountactive->getCurrentCampaign()+".txt").c_str()));
2025 ipstream.ignore(256,':');
2026 ipstream >> campaignnumlevels;
2027 for(int i=0;i<campaignnumlevels;i++) {
2028 ipstream.ignore(256,':');
2029 ipstream.ignore(256,':');
2030 ipstream.ignore(256,' ');
2031 ipstream >> campaignmapname[i];
2032 ipstream.ignore(256,':');
2033 ipstream >> campaigndescription[i];
2034 for(int j=0;j<256;j++){
2035 if(campaigndescription[i][j]=='_')campaigndescription[i][j]=' ';
2037 ipstream.ignore(256,':');
2038 ipstream >> campaignchoosenext[i];
2039 ipstream.ignore(256,':');
2040 ipstream >> campaignnumnext[i];
2041 for(int j=0;j<campaignnumnext[i];j++){
2042 ipstream.ignore(256,':');
2043 ipstream >> campaignnextlevel[i][j];
2044 campaignnextlevel[i][j]-=1;
2046 ipstream.ignore(256,':');
2047 ipstream >> campaignlocationx[i];
2048 ipstream.ignore(256,':');
2049 ipstream >> campaignlocationy[i];
2053 for(int i=0;i<campaignnumlevels;i++){
2055 levelhighlight[i]=0;
2060 for(int i=0;i<accountactive->getCampaignChoicesMade();i++){
2061 levelorder[i+1]=campaignnextlevel[levelorder[i]][accountactive->getCampaignChoice(i)];
2062 levelvisible[levelorder[i+1]]=1;
2064 int whichlevelstart = accountactive->getCampaignChoicesMade()-1;
2065 if(whichlevelstart<0){
2066 accountactive->setCampaignScore(0);
2067 accountactive->resetFasttime();
2068 campaignchoicenum=1;
2069 campaignchoicewhich[0]=0;
2073 campaignchoicenum=campaignnumnext[levelorder[whichlevelstart]];
2074 for(int i=0;i<campaignchoicenum;i++){
2075 campaignchoicewhich[i]=campaignnextlevel[levelorder[whichlevelstart]][i];
2076 levelvisible[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
2077 levelhighlight[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
2082 void Game::DrawMenu()
2085 static float lastcheck;
2087 lastcheck+=multiplier;
2089 // !!! FIXME: hack: clamp framerate in menu so text input works correctly on fast systems.
2092 glDrawBuffer(GL_BACK);
2093 glReadBuffer(GL_BACK);
2094 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
2095 ReSizeGLScene(90,.1f);
2098 temptexdetail=texdetail;
2099 if(texdetail>2)texdetail=2;
2100 if(mainmenu!=oldmainmenu&&oldmainmenu!=0){
2102 LoadTexture(":Data:Textures:Newgame.png",&Mainmenuitems[1],0,0);
2103 LoadTexture(":Data:Textures:Quit.png",&Mainmenuitems[3],0,0);
2106 LoadTexture(":Data:Textures:Resume.png",&Mainmenuitems[1],0,0);
2107 LoadTexture(":Data:Textures:Endgame.png",&Mainmenuitems[3],0,0);
2110 if(lastcheck>.5||oldmainmenu!=mainmenu){
2119 texdetail=temptexdetail;
2121 oldmainmenu=mainmenu;
2123 if(mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==8||mainmenu==9||mainmenu==10||mainmenu==18){
2124 glClear(GL_DEPTH_BUFFER_BIT);
2125 glEnable(GL_ALPHA_TEST);
2126 glAlphaFunc(GL_GREATER, 0.001f);
2127 glEnable(GL_TEXTURE_2D);
2128 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
2129 glDisable(GL_CULL_FACE);
2130 glDisable(GL_LIGHTING);
2132 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2133 glPushMatrix(); // Store The Projection Matrix
2134 glLoadIdentity(); // Reset The Projection Matrix
2135 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
2136 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2137 glPushMatrix(); // Store The Modelview Matrix
2138 glLoadIdentity(); // Reset The Modelview Matrix
2139 glTranslatef(screenwidth/2,screenheight/2,0);
2141 glScalef((float)screenwidth/2,(float)screenheight/2,1);
2142 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
2143 glDisable(GL_BLEND);
2144 glColor4f(0,0,0,1.0);
2145 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2146 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2147 glDisable(GL_TEXTURE_2D);
2149 //glScalef(.25,.25,.25);
2152 glVertex3f(-1, -1, 0.0f);
2154 glVertex3f(1, -1, 0.0f);
2156 glVertex3f(1, 1, 0.0f);
2158 glVertex3f(-1, 1, 0.0f);
2162 glColor4f(0.4,0.4,0.4,1.0);
2163 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2164 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2165 glEnable(GL_TEXTURE_2D);
2166 glBindTexture( GL_TEXTURE_2D, Mainmenuitems[4]);
2168 //glScalef(.25,.25,.25);
2171 glVertex3f(-1, -1, 0.0f);
2173 glVertex3f(1, -1, 0.0f);
2175 glVertex3f(1, 1, 0.0f);
2177 glVertex3f(-1, 1, 0.0f);
2182 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2184 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2188 if((float)newscreenwidth>(float)newscreenheight*1.61||(float)newscreenwidth<(float)newscreenheight*1.59)sprintf (menustring[0], "Resolution: %d*%d",(int)newscreenwidth,(int)newscreenheight);
2189 else sprintf (menustring[0], "Resolution: %d*%d (widescreen)",(int)newscreenwidth,(int)newscreenheight);
2192 endx[0]=startx[0]+strlen(menustring[0])*10;
2193 endy[0]=starty[0]+20;
2195 if(newdetail==2)sprintf (menustring[1], "Detail: High");
2196 else if(newdetail==1)sprintf (menustring[1], "Detail: Medium");
2197 else sprintf (menustring[1], "Detail: Low");
2200 endx[1]=startx[1]+strlen(menustring[1])*10;
2201 endy[1]=starty[1]+20;
2203 if(bloodtoggle==2)sprintf (menustring[2], "Blood: On, high detail (slower)");
2204 if(bloodtoggle==1)sprintf (menustring[2], "Blood: On, low detail");
2205 if(bloodtoggle==0)sprintf (menustring[2], "Blood: Off");
2208 endx[2]=startx[2]+strlen(menustring[2])*10;
2209 endy[2]=starty[2]+20;
2211 if(difficulty==2)sprintf (menustring[3], "Difficulty: Insane");
2212 if(difficulty==1)sprintf (menustring[3], "Difficulty: Difficult");
2213 if(difficulty==0)sprintf (menustring[3], "Difficulty: Easier");
2214 startx[3]=10+20-1000;
2216 endx[3]=startx[3]+strlen(menustring[3])*10;
2217 endy[3]=starty[3]+20;
2219 if(ismotionblur==1)sprintf (menustring[4], "Blur Effects: Enabled (less compatible)");
2220 if(ismotionblur==0)sprintf (menustring[4], "Blur Effects: Disabled (more compatible)");
2223 endx[4]=startx[4]+strlen(menustring[4])*10;
2224 endy[4]=starty[4]+20;
2226 if(decals==1)sprintf (menustring[5], "Decals: Enabled (slower)");
2227 if(decals==0)sprintf (menustring[5], "Decals: Disabled");
2230 endx[5]=startx[5]+strlen(menustring[5])*10;
2231 endy[5]=starty[5]+20;
2233 if(musictoggle==1)sprintf (menustring[6], "Music: Enabled");
2234 if(musictoggle==0)sprintf (menustring[6], "Music: Disabled");
2237 endx[6]=startx[6]+strlen(menustring[6])*10;
2238 endy[6]=starty[6]+20;
2240 if(invertmouse==1)sprintf (menustring[9], "Invert mouse: Yes");
2241 if(invertmouse==0)sprintf (menustring[9], "Invert mouse: No");
2244 endx[9]=startx[9]+strlen(menustring[9])*10;
2245 endy[9]=starty[9]+20;
2247 sprintf (menustring[10], "Mouse Speed: %d", (int)(usermousesensitivity*5));
2250 endx[10]=startx[10]+strlen(menustring[10])*10;
2251 endy[10]=starty[10]+20;
2253 sprintf (menustring[11], "Volume: %d%%", (int)(volume*100));
2256 endx[11]=startx[11]+strlen(menustring[11])*10;
2257 endy[11]=starty[11]+20;
2259 sprintf (menustring[13], "Damage Bar: %s",(showdamagebar?"on":"off"));
2262 endx[13]=startx[13]+strlen(menustring[13])*10;
2263 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;
2271 sprintf (menustring[12], "-Configure Stereo -");
2274 endx[12]=startx[12]+strlen(menustring[7])*10;
2275 endy[12]=starty[12]+20;
2277 if(newdetail==detail&&newscreenheight==(int)screenheight&&newscreenwidth==(int)screenwidth)sprintf (menustring[8], "Back");
2278 else sprintf (menustring[8], "Back (some changes take effect next time Lugaru is opened)");
2280 endx[8]=startx[8]+strlen(menustring[8])*10;
2282 endy[8]=starty[8]+20;
2287 if(keyselect!=0)sprintf (menustring[0], "Forwards: %s",Input::keyToChar(forwardkey));
2288 else sprintf (menustring[0], "Forwards: _");
2291 endx[0]=startx[0]+strlen(menustring[0])*10;
2292 endy[0]=starty[0]+20;
2294 if(keyselect!=1)sprintf (menustring[1], "Back: %s",Input::keyToChar(backkey));
2295 else sprintf (menustring[1], "Back: _");
2298 endx[1]=startx[1]+strlen(menustring[1])*10;
2299 endy[1]=starty[1]+20;
2301 if(keyselect!=2)sprintf (menustring[2], "Left: %s",Input::keyToChar(leftkey));
2302 else sprintf (menustring[2], "Left: _");
2305 endx[2]=startx[2]+strlen(menustring[2])*10;
2306 endy[2]=starty[2]+20;
2308 if(keyselect!=3)sprintf (menustring[3], "Right: %s",Input::keyToChar(rightkey));
2309 else sprintf (menustring[3], "Right: _");
2312 endx[3]=startx[3]+strlen(menustring[3])*10;
2313 endy[3]=starty[3]+20;
2315 if(keyselect!=4)sprintf (menustring[4], "Crouch: %s",Input::keyToChar(crouchkey));
2316 else sprintf (menustring[4], "Crouch: _");
2319 endx[4]=startx[4]+strlen(menustring[4])*10;
2320 endy[4]=starty[4]+20;
2322 if(keyselect!=5)sprintf (menustring[5], "Jump: %s",Input::keyToChar(jumpkey));
2323 else sprintf (menustring[5], "Jump: _");
2326 endx[5]=startx[5]+strlen(menustring[5])*10;
2327 endy[5]=starty[5]+20;
2329 if(keyselect!=6)sprintf (menustring[6], "Draw: %s",Input::keyToChar(drawkey));
2330 else sprintf (menustring[6], "Draw: _");
2333 endx[6]=startx[6]+strlen(menustring[6])*10;
2334 endy[6]=starty[6]+20;
2336 if(keyselect!=7)sprintf (menustring[7], "Throw: %s",Input::keyToChar(throwkey));
2337 else sprintf (menustring[7], "Throw: _");
2340 endx[7]=startx[7]+strlen(menustring[7])*10;
2341 endy[7]=starty[7]+20;
2343 if(keyselect!=8)sprintf (menustring[8], "Attack: %s",Input::keyToChar(attackkey));
2344 else sprintf (menustring[8], "Attack: _");
2347 endx[8]=startx[8]+strlen(menustring[8])*10;
2348 endy[8]=starty[8]+20;
2352 sprintf (menustring[9], "Back");
2354 endx[9]=startx[9]+strlen(menustring[9])*10;
2356 endy[9]=starty[9]+20;
2360 nummenuitems=NB_CAMPAIGN_MENU_ITEM+1+(accountactive?accountactive->getCampaignChoicesMade():0)+campaignchoicenum;
2362 sprintf (menustring[0], "%s",accountactive->getName());
2365 endx[0]=startx[0]+strlen(menustring[0])*10;
2366 endy[0]=starty[0]+20;
2368 sprintf (menustring[1], "Tutorial");
2371 endx[1]=startx[1]+strlen(menustring[1])*10;
2372 endy[1]=starty[1]+20;
2374 sprintf (menustring[2], "Challenge");
2377 endx[2]=startx[2]+strlen(menustring[2])*10;
2378 endy[2]=starty[2]+20;
2380 sprintf (menustring[3], "Delete User");
2383 endx[3]=startx[3]+strlen(menustring[3])*10;
2384 endy[3]=starty[3]+20;
2386 sprintf (menustring[4], "Main Menu");
2389 endx[4]=startx[4]+strlen(menustring[4])*10;
2390 endy[4]=starty[4]+20;
2392 sprintf (menustring[5], "Change User");
2394 endx[5]=startx[5]+strlen(menustring[5])*10;
2396 endy[5]=starty[5]+20;
2398 sprintf (menustring[6], "Campaign : %s", accountactive->getCurrentCampaign().c_str());
2400 endx[6]=startx[6]+strlen(menustring[6])*10;
2402 endy[6]=starty[6]+20;
2406 sprintf (menustring[NB_CAMPAIGN_MENU_ITEM], "World");
2407 startx[NB_CAMPAIGN_MENU_ITEM]=30+120;
2408 starty[NB_CAMPAIGN_MENU_ITEM]=30+480-400-50;
2409 endx[NB_CAMPAIGN_MENU_ITEM]=startx[NB_CAMPAIGN_MENU_ITEM]+400;
2410 endy[NB_CAMPAIGN_MENU_ITEM]=30+480-50;
2412 if((accountactive?accountactive->getCampaignChoicesMade():0)) {
2413 for(i=0;i<(accountactive?accountactive->getCampaignChoicesMade():0);i++) {
2414 sprintf (menustring[NB_CAMPAIGN_MENU_ITEM+1+i], "%s", campaigndescription[levelorder[i]]);
2415 startx[NB_CAMPAIGN_MENU_ITEM+1+i]=30+120+campaignlocationx[levelorder[i]]*400/512;
2416 starty[NB_CAMPAIGN_MENU_ITEM+1+i]=30+30+(512-campaignlocationy[levelorder[i]])*400/512;
2417 endx[NB_CAMPAIGN_MENU_ITEM+1+i]=startx[NB_CAMPAIGN_MENU_ITEM+1+i]+10;
2418 endy[NB_CAMPAIGN_MENU_ITEM+1+i]=starty[NB_CAMPAIGN_MENU_ITEM+1+i]+10;
2422 if(campaignchoicenum>0) {
2423 for(i=(accountactive?accountactive->getCampaignChoicesMade():0);i<(accountactive?accountactive->getCampaignChoicesMade():0)+campaignchoicenum;i++){
2424 sprintf (menustring[NB_CAMPAIGN_MENU_ITEM+1+i], "%s", campaigndescription[levelorder[i]]);
2425 startx[NB_CAMPAIGN_MENU_ITEM+1+i]=30+120+campaignlocationx[campaignchoicewhich[i-((accountactive?accountactive->getCampaignChoicesMade():0))]]*400/512;
2426 starty[NB_CAMPAIGN_MENU_ITEM+1+i]=30+30+(512-campaignlocationy[campaignchoicewhich[i-((accountactive?accountactive->getCampaignChoicesMade():0))]])*400/512;
2427 endx[NB_CAMPAIGN_MENU_ITEM+1+i]=startx[NB_CAMPAIGN_MENU_ITEM+1+i]+10;
2428 endy[NB_CAMPAIGN_MENU_ITEM+1+i]=starty[NB_CAMPAIGN_MENU_ITEM+1+i]+10;
2437 sprintf (menustring[0], "Are you sure you want to delete this user?");
2440 endx[0]=startx[0]+strlen(menustring[0])*10;
2441 endy[0]=starty[0]+20;
2443 sprintf (menustring[1], "Yes");
2446 endx[1]=startx[1]+strlen(menustring[1])*10;
2447 endy[1]=starty[1]+20;
2449 sprintf (menustring[2], "No");
2452 endx[2]=startx[2]+strlen(menustring[2])*10;
2453 endy[2]=starty[2]+20;
2455 sprintf (menustring[3], "Extra 4");
2458 endx[3]=startx[3]+strlen(menustring[3])*10;
2459 endy[3]=starty[3]+20;
2461 sprintf (menustring[4], "Extra 5");
2464 endx[4]=startx[4]+strlen(menustring[4])*10;
2465 endy[4]=starty[4]+20;
2467 sprintf (menustring[5], "Back");
2469 endx[5]=startx[5]+strlen(menustring[5])*10;
2471 endy[5]=starty[5]+20;
2475 nummenuitems=Account::getNbAccounts()+2;
2479 if(Account::getNbAccounts()<8)
2480 sprintf (menustring[0], "New User");
2482 sprintf (menustring[0], "No More Users");
2485 endx[0]=startx[0]+strlen(menustring[0])*10;
2486 endy[0]=starty[0]+20;
2493 for(i=0;i<Account::getNbAccounts();i++){
2494 sprintf (menustring[num], "%s",Account::get(i)->getName());
2496 starty[num]=360-20-20*num;
2497 endx[num]=startx[num]+strlen(menustring[num])*10;
2498 endy[num]=starty[num]+20;
2503 sprintf (menustring[num], "Back");
2505 endx[num]=startx[num]+strlen(menustring[num])*10;
2507 endy[num]=starty[num]+20;
2512 sprintf (menustring[0], "Easier");
2515 endx[0]=startx[0]+strlen(menustring[0])*10;
2516 endy[0]=starty[0]+20;
2518 sprintf (menustring[1], "Difficult");
2521 endx[1]=startx[1]+strlen(menustring[1])*10;
2522 endy[1]=starty[1]+20;
2524 sprintf (menustring[2], "Insane");
2527 endx[2]=startx[2]+strlen(menustring[2])*10;
2528 endy[2]=starty[2]+20;
2531 nummenuitems=2+numchallengelevels;
2534 for(j=0;j<numchallengelevels;j++){
2535 for(i=0;i<255;i++)menustring[j][i]='\0';
2536 sprintf (temp, "Level %d",j+1);
2537 strcpy(menustring[j],temp);
2538 for(i=0;i<17;i++)if(menustring[j][i]=='\0')menustring[j][i]=' ';
2539 menustring[j][17]='\0';
2540 sprintf (temp, "%d",(int)accountactive->getHighScore(j));
2541 strcat(menustring[j],temp);
2542 for(i=18;i<32;i++)if(menustring[j][i]=='\0')menustring[j][i]=' ';
2543 menustring[j][32]='\0';
2544 sprintf (temp, "%d:",(int)(((int)accountactive->getFastTime(j)-(int)(accountactive->getFastTime(j))%60)/60));
2545 strcat(menustring[j],temp);
2546 if((int)(accountactive->getFastTime(j))%60<10)strcat(menustring[j],"0");
2547 sprintf (temp, "%d",(int)(accountactive->getFastTime(j))%60);
2548 strcat(menustring[j],temp);
2552 endx[j]=startx[j]+strlen(menustring[j])*10;
2553 endy[j]=starty[j]+20;
2556 sprintf (menustring[numchallengelevels], "Back");
2557 startx[numchallengelevels]=10;
2558 endx[numchallengelevels]=startx[numchallengelevels]+strlen(menustring[numchallengelevels])*10;
2559 starty[numchallengelevels]=10;
2560 endy[numchallengelevels]=starty[numchallengelevels]+20;
2562 sprintf (menustring[numchallengelevels+1], " High Score Best Time");
2563 startx[numchallengelevels+1]=10;
2564 starty[numchallengelevels+1]=440;
2565 endx[numchallengelevels+1]=startx[numchallengelevels+1]+strlen(menustring[numchallengelevels+1])*10;
2566 endy[numchallengelevels+1]=starty[numchallengelevels+1]+20;
2568 //numchallengelevels=tempncl;
2575 sprintf (menustring[0], "Congratulations!");
2578 endx[0]=startx[0]+strlen(menustring[0])*10;
2579 endy[0]=starty[0]+20;
2581 sprintf (menustring[1], "You have avenged your family and");
2584 endx[1]=startx[1]+strlen(menustring[1])*10;
2585 endy[1]=starty[1]+20;
2587 sprintf (menustring[2], "restored peace to the island of Lugaru.");
2590 endx[2]=startx[2]+strlen(menustring[2])*10;
2591 endy[2]=starty[2]+20;
2593 sprintf (menustring[3], "Back");
2595 endx[3]=startx[3]+strlen(menustring[3])*10;
2597 endy[3]=starty[3]+20;
2599 for(i=0;i<255;i++)menustring[4][i]='\0';
2600 sprintf (temp, "Your score:");
2601 strcpy(menustring[4],temp);
2602 for(i=0;i<20;i++)if(menustring[4][i]=='\0')menustring[4][i]=' ';
2603 menustring[4][20]='\0';
2604 sprintf (temp, "%d",(int)accountactive->getCampaignScore());
2605 strcat(menustring[4],temp);
2607 endx[4]=startx[4]+strlen(menustring[4])*10;
2609 endy[4]=starty[4]+20;
2610 for(i=0;i<255;i++)menustring[5][i]='\0';
2611 sprintf (temp, "Highest score:");
2612 strcpy(menustring[5],temp);
2613 for(i=0;i<20;i++)if(menustring[5][i]=='\0')menustring[5][i]=' ';
2614 menustring[5][20]='\0';
2615 sprintf (temp, "%d",(int)accountactive->getCampaignHighScore());
2616 strcat(menustring[5],temp);
2618 endx[5]=startx[5]+strlen(menustring[5])*10;
2620 endy[5]=starty[5]+20;
2624 sprintf (menustring[0], "Stereo mode: %s", StereoModeName(newstereomode));
2627 endx[0]=startx[0]+strlen(menustring[0])*10;
2628 endy[0]=starty[0]+20;
2630 sprintf (menustring[1], "Stereo separation: %.3f", stereoseparation);
2633 endx[1]=startx[1]+strlen(menustring[1])*10;
2634 endy[1]=starty[1]+20;
2636 sprintf (menustring[2], "Reverse stereo: %s", stereoreverse ? "Yes" : "No");
2639 endx[2]=startx[2]+strlen(menustring[2])*10;
2640 endy[2]=starty[2]+20;
2642 sprintf (menustring[3], "Back");
2644 endx[3]=startx[3]+strlen(menustring[3])*10;
2646 endy[3]=starty[3]+20;
2650 if(mainmenu==1||mainmenu==2){
2658 starty[1]=480-152-32;
2663 starty[2]=480-228-32;
2669 starty[3]=480-306-32;
2676 starty[3]=480-306-32;
2685 for(i=0;i<nummenuitems;i++) {
2686 if((mousecoordh/screenwidth*640)>startx[i]&&(mousecoordh/screenwidth*640)<endx[i]&&480-(mousecoordv/screenheight*480)>starty[i]&&480-(mousecoordv/screenheight*480)<endy[i]) {
2687 if(mainmenu!=5) selected=i;
2688 else if( (i>0) && (i!=NB_CAMPAIGN_MENU_ITEM) ) selected=i;
2692 for(i=0;i<nummenuitems;i++){
2694 selectedlong[i]+=multiplier*5;
2695 if(selectedlong[i]>1) selectedlong[i]=1;
2697 selectedlong[i]-=multiplier*5;
2698 if(selectedlong[i]<0) selectedlong[i]=0;
2700 offsetx[i]=(startx[i]+endx[i])/2-(mousecoordh/screenwidth*640);
2701 offsety[i]=(starty[i]+endy[i])/2-(480-(mousecoordv/screenheight*480));
2708 if(mainmenu==1||mainmenu==2){
2709 glClear(GL_DEPTH_BUFFER_BIT);
2710 glEnable(GL_ALPHA_TEST);
2711 glAlphaFunc(GL_GREATER, 0.001f);
2712 glEnable(GL_TEXTURE_2D);
2713 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
2714 glDisable(GL_CULL_FACE);
2715 glDisable(GL_LIGHTING);
2717 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2718 glPushMatrix(); // Store The Projection Matrix
2719 glLoadIdentity(); // Reset The Projection Matrix
2720 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
2721 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2722 glPushMatrix(); // Store The Modelview Matrix
2723 glLoadIdentity(); // Reset The Modelview Matrix
2724 glTranslatef(screenwidth/2,screenheight/2,0);
2726 glScalef((float)screenwidth/2,(float)screenheight/2,1);
2727 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
2728 glDisable(GL_BLEND);
2729 glColor4f(0,0,0,1.0);
2730 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2731 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2732 glDisable(GL_TEXTURE_2D);
2734 //glScalef(.25,.25,.25);
2737 glVertex3f(-1, -1, 0.0f);
2739 glVertex3f(1, -1, 0.0f);
2741 glVertex3f(1, 1, 0.0f);
2743 glVertex3f(-1, 1, 0.0f);
2747 glColor4f(0.4,0.4,0.4,1.0);
2748 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2749 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2750 glEnable(GL_TEXTURE_2D);
2751 glBindTexture( GL_TEXTURE_2D, Mainmenuitems[4]);
2753 //glScalef(.25,.25,.25);
2756 glVertex3f(-1, -1, 0.0f);
2758 glVertex3f(1, -1, 0.0f);
2760 glVertex3f(1, 1, 0.0f);
2762 glVertex3f(-1, 1, 0.0f);
2767 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2770 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2771 glPushMatrix(); // Store The Projection Matrix
2772 glLoadIdentity(); // Reset The Projection Matrix
2773 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
2774 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2775 glPushMatrix(); // Store The Modelview Matrix
2776 glLoadIdentity(); // Reset The Modelview Matrix
2778 glDisable(GL_TEXTURE_2D);
2782 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2784 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2788 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2789 glPushMatrix(); // Store The Projection Matrix
2790 glLoadIdentity(); // Reset The Projection Matrix
2791 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
2792 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2793 glPushMatrix(); // Store The Modelview Matrix
2794 glLoadIdentity(); // Reset The Modelview Matrix
2795 glEnable(GL_TEXTURE_2D);
2796 for(j=0;j<nummenuitems;j++)
2798 //glDisable(GL_BLEND);
2799 glEnable(GL_ALPHA_TEST);
2801 //glDisable(GL_ALPHA_TEST);
2802 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
2803 if(mainmenu==1||mainmenu==2)
2806 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
2807 glBindTexture( GL_TEXTURE_2D, Mainmenuitems[j]);
2808 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
2809 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
2810 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2814 glVertex3f(startx[j], starty[j], 0.0f);
2816 glVertex3f(endx[j], starty[j], 0.0f);
2818 glVertex3f(endx[j], endy[j], 0.0f);
2820 glVertex3f(startx[j], endy[j], 0.0f);
2824 //glDisable(GL_ALPHA_TEST);
2825 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
2828 if(1-((float)i)/10-(1-selectedlong[j])>0)
2830 glColor4f(1,1,1,(1-((float)i)/10-(1-selectedlong[j]))*.25);
2831 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2835 glVertex3f(startx[j]-((float)i)*1/2+offsetx[j]*((float)i)/2, starty[j]-((float)i)*1/2+offsety[j]*((float)i)/2, 0.0f);
2837 glVertex3f(endx[j]+((float)i)*1/2+offsetx[j]*((float)i)/2, starty[j]-((float)i)*1/2+offsety[j]*((float)i)/2, 0.0f);
2839 glVertex3f(endx[j]+((float)i)*1/2+offsetx[j]*((float)i)/2, endy[j]+((float)i)*1/2+offsety[j]*((float)i)/2, 0.0f);
2841 glVertex3f(startx[j]-((float)i)*1/2+offsetx[j]*((float)i)/2, endy[j]+((float)i)*1/2+offsety[j]*((float)i)/2, 0.0f);
2847 if(mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==8||mainmenu==9||mainmenu==10||mainmenu==18)
2849 if(mainmenu!=5||j<NB_CAMPAIGN_MENU_ITEM)
2852 if( (mainmenu==9) && j>accountactive->getProgress() && (j<numchallengelevels) )
2853 glColor4f(0.5,0,0,1);
2854 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2856 if(mainmenu!=7||j!=0||!entername)
2857 text.glPrint(startx[j],starty[j],menustring[j],0,1,640,480);
2862 //~ sprintf (string, "_");
2863 text.glPrint(startx[j]+(float)(displayselected)*10,starty[j],string,0,1,640,480);
2865 for(int l=0;l<displaychars[0];l++) {
2866 sprintf (string, "%c",displaytext[0][l]);
2867 text.glPrint(startx[j]+l*10,starty[j],string,0,1,640,480);
2872 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
2875 if(1-((float)i)/15-(1-selectedlong[j])>0)
2877 glColor4f(1,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
2878 if(mainmenu==9&&j>accountactive->getProgress()&&j<numchallengelevels)glColor4f(0.5,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
2879 if(mainmenu==11&&j>accountactive->getProgress()&&j<numchallengelevels)glColor4f(0.5,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
2880 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);
2881 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);
2882 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);
2883 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);
2884 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);
2885 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);
2886 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);
2887 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);
2888 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);
2894 if(j==NB_CAMPAIGN_MENU_ITEM) {
2895 //glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); // black background for the map
2896 glBlendFunc(GL_SRC_ALPHA,GL_ONE); // no background
2899 glClear(GL_DEPTH_BUFFER_BIT);
2900 glEnable(GL_ALPHA_TEST);
2901 glAlphaFunc(GL_GREATER, 0.001f);
2902 glEnable(GL_TEXTURE_2D);
2903 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
2904 glDisable(GL_CULL_FACE);
2905 glDisable(GL_LIGHTING);
2906 if(j==NB_CAMPAIGN_MENU_ITEM) glColor4f(1,1,1,1);
2907 else glColor4f(1,0,0,1);
2909 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2910 glPushMatrix(); // Store The Projection Matrix
2911 glLoadIdentity(); // Reset The Projection Matrix
2912 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
2913 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2914 glPushMatrix(); // Store The Modelview Matrix
2915 glLoadIdentity(); // Reset The Modelview Matrix
2918 //Draw world, draw map
2919 glTranslatef(2,-5,0);
2921 if(j>NB_CAMPAIGN_MENU_ITEM&&j<nummenuitems-1)
2923 XYZ linestart,lineend,offset;
2930 //float linestartx,lineendx,linestarty,lineendy,offsetx,offsety;
2931 linestart.x=(startx[j]+endx[j])/2;
2932 linestart.y=(starty[j]+endy[j])/2;
2933 if(j>=NB_CAMPAIGN_MENU_ITEM+(accountactive?accountactive->getCampaignChoicesMade():0)){
2934 linestart.x=(startx[6+(accountactive?accountactive->getCampaignChoicesMade():0)]+endx[6+(accountactive?accountactive->getCampaignChoicesMade():0)])/2;
2935 linestart.y=(starty[6+(accountactive?accountactive->getCampaignChoicesMade():0)]+endy[6+(accountactive?accountactive->getCampaignChoicesMade():0)])/2;
2937 lineend.x=(startx[j+1]+endx[j+1])/2;
2938 lineend.y=(starty[j+1]+endy[j+1])/2;
2939 offset=lineend-linestart;
2942 offset=DoRotation(offset,0,0,90);
2944 glDisable(GL_TEXTURE_2D);
2946 if(j<NB_CAMPAIGN_MENU_ITEM+(accountactive?accountactive->getCampaignChoicesMade():0)){
2947 glColor4f(0.5,0,0,1);
2955 linestart+=fac*4*startsize;
2956 lineend-=fac*4*endsize;
2958 if(!(j>NB_CAMPAIGN_MENU_ITEM+1+(accountactive?accountactive->getCampaignChoicesMade():0)+campaignchoicenum)){
2959 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2963 glVertex3f(linestart.x-offset.x*startsize, linestart.y-offset.y*startsize, 0.0f);
2965 glVertex3f(linestart.x+offset.x*startsize, linestart.y+offset.y*startsize, 0.0f);
2967 glVertex3f(lineend.x+offset.x*endsize, lineend.y+offset.y*endsize, 0.0f);
2969 glVertex3f(lineend.x-offset.x*endsize, lineend.y-offset.y*endsize, 0.0f);
2973 glEnable(GL_TEXTURE_2D);
2977 if(j==NB_CAMPAIGN_MENU_ITEM) glBindTexture( GL_TEXTURE_2D, Mainmenuitems[7]);
2978 else glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
2979 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
2980 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
2981 if(j-NB_CAMPAIGN_MENU_ITEM-1 < (accountactive?accountactive->getCampaignChoicesMade():0)) glColor4f(0.5,0,0,1);
2982 if(j-NB_CAMPAIGN_MENU_ITEM-1 >= (accountactive?accountactive->getCampaignChoicesMade():0)) glColor4f(1,0,0,1);
2983 if(j==NB_CAMPAIGN_MENU_ITEM) glColor4f(1,1,1,1);
2986 itemsize=abs(startx[j]-endx[j])/2;
2988 midpoint.x=(startx[j]+endx[j])/2;
2989 midpoint.y=(starty[j]+endy[j])/2;
2990 if (j>NB_CAMPAIGN_MENU_ITEM &&
2991 (j-NB_CAMPAIGN_MENU_ITEM-1 < (accountactive?accountactive->getCampaignChoicesMade():0))) {
2994 if(!(j-NB_CAMPAIGN_MENU_ITEM-1 > (accountactive?accountactive->getCampaignChoicesMade():0)+campaignchoicenum))
2996 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3000 glVertex3f(midpoint.x-itemsize, midpoint.y-itemsize, 0.0f);
3002 glVertex3f(midpoint.x+itemsize, midpoint.y-itemsize, 0.0f);
3004 glVertex3f(midpoint.x+itemsize, midpoint.y+itemsize, 0.0f);
3006 glVertex3f(midpoint.x-itemsize, midpoint.y+itemsize, 0.0f);
3010 //glDisable(GL_ALPHA_TEST);
3011 if(j<4) glBlendFunc(GL_SRC_ALPHA,GL_ONE); // Black is transparent
3014 if(1-((float)i)/10-(1-selectedlong[j])>0)
3016 glColor4f(1,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3017 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3021 glVertex3f(midpoint.x-itemsize-((float)i)*1/2+offsetx[j]*((float)i)/2, midpoint.y-itemsize-((float)i)*1/2+offsety[j]*((float)i)/2, 0.0f);
3023 glVertex3f(midpoint.x+itemsize+((float)i)*1/2+offsetx[j]*((float)i)/2, midpoint.y-itemsize-((float)i)*1/2+offsety[j]*((float)i)/2, 0.0f);
3025 glVertex3f(midpoint.x+itemsize+((float)i)*1/2+offsetx[j]*((float)i)/2, midpoint.y+itemsize+((float)i)*1/2+offsety[j]*((float)i)/2, 0.0f);
3027 glVertex3f(midpoint.x-itemsize-((float)i)*1/2+offsetx[j]*((float)i)/2, midpoint.y+itemsize+((float)i)*1/2+offsety[j]*((float)i)/2, 0.0f);
3035 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3037 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3039 if(j-NB_CAMPAIGN_MENU_ITEM-1>=(accountactive?accountactive->getCampaignChoicesMade():0)){
3040 text.glPrintOutlined(0.9,0,0,startx[j]+10,starty[j]-4,menustring[j],0,0.6,640,480);
3041 glDisable(GL_DEPTH_TEST);
3046 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3048 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3051 if(mainmenu==1||mainmenu==2) {
3052 //if(transition<.1||transition>.9) {
3053 glClear(GL_DEPTH_BUFFER_BIT);
3054 glEnable(GL_ALPHA_TEST);
3055 glAlphaFunc(GL_GREATER, 0.001f);
3056 glEnable(GL_TEXTURE_2D);
3057 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3058 glDisable(GL_CULL_FACE);
3059 glDisable(GL_LIGHTING);
3061 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3062 glPushMatrix(); // Store The Projection Matrix
3063 glLoadIdentity(); // Reset The Projection Matrix
3064 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3065 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3066 glPushMatrix(); // Store The Modelview Matrix
3067 glLoadIdentity(); // Reset The Modelview Matrix
3069 glDisable(GL_TEXTURE_2D);
3071 //glColor4f(1,0,0,1-(transition*10));
3073 //glColor4f(1,0,0,1-((1-transition)*10));
3077 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3082 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3083 glPushMatrix(); // Store The Projection Matrix
3084 glLoadIdentity(); // Reset The Projection Matrix
3085 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
3086 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3087 glPushMatrix(); // Store The Modelview Matrix
3088 glLoadIdentity(); // Reset The Modelview Matrix
3089 glTranslatef(screenwidth/2,screenheight/2,0);
3091 glScalef((float)screenwidth/2,(float)screenheight/2,1);
3092 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3094 glEnable(GL_TEXTURE_2D);
3096 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
3097 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
3099 if(!waiting) { // hide the cursor while waiting for a key
3101 glTranslatef(mousecoordh-screenwidth/2,mousecoordv*-1+screenheight/2,0);
3102 glScalef((float)screenwidth/64,(float)screenwidth/64,1);
3103 glTranslatef(1,-1,0);
3104 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3106 glBindTexture( GL_TEXTURE_2D, cursortexture);
3108 //glScalef(.25,.25,.25);
3111 glVertex3f(-1, -1, 0.0f);
3113 glVertex3f(1, -1, 0.0f);
3115 glVertex3f(1, 1, 0.0f);
3117 glVertex3f(-1, 1, 0.0f);
3123 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3129 //printf("Flash amount: %f, delay %i\n", flashamount, flashdelay);
3130 if(flashamount>1)flashamount=1;
3131 if(flashdelay<=0)flashamount-=multiplier;
3133 if(flashamount<0)flashamount=0;
3134 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3135 glDisable(GL_CULL_FACE);
3136 glDisable(GL_LIGHTING);
3137 glDisable(GL_TEXTURE_2D);
3139 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3140 glPushMatrix(); // Store The Projection Matrix
3141 glLoadIdentity(); // Reset The Projection Matrix
3142 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
3143 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3144 glPushMatrix(); // Store The Modelview Matrix
3145 glLoadIdentity(); // Reset The Modelview Matrix
3146 glScalef(screenwidth,screenheight,1);
3147 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3149 glColor4f(flashr,flashg,flashb,flashamount);
3151 glVertex3f(0, 0, 0.0f);
3152 glVertex3f(256, 0, 0.0f);
3153 glVertex3f(256, 256, 0.0f);
3154 glVertex3f(0, 256, 0.0f);
3156 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3157 glPopMatrix(); // Restore The Old Projection Matrix
3158 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3159 glPopMatrix(); // Restore The Old Projection Matrix
3160 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
3161 glEnable(GL_CULL_FACE);
3162 glDisable(GL_BLEND);