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"
28 extern int environment;
29 extern float texscale;
31 extern Terrain terrain;
32 extern Sprites sprites;
33 extern float multiplier;
35 extern float viewdistance;
36 extern float fadestart;
37 extern float screenwidth,screenheight;
38 extern int kTextureSize;
39 extern FRUSTUM frustum;
41 extern Objects objects;
43 extern float usermousesensitivity;
45 extern float camerashake;
46 extern Weapons weapons;
47 extern Person player[maxplayers];
49 extern float slomodelay;
50 extern bool ismotionblur;
52 extern float blackout;
53 extern bool damageeffects;
55 extern int numplayers;
56 extern bool texttoggle;
57 extern float blurness;
58 extern float targetblurness;
59 extern float playerdist;
60 extern bool cellophane;
62 extern float flashamount,flashr,flashg,flashb;
63 extern int flashdelay;
65 extern float motionbluramount;
67 extern bool alwaysblur;
69 extern bool tilt2weird;
70 extern bool tiltweird;
72 extern bool proportionweird;
73 extern bool vertexweird[6];
74 extern bool velocityblur;
75 extern bool buttons[3];
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 OPENAL_SAMPLE *samp[100];
163 extern int channels[100];
164 extern "C" void PlaySoundEx(int channel, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
166 /*********************> DrawGLScene() <*****/
167 long long Game::MD5_string (char *string){
172 sprintf (temp, "%s",string);
175 while (i<256&&temp[i]!='\0'){
176 if(temp[i]%3==0)num+=temp[i]*124;
177 else if(temp[i]%3==1)num-=temp[i]*temp[i];
182 num=longlongabs(num);
185 while(num<LONGLONGCONST(5000000000000000)){
189 while(num>LONGLONGCONST(9900000000000000)){
195 //return 1111111111111111;
198 int Game::DrawGLScene(StereoSide side)
200 static float texcoordwidth,texcoordheight;
201 static float texviewwidth, texviewheight;
203 static GLubyte color;
204 static float newbrightness;
205 static float changespeed;
206 static XYZ checkpoint;
207 static float tempmult;
209 static char string[256]="";
210 static char string2[256]="";
211 static char string3[256]="";
213 static float lastcheck;
215 lastcheck+=multiplier;
217 if ( stereomode == stereoAnaglyph ) {
219 case stereoLeft: glColorMask( 0.0, 1.0, 1.0, 1.0 ); break;
220 case stereoRight: glColorMask( 1.0, 0.0, 0.0, 1.0 ); break;
223 glColorMask( 1.0, 1.0, 1.0, 1.0 );
225 if ( stereomode == stereoHorizontalInterlaced || stereomode == stereoVerticalInterlaced ) {
226 glStencilFunc(side == stereoLeft ? GL_NOTEQUAL : GL_EQUAL, 0x01, 0x01);
230 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)){
237 numboundaries=mapradius*2;
238 if(numboundaries>360)numboundaries=360;
239 for(i=0;i<numboundaries;i++){
242 boundary[i]=mapcenter+DoRotation(boundary[i]*mapradius,0,i*(360/((float)(numboundaries))),0);
251 olddrawmode=drawmode;
252 if(ismotionblur&&!loading){
253 if((findLengthfast(&player[0].velocity)>200)&&velocityblur&&!cameramode){
254 drawmode=motionblurmode;
255 motionbluramount=200/(findLengthfast(&player[0].velocity));
258 if(player[0].damage-player[0].superpermanentdamage>(player[0].damagetolerance-player[0].superpermanentdamage)*1/2&&damageeffects&&!cameramode){
259 drawmode=doublevisionmode;
266 drawmode=motionblurmode;
268 slomodelay-=multiplier;
269 if(slomodelay<0)slomo=0;
273 if((!changed&&!slomo)||loading){
275 if(ismotionblur&&(/*fps>100||*/alwaysblur)){
276 if(olddrawmode!=realmotionblurmode)change=1;
278 drawmode=realmotionblurmode;
280 else if(olddrawmode==realmotionblurmode)change=2;
284 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted))drawmode=normalmode;
285 if((freeze||winfreeze)&&ismotionblur&&!mainmenu)drawmode=radialzoommode;
287 if(winfreeze||mainmenu)drawmode=normalmode;
290 if(drawmode==glowmode){
296 DSpContext_FadeGamma(NULL,200,&color2);
300 if(drawtoggle!=2)drawtoggle=1-drawtoggle;
304 texviewwidth=kTextureSize;
305 if(texviewwidth>screenwidth)texviewwidth=screenwidth;
306 texviewheight=kTextureSize;
307 if(texviewheight>screenheight)texviewheight=screenheight;
309 texcoordwidth=screenwidth/kTextureSize;
310 texcoordheight=screenheight/kTextureSize;
311 if(texcoordwidth>1)texcoordwidth=1;
312 if(texcoordheight>1)texcoordheight=1;
315 glDrawBuffer(GL_BACK);
316 glReadBuffer(GL_BACK);
318 /*if(environment==desertenvironment)glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, (float)(abs(Random()%100))/50 );
319 else glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0);
321 if(abs(blurness-targetblurness)<multiplier*10||abs(blurness-targetblurness)>2){
322 blurness=targetblurness;
323 targetblurness=(float)(abs(Random()%100))/40;
325 if(blurness<targetblurness)blurness+=multiplier*5;
326 if(blurness>targetblurness)blurness-=multiplier*5;
329 static XYZ terrainlight;
330 static float distance;
331 //if(drawmode==normalmode)ReSizeGLScene(90,.1);
332 if(drawmode==normalmode)ReSizeGLScene(90,.1f);
333 if(drawmode!=normalmode)glViewport(0,0,texviewwidth,texviewheight);
334 glDepthFunc(GL_LEQUAL);
336 glAlphaFunc(GL_GREATER, 0.0001f);
337 glEnable(GL_ALPHA_TEST);
338 glClearColor(0.25f, 0.25f, 0.25f, 1.0f);
339 glClear(GL_DEPTH_BUFFER_BIT);
341 glMatrixMode (GL_MODELVIEW);
342 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
345 // Move the camera for the current eye's point of view.
346 // Reverse the movement if we're reversing stereo
347 glTranslatef((stereoseparation/2) * side * (stereoreverse ? -1 : 1), 0, 0);
349 if(!cameramode&&!freeze&&!winfreeze){
350 glRotatef(float(Random()%100)/10*camerashake/*+(woozy*woozy)/10*/,0,0,1);
351 glRotatef(rotation2+sin(woozy/2)*(player[0].damage/player[0].damagetolerance)*5,1,0,0);
352 glRotatef(rotation+sin(woozy)*(player[0].damage/player[0].damagetolerance)*5,0,1,0);
354 if(cameramode||freeze||winfreeze){
355 //glRotatef(float(Random()%100)/10*camerashake/*+(woozy*woozy)/10*/,0,0,1);
356 glRotatef(rotation2,1,0,0);
357 glRotatef(rotation,0,1,0);
360 if(environment==desertenvironment){
361 glRotatef((float)(abs(Random()%100))/3000-1,1,0,0);
362 glRotatef((float)(abs(Random()%100))/3000-1,0,1,0);
363 //glRotatef(blurness/40-1,1,0,0);
364 //glRotatef(blurness/40-1,0,1,0);
366 SetUpLight(&light,0);
368 if(environment==desertenvironment&&detail==2)glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, blurness+.4 );
369 if(environment==desertenvironment){
370 glRotatef((float)(abs(Random()%100))/1000,1,0,0);
371 glRotatef((float)(abs(Random()%100))/1000,0,1,0);
374 glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0);
376 glTranslatef(-viewer.x,-viewer.y,-viewer.z);
377 frustum.GetFrustum();
381 static float size,opacity,rotation;
383 for(k=0;k<numplayers;k++){
384 if(!player[k].skeleton.free&&player[k].playerdetail&&player[k].howactive<typesleeping)
385 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)
386 for(i=0;i<player[k].skeleton.num_joints;i++){
387 if(player[k].skeleton.joints[i].label==leftknee||player[k].skeleton.joints[i].label==rightknee||player[k].skeleton.joints[i].label==groin){
388 point=DoRotation(player[k].skeleton.joints[i].position,0,player[k].rotation,0)*player[k].scale+player[k].coords;
390 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;
391 if(k!=0&&tutoriallevel==1){
392 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;
394 terrain.MakeDecal(shadowdecal,point,size,opacity,rotation);
395 if(terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz])
396 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
397 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
398 if(objects.position[j].y<player[k].coords.y||objects.type[j]==tunneltype||objects.type[j]==weirdtype){
399 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);
402 if(k!=0&&tutoriallevel==1){
403 opacity=.2+.2*sin(smoketex*6+i);
405 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
410 if((player[k].skeleton.free||player[k].howactive>=typesleeping)&&player[k].playerdetail)
411 if(frustum.SphereInFrustum(player[k].coords.x,player[k].coords.y,player[k].coords.z,player[k].scale*5)&&player[k].occluded<25)
412 for(i=0;i<player[k].skeleton.num_joints;i++){
413 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){
414 if(player[k].skeleton.free)point=player[k].skeleton.joints[i].position*player[k].scale+player[k].coords;
415 else point=DoRotation(player[k].skeleton.joints[i].position,0,player[k].rotation,0)*player[k].scale+player[k].coords;
417 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;
418 if(k!=0&&tutoriallevel==1){
419 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;
421 terrain.MakeDecal(shadowdecal,point,size,opacity*.7,rotation);
422 if(terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz])
423 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
424 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
425 if(objects.position[j].y<player[k].coords.y||objects.type[j]==tunneltype||objects.type[j]==weirdtype){
426 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);
427 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);
430 if(k!=0&&tutoriallevel==1){
431 opacity=.2+.2*sin(smoketex*6+i);
433 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
439 if(!player[k].playerdetail)
440 if(frustum.SphereInFrustum(player[k].coords.x,player[k].coords.y,player[k].coords.z,player[k].scale*5))
442 point=player[k].coords;
444 opacity=.4-(player[k].coords.y-terrain.getHeight(player[k].coords.x,player[k].coords.z))/5;
445 terrain.MakeDecal(shadowdecal,point,size,opacity*.7,rotation);
446 if(terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz])
447 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
448 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
449 point=DoRotation(player[k].coords-objects.position[j],0,-objects.rotation[j],0);
452 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
458 glEnable(GL_TEXTURE_2D);
460 glEnable(GL_DEPTH_TEST);
461 glEnable(GL_CULL_FACE);
463 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
464 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
465 glBindTexture( GL_TEXTURE_2D, terraintexture);
467 glBindTexture( GL_TEXTURE_2D, terraintexture2);
469 //glBindTexture( GL_TEXTURE_2D, terraintexture3);
470 //glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
473 terrain.drawdecals();
476 glEnable(GL_CULL_FACE);
477 glEnable(GL_LIGHTING);
479 glEnable(GL_TEXTURE_2D);
482 glEnable(GL_COLOR_MATERIAL);
497 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
498 glEnable(GL_CULL_FACE);
499 glCullFace(GL_FRONT);
501 for(k=0;k<numplayers;k++){
502 if(k==0||tutoriallevel!=1){
504 glEnable(GL_LIGHTING);
505 terrainlight=terrain.getLighting(player[k].coords.x,player[k].coords.z);
506 distance=findDistancefast(&viewer,&player[k].coords);
507 distance=(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance;
508 glColor4f(terrainlight.x,terrainlight.y,terrainlight.z,distance);
509 if(distance>=1)glDisable(GL_BLEND);
511 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;
513 if(!player[k].occluded==0)i=checkcollide(viewer,checkpoint,player[k].lastoccluded);
514 if(i==-1||player[k].occluded==0)i=checkcollide(viewer,checkpoint);
516 player[k].occluded+=1;
517 player[k].lastoccluded=i;
519 else player[k].occluded=0;
520 if(player[k].occluded<25)player[k].DrawSkeleton();
526 if(!cameramode&&musictype==stream_music2)playerdist=findDistancefastflat(&player[0].coords,&viewer);
527 else playerdist=-100;
530 glEnable(GL_TEXTURE_2D);
535 if(frustum.SphereInFrustum(realhawkcoords.x+hawk.boundingspherecenter.x,realhawkcoords.y+hawk.boundingspherecenter.y,realhawkcoords.z+hawk.boundingspherecenter.z,2)){
536 glAlphaFunc(GL_GREATER, 0.0001f);
538 glDisable(GL_CULL_FACE);
539 glDisable(GL_LIGHTING);
541 glTranslatef(hawkcoords.x,hawkcoords.y,hawkcoords.z);
542 glRotatef(hawkrotation,0,1,0);
543 glTranslatef(25,0,0);
544 distance=findDistancefast(&viewer,&realhawkcoords)*1.2;
545 glColor4f(light.color[0],light.color[1],light.color[2],(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance);
546 if((viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance>1)glColor4f(light.color[0],light.color[1],light.color[2],1);
547 if((viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance>0)
548 hawk.drawdifftex(hawktexture);
552 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
553 glEnable(GL_CULL_FACE);
554 glCullFace(GL_FRONT);
556 for(k=0;k<numplayers;k++){
557 if(!(k==0||tutoriallevel!=1)){
559 glEnable(GL_LIGHTING);
560 terrainlight=terrain.getLighting(player[k].coords.x,player[k].coords.z);
561 distance=findDistancefast(&viewer,&player[k].coords);
562 distance=(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance;
563 glColor4f(terrainlight.x,terrainlight.y,terrainlight.z,distance);
564 if(distance>=1)glDisable(GL_BLEND);
566 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;
568 if(!player[k].occluded==0)i=checkcollide(viewer,checkpoint,player[k].lastoccluded);
569 if(i==-1||player[k].occluded==0)i=checkcollide(viewer,checkpoint);
571 player[k].occluded+=1;
572 player[k].lastoccluded=i;
574 else player[k].occluded=0;
575 if(player[k].occluded<25)player[k].DrawSkeleton();
582 glEnable(GL_TEXTURE_2D);
587 glDisable(GL_COLOR_MATERIAL);
589 glDisable(GL_LIGHTING);
590 glDisable(GL_TEXTURE_2D);
598 glDisable(GL_LIGHTING);
599 glDisable(GL_TEXTURE_2D);
600 glDisable(GL_COLOR_MATERIAL);
603 for(k=0;k<numplayers;k++){
604 if(player[k].numwaypoints>1){
605 glBegin(GL_LINE_LOOP);
606 for(i=0;i<player[k].numwaypoints;i++){
607 glVertex3f(player[k].waypoints[i].x,player[k].waypoints[i].y+.5,player[k].waypoints[i].z);
616 for(k=0;k<numpathpoints;k++){
617 if(numpathpointconnect[k]){
618 for(i=0;i<numpathpointconnect[k];i++){
619 glBegin(GL_LINE_LOOP);
620 glVertex3f(pathpoint[k].x,pathpoint[k].y+.5,pathpoint[k].z);
621 glVertex3f(pathpoint[pathpointconnect[k][i]].x,pathpoint[pathpointconnect[k][i]].y+.5,pathpoint[pathpointconnect[k][i]].z);
629 glVertex3f(pathpoint[pathpointselected].x,pathpoint[pathpointselected].y+.5,pathpoint[pathpointselected].z);
636 glEnable(GL_TEXTURE_2D);
637 glColor4f(.5,.5,.5,1);
639 sprintf (string, " ",(int)(fps));
640 text.glPrint(10,30,string,0,.8,screenwidth,screenheight);
643 if(bonus>0&&bonustime<1&&!winfreeze&&indialogue==-1/*bonustime<4*/){
644 if(bonus==tracheotomy)sprintf (string, "Tracheotomy!");
645 else if(bonus==backstab)sprintf (string, "Backstabber!");
646 else if(bonus==spinecrusher)sprintf (string, "Spinecrusher!");
647 else if(bonus==ninja)sprintf (string, "Ninja Bonus!");
648 else if(bonus==style)sprintf (string, "Style Bonus!");
649 else if(bonus==cannon)sprintf (string, "Leg Cannon!");
650 else if(bonus==aimbonus)sprintf (string, "Nice Aim!");
651 else if(bonus==deepimpact)sprintf (string, "Heavy Impact!");
652 else if(bonus==touchofdeath)sprintf (string, "Touch of Death!");
653 else if(bonus==swordreversebonus)sprintf (string, "Sword Disarm!");
654 else if(bonus==staffreversebonus)sprintf (string, "Staff Disarm!");
655 else if(bonus==reverseko)sprintf (string, "Reversal KO!");
656 else if(bonus==solidhit)sprintf (string, "Solid Hit!");
657 else if(bonus==twoxcombo)sprintf (string, "2X Combo!");
658 else if(bonus==threexcombo)sprintf (string, "3X Combo!");
659 else if(bonus==fourxcombo)sprintf (string, "4X COMBO!");
660 else if(bonus==megacombo)sprintf (string, "MEGA COMBO!");
661 else if(bonus==Reversal)sprintf (string, "Reversal!");
662 else if(bonus==Stabbonus)sprintf (string, "Punctured!");
663 else if(bonus==Slicebonus)sprintf (string, "Sliced!");
664 else if(bonus==Bullseyebonus)sprintf (string, "Bullseye!");
665 else if(bonus==Slashbonus)sprintf (string, "Slashed!");
666 else if(bonus==Wolfbonus)sprintf (string, "WOLF SLAYER!");
667 else if(bonus==FinishedBonus)sprintf (string, "SLAIN!");
668 else if(bonus==TackleBonus)sprintf (string, "Tackle!");
669 else if(bonus==AboveBonus)sprintf (string, "Death from Above!");
670 else sprintf (string, "Excellent!");
672 glColor4f(0,0,0,1-bonustime);
673 text.glPrintOutline(1024/2-10*strlen(string)-4,768/16-4+768*4/5,string,1,2.5,1024,768);
674 glColor4f(1,0,0,1-bonustime);
675 text.glPrint(1024/2-10*strlen(string),768/16+768*4/5,string,1,2,1024,768);
677 sprintf (string, "%d",(int)bonusvalue);
678 glColor4f(0,0,0,1-bonustime);
679 text.glPrintOutline(1024/2-10*strlen(string)-4,768/16-4-20+768*4/5,string,1,2.5*.8,1024,768);
680 glColor4f(1,0,0,1-bonustime);
681 text.glPrint(1024/2-10*strlen(string),768/16-20+768*4/5,string,1,2*.8,1024,768);
682 glColor4f(.5,.5,.5,1);
685 if(tutoriallevel==1){
686 tutorialopac=tutorialmaxtime-tutorialstagetime;
687 if(tutorialopac>1)tutorialopac=1;
688 if(tutorialopac<0)tutorialopac=0;
690 sprintf (string, " ");
691 sprintf (string2, " ");
692 sprintf (string3, " ");
693 if(tutorialstage==0){
694 sprintf (string, " ");
695 sprintf (string2, " ");
696 sprintf (string3, " ");
698 if(tutorialstage==1){
699 sprintf (string, "Welcome to the Lugaru training level!");
700 sprintf (string2, " ");
701 sprintf (string3, " ");
703 if(tutorialstage==2){
704 sprintf (string, "BASIC MOVEMENT:");
705 sprintf (string2, " ");
706 sprintf (string3, " ");
708 if(tutorialstage==3){
709 sprintf (string, "You can move the mouse to rotate the camera.");
710 sprintf (string2, " ");
711 sprintf (string3, " ");
713 if(tutorialstage==4){
714 sprintf (string, "Try using the %s, %s, %s and %s keys to move around.",KeyToChar(forwardkey),KeyToChar(leftkey),KeyToChar(backkey),KeyToChar(rightkey));
715 sprintf (string2, "All movement is relative to the camera.");
716 sprintf (string3, " ");
718 if(tutorialstage==5){
719 sprintf (string, "Please press %s to jump.",KeyToChar(jumpkey));
720 sprintf (string2, "You can hold it longer to jump higher.");
721 sprintf (string3, " ");
723 if(tutorialstage==6){
724 sprintf (string, "You can press %s to crouch.",KeyToChar(crouchkey));
725 sprintf (string2, "You can jump higher from a crouching position.");
726 sprintf (string3, " ");
728 if(tutorialstage==7){
729 sprintf (string, "While running, you can press %s to roll.",KeyToChar(crouchkey));
730 sprintf (string2, " ");
731 sprintf (string3, " ");
733 if(tutorialstage==8){
734 sprintf (string, "While crouching, you can sneak around silently");
735 sprintf (string2, "using the movement keys.");
736 sprintf (string3, " ");
738 if(tutorialstage==9){
739 sprintf (string, "Release the crouch key while sneaking and hold the movement keys");
740 sprintf (string2, "to run animal-style.");
741 sprintf (string3, " ");
743 if(tutorialstage==10){
744 sprintf (string, "ADVANCED MOVEMENT:");
745 sprintf (string2, " ");
746 sprintf (string3, " ");
748 if(tutorialstage==11){
749 sprintf (string, "When you jump at a wall, you can hold %s again",KeyToChar(jumpkey));
750 sprintf (string2, "during impact to perform a walljump.");
751 sprintf (string3, "Be sure to use the movement keys to press against the wall");
753 if(tutorialstage==12){
754 sprintf (string, "While in the air, you can press crouch to flip.",KeyToChar(jumpkey));
755 sprintf (string2, "Walljumps and flips confuse enemies and give you more control.");
756 sprintf (string3, " ");
758 if(tutorialstage==13){
759 sprintf (string, "BASIC COMBAT:");
760 sprintf (string2, " ");
761 sprintf (string3, " ");
763 if(tutorialstage==14){
764 sprintf (string, "There is now an imaginary enemy");
765 sprintf (string2, "in the middle of the training area.");
766 sprintf (string3, " ");
768 if(tutorialstage==15){
769 if(attackkey==MAC_MOUSEBUTTON1)sprintf (string, "Click to attack when you are near an enemy.");
770 else sprintf (string, "Press %s to attack when you are near an enemy.",KeyToChar(attackkey));
771 sprintf (string2, "You can punch by standing still near an enemy and attacking.");
772 sprintf (string3, " ");
774 if(tutorialstage==16){
775 sprintf (string, "If you are close, you will perform a weak punch.");
776 sprintf (string2, "The weak punch is excellent for starting attack combinations.");
777 sprintf (string3, " ");
779 if(tutorialstage==17){
780 sprintf (string, "Attacking while running results in a spin kick.");
781 sprintf (string2, "This is one of your most powerful ground attacks.");
782 sprintf (string3, " ");
784 if(tutorialstage==18){
785 sprintf (string, "Sweep the enemy's legs out by attacking while crouched.");
786 sprintf (string2, "This is a very fast attack, and easy to follow up.");
787 sprintf (string3, " ");
789 if(tutorialstage==19){
790 sprintf (string, "When an enemy is on the ground, you can deal some extra");
791 sprintf (string2, "damage by running up and drop-kicking him.");
792 sprintf (string3, "(Try knocking them down with a sweep first)");
794 if(tutorialstage==20){
795 sprintf (string, "Your most powerful individual attack is the rabbit kick.");
796 if(attackkey==MAC_MOUSEBUTTON1)sprintf (string2, "Run at the enemy while holding the mouse button, and press");
797 else sprintf (string2, "Run at the enemy while holding %s, and press", KeyToChar(attackkey));
798 sprintf (string3, "the jump key (%s) to attack.",KeyToChar(jumpkey));
800 if(tutorialstage==21){
801 sprintf (string, "This attack is devastating if timed correctly.");
802 sprintf (string2, "Even if timed incorrectly, it will knock the enemy over.");
803 if(againbonus)sprintf (string3, "Try rabbit-kicking the imaginary enemy again.");
804 else sprintf (string3, "Try rabbit-kicking the imaginary enemy.");
806 if(tutorialstage==22){
807 sprintf (string, "If you sneak behind an enemy unnoticed, you can kill");
808 sprintf (string2, "him instantly. Move close behind this enemy");
809 sprintf (string3, "and attack.");
811 if(tutorialstage==23){
812 sprintf (string, "Another important attack is the wall kick. When an enemy");
813 sprintf (string2, "is near a wall, perform a walljump nearby and hold");
814 sprintf (string3, "the attack key during impact with the wall.");
816 if(tutorialstage==24){
817 sprintf (string, "You can tackle enemies by running at them animal-style");
818 if(attackkey==MAC_MOUSEBUTTON1)sprintf (string2, "and pressing jump (%s) or attack(mouse button).",KeyToChar(jumpkey));
819 else sprintf (string2, "and pressing jump (%s) or attack(%s).",KeyToChar(jumpkey),KeyToChar(attackkey));
820 sprintf (string3, "This is especially useful when they are running away.");
822 if(tutorialstage==25){
823 sprintf (string, "Dodge by pressing back and attack. Dodging is essential");
824 sprintf (string2, "against enemies with swords or other long weapons.");
825 sprintf (string3, " ");
827 if(tutorialstage==26){
828 sprintf (string, "REVERSALS AND COUNTER-REVERSALS");
829 sprintf (string2, " ");
830 sprintf (string3, " ");
832 if(tutorialstage==27){
833 sprintf (string, "The enemy can now reverse your attacks.");
834 sprintf (string2, " ");
835 sprintf (string3, " ");
837 if(tutorialstage==28){
838 sprintf (string, "If you attack, you will notice that the enemy now sometimes");
839 sprintf (string2, "catches your attack and uses it against you. Hold");
840 sprintf (string3, "crouch (%s) after attacking to escape from reversals.",KeyToChar(crouchkey));
842 if(tutorialstage==29){
843 sprintf (string, "Try escaping from two more reversals in a row.");
844 sprintf (string2, " ");
845 sprintf (string3, " ");
847 if(tutorialstage==30){
848 sprintf (string, "Good!");
849 sprintf (string2, " ");
850 sprintf (string3, " ");
852 if(tutorialstage==31){
853 sprintf (string, "To reverse an attack, you must tap crouch (%s) during the",KeyToChar(crouchkey));
854 sprintf (string2, "enemy's attack. You must also be close to the enemy;");
855 sprintf (string3, "this is especially important against armed opponents.");
857 if(tutorialstage==32){
858 sprintf (string, "The enemy can attack in %d seconds.", (int)(tutorialmaxtime-tutorialstagetime));
859 sprintf (string2, "This imaginary opponents attacks will be highlighted");
860 sprintf (string3, "to make this easier.");
862 if(tutorialstage==33){
863 sprintf (string, "Reverse three enemy attacks!");
864 sprintf (string2, " ");
865 sprintf (string3, " ");
867 if(tutorialstage==34){
868 sprintf (string, "Reverse two more enemy attacks!");
869 sprintf (string2, " ");
870 sprintf (string3, " ");
872 if(tutorialstage==35){
873 sprintf (string, "Reverse one more enemy attack!");
874 sprintf (string2, " ");
875 sprintf (string3, " ");
877 if(tutorialstage==36){
878 sprintf (string, "Excellent!");
879 sprintf (string2, " ");
880 sprintf (string3, " ");
882 if(tutorialstage==37){
883 sprintf (string, "Now spar with the enemy for %d more seconds.", (int)(tutorialmaxtime-tutorialstagetime));
884 sprintf (string2, "Damage dealt: %d",(int)damagedealt);
885 sprintf (string3, "Damage taken: %d.",(int)damagetaken);
887 if(tutorialstage==38){
888 sprintf (string, "WEAPONS:");
889 sprintf (string2, " ");
890 sprintf (string3, " ");
892 if(tutorialstage==39){
893 sprintf (string, "There is now an imaginary knife");
894 sprintf (string2, "in the center of the training area.");
895 sprintf (string3, " ");
897 if(tutorialstage==40){
898 sprintf (string, "Stand, roll or handspring over the knife");
899 sprintf (string2, "while pressing %s to pick it up.",KeyToChar(throwkey));
900 sprintf (string3, "You can crouch and press the same key to drop it again.");
902 if(tutorialstage==41){
903 sprintf (string, "You can equip and unequip weapons using the %s key.",KeyToChar(drawkey));
904 sprintf (string2, "Sometimes it is best to keep them unequipped to");
905 sprintf (string3, "prevent enemies from taking them. ");
907 if(tutorialstage==42){
908 sprintf (string, "The knife is the smallest weapon and the least encumbering.");
909 sprintf (string2, "You can equip or unequip it while standing, crouching,");
910 sprintf (string3, "running or flipping.");
912 if(tutorialstage==43){
913 sprintf (string, "You perform weapon attacks the same way as unarmed attacks,");
914 sprintf (string2, "but sharp weapons cause permanent damage, instead of the");
915 sprintf (string3, "temporary trauma from blunt weapons, fists and feet.");
917 if(tutorialstage==44){
918 sprintf (string, "The enemy now has your knife!");
919 sprintf (string2, "Please reverse two of his knife attacks.");
920 sprintf (string3, " ");
922 if(tutorialstage==45){
923 sprintf (string, "Please reverse one more of his knife attacks.");
924 sprintf (string2, " ");
925 sprintf (string3, " ");
927 if(tutorialstage==46){
928 sprintf (string, "Now he has a sword!");
929 sprintf (string2, "The sword has longer reach than your arms, so you");
930 sprintf (string3, "must move close to reverse the sword slash.");
932 if(tutorialstage==47){
933 sprintf (string, "Long weapons like the sword and staff are also useful for defense;");
934 sprintf (string2, "you can parry enemy weapon attacks by pressing the attack key");
935 sprintf (string3, "at the right time. Please try parrying the enemy's attacks!");
937 if(tutorialstage==48){
938 sprintf (string, "The staff is like the sword, but has two main attacks.");
939 sprintf (string2, "The standing smash is fast and effective, and the running");
940 sprintf (string3, "spin smash is slower and more powerful.");
942 if(tutorialstage==49){
943 sprintf (string, "When facing an enemy, you can throw the knife with %s.",KeyToChar(throwkey));
944 sprintf (string2, "It is possible to throw the knife while flipping,");
945 sprintf (string3, "but it is very inaccurate.");
947 if(tutorialstage==50){
948 sprintf (string, "You now know everything you can learn from training.");
949 sprintf (string2, "Everything else you must learn from experience!");
950 sprintf (string3, " ");
952 if(tutorialstage==51){
953 sprintf (string, "Walk out of the training area to return to the main menu.");
954 sprintf (string2, " ");
955 sprintf (string3, " ");
958 glColor4f(0,0,0,tutorialopac);
959 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);
960 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);
961 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);
962 glColor4f(1,1,1,tutorialopac);
963 text.glPrint(screenwidth/2-7.6*strlen(string)*screenwidth/1024,screenheight/16+screenheight*4/5,string,1,1.5*screenwidth/1024,screenwidth,screenheight);
964 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);
965 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);
967 sprintf (string, "Press 'tab' to skip to the next item.",KeyToChar(jumpkey));
968 sprintf (string2, "Press escape at any time to");
969 sprintf (string3, "pause or exit the tutorial.");
972 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);
973 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);
974 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);
975 glColor4f(0.5,0.5,0.5,1);
976 text.glPrint(screenwidth/2-7.6*strlen(string)*screenwidth/1024*.8,0+screenheight*1/10,string,1,1.5*screenwidth/1024*.8,screenwidth,screenheight);
977 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);
978 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);
982 if(numhotspots&&(bonustime>=1||bonus<=0||bonustime<0)&&!tutoriallevel){
984 float closestdist=-1;
986 closest=currenthotspot;
987 for(i=0;i<numhotspots;i++){
988 distance=findDistancefast(&player[0].coords,&hotspot[i]);
989 if(closestdist==-1||distance<closestdist){
990 if(findDistancefast(&player[0].coords,&hotspot[i])<hotspotsize[i]&&((hotspottype[i]<=10&&hotspottype[i]>=0)||(hotspottype[i]<=40&&hotspottype[i]>=20))){
991 closestdist=distance;
997 currenthotspot=closest;
998 if(currenthotspot!=-1){
999 if(hotspottype[closest]<=10){
1000 if(findDistancefast(&player[0].coords,&hotspot[closest])<hotspotsize[closest])
1001 tutorialstagetime=0;
1003 tutorialopac=tutorialmaxtime-tutorialstagetime;
1004 if(tutorialopac>1)tutorialopac=1;
1005 if(tutorialopac<0)tutorialopac=0;
1007 sprintf (string, "%s", hotspottext[closest]);
1015 if(string[i]=='\n'||string[i]>'z'||string[i]<' '||string[i]=='\0'){
1016 glColor4f(0,0,0,tutorialopac);
1017 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);
1018 glColor4f(1,1,1,tutorialopac);
1019 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);
1022 if(string[i]=='\0')done=1;
1028 else if (hotspottype[closest]>=20&&dialoguegonethrough[hotspottype[closest]-20]==0){
1029 whichdialogue=hotspottype[closest]-20;
1030 for(j=0;j<numdialogueboxes[whichdialogue];j++){
1031 player[participantfocus[whichdialogue][j]].coords=participantlocation[whichdialogue][participantfocus[whichdialogue][j]];
1032 player[participantfocus[whichdialogue][j]].rotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
1033 player[participantfocus[whichdialogue][j]].targetrotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
1034 player[participantfocus[whichdialogue][j]].velocity=0;
1035 player[participantfocus[whichdialogue][j]].targetanimation=player[participantfocus[whichdialogue][j]].getIdle();
1036 player[participantfocus[whichdialogue][j]].targetframe=0;
1040 dialoguegonethrough[whichdialogue]++;
1041 if(dialogueboxsound[whichdialogue][indialogue]!=0){
1042 static float gLoc[3];
1043 static float vel[3];
1044 gLoc[0]=player[participantfocus[whichdialogue][indialogue]].coords.x;
1045 gLoc[1]=player[participantfocus[whichdialogue][indialogue]].coords.y;
1046 gLoc[2]=player[participantfocus[whichdialogue][indialogue]].coords.z;
1051 if(dialogueboxsound[whichdialogue][indialogue]==1)whichsoundplay=rabbitchitter;
1052 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
1053 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
1054 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
1055 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
1056 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
1057 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
1058 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
1059 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
1060 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
1061 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
1062 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
1063 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
1064 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
1065 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
1066 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
1067 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
1068 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
1069 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
1070 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
1071 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, true);
1072 OPENAL_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
1073 OPENAL_SetVolume(channels[whichsoundplay], 256);
1074 OPENAL_SetPaused(channels[whichsoundplay], false);
1080 if(indialogue!=-1&&!mainmenu){
1081 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1082 glDisable(GL_CULL_FACE);
1083 glDisable(GL_LIGHTING);
1084 glDisable(GL_TEXTURE_2D);
1086 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1087 glPushMatrix(); // Store The Projection Matrix
1088 glLoadIdentity(); // Reset The Projection Matrix
1089 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1090 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1091 glPushMatrix(); // Store The Modelview Matrix
1092 glLoadIdentity(); // Reset The Modelview Matrix
1093 if(dialogueboxlocation[whichdialogue][indialogue]==1)glTranslatef(0,screenheight*3/4,0);
1094 glScalef(screenwidth,screenheight/4,1);
1095 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1098 glColor4f(dialogueboxcolor[whichdialogue][indialogue][0],dialogueboxcolor[whichdialogue][indialogue][1],dialogueboxcolor[whichdialogue][indialogue][2],0.7);
1100 glVertex3f(0, 0, 0.0f);
1101 glVertex3f(1, 0, 0.0f);
1102 glVertex3f(1, 1, 0.0f);
1103 glVertex3f(0, 1, 0.0f);
1105 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1106 glPopMatrix(); // Restore The Old Projection Matrix
1107 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1108 glPopMatrix(); // Restore The Old Projection Matrix
1109 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1110 glEnable(GL_CULL_FACE);
1111 glDisable(GL_BLEND);
1113 glEnable(GL_TEXTURE_2D);
1120 startx=screenwidth*1/5;
1121 if(dialogueboxlocation[whichdialogue][indialogue]==1)starty=screenheight/16+screenheight*4/5;
1122 if(dialogueboxlocation[whichdialogue][indialogue]==2)starty=screenheight*1/5-screenheight/16;
1124 // char tempname[64];
1128 // for(i=0;i<64;i++){
1133 for(i=0;i<(int)strlen(dialoguename[whichdialogue][indialogue]);i++){
1134 tempname[tempnum]=dialoguename[whichdialogue][indialogue][i];
1136 if(dialoguename[whichdialogue][indialogue][i]=='#'||dialoguename[whichdialogue][indialogue][i]=='\0')goodchar=0;
1137 //if(tempnum>2)if(tempname[tempnum-2]=='e'&&tempname[tempnum-1]=='r')goodchar=0;
1138 //if(tempnum>2)if(tempname[tempnum]=='r'&&tempname[0]=='a')goodchar=0;
1139 if(goodchar)tempnum++;
1140 else tempname[tempnum]='\0';
1143 sprintf (string, "%s: ", tempname);
1145 if(dialogueboxcolor[whichdialogue][indialogue][0]+dialogueboxcolor[whichdialogue][indialogue][1]+dialogueboxcolor[whichdialogue][indialogue][2]<1.5){
1146 glColor4f(0,0,0,tutorialopac);
1147 text.glPrintOutline(startx-2*7.6*strlen(string)*screenwidth/1024-4,starty-4,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight);
1148 glColor4f(0.7,0.7,0.7,tutorialopac);
1149 text.glPrint(startx-2*7.6*strlen(string)*screenwidth/1024,starty,string,1,1.5*screenwidth/1024,screenwidth,screenheight);
1153 glColor4f(0,0,0,tutorialopac);
1154 text.glPrintOutline(startx-2*7.6*strlen(string)*screenwidth/1024-4,starty-4,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight);
1159 for(i=0;i<(int)strlen(dialoguetext[whichdialogue][indialogue])+1;i++){
1160 tempname[tempnum]=dialoguetext[whichdialogue][indialogue][i];
1161 if(dialoguetext[whichdialogue][indialogue][i]!='#')tempnum++;
1165 sprintf (string, "%s", tempname);
1174 if(string[i]=='\n'||string[i]>'z'||string[i]<' '||string[i]=='\0'){
1175 if(dialogueboxcolor[whichdialogue][indialogue][0]+dialogueboxcolor[whichdialogue][indialogue][1]+dialogueboxcolor[whichdialogue][indialogue][2]<1.5){
1176 glColor4f(0,0,0,tutorialopac);
1177 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);
1178 glColor4f(1,1,1,tutorialopac);
1179 text.glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/,starty-20*screenwidth/1024*line,string,1,1.5*screenwidth/1024,screenwidth,screenheight,lastline,i);
1183 glColor4f(0,0,0,tutorialopac);
1184 text.glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/,starty-20*screenwidth/1024*line,string,1,1.5*screenwidth/1024,screenwidth,screenheight,lastline,i);
1188 if(string[i]=='\0')done=1;
1195 if(!tutoriallevel&&!winfreeze&&indialogue==-1&&!mainmenu){
1197 if(!scoreadded)sprintf (string, "Score: %d", (int)accountactive->getCampaignScore()+(int)bonustotal);//(int)bonustotal);
1198 if(scoreadded)sprintf (string, "Score: %d", (int)accountactive->getCampaignScore());//(int)bonustotal);
1200 if(!campaign)sprintf (string, "Score: %d", (int)bonustotal);
1202 text.glPrintOutline(1024/40-4,768/16-4+768*14/16,string,1,1.5*1.25,1024,768);
1204 text.glPrint(1024/40,768/16+768*14/16,string,1,1.5,1024,768);
1206 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1207 glDisable(GL_CULL_FACE);
1208 glDisable(GL_LIGHTING);
1209 glDisable(GL_TEXTURE_2D);
1211 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1212 glPushMatrix(); // Store The Projection Matrix
1213 glLoadIdentity(); // Reset The Projection Matrix
1214 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1215 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1216 glPushMatrix(); // Store The Modelview Matrix
1217 glLoadIdentity(); // Reset The Modelview Matrix
1218 glTranslatef(15,screenheight*17.5/20,0);
1219 glScalef(screenwidth/3+20,screenheight/20,1);
1220 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1222 glColor4f(0.0,0.4,0.0,0.7);
1223 float bar=((float)player[0].damage)/player[0].damagetolerance;
1225 glVertex3f((bar<1?bar:1),0,0.0f);
1226 glVertex3f(1,0,0.0f);
1227 glVertex3f(1,1,0.0f);
1228 glVertex3f((bar<1?bar:1),1,0.0f);
1230 glColor4f(0.1,0.0,0.0,1);
1231 bar = ((float)player[0].bloodloss)/player[0].damagetolerance;
1233 glVertex3f(0,0,0.0f);
1234 glVertex3f((bar<1?bar:1),0,0.0f);
1235 glVertex3f((bar<1?bar:1),1,0.0f);
1236 glVertex3f(0,1,0.0f);
1238 glColor4f(0.4,0.0,0.0,0.7);
1239 bar = ((float)player[0].damage)/player[0].damagetolerance;
1241 glVertex3f(0,0,0.0f);
1242 glVertex3f((bar<1?bar:1),0,0.0f);
1243 glVertex3f((bar<1?bar:1),1,0.0f);
1244 glVertex3f(0,1,0.0f);
1246 glColor4f(0.4,0.0,0.0,0.7);
1247 bar = ((float)player[0].permanentdamage)/player[0].damagetolerance;
1249 glVertex3f(0,0,0.0f);
1250 glVertex3f((bar<1?bar:1),0,0.0f);
1251 glVertex3f((bar<1?bar:1),1,0.0f);
1252 glVertex3f(0,1,0.0f);
1254 glColor4f(0.4,0.0,0.0,0.7);
1255 bar = ((float)player[0].superpermanentdamage)/player[0].damagetolerance;
1257 glVertex3f(0,0,0.0f);
1258 glVertex3f((bar<1?bar:1),0,0.0f);
1259 glVertex3f((bar<1?bar:1),1,0.0f);
1260 glVertex3f(0,1,0.0f);
1262 glColor4f(0.0,0.0,0.0,0.7);
1264 glBegin(GL_LINE_STRIP);
1265 glVertex3f(0,0,0.0f);
1266 glVertex3f(1,0,0.0f);
1267 glVertex3f(1,1,0.0f);
1268 glVertex3f(0,1,0.0f);
1269 glVertex3f(0,0,0.0f);
1272 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1273 glPopMatrix(); // Restore The Old Projection Matrix
1274 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1275 glPopMatrix(); // Restore The Old Projection Matrix
1276 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1277 glEnable(GL_CULL_FACE);
1278 glDisable(GL_BLEND);
1280 glEnable(GL_TEXTURE_2D);
1282 // writing the numbers :
1283 sprintf (string, "Damages : %d/%d (%d)",(int)(player[0].damage),(int)(player[0].damagetolerance),(int)(player[0].bloodloss));
1285 text.glPrintOutline(1024/40-4,768/16-4+768*14/16-40,string,1,1.5*1.25,1024,768);
1287 text.glPrint(1024/40,768/16+768*14/16-40,string,1,1.5,1024,768);
1291 glColor4f(.5,.5,.5,1);
1294 if((texttoggle||editorenabled)&&debugmode&&!mainmenu){
1295 sprintf (string, "The framespersecond is %d.",(int)(fps));
1296 text.glPrint(10,30,string,0,.8,1024,768);
1298 sprintf (string, "Name: %s", registrationname);
1299 text.glPrint(10,260,string,0,.8,1024,768);
1302 if(editorenabled)sprintf (string, "Map editor enabled.");
1303 if(!editorenabled)sprintf (string, "Map editor Disabled.");
1304 text.glPrint(10,60,string,0,.8,1024,768);
1306 sprintf (string, "Object size: %f",editorsize);
1307 text.glPrint(10,75,string,0,.8,1024,768);
1308 if(editorrotation>=0)sprintf (string, "Object rotation: %f",editorrotation);
1309 else sprintf (string, "Object rotation: Random");
1310 text.glPrint(10,90,string,0,.8,1024,768);
1311 if(editorrotation2>=0)sprintf (string, "Object rotation2: %f",editorrotation2);
1312 else sprintf (string, "Object rotation2: Random");
1313 text.glPrint(10,105,string,0,.8,1024,768);
1314 sprintf (string, "Object type: %d",editortype);
1315 text.glPrint(10,120,string,0,.8,1024,768);
1316 if(editortype==boxtype)sprintf (string, "(box)");
1317 if(editortype==treetrunktype)sprintf (string, "(tree)");
1318 if(editortype==walltype)sprintf (string, "(wall)");
1319 if(editortype==weirdtype)sprintf (string, "(weird)");
1320 if(editortype==spiketype)sprintf (string, "(spike)");
1321 if(editortype==rocktype)sprintf (string, "(rock)");
1322 if(editortype==bushtype)sprintf (string, "(bush)");
1323 if(editortype==tunneltype)sprintf (string, "(tunnel)");
1324 if(editortype==chimneytype)sprintf (string, "(chimney)");
1325 if(editortype==platformtype)sprintf (string, "(platform)");
1326 if(editortype==cooltype)sprintf (string, "(cool)");
1327 if(editortype==firetype)sprintf (string, "(fire)");
1328 text.glPrint(130,120,string,0,.8,1024,768);
1330 sprintf (string, "Numplayers: %d",numplayers);
1331 text.glPrint(10,155,string,0,.8,1024,768);
1332 sprintf (string, "Player %d: numwaypoints: %d",numplayers,player[numplayers-1].numwaypoints);
1333 text.glPrint(10,140,string,0,.8,1024,768);
1335 /*sprintf (string, "Coords are: %f %f %f",player[0].coords.x,player[0].coords.y,player[0].coords.z);
1336 text.glPrint(10,200,string,0,.8,1024,768);*/
1337 sprintf (string, "Difficulty: %d",difficulty);
1338 text.glPrint(10,240,string,0,.8,1024,768);
1340 sprintf (string, "lasthotspot: %d",hotspottype[numhotspots-1]);
1341 text.glPrint(10,240,string,0,.8,1024,768);
1342 sprintf (string, "killhotspot: %d",killhotspot);
1343 text.glPrint(10,220,string,0,.8,1024,768);
1344 sprintf (string, "winhotspot: %d",winhotspot);
1345 text.glPrint(10,200,string,0,.8,1024,768);*/
1350 if(drawmode==glowmode){
1351 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1352 glDisable(GL_CULL_FACE);
1353 glDisable(GL_LIGHTING);
1354 glDisable(GL_TEXTURE_2D);
1356 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1357 glPushMatrix(); // Store The Projection Matrix
1358 glLoadIdentity(); // Reset The Projection Matrix
1359 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1360 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1361 glPushMatrix(); // Store The Modelview Matrix
1362 glLoadIdentity(); // Reset The Modelview Matrix
1363 glScalef(screenwidth,screenheight,1);
1364 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1366 glColor4f(0,0,0,.5);
1368 glVertex3f(0, 0, 0.0f);
1369 glVertex3f(256, 0, 0.0f);
1370 glVertex3f(256, 256, 0.0f);
1371 glVertex3f(0, 256, 0.0f);
1373 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1374 glPopMatrix(); // Restore The Old Projection Matrix
1375 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1376 glPopMatrix(); // Restore The Old Projection Matrix
1377 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1378 glEnable(GL_CULL_FACE);
1379 glDisable(GL_BLEND);
1383 if((((blackout&&damageeffects)||(player[0].bloodloss>0&&damageeffects&&player[0].blooddimamount>0)||player[0].dead)&&!cameramode)||console){
1384 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1385 glDisable(GL_CULL_FACE);
1386 glDisable(GL_LIGHTING);
1387 glDisable(GL_TEXTURE_2D);
1389 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1390 glPushMatrix(); // Store The Projection Matrix
1391 glLoadIdentity(); // Reset The Projection Matrix
1392 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1393 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1394 glPushMatrix(); // Store The Modelview Matrix
1395 glLoadIdentity(); // Reset The Modelview Matrix
1396 glScalef(screenwidth,screenheight,1);
1397 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1399 if(player[0].dead)blackout+=multiplier*3;
1400 if(player[0].dead==1)blackout=.4f;
1401 if(player[0].dead==2&&blackout>.6)blackout=.6;
1402 glColor4f(0,0,0,blackout);
1403 if(!player[0].dead){
1404 if((player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5))*.3<.3){
1405 glColor4f(0,0,0,player[0].blooddimamount*player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5)*.3);
1406 blackout=player[0].blooddimamount*player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5)*.3;
1409 glColor4f(0,0,0,player[0].blooddimamount*.3);
1410 blackout=player[0].blooddimamount*.3;
1413 if(console)glColor4f(.7,0,0,.2);
1415 glVertex3f(0, 0, 0.0f);
1416 glVertex3f(256, 0, 0.0f);
1417 glVertex3f(256, 256, 0.0f);
1418 glVertex3f(0, 256, 0.0f);
1420 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1421 glPopMatrix(); // Restore The Old Projection Matrix
1422 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1423 glPopMatrix(); // Restore The Old Projection Matrix
1424 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1425 glEnable(GL_CULL_FACE);
1426 glDisable(GL_BLEND);
1430 if(flashamount>0&&damageeffects){
1431 if(flashamount>1)flashamount=1;
1432 if(flashdelay<=0)flashamount-=multiplier;
1434 if(flashamount<0)flashamount=0;
1435 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1436 glDisable(GL_CULL_FACE);
1437 glDisable(GL_LIGHTING);
1439 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1440 glPushMatrix(); // Store The Projection Matrix
1441 glLoadIdentity(); // Reset The Projection Matrix
1442 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1443 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1444 glPushMatrix(); // Store The Modelview Matrix
1445 glLoadIdentity(); // Reset The Modelview Matrix
1446 glScalef(screenwidth,screenheight,1);
1447 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1449 glColor4f(flashr,flashg,flashb,flashamount);
1451 glVertex3f(0, 0, 0.0f);
1452 glVertex3f(256, 0, 0.0f);
1453 glVertex3f(256, 256, 0.0f);
1454 glVertex3f(0, 256, 0.0f);
1456 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1457 glPopMatrix(); // Restore The Old Projection Matrix
1458 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1459 glPopMatrix(); // Restore The Old Projection Matrix
1460 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1461 glEnable(GL_CULL_FACE);
1462 glDisable(GL_BLEND);
1468 glEnable(GL_TEXTURE_2D);
1471 sprintf (string, " ]");
1472 text.glPrint(10,30+screenheight-330,string,0,1,screenwidth,screenheight);
1474 sprintf (string, "_");
1475 text.glPrint(30+(float)(displayselected)*10,30+(screenheight-330),string,0,1,screenwidth,screenheight);
1479 if((i!=0||chatting)&&displaytime[i]<4)
1480 for(j=0;j<displaychars[i];j++){
1481 glColor4f(1,1,1,4-displaytime[i]);
1482 if(j<displaychars[i]){
1483 sprintf (string, "%c",displaytext[i][j]);
1484 text.glPrint(30+j*10,30+i*20+(screenheight-330),string,0,1,screenwidth,screenheight);
1490 if(minimap&&indialogue==-1){
1494 glDisable(GL_DEPTH_TEST);
1495 glColor3f (1.0, 1.0, 1.0); // no coloring
1497 glEnable(GL_TEXTURE_2D);
1498 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1499 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1500 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1501 glDisable(GL_CULL_FACE);
1502 glDisable(GL_LIGHTING);
1504 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1505 glPushMatrix(); // Store The Projection Matrix
1506 glLoadIdentity(); // Reset The Projection Matrix
1507 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1508 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1509 glPushMatrix(); // Store The Modelview Matrix
1510 glLoadIdentity(); // Reset The Modelview Matrix
1511 glScalef((float)screenwidth/2,(float)screenwidth/2,1);
1512 glTranslatef(1.75,.25,0);
1513 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1523 int numliveplayers=0;
1524 for(i=0;i<numplayers;i++){
1525 if(!player[i].dead)numliveplayers++;
1531 for(i=0;i<objects.numobjects;i++){
1532 if(objects.type[i]==treetrunktype||objects.type[i]==boxtype){
1533 center+=objects.position[i];
1537 for(i=0;i<numplayers;i++){
1538 if(!player[i].dead)center+=player[i].coords;
1540 center/=numadd+numliveplayers;
1542 center=player[0].coords;
1544 float maxdistance=0;
1547 for(i=0;i<objects.numobjects;i++){
1548 tempdist=findDistancefast(¢er,&objects.position[i]);
1549 if(tempdist>maxdistance){
1551 maxdistance=tempdist;
1554 for(i=0;i<numplayers;i++){
1555 if(!player[i].dead){
1556 tempdist=findDistancefast(¢er,&player[i].coords);
1557 if(tempdist>maxdistance){
1559 maxdistance=tempdist;
1563 radius=fast_sqrt(maxdistance);
1567 glScalef(.25/radius*256*terrain.scale*.4,.25/radius*256*terrain.scale*.4,1);
1569 glScalef(1/(1/radius*256*terrain.scale*.4),1/(1/radius*256*terrain.scale*.4),1);
1570 /*float startx,starty,endx,endy;
1572 glTexCoord2f(1-(center.x-radius)/terrain.scale/256,(center.z-radius)/terrain.scale/256);
1573 glVertex3f(-1, -1, 0.0f);
1574 glTexCoord2f(1-(center.x+radius)/terrain.scale/256,(center.z-radius)/terrain.scale/256);
1575 glVertex3f(1, -1, 0.0f);
1576 glTexCoord2f(1-(center.x+radius)/terrain.scale/256,(center.z+radius)/terrain.scale/256);
1577 glVertex3f(1, 1, 0.0f);
1578 glTexCoord2f(1-(center.x-radius)/terrain.scale/256,(center.z+radius)/terrain.scale/256);
1579 glVertex3f(-1, 1, 0.0f);
1582 glRotatef(player[0].lookrotation*-1+180,0,0,1);
1583 glTranslatef(-(center.x/terrain.scale/256*-2+1),(center.z/terrain.scale/256*-2+1),0);
1584 for(i=0;i<objects.numobjects;i++){
1585 if(objects.type[i]==treetrunktype){
1586 distcheck=findDistancefast(&player[0].coords,&objects.position[i]);
1587 if(distcheck<mapviewdist){
1588 glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
1589 glColor4f(0,.3,0,opac*(1-distcheck/mapviewdist));
1591 glTranslatef(objects.position[i].x/terrain.scale/256*-2+1,objects.position[i].z/terrain.scale/256*2-1,0);
1592 glRotatef(objects.rotation[i],0,0,1);
1593 glScalef(.003,.003,.003);
1596 glVertex3f(-1, -1, 0.0f);
1598 glVertex3f(1, -1, 0.0f);
1600 glVertex3f(1, 1, 0.0f);
1602 glVertex3f(-1, 1, 0.0f);
1607 if(objects.type[i]==boxtype){
1608 distcheck=findDistancefast(&player[0].coords,&objects.position[i]);
1609 if(distcheck<mapviewdist){
1610 glBindTexture( GL_TEXTURE_2D, Mapboxtexture);
1611 glColor4f(.4,.4,.4,opac*(1-distcheck/mapviewdist));
1613 glTranslatef(objects.position[i].x/terrain.scale/256*-2+1,objects.position[i].z/terrain.scale/256*2-1,0);
1614 glRotatef(objects.rotation[i],0,0,1);
1615 glScalef(.01*objects.scale[i],.01*objects.scale[i],.01*objects.scale[i]);
1618 glVertex3f(-1, -1, 0.0f);
1620 glVertex3f(1, -1, 0.0f);
1622 glVertex3f(1, 1, 0.0f);
1624 glVertex3f(-1, 1, 0.0f);
1631 glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
1632 for(i=0;i<numboundaries;i++){
1633 glColor4f(0,0,0,opac/3);
1635 glTranslatef(boundary[i].x/terrain.scale/256*-2+1,boundary[i].z/terrain.scale/256*2-1,0);
1636 glScalef(.002,.002,.002);
1639 glVertex3f(-1, -1, 0.0f);
1641 glVertex3f(1, -1, 0.0f);
1643 glVertex3f(1, 1, 0.0f);
1645 glVertex3f(-1, 1, 0.0f);
1650 for(i=0;i<numplayers;i++){
1651 distcheck=findDistancefast(&player[0].coords,&player[i].coords);
1652 if(distcheck<mapviewdist){
1654 glBindTexture( GL_TEXTURE_2D, Maparrowtexture);
1655 if(i==0)glColor4f(1,1,1,opac);
1656 else if(player[i].dead==2||player[i].howactive>typesleeping)glColor4f(0,0,0,opac*(1-distcheck/mapviewdist));
1657 else if(player[i].dead)glColor4f(.3,.3,.3,opac*(1-distcheck/mapviewdist));
1658 else if(player[i].aitype==attacktypecutoff)glColor4f(1,0,0,opac*(1-distcheck/mapviewdist));
1659 else if(player[i].aitype==passivetype)glColor4f(0,1,0,opac*(1-distcheck/mapviewdist));
1660 else glColor4f(1,1,0,1);
1661 glTranslatef(player[i].coords.x/terrain.scale/256*-2+1,player[i].coords.z/terrain.scale/256*2-1,0);
1662 glRotatef(player[i].rotation+180,0,0,1);
1663 glScalef(.005,.005,.005);
1666 glVertex3f(-1, -1, 0.0f);
1668 glVertex3f(1, -1, 0.0f);
1670 glVertex3f(1, 1, 0.0f);
1672 glVertex3f(-1, 1, 0.0f);
1674 /*glBegin(GL_TRIANGLES);
1676 glVertex3f(-1, -1, 0.0f);
1678 glVertex3f(1, -1, 0.0f);
1680 glVertex3f(0, 1, 0.0f);
1685 /*glBegin(GL_QUADS);
1687 glVertex3f(-1, -1, 0.0f);
1689 glVertex3f(1, -1, 0.0f);
1691 glVertex3f(1, 1, 0.0f);
1693 glVertex3f(-1, 1, 0.0f);
1696 glDisable(GL_TEXTURE_2D);
1697 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1698 glPopMatrix(); // Restore The Old Projection Matrix
1699 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1700 glPopMatrix(); // Restore The Old Projection Matrix
1701 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1702 glEnable(GL_CULL_FACE);
1703 glDisable(GL_BLEND);
1709 drawmode=normalmode;
1713 if(loading&&!stealthloading&&(!campaign||player[0].dead)){
1714 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1715 glDisable(GL_CULL_FACE);
1716 glDisable(GL_LIGHTING);
1717 glDisable(GL_TEXTURE_2D);
1719 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1720 glPushMatrix(); // Store The Projection Matrix
1721 glLoadIdentity(); // Reset The Projection Matrix
1722 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1723 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1724 glPushMatrix(); // Store The Modelview Matrix
1725 glLoadIdentity(); // Reset The Modelview Matrix
1726 glScalef(screenwidth,screenheight,1);
1727 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1729 glColor4f(0,0,0,.7);
1731 glVertex3f(0, 0, 0.0f);
1732 glVertex3f(256, 0, 0.0f);
1733 glVertex3f(256, 256, 0.0f);
1734 glVertex3f(0, 256, 0.0f);
1736 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1737 glPopMatrix(); // Restore The Old Projection Matrix
1738 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1739 glPopMatrix(); // Restore The Old Projection Matrix
1740 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1741 glEnable(GL_CULL_FACE);
1742 glDisable(GL_BLEND);
1746 glDisable(GL_DEPTH_TEST);
1747 glColor3f (1.0, 1.0, 1.0); // no coloring
1749 glEnable(GL_TEXTURE_2D);
1750 /*glBindTexture( GL_TEXTURE_2D, logotexture);
1751 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1752 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1753 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1754 glDisable(GL_CULL_FACE);
1755 glDisable(GL_LIGHTING);
1757 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1758 glPushMatrix(); // Store The Projection Matrix
1759 glLoadIdentity(); // Reset The Projection Matrix
1760 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1761 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1762 glPushMatrix(); // Store The Modelview Matrix
1763 glLoadIdentity(); // Reset The Modelview Matrix
1764 glScalef((float)screenwidth/2,(float)screenwidth/2,1);
1765 glTranslatef(1.8,1.25,0);
1766 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1770 glScalef(.25,.25,.25);
1773 glVertex3f(-1, -1, 0.0f);
1775 glVertex3f(1, -1, 0.0f);
1777 glVertex3f(1, 1, 0.0f);
1779 glVertex3f(-1, 1, 0.0f);
1782 glDisable(GL_TEXTURE_2D);
1783 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1784 glPopMatrix(); // Restore The Old Projection Matrix
1785 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1786 glPopMatrix(); // Restore The Old Projection Matrix
1787 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1788 glEnable(GL_CULL_FACE);
1789 glDisable(GL_BLEND);
1795 glEnable(GL_TEXTURE_2D);
1797 sprintf (string, "Loading...");
1798 text.glPrint(1024/2-90,768/2,string,1,2,1024,768);
1801 //if(ismotionblur)drawmode=motionblurmode;
1802 drawmode=normalmode;
1805 if(winfreeze&&!campaign){
1806 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1807 glDisable(GL_CULL_FACE);
1808 glDisable(GL_LIGHTING);
1809 glDisable(GL_TEXTURE_2D);
1811 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1812 glPushMatrix(); // Store The Projection Matrix
1813 glLoadIdentity(); // Reset The Projection Matrix
1814 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1815 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1816 glPushMatrix(); // Store The Modelview Matrix
1817 glLoadIdentity(); // Reset The Modelview Matrix
1818 glScalef(screenwidth,screenheight,1);
1819 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1821 glColor4f(0,0,0,.4);
1823 glVertex3f(0, 0, 0.0f);
1824 glVertex3f(256, 0, 0.0f);
1825 glVertex3f(256, 256, 0.0f);
1826 glVertex3f(0, 256, 0.0f);
1828 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1829 glPopMatrix(); // Restore The Old Projection Matrix
1830 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1831 glPopMatrix(); // Restore The Old Projection Matrix
1832 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1833 glEnable(GL_CULL_FACE);
1834 glDisable(GL_BLEND);
1838 glDisable(GL_DEPTH_TEST);
1839 glColor3f (1.0, 1.0, 1.0); // no coloring
1841 glEnable(GL_TEXTURE_2D);
1842 /*glBindTexture( GL_TEXTURE_2D, logotexture);
1843 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1844 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1845 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1846 glDisable(GL_CULL_FACE);
1847 glDisable(GL_LIGHTING);
1849 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1850 glPushMatrix(); // Store The Projection Matrix
1851 glLoadIdentity(); // Reset The Projection Matrix
1852 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1853 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1854 glPushMatrix(); // Store The Modelview Matrix
1855 glLoadIdentity(); // Reset The Modelview Matrix
1856 glScalef((float)screenwidth/2,(float)screenwidth/2,1);
1857 glTranslatef(1.8,1.25,0);
1858 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1862 glScalef(.25,.25,.25);
1865 glVertex3f(-1, -1, 0.0f);
1867 glVertex3f(1, -1, 0.0f);
1869 glVertex3f(1, 1, 0.0f);
1871 glVertex3f(-1, 1, 0.0f);
1874 glDisable(GL_TEXTURE_2D);
1875 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1876 glPopMatrix(); // Restore The Old Projection Matrix
1877 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1878 glPopMatrix(); // Restore The Old Projection Matrix
1879 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1880 glEnable(GL_CULL_FACE);
1881 glDisable(GL_BLEND);
1889 if(damagetaken==0&&player[0].bloodloss==0){
1890 awards[numawards]=awardflawless;
1896 for(i=1;i<numplayers;i++){
1897 if(player[i].dead!=2)alldead=0;
1900 awards[numawards]=awardalldead;
1905 for(i=1;i<numplayers;i++){
1906 if(player[i].dead!=1)alldead=0;
1909 awards[numawards]=awardnodead;
1912 if(numresponded==0&&!numthrowkill){
1913 awards[numawards]=awardstealth;
1916 if(numattacks==numstaffattack&&numattacks>0){
1917 awards[numawards]=awardbojutsu;
1920 if(numattacks==numswordattack&&numattacks>0){
1921 awards[numawards]=awardswordsman;
1924 if(numattacks==numknifeattack&&numattacks>0){
1925 awards[numawards]=awardknifefighter;
1928 if(numattacks==numunarmedattack&&numthrowkill==0&&weapons.numweapons>0){
1929 awards[numawards]=awardkungfu;
1933 awards[numawards]=awardevasion;
1936 if(numflipfail==0&&numflipped+numwallflipped*2>20){
1937 awards[numawards]=awardacrobat;
1940 if(numthrowkill==numplayers-1){
1941 awards[numawards]=awardlongrange;
1946 for(i=1;i<numplayers;i++){
1947 if(player[i].dead!=2)alldead=0;
1949 if(numafterkill>0&&alldead){
1950 awards[numawards]=awardbrutal;
1953 if(numreversals>((float)numattacks)*.8&&numreversals>3){
1954 awards[numawards]=awardaikido;
1957 if(maxalarmed==1&&numplayers>2){
1958 awards[numawards]=awardstrategy;
1962 awards[numawards]=awardklutz;
1967 //Win Screen Won Victory
1969 glEnable(GL_TEXTURE_2D);
1971 sprintf (string, "Level Cleared!");
1972 text.glPrintOutlined(1024/2-strlen(string)*10,768*7/8,string,1,2,1024,768);
1974 sprintf (string, "Score: %d",(int)(bonustotal-startbonustotal));
1975 text.glPrintOutlined(1024/30,768*6/8,string,1,2,1024,768);
1977 if(!campaign)sprintf (string, "Press Escape to return to menu or Space to continue");
1978 if(campaign)sprintf (string, "Press Escape or Space to continue");
1979 text.glPrintOutlined(640/2-strlen(string)*5,480*1/16,string,1,1,640,480);
1983 for(i=0;i<255;i++)string[i]='\0';
1984 sprintf (temp, "Time: %d:",(int)(((int)leveltime-(int)(leveltime)%60)/60));
1985 strcat(string,temp);
1986 if((int)(leveltime)%60<10)strcat(string,"0");
1987 sprintf (temp, "%d",(int)(leveltime)%60);
1988 strcat(string,temp);
1989 text.glPrintOutlined(1024/30,768*6/8-40,string,1,2,1024,768);
1991 for(i=0;i<numawards;i++){
1993 if(awards[i]==awardklutz)sprintf (string, "Suicidal");
1994 if(awards[i]==awardflawless)sprintf (string, "Flawless!");
1995 if(awards[i]==awardalldead)sprintf (string, "Take no prisoners");
1996 if(awards[i]==awardnodead)sprintf (string, "Merciful");
1997 if(awards[i]==awardstealth)sprintf (string, "One with the shadows!");
1998 if(awards[i]==awardswordsman)sprintf (string, "Swordsman");
1999 if(awards[i]==awardkungfu)sprintf (string, "Unarmed!");
2000 if(awards[i]==awardknifefighter)sprintf (string, "Knife fighter");
2001 if(awards[i]==awardcoward)sprintf (string, "Coward");
2002 if(awards[i]==awardevasion)sprintf (string, "Escape artist");
2003 if(awards[i]==awardacrobat)sprintf (string, "Gymnast");
2004 if(awards[i]==awardlongrange)sprintf (string, "Blade slinger");
2005 if(awards[i]==awardbrutal)sprintf (string, "Brutal");
2006 if(awards[i]==awardhyper)sprintf (string, "Hyper");
2007 if(awards[i]==awardaikido)sprintf (string, "Aikido master!");
2008 if(awards[i]==awardrambo)sprintf (string, "Rambo");
2009 if(awards[i]==awardfast)sprintf (string, "Fast");
2010 if(awards[i]==awardrealfast)sprintf (string, "Real fast");
2011 if(awards[i]==awarddamnfast)sprintf (string, "Damn fast");
2012 if(awards[i]==awardstrategy)sprintf (string, "Divide and conquer");
2013 if(awards[i]==awardbojutsu)sprintf (string, "Bojutsu");
2014 text.glPrintOutlined(1024/30,768*6/8-90-40*i,string,1,2,1024,768);
2018 //drawmode=normalmode;
2021 if(drawmode!=normalmode){
2022 glEnable(GL_TEXTURE_2D);
2024 if(!drawtoggle||drawmode!=realmotionblurmode||(drawtoggle==2||change==1)){
2027 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
2028 GLfloat subtractColor[4] = { 0.5, 0.5, 0.5, 0.0 };
2029 glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, subtractColor);
2030 //glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_SUBTRACT);
2031 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE);
2032 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_CONSTANT_EXT);
2033 glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 2.0f);
2035 glBindTexture( GL_TEXTURE_2D, screentexture);
2036 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
2039 if((drawtoggle||change==1)&&drawmode==realmotionblurmode){
2041 glBindTexture( GL_TEXTURE_2D, screentexture2);
2042 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
2044 if(!screentexture2){
2045 glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
2047 glGenTextures( 1, &screentexture2 );
2048 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
2050 glEnable(GL_TEXTURE_2D);
2051 glBindTexture( GL_TEXTURE_2D, screentexture2);
2052 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
2053 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
2055 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
2061 glClear(GL_DEPTH_BUFFER_BIT);
2062 ReSizeGLScene(90,.1f);
2063 glViewport(0,0,screenwidth,screenheight);
2065 if(drawmode!=normalmode){
2066 glDisable(GL_DEPTH_TEST);
2067 if(drawmode==motionblurmode){
2068 glDrawBuffer(GL_FRONT);
2069 glReadBuffer(GL_BACK);
2070 //myassert(glGetError() == GL_NO_ERROR);
2073 glColor3f (1.0, 1.0, 1.0); // no coloring
2075 glEnable(GL_TEXTURE_2D);
2076 glBindTexture( GL_TEXTURE_2D, screentexture);
2077 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
2078 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
2079 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
2080 glDisable(GL_CULL_FACE);
2081 glDisable(GL_LIGHTING);
2083 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2084 glPushMatrix(); // Store The Projection Matrix
2085 glLoadIdentity(); // Reset The Projection Matrix
2086 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
2087 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2088 glPushMatrix(); // Store The Modelview Matrix
2089 glLoadIdentity(); // Reset The Modelview Matrix
2090 glScalef((float)screenwidth/2,(float)screenheight/2,1);
2091 glTranslatef(1,1,0);
2092 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
2094 if(drawmode==motionblurmode){
2095 if(motionbluramount<.2)motionbluramount=.2;
2096 //glColor4f(1,1,1,fast_sqrt(multiplier)*2.9*motionbluramount);
2097 glColor4f(1,1,1,motionbluramount);
2101 glVertex3f(-1, -1, 0.0f);
2102 glTexCoord2f(texcoordwidth,0);
2103 glVertex3f(1, -1, 0.0f);
2104 glTexCoord2f(texcoordwidth,texcoordheight);
2105 glVertex3f(1, 1, 0.0f);
2106 glTexCoord2f(0,texcoordheight);
2107 glVertex3f(-1, 1, 0.0f);
2111 if(drawmode==realmotionblurmode){
2112 glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
2113 glClear(GL_COLOR_BUFFER_BIT);
2114 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
2115 glBindTexture( GL_TEXTURE_2D, screentexture);
2116 glColor4f(1,1,1,.5);
2120 glVertex3f(-1, -1, 0.0f);
2121 glTexCoord2f(texcoordwidth,0);
2122 glVertex3f(1, -1, 0.0f);
2123 glTexCoord2f(texcoordwidth,texcoordheight);
2124 glVertex3f(1, 1, 0.0f);
2125 glTexCoord2f(0,texcoordheight);
2126 glVertex3f(-1, 1, 0.0f);
2129 glBindTexture( GL_TEXTURE_2D, screentexture2);
2130 glColor4f(1,1,1,.5);
2134 glVertex3f(-1, -1, 0.0f);
2135 glTexCoord2f(texcoordwidth,0);
2136 glVertex3f(1, -1, 0.0f);
2137 glTexCoord2f(texcoordwidth,texcoordheight);
2138 glVertex3f(1, 1, 0.0f);
2139 glTexCoord2f(0,texcoordheight);
2140 glVertex3f(-1, 1, 0.0f);
2143 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
2145 if(drawmode==doublevisionmode){
2146 static float crosseyedness;
2147 crosseyedness=abs(player[0].damage-player[0].superpermanentdamage-(player[0].damagetolerance-player[0].superpermanentdamage)*1/2)/30;
2148 if(crosseyedness>1)crosseyedness=1;
2149 if(crosseyedness<0)crosseyedness=0;
2151 glDisable(GL_BLEND);
2156 glVertex3f(-1, -1, 0.0f);
2157 glTexCoord2f(texcoordwidth,0);
2158 glVertex3f(1, -1, 0.0f);
2159 glTexCoord2f(texcoordwidth,texcoordheight);
2160 glVertex3f(1, 1, 0.0f);
2161 glTexCoord2f(0,texcoordheight);
2162 glVertex3f(-1, 1, 0.0f);
2166 glColor4f(1,1,1,.5);
2169 glTranslatef(.015*crosseyedness,0,0);
2173 glVertex3f(-1, -1, 0.0f);
2174 glTexCoord2f(texcoordwidth,0);
2175 glVertex3f(1, -1, 0.0f);
2176 glTexCoord2f(texcoordwidth,texcoordheight);
2177 glVertex3f(1, 1, 0.0f);
2178 glTexCoord2f(0,texcoordheight);
2179 glVertex3f(-1, 1, 0.0f);
2184 if(drawmode==glowmode){
2185 glColor4f(.5,.5,.5,.5);
2187 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
2189 glTranslatef(.01,0,0);
2192 glVertex3f(-1, -1, 0.0f);
2193 glTexCoord2f(texcoordwidth,0);
2194 glVertex3f(1, -1, 0.0f);
2195 glTexCoord2f(texcoordwidth,texcoordheight);
2196 glVertex3f(1, 1, 0.0f);
2197 glTexCoord2f(0,texcoordheight);
2198 glVertex3f(-1, 1, 0.0f);
2202 glTranslatef(-.01,0,0);
2205 glVertex3f(-1, -1, 0.0f);
2206 glTexCoord2f(texcoordwidth,0);
2207 glVertex3f(1, -1, 0.0f);
2208 glTexCoord2f(texcoordwidth,texcoordheight);
2209 glVertex3f(1, 1, 0.0f);
2210 glTexCoord2f(0,texcoordheight);
2211 glVertex3f(-1, 1, 0.0f);
2215 glTranslatef(.0,.01,0);
2218 glVertex3f(-1, -1, 0.0f);
2219 glTexCoord2f(texcoordwidth,0);
2220 glVertex3f(1, -1, 0.0f);
2221 glTexCoord2f(texcoordwidth,texcoordheight);
2222 glVertex3f(1, 1, 0.0f);
2223 glTexCoord2f(0,texcoordheight);
2224 glVertex3f(-1, 1, 0.0f);
2228 glTranslatef(0,-.01,0);
2231 glVertex3f(-1, -1, 0.0f);
2232 glTexCoord2f(texcoordwidth,0);
2233 glVertex3f(1, -1, 0.0f);
2234 glTexCoord2f(texcoordwidth,texcoordheight);
2235 glVertex3f(1, 1, 0.0f);
2236 glTexCoord2f(0,texcoordheight);
2237 glVertex3f(-1, 1, 0.0f);
2241 if(drawmode==radialzoommode){
2243 //glRotatef((float)i*.1,0,0,1);
2244 glColor4f(1,1,1,1/((float)i+1));
2246 glScalef(1+(float)i*.01,1+(float)i*.01,1);
2249 glVertex3f(-1, -1, 0.0f);
2250 glTexCoord2f(texcoordwidth,0);
2251 glVertex3f(1, -1, 0.0f);
2252 glTexCoord2f(texcoordwidth,texcoordheight);
2253 glVertex3f(1, 1, 0.0f);
2254 glTexCoord2f(0,texcoordheight);
2255 glVertex3f(-1, 1, 0.0f);
2260 glDisable(GL_TEXTURE_2D);
2261 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2262 glPopMatrix(); // Restore The Old Projection Matrix
2263 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2264 glPopMatrix(); // Restore The Old Projection Matrix
2265 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
2266 glEnable(GL_CULL_FACE);
2267 glDisable(GL_BLEND);
2272 glEnable(GL_TEXTURE_2D);
2277 if(consoleselected>=60)offset=consoleselected-60;
2278 sprintf (string, " ]");
2279 text.glPrint(10,30,string,0,1,1024,768);
2281 sprintf (string, "_");
2282 text.glPrint(30+(float)(consoleselected)*10-offset*10,30,string,0,1,1024,768);
2285 for(j=0;j<consolechars[i];j++){
2286 glColor4f(1,1,1,1-(float)(i)/16);
2287 if(j<consolechars[i]){
2288 sprintf (string, "%c",consoletext[i][j]);
2289 text.glPrint(30+j*10-offset*10,30+i*20,string,0,1,1024,768);
2297 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)||(mainmenu&&gameon)||(!gameon&&gamestarted)||(!gameon&&gamestarted)){
2298 multiplier=tempmult;
2303 // !!! FIXME: hack: clamp framerate in menu so text input works correctly on fast systems.
2306 glDrawBuffer(GL_BACK);
2307 glReadBuffer(GL_BACK);
2308 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
2309 ReSizeGLScene(90,.1f);
2312 temptexdetail=texdetail;
2313 if(texdetail>2)texdetail=2;
2314 if(mainmenu!=oldmainmenu&&oldmainmenu!=0){
2316 LoadTexture(":Data:Textures:Newgame.png",&Mainmenuitems[1],0,0);
2317 LoadTexture(":Data:Textures:Quit.png",&Mainmenuitems[3],0,0);
2318 /*if(oldmainmenu==1||oldmainmenu==0){
2319 LoadTexture(":Data:Textures:World.png",&Mainmenuitems[7],0,0);
2320 LoadTexture(":Data:Textures:Options.png",&Mainmenuitems[2],0,0);
2321 LoadTexture(":Data:Textures:Lugaru.png",&Mainmenuitems[0],0,0);
2326 LoadTexture(":Data:Textures:Resume.png",&Mainmenuitems[1],0,0);
2327 LoadTexture(":Data:Textures:Endgame.png",&Mainmenuitems[3],0,0);
2328 /*if(oldmainmenu==2||oldmainmenu==0){
2329 LoadTexture(":Data:Textures:World.png",&Mainmenuitems[7],0,0);
2330 LoadTexture(":Data:Textures:Options.png",&Mainmenuitems[2],0,0);
2331 LoadTexture(":Data:Textures:Lugaru.png",&Mainmenuitems[0],0,0);
2336 if(lastcheck>.5||oldmainmenu!=mainmenu){
2338 ifstream ipstream(ConvertFileName(":Data:Campaigns:main.txt"));
2339 //campaignnumlevels=0;
2340 //accountactive->getCampaignChoicesMade()=0;
2341 ipstream.ignore(256,':');
2342 ipstream >> campaignnumlevels;
2343 for(i=0;i<campaignnumlevels;i++){
2344 ipstream.ignore(256,':');
2345 ipstream.ignore(256,':');
2346 ipstream.ignore(256,' ');
2347 ipstream >> campaignmapname[i];
2348 ipstream.ignore(256,':');
2349 ipstream >> campaigndescription[i];
2351 if(campaigndescription[i][j]=='_')campaigndescription[i][j]=' ';
2353 ipstream.ignore(256,':');
2354 ipstream >> campaignchoosenext[i];
2355 ipstream.ignore(256,':');
2356 ipstream >> campaignnumnext[i];
2357 if(campaignnumnext[i])
2358 for(j=0;j<campaignnumnext[i];j++){
2359 ipstream.ignore(256,':');
2360 ipstream >> campaignnextlevel[i][j];
2361 campaignnextlevel[i][j]-=1;
2363 ipstream.ignore(256,':');
2364 ipstream >> campaignlocationx[i];
2365 //campaignlocationx[i]-=30;
2366 ipstream.ignore(256,':');
2367 ipstream >> campaignlocationy[i];
2368 //campaignlocationy[i]+=30;
2372 for(i=0;i<campaignnumlevels;i++){
2374 levelhighlight[i]=0;
2379 if(accountactive->getCampaignChoicesMade())
2380 for(i=0;i<accountactive->getCampaignChoicesMade();i++){
2381 levelorder[i+1]=campaignnextlevel[levelorder[i]][accountactive->getCampaignChoice(i)];
2382 levelvisible[levelorder[i+1]]=1;
2384 int whichlevelstart;
2385 whichlevelstart=accountactive->getCampaignChoicesMade()-1;
2386 if(whichlevelstart<0){
2387 accountactive->setCampaignScore(0);
2388 accountactive->resetFasttime();
2389 campaignchoicenum=1;
2390 campaignchoicewhich[0]=0;
2394 campaignchoicenum=campaignnumnext[levelorder[whichlevelstart]];
2395 if(campaignchoicenum==0){
2396 //if(accountactive->getCampaignFasttime()==0||accountcampaigntime[accountactive]<accountactive->getCampaignFasttime())accountactive->getCampaignFasttime()=accountcampaigntime[accountactive];
2398 if(campaignchoicenum)
2399 for(i=0;i<campaignchoicenum;i++){
2400 campaignchoicewhich[i]=campaignnextlevel[levelorder[whichlevelstart]][i];
2401 levelvisible[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
2402 levelhighlight[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
2415 texdetail=temptexdetail;
2417 /*if(mainmenu!=0)*/oldmainmenu=mainmenu;
2419 if(mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==8||mainmenu==9||mainmenu==10||mainmenu==119||mainmenu==13||mainmenu==17||mainmenu==18){
2420 glClear(GL_DEPTH_BUFFER_BIT);
2421 glEnable(GL_ALPHA_TEST);
2422 glAlphaFunc(GL_GREATER, 0.001f);
2423 glEnable(GL_TEXTURE_2D);
2424 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
2425 glDisable(GL_CULL_FACE);
2426 glDisable(GL_LIGHTING);
2428 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2429 glPushMatrix(); // Store The Projection Matrix
2430 glLoadIdentity(); // Reset The Projection Matrix
2431 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
2432 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2433 glPushMatrix(); // Store The Modelview Matrix
2434 glLoadIdentity(); // Reset The Modelview Matrix
2435 glTranslatef(screenwidth/2,screenheight/2,0);
2437 glScalef((float)screenwidth/2,(float)screenheight/2,1);
2438 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
2439 glDisable(GL_BLEND);
2440 glColor4f(0,0,0,1.0);
2441 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2442 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2443 glDisable(GL_TEXTURE_2D);
2445 //glScalef(.25,.25,.25);
2448 glVertex3f(-1, -1, 0.0f);
2450 glVertex3f(1, -1, 0.0f);
2452 glVertex3f(1, 1, 0.0f);
2454 glVertex3f(-1, 1, 0.0f);
2458 glColor4f(0.4,0.4,0.4,1.0);
2459 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2460 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2461 glEnable(GL_TEXTURE_2D);
2462 glBindTexture( GL_TEXTURE_2D, Mainmenuitems[4]);
2464 //glScalef(.25,.25,.25);
2467 glVertex3f(-1, -1, 0.0f);
2469 glVertex3f(1, -1, 0.0f);
2471 glVertex3f(1, 1, 0.0f);
2473 glVertex3f(-1, 1, 0.0f);
2478 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2480 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2484 if((float)newscreenwidth>(float)newscreenheight*1.61||(float)newscreenwidth<(float)newscreenheight*1.59)sprintf (menustring[0], "Resolution: %d*%d",(int)newscreenwidth,(int)newscreenheight);
2485 else sprintf (menustring[0], "Resolution: %d*%d (widescreen)",(int)newscreenwidth,(int)newscreenheight);
2488 endx[0]=startx[0]+strlen(menustring[0])*10;
2489 endy[0]=starty[0]+20;
2493 if(newdetail==2)sprintf (menustring[1], "Detail: High");
2494 else if(newdetail==1)sprintf (menustring[1], "Detail: Medium");
2495 else sprintf (menustring[1], "Detail: Low");
2498 endx[1]=startx[1]+strlen(menustring[1])*10;
2499 endy[1]=starty[1]+20;
2503 if(bloodtoggle==2)sprintf (menustring[2], "Blood: On, high detail (slower)");
2504 if(bloodtoggle==1)sprintf (menustring[2], "Blood: On, low detail");
2505 if(bloodtoggle==0)sprintf (menustring[2], "Blood: Off");
2508 endx[2]=startx[2]+strlen(menustring[2])*10;
2509 endy[2]=starty[2]+20;
2513 if(difficulty==2)sprintf (menustring[3], "Difficulty: Insane");
2514 if(difficulty==1)sprintf (menustring[3], "Difficulty: Difficult");
2515 if(difficulty==0)sprintf (menustring[3], "Difficulty: Easier");
2516 startx[3]=10+20-1000;
2518 endx[3]=startx[3]+strlen(menustring[3])*10;
2519 endy[3]=starty[3]+20;
2523 if(ismotionblur==1)sprintf (menustring[4], "Blur Effects: Enabled (less compatible)");
2524 if(ismotionblur==0)sprintf (menustring[4], "Blur Effects: Disabled (more compatible)");
2527 endx[4]=startx[4]+strlen(menustring[4])*10;
2528 endy[4]=starty[4]+20;
2532 if(decals==1)sprintf (menustring[5], "Decals: Enabled (slower)");
2533 if(decals==0)sprintf (menustring[5], "Decals: Disabled");
2536 endx[5]=startx[5]+strlen(menustring[5])*10;
2537 endy[5]=starty[5]+20;
2541 if(musictoggle==1)sprintf (menustring[6], "Music: Enabled");
2542 if(musictoggle==0)sprintf (menustring[6], "Music: Disabled");
2545 endx[6]=startx[6]+strlen(menustring[6])*10;
2546 endy[6]=starty[6]+20;
2550 if(invertmouse==1)sprintf (menustring[9], "Invert mouse: Yes");
2551 if(invertmouse==0)sprintf (menustring[9], "Invert mouse: No");
2554 endx[9]=startx[9]+strlen(menustring[9])*10;
2555 endy[9]=starty[9]+20;
2559 sprintf (menustring[10], "Mouse Speed: %d", (int)(usermousesensitivity*5));
2562 endx[10]=startx[10]+strlen(menustring[10])*10;
2563 endy[10]=starty[10]+20;
2567 sprintf (menustring[11], "Volume: %d%%", (int)(volume*100));
2570 endx[11]=startx[11]+strlen(menustring[11])*10;
2571 endy[11]=starty[11]+20;
2575 sprintf (menustring[13], "Damage Bar: %s",(showdamagebar?"on":"off"));
2578 endx[13]=startx[13]+strlen(menustring[13])*10;
2579 endy[13]=starty[13]+20;
2583 sprintf (menustring[7], "-Configure Controls-");
2586 endx[7]=startx[7]+strlen(menustring[7])*10;
2587 endy[7]=starty[7]+20;
2591 sprintf (menustring[12], "-Configure Stereo -");
2594 endx[12]=startx[12]+strlen(menustring[7])*10;
2595 endy[12]=starty[12]+20;
2599 if(newdetail==detail&&newscreenheight==(int)screenheight&&newscreenwidth==(int)screenwidth)sprintf (menustring[8], "Back");
2600 else sprintf (menustring[8], "Back (some changes take effect next time Lugaru is opened)");
2602 endx[8]=startx[8]+strlen(menustring[8])*10;
2604 endy[8]=starty[8]+20;
2611 if(keyselect!=0)sprintf (menustring[0], "Forwards: %s",KeyToChar(forwardkey));
2612 else sprintf (menustring[0], "Forwards: _");
2615 endx[0]=startx[0]+strlen(menustring[0])*10;
2616 endy[0]=starty[0]+20;
2620 if(keyselect!=1)sprintf (menustring[1], "Back: %s",KeyToChar(backkey));
2621 else sprintf (menustring[1], "Back: _");
2624 endx[1]=startx[1]+strlen(menustring[1])*10;
2625 endy[1]=starty[1]+20;
2629 if(keyselect!=2)sprintf (menustring[2], "Left: %s",KeyToChar(leftkey));
2630 else sprintf (menustring[2], "Left: _");
2633 endx[2]=startx[2]+strlen(menustring[2])*10;
2634 endy[2]=starty[2]+20;
2638 if(keyselect!=3)sprintf (menustring[3], "Right: %s",KeyToChar(rightkey));
2639 else sprintf (menustring[3], "Right: _");
2642 endx[3]=startx[3]+strlen(menustring[3])*10;
2643 endy[3]=starty[3]+20;
2647 if(keyselect!=4)sprintf (menustring[4], "Crouch: %s",KeyToChar(crouchkey));
2648 else sprintf (menustring[4], "Crouch: _");
2651 endx[4]=startx[4]+strlen(menustring[4])*10;
2652 endy[4]=starty[4]+20;
2656 if(keyselect!=5)sprintf (menustring[5], "Jump: %s",KeyToChar(jumpkey));
2657 else sprintf (menustring[5], "Jump: _");
2660 endx[5]=startx[5]+strlen(menustring[5])*10;
2661 endy[5]=starty[5]+20;
2665 if(keyselect!=6)sprintf (menustring[6], "Draw: %s",KeyToChar(drawkey));
2666 else sprintf (menustring[6], "Draw: _");
2669 endx[6]=startx[6]+strlen(menustring[6])*10;
2670 endy[6]=starty[6]+20;
2674 if(keyselect!=7)sprintf (menustring[7], "Throw: %s",KeyToChar(throwkey));
2675 else sprintf (menustring[7], "Throw: _");
2678 endx[7]=startx[7]+strlen(menustring[7])*10;
2679 endy[7]=starty[7]+20;
2683 if(keyselect!=8)sprintf (menustring[8], "Attack: %s",KeyToChar(attackkey));
2684 else sprintf (menustring[8], "Attack: _");
2687 endx[8]=startx[8]+strlen(menustring[8])*10;
2688 endy[8]=starty[8]+20;
2694 sprintf (menustring[9], "Back");
2696 endx[9]=startx[9]+strlen(menustring[9])*10;
2698 endy[9]=starty[9]+20;
2703 nummenuitems=7+accountactive->getCampaignChoicesMade()+campaignchoicenum;
2705 sprintf (menustring[0], "%s",accountactive->getName());
2708 endx[0]=startx[0]+strlen(menustring[0])*10;
2709 endy[0]=starty[0]+20;
2713 sprintf (menustring[1], "Tutorial");
2716 endx[1]=startx[1]+strlen(menustring[1])*10;
2717 endy[1]=starty[1]+20;
2721 sprintf (menustring[2], "Challenge");
2724 endx[2]=startx[2]+strlen(menustring[2])*10;
2725 endy[2]=starty[2]+20;
2729 sprintf (menustring[3], "Delete User");
2732 endx[3]=startx[3]+strlen(menustring[3])*10;
2733 endy[3]=starty[3]+20;
2737 sprintf (menustring[4], "Main Menu");
2740 endx[4]=startx[4]+strlen(menustring[4])*10;
2741 endy[4]=starty[4]+20;
2745 sprintf (menustring[5], "Change User");
2747 endx[5]=startx[5]+strlen(menustring[5])*10;
2749 endy[5]=starty[5]+20;
2755 sprintf (menustring[6], "World");
2757 starty[6]=30+480-400-50;
2758 endx[6]=startx[6]+400;
2763 if(accountactive->getCampaignChoicesMade())
2764 for(i=0;i<accountactive->getCampaignChoicesMade();i++){
2765 sprintf (menustring[7+i], "%s", campaigndescription[levelorder[i]]);
2766 startx[7+i]=30+120+campaignlocationx[levelorder[i]]*400/512;
2767 starty[7+i]=30+30+(512-campaignlocationy[levelorder[i]])*400/512;
2768 endx[7+i]=startx[7+i]+10;
2769 endy[7+i]=starty[7+i]+10;
2774 if(campaignchoicenum>0)
2775 for(i=accountactive->getCampaignChoicesMade();i<accountactive->getCampaignChoicesMade()+campaignchoicenum;i++){
2776 sprintf (menustring[7+i], "%s", campaigndescription[levelorder[i]]);
2777 startx[7+i]=30+120+campaignlocationx[campaignchoicewhich[i-(accountactive->getCampaignChoicesMade())]]*400/512;
2778 starty[7+i]=30+30+(512-campaignlocationy[campaignchoicewhich[i-(accountactive->getCampaignChoicesMade())]])*400/512;
2779 endx[7+i]=startx[7+i]+10;
2780 endy[7+i]=starty[7+i]+10;
2785 /*sprintf (menustring[7], "Dot");
2786 startx[7]=120+260*400/512;
2787 starty[7]=30+(512-184)*400/512;
2788 endx[7]=startx[7]+10;
2789 endy[7]=starty[7]+10;
2793 sprintf (menustring[8], "Dot");
2794 startx[8]=120+129*400/512;
2795 starty[8]=30+(512-284)*400/512;
2796 endx[8]=startx[8]+10;
2797 endy[8]=starty[8]+10;
2801 sprintf (menustring[9], "Dot");
2802 startx[9]=120+358*400/512;
2803 starty[9]=30+(512-235)*400/512;
2804 endx[9]=startx[9]+10;
2805 endy[9]=starty[9]+10;
2809 sprintf (menustring[10], "Dot");
2810 startx[10]=120+359*400/512;
2811 starty[10]=30+(512-308)*400/512;
2812 endx[10]=startx[10]+10;
2813 endy[10]=starty[10]+10;
2817 sprintf (menustring[11], "Dot");
2818 startx[11]=120+288*400/512;
2819 starty[11]=30+(512-277)*400/512;
2820 endx[11]=startx[11]+10;
2821 endy[11]=starty[11]+10;
2829 sprintf (menustring[0], "Are you sure you want to delete this user?");
2832 endx[0]=startx[0]+strlen(menustring[0])*10;
2833 endy[0]=starty[0]+20;
2837 sprintf (menustring[1], "Yes");
2840 endx[1]=startx[1]+strlen(menustring[1])*10;
2841 endy[1]=starty[1]+20;
2845 sprintf (menustring[2], "No");
2848 endx[2]=startx[2]+strlen(menustring[2])*10;
2849 endy[2]=starty[2]+20;
2853 sprintf (menustring[3], "Extra 4");
2856 endx[3]=startx[3]+strlen(menustring[3])*10;
2857 endy[3]=starty[3]+20;
2861 sprintf (menustring[4], "Extra 5");
2864 endx[4]=startx[4]+strlen(menustring[4])*10;
2865 endy[4]=starty[4]+20;
2869 sprintf (menustring[5], "Back");
2871 endx[5]=startx[5]+strlen(menustring[5])*10;
2873 endy[5]=starty[5]+20;
2879 nummenuitems=Account::getNbAccounts()+2;
2883 if(Account::getNbAccounts()<8)
2884 sprintf (menustring[0], "New User");
2886 sprintf (menustring[0], "No More Users");
2889 endx[0]=startx[0]+strlen(menustring[0])*10;
2890 endy[0]=starty[0]+20;
2899 for(i=0;i<Account::getNbAccounts();i++){
2900 sprintf (menustring[num], "%s",Account::get(i)->getName());
2902 starty[num]=360-20-20*num;
2903 endx[num]=startx[num]+strlen(menustring[num])*10;
2904 endy[num]=starty[num]+20;
2911 sprintf (menustring[num], "Back");
2913 endx[num]=startx[num]+strlen(menustring[num])*10;
2915 endy[num]=starty[num]+20;
2922 sprintf (menustring[0], "Easier");
2925 endx[0]=startx[0]+strlen(menustring[0])*10;
2926 endy[0]=starty[0]+20;
2930 sprintf (menustring[1], "Difficult");
2933 endx[1]=startx[1]+strlen(menustring[1])*10;
2934 endy[1]=starty[1]+20;
2938 sprintf (menustring[2], "Insane");
2941 endx[2]=startx[2]+strlen(menustring[2])*10;
2942 endy[2]=starty[2]+20;
2948 //tempncl=numchallengelevels;
2949 //numchallengelevels=9;
2950 nummenuitems=2+numchallengelevels;
2953 for(j=0;j<numchallengelevels;j++){
2954 for(i=0;i<255;i++)menustring[j][i]='\0';
2955 sprintf (temp, "Level %d",j+1);
2956 strcpy(menustring[j],temp);
2957 for(i=0;i<17;i++)if(menustring[j][i]=='\0')menustring[j][i]=' ';
2958 menustring[j][17]='\0';
2959 sprintf (temp, "%d",(int)accountactive->getHighScore(j));
2960 strcat(menustring[j],temp);
2961 for(i=18;i<32;i++)if(menustring[j][i]=='\0')menustring[j][i]=' ';
2962 menustring[j][32]='\0';
2963 sprintf (temp, "%d:",(int)(((int)accountactive->getFastTime(j)-(int)(accountactive->getFastTime(j))%60)/60));
2964 strcat(menustring[j],temp);
2965 if((int)(accountactive->getFastTime(j))%60<10)strcat(menustring[j],"0");
2966 sprintf (temp, "%d",(int)(accountactive->getFastTime(j))%60);
2967 strcat(menustring[j],temp);
2971 endx[j]=startx[j]+strlen(menustring[j])*10;
2972 endy[j]=starty[j]+20;
2977 sprintf (menustring[numchallengelevels], "Back");
2978 startx[numchallengelevels]=10;
2979 endx[numchallengelevels]=startx[numchallengelevels]+strlen(menustring[numchallengelevels])*10;
2980 starty[numchallengelevels]=10;
2981 endy[numchallengelevels]=starty[numchallengelevels]+20;
2982 movex[numchallengelevels]=0;
2983 movey[numchallengelevels]=0;
2985 sprintf (menustring[numchallengelevels+1], " High Score Best Time");
2986 startx[numchallengelevels+1]=10;
2987 starty[numchallengelevels+1]=440;
2988 endx[numchallengelevels+1]=startx[numchallengelevels+1]+strlen(menustring[numchallengelevels+1])*10;
2989 endy[numchallengelevels+1]=starty[numchallengelevels+1]+20;
2990 movex[numchallengelevels+1]=0;
2991 movey[numchallengelevels+1]=0;
2993 //numchallengelevels=tempncl;
2997 nummenuitems=2+numchallengelevels;
3000 for(j=0;j<numchallengelevels;j++){
3001 for(i=0;i<255;i++)menustring[j][i]='\0';
3002 sprintf (temp, "Level %d",j+1);
3003 strcpy(menustring[j],temp);
3004 for(i=0;i<17;i++)if(menustring[j][i]=='\0')menustring[j][i]=' ';
3005 menustring[j][17]='\0';
3006 sprintf (temp, "%d",(int)accountactive->getHighScore(j));
3007 strcat(menustring[j],temp);
3008 for(i=18;i<32;i++)if(menustring[j][i]=='\0')menustring[j][i]=' ';
3009 menustring[j][32]='\0';
3010 sprintf (temp, "%d:",(int)(((int)accountactive->getFastTime(j)-(int)(accountactive->getFastTime(j))%60)/60));
3011 strcat(menustring[j],temp);
3012 if((int)(accountactive->getFastTime(j))%60<10)strcat(menustring[j],"0");
3013 sprintf (temp, "%d",(int)(accountactive->getFastTime(j))%60);
3014 strcat(menustring[j],temp);
3018 endx[j]=startx[j]+strlen(menustring[j])*10;
3019 endy[j]=starty[j]+20;
3024 sprintf (menustring[numchallengelevels], "Back");
3025 startx[numchallengelevels]=10;
3026 endx[numchallengelevels]=startx[numchallengelevels]+strlen(menustring[numchallengelevels])*10;
3027 starty[numchallengelevels]=10;
3028 endy[numchallengelevels]=starty[numchallengelevels]+20;
3029 movex[numchallengelevels]=0;
3030 movey[numchallengelevels]=0;
3032 sprintf (menustring[numchallengelevels+1], " High Score Best Time");
3033 startx[numchallengelevels+1]=10;
3034 starty[numchallengelevels+1]=400;
3035 endx[numchallengelevels+1]=startx[numchallengelevels+1]+strlen(menustring[numchallengelevels+1])*10;
3036 endy[numchallengelevels+1]=starty[numchallengelevels+1]+20;
3037 movex[numchallengelevels+1]=0;
3038 movey[numchallengelevels+1]=0;
3045 sprintf (menustring[0], "Congratulations!");
3048 endx[0]=startx[0]+strlen(menustring[0])*10;
3049 endy[0]=starty[0]+20;
3053 sprintf (menustring[1], "You have avenged your family and");
3056 endx[1]=startx[1]+strlen(menustring[1])*10;
3057 endy[1]=starty[1]+20;
3061 sprintf (menustring[2], "restored peace to the island of Lugaru.");
3064 endx[2]=startx[2]+strlen(menustring[2])*10;
3065 endy[2]=starty[2]+20;
3069 sprintf (menustring[3], "Back");
3071 endx[3]=startx[3]+strlen(menustring[3])*10;
3073 endy[3]=starty[3]+20;
3077 for(i=0;i<255;i++)menustring[4][i]='\0';
3078 sprintf (temp, "Your score:");
3079 strcpy(menustring[4],temp);
3080 for(i=0;i<20;i++)if(menustring[4][i]=='\0')menustring[4][i]=' ';
3081 menustring[4][20]='\0';
3082 sprintf (temp, "%d",(int)accountactive->getCampaignScore());
3083 strcat(menustring[4],temp);
3085 endx[4]=startx[4]+strlen(menustring[4])*10;
3087 endy[4]=starty[4]+20;
3091 for(i=0;i<255;i++)menustring[5][i]='\0';
3092 sprintf (temp, "Your time:");
3093 strcpy(menustring[5],temp);
3094 for(i=0;i<20;i++)if(menustring[5][i]=='\0')menustring[5][i]=' ';
3095 menustring[5][20]='\0';
3096 sprintf (temp, "%d",(int)accountcampaigntime[accountactive]);
3097 strcat(menustring[5],temp);
3099 endx[5]=startx[5]+strlen(menustring[5])*10;
3101 endy[5]=starty[5]+20;
3105 for(i=0;i<255;i++)menustring[5][i]='\0';
3106 sprintf (temp, "Highest score:");
3107 strcpy(menustring[5],temp);
3108 for(i=0;i<20;i++)if(menustring[5][i]=='\0')menustring[5][i]=' ';
3109 menustring[5][20]='\0';
3110 sprintf (temp, "%d",(int)accountactive->getCampaignHighScore());
3111 strcat(menustring[5],temp);
3113 endx[5]=startx[5]+strlen(menustring[5])*10;
3115 endy[5]=starty[5]+20;
3119 for(i=0;i<255;i++)menustring[7][i]='\0';
3120 sprintf (temp, "Lowest time:");
3121 strcpy(menustring[7],temp);
3122 for(i=0;i<20;i++)if(menustring[7][i]=='\0')menustring[7][i]=' ';
3123 menustring[7][20]='\0';
3124 sprintf (temp, "%d",(int)accountactive->getCampaignFasttime());
3125 strcat(menustring[7],temp);
3127 endx[7]=startx[7]+strlen(menustring[7])*10;
3129 endy[7]=starty[7]+20;
3135 sprintf (menustring[0], "Stereo mode: %s", StereoModeName(newstereomode));
3138 endx[0]=startx[0]+strlen(menustring[0])*10;
3139 endy[0]=starty[0]+20;
3143 sprintf (menustring[1], "Stereo separation: %.3f", stereoseparation);
3146 endx[1]=startx[1]+strlen(menustring[1])*10;
3147 endy[1]=starty[1]+20;
3151 sprintf (menustring[2], "Reverse stereo: %s", stereoreverse ? "Yes" : "No");
3154 endx[2]=startx[2]+strlen(menustring[2])*10;
3155 endy[2]=starty[2]+20;
3159 sprintf (menustring[3], "Back");
3161 endx[3]=startx[3]+strlen(menustring[3])*10;
3163 endy[3]=starty[3]+20;
3173 sprintf (menustring[0], "Please enter your name:");
3176 endx[0]=startx[0]+strlen(menustring[0])*10;
3177 endy[0]=starty[0]+20;
3181 sprintf (menustring[1], "Please enter your name:");
3184 endx[1]=startx[1]+strlen(menustring[1])*10;
3185 endy[1]=starty[1]+20;
3189 if(mainmenu==1||mainmenu==2){
3199 starty[1]=480-152-32;
3206 starty[2]=480-228-32;
3214 starty[3]=480-306-32;
3223 starty[3]=480-306-32;
3237 starty[4]=480-140-256;
3244 starty[5]=480-138-256;
3251 starty[6]=480-144-256;
3259 starty[4]=480-140-256;
3266 starty[5]=480-138-256;
3273 starty[6]=480-144-256;
3281 starty[4]=480-140-256;
3288 starty[5]=480-150-256;
3295 starty[6]=480-144-256;
3303 starty[4]=480-140-256;
3310 starty[5]=480-150-256;
3317 starty[6]=480-144-256;
3325 starty[4]=480-100-256;
3332 starty[5]=480-120-256;
3339 starty[6]=480-144-256;
3349 if(mainmenu==1||mainmenu==2)
3351 if((mousecoordh/screenwidth*640)>startx[i]&&(mousecoordh/screenwidth*640)<endx[i]&&480-(mousecoordv/screenheight*480)>starty[i]&&480-(mousecoordv/screenheight*480)<endy[i]){
3356 if(mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==8||mainmenu==9||mainmenu==10||mainmenu==11||mainmenu==13||mainmenu==17||mainmenu==18)
3357 for(i=0;i<nummenuitems;i++){
3358 if((mousecoordh/screenwidth*640)>startx[i]&&(mousecoordh/screenwidth*640)<endx[i]&&480-(mousecoordv/screenheight*480)>starty[i]&&480-(mousecoordv/screenheight*480)<endy[i]){
3359 if(mainmenu!=5)selected=i;
3360 if(mainmenu==5&&(i!=0&&i!=6))selected=i;
3361 if(mainmenu==9&&(i!=numchallengelevels+1))selected=i;
3362 if(mainmenu==11&&(i!=numchallengelevels+1))selected=i;
3367 for(i=0;i<nummenuitems;i++){
3368 if(selected==i)selectedlong[i]+=multiplier*5;
3369 if(selectedlong[i]>1)selectedlong[i]=1;
3370 if(selected!=i)selectedlong[i]-=multiplier*5;
3371 if(selectedlong[i]<0)selectedlong[i]=0;
3372 //if(i>=4)selectedlong[i]=.3;
3373 if(i>=4&&(mainmenu==1||mainmenu==2))selectedlong[i]=0;
3377 for(i=0;i<nummenuitems;i++){
3378 offsetx[i]=(startx[i]+endx[i])/2-(mousecoordh/screenwidth*640);
3379 offsety[i]=(starty[i]+endy[i])/2-(480-(mousecoordv/screenheight*480));
3384 if(i>=4&&(mainmenu==1||mainmenu==2)){
3385 offsetx[i]=(startx[i]+endx[i]+movex[i]*transition)/2-(640+190)/2;
3386 offsety[i]=(starty[i]+endy[i]+movey[i]*transition)/2-(336+150)/2;
3392 if(mainmenu==1||mainmenu==2){
3393 glClear(GL_DEPTH_BUFFER_BIT);
3394 glEnable(GL_ALPHA_TEST);
3395 glAlphaFunc(GL_GREATER, 0.001f);
3396 glEnable(GL_TEXTURE_2D);
3397 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3398 glDisable(GL_CULL_FACE);
3399 glDisable(GL_LIGHTING);
3401 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3402 glPushMatrix(); // Store The Projection Matrix
3403 glLoadIdentity(); // Reset The Projection Matrix
3404 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
3405 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3406 glPushMatrix(); // Store The Modelview Matrix
3407 glLoadIdentity(); // Reset The Modelview Matrix
3408 glTranslatef(screenwidth/2,screenheight/2,0);
3410 glScalef((float)screenwidth/2,(float)screenheight/2,1);
3411 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3412 glDisable(GL_BLEND);
3413 glColor4f(0,0,0,1.0);
3414 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
3415 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
3416 glDisable(GL_TEXTURE_2D);
3418 //glScalef(.25,.25,.25);
3421 glVertex3f(-1, -1, 0.0f);
3423 glVertex3f(1, -1, 0.0f);
3425 glVertex3f(1, 1, 0.0f);
3427 glVertex3f(-1, 1, 0.0f);
3431 glColor4f(0.4,0.4,0.4,1.0);
3432 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
3433 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
3434 glEnable(GL_TEXTURE_2D);
3435 glBindTexture( GL_TEXTURE_2D, Mainmenuitems[4]);
3437 //glScalef(.25,.25,.25);
3440 glVertex3f(-1, -1, 0.0f);
3442 glVertex3f(1, -1, 0.0f);
3444 glVertex3f(1, 1, 0.0f);
3446 glVertex3f(-1, 1, 0.0f);
3451 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3454 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3455 glPushMatrix(); // Store The Projection Matrix
3456 glLoadIdentity(); // Reset The Projection Matrix
3457 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3458 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3459 glPushMatrix(); // Store The Modelview Matrix
3460 glLoadIdentity(); // Reset The Modelview Matrix
3462 glDisable(GL_TEXTURE_2D);
3467 if(anim!=1)glVertex3f(190, 150, 0.0f);
3468 if(anim==1)glVertex3f(190+movex[4]*transition, 150, 0.0f);
3470 glVertex3f(640, 150, 0.0f);
3472 glVertex3f(640, 336, 0.0f);
3474 if(anim!=1)glVertex3f(190, 336, 0.0f);
3475 if(anim==1)glVertex3f(190+movex[4]*transition, 336, 0.0f);
3480 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3482 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3486 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3487 glPushMatrix(); // Store The Projection Matrix
3488 glLoadIdentity(); // Reset The Projection Matrix
3489 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3490 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3491 glPushMatrix(); // Store The Modelview Matrix
3492 glLoadIdentity(); // Reset The Modelview Matrix
3493 glEnable(GL_TEXTURE_2D);
3496 for(j=0;j<nummenuitems;j++)
3498 if(j<=3||(mainmenu!=1&&mainmenu!=2))
3500 //glDisable(GL_BLEND);
3501 glEnable(GL_ALPHA_TEST);
3503 //glDisable(GL_ALPHA_TEST);
3504 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3505 if(mainmenu==1||mainmenu==2)
3508 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3509 glBindTexture( GL_TEXTURE_2D, Mainmenuitems[j]);
3510 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
3511 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
3512 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3516 glVertex3f(startx[j]+movex[j]*transition, starty[j]+movey[j]*transition, 0.0f);
3518 glVertex3f(endx[j]+movex[j]*transition, starty[j]+movey[j]*transition, 0.0f);
3520 glVertex3f(endx[j]+movex[j]*transition, endy[j]+movey[j]*transition, 0.0f);
3522 glVertex3f(startx[j]+movex[j]*transition, endy[j]+movey[j]*transition, 0.0f);
3526 //glDisable(GL_ALPHA_TEST);
3527 if(j<4)glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3530 if(1-((float)i)/10-(1-selectedlong[j])>0)
3532 glColor4f(1,1,1,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3533 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3537 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);
3539 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);
3541 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);
3543 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);
3549 if(mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==8||mainmenu==9||mainmenu==10||mainmenu==11||mainmenu==13||mainmenu==17||mainmenu==18)
3551 if(mainmenu!=5||j<6)
3554 if(mainmenu==9&&j>accountactive->getProgress()&&j<numchallengelevels)glColor4f(0.5,0,0,1);
3555 if(mainmenu==11&&j>accountactive->getProgress()&&j<numchallengelevels)glColor4f(0.5,0,0,1);
3556 //if(1-((float)i)/10-(1-selectedlong[j])>0){
3557 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3559 if(mainmenu!=7||j!=0||!entername)
3560 text.glPrint(startx[j],starty[j],menustring[j],0,1,640,480);
3564 sprintf (string, "_");
3565 text.glPrint(startx[j]+(float)(displayselected)*10,starty[j],string,0,1,640,480);
3567 for(l=0;l<displaychars[0];l++){
3568 sprintf (string, "%c",displaytext[0][l]);
3569 text.glPrint(startx[j]+l*10,starty[j],string,0,1,640,480);
3574 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3577 if(1-((float)i)/15-(1-selectedlong[j])>0)
3579 glColor4f(1,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3580 if(mainmenu==9&&j>accountactive->getProgress()&&j<numchallengelevels)glColor4f(0.5,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3581 if(mainmenu==11&&j>accountactive->getProgress()&&j<numchallengelevels)glColor4f(0.5,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3582 if(mainmenu==3)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4-((/*1*/+((float)i)/70)*strlen(menustring[j]))*3,starty[j]/*-i*1/2*/+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
3583 if(mainmenu==4)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4/*-((((float)i)/70)*strlen(menustring[j]))*3*/,starty[j]/*-i*1/2*/+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
3584 if(mainmenu==5)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4/*-((((float)i)/70)*strlen(menustring[j]))*3*/,starty[j]/*-i*1/2*/+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
3585 if(mainmenu==6)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4/*-((((float)i)/70)*strlen(menustring[j]))*3*/,starty[j]/*-i*1/2*/+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
3586 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);
3587 if(mainmenu==8)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4/*-((((float)i)/70)*strlen(menustring[j]))*3*/,starty[j]/*-i*1/2*/+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
3588 if(mainmenu==9)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4/*-((((float)i)/70)*strlen(menustring[j]))*3*/,starty[j]/*-i*1/2*/+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
3589 if(mainmenu==11)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4/*-((((float)i)/70)*strlen(menustring[j]))*3*/,starty[j]/*-i*1/2*/+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
3590 if(mainmenu==10)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4/*-((((float)i)/70)*strlen(menustring[j]))*3*/,starty[j]/*-i*1/2*/+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
3591 if(mainmenu==17)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4/*-((((float)i)/70)*strlen(menustring[j]))*3*/,starty[j]/*-i*1/2*/+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
3592 if(mainmenu==13&&j!=1)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4/*-((((float)i)/70)*strlen(menustring[j]))*3*/,starty[j]/*-i*1/2*/+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
3593 if(mainmenu==18)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4/*-((((float)i)/70)*strlen(menustring[j]))*3*/,starty[j]/*-i*1/2*/+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
3596 sprintf (string, "_");
3597 text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4+(float)(displayselected)*10*(1+((float)i)/70),starty[j]+offsety[j]*((float)i)/4,string,0,1+((float)i)/70,640,480);
3600 for(l=0;l<displaychars[k];l++){
3601 if(l<displaychars[k]){
3602 sprintf (string, "%c",displaytext[k][l]);
3603 text.glPrint(startx[j]-((float)k)+offsetx[j]*((float)k)/4+l*10*(1+((float)i)/70),starty[j]+offsety[j]*((float)i)/4,string,0,1+((float)i)/70,640,480);
3612 glClear(GL_DEPTH_BUFFER_BIT);
3613 glEnable(GL_ALPHA_TEST);
3614 glAlphaFunc(GL_GREATER, 0.001f);
3615 glEnable(GL_TEXTURE_2D);
3616 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3617 glDisable(GL_CULL_FACE);
3618 glDisable(GL_LIGHTING);
3619 if(j==6)glColor4f(1,1,1,1);
3620 else glColor4f(1,0,0,1);
3622 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3623 glPushMatrix(); // Store The Projection Matrix
3624 glLoadIdentity(); // Reset The Projection Matrix
3625 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3626 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3627 glPushMatrix(); // Store The Modelview Matrix
3628 glLoadIdentity(); // Reset The Modelview Matrix
3631 //Draw world, draw map
3632 glTranslatef(2,-5,0);
3634 if(j>6&&j<nummenuitems-1)
3636 XYZ linestart,lineend,offset;
3643 //float linestartx,lineendx,linestarty,lineendy,offsetx,offsety;
3644 linestart.x=(startx[j]+endx[j])/2;
3645 linestart.y=(starty[j]+endy[j])/2;
3646 if(j>=6+accountactive->getCampaignChoicesMade()){
3647 linestart.x=(startx[6+accountactive->getCampaignChoicesMade()]+endx[6+accountactive->getCampaignChoicesMade()])/2;
3648 linestart.y=(starty[6+accountactive->getCampaignChoicesMade()]+endy[6+accountactive->getCampaignChoicesMade()])/2;
3650 lineend.x=(startx[j+1]+endx[j+1])/2;
3651 lineend.y=(starty[j+1]+endy[j+1])/2;
3652 offset=lineend-linestart;
3655 offset=DoRotation(offset,0,0,90);
3657 glDisable(GL_TEXTURE_2D);
3659 if(j<6+accountactive->getCampaignChoicesMade()){
3660 glColor4f(0.5,0,0,1);
3664 if(j>=6+accountactive->getCampaignChoicesMade()){
3670 linestart+=fac*4*startsize;
3671 lineend-=fac*4*endsize;
3673 if(!(j>7+accountactive->getCampaignChoicesMade()+campaignchoicenum)){
3674 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3678 glVertex3f(linestart.x-offset.x*startsize, linestart.y-offset.y*startsize, 0.0f);
3680 glVertex3f(linestart.x+offset.x*startsize, linestart.y+offset.y*startsize, 0.0f);
3682 glVertex3f(lineend.x+offset.x*endsize, lineend.y+offset.y*endsize, 0.0f);
3684 glVertex3f(lineend.x-offset.x*endsize, lineend.y-offset.y*endsize, 0.0f);
3688 glEnable(GL_TEXTURE_2D);
3692 if(j==6)glBindTexture( GL_TEXTURE_2D, Mainmenuitems[7]);
3693 else glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
3694 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
3695 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
3696 if(j-7<accountactive->getCampaignChoicesMade())glColor4f(0.5,0,0,1);
3697 if(j-7>=accountactive->getCampaignChoicesMade())glColor4f(1,0,0,1);
3698 if(j==6)glColor4f(1,1,1,1);
3701 itemsize=abs(startx[j]-endx[j])/2;
3703 midpoint.x=(startx[j]+endx[j])/2;
3704 midpoint.y=(starty[j]+endy[j])/2;
3705 if(j>6&&(j-7<accountactive->getCampaignChoicesMade()))itemsize*=.5;
3706 if(!(j-7>accountactive->getCampaignChoicesMade()+campaignchoicenum))
3708 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3712 glVertex3f(midpoint.x-itemsize+movex[j]*transition, midpoint.y-itemsize+movey[j]*transition, 0.0f);
3714 glVertex3f(midpoint.x+itemsize+movex[j]*transition, midpoint.y-itemsize+movey[j]*transition, 0.0f);
3716 glVertex3f(midpoint.x+itemsize+movex[j]*transition, midpoint.y+itemsize+movey[j]*transition, 0.0f);
3718 glVertex3f(midpoint.x-itemsize+movex[j]*transition, midpoint.y+itemsize+movey[j]*transition, 0.0f);
3722 //glDisable(GL_ALPHA_TEST);
3723 if(j<4)glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3726 if(1-((float)i)/10-(1-selectedlong[j])>0)
3728 glColor4f(1,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3729 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3733 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);
3735 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);
3737 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);
3739 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);
3747 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3749 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3751 if(j-7>=accountactive->getCampaignChoicesMade()){
3752 //glColor4f(0,0,0,1);
3753 //text.glPrintOutline(startx[j]+10-1.5,starty[j]-4-1.5,menustring[j],0,0.6*1.25,640,480);
3754 //glColor4f(1,0,0,1);
3755 //text.glPrint(startx[j]+10,starty[j]-4,menustring[j],0,0.6,640,480);
3756 text.glPrintOutlined(0.9,0,0,startx[j]+10,starty[j]-4,menustring[j],0,0.6,640,480);
3757 glDisable(GL_DEPTH_TEST);
3764 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3766 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3769 if(mainmenu==1||mainmenu==2)
3770 if(transition<.1||transition>.9){
3771 glClear(GL_DEPTH_BUFFER_BIT);
3772 glEnable(GL_ALPHA_TEST);
3773 glAlphaFunc(GL_GREATER, 0.001f);
3774 glEnable(GL_TEXTURE_2D);
3775 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3776 glDisable(GL_CULL_FACE);
3777 glDisable(GL_LIGHTING);
3779 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3780 glPushMatrix(); // Store The Projection Matrix
3781 glLoadIdentity(); // Reset The Projection Matrix
3782 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3783 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3784 glPushMatrix(); // Store The Modelview Matrix
3785 glLoadIdentity(); // Reset The Modelview Matrix
3787 glDisable(GL_TEXTURE_2D);
3788 if(transition<.1)glColor4f(1,0,0,1-(transition*10));
3789 if(transition>.9)glColor4f(1,0,0,1-((1-transition)*10));
3793 glVertex3f(190, 150, 0.0f);
3795 glVertex3f(640, 150, 0.0f);
3797 glVertex3f(640, 336, 0.0f);
3799 glVertex3f(190, 336, 0.0f);
3804 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3808 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3809 glPushMatrix(); // Store The Projection Matrix
3810 glLoadIdentity(); // Reset The Projection Matrix
3811 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
3812 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3813 glPushMatrix(); // Store The Modelview Matrix
3814 glLoadIdentity(); // Reset The Modelview Matrix
3815 glTranslatef(screenwidth/2,screenheight/2,0);
3817 glScalef((float)screenwidth/2,(float)screenheight/2,1);
3818 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3820 glEnable(GL_TEXTURE_2D);
3822 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
3823 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
3826 glTranslatef(mousecoordh-screenwidth/2,mousecoordv*-1+screenheight/2,0);
3827 glScalef((float)screenwidth/64,(float)screenwidth/64,1);
3828 glTranslatef(1,-1,0);
3829 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3831 glBindTexture( GL_TEXTURE_2D, cursortexture);
3833 //glScalef(.25,.25,.25);
3836 glVertex3f(-1, -1, 0.0f);
3838 glVertex3f(1, -1, 0.0f);
3840 glVertex3f(1, 1, 0.0f);
3842 glVertex3f(-1, 1, 0.0f);
3847 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3853 //printf("Flash amount: %f, delay %i\n", flashamount, flashdelay);
3854 if(flashamount>1)flashamount=1;
3855 if(flashdelay<=0)flashamount-=multiplier;
3857 if(flashamount<0)flashamount=0;
3858 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3859 glDisable(GL_CULL_FACE);
3860 glDisable(GL_LIGHTING);
3861 glDisable(GL_TEXTURE_2D);
3863 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3864 glPushMatrix(); // Store The Projection Matrix
3865 glLoadIdentity(); // Reset The Projection Matrix
3866 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
3867 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3868 glPushMatrix(); // Store The Modelview Matrix
3869 glLoadIdentity(); // Reset The Modelview Matrix
3870 glScalef(screenwidth,screenheight,1);
3871 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3873 glColor4f(flashr,flashg,flashb,flashamount);
3875 glVertex3f(0, 0, 0.0f);
3876 glVertex3f(256, 0, 0.0f);
3877 glVertex3f(256, 256, 0.0f);
3878 glVertex3f(0, 256, 0.0f);
3880 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3881 glPopMatrix(); // Restore The Old Projection Matrix
3882 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3883 glPopMatrix(); // Restore The Old Projection Matrix
3884 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
3885 glEnable(GL_CULL_FACE);
3886 glDisable(GL_BLEND);
3891 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)||(!gameon&&gamestarted)){
3892 tempmult=multiplier;
3897 if ( side == stereoRight || side == stereoCenter ) {
3898 if(drawmode!=motionblurmode||mainmenu){
3903 //myassert(glGetError() == GL_NO_ERROR);
3904 glDrawBuffer(GL_BACK);
3905 glReadBuffer(GL_BACK);
3910 if(drawtoggle==2)drawtoggle=0;
3912 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)){
3913 multiplier=tempmult;
3915 //Jordan fixed your warning!