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"
29 extern int environment;
30 extern float texscale;
32 extern Terrain terrain;
33 //extern Sprites sprites;
34 extern float multiplier;
36 extern float viewdistance;
37 extern float fadestart;
38 extern float screenwidth,screenheight;
39 extern int kTextureSize;
40 extern FRUSTUM frustum;
42 extern Objects objects;
44 extern float usermousesensitivity;
46 extern float camerashake;
47 extern Weapons weapons;
48 extern Person player[maxplayers];
50 extern float slomodelay;
51 extern bool ismotionblur;
53 extern float blackout;
54 extern bool damageeffects;
56 extern int numplayers;
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;
87 extern float bonusvalue;
88 extern float bonustotal;
89 extern float bonustime;
91 extern float startbonustotal;
92 extern float bonusnum[100];
93 extern int tutoriallevel;
94 extern float smoketex;
95 extern float tutorialstagetime;
96 extern float tutorialmaxtime;
97 extern int tutorialstage;
98 extern bool againbonus;
99 extern float damagedealt;
100 extern float damagetaken;
101 extern bool invertmouse;
103 extern int numhotspots;
104 extern int winhotspot;
105 extern int killhotspot;
106 extern XYZ hotspot[40];
107 extern int hotspottype[40];
108 extern float hotspotsize[40];
109 extern char hotspottext[40][256];
110 extern int currenthotspot;;
113 extern int numflipfail;
115 extern int numstaffattack;
116 extern int numswordattack;
117 extern int numknifeattack;
118 extern int numunarmedattack;
119 extern int numescaped;
120 extern int numflipped;
121 extern int numwallflipped;
122 extern int numthrowkill;
123 extern int numafterkill;
124 extern int numreversals;
125 extern int numattacks;
126 extern int maxalarmed;
127 extern int numresponded;
129 extern bool campaign;
130 extern bool winfreeze;
132 extern float menupulse;
134 extern bool gamestart;
136 extern int numdialogues;
137 extern int numdialogueboxes[max_dialogues];
138 extern int dialoguetype[max_dialogues];
139 extern int dialogueboxlocation[max_dialogues][max_dialoguelength];
140 extern float dialogueboxcolor[max_dialogues][max_dialoguelength][3];
141 extern int dialogueboxsound[max_dialogues][max_dialoguelength];
142 extern char dialoguetext[max_dialogues][max_dialoguelength][128];
143 extern char dialoguename[max_dialogues][max_dialoguelength][64];
144 extern XYZ dialoguecamera[max_dialogues][max_dialoguelength];
145 extern XYZ participantlocation[max_dialogues][10];
146 extern int participantfocus[max_dialogues][max_dialoguelength];
147 extern int participantaction[max_dialogues][max_dialoguelength];
148 extern float participantrotation[max_dialogues][10];
149 extern XYZ participantfacing[max_dialogues][max_dialoguelength][10];
150 extern float dialoguecamerarotation[max_dialogues][max_dialoguelength];
151 extern float dialoguecamerarotation2[max_dialogues][max_dialoguelength];
152 extern int indialogue;
153 extern int whichdialogue;
154 extern int directing;
155 extern float dialoguetime;
156 extern int dialoguegonethrough[20];
158 extern bool gamestarted;
160 extern bool showdamagebar;
162 extern int channels[100];
163 extern "C" void PlaySoundEx(int channel, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
165 void Game::flash() { // shouldn't be that way, these should be attributes and Person class should not change rendering.
172 /*********************> DrawGLScene() <*****/
173 int Game::DrawGLScene(StereoSide side)
175 static float texcoordwidth,texcoordheight;
176 static float texviewwidth, texviewheight;
178 static GLubyte color;
179 static float newbrightness;
180 static float changespeed;
181 static XYZ checkpoint;
182 static float tempmult;
184 static char string[256]="";
185 static char string2[256]="";
186 static char string3[256]="";
188 static float lastcheck;
190 lastcheck+=multiplier;
192 if ( stereomode == stereoAnaglyph ) {
194 case stereoLeft: glColorMask( 0.0, 1.0, 1.0, 1.0 ); break;
195 case stereoRight: glColorMask( 1.0, 0.0, 0.0, 1.0 ); break;
198 glColorMask( 1.0, 1.0, 1.0, 1.0 );
200 if ( stereomode == stereoHorizontalInterlaced || stereomode == stereoVerticalInterlaced ) {
201 glStencilFunc(side == stereoLeft ? GL_NOTEQUAL : GL_EQUAL, 0x01, 0x01);
205 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)){
212 numboundaries=mapradius*2;
213 if(numboundaries>360)numboundaries=360;
214 for(i=0;i<numboundaries;i++){
217 boundary[i]=mapcenter+DoRotation(boundary[i]*mapradius,0,i*(360/((float)(numboundaries))),0);
226 olddrawmode=drawmode;
227 if(ismotionblur&&!loading){
228 if((findLengthfast(&player[0].velocity)>200)&&velocityblur&&!cameramode){
229 drawmode=motionblurmode;
230 motionbluramount=200/(findLengthfast(&player[0].velocity));
233 if(player[0].damage-player[0].superpermanentdamage>(player[0].damagetolerance-player[0].superpermanentdamage)*1/2&&damageeffects&&!cameramode){
234 drawmode=doublevisionmode;
241 drawmode=motionblurmode;
243 slomodelay-=multiplier;
244 if(slomodelay<0)slomo=0;
248 if((!changed&&!slomo)||loading){
250 if(ismotionblur&&(/*fps>100||*/alwaysblur)){
251 if(olddrawmode!=realmotionblurmode)change=1;
253 drawmode=realmotionblurmode;
255 else if(olddrawmode==realmotionblurmode)change=2;
259 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted))drawmode=normalmode;
260 if((freeze||winfreeze)&&ismotionblur&&!mainmenu)drawmode=radialzoommode;
262 if(winfreeze||mainmenu)drawmode=normalmode;
265 if(drawmode==glowmode){
270 DSpContext_FadeGamma(NULL,200,&color2);
274 if(drawtoggle!=2)drawtoggle=1-drawtoggle;
278 texviewwidth=kTextureSize;
279 if(texviewwidth>screenwidth)texviewwidth=screenwidth;
280 texviewheight=kTextureSize;
281 if(texviewheight>screenheight)texviewheight=screenheight;
283 texcoordwidth=screenwidth/kTextureSize;
284 texcoordheight=screenheight/kTextureSize;
285 if(texcoordwidth>1)texcoordwidth=1;
286 if(texcoordheight>1)texcoordheight=1;
289 glDrawBuffer(GL_BACK);
290 glReadBuffer(GL_BACK);
292 if(abs(blurness-targetblurness)<multiplier*10||abs(blurness-targetblurness)>2){
293 blurness=targetblurness;
294 targetblurness=(float)(abs(Random()%100))/40;
296 if(blurness<targetblurness)
297 blurness+=multiplier*5;
299 blurness-=multiplier*5;
302 static XYZ terrainlight;
303 static float distance;
304 if(drawmode==normalmode)ReSizeGLScene(90,.1f);
305 if(drawmode!=normalmode)glViewport(0,0,texviewwidth,texviewheight);
306 glDepthFunc(GL_LEQUAL);
308 glAlphaFunc(GL_GREATER, 0.0001f);
309 glEnable(GL_ALPHA_TEST);
310 glClearColor(0.25f, 0.25f, 0.25f, 1.0f);
311 glClear(GL_DEPTH_BUFFER_BIT);
313 glMatrixMode (GL_MODELVIEW);
314 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
317 // Move the camera for the current eye's point of view.
318 // Reverse the movement if we're reversing stereo
319 glTranslatef((stereoseparation/2) * side * (stereoreverse ? -1 : 1), 0, 0);
321 if(!cameramode&&!freeze&&!winfreeze){
322 glRotatef(float(Random()%100)/10*camerashake/*+(woozy*woozy)/10*/,0,0,1);
323 glRotatef(rotation2+sin(woozy/2)*(player[0].damage/player[0].damagetolerance)*5,1,0,0);
324 glRotatef(rotation+sin(woozy)*(player[0].damage/player[0].damagetolerance)*5,0,1,0);
326 if(cameramode||freeze||winfreeze){
327 glRotatef(rotation2,1,0,0);
328 glRotatef(rotation,0,1,0);
331 if(environment==desertenvironment){
332 glRotatef((float)(abs(Random()%100))/3000-1,1,0,0);
333 glRotatef((float)(abs(Random()%100))/3000-1,0,1,0);
335 SetUpLight(&light,0);
337 if(environment==desertenvironment&&detail==2)glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, blurness+.4 );
338 if(environment==desertenvironment){
339 glRotatef((float)(abs(Random()%100))/1000,1,0,0);
340 glRotatef((float)(abs(Random()%100))/1000,0,1,0);
343 glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0);
345 glTranslatef(-viewer.x,-viewer.y,-viewer.z);
346 frustum.GetFrustum();
350 static float size,opacity,rotation;
352 for(k=0;k<numplayers;k++){
353 if(!player[k].skeleton.free&&player[k].playerdetail&&player[k].howactive<typesleeping)
354 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)
355 for(i=0;i<player[k].skeleton.num_joints;i++){
356 if(player[k].skeleton.joints[i].label==leftknee||player[k].skeleton.joints[i].label==rightknee||player[k].skeleton.joints[i].label==groin){
357 point=DoRotation(player[k].skeleton.joints[i].position,0,player[k].rotation,0)*player[k].scale+player[k].coords;
359 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;
360 if(k!=0&&tutoriallevel==1){
361 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;
363 terrain.MakeDecal(shadowdecal,point,size,opacity,rotation);
364 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
365 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
366 if(objects.position[j].y<player[k].coords.y||objects.type[j]==tunneltype||objects.type[j]==weirdtype){
367 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);
370 if(k!=0&&tutoriallevel==1){
371 opacity=.2+.2*sin(smoketex*6+i);
373 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
378 if((player[k].skeleton.free||player[k].howactive>=typesleeping)&&player[k].playerdetail)
379 if(frustum.SphereInFrustum(player[k].coords.x,player[k].coords.y,player[k].coords.z,player[k].scale*5)&&player[k].occluded<25)
380 for(i=0;i<player[k].skeleton.num_joints;i++){
381 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){
382 if(player[k].skeleton.free)point=player[k].skeleton.joints[i].position*player[k].scale+player[k].coords;
383 else point=DoRotation(player[k].skeleton.joints[i].position,0,player[k].rotation,0)*player[k].scale+player[k].coords;
385 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;
386 if(k!=0&&tutoriallevel==1){
387 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;
389 terrain.MakeDecal(shadowdecal,point,size,opacity*.7,rotation);
390 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
391 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
392 if(objects.position[j].y<player[k].coords.y||objects.type[j]==tunneltype||objects.type[j]==weirdtype){
393 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);
394 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);
397 if(k!=0&&tutoriallevel==1){
398 opacity=.2+.2*sin(smoketex*6+i);
400 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
406 if(!player[k].playerdetail)
407 if(frustum.SphereInFrustum(player[k].coords.x,player[k].coords.y,player[k].coords.z,player[k].scale*5))
409 point=player[k].coords;
411 opacity=.4-(player[k].coords.y-terrain.getHeight(player[k].coords.x,player[k].coords.z))/5;
412 terrain.MakeDecal(shadowdecal,point,size,opacity*.7,rotation);
413 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
414 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
415 point=DoRotation(player[k].coords-objects.position[j],0,-objects.rotation[j],0);
418 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
424 glEnable(GL_TEXTURE_2D);
426 glEnable(GL_DEPTH_TEST);
427 glEnable(GL_CULL_FACE);
429 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
430 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
431 glBindTexture( GL_TEXTURE_2D, terraintexture);
433 glBindTexture( GL_TEXTURE_2D, terraintexture2);
435 //glBindTexture( GL_TEXTURE_2D, terraintexture3);
436 //glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
439 terrain.drawdecals();
442 glEnable(GL_CULL_FACE);
443 glEnable(GL_LIGHTING);
445 glEnable(GL_TEXTURE_2D);
448 glEnable(GL_COLOR_MATERIAL);
463 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
464 glEnable(GL_CULL_FACE);
465 glCullFace(GL_FRONT);
467 for(k=0;k<numplayers;k++){
468 if(k==0||tutoriallevel!=1){
470 glEnable(GL_LIGHTING);
471 terrainlight=terrain.getLighting(player[k].coords.x,player[k].coords.z);
472 distance=findDistancefast(&viewer,&player[k].coords);
473 distance=(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance;
474 glColor4f(terrainlight.x,terrainlight.y,terrainlight.z,distance);
475 if(distance>=1)glDisable(GL_BLEND);
477 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;
479 if(!player[k].occluded==0)i=checkcollide(viewer,checkpoint,player[k].lastoccluded);
480 if(i==-1||player[k].occluded==0)i=checkcollide(viewer,checkpoint);
482 player[k].occluded+=1;
483 player[k].lastoccluded=i;
485 else player[k].occluded=0;
486 if(player[k].occluded<25)player[k].DrawSkeleton();
492 if(!cameramode&&musictype==stream_music2)playerdist=findDistancefastflat(&player[0].coords,&viewer);
493 else playerdist=-100;
496 glEnable(GL_TEXTURE_2D);
501 if(frustum.SphereInFrustum(realhawkcoords.x+hawk.boundingspherecenter.x,realhawkcoords.y+hawk.boundingspherecenter.y,realhawkcoords.z+hawk.boundingspherecenter.z,2)){
502 glAlphaFunc(GL_GREATER, 0.0001f);
504 glDisable(GL_CULL_FACE);
505 glDisable(GL_LIGHTING);
507 glTranslatef(hawkcoords.x,hawkcoords.y,hawkcoords.z);
508 glRotatef(hawkrotation,0,1,0);
509 glTranslatef(25,0,0);
510 distance=findDistancefast(&viewer,&realhawkcoords)*1.2;
511 glColor4f(light.color[0],light.color[1],light.color[2],(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance);
512 if((viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance>1)glColor4f(light.color[0],light.color[1],light.color[2],1);
513 if((viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance>0)
514 hawk.drawdifftex(hawktexture);
518 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
519 glEnable(GL_CULL_FACE);
520 glCullFace(GL_FRONT);
522 for(k=0;k<numplayers;k++){
523 if(!(k==0||tutoriallevel!=1)){
525 glEnable(GL_LIGHTING);
526 terrainlight=terrain.getLighting(player[k].coords.x,player[k].coords.z);
527 distance=findDistancefast(&viewer,&player[k].coords);
528 distance=(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance;
529 glColor4f(terrainlight.x,terrainlight.y,terrainlight.z,distance);
530 if(distance>=1)glDisable(GL_BLEND);
532 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;
534 if(!player[k].occluded==0)i=checkcollide(viewer,checkpoint,player[k].lastoccluded);
535 if(i==-1||player[k].occluded==0)i=checkcollide(viewer,checkpoint);
537 player[k].occluded+=1;
538 player[k].lastoccluded=i;
540 else player[k].occluded=0;
541 if(player[k].occluded<25)player[k].DrawSkeleton();
547 glEnable(GL_TEXTURE_2D);
552 glDisable(GL_COLOR_MATERIAL);
554 glDisable(GL_LIGHTING);
555 glDisable(GL_TEXTURE_2D);
563 glDisable(GL_LIGHTING);
564 glDisable(GL_TEXTURE_2D);
565 glDisable(GL_COLOR_MATERIAL);
568 for(k=0;k<numplayers;k++){
569 if(player[k].numwaypoints>1){
570 glBegin(GL_LINE_LOOP);
571 for(i=0;i<player[k].numwaypoints;i++){
572 glVertex3f(player[k].waypoints[i].x,player[k].waypoints[i].y+.5,player[k].waypoints[i].z);
581 for(k=0;k<numpathpoints;k++){
582 if(numpathpointconnect[k]){
583 for(i=0;i<numpathpointconnect[k];i++){
584 glBegin(GL_LINE_LOOP);
585 glVertex3f(pathpoint[k].x,pathpoint[k].y+.5,pathpoint[k].z);
586 glVertex3f(pathpoint[pathpointconnect[k][i]].x,pathpoint[pathpointconnect[k][i]].y+.5,pathpoint[pathpointconnect[k][i]].z);
594 glVertex3f(pathpoint[pathpointselected].x,pathpoint[pathpointselected].y+.5,pathpoint[pathpointselected].z);
601 glEnable(GL_TEXTURE_2D);
602 glColor4f(.5,.5,.5,1);
604 sprintf (string, " ",(int)(fps));
605 text.glPrint(10,30,string,0,.8,screenwidth,screenheight);
608 if(bonus>0&&bonustime<1&&!winfreeze&&indialogue==-1/*bonustime<4*/){
609 if(bonus==tracheotomy)sprintf (string, "Tracheotomy!");
610 else if(bonus==backstab)sprintf (string, "Backstabber!");
611 else if(bonus==spinecrusher)sprintf (string, "Spinecrusher!");
612 else if(bonus==ninja)sprintf (string, "Ninja Bonus!");
613 else if(bonus==style)sprintf (string, "Style Bonus!");
614 else if(bonus==cannon)sprintf (string, "Leg Cannon!");
615 else if(bonus==aimbonus)sprintf (string, "Nice Aim!");
616 else if(bonus==deepimpact)sprintf (string, "Heavy Impact!");
617 else if(bonus==touchofdeath)sprintf (string, "Touch of Death!");
618 else if(bonus==swordreversebonus)sprintf (string, "Sword Disarm!");
619 else if(bonus==staffreversebonus)sprintf (string, "Staff Disarm!");
620 else if(bonus==reverseko)sprintf (string, "Reversal KO!");
621 else if(bonus==solidhit)sprintf (string, "Solid Hit!");
622 else if(bonus==twoxcombo)sprintf (string, "2X Combo!");
623 else if(bonus==threexcombo)sprintf (string, "3X Combo!");
624 else if(bonus==fourxcombo)sprintf (string, "4X COMBO!");
625 else if(bonus==megacombo)sprintf (string, "MEGA COMBO!");
626 else if(bonus==Reversal)sprintf (string, "Reversal!");
627 else if(bonus==Stabbonus)sprintf (string, "Punctured!");
628 else if(bonus==Slicebonus)sprintf (string, "Sliced!");
629 else if(bonus==Bullseyebonus)sprintf (string, "Bullseye!");
630 else if(bonus==Slashbonus)sprintf (string, "Slashed!");
631 else if(bonus==Wolfbonus)sprintf (string, "WOLF SLAYER!");
632 else if(bonus==FinishedBonus)sprintf (string, "SLAIN!");
633 else if(bonus==TackleBonus)sprintf (string, "Tackle!");
634 else if(bonus==AboveBonus)sprintf (string, "Death from Above!");
635 else sprintf (string, "Excellent!");
637 glColor4f(0,0,0,1-bonustime);
638 text.glPrintOutline(1024/2-10*strlen(string)-4,768/16-4+768*4/5,string,1,2.5,1024,768);
639 glColor4f(1,0,0,1-bonustime);
640 text.glPrint(1024/2-10*strlen(string),768/16+768*4/5,string,1,2,1024,768);
642 sprintf (string, "%d",(int)bonusvalue);
643 glColor4f(0,0,0,1-bonustime);
644 text.glPrintOutline(1024/2-10*strlen(string)-4,768/16-4-20+768*4/5,string,1,2.5*.8,1024,768);
645 glColor4f(1,0,0,1-bonustime);
646 text.glPrint(1024/2-10*strlen(string),768/16-20+768*4/5,string,1,2*.8,1024,768);
647 glColor4f(.5,.5,.5,1);
650 if(tutoriallevel==1){
651 tutorialopac=tutorialmaxtime-tutorialstagetime;
652 if(tutorialopac>1)tutorialopac=1;
653 if(tutorialopac<0)tutorialopac=0;
655 sprintf (string, " ");
656 sprintf (string2, " ");
657 sprintf (string3, " ");
658 if(tutorialstage==0){
659 sprintf (string, " ");
660 sprintf (string2, " ");
661 sprintf (string3, " ");
663 if(tutorialstage==1){
664 sprintf (string, "Welcome to the Lugaru training level!");
665 sprintf (string2, " ");
666 sprintf (string3, " ");
668 if(tutorialstage==2){
669 sprintf (string, "BASIC MOVEMENT:");
670 sprintf (string2, " ");
671 sprintf (string3, " ");
673 if(tutorialstage==3){
674 sprintf (string, "You can move the mouse to rotate the camera.");
675 sprintf (string2, " ");
676 sprintf (string3, " ");
678 if(tutorialstage==4){
679 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));
680 sprintf (string2, "All movement is relative to the camera.");
681 sprintf (string3, " ");
683 if(tutorialstage==5){
684 sprintf (string, "Please press %s to jump.",Input::keyToChar(jumpkey));
685 sprintf (string2, "You can hold it longer to jump higher.");
686 sprintf (string3, " ");
688 if(tutorialstage==6){
689 sprintf (string, "You can press %s to crouch.",Input::keyToChar(crouchkey));
690 sprintf (string2, "You can jump higher from a crouching position.");
691 sprintf (string3, " ");
693 if(tutorialstage==7){
694 sprintf (string, "While running, you can press %s to roll.",Input::keyToChar(crouchkey));
695 sprintf (string2, " ");
696 sprintf (string3, " ");
698 if(tutorialstage==8){
699 sprintf (string, "While crouching, you can sneak around silently");
700 sprintf (string2, "using the movement keys.");
701 sprintf (string3, " ");
703 if(tutorialstage==9){
704 sprintf (string, "Release the crouch key while sneaking and hold the movement keys");
705 sprintf (string2, "to run animal-style.");
706 sprintf (string3, " ");
708 if(tutorialstage==10){
709 sprintf (string, "ADVANCED MOVEMENT:");
710 sprintf (string2, " ");
711 sprintf (string3, " ");
713 if(tutorialstage==11){
714 sprintf (string, "When you jump at a wall, you can hold %s again",Input::keyToChar(jumpkey));
715 sprintf (string2, "during impact to perform a walljump.");
716 sprintf (string3, "Be sure to use the movement keys to press against the wall");
718 if(tutorialstage==12){
719 sprintf (string, "While in the air, you can press crouch to flip.",Input::keyToChar(jumpkey));
720 sprintf (string2, "Walljumps and flips confuse enemies and give you more control.");
721 sprintf (string3, " ");
723 if(tutorialstage==13){
724 sprintf (string, "BASIC COMBAT:");
725 sprintf (string2, " ");
726 sprintf (string3, " ");
728 if(tutorialstage==14){
729 sprintf (string, "There is now an imaginary enemy");
730 sprintf (string2, "in the middle of the training area.");
731 sprintf (string3, " ");
733 if(tutorialstage==15){
734 if(attackkey==MOUSEBUTTON1)sprintf (string, "Click to attack when you are near an enemy.");
735 else sprintf (string, "Press %s to attack when you are near an enemy.",Input::keyToChar(attackkey));
736 sprintf (string2, "You can punch by standing still near an enemy and attacking.");
737 sprintf (string3, " ");
739 if(tutorialstage==16){
740 sprintf (string, "If you are close, you will perform a weak punch.");
741 sprintf (string2, "The weak punch is excellent for starting attack combinations.");
742 sprintf (string3, " ");
744 if(tutorialstage==17){
745 sprintf (string, "Attacking while running results in a spin kick.");
746 sprintf (string2, "This is one of your most powerful ground attacks.");
747 sprintf (string3, " ");
749 if(tutorialstage==18){
750 sprintf (string, "Sweep the enemy's legs out by attacking while crouched.");
751 sprintf (string2, "This is a very fast attack, and easy to follow up.");
752 sprintf (string3, " ");
754 if(tutorialstage==19){
755 sprintf (string, "When an enemy is on the ground, you can deal some extra");
756 sprintf (string2, "damage by running up and drop-kicking him.");
757 sprintf (string3, "(Try knocking them down with a sweep first)");
759 if(tutorialstage==20){
760 sprintf (string, "Your most powerful individual attack is the rabbit kick.");
761 if(attackkey==MOUSEBUTTON1)sprintf (string2, "Run at the enemy while holding the mouse button, and press");
762 else sprintf (string2, "Run at the enemy while holding %s, and press", Input::keyToChar(attackkey));
763 sprintf (string3, "the jump key (%s) to attack.",Input::keyToChar(jumpkey));
765 if(tutorialstage==21){
766 sprintf (string, "This attack is devastating if timed correctly.");
767 sprintf (string2, "Even if timed incorrectly, it will knock the enemy over.");
768 if(againbonus)sprintf (string3, "Try rabbit-kicking the imaginary enemy again.");
769 else sprintf (string3, "Try rabbit-kicking the imaginary enemy.");
771 if(tutorialstage==22){
772 sprintf (string, "If you sneak behind an enemy unnoticed, you can kill");
773 sprintf (string2, "him instantly. Move close behind this enemy");
774 sprintf (string3, "and attack.");
776 if(tutorialstage==23){
777 sprintf (string, "Another important attack is the wall kick. When an enemy");
778 sprintf (string2, "is near a wall, perform a walljump nearby and hold");
779 sprintf (string3, "the attack key during impact with the wall.");
781 if(tutorialstage==24){
782 sprintf (string, "You can tackle enemies by running at them animal-style");
783 if(attackkey==MOUSEBUTTON1)sprintf (string2, "and pressing jump (%s) or attack(mouse button).",Input::keyToChar(jumpkey));
784 else sprintf (string2, "and pressing jump (%s) or attack(%s).",Input::keyToChar(jumpkey),Input::keyToChar(attackkey));
785 sprintf (string3, "This is especially useful when they are running away.");
787 if(tutorialstage==25){
788 sprintf (string, "Dodge by pressing back and attack. Dodging is essential");
789 sprintf (string2, "against enemies with swords or other long weapons.");
790 sprintf (string3, " ");
792 if(tutorialstage==26){
793 sprintf (string, "REVERSALS AND COUNTER-REVERSALS");
794 sprintf (string2, " ");
795 sprintf (string3, " ");
797 if(tutorialstage==27){
798 sprintf (string, "The enemy can now reverse your attacks.");
799 sprintf (string2, " ");
800 sprintf (string3, " ");
802 if(tutorialstage==28){
803 sprintf (string, "If you attack, you will notice that the enemy now sometimes");
804 sprintf (string2, "catches your attack and uses it against you. Hold");
805 sprintf (string3, "crouch (%s) after attacking to escape from reversals.",Input::keyToChar(crouchkey));
807 if(tutorialstage==29){
808 sprintf (string, "Try escaping from two more reversals in a row.");
809 sprintf (string2, " ");
810 sprintf (string3, " ");
812 if(tutorialstage==30){
813 sprintf (string, "Good!");
814 sprintf (string2, " ");
815 sprintf (string3, " ");
817 if(tutorialstage==31){
818 sprintf (string, "To reverse an attack, you must tap crouch (%s) during the",Input::keyToChar(crouchkey));
819 sprintf (string2, "enemy's attack. You must also be close to the enemy;");
820 sprintf (string3, "this is especially important against armed opponents.");
822 if(tutorialstage==32){
823 sprintf (string, "The enemy can attack in %d seconds.", (int)(tutorialmaxtime-tutorialstagetime));
824 sprintf (string2, "This imaginary opponents attacks will be highlighted");
825 sprintf (string3, "to make this easier.");
827 if(tutorialstage==33){
828 sprintf (string, "Reverse three enemy attacks!");
829 sprintf (string2, " ");
830 sprintf (string3, " ");
832 if(tutorialstage==34){
833 sprintf (string, "Reverse two more enemy attacks!");
834 sprintf (string2, " ");
835 sprintf (string3, " ");
837 if(tutorialstage==35){
838 sprintf (string, "Reverse one more enemy attack!");
839 sprintf (string2, " ");
840 sprintf (string3, " ");
842 if(tutorialstage==36){
843 sprintf (string, "Excellent!");
844 sprintf (string2, " ");
845 sprintf (string3, " ");
847 if(tutorialstage==37){
848 sprintf (string, "Now spar with the enemy for %d more seconds.", (int)(tutorialmaxtime-tutorialstagetime));
849 sprintf (string2, "Damage dealt: %d",(int)damagedealt);
850 sprintf (string3, "Damage taken: %d.",(int)damagetaken);
852 if(tutorialstage==38){
853 sprintf (string, "WEAPONS:");
854 sprintf (string2, " ");
855 sprintf (string3, " ");
857 if(tutorialstage==39){
858 sprintf (string, "There is now an imaginary knife");
859 sprintf (string2, "in the center of the training area.");
860 sprintf (string3, " ");
862 if(tutorialstage==40){
863 sprintf (string, "Stand, roll or handspring over the knife");
864 sprintf (string2, "while pressing %s to pick it up.",Input::keyToChar(throwkey));
865 sprintf (string3, "You can crouch and press the same key to drop it again.");
867 if(tutorialstage==41){
868 sprintf (string, "You can equip and unequip weapons using the %s key.",Input::keyToChar(drawkey));
869 sprintf (string2, "Sometimes it is best to keep them unequipped to");
870 sprintf (string3, "prevent enemies from taking them. ");
872 if(tutorialstage==42){
873 sprintf (string, "The knife is the smallest weapon and the least encumbering.");
874 sprintf (string2, "You can equip or unequip it while standing, crouching,");
875 sprintf (string3, "running or flipping.");
877 if(tutorialstage==43){
878 sprintf (string, "You perform weapon attacks the same way as unarmed attacks,");
879 sprintf (string2, "but sharp weapons cause permanent damage, instead of the");
880 sprintf (string3, "temporary trauma from blunt weapons, fists and feet.");
882 if(tutorialstage==44){
883 sprintf (string, "The enemy now has your knife!");
884 sprintf (string2, "Please reverse two of his knife attacks.");
885 sprintf (string3, " ");
887 if(tutorialstage==45){
888 sprintf (string, "Please reverse one more of his knife attacks.");
889 sprintf (string2, " ");
890 sprintf (string3, " ");
892 if(tutorialstage==46){
893 sprintf (string, "Now he has a sword!");
894 sprintf (string2, "The sword has longer reach than your arms, so you");
895 sprintf (string3, "must move close to reverse the sword slash.");
897 if(tutorialstage==47){
898 sprintf (string, "Long weapons like the sword and staff are also useful for defense;");
899 sprintf (string2, "you can parry enemy weapon attacks by pressing the attack key");
900 sprintf (string3, "at the right time. Please try parrying the enemy's attacks!");
902 if(tutorialstage==48){
903 sprintf (string, "The staff is like the sword, but has two main attacks.");
904 sprintf (string2, "The standing smash is fast and effective, and the running");
905 sprintf (string3, "spin smash is slower and more powerful.");
907 if(tutorialstage==49){
908 sprintf (string, "When facing an enemy, you can throw the knife with %s.",Input::keyToChar(throwkey));
909 sprintf (string2, "It is possible to throw the knife while flipping,");
910 sprintf (string3, "but it is very inaccurate.");
912 if(tutorialstage==50){
913 sprintf (string, "You now know everything you can learn from training.");
914 sprintf (string2, "Everything else you must learn from experience!");
915 sprintf (string3, " ");
917 if(tutorialstage==51){
918 sprintf (string, "Walk out of the training area to return to the main menu.");
919 sprintf (string2, " ");
920 sprintf (string3, " ");
923 glColor4f(0,0,0,tutorialopac);
924 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);
925 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);
926 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);
927 glColor4f(1,1,1,tutorialopac);
928 text.glPrint(screenwidth/2-7.6*strlen(string)*screenwidth/1024,screenheight/16+screenheight*4/5,string,1,1.5*screenwidth/1024,screenwidth,screenheight);
929 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);
930 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);
932 sprintf (string, "Press 'tab' to skip to the next item.",Input::keyToChar(jumpkey));
933 sprintf (string2, "Press escape at any time to");
934 sprintf (string3, "pause or exit the tutorial.");
937 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);
938 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);
939 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);
940 glColor4f(0.5,0.5,0.5,1);
941 text.glPrint(screenwidth/2-7.6*strlen(string)*screenwidth/1024*.8,0+screenheight*1/10,string,1,1.5*screenwidth/1024*.8,screenwidth,screenheight);
942 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);
943 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);
947 if(numhotspots&&(bonustime>=1||bonus<=0||bonustime<0)&&!tutoriallevel){
949 float closestdist=-1;
951 closest=currenthotspot;
952 for(i=0;i<numhotspots;i++){
953 distance=findDistancefast(&player[0].coords,&hotspot[i]);
954 if(closestdist==-1||distance<closestdist){
955 if(findDistancefast(&player[0].coords,&hotspot[i])<hotspotsize[i]&&((hotspottype[i]<=10&&hotspottype[i]>=0)||(hotspottype[i]<=40&&hotspottype[i]>=20))){
956 closestdist=distance;
962 currenthotspot=closest;
963 if(currenthotspot!=-1){
964 if(hotspottype[closest]<=10){
965 if(findDistancefast(&player[0].coords,&hotspot[closest])<hotspotsize[closest])
968 tutorialopac=tutorialmaxtime-tutorialstagetime;
969 if(tutorialopac>1)tutorialopac=1;
970 if(tutorialopac<0)tutorialopac=0;
972 sprintf (string, "%s", hotspottext[closest]);
979 if(string[i]=='\n'||string[i]>'z'||string[i]<' '||string[i]=='\0'){
980 glColor4f(0,0,0,tutorialopac);
981 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);
982 glColor4f(1,1,1,tutorialopac);
983 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);
986 if(string[i]=='\0')done=1;
992 else if (hotspottype[closest]>=20&&dialoguegonethrough[hotspottype[closest]-20]==0){
993 whichdialogue=hotspottype[closest]-20;
994 for(j=0;j<numdialogueboxes[whichdialogue];j++){
995 player[participantfocus[whichdialogue][j]].coords=participantlocation[whichdialogue][participantfocus[whichdialogue][j]];
996 player[participantfocus[whichdialogue][j]].rotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
997 player[participantfocus[whichdialogue][j]].targetrotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
998 player[participantfocus[whichdialogue][j]].velocity=0;
999 player[participantfocus[whichdialogue][j]].targetanimation=player[participantfocus[whichdialogue][j]].getIdle();
1000 player[participantfocus[whichdialogue][j]].targetframe=0;
1004 dialoguegonethrough[whichdialogue]++;
1005 if(dialogueboxsound[whichdialogue][indialogue]!=0){
1006 static float gLoc[3];
1007 static float vel[3];
1008 gLoc[0]=player[participantfocus[whichdialogue][indialogue]].coords.x;
1009 gLoc[1]=player[participantfocus[whichdialogue][indialogue]].coords.y;
1010 gLoc[2]=player[participantfocus[whichdialogue][indialogue]].coords.z;
1015 if(dialogueboxsound[whichdialogue][indialogue]==1)whichsoundplay=rabbitchitter;
1016 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
1017 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
1018 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
1019 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
1020 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
1021 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
1022 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
1023 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
1024 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
1025 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
1026 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
1027 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
1028 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
1029 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
1030 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
1031 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
1032 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
1033 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
1034 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
1035 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, true);
1036 OPENAL_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
1037 OPENAL_SetVolume(channels[whichsoundplay], 256);
1038 OPENAL_SetPaused(channels[whichsoundplay], false);
1044 if(indialogue!=-1&&!mainmenu){
1045 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1046 glDisable(GL_CULL_FACE);
1047 glDisable(GL_LIGHTING);
1048 glDisable(GL_TEXTURE_2D);
1050 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1051 glPushMatrix(); // Store The Projection Matrix
1052 glLoadIdentity(); // Reset The Projection Matrix
1053 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1054 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1055 glPushMatrix(); // Store The Modelview Matrix
1056 glLoadIdentity(); // Reset The Modelview Matrix
1057 if(dialogueboxlocation[whichdialogue][indialogue]==1)glTranslatef(0,screenheight*3/4,0);
1058 glScalef(screenwidth,screenheight/4,1);
1059 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1062 glColor4f(dialogueboxcolor[whichdialogue][indialogue][0],dialogueboxcolor[whichdialogue][indialogue][1],dialogueboxcolor[whichdialogue][indialogue][2],0.7);
1064 glVertex3f(0, 0, 0.0f);
1065 glVertex3f(1, 0, 0.0f);
1066 glVertex3f(1, 1, 0.0f);
1067 glVertex3f(0, 1, 0.0f);
1069 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1070 glPopMatrix(); // Restore The Old Projection Matrix
1071 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1072 glPopMatrix(); // Restore The Old Projection Matrix
1073 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1074 glEnable(GL_CULL_FACE);
1075 glDisable(GL_BLEND);
1077 glEnable(GL_TEXTURE_2D);
1084 startx=screenwidth*1/5;
1085 if(dialogueboxlocation[whichdialogue][indialogue]==1)starty=screenheight/16+screenheight*4/5;
1086 if(dialogueboxlocation[whichdialogue][indialogue]==2)starty=screenheight*1/5-screenheight/16;
1095 for(i=0;i<(int)strlen(dialoguename[whichdialogue][indialogue]);i++){
1096 tempname[tempnum]=dialoguename[whichdialogue][indialogue][i];
1098 if(dialoguename[whichdialogue][indialogue][i]=='#'||dialoguename[whichdialogue][indialogue][i]=='\0')goodchar=0;
1102 tempname[tempnum]='\0';
1105 sprintf (string, "%s: ", tempname);
1107 if(dialogueboxcolor[whichdialogue][indialogue][0]+dialogueboxcolor[whichdialogue][indialogue][1]+dialogueboxcolor[whichdialogue][indialogue][2]<1.5){
1108 glColor4f(0,0,0,tutorialopac);
1109 text.glPrintOutline(startx-2*7.6*strlen(string)*screenwidth/1024-4,starty-4,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight);
1110 glColor4f(0.7,0.7,0.7,tutorialopac);
1111 text.glPrint(startx-2*7.6*strlen(string)*screenwidth/1024,starty,string,1,1.5*screenwidth/1024,screenwidth,screenheight);
1115 glColor4f(0,0,0,tutorialopac);
1116 text.glPrintOutline(startx-2*7.6*strlen(string)*screenwidth/1024-4,starty-4,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight);
1120 for(i=0;i<(int)strlen(dialoguetext[whichdialogue][indialogue])+1;i++){
1121 tempname[tempnum]=dialoguetext[whichdialogue][indialogue][i];
1122 if(dialoguetext[whichdialogue][indialogue][i]!='#')tempnum++;
1125 sprintf (string, "%s", tempname);
1132 if(string[i]=='\n'||string[i]>'z'||string[i]<' '||string[i]=='\0'){
1133 if(dialogueboxcolor[whichdialogue][indialogue][0]+dialogueboxcolor[whichdialogue][indialogue][1]+dialogueboxcolor[whichdialogue][indialogue][2]<1.5){
1134 glColor4f(0,0,0,tutorialopac);
1135 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);
1136 glColor4f(1,1,1,tutorialopac);
1137 text.glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/,starty-20*screenwidth/1024*line,string,1,1.5*screenwidth/1024,screenwidth,screenheight,lastline,i);
1141 glColor4f(0,0,0,tutorialopac);
1142 text.glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/,starty-20*screenwidth/1024*line,string,1,1.5*screenwidth/1024,screenwidth,screenheight,lastline,i);
1146 if(string[i]=='\0')done=1;
1153 if(!tutoriallevel&&!winfreeze&&indialogue==-1&&!mainmenu){
1156 sprintf (string, "Score: %d", (int)accountactive->getCampaignScore());
1158 sprintf (string, "Score: %d", (int)accountactive->getCampaignScore()+(int)bonustotal);
1160 if(!campaign)sprintf (string, "Score: %d", (int)bonustotal);
1162 text.glPrintOutline(1024/40-4,768/16-4+768*14/16,string,1,1.5*1.25,1024,768);
1164 text.glPrint(1024/40,768/16+768*14/16,string,1,1.5,1024,768);
1166 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1167 glDisable(GL_CULL_FACE);
1168 glDisable(GL_LIGHTING);
1169 glDisable(GL_TEXTURE_2D);
1171 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1172 glPushMatrix(); // Store The Projection Matrix
1173 glLoadIdentity(); // Reset The Projection Matrix
1174 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1175 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1176 glPushMatrix(); // Store The Modelview Matrix
1177 glLoadIdentity(); // Reset The Modelview Matrix
1178 glTranslatef(15,screenheight*17.5/20,0);
1179 glScalef(screenwidth/3+20,screenheight/20,1);
1180 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1182 glColor4f(0.0,0.4,0.0,0.7);
1183 float bar=((float)player[0].damage)/player[0].damagetolerance;
1185 glVertex3f((bar<1?bar:1),0,0.0f);
1186 glVertex3f(1,0,0.0f);
1187 glVertex3f(1,1,0.0f);
1188 glVertex3f((bar<1?bar:1),1,0.0f);
1190 glColor4f(0.1,0.0,0.0,1);
1191 bar = ((float)player[0].bloodloss)/player[0].damagetolerance;
1193 glVertex3f(0,0,0.0f);
1194 glVertex3f((bar<1?bar:1),0,0.0f);
1195 glVertex3f((bar<1?bar:1),1,0.0f);
1196 glVertex3f(0,1,0.0f);
1198 glColor4f(0.4,0.0,0.0,0.7);
1199 bar = ((float)player[0].damage)/player[0].damagetolerance;
1201 glVertex3f(0,0,0.0f);
1202 glVertex3f((bar<1?bar:1),0,0.0f);
1203 glVertex3f((bar<1?bar:1),1,0.0f);
1204 glVertex3f(0,1,0.0f);
1206 glColor4f(0.4,0.0,0.0,0.7);
1207 bar = ((float)player[0].permanentdamage)/player[0].damagetolerance;
1209 glVertex3f(0,0,0.0f);
1210 glVertex3f((bar<1?bar:1),0,0.0f);
1211 glVertex3f((bar<1?bar:1),1,0.0f);
1212 glVertex3f(0,1,0.0f);
1214 glColor4f(0.4,0.0,0.0,0.7);
1215 bar = ((float)player[0].superpermanentdamage)/player[0].damagetolerance;
1217 glVertex3f(0,0,0.0f);
1218 glVertex3f((bar<1?bar:1),0,0.0f);
1219 glVertex3f((bar<1?bar:1),1,0.0f);
1220 glVertex3f(0,1,0.0f);
1222 glColor4f(0.0,0.0,0.0,0.7);
1224 glBegin(GL_LINE_STRIP);
1225 glVertex3f(0,0,0.0f);
1226 glVertex3f(1,0,0.0f);
1227 glVertex3f(1,1,0.0f);
1228 glVertex3f(0,1,0.0f);
1229 glVertex3f(0,0,0.0f);
1232 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1233 glPopMatrix(); // Restore The Old Projection Matrix
1234 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1235 glPopMatrix(); // Restore The Old Projection Matrix
1236 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1237 glEnable(GL_CULL_FACE);
1238 glDisable(GL_BLEND);
1240 glEnable(GL_TEXTURE_2D);
1242 // writing the numbers :
1243 sprintf (string, "Damages : %d/%d (%d)",(int)(player[0].damage),(int)(player[0].damagetolerance),(int)(player[0].bloodloss));
1245 text.glPrintOutline(1024/40-4,768/16-4+768*14/16-40,string,1,1.5*1.25,1024,768);
1247 text.glPrint(1024/40,768/16+768*14/16-40,string,1,1.5,1024,768);
1251 glColor4f(.5,.5,.5,1);
1254 if((texttoggle||editorenabled)&&debugmode&&!mainmenu){
1255 sprintf (string, "The framespersecond is %d.",(int)(fps));
1256 text.glPrint(10,30,string,0,.8,1024,768);
1258 sprintf (string, "Name: %s", registrationname);
1259 text.glPrint(10,260,string,0,.8,1024,768);
1263 sprintf (string, "Map editor enabled.");
1265 sprintf (string, "Map editor disabled.");
1266 text.glPrint(10,60,string,0,.8,1024,768);
1268 sprintf (string, "Object size: %f",editorsize);
1269 text.glPrint(10,75,string,0,.8,1024,768);
1270 if(editorrotation>=0)sprintf (string, "Object rotation: %f",editorrotation);
1271 else sprintf (string, "Object rotation: Random");
1272 text.glPrint(10,90,string,0,.8,1024,768);
1273 if(editorrotation2>=0)sprintf (string, "Object rotation2: %f",editorrotation2);
1274 else sprintf (string, "Object rotation2: Random");
1275 text.glPrint(10,105,string,0,.8,1024,768);
1276 sprintf (string, "Object type: %d",editortype);
1277 text.glPrint(10,120,string,0,.8,1024,768);
1278 switch(editortype) {
1280 sprintf (string, "(box)");
1283 sprintf (string, "(tree)");
1286 sprintf (string, "(wall)");
1289 sprintf (string, "(weird)");
1292 sprintf (string, "(spike)");
1295 sprintf (string, "(rock)");
1298 sprintf (string, "(bush)");
1301 sprintf (string, "(tunnel)");
1304 sprintf (string, "(chimney)");
1307 sprintf (string, "(platform)");
1310 sprintf (string, "(cool)");
1313 sprintf (string, "(fire)");
1316 text.glPrint(130,120,string,0,.8,1024,768);
1318 sprintf (string, "Numplayers: %d",numplayers);
1319 text.glPrint(10,155,string,0,.8,1024,768);
1320 sprintf (string, "Player %d: numwaypoints: %d",numplayers,player[numplayers-1].numwaypoints);
1321 text.glPrint(10,140,string,0,.8,1024,768);
1323 sprintf (string, "Difficulty: %d",difficulty);
1324 text.glPrint(10,240,string,0,.8,1024,768);
1329 if(drawmode==glowmode){
1330 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1331 glDisable(GL_CULL_FACE);
1332 glDisable(GL_LIGHTING);
1333 glDisable(GL_TEXTURE_2D);
1335 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1336 glPushMatrix(); // Store The Projection Matrix
1337 glLoadIdentity(); // Reset The Projection Matrix
1338 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1339 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1340 glPushMatrix(); // Store The Modelview Matrix
1341 glLoadIdentity(); // Reset The Modelview Matrix
1342 glScalef(screenwidth,screenheight,1);
1343 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1345 glColor4f(0,0,0,.5);
1347 glVertex3f(0, 0, 0.0f);
1348 glVertex3f(256, 0, 0.0f);
1349 glVertex3f(256, 256, 0.0f);
1350 glVertex3f(0, 256, 0.0f);
1352 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1353 glPopMatrix(); // Restore The Old Projection Matrix
1354 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1355 glPopMatrix(); // Restore The Old Projection Matrix
1356 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1357 glEnable(GL_CULL_FACE);
1358 glDisable(GL_BLEND);
1362 if((((blackout&&damageeffects)||(player[0].bloodloss>0&&damageeffects&&player[0].blooddimamount>0)||player[0].dead)&&!cameramode)||console){
1363 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1364 glDisable(GL_CULL_FACE);
1365 glDisable(GL_LIGHTING);
1366 glDisable(GL_TEXTURE_2D);
1368 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1369 glPushMatrix(); // Store The Projection Matrix
1370 glLoadIdentity(); // Reset The Projection Matrix
1371 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1372 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1373 glPushMatrix(); // Store The Modelview Matrix
1374 glLoadIdentity(); // Reset The Modelview Matrix
1375 glScalef(screenwidth,screenheight,1);
1376 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1378 if(player[0].dead)blackout+=multiplier*3;
1379 if(player[0].dead==1)blackout=.4f;
1380 if(player[0].dead==2&&blackout>.6)blackout=.6;
1381 glColor4f(0,0,0,blackout);
1382 if(!player[0].dead){
1383 if((player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5))*.3<.3){
1384 glColor4f(0,0,0,player[0].blooddimamount*player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5)*.3);
1385 blackout=player[0].blooddimamount*player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5)*.3;
1388 glColor4f(0,0,0,player[0].blooddimamount*.3);
1389 blackout=player[0].blooddimamount*.3;
1392 if(console)glColor4f(.7,0,0,.2);
1394 glVertex3f(0, 0, 0.0f);
1395 glVertex3f(256, 0, 0.0f);
1396 glVertex3f(256, 256, 0.0f);
1397 glVertex3f(0, 256, 0.0f);
1399 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1400 glPopMatrix(); // Restore The Old Projection Matrix
1401 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1402 glPopMatrix(); // Restore The Old Projection Matrix
1403 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1404 glEnable(GL_CULL_FACE);
1405 glDisable(GL_BLEND);
1409 if(flashamount>0&&damageeffects){
1410 if(flashamount>1)flashamount=1;
1411 if(flashdelay<=0)flashamount-=multiplier;
1413 if(flashamount<0)flashamount=0;
1414 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1415 glDisable(GL_CULL_FACE);
1416 glDisable(GL_LIGHTING);
1418 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1419 glPushMatrix(); // Store The Projection Matrix
1420 glLoadIdentity(); // Reset The Projection Matrix
1421 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1422 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1423 glPushMatrix(); // Store The Modelview Matrix
1424 glLoadIdentity(); // Reset The Modelview Matrix
1425 glScalef(screenwidth,screenheight,1);
1426 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1428 glColor4f(flashr,flashg,flashb,flashamount);
1430 glVertex3f(0, 0, 0.0f);
1431 glVertex3f(256, 0, 0.0f);
1432 glVertex3f(256, 256, 0.0f);
1433 glVertex3f(0, 256, 0.0f);
1435 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1436 glPopMatrix(); // Restore The Old Projection Matrix
1437 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1438 glPopMatrix(); // Restore The Old Projection Matrix
1439 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1440 glEnable(GL_CULL_FACE);
1441 glDisable(GL_BLEND);
1447 glEnable(GL_TEXTURE_2D);
1450 sprintf (string, " ]");
1451 text.glPrint(10,30+screenheight-330,string,0,1,screenwidth,screenheight);
1453 sprintf (string, "_");
1454 text.glPrint(30+(float)(displayselected)*10,30+(screenheight-330),string,0,1,screenwidth,screenheight);
1458 if((i!=0||chatting)&&displaytime[i]<4)
1459 for(j=0;j<displaychars[i];j++){
1460 glColor4f(1,1,1,4-displaytime[i]);
1461 if(j<displaychars[i]){
1462 sprintf (string, "%c",displaytext[i][j]);
1463 text.glPrint(30+j*10,30+i*20+(screenheight-330),string,0,1,screenwidth,screenheight);
1469 if(minimap&&indialogue==-1){
1470 float mapviewdist = 20000;
1472 glDisable(GL_DEPTH_TEST);
1473 glColor3f (1.0, 1.0, 1.0); // no coloring
1475 glEnable(GL_TEXTURE_2D);
1476 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1477 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1478 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1479 glDisable(GL_CULL_FACE);
1480 glDisable(GL_LIGHTING);
1482 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1483 glPushMatrix(); // Store The Projection Matrix
1484 glLoadIdentity(); // Reset The Projection Matrix
1485 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1486 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1487 glPushMatrix(); // Store The Modelview Matrix
1488 glLoadIdentity(); // Reset The Modelview Matrix
1489 glScalef((float)screenwidth/2,(float)screenwidth/2,1);
1490 glTranslatef(1.75,.25,0);
1491 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1499 int numliveplayers=0;
1501 for(i=0;i<numplayers;i++){
1502 if(!player[i].dead) numliveplayers++;
1507 for(i=0;i<objects.numobjects;i++){
1508 if(objects.type[i]==treetrunktype||objects.type[i]==boxtype){
1509 center+=objects.position[i];
1513 for(i=0;i<numplayers;i++){
1514 if(!player[i].dead)center+=player[i].coords;
1516 center/=numadd+numliveplayers;
1518 center=player[0].coords;
1520 float maxdistance=0;
1523 for(i=0;i<objects.numobjects;i++){
1524 tempdist=findDistancefast(¢er,&objects.position[i]);
1525 if(tempdist>maxdistance){
1527 maxdistance=tempdist;
1530 for(i=0;i<numplayers;i++){
1531 if(!player[i].dead){
1532 tempdist=findDistancefast(¢er,&player[i].coords);
1533 if(tempdist>maxdistance){
1535 maxdistance=tempdist;
1539 radius=fast_sqrt(maxdistance);
1543 glScalef(.25/radius*256*terrain.scale*.4,.25/radius*256*terrain.scale*.4,1);
1545 glScalef(1/(1/radius*256*terrain.scale*.4),1/(1/radius*256*terrain.scale*.4),1);
1547 glRotatef(player[0].lookrotation*-1+180,0,0,1);
1548 glTranslatef(-(center.x/terrain.scale/256*-2+1),(center.z/terrain.scale/256*-2+1),0);
1549 for(i=0;i<objects.numobjects;i++){
1550 if(objects.type[i]==treetrunktype){
1551 distcheck=findDistancefast(&player[0].coords,&objects.position[i]);
1552 if(distcheck<mapviewdist){
1553 glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
1554 glColor4f(0,.3,0,opac*(1-distcheck/mapviewdist));
1556 glTranslatef(objects.position[i].x/terrain.scale/256*-2+1,objects.position[i].z/terrain.scale/256*2-1,0);
1557 glRotatef(objects.rotation[i],0,0,1);
1558 glScalef(.003,.003,.003);
1561 glVertex3f(-1, -1, 0.0f);
1563 glVertex3f(1, -1, 0.0f);
1565 glVertex3f(1, 1, 0.0f);
1567 glVertex3f(-1, 1, 0.0f);
1572 if(objects.type[i]==boxtype){
1573 distcheck=findDistancefast(&player[0].coords,&objects.position[i]);
1574 if(distcheck<mapviewdist){
1575 glBindTexture( GL_TEXTURE_2D, Mapboxtexture);
1576 glColor4f(.4,.4,.4,opac*(1-distcheck/mapviewdist));
1578 glTranslatef(objects.position[i].x/terrain.scale/256*-2+1,objects.position[i].z/terrain.scale/256*2-1,0);
1579 glRotatef(objects.rotation[i],0,0,1);
1580 glScalef(.01*objects.scale[i],.01*objects.scale[i],.01*objects.scale[i]);
1583 glVertex3f(-1, -1, 0.0f);
1585 glVertex3f(1, -1, 0.0f);
1587 glVertex3f(1, 1, 0.0f);
1589 glVertex3f(-1, 1, 0.0f);
1596 glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
1597 for(i=0;i<numboundaries;i++){
1598 glColor4f(0,0,0,opac/3);
1600 glTranslatef(boundary[i].x/terrain.scale/256*-2+1,boundary[i].z/terrain.scale/256*2-1,0);
1601 glScalef(.002,.002,.002);
1604 glVertex3f(-1, -1, 0.0f);
1606 glVertex3f(1, -1, 0.0f);
1608 glVertex3f(1, 1, 0.0f);
1610 glVertex3f(-1, 1, 0.0f);
1615 for(i=0;i<numplayers;i++){
1616 distcheck=findDistancefast(&player[0].coords,&player[i].coords);
1617 if(distcheck<mapviewdist){
1619 glBindTexture( GL_TEXTURE_2D, Maparrowtexture);
1620 if(i==0)glColor4f(1,1,1,opac);
1621 else if(player[i].dead==2||player[i].howactive>typesleeping)glColor4f(0,0,0,opac*(1-distcheck/mapviewdist));
1622 else if(player[i].dead)glColor4f(.3,.3,.3,opac*(1-distcheck/mapviewdist));
1623 else if(player[i].aitype==attacktypecutoff)glColor4f(1,0,0,opac*(1-distcheck/mapviewdist));
1624 else if(player[i].aitype==passivetype)glColor4f(0,1,0,opac*(1-distcheck/mapviewdist));
1625 else glColor4f(1,1,0,1);
1626 glTranslatef(player[i].coords.x/terrain.scale/256*-2+1,player[i].coords.z/terrain.scale/256*2-1,0);
1627 glRotatef(player[i].rotation+180,0,0,1);
1628 glScalef(.005,.005,.005);
1631 glVertex3f(-1, -1, 0.0f);
1633 glVertex3f(1, -1, 0.0f);
1635 glVertex3f(1, 1, 0.0f);
1637 glVertex3f(-1, 1, 0.0f);
1643 glDisable(GL_TEXTURE_2D);
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 if(loading&&!stealthloading&&(!campaign||player[0].dead)){
1655 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1656 glDisable(GL_CULL_FACE);
1657 glDisable(GL_LIGHTING);
1658 glDisable(GL_TEXTURE_2D);
1660 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1661 glPushMatrix(); // Store The Projection Matrix
1662 glLoadIdentity(); // Reset The Projection Matrix
1663 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1664 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1665 glPushMatrix(); // Store The Modelview Matrix
1666 glLoadIdentity(); // Reset The Modelview Matrix
1667 glScalef(screenwidth,screenheight,1);
1668 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1670 glColor4f(0,0,0,.7);
1672 glVertex3f(0, 0, 0.0f);
1673 glVertex3f(256, 0, 0.0f);
1674 glVertex3f(256, 256, 0.0f);
1675 glVertex3f(0, 256, 0.0f);
1677 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1678 glPopMatrix(); // Restore The Old Projection Matrix
1679 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1680 glPopMatrix(); // Restore The Old Projection Matrix
1681 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1682 glEnable(GL_CULL_FACE);
1683 glDisable(GL_BLEND);
1687 glDisable(GL_DEPTH_TEST);
1688 glColor3f (1.0, 1.0, 1.0); // no coloring
1690 glEnable(GL_TEXTURE_2D);
1695 glEnable(GL_TEXTURE_2D);
1697 sprintf (string, "Loading...");
1698 text.glPrint(1024/2-90,768/2,string,1,2,1024,768);
1701 //if(ismotionblur)drawmode=motionblurmode;
1702 drawmode=normalmode;
1705 if(winfreeze&&!campaign){
1706 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1707 glDisable(GL_CULL_FACE);
1708 glDisable(GL_LIGHTING);
1709 glDisable(GL_TEXTURE_2D);
1711 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1712 glPushMatrix(); // Store The Projection Matrix
1713 glLoadIdentity(); // Reset The Projection Matrix
1714 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1715 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1716 glPushMatrix(); // Store The Modelview Matrix
1717 glLoadIdentity(); // Reset The Modelview Matrix
1718 glScalef(screenwidth,screenheight,1);
1719 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1721 glColor4f(0,0,0,.4);
1723 glVertex3f(0, 0, 0.0f);
1724 glVertex3f(256, 0, 0.0f);
1725 glVertex3f(256, 256, 0.0f);
1726 glVertex3f(0, 256, 0.0f);
1728 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1729 glPopMatrix(); // Restore The Old Projection Matrix
1730 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1731 glPopMatrix(); // Restore The Old Projection Matrix
1732 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1733 glEnable(GL_CULL_FACE);
1734 glDisable(GL_BLEND);
1738 glDisable(GL_DEPTH_TEST);
1739 glColor3f (1.0, 1.0, 1.0); // no coloring
1741 glEnable(GL_TEXTURE_2D);
1747 if(damagetaken==0&&player[0].bloodloss==0){
1748 awards[numawards]=awardflawless;
1751 bool alldead = true;
1752 for(i=1;i<numplayers;i++){
1753 if(player[i].dead!=2)alldead=0;
1756 awards[numawards]=awardalldead;
1760 for(i=1;i<numplayers;i++){
1761 if(player[i].dead!=1)alldead=0;
1764 awards[numawards]=awardnodead;
1767 if(numresponded==0&&!numthrowkill){
1768 awards[numawards]=awardstealth;
1771 if(numattacks==numstaffattack&&numattacks>0){
1772 awards[numawards]=awardbojutsu;
1775 if(numattacks==numswordattack&&numattacks>0){
1776 awards[numawards]=awardswordsman;
1779 if(numattacks==numknifeattack&&numattacks>0){
1780 awards[numawards]=awardknifefighter;
1783 if(numattacks==numunarmedattack&&numthrowkill==0&&weapons.numweapons>0){
1784 awards[numawards]=awardkungfu;
1788 awards[numawards]=awardevasion;
1791 if(numflipfail==0&&numflipped+numwallflipped*2>20){
1792 awards[numawards]=awardacrobat;
1795 if(numthrowkill==numplayers-1){
1796 awards[numawards]=awardlongrange;
1800 for(i=1;i<numplayers;i++){
1801 if(player[i].dead!=2)alldead=0;
1803 if(numafterkill>0&&alldead){
1804 awards[numawards]=awardbrutal;
1807 if(numreversals>((float)numattacks)*.8&&numreversals>3){
1808 awards[numawards]=awardaikido;
1811 if(maxalarmed==1&&numplayers>2){
1812 awards[numawards]=awardstrategy;
1816 awards[numawards]=awardklutz;
1820 //Win Screen Won Victory
1822 glEnable(GL_TEXTURE_2D);
1824 sprintf (string, "Level Cleared!");
1825 text.glPrintOutlined(1024/2-strlen(string)*10,768*7/8,string,1,2,1024,768);
1827 sprintf (string, "Score: %d",(int)(bonustotal-startbonustotal));
1828 text.glPrintOutlined(1024/30,768*6/8,string,1,2,1024,768);
1831 sprintf (string, "Press Escape or Space to continue");
1833 sprintf (string, "Press Escape to return to menu or Space to continue");
1834 text.glPrintOutlined(640/2-strlen(string)*5,480*1/16,string,1,1,640,480);
1838 for(i=0;i<255;i++)string[i]='\0';
1839 sprintf (temp, "Time: %d:",(int)(((int)leveltime-(int)(leveltime)%60)/60));
1840 strcat(string,temp);
1841 if((int)(leveltime)%60<10)strcat(string,"0");
1842 sprintf (temp, "%d",(int)(leveltime)%60);
1843 strcat(string,temp);
1844 text.glPrintOutlined(1024/30,768*6/8-40,string,1,2,1024,768);
1846 for(i=0;i<numawards;i++){
1848 if(awards[i]==awardklutz)sprintf (string, "Suicidal");
1849 if(awards[i]==awardflawless)sprintf (string, "Flawless!");
1850 if(awards[i]==awardalldead)sprintf (string, "Take no prisoners");
1851 if(awards[i]==awardnodead)sprintf (string, "Merciful");
1852 if(awards[i]==awardstealth)sprintf (string, "One with the shadows!");
1853 if(awards[i]==awardswordsman)sprintf (string, "Swordsman");
1854 if(awards[i]==awardkungfu)sprintf (string, "Unarmed!");
1855 if(awards[i]==awardknifefighter)sprintf (string, "Knife fighter");
1856 if(awards[i]==awardcoward)sprintf (string, "Coward");
1857 if(awards[i]==awardevasion)sprintf (string, "Escape artist");
1858 if(awards[i]==awardacrobat)sprintf (string, "Gymnast");
1859 if(awards[i]==awardlongrange)sprintf (string, "Blade slinger");
1860 if(awards[i]==awardbrutal)sprintf (string, "Brutal");
1861 if(awards[i]==awardhyper)sprintf (string, "Hyper");
1862 if(awards[i]==awardaikido)sprintf (string, "Aikido master!");
1863 if(awards[i]==awardrambo)sprintf (string, "Rambo");
1864 if(awards[i]==awardfast)sprintf (string, "Fast");
1865 if(awards[i]==awardrealfast)sprintf (string, "Real fast");
1866 if(awards[i]==awarddamnfast)sprintf (string, "Damn fast");
1867 if(awards[i]==awardstrategy)sprintf (string, "Divide and conquer");
1868 if(awards[i]==awardbojutsu)sprintf (string, "Bojutsu");
1869 text.glPrintOutlined(1024/30,768*6/8-90-40*i,string,1,2,1024,768);
1874 if(drawmode!=normalmode){
1875 glEnable(GL_TEXTURE_2D);
1877 if(!drawtoggle||drawmode!=realmotionblurmode||(drawtoggle==2||change==1)){
1880 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
1881 GLfloat subtractColor[4] = { 0.5, 0.5, 0.5, 0.0 };
1882 glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, subtractColor);
1883 //glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_SUBTRACT);
1884 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE);
1885 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_CONSTANT_EXT);
1886 glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 2.0f);
1888 glBindTexture( GL_TEXTURE_2D, screentexture);
1889 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1892 if((drawtoggle||change==1)&&drawmode==realmotionblurmode){
1894 glBindTexture( GL_TEXTURE_2D, screentexture2);
1895 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1897 if(!screentexture2){
1898 glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
1900 glGenTextures( 1, &screentexture2 );
1901 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
1903 glEnable(GL_TEXTURE_2D);
1904 glBindTexture( GL_TEXTURE_2D, screentexture2);
1905 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
1906 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
1908 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
1914 glClear(GL_DEPTH_BUFFER_BIT);
1915 ReSizeGLScene(90,.1f);
1916 glViewport(0,0,screenwidth,screenheight);
1918 if(drawmode!=normalmode){
1919 glDisable(GL_DEPTH_TEST);
1920 if(drawmode==motionblurmode){
1921 glDrawBuffer(GL_FRONT);
1922 glReadBuffer(GL_BACK);
1924 glColor3f (1.0, 1.0, 1.0); // no coloring
1926 glEnable(GL_TEXTURE_2D);
1927 glBindTexture( GL_TEXTURE_2D, screentexture);
1928 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1929 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1930 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1931 glDisable(GL_CULL_FACE);
1932 glDisable(GL_LIGHTING);
1934 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1935 glPushMatrix(); // Store The Projection Matrix
1936 glLoadIdentity(); // Reset The Projection Matrix
1937 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1938 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1939 glPushMatrix(); // Store The Modelview Matrix
1940 glLoadIdentity(); // Reset The Modelview Matrix
1941 glScalef((float)screenwidth/2,(float)screenheight/2,1);
1942 glTranslatef(1,1,0);
1943 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1945 if(drawmode==motionblurmode){
1946 if(motionbluramount<.2)motionbluramount=.2;
1947 //glColor4f(1,1,1,fast_sqrt(multiplier)*2.9*motionbluramount);
1948 glColor4f(1,1,1,motionbluramount);
1952 glVertex3f(-1, -1, 0.0f);
1953 glTexCoord2f(texcoordwidth,0);
1954 glVertex3f(1, -1, 0.0f);
1955 glTexCoord2f(texcoordwidth,texcoordheight);
1956 glVertex3f(1, 1, 0.0f);
1957 glTexCoord2f(0,texcoordheight);
1958 glVertex3f(-1, 1, 0.0f);
1962 if(drawmode==realmotionblurmode){
1963 glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
1964 glClear(GL_COLOR_BUFFER_BIT);
1965 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
1966 glBindTexture( GL_TEXTURE_2D, screentexture);
1967 glColor4f(1,1,1,.5);
1971 glVertex3f(-1, -1, 0.0f);
1972 glTexCoord2f(texcoordwidth,0);
1973 glVertex3f(1, -1, 0.0f);
1974 glTexCoord2f(texcoordwidth,texcoordheight);
1975 glVertex3f(1, 1, 0.0f);
1976 glTexCoord2f(0,texcoordheight);
1977 glVertex3f(-1, 1, 0.0f);
1980 glBindTexture( GL_TEXTURE_2D, screentexture2);
1981 glColor4f(1,1,1,.5);
1985 glVertex3f(-1, -1, 0.0f);
1986 glTexCoord2f(texcoordwidth,0);
1987 glVertex3f(1, -1, 0.0f);
1988 glTexCoord2f(texcoordwidth,texcoordheight);
1989 glVertex3f(1, 1, 0.0f);
1990 glTexCoord2f(0,texcoordheight);
1991 glVertex3f(-1, 1, 0.0f);
1994 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1996 if(drawmode==doublevisionmode){
1997 static float crosseyedness;
1998 crosseyedness=abs(player[0].damage-player[0].superpermanentdamage-(player[0].damagetolerance-player[0].superpermanentdamage)*1/2)/30;
1999 if(crosseyedness>1)crosseyedness=1;
2000 if(crosseyedness<0)crosseyedness=0;
2002 glDisable(GL_BLEND);
2007 glVertex3f(-1, -1, 0.0f);
2008 glTexCoord2f(texcoordwidth,0);
2009 glVertex3f(1, -1, 0.0f);
2010 glTexCoord2f(texcoordwidth,texcoordheight);
2011 glVertex3f(1, 1, 0.0f);
2012 glTexCoord2f(0,texcoordheight);
2013 glVertex3f(-1, 1, 0.0f);
2017 glColor4f(1,1,1,.5);
2020 glTranslatef(.015*crosseyedness,0,0);
2024 glVertex3f(-1, -1, 0.0f);
2025 glTexCoord2f(texcoordwidth,0);
2026 glVertex3f(1, -1, 0.0f);
2027 glTexCoord2f(texcoordwidth,texcoordheight);
2028 glVertex3f(1, 1, 0.0f);
2029 glTexCoord2f(0,texcoordheight);
2030 glVertex3f(-1, 1, 0.0f);
2035 if(drawmode==glowmode){
2036 glColor4f(.5,.5,.5,.5);
2038 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
2040 glTranslatef(.01,0,0);
2043 glVertex3f(-1, -1, 0.0f);
2044 glTexCoord2f(texcoordwidth,0);
2045 glVertex3f(1, -1, 0.0f);
2046 glTexCoord2f(texcoordwidth,texcoordheight);
2047 glVertex3f(1, 1, 0.0f);
2048 glTexCoord2f(0,texcoordheight);
2049 glVertex3f(-1, 1, 0.0f);
2053 glTranslatef(-.01,0,0);
2056 glVertex3f(-1, -1, 0.0f);
2057 glTexCoord2f(texcoordwidth,0);
2058 glVertex3f(1, -1, 0.0f);
2059 glTexCoord2f(texcoordwidth,texcoordheight);
2060 glVertex3f(1, 1, 0.0f);
2061 glTexCoord2f(0,texcoordheight);
2062 glVertex3f(-1, 1, 0.0f);
2066 glTranslatef(.0,.01,0);
2069 glVertex3f(-1, -1, 0.0f);
2070 glTexCoord2f(texcoordwidth,0);
2071 glVertex3f(1, -1, 0.0f);
2072 glTexCoord2f(texcoordwidth,texcoordheight);
2073 glVertex3f(1, 1, 0.0f);
2074 glTexCoord2f(0,texcoordheight);
2075 glVertex3f(-1, 1, 0.0f);
2079 glTranslatef(0,-.01,0);
2082 glVertex3f(-1, -1, 0.0f);
2083 glTexCoord2f(texcoordwidth,0);
2084 glVertex3f(1, -1, 0.0f);
2085 glTexCoord2f(texcoordwidth,texcoordheight);
2086 glVertex3f(1, 1, 0.0f);
2087 glTexCoord2f(0,texcoordheight);
2088 glVertex3f(-1, 1, 0.0f);
2092 if(drawmode==radialzoommode){
2094 //glRotatef((float)i*.1,0,0,1);
2095 glColor4f(1,1,1,1/((float)i+1));
2097 glScalef(1+(float)i*.01,1+(float)i*.01,1);
2100 glVertex3f(-1, -1, 0.0f);
2101 glTexCoord2f(texcoordwidth,0);
2102 glVertex3f(1, -1, 0.0f);
2103 glTexCoord2f(texcoordwidth,texcoordheight);
2104 glVertex3f(1, 1, 0.0f);
2105 glTexCoord2f(0,texcoordheight);
2106 glVertex3f(-1, 1, 0.0f);
2111 glDisable(GL_TEXTURE_2D);
2112 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2113 glPopMatrix(); // Restore The Old Projection Matrix
2114 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2115 glPopMatrix(); // Restore The Old Projection Matrix
2116 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
2117 glEnable(GL_CULL_FACE);
2118 glDisable(GL_BLEND);
2123 glEnable(GL_TEXTURE_2D);
2126 if(consoleselected>=60)
2127 offset=consoleselected-60;
2128 sprintf (string, " ]");
2129 text.glPrint(10,30,string,0,1,1024,768);
2131 sprintf (string, "_");
2132 text.glPrint(30+(float)(consoleselected)*10-offset*10,30,string,0,1,1024,768);
2135 for(j=0;j<consolechars[i];j++){
2136 glColor4f(1,1,1,1-(float)(i)/16);
2137 if(j<consolechars[i]){
2138 sprintf (string, "%c",consoletext[i][j]);
2139 text.glPrint(30+j*10-offset*10,30+i*20,string,0,1,1024,768);
2146 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)||(mainmenu&&gameon)||(!gameon&&gamestarted)||(!gameon&&gamestarted)){
2147 multiplier=tempmult;
2152 // !!! FIXME: hack: clamp framerate in menu so text input works correctly on fast systems.
2155 glDrawBuffer(GL_BACK);
2156 glReadBuffer(GL_BACK);
2157 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
2158 ReSizeGLScene(90,.1f);
2161 temptexdetail=texdetail;
2162 if(texdetail>2)texdetail=2;
2163 if(mainmenu!=oldmainmenu&&oldmainmenu!=0){
2165 LoadTexture(":Data:Textures:Newgame.png",&Mainmenuitems[1],0,0);
2166 LoadTexture(":Data:Textures:Quit.png",&Mainmenuitems[3],0,0);
2169 LoadTexture(":Data:Textures:Resume.png",&Mainmenuitems[1],0,0);
2170 LoadTexture(":Data:Textures:Endgame.png",&Mainmenuitems[3],0,0);
2173 if(lastcheck>.5||oldmainmenu!=mainmenu){
2175 ifstream ipstream(ConvertFileName(":Data:Campaigns:main.txt"));
2176 ipstream.ignore(256,':');
2177 ipstream >> campaignnumlevels;
2178 for(i=0;i<campaignnumlevels;i++){
2179 ipstream.ignore(256,':');
2180 ipstream.ignore(256,':');
2181 ipstream.ignore(256,' ');
2182 ipstream >> campaignmapname[i];
2183 ipstream.ignore(256,':');
2184 ipstream >> campaigndescription[i];
2186 if(campaigndescription[i][j]=='_')campaigndescription[i][j]=' ';
2188 ipstream.ignore(256,':');
2189 ipstream >> campaignchoosenext[i];
2190 ipstream.ignore(256,':');
2191 ipstream >> campaignnumnext[i];
2192 for(j=0;j<campaignnumnext[i];j++){
2193 ipstream.ignore(256,':');
2194 ipstream >> campaignnextlevel[i][j];
2195 campaignnextlevel[i][j]-=1;
2197 ipstream.ignore(256,':');
2198 ipstream >> campaignlocationx[i];
2199 ipstream.ignore(256,':');
2200 ipstream >> campaignlocationy[i];
2204 for(i=0;i<campaignnumlevels;i++){
2206 levelhighlight[i]=0;
2211 for(i=0;i<accountactive->getCampaignChoicesMade();i++){
2212 levelorder[i+1]=campaignnextlevel[levelorder[i]][accountactive->getCampaignChoice(i)];
2213 levelvisible[levelorder[i+1]]=1;
2215 int whichlevelstart = accountactive->getCampaignChoicesMade()-1;
2216 if(whichlevelstart<0){
2217 accountactive->setCampaignScore(0);
2218 accountactive->resetFasttime();
2219 campaignchoicenum=1;
2220 campaignchoicewhich[0]=0;
2224 campaignchoicenum=campaignnumnext[levelorder[whichlevelstart]];
2225 for(i=0;i<campaignchoicenum;i++){
2226 campaignchoicewhich[i]=campaignnextlevel[levelorder[whichlevelstart]][i];
2227 levelvisible[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
2228 levelhighlight[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
2237 texdetail=temptexdetail;
2239 oldmainmenu=mainmenu;
2241 if(mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==8||mainmenu==9||mainmenu==10||mainmenu==119||mainmenu==18){
2242 glClear(GL_DEPTH_BUFFER_BIT);
2243 glEnable(GL_ALPHA_TEST);
2244 glAlphaFunc(GL_GREATER, 0.001f);
2245 glEnable(GL_TEXTURE_2D);
2246 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
2247 glDisable(GL_CULL_FACE);
2248 glDisable(GL_LIGHTING);
2250 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2251 glPushMatrix(); // Store The Projection Matrix
2252 glLoadIdentity(); // Reset The Projection Matrix
2253 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
2254 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2255 glPushMatrix(); // Store The Modelview Matrix
2256 glLoadIdentity(); // Reset The Modelview Matrix
2257 glTranslatef(screenwidth/2,screenheight/2,0);
2259 glScalef((float)screenwidth/2,(float)screenheight/2,1);
2260 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
2261 glDisable(GL_BLEND);
2262 glColor4f(0,0,0,1.0);
2263 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2264 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2265 glDisable(GL_TEXTURE_2D);
2267 //glScalef(.25,.25,.25);
2270 glVertex3f(-1, -1, 0.0f);
2272 glVertex3f(1, -1, 0.0f);
2274 glVertex3f(1, 1, 0.0f);
2276 glVertex3f(-1, 1, 0.0f);
2280 glColor4f(0.4,0.4,0.4,1.0);
2281 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2282 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2283 glEnable(GL_TEXTURE_2D);
2284 glBindTexture( GL_TEXTURE_2D, Mainmenuitems[4]);
2286 //glScalef(.25,.25,.25);
2289 glVertex3f(-1, -1, 0.0f);
2291 glVertex3f(1, -1, 0.0f);
2293 glVertex3f(1, 1, 0.0f);
2295 glVertex3f(-1, 1, 0.0f);
2300 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2302 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2306 if((float)newscreenwidth>(float)newscreenheight*1.61||(float)newscreenwidth<(float)newscreenheight*1.59)sprintf (menustring[0], "Resolution: %d*%d",(int)newscreenwidth,(int)newscreenheight);
2307 else sprintf (menustring[0], "Resolution: %d*%d (widescreen)",(int)newscreenwidth,(int)newscreenheight);
2310 endx[0]=startx[0]+strlen(menustring[0])*10;
2311 endy[0]=starty[0]+20;
2315 if(newdetail==2)sprintf (menustring[1], "Detail: High");
2316 else if(newdetail==1)sprintf (menustring[1], "Detail: Medium");
2317 else sprintf (menustring[1], "Detail: Low");
2320 endx[1]=startx[1]+strlen(menustring[1])*10;
2321 endy[1]=starty[1]+20;
2325 if(bloodtoggle==2)sprintf (menustring[2], "Blood: On, high detail (slower)");
2326 if(bloodtoggle==1)sprintf (menustring[2], "Blood: On, low detail");
2327 if(bloodtoggle==0)sprintf (menustring[2], "Blood: Off");
2330 endx[2]=startx[2]+strlen(menustring[2])*10;
2331 endy[2]=starty[2]+20;
2335 if(difficulty==2)sprintf (menustring[3], "Difficulty: Insane");
2336 if(difficulty==1)sprintf (menustring[3], "Difficulty: Difficult");
2337 if(difficulty==0)sprintf (menustring[3], "Difficulty: Easier");
2338 startx[3]=10+20-1000;
2340 endx[3]=startx[3]+strlen(menustring[3])*10;
2341 endy[3]=starty[3]+20;
2345 if(ismotionblur==1)sprintf (menustring[4], "Blur Effects: Enabled (less compatible)");
2346 if(ismotionblur==0)sprintf (menustring[4], "Blur Effects: Disabled (more compatible)");
2349 endx[4]=startx[4]+strlen(menustring[4])*10;
2350 endy[4]=starty[4]+20;
2354 if(decals==1)sprintf (menustring[5], "Decals: Enabled (slower)");
2355 if(decals==0)sprintf (menustring[5], "Decals: Disabled");
2358 endx[5]=startx[5]+strlen(menustring[5])*10;
2359 endy[5]=starty[5]+20;
2363 if(musictoggle==1)sprintf (menustring[6], "Music: Enabled");
2364 if(musictoggle==0)sprintf (menustring[6], "Music: Disabled");
2367 endx[6]=startx[6]+strlen(menustring[6])*10;
2368 endy[6]=starty[6]+20;
2372 if(invertmouse==1)sprintf (menustring[9], "Invert mouse: Yes");
2373 if(invertmouse==0)sprintf (menustring[9], "Invert mouse: No");
2376 endx[9]=startx[9]+strlen(menustring[9])*10;
2377 endy[9]=starty[9]+20;
2381 sprintf (menustring[10], "Mouse Speed: %d", (int)(usermousesensitivity*5));
2384 endx[10]=startx[10]+strlen(menustring[10])*10;
2385 endy[10]=starty[10]+20;
2389 sprintf (menustring[11], "Volume: %d%%", (int)(volume*100));
2392 endx[11]=startx[11]+strlen(menustring[11])*10;
2393 endy[11]=starty[11]+20;
2397 sprintf (menustring[13], "Damage Bar: %s",(showdamagebar?"on":"off"));
2400 endx[13]=startx[13]+strlen(menustring[13])*10;
2401 endy[13]=starty[13]+20;
2405 sprintf (menustring[7], "-Configure Controls-");
2408 endx[7]=startx[7]+strlen(menustring[7])*10;
2409 endy[7]=starty[7]+20;
2413 sprintf (menustring[12], "-Configure Stereo -");
2416 endx[12]=startx[12]+strlen(menustring[7])*10;
2417 endy[12]=starty[12]+20;
2421 if(newdetail==detail&&newscreenheight==(int)screenheight&&newscreenwidth==(int)screenwidth)sprintf (menustring[8], "Back");
2422 else sprintf (menustring[8], "Back (some changes take effect next time Lugaru is opened)");
2424 endx[8]=startx[8]+strlen(menustring[8])*10;
2426 endy[8]=starty[8]+20;
2433 if(keyselect!=0)sprintf (menustring[0], "Forwards: %s",Input::keyToChar(forwardkey));
2434 else sprintf (menustring[0], "Forwards: _");
2437 endx[0]=startx[0]+strlen(menustring[0])*10;
2438 endy[0]=starty[0]+20;
2442 if(keyselect!=1)sprintf (menustring[1], "Back: %s",Input::keyToChar(backkey));
2443 else sprintf (menustring[1], "Back: _");
2446 endx[1]=startx[1]+strlen(menustring[1])*10;
2447 endy[1]=starty[1]+20;
2451 if(keyselect!=2)sprintf (menustring[2], "Left: %s",Input::keyToChar(leftkey));
2452 else sprintf (menustring[2], "Left: _");
2455 endx[2]=startx[2]+strlen(menustring[2])*10;
2456 endy[2]=starty[2]+20;
2460 if(keyselect!=3)sprintf (menustring[3], "Right: %s",Input::keyToChar(rightkey));
2461 else sprintf (menustring[3], "Right: _");
2464 endx[3]=startx[3]+strlen(menustring[3])*10;
2465 endy[3]=starty[3]+20;
2469 if(keyselect!=4)sprintf (menustring[4], "Crouch: %s",Input::keyToChar(crouchkey));
2470 else sprintf (menustring[4], "Crouch: _");
2473 endx[4]=startx[4]+strlen(menustring[4])*10;
2474 endy[4]=starty[4]+20;
2478 if(keyselect!=5)sprintf (menustring[5], "Jump: %s",Input::keyToChar(jumpkey));
2479 else sprintf (menustring[5], "Jump: _");
2482 endx[5]=startx[5]+strlen(menustring[5])*10;
2483 endy[5]=starty[5]+20;
2487 if(keyselect!=6)sprintf (menustring[6], "Draw: %s",Input::keyToChar(drawkey));
2488 else sprintf (menustring[6], "Draw: _");
2491 endx[6]=startx[6]+strlen(menustring[6])*10;
2492 endy[6]=starty[6]+20;
2496 if(keyselect!=7)sprintf (menustring[7], "Throw: %s",Input::keyToChar(throwkey));
2497 else sprintf (menustring[7], "Throw: _");
2500 endx[7]=startx[7]+strlen(menustring[7])*10;
2501 endy[7]=starty[7]+20;
2505 if(keyselect!=8)sprintf (menustring[8], "Attack: %s",Input::keyToChar(attackkey));
2506 else sprintf (menustring[8], "Attack: _");
2509 endx[8]=startx[8]+strlen(menustring[8])*10;
2510 endy[8]=starty[8]+20;
2516 sprintf (menustring[9], "Back");
2518 endx[9]=startx[9]+strlen(menustring[9])*10;
2520 endy[9]=starty[9]+20;
2525 nummenuitems=7+accountactive->getCampaignChoicesMade()+campaignchoicenum;
2527 sprintf (menustring[0], "%s",accountactive->getName());
2530 endx[0]=startx[0]+strlen(menustring[0])*10;
2531 endy[0]=starty[0]+20;
2535 sprintf (menustring[1], "Tutorial");
2538 endx[1]=startx[1]+strlen(menustring[1])*10;
2539 endy[1]=starty[1]+20;
2543 sprintf (menustring[2], "Challenge");
2546 endx[2]=startx[2]+strlen(menustring[2])*10;
2547 endy[2]=starty[2]+20;
2551 sprintf (menustring[3], "Delete User");
2554 endx[3]=startx[3]+strlen(menustring[3])*10;
2555 endy[3]=starty[3]+20;
2559 sprintf (menustring[4], "Main Menu");
2562 endx[4]=startx[4]+strlen(menustring[4])*10;
2563 endy[4]=starty[4]+20;
2567 sprintf (menustring[5], "Change User");
2569 endx[5]=startx[5]+strlen(menustring[5])*10;
2571 endy[5]=starty[5]+20;
2577 sprintf (menustring[6], "World");
2579 starty[6]=30+480-400-50;
2580 endx[6]=startx[6]+400;
2585 if(accountactive->getCampaignChoicesMade())
2586 for(i=0;i<accountactive->getCampaignChoicesMade();i++){
2587 sprintf (menustring[7+i], "%s", campaigndescription[levelorder[i]]);
2588 startx[7+i]=30+120+campaignlocationx[levelorder[i]]*400/512;
2589 starty[7+i]=30+30+(512-campaignlocationy[levelorder[i]])*400/512;
2590 endx[7+i]=startx[7+i]+10;
2591 endy[7+i]=starty[7+i]+10;
2596 if(campaignchoicenum>0)
2597 for(i=accountactive->getCampaignChoicesMade();i<accountactive->getCampaignChoicesMade()+campaignchoicenum;i++){
2598 sprintf (menustring[7+i], "%s", campaigndescription[levelorder[i]]);
2599 startx[7+i]=30+120+campaignlocationx[campaignchoicewhich[i-(accountactive->getCampaignChoicesMade())]]*400/512;
2600 starty[7+i]=30+30+(512-campaignlocationy[campaignchoicewhich[i-(accountactive->getCampaignChoicesMade())]])*400/512;
2601 endx[7+i]=startx[7+i]+10;
2602 endy[7+i]=starty[7+i]+10;
2607 /*sprintf (menustring[7], "Dot");
2608 startx[7]=120+260*400/512;
2609 starty[7]=30+(512-184)*400/512;
2610 endx[7]=startx[7]+10;
2611 endy[7]=starty[7]+10;
2615 sprintf (menustring[8], "Dot");
2616 startx[8]=120+129*400/512;
2617 starty[8]=30+(512-284)*400/512;
2618 endx[8]=startx[8]+10;
2619 endy[8]=starty[8]+10;
2623 sprintf (menustring[9], "Dot");
2624 startx[9]=120+358*400/512;
2625 starty[9]=30+(512-235)*400/512;
2626 endx[9]=startx[9]+10;
2627 endy[9]=starty[9]+10;
2631 sprintf (menustring[10], "Dot");
2632 startx[10]=120+359*400/512;
2633 starty[10]=30+(512-308)*400/512;
2634 endx[10]=startx[10]+10;
2635 endy[10]=starty[10]+10;
2639 sprintf (menustring[11], "Dot");
2640 startx[11]=120+288*400/512;
2641 starty[11]=30+(512-277)*400/512;
2642 endx[11]=startx[11]+10;
2643 endy[11]=starty[11]+10;
2651 sprintf (menustring[0], "Are you sure you want to delete this user?");
2654 endx[0]=startx[0]+strlen(menustring[0])*10;
2655 endy[0]=starty[0]+20;
2659 sprintf (menustring[1], "Yes");
2662 endx[1]=startx[1]+strlen(menustring[1])*10;
2663 endy[1]=starty[1]+20;
2667 sprintf (menustring[2], "No");
2670 endx[2]=startx[2]+strlen(menustring[2])*10;
2671 endy[2]=starty[2]+20;
2675 sprintf (menustring[3], "Extra 4");
2678 endx[3]=startx[3]+strlen(menustring[3])*10;
2679 endy[3]=starty[3]+20;
2683 sprintf (menustring[4], "Extra 5");
2686 endx[4]=startx[4]+strlen(menustring[4])*10;
2687 endy[4]=starty[4]+20;
2691 sprintf (menustring[5], "Back");
2693 endx[5]=startx[5]+strlen(menustring[5])*10;
2695 endy[5]=starty[5]+20;
2701 nummenuitems=Account::getNbAccounts()+2;
2705 if(Account::getNbAccounts()<8)
2706 sprintf (menustring[0], "New User");
2708 sprintf (menustring[0], "No More Users");
2711 endx[0]=startx[0]+strlen(menustring[0])*10;
2712 endy[0]=starty[0]+20;
2721 for(i=0;i<Account::getNbAccounts();i++){
2722 sprintf (menustring[num], "%s",Account::get(i)->getName());
2724 starty[num]=360-20-20*num;
2725 endx[num]=startx[num]+strlen(menustring[num])*10;
2726 endy[num]=starty[num]+20;
2733 sprintf (menustring[num], "Back");
2735 endx[num]=startx[num]+strlen(menustring[num])*10;
2737 endy[num]=starty[num]+20;
2744 sprintf (menustring[0], "Easier");
2747 endx[0]=startx[0]+strlen(menustring[0])*10;
2748 endy[0]=starty[0]+20;
2752 sprintf (menustring[1], "Difficult");
2755 endx[1]=startx[1]+strlen(menustring[1])*10;
2756 endy[1]=starty[1]+20;
2760 sprintf (menustring[2], "Insane");
2763 endx[2]=startx[2]+strlen(menustring[2])*10;
2764 endy[2]=starty[2]+20;
2770 //tempncl=numchallengelevels;
2771 //numchallengelevels=9;
2772 nummenuitems=2+numchallengelevels;
2775 for(j=0;j<numchallengelevels;j++){
2776 for(i=0;i<255;i++)menustring[j][i]='\0';
2777 sprintf (temp, "Level %d",j+1);
2778 strcpy(menustring[j],temp);
2779 for(i=0;i<17;i++)if(menustring[j][i]=='\0')menustring[j][i]=' ';
2780 menustring[j][17]='\0';
2781 sprintf (temp, "%d",(int)accountactive->getHighScore(j));
2782 strcat(menustring[j],temp);
2783 for(i=18;i<32;i++)if(menustring[j][i]=='\0')menustring[j][i]=' ';
2784 menustring[j][32]='\0';
2785 sprintf (temp, "%d:",(int)(((int)accountactive->getFastTime(j)-(int)(accountactive->getFastTime(j))%60)/60));
2786 strcat(menustring[j],temp);
2787 if((int)(accountactive->getFastTime(j))%60<10)strcat(menustring[j],"0");
2788 sprintf (temp, "%d",(int)(accountactive->getFastTime(j))%60);
2789 strcat(menustring[j],temp);
2793 endx[j]=startx[j]+strlen(menustring[j])*10;
2794 endy[j]=starty[j]+20;
2799 sprintf (menustring[numchallengelevels], "Back");
2800 startx[numchallengelevels]=10;
2801 endx[numchallengelevels]=startx[numchallengelevels]+strlen(menustring[numchallengelevels])*10;
2802 starty[numchallengelevels]=10;
2803 endy[numchallengelevels]=starty[numchallengelevels]+20;
2804 movex[numchallengelevels]=0;
2805 movey[numchallengelevels]=0;
2807 sprintf (menustring[numchallengelevels+1], " High Score Best Time");
2808 startx[numchallengelevels+1]=10;
2809 starty[numchallengelevels+1]=440;
2810 endx[numchallengelevels+1]=startx[numchallengelevels+1]+strlen(menustring[numchallengelevels+1])*10;
2811 endy[numchallengelevels+1]=starty[numchallengelevels+1]+20;
2812 movex[numchallengelevels+1]=0;
2813 movey[numchallengelevels+1]=0;
2815 //numchallengelevels=tempncl;
2822 sprintf (menustring[0], "Congratulations!");
2825 endx[0]=startx[0]+strlen(menustring[0])*10;
2826 endy[0]=starty[0]+20;
2830 sprintf (menustring[1], "You have avenged your family and");
2833 endx[1]=startx[1]+strlen(menustring[1])*10;
2834 endy[1]=starty[1]+20;
2838 sprintf (menustring[2], "restored peace to the island of Lugaru.");
2841 endx[2]=startx[2]+strlen(menustring[2])*10;
2842 endy[2]=starty[2]+20;
2846 sprintf (menustring[3], "Back");
2848 endx[3]=startx[3]+strlen(menustring[3])*10;
2850 endy[3]=starty[3]+20;
2854 for(i=0;i<255;i++)menustring[4][i]='\0';
2855 sprintf (temp, "Your score:");
2856 strcpy(menustring[4],temp);
2857 for(i=0;i<20;i++)if(menustring[4][i]=='\0')menustring[4][i]=' ';
2858 menustring[4][20]='\0';
2859 sprintf (temp, "%d",(int)accountactive->getCampaignScore());
2860 strcat(menustring[4],temp);
2862 endx[4]=startx[4]+strlen(menustring[4])*10;
2864 endy[4]=starty[4]+20;
2868 for(i=0;i<255;i++)menustring[5][i]='\0';
2869 sprintf (temp, "Your time:");
2870 strcpy(menustring[5],temp);
2871 for(i=0;i<20;i++)if(menustring[5][i]=='\0')menustring[5][i]=' ';
2872 menustring[5][20]='\0';
2873 sprintf (temp, "%d",(int)accountcampaigntime[accountactive]);
2874 strcat(menustring[5],temp);
2876 endx[5]=startx[5]+strlen(menustring[5])*10;
2878 endy[5]=starty[5]+20;
2882 for(i=0;i<255;i++)menustring[5][i]='\0';
2883 sprintf (temp, "Highest score:");
2884 strcpy(menustring[5],temp);
2885 for(i=0;i<20;i++)if(menustring[5][i]=='\0')menustring[5][i]=' ';
2886 menustring[5][20]='\0';
2887 sprintf (temp, "%d",(int)accountactive->getCampaignHighScore());
2888 strcat(menustring[5],temp);
2890 endx[5]=startx[5]+strlen(menustring[5])*10;
2892 endy[5]=starty[5]+20;
2896 for(i=0;i<255;i++)menustring[7][i]='\0';
2897 sprintf (temp, "Lowest time:");
2898 strcpy(menustring[7],temp);
2899 for(i=0;i<20;i++)if(menustring[7][i]=='\0')menustring[7][i]=' ';
2900 menustring[7][20]='\0';
2901 sprintf (temp, "%d",(int)accountactive->getCampaignFasttime());
2902 strcat(menustring[7],temp);
2904 endx[7]=startx[7]+strlen(menustring[7])*10;
2906 endy[7]=starty[7]+20;
2912 sprintf (menustring[0], "Stereo mode: %s", StereoModeName(newstereomode));
2915 endx[0]=startx[0]+strlen(menustring[0])*10;
2916 endy[0]=starty[0]+20;
2920 sprintf (menustring[1], "Stereo separation: %.3f", stereoseparation);
2923 endx[1]=startx[1]+strlen(menustring[1])*10;
2924 endy[1]=starty[1]+20;
2928 sprintf (menustring[2], "Reverse stereo: %s", stereoreverse ? "Yes" : "No");
2931 endx[2]=startx[2]+strlen(menustring[2])*10;
2932 endy[2]=starty[2]+20;
2936 sprintf (menustring[3], "Back");
2938 endx[3]=startx[3]+strlen(menustring[3])*10;
2940 endy[3]=starty[3]+20;
2946 if(mainmenu==1||mainmenu==2){
2956 starty[1]=480-152-32;
2963 starty[2]=480-228-32;
2971 starty[3]=480-306-32;
2980 starty[3]=480-306-32;
2994 starty[4]=480-140-256;
3001 starty[5]=480-138-256;
3008 starty[6]=480-144-256;
3016 starty[4]=480-140-256;
3023 starty[5]=480-138-256;
3030 starty[6]=480-144-256;
3038 starty[4]=480-140-256;
3045 starty[5]=480-150-256;
3052 starty[6]=480-144-256;
3060 starty[4]=480-140-256;
3067 starty[5]=480-150-256;
3074 starty[6]=480-144-256;
3082 starty[4]=480-100-256;
3089 starty[5]=480-120-256;
3096 starty[6]=480-144-256;
3106 if(mainmenu==1||mainmenu==2)
3108 if((mousecoordh/screenwidth*640)>startx[i]&&(mousecoordh/screenwidth*640)<endx[i]&&480-(mousecoordv/screenheight*480)>starty[i]&&480-(mousecoordv/screenheight*480)<endy[i]){
3113 if(mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==8||mainmenu==9||mainmenu==10||mainmenu==18)
3114 for(i=0;i<nummenuitems;i++){
3115 if((mousecoordh/screenwidth*640)>startx[i]&&(mousecoordh/screenwidth*640)<endx[i]&&480-(mousecoordv/screenheight*480)>starty[i]&&480-(mousecoordv/screenheight*480)<endy[i]){
3116 if(mainmenu!=5)selected=i;
3117 if(mainmenu==5&&(i!=0&&i!=6))selected=i;
3118 if(mainmenu==9&&(i!=numchallengelevels+1))selected=i; // seem useless, if mainmenu==9 then mainmenu!=5, so selected==i.
3122 for(i=0;i<nummenuitems;i++){
3124 selectedlong[i]+=multiplier*5;
3125 if(selectedlong[i]>1) selectedlong[i]=1;
3127 selectedlong[i]-=multiplier*5;
3128 if(selectedlong[i]<0) selectedlong[i]=0;
3130 offsetx[i]=(startx[i]+endx[i])/2-(mousecoordh/screenwidth*640);
3131 offsety[i]=(starty[i]+endy[i])/2-(480-(mousecoordv/screenheight*480));
3136 if(i>=4&&(mainmenu==1||mainmenu==2)){
3138 offsetx[i]=(startx[i]+endx[i]+movex[i]*transition)/2-(640+190)/2;
3139 offsety[i]=(starty[i]+endy[i]+movey[i]*transition)/2-(336+150)/2;
3145 if(mainmenu==1||mainmenu==2){
3146 glClear(GL_DEPTH_BUFFER_BIT);
3147 glEnable(GL_ALPHA_TEST);
3148 glAlphaFunc(GL_GREATER, 0.001f);
3149 glEnable(GL_TEXTURE_2D);
3150 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3151 glDisable(GL_CULL_FACE);
3152 glDisable(GL_LIGHTING);
3154 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3155 glPushMatrix(); // Store The Projection Matrix
3156 glLoadIdentity(); // Reset The Projection Matrix
3157 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
3158 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3159 glPushMatrix(); // Store The Modelview Matrix
3160 glLoadIdentity(); // Reset The Modelview Matrix
3161 glTranslatef(screenwidth/2,screenheight/2,0);
3163 glScalef((float)screenwidth/2,(float)screenheight/2,1);
3164 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3165 glDisable(GL_BLEND);
3166 glColor4f(0,0,0,1.0);
3167 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
3168 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
3169 glDisable(GL_TEXTURE_2D);
3171 //glScalef(.25,.25,.25);
3174 glVertex3f(-1, -1, 0.0f);
3176 glVertex3f(1, -1, 0.0f);
3178 glVertex3f(1, 1, 0.0f);
3180 glVertex3f(-1, 1, 0.0f);
3184 glColor4f(0.4,0.4,0.4,1.0);
3185 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
3186 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
3187 glEnable(GL_TEXTURE_2D);
3188 glBindTexture( GL_TEXTURE_2D, Mainmenuitems[4]);
3190 //glScalef(.25,.25,.25);
3193 glVertex3f(-1, -1, 0.0f);
3195 glVertex3f(1, -1, 0.0f);
3197 glVertex3f(1, 1, 0.0f);
3199 glVertex3f(-1, 1, 0.0f);
3204 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3207 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3208 glPushMatrix(); // Store The Projection Matrix
3209 glLoadIdentity(); // Reset The Projection Matrix
3210 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3211 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3212 glPushMatrix(); // Store The Modelview Matrix
3213 glLoadIdentity(); // Reset The Modelview Matrix
3215 glDisable(GL_TEXTURE_2D);
3219 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3221 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3225 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3226 glPushMatrix(); // Store The Projection Matrix
3227 glLoadIdentity(); // Reset The Projection Matrix
3228 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3229 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3230 glPushMatrix(); // Store The Modelview Matrix
3231 glLoadIdentity(); // Reset The Modelview Matrix
3232 glEnable(GL_TEXTURE_2D);
3233 for(j=0;j<nummenuitems;j++)
3235 if(j<=3||(mainmenu!=1&&mainmenu!=2))
3237 //glDisable(GL_BLEND);
3238 glEnable(GL_ALPHA_TEST);
3240 //glDisable(GL_ALPHA_TEST);
3241 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3242 if(mainmenu==1||mainmenu==2)
3245 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3246 glBindTexture( GL_TEXTURE_2D, Mainmenuitems[j]);
3247 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
3248 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
3249 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3253 glVertex3f(startx[j]+movex[j]*transition, starty[j]+movey[j]*transition, 0.0f);
3255 glVertex3f(endx[j]+movex[j]*transition, starty[j]+movey[j]*transition, 0.0f);
3257 glVertex3f(endx[j]+movex[j]*transition, endy[j]+movey[j]*transition, 0.0f);
3259 glVertex3f(startx[j]+movex[j]*transition, endy[j]+movey[j]*transition, 0.0f);
3263 //glDisable(GL_ALPHA_TEST);
3264 if(j<4)glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3267 if(1-((float)i)/10-(1-selectedlong[j])>0)
3269 glColor4f(1,1,1,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3270 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3274 glVertex3f(startx[j]-((float)i)*1/2+offsetx[j]*((float)i)/2+movex[j]*transition, starty[j]-((float)i)*1/2+offsety[j]*((float)i)/2+movey[j]*transition, 0.0f);
3276 glVertex3f(endx[j]+((float)i)*1/2+offsetx[j]*((float)i)/2+movex[j]*transition, starty[j]-((float)i)*1/2+offsety[j]*((float)i)/2+movey[j]*transition, 0.0f);
3278 glVertex3f(endx[j]+((float)i)*1/2+offsetx[j]*((float)i)/2+movex[j]*transition, endy[j]+((float)i)*1/2+offsety[j]*((float)i)/2+movey[j]*transition, 0.0f);
3280 glVertex3f(startx[j]-((float)i)*1/2+offsetx[j]*((float)i)/2+movex[j]*transition, endy[j]+((float)i)*1/2+offsety[j]*((float)i)/2+movey[j]*transition, 0.0f);
3286 if(mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==8||mainmenu==9||mainmenu==10||mainmenu==18)
3288 if(mainmenu!=5||j<6)
3291 if(mainmenu==9&&j>accountactive->getProgress()&&j<numchallengelevels)glColor4f(0.5,0,0,1);
3292 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3294 if(mainmenu!=7||j!=0||!entername)
3295 text.glPrint(startx[j],starty[j],menustring[j],0,1,640,480);
3299 sprintf (string, "_");
3300 text.glPrint(startx[j]+(float)(displayselected)*10,starty[j],string,0,1,640,480);
3302 for(l=0;l<displaychars[0];l++){
3303 sprintf (string, "%c",displaytext[0][l]);
3304 text.glPrint(startx[j]+l*10,starty[j],string,0,1,640,480);
3309 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3312 if(1-((float)i)/15-(1-selectedlong[j])>0)
3314 glColor4f(1,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3315 if(mainmenu==9&&j>accountactive->getProgress()&&j<numchallengelevels)glColor4f(0.5,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3316 if(mainmenu==11&&j>accountactive->getProgress()&&j<numchallengelevels)glColor4f(0.5,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3317 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);
3318 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);
3319 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);
3320 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);
3321 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);
3322 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);
3323 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);
3324 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);
3325 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);
3331 glClear(GL_DEPTH_BUFFER_BIT);
3332 glEnable(GL_ALPHA_TEST);
3333 glAlphaFunc(GL_GREATER, 0.001f);
3334 glEnable(GL_TEXTURE_2D);
3335 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3336 glDisable(GL_CULL_FACE);
3337 glDisable(GL_LIGHTING);
3338 if(j==6)glColor4f(1,1,1,1);
3339 else glColor4f(1,0,0,1);
3341 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3342 glPushMatrix(); // Store The Projection Matrix
3343 glLoadIdentity(); // Reset The Projection Matrix
3344 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3345 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3346 glPushMatrix(); // Store The Modelview Matrix
3347 glLoadIdentity(); // Reset The Modelview Matrix
3350 //Draw world, draw map
3351 glTranslatef(2,-5,0);
3353 if(j>6&&j<nummenuitems-1)
3355 XYZ linestart,lineend,offset;
3362 //float linestartx,lineendx,linestarty,lineendy,offsetx,offsety;
3363 linestart.x=(startx[j]+endx[j])/2;
3364 linestart.y=(starty[j]+endy[j])/2;
3365 if(j>=6+accountactive->getCampaignChoicesMade()){
3366 linestart.x=(startx[6+accountactive->getCampaignChoicesMade()]+endx[6+accountactive->getCampaignChoicesMade()])/2;
3367 linestart.y=(starty[6+accountactive->getCampaignChoicesMade()]+endy[6+accountactive->getCampaignChoicesMade()])/2;
3369 lineend.x=(startx[j+1]+endx[j+1])/2;
3370 lineend.y=(starty[j+1]+endy[j+1])/2;
3371 offset=lineend-linestart;
3374 offset=DoRotation(offset,0,0,90);
3376 glDisable(GL_TEXTURE_2D);
3378 if(j<6+accountactive->getCampaignChoicesMade()){
3379 glColor4f(0.5,0,0,1);
3387 linestart+=fac*4*startsize;
3388 lineend-=fac*4*endsize;
3390 if(!(j>7+accountactive->getCampaignChoicesMade()+campaignchoicenum)){
3391 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3395 glVertex3f(linestart.x-offset.x*startsize, linestart.y-offset.y*startsize, 0.0f);
3397 glVertex3f(linestart.x+offset.x*startsize, linestart.y+offset.y*startsize, 0.0f);
3399 glVertex3f(lineend.x+offset.x*endsize, lineend.y+offset.y*endsize, 0.0f);
3401 glVertex3f(lineend.x-offset.x*endsize, lineend.y-offset.y*endsize, 0.0f);
3405 glEnable(GL_TEXTURE_2D);
3409 if(j==6)glBindTexture( GL_TEXTURE_2D, Mainmenuitems[7]);
3410 else glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
3411 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
3412 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
3413 if(j-7<accountactive->getCampaignChoicesMade())glColor4f(0.5,0,0,1);
3414 if(j-7>=accountactive->getCampaignChoicesMade())glColor4f(1,0,0,1);
3415 if(j==6)glColor4f(1,1,1,1);
3418 itemsize=abs(startx[j]-endx[j])/2;
3420 midpoint.x=(startx[j]+endx[j])/2;
3421 midpoint.y=(starty[j]+endy[j])/2;
3422 if(j>6&&(j-7<accountactive->getCampaignChoicesMade()))itemsize*=.5;
3423 if(!(j-7>accountactive->getCampaignChoicesMade()+campaignchoicenum))
3425 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3429 glVertex3f(midpoint.x-itemsize+movex[j]*transition, midpoint.y-itemsize+movey[j]*transition, 0.0f);
3431 glVertex3f(midpoint.x+itemsize+movex[j]*transition, midpoint.y-itemsize+movey[j]*transition, 0.0f);
3433 glVertex3f(midpoint.x+itemsize+movex[j]*transition, midpoint.y+itemsize+movey[j]*transition, 0.0f);
3435 glVertex3f(midpoint.x-itemsize+movex[j]*transition, midpoint.y+itemsize+movey[j]*transition, 0.0f);
3439 //glDisable(GL_ALPHA_TEST);
3440 if(j<4)glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3443 if(1-((float)i)/10-(1-selectedlong[j])>0)
3445 glColor4f(1,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3446 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3450 glVertex3f(midpoint.x-itemsize-((float)i)*1/2+offsetx[j]*((float)i)/2+movex[j]*transition, midpoint.y-itemsize-((float)i)*1/2+offsety[j]*((float)i)/2+movey[j]*transition, 0.0f);
3452 glVertex3f(midpoint.x+itemsize+((float)i)*1/2+offsetx[j]*((float)i)/2+movex[j]*transition, midpoint.y-itemsize-((float)i)*1/2+offsety[j]*((float)i)/2+movey[j]*transition, 0.0f);
3454 glVertex3f(midpoint.x+itemsize+((float)i)*1/2+offsetx[j]*((float)i)/2+movex[j]*transition, midpoint.y+itemsize+((float)i)*1/2+offsety[j]*((float)i)/2+movey[j]*transition, 0.0f);
3456 glVertex3f(midpoint.x-itemsize-((float)i)*1/2+offsetx[j]*((float)i)/2+movex[j]*transition, midpoint.y+itemsize+((float)i)*1/2+offsety[j]*((float)i)/2+movey[j]*transition, 0.0f);
3464 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3466 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3468 if(j-7>=accountactive->getCampaignChoicesMade()){
3469 text.glPrintOutlined(0.9,0,0,startx[j]+10,starty[j]-4,menustring[j],0,0.6,640,480);
3470 glDisable(GL_DEPTH_TEST);
3476 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3478 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3481 if(mainmenu==1||mainmenu==2)
3482 if(transition<.1||transition>.9){
3483 glClear(GL_DEPTH_BUFFER_BIT);
3484 glEnable(GL_ALPHA_TEST);
3485 glAlphaFunc(GL_GREATER, 0.001f);
3486 glEnable(GL_TEXTURE_2D);
3487 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3488 glDisable(GL_CULL_FACE);
3489 glDisable(GL_LIGHTING);
3491 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3492 glPushMatrix(); // Store The Projection Matrix
3493 glLoadIdentity(); // Reset The Projection Matrix
3494 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3495 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3496 glPushMatrix(); // Store The Modelview Matrix
3497 glLoadIdentity(); // Reset The Modelview Matrix
3499 glDisable(GL_TEXTURE_2D);
3501 glColor4f(1,0,0,1-(transition*10));
3503 glColor4f(1,0,0,1-((1-transition)*10));
3506 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3510 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3511 glPushMatrix(); // Store The Projection Matrix
3512 glLoadIdentity(); // Reset The Projection Matrix
3513 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
3514 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3515 glPushMatrix(); // Store The Modelview Matrix
3516 glLoadIdentity(); // Reset The Modelview Matrix
3517 glTranslatef(screenwidth/2,screenheight/2,0);
3519 glScalef((float)screenwidth/2,(float)screenheight/2,1);
3520 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3522 glEnable(GL_TEXTURE_2D);
3524 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
3525 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
3527 if(!waiting) { // hide the cursor while waiting for a key
3529 glTranslatef(mousecoordh-screenwidth/2,mousecoordv*-1+screenheight/2,0);
3530 glScalef((float)screenwidth/64,(float)screenwidth/64,1);
3531 glTranslatef(1,-1,0);
3532 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3534 glBindTexture( GL_TEXTURE_2D, cursortexture);
3536 //glScalef(.25,.25,.25);
3539 glVertex3f(-1, -1, 0.0f);
3541 glVertex3f(1, -1, 0.0f);
3543 glVertex3f(1, 1, 0.0f);
3545 glVertex3f(-1, 1, 0.0f);
3551 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3557 //printf("Flash amount: %f, delay %i\n", flashamount, flashdelay);
3558 if(flashamount>1)flashamount=1;
3559 if(flashdelay<=0)flashamount-=multiplier;
3561 if(flashamount<0)flashamount=0;
3562 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3563 glDisable(GL_CULL_FACE);
3564 glDisable(GL_LIGHTING);
3565 glDisable(GL_TEXTURE_2D);
3567 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3568 glPushMatrix(); // Store The Projection Matrix
3569 glLoadIdentity(); // Reset The Projection Matrix
3570 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
3571 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3572 glPushMatrix(); // Store The Modelview Matrix
3573 glLoadIdentity(); // Reset The Modelview Matrix
3574 glScalef(screenwidth,screenheight,1);
3575 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3577 glColor4f(flashr,flashg,flashb,flashamount);
3579 glVertex3f(0, 0, 0.0f);
3580 glVertex3f(256, 0, 0.0f);
3581 glVertex3f(256, 256, 0.0f);
3582 glVertex3f(0, 256, 0.0f);
3584 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3585 glPopMatrix(); // Restore The Old Projection Matrix
3586 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3587 glPopMatrix(); // Restore The Old Projection Matrix
3588 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
3589 glEnable(GL_CULL_FACE);
3590 glDisable(GL_BLEND);
3595 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)||(!gameon&&gamestarted)){
3596 tempmult=multiplier;
3601 if ( side == stereoRight || side == stereoCenter ) {
3602 if(drawmode!=motionblurmode||mainmenu){
3607 //myassert(glGetError() == GL_NO_ERROR);
3608 glDrawBuffer(GL_BACK);
3609 glReadBuffer(GL_BACK);
3614 if(drawtoggle==2)drawtoggle=0;
3616 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)){
3617 multiplier=tempmult;
3619 //Jordan fixed your warning!