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.
27 extern int environment;
28 extern float texscale;
30 extern Terrain terrain;
31 extern Sprites sprites;
32 extern float multiplier;
34 extern float viewdistance;
35 extern float fadestart;
36 extern float screenwidth,screenheight;
37 extern int kTextureSize;
38 extern FRUSTUM frustum;
40 extern Objects objects;
42 extern float usermousesensitivity;
44 extern float camerashake;
45 extern Weapons weapons;
46 extern Person player[maxplayers];
48 extern float slomodelay;
49 extern bool ismotionblur;
51 extern float blackout;
52 extern bool damageeffects;
54 extern int numplayers;
55 extern bool texttoggle;
56 extern float blurness;
57 extern float targetblurness;
58 extern float playerdist;
59 extern bool cellophane;
61 extern float flashamount,flashr,flashg,flashb;
62 extern int flashdelay;
64 extern float motionbluramount;
66 extern bool alwaysblur;
68 extern bool tilt2weird;
69 extern bool tiltweird;
71 extern bool proportionweird;
72 extern bool vertexweird[6];
73 extern bool velocityblur;
74 extern bool buttons[3];
75 extern bool debugmode;
77 extern int oldmainmenu;
78 extern int bloodtoggle;
79 extern int difficulty;
82 //extern int texdetail;
83 extern float texdetail;
84 extern bool musictoggle;
86 extern float bonusvalue;
87 extern float bonustotal;
88 extern float bonustime;
90 extern float startbonustotal;
91 extern float bonusnum[100];
92 extern int tutoriallevel;
93 extern float smoketex;
94 extern float tutorialstagetime;
95 extern float tutorialmaxtime;
96 extern int tutorialstage;
97 extern bool againbonus;
98 extern float damagedealt;
99 extern float damagetaken;
100 extern bool invertmouse;
102 extern int numhotspots;
103 extern int winhotspot;
104 extern int killhotspot;
105 extern XYZ hotspot[40];
106 extern int hotspottype[40];
107 extern float hotspotsize[40];
108 extern char hotspottext[40][256];
109 extern int currenthotspot;
111 extern int numaccounts;
112 extern int accountactive;
113 extern int accountdifficulty[10];
114 extern int accountprogress[10];
115 extern float accountpoints[10];
116 extern float accounthighscore[10][50];
117 extern float accountfasttime[10][50];
118 extern bool accountunlocked[10][60];
119 extern char accountname[10][256];
122 extern int numflipfail;
124 extern int numstaffattack;
125 extern int numswordattack;
126 extern int numknifeattack;
127 extern int numunarmedattack;
128 extern int numescaped;
129 extern int numflipped;
130 extern int numwallflipped;
131 extern int numthrowkill;
132 extern int numafterkill;
133 extern int numreversals;
134 extern int numattacks;
135 extern int maxalarmed;
136 extern int numresponded;
138 extern bool campaign;
139 extern bool winfreeze;
141 extern float menupulse;
143 extern bool gamestart;
145 extern int numdialogues;
146 extern int numdialogueboxes[max_dialogues];
147 extern int dialoguetype[max_dialogues];
148 extern int dialogueboxlocation[max_dialogues][max_dialoguelength];
149 extern float dialogueboxcolor[max_dialogues][max_dialoguelength][3];
150 extern int dialogueboxsound[max_dialogues][max_dialoguelength];
151 extern char dialoguetext[max_dialogues][max_dialoguelength][128];
152 extern char dialoguename[max_dialogues][max_dialoguelength][64];
153 extern XYZ dialoguecamera[max_dialogues][max_dialoguelength];
154 extern XYZ participantlocation[max_dialogues][10];
155 extern int participantfocus[max_dialogues][max_dialoguelength];
156 extern int participantaction[max_dialogues][max_dialoguelength];
157 extern float participantrotation[max_dialogues][10];
158 extern XYZ participantfacing[max_dialogues][max_dialoguelength][10];
159 extern float dialoguecamerarotation[max_dialogues][max_dialoguelength];
160 extern float dialoguecamerarotation2[max_dialogues][max_dialoguelength];
161 extern int indialogue;
162 extern int whichdialogue;
163 extern int directing;
164 extern float dialoguetime;
165 extern int dialoguegonethrough[20];
167 extern int accountcampaignchoicesmade[10];
168 extern int accountcampaignchoices[10][5000];
170 extern float accountcampaignhighscore[10];
171 extern float accountcampaignfasttime[10];
172 extern float accountcampaignscore[10];
173 extern float accountcampaigntime[10];
175 extern bool gamestarted;
177 extern FSOUND_SAMPLE *samp[100];
178 extern int channels[100];
179 extern "C" void PlaySoundEx(int channel, FSOUND_SAMPLE *sptr, FSOUND_DSPUNIT *dsp, signed char startpaused);
181 /*********************> DrawGLScene() <*****/
182 long long Game::MD5_string (char *string){
187 sprintf (temp, "%s",string);
190 while (i<256&&temp[i]!='\0'){
191 if(temp[i]%3==0)num+=temp[i]*124;
192 else if(temp[i]%3==1)num-=temp[i]*temp[i];
197 num=longlongabs(num);
200 while(num<LONGLONGCONST(5000000000000000)){
204 while(num>LONGLONGCONST(9900000000000000)){
210 //return 1111111111111111;
213 int Game::DrawGLScene(void)
215 static float texcoordwidth,texcoordheight;
216 static float texviewwidth, texviewheight;
218 static GLubyte color;
219 static float newbrightness;
220 static float changespeed;
221 static XYZ checkpoint;
222 static float tempmult;
224 static char string[256]="";
225 static char string2[256]="";
226 static char string3[256]="";
228 static float lastcheck;
230 lastcheck+=multiplier;
232 glColorMask( 1.0, 1.0, 1.0, 1.0 );
233 if(!registered)debugmode=0;
236 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)){
243 numboundaries=mapradius*2;
244 if(numboundaries>360)numboundaries=360;
245 for(i=0;i<numboundaries;i++){
248 boundary[i]=mapcenter+DoRotation(boundary[i]*mapradius,0,i*(360/((float)(numboundaries))),0);
257 olddrawmode=drawmode;
258 if(ismotionblur&&!loading){
259 if((findLengthfast(&player[0].velocity)>200)&&velocityblur&&!cameramode){
260 drawmode=motionblurmode;
261 motionbluramount=200/(findLengthfast(&player[0].velocity));
264 if(player[0].damage-player[0].superpermanentdamage>(player[0].damagetolerance-player[0].superpermanentdamage)*1/2&&damageeffects&&!cameramode){
265 drawmode=doublevisionmode;
272 drawmode=motionblurmode;
274 slomodelay-=multiplier;
275 if(slomodelay<0)slomo=0;
279 if((!changed&&!slomo)||loading){
281 if(ismotionblur&&(/*fps>100||*/alwaysblur)){
282 if(olddrawmode!=realmotionblurmode)change=1;
284 drawmode=realmotionblurmode;
286 else if(olddrawmode==realmotionblurmode)change=2;
290 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted))drawmode=normalmode;
291 if((freeze||winfreeze)&&ismotionblur&&!mainmenu)drawmode=radialzoommode;
293 if(winfreeze||mainmenu)drawmode=normalmode;
296 if(drawmode==glowmode){
302 DSpContext_FadeGamma(NULL,200,&color2);
306 if(drawtoggle!=2)drawtoggle=1-drawtoggle;
310 texviewwidth=kTextureSize;
311 if(texviewwidth>screenwidth)texviewwidth=screenwidth;
312 texviewheight=kTextureSize;
313 if(texviewheight>screenheight)texviewheight=screenheight;
315 texcoordwidth=screenwidth/kTextureSize;
316 texcoordheight=screenheight/kTextureSize;
317 if(texcoordwidth>1)texcoordwidth=1;
318 if(texcoordheight>1)texcoordheight=1;
321 glDrawBuffer(GL_BACK);
322 glReadBuffer(GL_BACK);
324 /*if(environment==desertenvironment)glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, (float)(abs(Random()%100))/50 );
325 else glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0);
327 if(abs(blurness-targetblurness)<multiplier*10||abs(blurness-targetblurness)>2){
328 blurness=targetblurness;
329 targetblurness=(float)(abs(Random()%100))/40;
331 if(blurness<targetblurness)blurness+=multiplier*5;
332 if(blurness>targetblurness)blurness-=multiplier*5;
335 static XYZ terrainlight;
336 static float distance;
337 //if(drawmode==normalmode)ReSizeGLScene(90,.1);
338 if(drawmode==normalmode)ReSizeGLScene(90,.1f);
339 if(drawmode!=normalmode)glViewport(0,0,texviewwidth,texviewheight);
340 glDepthFunc(GL_LEQUAL);
342 glAlphaFunc(GL_GREATER, 0.0001f);
343 glEnable(GL_ALPHA_TEST);
344 glClearColor(0.25f, 0.25f, 0.25f, 1.0f);
345 glClear(GL_DEPTH_BUFFER_BIT);
347 glMatrixMode (GL_MODELVIEW);
348 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
350 if(!cameramode&&!freeze&&!winfreeze){
351 glRotatef(float(Random()%100)/10*camerashake/*+(woozy*woozy)/10*/,0,0,1);
352 glRotatef(rotation2+sin(woozy/2)*(player[0].damage/player[0].damagetolerance)*5,1,0,0);
353 glRotatef(rotation+sin(woozy)*(player[0].damage/player[0].damagetolerance)*5,0,1,0);
355 if(cameramode||freeze||winfreeze){
356 //glRotatef(float(Random()%100)/10*camerashake/*+(woozy*woozy)/10*/,0,0,1);
357 glRotatef(rotation2,1,0,0);
358 glRotatef(rotation,0,1,0);
361 if(environment==desertenvironment){
362 glRotatef((float)(abs(Random()%100))/3000-1,1,0,0);
363 glRotatef((float)(abs(Random()%100))/3000-1,0,1,0);
364 //glRotatef(blurness/40-1,1,0,0);
365 //glRotatef(blurness/40-1,0,1,0);
367 SetUpLight(&light,0);
369 if(environment==desertenvironment&&detail==2)glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, blurness+.4 );
370 if(environment==desertenvironment){
371 glRotatef((float)(abs(Random()%100))/1000,1,0,0);
372 glRotatef((float)(abs(Random()%100))/1000,0,1,0);
375 glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0);
377 glTranslatef(-viewer.x,-viewer.y,-viewer.z);
378 frustum.GetFrustum();
382 static float size,opacity,rotation;
384 for(k=0;k<numplayers;k++){
385 if(!player[k].skeleton.free&&player[k].playerdetail&&player[k].howactive<typesleeping)
386 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)
387 for(i=0;i<player[k].skeleton.num_joints;i++){
388 if(player[k].skeleton.joints[i].label==leftknee||player[k].skeleton.joints[i].label==rightknee||player[k].skeleton.joints[i].label==groin){
389 point=DoRotation(player[k].skeleton.joints[i].position,0,player[k].rotation,0)*player[k].scale+player[k].coords;
391 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;
392 if(k!=0&&tutoriallevel==1){
393 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;
395 terrain.MakeDecal(shadowdecal,point,size,opacity,rotation);
396 if(terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz])
397 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
398 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
399 if(objects.position[j].y<player[k].coords.y||objects.type[j]==tunneltype||objects.type[j]==weirdtype){
400 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);
403 if(k!=0&&tutoriallevel==1){
404 opacity=.2+.2*sin(smoketex*6+i);
406 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
411 if((player[k].skeleton.free||player[k].howactive>=typesleeping)&&player[k].playerdetail)
412 if(frustum.SphereInFrustum(player[k].coords.x,player[k].coords.y,player[k].coords.z,player[k].scale*5)&&player[k].occluded<25)
413 for(i=0;i<player[k].skeleton.num_joints;i++){
414 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){
415 if(player[k].skeleton.free)point=player[k].skeleton.joints[i].position*player[k].scale+player[k].coords;
416 else point=DoRotation(player[k].skeleton.joints[i].position,0,player[k].rotation,0)*player[k].scale+player[k].coords;
418 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;
419 if(k!=0&&tutoriallevel==1){
420 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;
422 terrain.MakeDecal(shadowdecal,point,size,opacity*.7,rotation);
423 if(terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz])
424 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
425 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
426 if(objects.position[j].y<player[k].coords.y||objects.type[j]==tunneltype||objects.type[j]==weirdtype){
427 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);
428 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);
431 if(k!=0&&tutoriallevel==1){
432 opacity=.2+.2*sin(smoketex*6+i);
434 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
440 if(!player[k].playerdetail)
441 if(frustum.SphereInFrustum(player[k].coords.x,player[k].coords.y,player[k].coords.z,player[k].scale*5))
443 point=player[k].coords;
445 opacity=.4-(player[k].coords.y-terrain.getHeight(player[k].coords.x,player[k].coords.z))/5;
446 terrain.MakeDecal(shadowdecal,point,size,opacity*.7,rotation);
447 if(terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz])
448 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
449 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
450 point=DoRotation(player[k].coords-objects.position[j],0,-objects.rotation[j],0);
453 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
459 glEnable(GL_TEXTURE_2D);
461 glEnable(GL_DEPTH_TEST);
462 glEnable(GL_CULL_FACE);
464 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
465 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
466 glBindTexture( GL_TEXTURE_2D, terraintexture);
468 glBindTexture( GL_TEXTURE_2D, terraintexture2);
470 //glBindTexture( GL_TEXTURE_2D, terraintexture3);
471 //glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
474 terrain.drawdecals();
477 glEnable(GL_CULL_FACE);
478 glEnable(GL_LIGHTING);
480 glEnable(GL_TEXTURE_2D);
483 glEnable(GL_COLOR_MATERIAL);
498 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
499 glEnable(GL_CULL_FACE);
500 glCullFace(GL_FRONT);
502 for(k=0;k<numplayers;k++){
503 if(k==0||tutoriallevel!=1){
505 glEnable(GL_LIGHTING);
506 terrainlight=terrain.getLighting(player[k].coords.x,player[k].coords.z);
507 distance=findDistancefast(&viewer,&player[k].coords);
508 distance=(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance;
509 glColor4f(terrainlight.x,terrainlight.y,terrainlight.z,distance);
510 if(distance>=1)glDisable(GL_BLEND);
512 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;
514 if(!player[k].occluded==0)i=checkcollide(viewer,checkpoint,player[k].lastoccluded);
515 if(i==-1||player[k].occluded==0)i=checkcollide(viewer,checkpoint);
517 player[k].occluded+=1;
518 player[k].lastoccluded=i;
520 else player[k].occluded=0;
521 if(player[k].occluded<25)player[k].DrawSkeleton();
527 if(!cameramode&&musictype==stream_music2)playerdist=findDistancefastflat(&player[0].coords,&viewer);
528 else playerdist=-100;
531 glEnable(GL_TEXTURE_2D);
536 if(frustum.SphereInFrustum(realhawkcoords.x+hawk.boundingspherecenter.x,realhawkcoords.y+hawk.boundingspherecenter.y,realhawkcoords.z+hawk.boundingspherecenter.z,2)){
537 glAlphaFunc(GL_GREATER, 0.0001f);
539 glDisable(GL_CULL_FACE);
540 glDisable(GL_LIGHTING);
542 glTranslatef(hawkcoords.x,hawkcoords.y,hawkcoords.z);
543 glRotatef(hawkrotation,0,1,0);
544 glTranslatef(25,0,0);
545 distance=findDistancefast(&viewer,&realhawkcoords)*1.2;
546 glColor4f(light.color[0],light.color[1],light.color[2],(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance);
547 if((viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance>1)glColor4f(light.color[0],light.color[1],light.color[2],1);
548 if((viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance>0)
549 hawk.drawdifftex(hawktexture);
554 /*glEnable(GL_CULL_FACE);
555 glCullFace(GL_FRONT);
557 for(k=0;k<numplayers;k++){
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(checkcollide(viewer,checkpoint)){
569 player[k].occluded+=1;
571 else player[k].occluded=0;
572 if(player[k].occluded<25)player[k].DrawSkeleton();
576 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
577 glEnable(GL_CULL_FACE);
578 glCullFace(GL_FRONT);
580 for(k=0;k<numplayers;k++){
581 if(!(k==0||tutoriallevel!=1)){
583 glEnable(GL_LIGHTING);
584 terrainlight=terrain.getLighting(player[k].coords.x,player[k].coords.z);
585 distance=findDistancefast(&viewer,&player[k].coords);
586 distance=(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance;
587 glColor4f(terrainlight.x,terrainlight.y,terrainlight.z,distance);
588 if(distance>=1)glDisable(GL_BLEND);
590 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;
592 if(!player[k].occluded==0)i=checkcollide(viewer,checkpoint,player[k].lastoccluded);
593 if(i==-1||player[k].occluded==0)i=checkcollide(viewer,checkpoint);
595 player[k].occluded+=1;
596 player[k].lastoccluded=i;
598 else player[k].occluded=0;
599 if(player[k].occluded<25)player[k].DrawSkeleton();
606 glEnable(GL_TEXTURE_2D);
611 glDisable(GL_COLOR_MATERIAL);
613 glDisable(GL_LIGHTING);
614 glDisable(GL_TEXTURE_2D);
622 glDisable(GL_LIGHTING);
623 glDisable(GL_TEXTURE_2D);
624 glDisable(GL_COLOR_MATERIAL);
627 for(k=0;k<numplayers;k++){
628 if(player[k].numwaypoints>1){
629 glBegin(GL_LINE_LOOP);
630 for(i=0;i<player[k].numwaypoints;i++){
631 glVertex3f(player[k].waypoints[i].x,player[k].waypoints[i].y+.5,player[k].waypoints[i].z);
640 for(k=0;k<numpathpoints;k++){
641 if(numpathpointconnect[k]){
642 for(i=0;i<numpathpointconnect[k];i++){
643 glBegin(GL_LINE_LOOP);
644 glVertex3f(pathpoint[k].x,pathpoint[k].y+.5,pathpoint[k].z);
645 glVertex3f(pathpoint[pathpointconnect[k][i]].x,pathpoint[pathpointconnect[k][i]].y+.5,pathpoint[pathpointconnect[k][i]].z);
653 glVertex3f(pathpoint[pathpointselected].x,pathpoint[pathpointselected].y+.5,pathpoint[pathpointselected].z);
660 glEnable(GL_TEXTURE_2D);
661 glColor4f(.5,.5,.5,1);
663 sprintf (string, " ",(int)(fps));
664 text.glPrint(10,30,string,0,.8,screenwidth,screenheight);
667 if(bonus>0&&bonustime<1&&!winfreeze&&indialogue==-1/*bonustime<4*/){
668 if(bonus==tracheotomy)sprintf (string, "Tracheotomy!");
669 else if(bonus==backstab)sprintf (string, "Backstabber!");
670 else if(bonus==spinecrusher)sprintf (string, "Spinecrusher!");
671 else if(bonus==ninja)sprintf (string, "Ninja Bonus!");
672 else if(bonus==style)sprintf (string, "Style Bonus!");
673 else if(bonus==cannon)sprintf (string, "Leg Cannon!");
674 else if(bonus==aimbonus)sprintf (string, "Nice Aim!");
675 else if(bonus==deepimpact)sprintf (string, "Heavy Impact!");
676 else if(bonus==touchofdeath)sprintf (string, "Touch of Death!");
677 else if(bonus==swordreversebonus)sprintf (string, "Sword Disarm!");
678 else if(bonus==staffreversebonus)sprintf (string, "Staff Disarm!");
679 else if(bonus==reverseko)sprintf (string, "Reversal KO!");
680 else if(bonus==solidhit)sprintf (string, "Solid Hit!");
681 else if(bonus==twoxcombo)sprintf (string, "2X Combo!");
682 else if(bonus==threexcombo)sprintf (string, "3X Combo!");
683 else if(bonus==fourxcombo)sprintf (string, "4X COMBO!");
684 else if(bonus==megacombo)sprintf (string, "MEGA COMBO!");
685 else if(bonus==Reversal)sprintf (string, "Reversal!");
686 else if(bonus==Stabbonus)sprintf (string, "Punctured!");
687 else if(bonus==Slicebonus)sprintf (string, "Sliced!");
688 else if(bonus==Bullseyebonus)sprintf (string, "Bullseye!");
689 else if(bonus==Slashbonus)sprintf (string, "Slashed!");
690 else if(bonus==Wolfbonus)sprintf (string, "WOLF SLAYER!");
691 else if(bonus==FinishedBonus)sprintf (string, "SLAIN!");
692 else if(bonus==TackleBonus)sprintf (string, "Tackle!");
693 else if(bonus==AboveBonus)sprintf (string, "Death from Above!");
694 else sprintf (string, "Excellent!");
696 glColor4f(0,0,0,1-bonustime);
697 text.glPrintOutline(1024/2-10*strlen(string)-4,768/16-4+768*4/5,string,1,2.5,1024,768);
698 glColor4f(1,0,0,1-bonustime);
699 text.glPrint(1024/2-10*strlen(string),768/16+768*4/5,string,1,2,1024,768);
701 sprintf (string, "%d",(int)bonusvalue);
702 glColor4f(0,0,0,1-bonustime);
703 text.glPrintOutline(1024/2-10*strlen(string)-4,768/16-4-20+768*4/5,string,1,2.5*.8,1024,768);
704 glColor4f(1,0,0,1-bonustime);
705 text.glPrint(1024/2-10*strlen(string),768/16-20+768*4/5,string,1,2*.8,1024,768);
706 glColor4f(.5,.5,.5,1);
709 if(tutoriallevel==1){
710 tutorialopac=tutorialmaxtime-tutorialstagetime;
711 if(tutorialopac>1)tutorialopac=1;
712 if(tutorialopac<0)tutorialopac=0;
714 sprintf (string, " ");
715 sprintf (string2, " ");
716 sprintf (string3, " ");
717 if(tutorialstage==0){
718 sprintf (string, " ");
719 sprintf (string2, " ");
720 sprintf (string3, " ");
722 if(tutorialstage==1){
723 sprintf (string, "Welcome to the Lugaru training level!");
724 sprintf (string2, " ");
725 sprintf (string3, " ");
727 if(tutorialstage==2){
728 sprintf (string, "BASIC MOVEMENT:");
729 sprintf (string2, " ");
730 sprintf (string3, " ");
732 if(tutorialstage==3){
733 sprintf (string, "You can move the mouse to rotate the camera.");
734 sprintf (string2, " ");
735 sprintf (string3, " ");
737 if(tutorialstage==4){
738 sprintf (string, "Try using the %s, %s, %s and %s keys to move around.",KeyToChar(forwardkey),KeyToChar(leftkey),KeyToChar(backkey),KeyToChar(rightkey));
739 sprintf (string2, "All movement is relative to the camera.");
740 sprintf (string3, " ");
742 if(tutorialstage==5){
743 sprintf (string, "Please press %s to jump.",KeyToChar(jumpkey));
744 sprintf (string2, "You can hold it longer to jump higher.");
745 sprintf (string3, " ");
747 if(tutorialstage==6){
748 sprintf (string, "You can press %s to crouch.",KeyToChar(crouchkey));
749 sprintf (string2, "You can jump higher from a crouching position.");
750 sprintf (string3, " ");
752 if(tutorialstage==7){
753 sprintf (string, "While running, you can press %s to roll.",KeyToChar(crouchkey));
754 sprintf (string2, " ");
755 sprintf (string3, " ");
757 if(tutorialstage==8){
758 sprintf (string, "While crouching, you can sneak around silently");
759 sprintf (string2, "using the movement keys.");
760 sprintf (string3, " ");
762 if(tutorialstage==9){
763 sprintf (string, "Release the crouch key while sneaking and hold the movement keys");
764 sprintf (string2, "to run animal-style.");
765 sprintf (string3, " ");
767 if(tutorialstage==10){
768 sprintf (string, "ADVANCED MOVEMENT:");
769 sprintf (string2, " ");
770 sprintf (string3, " ");
772 if(tutorialstage==11){
773 sprintf (string, "When you jump at a wall, you can hold %s again",KeyToChar(jumpkey));
774 sprintf (string2, "during impact to perform a walljump.");
775 sprintf (string3, "Be sure to use the movement keys to press against the wall");
777 if(tutorialstage==12){
778 sprintf (string, "While in the air, you can press crouch to flip.",KeyToChar(jumpkey));
779 sprintf (string2, "Walljumps and flips confuse enemies and give you more control.");
780 sprintf (string3, " ");
782 if(tutorialstage==13){
783 sprintf (string, "BASIC COMBAT:");
784 sprintf (string2, " ");
785 sprintf (string3, " ");
787 if(tutorialstage==14){
788 sprintf (string, "There is now an imaginary enemy");
789 sprintf (string2, "in the middle of the training area.");
790 sprintf (string3, " ");
792 if(tutorialstage==15){
793 if(attackkey==MAC_MOUSEBUTTON1)sprintf (string, "Click to attack when you are near an enemy.");
794 else sprintf (string, "Press %s to attack when you are near an enemy.",KeyToChar(attackkey));
795 sprintf (string2, "You can punch by standing still near an enemy and attacking.");
796 sprintf (string3, " ");
798 if(tutorialstage==16){
799 sprintf (string, "If you are close, you will perform a weak punch.");
800 sprintf (string2, "The weak punch is excellent for starting attack combinations.");
801 sprintf (string3, " ");
803 if(tutorialstage==17){
804 sprintf (string, "Attacking while running results in a spin kick.");
805 sprintf (string2, "This is one of your most powerful ground attacks.");
806 sprintf (string3, " ");
808 if(tutorialstage==18){
809 sprintf (string, "Sweep the enemy's legs out by attacking while crouched.");
810 sprintf (string2, "This is a very fast attack, and easy to follow up.");
811 sprintf (string3, " ");
813 if(tutorialstage==19){
814 sprintf (string, "When an enemy is on the ground, you can deal some extra");
815 sprintf (string2, "damage by running up and drop-kicking him.");
816 sprintf (string3, "(Try knocking them down with a sweep first)");
818 if(tutorialstage==20){
819 sprintf (string, "Your most powerful individual attack is the rabbit kick.");
820 if(attackkey==MAC_MOUSEBUTTON1)sprintf (string2, "Run at the enemy while holding the mouse button, and press");
821 else sprintf (string2, "Run at the enemy while holding %s, and press", KeyToChar(attackkey));
822 sprintf (string3, "the jump key (%s) to attack.",KeyToChar(jumpkey));
824 if(tutorialstage==21){
825 sprintf (string, "This attack is devastating if timed correctly.");
826 sprintf (string2, "Even if timed incorrectly, it will knock the enemy over.");
827 if(againbonus)sprintf (string3, "Try rabbit-kicking the imaginary enemy again.");
828 else sprintf (string3, "Try rabbit-kicking the imaginary enemy.");
830 if(tutorialstage==22){
831 sprintf (string, "If you sneak behind an enemy unnoticed, you can kill");
832 sprintf (string2, "him instantly. Move close behind this enemy");
833 sprintf (string3, "and attack.");
835 if(tutorialstage==23){
836 sprintf (string, "Another important attack is the wall kick. When an enemy");
837 sprintf (string2, "is near a wall, perform a walljump nearby and hold");
838 sprintf (string3, "the attack key during impact with the wall.");
840 if(tutorialstage==24){
841 sprintf (string, "You can tackle enemies by running at them animal-style");
842 if(attackkey==MAC_MOUSEBUTTON1)sprintf (string2, "and pressing jump (%s) or attack(mouse button).",KeyToChar(jumpkey));
843 else sprintf (string2, "and pressing jump (%s) or attack(%s).",KeyToChar(jumpkey),KeyToChar(attackkey));
844 sprintf (string3, "This is especially useful when they are running away.");
846 if(tutorialstage==25){
847 sprintf (string, "Dodge by pressing back and attack. Dodging is essential");
848 sprintf (string2, "against enemies with swords or other long weapons.");
849 sprintf (string3, " ");
851 if(tutorialstage==26){
852 sprintf (string, "REVERSALS AND COUNTER-REVERSALS");
853 sprintf (string2, " ");
854 sprintf (string3, " ");
856 if(tutorialstage==27){
857 sprintf (string, "The enemy can now reverse your attacks.");
858 sprintf (string2, " ");
859 sprintf (string3, " ");
861 if(tutorialstage==28){
862 sprintf (string, "If you attack, you will notice that the enemy now sometimes");
863 sprintf (string2, "catches your attack and uses it against you. Hold");
864 sprintf (string3, "crouch (%s) after attacking to escape from reversals.",KeyToChar(crouchkey));
866 if(tutorialstage==29){
867 sprintf (string, "Try escaping from two more reversals in a row.");
868 sprintf (string2, " ");
869 sprintf (string3, " ");
871 if(tutorialstage==30){
872 sprintf (string, "Good!");
873 sprintf (string2, " ");
874 sprintf (string3, " ");
876 if(tutorialstage==31){
877 sprintf (string, "To reverse an attack, you must tap crouch (%s) during the",KeyToChar(crouchkey));
878 sprintf (string2, "enemy's attack. You must also be close to the enemy;");
879 sprintf (string3, "this is especially important against armed opponents.");
881 if(tutorialstage==32){
882 sprintf (string, "The enemy can attack in %d seconds.", (int)(tutorialmaxtime-tutorialstagetime));
883 sprintf (string2, "This imaginary opponents attacks will be highlighted");
884 sprintf (string3, "to make this easier.");
886 if(tutorialstage==33){
887 sprintf (string, "Reverse three enemy attacks!");
888 sprintf (string2, " ");
889 sprintf (string3, " ");
891 if(tutorialstage==34){
892 sprintf (string, "Reverse two more enemy attacks!");
893 sprintf (string2, " ");
894 sprintf (string3, " ");
896 if(tutorialstage==35){
897 sprintf (string, "Reverse one more enemy attack!");
898 sprintf (string2, " ");
899 sprintf (string3, " ");
901 if(tutorialstage==36){
902 sprintf (string, "Excellent!");
903 sprintf (string2, " ");
904 sprintf (string3, " ");
906 if(tutorialstage==37){
907 sprintf (string, "Now spar with the enemy for %d more seconds.", (int)(tutorialmaxtime-tutorialstagetime));
908 sprintf (string2, "Damage dealt: %d",(int)damagedealt);
909 sprintf (string3, "Damage taken: %d.",(int)damagetaken);
911 if(tutorialstage==38){
912 sprintf (string, "WEAPONS:");
913 sprintf (string2, " ");
914 sprintf (string3, " ");
916 if(tutorialstage==39){
917 sprintf (string, "There is now an imaginary knife");
918 sprintf (string2, "in the center of the training area.");
919 sprintf (string3, " ");
921 if(tutorialstage==40){
922 sprintf (string, "Stand, roll or handspring over the knife");
923 sprintf (string2, "while pressing %s to pick it up.",KeyToChar(throwkey));
924 sprintf (string3, "You can crouch and press the same key to drop it again.");
926 if(tutorialstage==41){
927 sprintf (string, "You can equip and unequip weapons using the %s key.",KeyToChar(drawkey));
928 sprintf (string2, "Sometimes it is best to keep them unequipped to");
929 sprintf (string3, "prevent enemies from taking them. ");
931 if(tutorialstage==42){
932 sprintf (string, "The knife is the smallest weapon and the least encumbering.");
933 sprintf (string2, "You can equip or unequip it while standing, crouching,");
934 sprintf (string3, "running or flipping.");
936 if(tutorialstage==43){
937 sprintf (string, "You perform weapon attacks the same way as unarmed attacks,");
938 sprintf (string2, "but sharp weapons cause permanent damage, instead of the");
939 sprintf (string3, "temporary trauma from blunt weapons, fists and feet.");
941 if(tutorialstage==44){
942 sprintf (string, "The enemy now has your knife!");
943 sprintf (string2, "Please reverse two of his knife attacks.");
944 sprintf (string3, " ");
946 if(tutorialstage==45){
947 sprintf (string, "Please reverse one more of his knife attacks.");
948 sprintf (string2, " ");
949 sprintf (string3, " ");
951 if(tutorialstage==46){
952 sprintf (string, "Now he has a sword!");
953 sprintf (string2, "The sword has longer reach than your arms, so you");
954 sprintf (string3, "must move close to reverse the sword slash.");
956 if(tutorialstage==47){
957 sprintf (string, "Long weapons like the sword and staff are also useful for defense;");
958 sprintf (string2, "you can parry enemy weapon attacks by pressing the attack key");
959 sprintf (string3, "at the right time. Please try parrying the enemy's attacks!");
961 if(tutorialstage==48){
962 sprintf (string, "The staff is like the sword, but has two main attacks.");
963 sprintf (string2, "The standing smash is fast and effective, and the running");
964 sprintf (string3, "spin smash is slower and more powerful.");
966 if(tutorialstage==49){
967 sprintf (string, "When facing an enemy, you can throw the knife with %s.",KeyToChar(throwkey));
968 sprintf (string2, "It is possible to throw the knife while flipping,");
969 sprintf (string3, "but it is very inaccurate.");
971 if(tutorialstage==50){
972 sprintf (string, "You now know everything you can learn from training.");
973 sprintf (string2, "Everything else you must learn from experience!");
974 sprintf (string3, " ");
976 if(tutorialstage==51){
977 sprintf (string, "Walk out of the training area to return to the main menu.");
978 sprintf (string2, " ");
979 sprintf (string3, " ");
982 glColor4f(0,0,0,tutorialopac);
983 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);
984 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);
985 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);
986 glColor4f(1,1,1,tutorialopac);
987 text.glPrint(screenwidth/2-7.6*strlen(string)*screenwidth/1024,screenheight/16+screenheight*4/5,string,1,1.5*screenwidth/1024,screenwidth,screenheight);
988 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);
989 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);
991 sprintf (string, "Press 'tab' to skip to the next item.",KeyToChar(jumpkey));
992 sprintf (string2, "Press escape at any time to");
993 sprintf (string3, "pause or exit the tutorial.");
996 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);
997 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);
998 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);
999 glColor4f(0.5,0.5,0.5,1);
1000 text.glPrint(screenwidth/2-7.6*strlen(string)*screenwidth/1024*.8,0+screenheight*1/10,string,1,1.5*screenwidth/1024*.8,screenwidth,screenheight);
1001 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);
1002 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);
1006 if(numhotspots&&(bonustime>=1||bonus<=0||bonustime<0)&&!tutoriallevel){
1008 float closestdist=-1;
1010 closest=currenthotspot;
1011 for(i=0;i<numhotspots;i++){
1012 distance=findDistancefast(&player[0].coords,&hotspot[i]);
1013 if(closestdist==-1||distance<closestdist){
1014 if(findDistancefast(&player[0].coords,&hotspot[i])<hotspotsize[i]&&((hotspottype[i]<=10&&hotspottype[i]>=0)||(hotspottype[i]<=40&&hotspottype[i]>=20))){
1015 closestdist=distance;
1021 currenthotspot=closest;
1022 if(currenthotspot!=-1){
1023 if(hotspottype[closest]<=10){
1024 if(findDistancefast(&player[0].coords,&hotspot[closest])<hotspotsize[closest])
1025 tutorialstagetime=0;
1027 tutorialopac=tutorialmaxtime-tutorialstagetime;
1028 if(tutorialopac>1)tutorialopac=1;
1029 if(tutorialopac<0)tutorialopac=0;
1031 sprintf (string, "%s", hotspottext[closest]);
1039 if(string[i]=='\n'||string[i]>'z'||string[i]<' '||string[i]=='\0'){
1040 glColor4f(0,0,0,tutorialopac);
1041 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);
1042 glColor4f(1,1,1,tutorialopac);
1043 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);
1046 if(string[i]=='\0')done=1;
1052 else if (hotspottype[closest]>=20&&dialoguegonethrough[hotspottype[closest]-20]==0){
1053 whichdialogue=hotspottype[closest]-20;
1054 for(j=0;j<numdialogueboxes[whichdialogue];j++){
1055 player[participantfocus[whichdialogue][j]].coords=participantlocation[whichdialogue][participantfocus[whichdialogue][j]];
1056 player[participantfocus[whichdialogue][j]].rotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
1057 player[participantfocus[whichdialogue][j]].targetrotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
1058 player[participantfocus[whichdialogue][j]].velocity=0;
1059 player[participantfocus[whichdialogue][j]].targetanimation=player[participantfocus[whichdialogue][j]].getIdle();
1060 player[participantfocus[whichdialogue][j]].targetframe=0;
1064 dialoguegonethrough[whichdialogue]++;
1065 if(dialogueboxsound[whichdialogue][indialogue]!=0){
1066 static float gLoc[3];
1067 static float vel[3];
1068 gLoc[0]=player[participantfocus[whichdialogue][indialogue]].coords.x;
1069 gLoc[1]=player[participantfocus[whichdialogue][indialogue]].coords.y;
1070 gLoc[2]=player[participantfocus[whichdialogue][indialogue]].coords.z;
1075 if(dialogueboxsound[whichdialogue][indialogue]==1)whichsoundplay=rabbitchitter;
1076 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
1077 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
1078 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
1079 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
1080 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
1081 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
1082 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
1083 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
1084 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
1085 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
1086 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
1087 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
1088 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
1089 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
1090 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
1091 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
1092 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
1093 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
1094 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
1095 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, true);
1096 FSOUND_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
1097 FSOUND_SetVolume(channels[whichsoundplay], 256);
1098 FSOUND_SetPaused(channels[whichsoundplay], false);
1104 if(indialogue!=-1&&!mainmenu){
1105 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1106 glDisable(GL_CULL_FACE);
1107 glDisable(GL_LIGHTING);
1108 glDisable(GL_TEXTURE_2D);
1110 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1111 glPushMatrix(); // Store The Projection Matrix
1112 glLoadIdentity(); // Reset The Projection Matrix
1113 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1114 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1115 glPushMatrix(); // Store The Modelview Matrix
1116 glLoadIdentity(); // Reset The Modelview Matrix
1117 if(dialogueboxlocation[whichdialogue][indialogue]==1)glTranslatef(0,screenheight*3/4,0);
1118 glScalef(screenwidth,screenheight/4,1);
1119 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1122 glColor4f(dialogueboxcolor[whichdialogue][indialogue][0],dialogueboxcolor[whichdialogue][indialogue][1],dialogueboxcolor[whichdialogue][indialogue][2],0.7);
1124 glVertex3f(0, 0, 0.0f);
1125 glVertex3f(1, 0, 0.0f);
1126 glVertex3f(1, 1, 0.0f);
1127 glVertex3f(0, 1, 0.0f);
1129 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1130 glPopMatrix(); // Restore The Old Projection Matrix
1131 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1132 glPopMatrix(); // Restore The Old Projection Matrix
1133 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1134 glEnable(GL_CULL_FACE);
1135 glDisable(GL_BLEND);
1137 glEnable(GL_TEXTURE_2D);
1144 startx=screenwidth*1/5;
1145 if(dialogueboxlocation[whichdialogue][indialogue]==1)starty=screenheight/16+screenheight*4/5;
1146 if(dialogueboxlocation[whichdialogue][indialogue]==2)starty=screenheight*1/5-screenheight/16;
1148 // char tempname[64];
1152 // for(i=0;i<64;i++){
1157 for(i=0;i<(int)strlen(dialoguename[whichdialogue][indialogue]);i++){
1158 tempname[tempnum]=dialoguename[whichdialogue][indialogue][i];
1160 if(dialoguename[whichdialogue][indialogue][i]=='#'||dialoguename[whichdialogue][indialogue][i]=='\0')goodchar=0;
1161 //if(tempnum>2)if(tempname[tempnum-2]=='e'&&tempname[tempnum-1]=='r')goodchar=0;
1162 //if(tempnum>2)if(tempname[tempnum]=='r'&&tempname[0]=='a')goodchar=0;
1163 if(goodchar)tempnum++;
1164 else tempname[tempnum]='\0';
1167 sprintf (string, "%s: ", tempname);
1169 if(dialogueboxcolor[whichdialogue][indialogue][0]+dialogueboxcolor[whichdialogue][indialogue][1]+dialogueboxcolor[whichdialogue][indialogue][2]<1.5){
1170 glColor4f(0,0,0,tutorialopac);
1171 text.glPrintOutline(startx-2*7.6*strlen(string)*screenwidth/1024-4,starty-4,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight);
1172 glColor4f(0.7,0.7,0.7,tutorialopac);
1173 text.glPrint(startx-2*7.6*strlen(string)*screenwidth/1024,starty,string,1,1.5*screenwidth/1024,screenwidth,screenheight);
1177 glColor4f(0,0,0,tutorialopac);
1178 text.glPrintOutline(startx-2*7.6*strlen(string)*screenwidth/1024-4,starty-4,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight);
1183 for(i=0;i<(int)strlen(dialoguetext[whichdialogue][indialogue])+1;i++){
1184 tempname[tempnum]=dialoguetext[whichdialogue][indialogue][i];
1185 if(dialoguetext[whichdialogue][indialogue][i]!='#')tempnum++;
1189 sprintf (string, "%s", tempname);
1198 if(string[i]=='\n'||string[i]>'z'||string[i]<' '||string[i]=='\0'){
1199 if(dialogueboxcolor[whichdialogue][indialogue][0]+dialogueboxcolor[whichdialogue][indialogue][1]+dialogueboxcolor[whichdialogue][indialogue][2]<1.5){
1200 glColor4f(0,0,0,tutorialopac);
1201 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);
1202 glColor4f(1,1,1,tutorialopac);
1203 text.glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/,starty-20*screenwidth/1024*line,string,1,1.5*screenwidth/1024,screenwidth,screenheight,lastline,i);
1207 glColor4f(0,0,0,tutorialopac);
1208 text.glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/,starty-20*screenwidth/1024*line,string,1,1.5*screenwidth/1024,screenwidth,screenheight,lastline,i);
1212 if(string[i]=='\0')done=1;
1219 if(!tutoriallevel&&!winfreeze&&indialogue==-1&&!mainmenu){
1221 if(!scoreadded)sprintf (string, "Score: %d", (int)accountcampaignscore[accountactive]+(int)bonustotal);//(int)bonustotal);
1222 if(scoreadded)sprintf (string, "Score: %d", (int)accountcampaignscore[accountactive]);//(int)bonustotal);
1224 if(!campaign)sprintf (string, "Score: %d", (int)bonustotal);
1226 text.glPrintOutline(1024/40-4,768/16-4+768*14/16,string,1,1.5*1.25,1024,768);
1228 text.glPrint(1024/40,768/16+768*14/16,string,1,1.5,1024,768);
1231 glColor4f(.5,.5,.5,1);
1234 if((texttoggle||editorenabled)&&debugmode&&!mainmenu){
1235 sprintf (string, "The framespersecond is %d.",(int)(fps));
1236 text.glPrint(10,30,string,0,.8,1024,768);
1238 sprintf (string, "Name: %s", registrationname);
1239 text.glPrint(10,260,string,0,.8,1024,768);
1242 if(editorenabled)sprintf (string, "Map editor enabled.");
1243 if(!editorenabled)sprintf (string, "Map editor Disabled.");
1244 text.glPrint(10,60,string,0,.8,1024,768);
1246 sprintf (string, "Object size: %f",editorsize);
1247 text.glPrint(10,75,string,0,.8,1024,768);
1248 if(editorrotation>=0)sprintf (string, "Object rotation: %f",editorrotation);
1249 else sprintf (string, "Object rotation: Random");
1250 text.glPrint(10,90,string,0,.8,1024,768);
1251 if(editorrotation2>=0)sprintf (string, "Object rotation2: %f",editorrotation2);
1252 else sprintf (string, "Object rotation2: Random");
1253 text.glPrint(10,105,string,0,.8,1024,768);
1254 sprintf (string, "Object type: %d",editortype);
1255 text.glPrint(10,120,string,0,.8,1024,768);
1256 if(editortype==boxtype)sprintf (string, "(box)");
1257 if(editortype==treetrunktype)sprintf (string, "(tree)");
1258 if(editortype==walltype)sprintf (string, "(wall)");
1259 if(editortype==weirdtype)sprintf (string, "(weird)");
1260 if(editortype==spiketype)sprintf (string, "(spike)");
1261 if(editortype==rocktype)sprintf (string, "(rock)");
1262 if(editortype==bushtype)sprintf (string, "(bush)");
1263 if(editortype==tunneltype)sprintf (string, "(tunnel)");
1264 if(editortype==chimneytype)sprintf (string, "(chimney)");
1265 if(editortype==platformtype)sprintf (string, "(platform)");
1266 if(editortype==cooltype)sprintf (string, "(cool)");
1267 if(editortype==firetype)sprintf (string, "(fire)");
1268 text.glPrint(130,120,string,0,.8,1024,768);
1270 sprintf (string, "Numplayers: %d",numplayers);
1271 text.glPrint(10,155,string,0,.8,1024,768);
1272 sprintf (string, "Player %d: numwaypoints: %d",numplayers,player[numplayers-1].numwaypoints);
1273 text.glPrint(10,140,string,0,.8,1024,768);
1275 /*sprintf (string, "Coords are: %f %f %f",player[0].coords.x,player[0].coords.y,player[0].coords.z);
1276 text.glPrint(10,200,string,0,.8,1024,768);*/
1277 sprintf (string, "Difficulty: %d",difficulty);
1278 text.glPrint(10,240,string,0,.8,1024,768);
1280 sprintf (string, "lasthotspot: %d",hotspottype[numhotspots-1]);
1281 text.glPrint(10,240,string,0,.8,1024,768);
1282 sprintf (string, "killhotspot: %d",killhotspot);
1283 text.glPrint(10,220,string,0,.8,1024,768);
1284 sprintf (string, "winhotspot: %d",winhotspot);
1285 text.glPrint(10,200,string,0,.8,1024,768);*/
1290 if(drawmode==glowmode){
1291 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1292 glDisable(GL_CULL_FACE);
1293 glDisable(GL_LIGHTING);
1294 glDisable(GL_TEXTURE_2D);
1296 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1297 glPushMatrix(); // Store The Projection Matrix
1298 glLoadIdentity(); // Reset The Projection Matrix
1299 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1300 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1301 glPushMatrix(); // Store The Modelview Matrix
1302 glLoadIdentity(); // Reset The Modelview Matrix
1303 glScalef(screenwidth,screenheight,1);
1304 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1306 glColor4f(0,0,0,.5);
1308 glVertex3f(0, 0, 0.0f);
1309 glVertex3f(256, 0, 0.0f);
1310 glVertex3f(256, 256, 0.0f);
1311 glVertex3f(0, 256, 0.0f);
1313 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1314 glPopMatrix(); // Restore The Old Projection Matrix
1315 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1316 glPopMatrix(); // Restore The Old Projection Matrix
1317 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1318 glEnable(GL_CULL_FACE);
1319 glDisable(GL_BLEND);
1323 if((((blackout&&damageeffects)||(player[0].bloodloss>0&&damageeffects&&player[0].blooddimamount>0)||player[0].dead)&&!cameramode)||console){
1324 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1325 glDisable(GL_CULL_FACE);
1326 glDisable(GL_LIGHTING);
1327 glDisable(GL_TEXTURE_2D);
1329 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1330 glPushMatrix(); // Store The Projection Matrix
1331 glLoadIdentity(); // Reset The Projection Matrix
1332 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1333 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1334 glPushMatrix(); // Store The Modelview Matrix
1335 glLoadIdentity(); // Reset The Modelview Matrix
1336 glScalef(screenwidth,screenheight,1);
1337 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1339 if(player[0].dead)blackout+=multiplier*3;
1340 if(player[0].dead==1)blackout=.4f;
1341 if(player[0].dead==2&&blackout>.6)blackout=.6;
1342 glColor4f(0,0,0,blackout);
1343 if(!player[0].dead){
1344 if((player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5))*.3<.3){
1345 glColor4f(0,0,0,player[0].blooddimamount*player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5)*.3);
1346 blackout=player[0].blooddimamount*player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5)*.3;
1349 glColor4f(0,0,0,player[0].blooddimamount*.3);
1350 blackout=player[0].blooddimamount*.3;
1353 if(console)glColor4f(.7,0,0,.2);
1355 glVertex3f(0, 0, 0.0f);
1356 glVertex3f(256, 0, 0.0f);
1357 glVertex3f(256, 256, 0.0f);
1358 glVertex3f(0, 256, 0.0f);
1360 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1361 glPopMatrix(); // Restore The Old Projection Matrix
1362 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1363 glPopMatrix(); // Restore The Old Projection Matrix
1364 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1365 glEnable(GL_CULL_FACE);
1366 glDisable(GL_BLEND);
1370 if(flashamount>0&&damageeffects){
1371 if(flashamount>1)flashamount=1;
1372 if(flashdelay<=0)flashamount-=multiplier;
1374 if(flashamount<0)flashamount=0;
1375 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1376 glDisable(GL_CULL_FACE);
1377 glDisable(GL_LIGHTING);
1379 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1380 glPushMatrix(); // Store The Projection Matrix
1381 glLoadIdentity(); // Reset The Projection Matrix
1382 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1383 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1384 glPushMatrix(); // Store The Modelview Matrix
1385 glLoadIdentity(); // Reset The Modelview Matrix
1386 glScalef(screenwidth,screenheight,1);
1387 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1389 glColor4f(flashr,flashg,flashb,flashamount);
1391 glVertex3f(0, 0, 0.0f);
1392 glVertex3f(256, 0, 0.0f);
1393 glVertex3f(256, 256, 0.0f);
1394 glVertex3f(0, 256, 0.0f);
1396 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1397 glPopMatrix(); // Restore The Old Projection Matrix
1398 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1399 glPopMatrix(); // Restore The Old Projection Matrix
1400 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1401 glEnable(GL_CULL_FACE);
1402 glDisable(GL_BLEND);
1408 glEnable(GL_TEXTURE_2D);
1411 sprintf (string, " ]");
1412 text.glPrint(10,30+screenheight-330,string,0,1,screenwidth,screenheight);
1414 sprintf (string, "_");
1415 text.glPrint(30+(float)(displayselected)*10,30+(screenheight-330),string,0,1,screenwidth,screenheight);
1419 if((i!=0||chatting)&&displaytime[i]<4)
1420 for(j=0;j<displaychars[i];j++){
1421 glColor4f(1,1,1,4-displaytime[i]);
1422 if(j<displaychars[i]){
1423 sprintf (string, "%c",displaytext[i][j]);
1424 text.glPrint(30+j*10,30+i*20+(screenheight-330),string,0,1,screenwidth,screenheight);
1430 if(minimap&&indialogue==-1){
1434 glDisable(GL_DEPTH_TEST);
1435 glColor3f (1.0, 1.0, 1.0); // no coloring
1437 glEnable(GL_TEXTURE_2D);
1438 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1439 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1440 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1441 glDisable(GL_CULL_FACE);
1442 glDisable(GL_LIGHTING);
1444 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1445 glPushMatrix(); // Store The Projection Matrix
1446 glLoadIdentity(); // Reset The Projection Matrix
1447 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1448 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1449 glPushMatrix(); // Store The Modelview Matrix
1450 glLoadIdentity(); // Reset The Modelview Matrix
1451 glScalef((float)screenwidth/2,(float)screenwidth/2,1);
1452 glTranslatef(1.75,.25,0);
1453 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1463 int numliveplayers=0;
1464 for(i=0;i<numplayers;i++){
1465 if(!player[i].dead)numliveplayers++;
1471 for(i=0;i<objects.numobjects;i++){
1472 if(objects.type[i]==treetrunktype||objects.type[i]==boxtype){
1473 center+=objects.position[i];
1477 for(i=0;i<numplayers;i++){
1478 if(!player[i].dead)center+=player[i].coords;
1480 center/=numadd+numliveplayers;
1482 center=player[0].coords;
1484 float maxdistance=0;
1487 for(i=0;i<objects.numobjects;i++){
1488 tempdist=findDistancefast(¢er,&objects.position[i]);
1489 if(tempdist>maxdistance){
1491 maxdistance=tempdist;
1494 for(i=0;i<numplayers;i++){
1495 if(!player[i].dead){
1496 tempdist=findDistancefast(¢er,&player[i].coords);
1497 if(tempdist>maxdistance){
1499 maxdistance=tempdist;
1503 radius=fast_sqrt(maxdistance);
1507 glScalef(.25/radius*256*terrain.scale*.4,.25/radius*256*terrain.scale*.4,1);
1509 glScalef(1/(1/radius*256*terrain.scale*.4),1/(1/radius*256*terrain.scale*.4),1);
1510 /*float startx,starty,endx,endy;
1512 glTexCoord2f(1-(center.x-radius)/terrain.scale/256,(center.z-radius)/terrain.scale/256);
1513 glVertex3f(-1, -1, 0.0f);
1514 glTexCoord2f(1-(center.x+radius)/terrain.scale/256,(center.z-radius)/terrain.scale/256);
1515 glVertex3f(1, -1, 0.0f);
1516 glTexCoord2f(1-(center.x+radius)/terrain.scale/256,(center.z+radius)/terrain.scale/256);
1517 glVertex3f(1, 1, 0.0f);
1518 glTexCoord2f(1-(center.x-radius)/terrain.scale/256,(center.z+radius)/terrain.scale/256);
1519 glVertex3f(-1, 1, 0.0f);
1522 glRotatef(player[0].lookrotation*-1+180,0,0,1);
1523 glTranslatef(-(center.x/terrain.scale/256*-2+1),(center.z/terrain.scale/256*-2+1),0);
1524 for(i=0;i<objects.numobjects;i++){
1525 if(objects.type[i]==treetrunktype){
1526 distcheck=findDistancefast(&player[0].coords,&objects.position[i]);
1527 if(distcheck<mapviewdist){
1528 glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
1529 glColor4f(0,.3,0,opac*(1-distcheck/mapviewdist));
1531 glTranslatef(objects.position[i].x/terrain.scale/256*-2+1,objects.position[i].z/terrain.scale/256*2-1,0);
1532 glRotatef(objects.rotation[i],0,0,1);
1533 glScalef(.003,.003,.003);
1536 glVertex3f(-1, -1, 0.0f);
1538 glVertex3f(1, -1, 0.0f);
1540 glVertex3f(1, 1, 0.0f);
1542 glVertex3f(-1, 1, 0.0f);
1547 if(objects.type[i]==boxtype){
1548 distcheck=findDistancefast(&player[0].coords,&objects.position[i]);
1549 if(distcheck<mapviewdist){
1550 glBindTexture( GL_TEXTURE_2D, Mapboxtexture);
1551 glColor4f(.4,.4,.4,opac*(1-distcheck/mapviewdist));
1553 glTranslatef(objects.position[i].x/terrain.scale/256*-2+1,objects.position[i].z/terrain.scale/256*2-1,0);
1554 glRotatef(objects.rotation[i],0,0,1);
1555 glScalef(.01*objects.scale[i],.01*objects.scale[i],.01*objects.scale[i]);
1558 glVertex3f(-1, -1, 0.0f);
1560 glVertex3f(1, -1, 0.0f);
1562 glVertex3f(1, 1, 0.0f);
1564 glVertex3f(-1, 1, 0.0f);
1571 glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
1572 for(i=0;i<numboundaries;i++){
1573 glColor4f(0,0,0,opac/3);
1575 glTranslatef(boundary[i].x/terrain.scale/256*-2+1,boundary[i].z/terrain.scale/256*2-1,0);
1576 glScalef(.002,.002,.002);
1579 glVertex3f(-1, -1, 0.0f);
1581 glVertex3f(1, -1, 0.0f);
1583 glVertex3f(1, 1, 0.0f);
1585 glVertex3f(-1, 1, 0.0f);
1590 for(i=0;i<numplayers;i++){
1591 distcheck=findDistancefast(&player[0].coords,&player[i].coords);
1592 if(distcheck<mapviewdist){
1594 glBindTexture( GL_TEXTURE_2D, Maparrowtexture);
1595 if(i==0)glColor4f(1,1,1,opac);
1596 else if(player[i].dead==2||player[i].howactive>typesleeping)glColor4f(0,0,0,opac*(1-distcheck/mapviewdist));
1597 else if(player[i].dead)glColor4f(.3,.3,.3,opac*(1-distcheck/mapviewdist));
1598 else if(player[i].aitype==attacktypecutoff)glColor4f(1,0,0,opac*(1-distcheck/mapviewdist));
1599 else if(player[i].aitype==passivetype)glColor4f(0,1,0,opac*(1-distcheck/mapviewdist));
1600 else glColor4f(1,1,0,1);
1601 glTranslatef(player[i].coords.x/terrain.scale/256*-2+1,player[i].coords.z/terrain.scale/256*2-1,0);
1602 glRotatef(player[i].rotation+180,0,0,1);
1603 glScalef(.005,.005,.005);
1606 glVertex3f(-1, -1, 0.0f);
1608 glVertex3f(1, -1, 0.0f);
1610 glVertex3f(1, 1, 0.0f);
1612 glVertex3f(-1, 1, 0.0f);
1614 /*glBegin(GL_TRIANGLES);
1616 glVertex3f(-1, -1, 0.0f);
1618 glVertex3f(1, -1, 0.0f);
1620 glVertex3f(0, 1, 0.0f);
1625 /*glBegin(GL_QUADS);
1627 glVertex3f(-1, -1, 0.0f);
1629 glVertex3f(1, -1, 0.0f);
1631 glVertex3f(1, 1, 0.0f);
1633 glVertex3f(-1, 1, 0.0f);
1636 glDisable(GL_TEXTURE_2D);
1637 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1638 glPopMatrix(); // Restore The Old Projection Matrix
1639 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1640 glPopMatrix(); // Restore The Old Projection Matrix
1641 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1642 glEnable(GL_CULL_FACE);
1643 glDisable(GL_BLEND);
1649 drawmode=normalmode;
1653 if(loading&&!stealthloading&&(!campaign||player[0].dead)){
1654 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1655 glDisable(GL_CULL_FACE);
1656 glDisable(GL_LIGHTING);
1657 glDisable(GL_TEXTURE_2D);
1659 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1660 glPushMatrix(); // Store The Projection Matrix
1661 glLoadIdentity(); // Reset The Projection Matrix
1662 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1663 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1664 glPushMatrix(); // Store The Modelview Matrix
1665 glLoadIdentity(); // Reset The Modelview Matrix
1666 glScalef(screenwidth,screenheight,1);
1667 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1669 glColor4f(0,0,0,.7);
1671 glVertex3f(0, 0, 0.0f);
1672 glVertex3f(256, 0, 0.0f);
1673 glVertex3f(256, 256, 0.0f);
1674 glVertex3f(0, 256, 0.0f);
1676 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1677 glPopMatrix(); // Restore The Old Projection Matrix
1678 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1679 glPopMatrix(); // Restore The Old Projection Matrix
1680 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1681 glEnable(GL_CULL_FACE);
1682 glDisable(GL_BLEND);
1686 glDisable(GL_DEPTH_TEST);
1687 glColor3f (1.0, 1.0, 1.0); // no coloring
1689 glEnable(GL_TEXTURE_2D);
1690 /*glBindTexture( GL_TEXTURE_2D, logotexture);
1691 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1692 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1693 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1694 glDisable(GL_CULL_FACE);
1695 glDisable(GL_LIGHTING);
1697 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1698 glPushMatrix(); // Store The Projection Matrix
1699 glLoadIdentity(); // Reset The Projection Matrix
1700 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1701 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1702 glPushMatrix(); // Store The Modelview Matrix
1703 glLoadIdentity(); // Reset The Modelview Matrix
1704 glScalef((float)screenwidth/2,(float)screenwidth/2,1);
1705 glTranslatef(1.8,1.25,0);
1706 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1710 glScalef(.25,.25,.25);
1713 glVertex3f(-1, -1, 0.0f);
1715 glVertex3f(1, -1, 0.0f);
1717 glVertex3f(1, 1, 0.0f);
1719 glVertex3f(-1, 1, 0.0f);
1722 glDisable(GL_TEXTURE_2D);
1723 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1724 glPopMatrix(); // Restore The Old Projection Matrix
1725 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1726 glPopMatrix(); // Restore The Old Projection Matrix
1727 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1728 glEnable(GL_CULL_FACE);
1729 glDisable(GL_BLEND);
1735 glEnable(GL_TEXTURE_2D);
1737 sprintf (string, "Loading...");
1738 text.glPrint(1024/2-90,768/2,string,1,2,1024,768);
1741 //if(ismotionblur)drawmode=motionblurmode;
1742 drawmode=normalmode;
1745 if(winfreeze&&!campaign){
1746 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1747 glDisable(GL_CULL_FACE);
1748 glDisable(GL_LIGHTING);
1749 glDisable(GL_TEXTURE_2D);
1751 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1752 glPushMatrix(); // Store The Projection Matrix
1753 glLoadIdentity(); // Reset The Projection Matrix
1754 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1755 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1756 glPushMatrix(); // Store The Modelview Matrix
1757 glLoadIdentity(); // Reset The Modelview Matrix
1758 glScalef(screenwidth,screenheight,1);
1759 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1761 glColor4f(0,0,0,.4);
1763 glVertex3f(0, 0, 0.0f);
1764 glVertex3f(256, 0, 0.0f);
1765 glVertex3f(256, 256, 0.0f);
1766 glVertex3f(0, 256, 0.0f);
1768 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1769 glPopMatrix(); // Restore The Old Projection Matrix
1770 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1771 glPopMatrix(); // Restore The Old Projection Matrix
1772 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1773 glEnable(GL_CULL_FACE);
1774 glDisable(GL_BLEND);
1778 glDisable(GL_DEPTH_TEST);
1779 glColor3f (1.0, 1.0, 1.0); // no coloring
1781 glEnable(GL_TEXTURE_2D);
1782 /*glBindTexture( GL_TEXTURE_2D, logotexture);
1783 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1784 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1785 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1786 glDisable(GL_CULL_FACE);
1787 glDisable(GL_LIGHTING);
1789 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1790 glPushMatrix(); // Store The Projection Matrix
1791 glLoadIdentity(); // Reset The Projection Matrix
1792 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1793 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1794 glPushMatrix(); // Store The Modelview Matrix
1795 glLoadIdentity(); // Reset The Modelview Matrix
1796 glScalef((float)screenwidth/2,(float)screenwidth/2,1);
1797 glTranslatef(1.8,1.25,0);
1798 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1802 glScalef(.25,.25,.25);
1805 glVertex3f(-1, -1, 0.0f);
1807 glVertex3f(1, -1, 0.0f);
1809 glVertex3f(1, 1, 0.0f);
1811 glVertex3f(-1, 1, 0.0f);
1814 glDisable(GL_TEXTURE_2D);
1815 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1816 glPopMatrix(); // Restore The Old Projection Matrix
1817 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1818 glPopMatrix(); // Restore The Old Projection Matrix
1819 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1820 glEnable(GL_CULL_FACE);
1821 glDisable(GL_BLEND);
1829 if(damagetaken==0&&player[0].bloodloss==0){
1830 awards[numawards]=awardflawless;
1836 for(i=1;i<numplayers;i++){
1837 if(player[i].dead!=2)alldead=0;
1840 awards[numawards]=awardalldead;
1845 for(i=1;i<numplayers;i++){
1846 if(player[i].dead!=1)alldead=0;
1849 awards[numawards]=awardnodead;
1852 if(numresponded==0&&!numthrowkill){
1853 awards[numawards]=awardstealth;
1856 if(numattacks==numstaffattack&&numattacks>0){
1857 awards[numawards]=awardbojutsu;
1860 if(numattacks==numswordattack&&numattacks>0){
1861 awards[numawards]=awardswordsman;
1864 if(numattacks==numknifeattack&&numattacks>0){
1865 awards[numawards]=awardknifefighter;
1868 if(numattacks==numunarmedattack&&numthrowkill==0&&weapons.numweapons>0){
1869 awards[numawards]=awardkungfu;
1873 awards[numawards]=awardevasion;
1876 if(numflipfail==0&&numflipped+numwallflipped*2>20){
1877 awards[numawards]=awardacrobat;
1880 if(numthrowkill==numplayers-1){
1881 awards[numawards]=awardlongrange;
1886 for(i=1;i<numplayers;i++){
1887 if(player[i].dead!=2)alldead=0;
1889 if(numafterkill>0&&alldead){
1890 awards[numawards]=awardbrutal;
1893 if(numreversals>((float)numattacks)*.8&&numreversals>3){
1894 awards[numawards]=awardaikido;
1897 if(maxalarmed==1&&numplayers>2){
1898 awards[numawards]=awardstrategy;
1902 awards[numawards]=awardklutz;
1907 //Win Screen Won Victory
1909 glEnable(GL_TEXTURE_2D);
1911 sprintf (string, "Level Cleared!");
1912 text.glPrintOutlined(1024/2-strlen(string)*10,768*7/8,string,1,2,1024,768);
1914 sprintf (string, "Score: %d",(int)(bonustotal-startbonustotal));
1915 text.glPrintOutlined(1024/30,768*6/8,string,1,2,1024,768);
1917 if(!campaign)sprintf (string, "Press Escape to return to menu or Space to continue");
1918 if(campaign)sprintf (string, "Press Escape or Space to continue");
1919 text.glPrintOutlined(640/2-strlen(string)*5,480*1/16,string,1,1,640,480);
1923 for(i=0;i<255;i++)string[i]='\0';
1924 sprintf (temp, "Time: %d:",(int)(((int)leveltime-(int)(leveltime)%60)/60));
1925 strcat(string,temp);
1926 if((int)(leveltime)%60<10)strcat(string,"0");
1927 sprintf (temp, "%d",(int)(leveltime)%60);
1928 strcat(string,temp);
1929 text.glPrintOutlined(1024/30,768*6/8-40,string,1,2,1024,768);
1931 for(i=0;i<numawards;i++){
1933 if(awards[i]==awardklutz)sprintf (string, "Suicidal");
1934 if(awards[i]==awardflawless)sprintf (string, "Flawless!");
1935 if(awards[i]==awardalldead)sprintf (string, "Take no prisoners");
1936 if(awards[i]==awardnodead)sprintf (string, "Merciful");
1937 if(awards[i]==awardstealth)sprintf (string, "One with the shadows!");
1938 if(awards[i]==awardswordsman)sprintf (string, "Swordsman");
1939 if(awards[i]==awardkungfu)sprintf (string, "Unarmed!");
1940 if(awards[i]==awardknifefighter)sprintf (string, "Knife fighter");
1941 if(awards[i]==awardcoward)sprintf (string, "Coward");
1942 if(awards[i]==awardevasion)sprintf (string, "Escape artist");
1943 if(awards[i]==awardacrobat)sprintf (string, "Gymnast");
1944 if(awards[i]==awardlongrange)sprintf (string, "Blade slinger");
1945 if(awards[i]==awardbrutal)sprintf (string, "Brutal");
1946 if(awards[i]==awardhyper)sprintf (string, "Hyper");
1947 if(awards[i]==awardaikido)sprintf (string, "Aikido master!");
1948 if(awards[i]==awardrambo)sprintf (string, "Rambo");
1949 if(awards[i]==awardfast)sprintf (string, "Fast");
1950 if(awards[i]==awardrealfast)sprintf (string, "Real fast");
1951 if(awards[i]==awarddamnfast)sprintf (string, "Damn fast");
1952 if(awards[i]==awardstrategy)sprintf (string, "Divide and conquer");
1953 if(awards[i]==awardbojutsu)sprintf (string, "Bojutsu");
1954 text.glPrintOutlined(1024/30,768*6/8-90-40*i,string,1,2,1024,768);
1958 //drawmode=normalmode;
1961 if(drawmode!=normalmode){
1962 glEnable(GL_TEXTURE_2D);
1964 if(!drawtoggle||drawmode!=realmotionblurmode||(drawtoggle==2||change==1)){
1967 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
1968 GLfloat subtractColor[4] = { 0.5, 0.5, 0.5, 0.0 };
1969 glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, subtractColor);
1970 //glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_SUBTRACT);
1971 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE);
1972 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_CONSTANT_EXT);
1973 glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 2.0f);
1975 glBindTexture( GL_TEXTURE_2D, screentexture);
1976 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1979 if((drawtoggle||change==1)&&drawmode==realmotionblurmode){
1981 glBindTexture( GL_TEXTURE_2D, screentexture2);
1982 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1984 if(!screentexture2){
1985 glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
1987 glGenTextures( 1, &screentexture2 );
1988 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
1990 glEnable(GL_TEXTURE_2D);
1991 glBindTexture( GL_TEXTURE_2D, screentexture2);
1992 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
1993 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
1995 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
2001 glClear(GL_DEPTH_BUFFER_BIT);
2002 ReSizeGLScene(90,.1f);
2003 glViewport(0,0,screenwidth,screenheight);
2005 if(drawmode!=normalmode){
2006 glDisable(GL_DEPTH_TEST);
2007 if(drawmode==motionblurmode){
2008 glDrawBuffer(GL_FRONT);
2009 glReadBuffer(GL_BACK);
2010 //myassert(glGetError() == GL_NO_ERROR);
2013 glColor3f (1.0, 1.0, 1.0); // no coloring
2015 glEnable(GL_TEXTURE_2D);
2016 glBindTexture( GL_TEXTURE_2D, screentexture);
2017 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
2018 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
2019 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
2020 glDisable(GL_CULL_FACE);
2021 glDisable(GL_LIGHTING);
2023 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2024 glPushMatrix(); // Store The Projection Matrix
2025 glLoadIdentity(); // Reset The Projection Matrix
2026 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
2027 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2028 glPushMatrix(); // Store The Modelview Matrix
2029 glLoadIdentity(); // Reset The Modelview Matrix
2030 glScalef((float)screenwidth/2,(float)screenheight/2,1);
2031 glTranslatef(1,1,0);
2032 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
2034 if(drawmode==motionblurmode){
2035 if(motionbluramount<.2)motionbluramount=.2;
2036 //glColor4f(1,1,1,fast_sqrt(multiplier)*2.9*motionbluramount);
2037 glColor4f(1,1,1,motionbluramount);
2041 glVertex3f(-1, -1, 0.0f);
2042 glTexCoord2f(texcoordwidth,0);
2043 glVertex3f(1, -1, 0.0f);
2044 glTexCoord2f(texcoordwidth,texcoordheight);
2045 glVertex3f(1, 1, 0.0f);
2046 glTexCoord2f(0,texcoordheight);
2047 glVertex3f(-1, 1, 0.0f);
2051 if(drawmode==realmotionblurmode){
2052 glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
2053 glClear(GL_COLOR_BUFFER_BIT);
2054 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
2055 glBindTexture( GL_TEXTURE_2D, screentexture);
2056 glColor4f(1,1,1,.5);
2060 glVertex3f(-1, -1, 0.0f);
2061 glTexCoord2f(texcoordwidth,0);
2062 glVertex3f(1, -1, 0.0f);
2063 glTexCoord2f(texcoordwidth,texcoordheight);
2064 glVertex3f(1, 1, 0.0f);
2065 glTexCoord2f(0,texcoordheight);
2066 glVertex3f(-1, 1, 0.0f);
2069 glBindTexture( GL_TEXTURE_2D, screentexture2);
2070 glColor4f(1,1,1,.5);
2074 glVertex3f(-1, -1, 0.0f);
2075 glTexCoord2f(texcoordwidth,0);
2076 glVertex3f(1, -1, 0.0f);
2077 glTexCoord2f(texcoordwidth,texcoordheight);
2078 glVertex3f(1, 1, 0.0f);
2079 glTexCoord2f(0,texcoordheight);
2080 glVertex3f(-1, 1, 0.0f);
2083 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
2085 if(drawmode==doublevisionmode){
2086 static float crosseyedness;
2087 crosseyedness=abs(player[0].damage-player[0].superpermanentdamage-(player[0].damagetolerance-player[0].superpermanentdamage)*1/2)/30;
2088 if(crosseyedness>1)crosseyedness=1;
2089 if(crosseyedness<0)crosseyedness=0;
2091 glDisable(GL_BLEND);
2096 glVertex3f(-1, -1, 0.0f);
2097 glTexCoord2f(texcoordwidth,0);
2098 glVertex3f(1, -1, 0.0f);
2099 glTexCoord2f(texcoordwidth,texcoordheight);
2100 glVertex3f(1, 1, 0.0f);
2101 glTexCoord2f(0,texcoordheight);
2102 glVertex3f(-1, 1, 0.0f);
2106 glColor4f(1,1,1,.5);
2109 glTranslatef(.015*crosseyedness,0,0);
2113 glVertex3f(-1, -1, 0.0f);
2114 glTexCoord2f(texcoordwidth,0);
2115 glVertex3f(1, -1, 0.0f);
2116 glTexCoord2f(texcoordwidth,texcoordheight);
2117 glVertex3f(1, 1, 0.0f);
2118 glTexCoord2f(0,texcoordheight);
2119 glVertex3f(-1, 1, 0.0f);
2124 if(drawmode==glowmode){
2125 glColor4f(.5,.5,.5,.5);
2127 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
2129 glTranslatef(.01,0,0);
2132 glVertex3f(-1, -1, 0.0f);
2133 glTexCoord2f(texcoordwidth,0);
2134 glVertex3f(1, -1, 0.0f);
2135 glTexCoord2f(texcoordwidth,texcoordheight);
2136 glVertex3f(1, 1, 0.0f);
2137 glTexCoord2f(0,texcoordheight);
2138 glVertex3f(-1, 1, 0.0f);
2142 glTranslatef(-.01,0,0);
2145 glVertex3f(-1, -1, 0.0f);
2146 glTexCoord2f(texcoordwidth,0);
2147 glVertex3f(1, -1, 0.0f);
2148 glTexCoord2f(texcoordwidth,texcoordheight);
2149 glVertex3f(1, 1, 0.0f);
2150 glTexCoord2f(0,texcoordheight);
2151 glVertex3f(-1, 1, 0.0f);
2155 glTranslatef(.0,.01,0);
2158 glVertex3f(-1, -1, 0.0f);
2159 glTexCoord2f(texcoordwidth,0);
2160 glVertex3f(1, -1, 0.0f);
2161 glTexCoord2f(texcoordwidth,texcoordheight);
2162 glVertex3f(1, 1, 0.0f);
2163 glTexCoord2f(0,texcoordheight);
2164 glVertex3f(-1, 1, 0.0f);
2168 glTranslatef(0,-.01,0);
2171 glVertex3f(-1, -1, 0.0f);
2172 glTexCoord2f(texcoordwidth,0);
2173 glVertex3f(1, -1, 0.0f);
2174 glTexCoord2f(texcoordwidth,texcoordheight);
2175 glVertex3f(1, 1, 0.0f);
2176 glTexCoord2f(0,texcoordheight);
2177 glVertex3f(-1, 1, 0.0f);
2181 if(drawmode==radialzoommode){
2183 //glRotatef((float)i*.1,0,0,1);
2184 glColor4f(1,1,1,1/((float)i+1));
2186 glScalef(1+(float)i*.01,1+(float)i*.01,1);
2189 glVertex3f(-1, -1, 0.0f);
2190 glTexCoord2f(texcoordwidth,0);
2191 glVertex3f(1, -1, 0.0f);
2192 glTexCoord2f(texcoordwidth,texcoordheight);
2193 glVertex3f(1, 1, 0.0f);
2194 glTexCoord2f(0,texcoordheight);
2195 glVertex3f(-1, 1, 0.0f);
2200 glDisable(GL_TEXTURE_2D);
2201 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2202 glPopMatrix(); // Restore The Old Projection Matrix
2203 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2204 glPopMatrix(); // Restore The Old Projection Matrix
2205 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
2206 glEnable(GL_CULL_FACE);
2207 glDisable(GL_BLEND);
2212 glEnable(GL_TEXTURE_2D);
2217 if(consoleselected>=60)offset=consoleselected-60;
2218 sprintf (string, " ]");
2219 text.glPrint(10,30,string,0,1,1024,768);
2221 sprintf (string, "_");
2222 text.glPrint(30+(float)(consoleselected)*10-offset*10,30,string,0,1,1024,768);
2225 for(j=0;j<consolechars[i];j++){
2226 glColor4f(1,1,1,1-(float)(i)/16);
2227 if(j<consolechars[i]){
2228 sprintf (string, "%c",consoletext[i][j]);
2229 text.glPrint(30+j*10-offset*10,30+i*20,string,0,1,1024,768);
2237 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)||(mainmenu&&gameon)||(!gameon&&gamestarted)||(!gameon&&gamestarted)){
2238 multiplier=tempmult;
2243 // !!! FIXME: hack: clamp framerate in menu so text input works correctly on fast systems.
2246 glDrawBuffer(GL_BACK);
2247 glReadBuffer(GL_BACK);
2248 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
2249 ReSizeGLScene(90,.1f);
2252 temptexdetail=texdetail;
2253 if(texdetail>2)texdetail=2;
2254 if(mainmenu!=oldmainmenu&&oldmainmenu!=0){
2256 LoadTexture(":Data:Textures:Newgame.png",&Mainmenuitems[1],0,0);
2257 LoadTexture(":Data:Textures:Quit.png",&Mainmenuitems[3],0,0);
2258 /*if(oldmainmenu==1||oldmainmenu==0){
2259 LoadTexture(":Data:Textures:World.png",&Mainmenuitems[7],0,0);
2260 LoadTexture(":Data:Textures:Options.png",&Mainmenuitems[2],0,0);
2261 LoadTexture(":Data:Textures:Lugaru.png",&Mainmenuitems[0],0,0);
2266 LoadTexture(":Data:Textures:Resume.png",&Mainmenuitems[1],0,0);
2267 LoadTexture(":Data:Textures:Endgame.png",&Mainmenuitems[3],0,0);
2268 /*if(oldmainmenu==2||oldmainmenu==0){
2269 LoadTexture(":Data:Textures:World.png",&Mainmenuitems[7],0,0);
2270 LoadTexture(":Data:Textures:Options.png",&Mainmenuitems[2],0,0);
2271 LoadTexture(":Data:Textures:Lugaru.png",&Mainmenuitems[0],0,0);
2276 if(lastcheck>.5||oldmainmenu!=mainmenu){
2278 ifstream ipstream(ConvertFileName(":Data:Campaigns:main.txt"));
2279 //campaignnumlevels=0;
2280 //accountcampaignchoicesmade[accountactive]=0;
2281 ipstream.ignore(256,':');
2282 ipstream >> campaignnumlevels;
2283 for(i=0;i<campaignnumlevels;i++){
2284 ipstream.ignore(256,':');
2285 ipstream.ignore(256,':');
2286 ipstream.ignore(256,' ');
2287 ipstream >> campaignmapname[i];
2288 ipstream.ignore(256,':');
2289 ipstream >> campaigndescription[i];
2291 if(campaigndescription[i][j]=='_')campaigndescription[i][j]=' ';
2293 ipstream.ignore(256,':');
2294 ipstream >> campaignchoosenext[i];
2295 ipstream.ignore(256,':');
2296 ipstream >> campaignnumnext[i];
2297 if(campaignnumnext[i])
2298 for(j=0;j<campaignnumnext[i];j++){
2299 ipstream.ignore(256,':');
2300 ipstream >> campaignnextlevel[i][j];
2301 campaignnextlevel[i][j]-=1;
2303 ipstream.ignore(256,':');
2304 ipstream >> campaignlocationx[i];
2305 //campaignlocationx[i]-=30;
2306 ipstream.ignore(256,':');
2307 ipstream >> campaignlocationy[i];
2308 //campaignlocationy[i]+=30;
2312 for(i=0;i<campaignnumlevels;i++){
2314 levelhighlight[i]=0;
2319 if(accountcampaignchoicesmade[accountactive])
2320 for(i=0;i<accountcampaignchoicesmade[accountactive];i++){
2321 levelorder[i+1]=campaignnextlevel[levelorder[i]][accountcampaignchoices[accountactive][i]];
2322 levelvisible[levelorder[i+1]]=1;
2324 int whichlevelstart;
2325 whichlevelstart=accountcampaignchoicesmade[accountactive]-1;
2326 if(whichlevelstart<0){
2327 accountcampaignscore[accountactive]=0;
2328 accountcampaignfasttime[accountactive]=0;
2329 campaignchoicenum=1;
2330 campaignchoicewhich[0]=0;
2334 campaignchoicenum=campaignnumnext[levelorder[whichlevelstart]];
2335 if(campaignchoicenum==0){
2336 if(accountcampaignscore[accountactive]>accountcampaignhighscore[accountactive])accountcampaignhighscore[accountactive]=accountcampaignscore[accountactive];
2337 if(accountcampaignfasttime[accountactive]==0||accountcampaigntime[accountactive]<accountcampaignfasttime[accountactive])accountcampaignfasttime[accountactive]=accountcampaigntime[accountactive];
2339 if(campaignchoicenum)
2340 for(i=0;i<campaignchoicenum;i++){
2341 campaignchoicewhich[i]=campaignnextlevel[levelorder[whichlevelstart]][i];
2342 levelvisible[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
2343 levelhighlight[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
2356 texdetail=temptexdetail;
2358 /*if(mainmenu!=0)*/oldmainmenu=mainmenu;
2360 if(mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==8||mainmenu==9||mainmenu==10||mainmenu==119||mainmenu==12||mainmenu==13||mainmenu==14||mainmenu==15||mainmenu==16||mainmenu==17){
2361 glClear(GL_DEPTH_BUFFER_BIT);
2362 glEnable(GL_ALPHA_TEST);
2363 glAlphaFunc(GL_GREATER, 0.001f);
2364 glEnable(GL_TEXTURE_2D);
2365 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
2366 glDisable(GL_CULL_FACE);
2367 glDisable(GL_LIGHTING);
2369 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2370 glPushMatrix(); // Store The Projection Matrix
2371 glLoadIdentity(); // Reset The Projection Matrix
2372 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
2373 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2374 glPushMatrix(); // Store The Modelview Matrix
2375 glLoadIdentity(); // Reset The Modelview Matrix
2376 glTranslatef(screenwidth/2,screenheight/2,0);
2378 glScalef((float)screenwidth/2,(float)screenheight/2,1);
2379 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
2380 glDisable(GL_BLEND);
2381 glColor4f(0,0,0,1.0);
2382 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2383 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2384 glDisable(GL_TEXTURE_2D);
2386 //glScalef(.25,.25,.25);
2389 glVertex3f(-1, -1, 0.0f);
2391 glVertex3f(1, -1, 0.0f);
2393 glVertex3f(1, 1, 0.0f);
2395 glVertex3f(-1, 1, 0.0f);
2399 glColor4f(0.4,0.4,0.4,1.0);
2400 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2401 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2402 glEnable(GL_TEXTURE_2D);
2403 glBindTexture( GL_TEXTURE_2D, Mainmenuitems[4]);
2405 //glScalef(.25,.25,.25);
2408 glVertex3f(-1, -1, 0.0f);
2410 glVertex3f(1, -1, 0.0f);
2412 glVertex3f(1, 1, 0.0f);
2414 glVertex3f(-1, 1, 0.0f);
2419 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2421 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2425 if((float)newscreenwidth>(float)newscreenheight*1.61||(float)newscreenwidth<(float)newscreenheight*1.59)sprintf (menustring[0], "Resolution: %d*%d",(int)newscreenwidth,(int)newscreenheight);
2426 else sprintf (menustring[0], "Resolution: %d*%d (widescreen)",(int)newscreenwidth,(int)newscreenheight);
2429 endx[0]=startx[0]+strlen(menustring[0])*10;
2430 endy[0]=starty[0]+20;
2434 if(newdetail==2)sprintf (menustring[1], "Detail: High");
2435 else if(newdetail==1)sprintf (menustring[1], "Detail: Medium");
2436 else sprintf (menustring[1], "Detail: Low");
2439 endx[1]=startx[1]+strlen(menustring[1])*10;
2440 endy[1]=starty[1]+20;
2444 if(bloodtoggle==2)sprintf (menustring[2], "Blood: On, high detail (slower)");
2445 if(bloodtoggle==1)sprintf (menustring[2], "Blood: On, low detail");
2446 if(bloodtoggle==0)sprintf (menustring[2], "Blood: Off");
2449 endx[2]=startx[2]+strlen(menustring[2])*10;
2450 endy[2]=starty[2]+20;
2454 if(difficulty==2)sprintf (menustring[3], "Difficulty: Insane");
2455 if(difficulty==1)sprintf (menustring[3], "Difficulty: Difficult");
2456 if(difficulty==0)sprintf (menustring[3], "Difficulty: Easier");
2457 startx[3]=10+20-1000;
2459 endx[3]=startx[3]+strlen(menustring[3])*10;
2460 endy[3]=starty[3]+20;
2464 if(ismotionblur==1)sprintf (menustring[4], "Blur Effects: Enabled (less compatible)");
2465 if(ismotionblur==0)sprintf (menustring[4], "Blur Effects: Disabled (more compatible)");
2468 endx[4]=startx[4]+strlen(menustring[4])*10;
2469 endy[4]=starty[4]+20;
2473 if(decals==1)sprintf (menustring[5], "Decals: Enabled (slower)");
2474 if(decals==0)sprintf (menustring[5], "Decals: Disabled");
2477 endx[5]=startx[5]+strlen(menustring[5])*10;
2478 endy[5]=starty[5]+20;
2482 if(musictoggle==1)sprintf (menustring[6], "Music: Enabled");
2483 if(musictoggle==0)sprintf (menustring[6], "Music: Disabled");
2486 endx[6]=startx[6]+strlen(menustring[6])*10;
2487 endy[6]=starty[6]+20;
2491 if(invertmouse==1)sprintf (menustring[9], "Invert mouse: Yes");
2492 if(invertmouse==0)sprintf (menustring[9], "Invert mouse: No");
2495 endx[9]=startx[9]+strlen(menustring[9])*10;
2496 endy[9]=starty[9]+20;
2500 sprintf (menustring[10], "Mouse Speed: %d", (int)(usermousesensitivity*5));
2503 endx[10]=startx[10]+strlen(menustring[10])*10;
2504 endy[10]=starty[10]+20;
2508 sprintf (menustring[11], "Volume: %d%", (int)(volume*100));
2511 endx[11]=startx[11]+strlen(menustring[11])*10;
2512 endy[11]=starty[11]+20;
2516 sprintf (menustring[7], "-Configure Controls-");
2519 endx[7]=startx[7]+strlen(menustring[7])*10;
2520 endy[7]=starty[7]+20;
2524 if(newdetail==detail&&newscreenheight==(int)screenheight&&newscreenwidth==(int)screenwidth)sprintf (menustring[8], "Back");
2525 else sprintf (menustring[8], "Back (some changes take effect next time Lugaru is opened)");
2527 endx[8]=startx[8]+strlen(menustring[8])*10;
2529 endy[8]=starty[8]+20;
2536 if(keyselect!=0)sprintf (menustring[0], "Forwards: %s",KeyToChar(forwardkey));
2537 else sprintf (menustring[0], "Forwards: _");
2540 endx[0]=startx[0]+strlen(menustring[0])*10;
2541 endy[0]=starty[0]+20;
2545 if(keyselect!=1)sprintf (menustring[1], "Back: %s",KeyToChar(backkey));
2546 else sprintf (menustring[1], "Back: _");
2549 endx[1]=startx[1]+strlen(menustring[1])*10;
2550 endy[1]=starty[1]+20;
2554 if(keyselect!=2)sprintf (menustring[2], "Left: %s",KeyToChar(leftkey));
2555 else sprintf (menustring[2], "Left: _");
2558 endx[2]=startx[2]+strlen(menustring[2])*10;
2559 endy[2]=starty[2]+20;
2563 if(keyselect!=3)sprintf (menustring[3], "Right: %s",KeyToChar(rightkey));
2564 else sprintf (menustring[3], "Right: _");
2567 endx[3]=startx[3]+strlen(menustring[3])*10;
2568 endy[3]=starty[3]+20;
2572 if(keyselect!=4)sprintf (menustring[4], "Crouch: %s",KeyToChar(crouchkey));
2573 else sprintf (menustring[4], "Crouch: _");
2576 endx[4]=startx[4]+strlen(menustring[4])*10;
2577 endy[4]=starty[4]+20;
2581 if(keyselect!=5)sprintf (menustring[5], "Jump: %s",KeyToChar(jumpkey));
2582 else sprintf (menustring[5], "Jump: _");
2585 endx[5]=startx[5]+strlen(menustring[5])*10;
2586 endy[5]=starty[5]+20;
2590 if(keyselect!=6)sprintf (menustring[6], "Draw: %s",KeyToChar(drawkey));
2591 else sprintf (menustring[6], "Draw: _");
2594 endx[6]=startx[6]+strlen(menustring[6])*10;
2595 endy[6]=starty[6]+20;
2599 if(keyselect!=7)sprintf (menustring[7], "Throw: %s",KeyToChar(throwkey));
2600 else sprintf (menustring[7], "Throw: _");
2603 endx[7]=startx[7]+strlen(menustring[7])*10;
2604 endy[7]=starty[7]+20;
2608 if(keyselect!=8)sprintf (menustring[8], "Attack: %s",KeyToChar(attackkey));
2609 else sprintf (menustring[8], "Attack: _");
2612 endx[8]=startx[8]+strlen(menustring[8])*10;
2613 endy[8]=starty[8]+20;
2619 sprintf (menustring[9], "Back");
2621 endx[9]=startx[9]+strlen(menustring[9])*10;
2623 endy[9]=starty[9]+20;
2628 nummenuitems=7+accountcampaignchoicesmade[accountactive]+campaignchoicenum;
2630 sprintf (menustring[0], "%s",accountname[accountactive]);
2633 endx[0]=startx[0]+strlen(menustring[0])*10;
2634 endy[0]=starty[0]+20;
2638 sprintf (menustring[1], "Tutorial");
2641 endx[1]=startx[1]+strlen(menustring[1])*10;
2642 endy[1]=starty[1]+20;
2646 sprintf (menustring[2], "Challenge");
2649 endx[2]=startx[2]+strlen(menustring[2])*10;
2650 endy[2]=starty[2]+20;
2654 sprintf (menustring[3], "Delete User");
2657 endx[3]=startx[3]+strlen(menustring[3])*10;
2658 endy[3]=starty[3]+20;
2662 sprintf (menustring[4], "Main Menu");
2665 endx[4]=startx[4]+strlen(menustring[4])*10;
2666 endy[4]=starty[4]+20;
2670 sprintf (menustring[5], "Change User");
2672 endx[5]=startx[5]+strlen(menustring[5])*10;
2674 endy[5]=starty[5]+20;
2680 sprintf (menustring[6], "World");
2682 starty[6]=30+480-400-50;
2683 endx[6]=startx[6]+400;
2688 if(accountcampaignchoicesmade[accountactive])
2689 for(i=0;i<accountcampaignchoicesmade[accountactive];i++){
2690 sprintf (menustring[7+i], campaigndescription[levelorder[i]]);
2691 startx[7+i]=30+120+campaignlocationx[levelorder[i]]*400/512;
2692 starty[7+i]=30+30+(512-campaignlocationy[levelorder[i]])*400/512;
2693 endx[7+i]=startx[7+i]+10;
2694 endy[7+i]=starty[7+i]+10;
2699 if(campaignchoicenum>0)
2700 for(i=accountcampaignchoicesmade[accountactive];i<accountcampaignchoicesmade[accountactive]+campaignchoicenum;i++){
2701 sprintf (menustring[7+i], campaigndescription[levelorder[i]]);
2702 startx[7+i]=30+120+campaignlocationx[campaignchoicewhich[i-(accountcampaignchoicesmade[accountactive])]]*400/512;
2703 starty[7+i]=30+30+(512-campaignlocationy[campaignchoicewhich[i-(accountcampaignchoicesmade[accountactive])]])*400/512;
2704 endx[7+i]=startx[7+i]+10;
2705 endy[7+i]=starty[7+i]+10;
2710 /*sprintf (menustring[7], "Dot");
2711 startx[7]=120+260*400/512;
2712 starty[7]=30+(512-184)*400/512;
2713 endx[7]=startx[7]+10;
2714 endy[7]=starty[7]+10;
2718 sprintf (menustring[8], "Dot");
2719 startx[8]=120+129*400/512;
2720 starty[8]=30+(512-284)*400/512;
2721 endx[8]=startx[8]+10;
2722 endy[8]=starty[8]+10;
2726 sprintf (menustring[9], "Dot");
2727 startx[9]=120+358*400/512;
2728 starty[9]=30+(512-235)*400/512;
2729 endx[9]=startx[9]+10;
2730 endy[9]=starty[9]+10;
2734 sprintf (menustring[10], "Dot");
2735 startx[10]=120+359*400/512;
2736 starty[10]=30+(512-308)*400/512;
2737 endx[10]=startx[10]+10;
2738 endy[10]=starty[10]+10;
2742 sprintf (menustring[11], "Dot");
2743 startx[11]=120+288*400/512;
2744 starty[11]=30+(512-277)*400/512;
2745 endx[11]=startx[11]+10;
2746 endy[11]=starty[11]+10;
2754 sprintf (menustring[0], "Are you sure you want to delete this user?");
2757 endx[0]=startx[0]+strlen(menustring[0])*10;
2758 endy[0]=starty[0]+20;
2762 sprintf (menustring[1], "Yes");
2765 endx[1]=startx[1]+strlen(menustring[1])*10;
2766 endy[1]=starty[1]+20;
2770 sprintf (menustring[2], "No");
2773 endx[2]=startx[2]+strlen(menustring[2])*10;
2774 endy[2]=starty[2]+20;
2778 sprintf (menustring[3], "Extra 4");
2781 endx[3]=startx[3]+strlen(menustring[3])*10;
2782 endy[3]=starty[3]+20;
2786 sprintf (menustring[4], "Extra 5");
2789 endx[4]=startx[4]+strlen(menustring[4])*10;
2790 endy[4]=starty[4]+20;
2794 sprintf (menustring[5], "Back");
2796 endx[5]=startx[5]+strlen(menustring[5])*10;
2798 endy[5]=starty[5]+20;
2804 nummenuitems=numaccounts+2;
2809 sprintf (menustring[0], "New User");
2811 sprintf (menustring[0], "No More Users");
2814 endx[0]=startx[0]+strlen(menustring[0])*10;
2815 endy[0]=starty[0]+20;
2819 if(entername)startx[0]+=10;
2824 for(i=0;i<numaccounts;i++){
2825 sprintf (menustring[num], "%s",accountname[i]);
2827 starty[num]=360-20-20*num;
2828 endx[num]=startx[num]+strlen(menustring[num])*10;
2829 endy[num]=starty[num]+20;
2836 sprintf (menustring[num], "Back");
2838 endx[num]=startx[num]+strlen(menustring[num])*10;
2840 endy[num]=starty[num]+20;
2847 sprintf (menustring[0], "Easier");
2850 endx[0]=startx[0]+strlen(menustring[0])*10;
2851 endy[0]=starty[0]+20;
2855 sprintf (menustring[1], "Difficult");
2858 endx[1]=startx[1]+strlen(menustring[1])*10;
2859 endy[1]=starty[1]+20;
2863 sprintf (menustring[2], "Insane");
2866 endx[2]=startx[2]+strlen(menustring[2])*10;
2867 endy[2]=starty[2]+20;
2873 //tempncl=numchallengelevels;
2874 //numchallengelevels=9;
2875 nummenuitems=2+numchallengelevels;
2878 for(j=0;j<numchallengelevels;j++){
2879 for(i=0;i<255;i++)menustring[j][i]='\0';
2880 sprintf (temp, "Level %d",j+1);
2881 strcpy(menustring[j],temp);
2882 for(i=0;i<17;i++)if(menustring[j][i]=='\0')menustring[j][i]=' ';
2883 menustring[j][17]='\0';
2884 sprintf (temp, "%d",(int)accounthighscore[accountactive][j]);
2885 strcat(menustring[j],temp);
2886 for(i=18;i<32;i++)if(menustring[j][i]=='\0')menustring[j][i]=' ';
2887 menustring[j][32]='\0';
2888 sprintf (temp, "%d:",(int)(((int)accountfasttime[accountactive][j]-(int)(accountfasttime[accountactive][j])%60)/60));
2889 strcat(menustring[j],temp);
2890 if((int)(accountfasttime[accountactive][j])%60<10)strcat(menustring[j],"0");
2891 sprintf (temp, "%d",(int)(accountfasttime[accountactive][j])%60);
2892 strcat(menustring[j],temp);
2896 endx[j]=startx[j]+strlen(menustring[j])*10;
2897 endy[j]=starty[j]+20;
2902 sprintf (menustring[numchallengelevels], "Back");
2903 startx[numchallengelevels]=10;
2904 endx[numchallengelevels]=startx[numchallengelevels]+strlen(menustring[numchallengelevels])*10;
2905 starty[numchallengelevels]=10;
2906 endy[numchallengelevels]=starty[numchallengelevels]+20;
2907 movex[numchallengelevels]=0;
2908 movey[numchallengelevels]=0;
2910 sprintf (menustring[numchallengelevels+1], " High Score Best Time");
2911 startx[numchallengelevels+1]=10;
2912 starty[numchallengelevels+1]=440;
2913 endx[numchallengelevels+1]=startx[numchallengelevels+1]+strlen(menustring[numchallengelevels+1])*10;
2914 endy[numchallengelevels+1]=starty[numchallengelevels+1]+20;
2915 movex[numchallengelevels+1]=0;
2916 movey[numchallengelevels+1]=0;
2918 //numchallengelevels=tempncl;
2922 nummenuitems=2+numchallengelevels;
2925 for(j=0;j<numchallengelevels;j++){
2926 for(i=0;i<255;i++)menustring[j][i]='\0';
2927 sprintf (temp, "Level %d",j+1);
2928 strcpy(menustring[j],temp);
2929 for(i=0;i<17;i++)if(menustring[j][i]=='\0')menustring[j][i]=' ';
2930 menustring[j][17]='\0';
2931 sprintf (temp, "%d",(int)accounthighscore[accountactive][j]);
2932 strcat(menustring[j],temp);
2933 for(i=18;i<32;i++)if(menustring[j][i]=='\0')menustring[j][i]=' ';
2934 menustring[j][32]='\0';
2935 sprintf (temp, "%d:",(int)(((int)accountfasttime[accountactive][j]-(int)(accountfasttime[accountactive][j])%60)/60));
2936 strcat(menustring[j],temp);
2937 if((int)(accountfasttime[accountactive][j])%60<10)strcat(menustring[j],"0");
2938 sprintf (temp, "%d",(int)(accountfasttime[accountactive][j])%60);
2939 strcat(menustring[j],temp);
2943 endx[j]=startx[j]+strlen(menustring[j])*10;
2944 endy[j]=starty[j]+20;
2949 sprintf (menustring[numchallengelevels], "Back");
2950 startx[numchallengelevels]=10;
2951 endx[numchallengelevels]=startx[numchallengelevels]+strlen(menustring[numchallengelevels])*10;
2952 starty[numchallengelevels]=10;
2953 endy[numchallengelevels]=starty[numchallengelevels]+20;
2954 movex[numchallengelevels]=0;
2955 movey[numchallengelevels]=0;
2957 sprintf (menustring[numchallengelevels+1], " High Score Best Time");
2958 startx[numchallengelevels+1]=10;
2959 starty[numchallengelevels+1]=400;
2960 endx[numchallengelevels+1]=startx[numchallengelevels+1]+strlen(menustring[numchallengelevels+1])*10;
2961 endy[numchallengelevels+1]=starty[numchallengelevels+1]+20;
2962 movex[numchallengelevels+1]=0;
2963 movey[numchallengelevels+1]=0;
2970 sprintf (menustring[0], "Congratulations!");
2973 endx[0]=startx[0]+strlen(menustring[0])*10;
2974 endy[0]=starty[0]+20;
2978 sprintf (menustring[1], "You have avenged your family and");
2981 endx[1]=startx[1]+strlen(menustring[1])*10;
2982 endy[1]=starty[1]+20;
2986 sprintf (menustring[2], "restored peace to the island of Lugaru.");
2989 endx[2]=startx[2]+strlen(menustring[2])*10;
2990 endy[2]=starty[2]+20;
2994 sprintf (menustring[3], "Back");
2996 endx[3]=startx[3]+strlen(menustring[3])*10;
2998 endy[3]=starty[3]+20;
3002 for(i=0;i<255;i++)menustring[4][i]='\0';
3003 sprintf (temp, "Your score:");
3004 strcpy(menustring[4],temp);
3005 for(i=0;i<20;i++)if(menustring[4][i]=='\0')menustring[4][i]=' ';
3006 menustring[4][20]='\0';
3007 sprintf (temp, "%d",(int)accountcampaignscore[accountactive]);
3008 strcat(menustring[4],temp);
3010 endx[4]=startx[4]+strlen(menustring[4])*10;
3012 endy[4]=starty[4]+20;
3016 for(i=0;i<255;i++)menustring[5][i]='\0';
3017 sprintf (temp, "Your time:");
3018 strcpy(menustring[5],temp);
3019 for(i=0;i<20;i++)if(menustring[5][i]=='\0')menustring[5][i]=' ';
3020 menustring[5][20]='\0';
3021 sprintf (temp, "%d",(int)accountcampaigntime[accountactive]);
3022 strcat(menustring[5],temp);
3024 endx[5]=startx[5]+strlen(menustring[5])*10;
3026 endy[5]=starty[5]+20;
3030 for(i=0;i<255;i++)menustring[5][i]='\0';
3031 sprintf (temp, "Highest score:");
3032 strcpy(menustring[5],temp);
3033 for(i=0;i<20;i++)if(menustring[5][i]=='\0')menustring[5][i]=' ';
3034 menustring[5][20]='\0';
3035 sprintf (temp, "%d",(int)accountcampaignhighscore[accountactive]);
3036 strcat(menustring[5],temp);
3038 endx[5]=startx[5]+strlen(menustring[5])*10;
3040 endy[5]=starty[5]+20;
3044 for(i=0;i<255;i++)menustring[7][i]='\0';
3045 sprintf (temp, "Lowest time:");
3046 strcpy(menustring[7],temp);
3047 for(i=0;i<20;i++)if(menustring[7][i]=='\0')menustring[7][i]=' ';
3048 menustring[7][20]='\0';
3049 sprintf (temp, "%d",(int)accountcampaignfasttime[accountactive]);
3050 strcat(menustring[7],temp);
3052 endx[7]=startx[7]+strlen(menustring[7])*10;
3054 endy[7]=starty[7]+20;
3061 menupulse+=multiplier*2;
3066 sprintf (menustring[0], "Register now for only $19.95!");
3069 endx[0]=startx[0]+strlen(menustring[0])*10;
3070 endy[0]=starty[0]+20;
3074 sprintf (menustring[1], "Confront raiders, wolves, and more!");
3077 endx[1]=startx[1]+strlen(menustring[1])*10;
3078 endy[1]=starty[1]+20;
3082 sprintf (menustring[2], "Fight using swords, staves and armor!");
3085 endx[2]=startx[2]+strlen(menustring[2])*10;
3086 endy[2]=starty[2]+20;
3090 if(!tryquit)sprintf (menustring[3], "Back");
3091 else sprintf (menustring[3], "Quit");
3093 endx[3]=startx[3]+strlen(menustring[3])*10;
3095 endy[3]=starty[3]+20;
3099 sprintf (menustring[4], "Register now!");
3101 endx[4]=startx[4]+strlen(menustring[4])*10;
3103 endy[4]=starty[4]+20;
3107 sprintf (menustring[5], "Enter registration code!");
3109 endx[5]=startx[5]+strlen(menustring[5])*10;
3111 endy[5]=starty[5]+20;
3120 sprintf (menustring[0], "Thank you for supporting Wolfire Software!");
3123 endx[0]=startx[0]+strlen(menustring[0])*10;
3124 endy[0]=starty[0]+20;
3128 sprintf (menustring[1], "Back");
3130 endx[1]=startx[1]+strlen(menustring[1])*10;
3132 endy[1]=starty[1]+20;
3141 sprintf (menustring[0], "Sorry, that name/serial number combination is incorrect.");
3144 endx[0]=startx[0]+strlen(menustring[0])*10;
3145 endy[0]=starty[0]+20;
3149 sprintf (menustring[1], "Back");
3151 endx[1]=startx[1]+strlen(menustring[1])*10;
3153 endy[1]=starty[1]+20;
3157 sprintf (menustring[2], "Please make sure you are copying your name and serial");
3160 endx[2]=startx[2]+strlen(menustring[2])*10;
3161 endy[2]=starty[2]+20;
3165 sprintf (menustring[3], "number exactly as they appear in your email.");
3168 endx[3]=startx[3]+strlen(menustring[3])*10;
3169 endy[3]=starty[3]+20;
3173 sprintf (menustring[4], "Capitalization and punctuation matter!");
3176 endx[4]=startx[4]+strlen(menustring[4])*10;
3177 endy[4]=starty[4]+20;
3186 sprintf (menustring[0], "Please enter your name:");
3189 endx[0]=startx[0]+strlen(menustring[0])*10;
3190 endy[0]=starty[0]+20;
3194 sprintf (menustring[1], "Please enter your name:");
3197 endx[1]=startx[1]+strlen(menustring[1])*10;
3198 endy[1]=starty[1]+20;
3207 sprintf (menustring[0], "Please enter your number:");
3210 endx[0]=startx[0]+strlen(menustring[0])*10;
3211 endy[0]=starty[0]+20;
3215 sprintf (menustring[1], "Please enter your name:");
3218 endx[1]=startx[1]+strlen(menustring[1])*10;
3219 endy[1]=starty[1]+20;
3223 char tempstring[256];
3224 sprintf (tempstring, "%s", registrationname);
3230 longnum = MD5_string ( tempstring);
3231 //longnum = 1111111111111111;
3232 num1 = longnum/100000000;
3233 num2 = longnum%100000000;
3234 sprintf (tempstring, "%d-%d-%d-%d", num1/10000, num1%10000, num2/10000, num2%10000);
3236 sprintf (menustring[2], "%s", tempstring);
3239 endx[2]=startx[2]+strlen(menustring[2])*10;
3240 endy[2]=starty[2]+20;
3245 if(mainmenu==1||mainmenu==2){
3255 starty[1]=480-152-32;
3262 starty[2]=480-228-32;
3270 starty[3]=480-306-32;
3279 starty[3]=480-306-32;
3293 starty[4]=480-140-256;
3300 starty[5]=480-138-256;
3307 starty[6]=480-144-256;
3315 starty[4]=480-140-256;
3322 starty[5]=480-138-256;
3329 starty[6]=480-144-256;
3337 starty[4]=480-140-256;
3344 starty[5]=480-150-256;
3351 starty[6]=480-144-256;
3359 starty[4]=480-140-256;
3366 starty[5]=480-150-256;
3373 starty[6]=480-144-256;
3381 starty[4]=480-100-256;
3388 starty[5]=480-120-256;
3395 starty[6]=480-144-256;
3405 if(mainmenu==1||mainmenu==2)
3407 if((mousecoordh/screenwidth*640)>startx[i]&&(mousecoordh/screenwidth*640)<endx[i]&&480-(mousecoordv/screenheight*480)>starty[i]&&480-(mousecoordv/screenheight*480)<endy[i]){
3412 if(mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==8||mainmenu==9||mainmenu==10||mainmenu==11||mainmenu==12||mainmenu==13||mainmenu==14||mainmenu==15||mainmenu==16||mainmenu==17)
3413 for(i=0;i<nummenuitems;i++){
3414 if((mousecoordh/screenwidth*640)>startx[i]&&(mousecoordh/screenwidth*640)<endx[i]&&480-(mousecoordv/screenheight*480)>starty[i]&&480-(mousecoordv/screenheight*480)<endy[i]){
3415 if(mainmenu!=5)selected=i;
3416 if(mainmenu==5&&(i!=0&&i!=6))selected=i;
3417 if(mainmenu==9&&(i!=numchallengelevels+1))selected=i;
3418 if(mainmenu==11&&(i!=numchallengelevels+1))selected=i;
3423 for(i=0;i<nummenuitems;i++){
3424 if(selected==i)selectedlong[i]+=multiplier*5;
3425 if(selectedlong[i]>1)selectedlong[i]=1;
3426 if(selected!=i)selectedlong[i]-=multiplier*5;
3427 if(selectedlong[i]<0)selectedlong[i]=0;
3428 //if(i>=4)selectedlong[i]=.3;
3429 if(i>=4&&(mainmenu==1||mainmenu==2))selectedlong[i]=0;
3433 for(i=0;i<nummenuitems;i++){
3434 offsetx[i]=(startx[i]+endx[i])/2-(mousecoordh/screenwidth*640);
3435 offsety[i]=(starty[i]+endy[i])/2-(480-(mousecoordv/screenheight*480));
3440 if(i>=4&&(mainmenu==1||mainmenu==2)){
3441 offsetx[i]=(startx[i]+endx[i]+movex[i]*transition)/2-(640+190)/2;
3442 offsety[i]=(starty[i]+endy[i]+movey[i]*transition)/2-(336+150)/2;
3448 if(mainmenu==1||mainmenu==2){
3449 glClear(GL_DEPTH_BUFFER_BIT);
3450 glEnable(GL_ALPHA_TEST);
3451 glAlphaFunc(GL_GREATER, 0.001f);
3452 glEnable(GL_TEXTURE_2D);
3453 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3454 glDisable(GL_CULL_FACE);
3455 glDisable(GL_LIGHTING);
3457 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3458 glPushMatrix(); // Store The Projection Matrix
3459 glLoadIdentity(); // Reset The Projection Matrix
3460 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
3461 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3462 glPushMatrix(); // Store The Modelview Matrix
3463 glLoadIdentity(); // Reset The Modelview Matrix
3464 glTranslatef(screenwidth/2,screenheight/2,0);
3466 glScalef((float)screenwidth/2,(float)screenheight/2,1);
3467 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3468 glDisable(GL_BLEND);
3469 glColor4f(0,0,0,1.0);
3470 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
3471 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
3472 glDisable(GL_TEXTURE_2D);
3474 //glScalef(.25,.25,.25);
3477 glVertex3f(-1, -1, 0.0f);
3479 glVertex3f(1, -1, 0.0f);
3481 glVertex3f(1, 1, 0.0f);
3483 glVertex3f(-1, 1, 0.0f);
3487 glColor4f(0.4,0.4,0.4,1.0);
3488 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
3489 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
3490 glEnable(GL_TEXTURE_2D);
3491 glBindTexture( GL_TEXTURE_2D, Mainmenuitems[4]);
3493 //glScalef(.25,.25,.25);
3496 glVertex3f(-1, -1, 0.0f);
3498 glVertex3f(1, -1, 0.0f);
3500 glVertex3f(1, 1, 0.0f);
3502 glVertex3f(-1, 1, 0.0f);
3507 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3510 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3511 glPushMatrix(); // Store The Projection Matrix
3512 glLoadIdentity(); // Reset The Projection Matrix
3513 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3514 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3515 glPushMatrix(); // Store The Modelview Matrix
3516 glLoadIdentity(); // Reset The Modelview Matrix
3518 glDisable(GL_TEXTURE_2D);
3523 if(anim!=1)glVertex3f(190, 150, 0.0f);
3524 if(anim==1)glVertex3f(190+movex[4]*transition, 150, 0.0f);
3526 glVertex3f(640, 150, 0.0f);
3528 glVertex3f(640, 336, 0.0f);
3530 if(anim!=1)glVertex3f(190, 336, 0.0f);
3531 if(anim==1)glVertex3f(190+movex[4]*transition, 336, 0.0f);
3536 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3538 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3542 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3543 glPushMatrix(); // Store The Projection Matrix
3544 glLoadIdentity(); // Reset The Projection Matrix
3545 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3546 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3547 glPushMatrix(); // Store The Modelview Matrix
3548 glLoadIdentity(); // Reset The Modelview Matrix
3549 glEnable(GL_TEXTURE_2D);
3552 for(j=0;j<nummenuitems;j++)
3554 if(j<=3||(mainmenu!=1&&mainmenu!=2))
3556 //glDisable(GL_BLEND);
3557 glEnable(GL_ALPHA_TEST);
3559 //glDisable(GL_ALPHA_TEST);
3560 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3561 if(mainmenu==1||mainmenu==2)
3564 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3565 glBindTexture( GL_TEXTURE_2D, Mainmenuitems[j]);
3566 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
3567 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
3568 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3572 glVertex3f(startx[j]+movex[j]*transition, starty[j]+movey[j]*transition, 0.0f);
3574 glVertex3f(endx[j]+movex[j]*transition, starty[j]+movey[j]*transition, 0.0f);
3576 glVertex3f(endx[j]+movex[j]*transition, endy[j]+movey[j]*transition, 0.0f);
3578 glVertex3f(startx[j]+movex[j]*transition, endy[j]+movey[j]*transition, 0.0f);
3582 //glDisable(GL_ALPHA_TEST);
3583 if(j<4)glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3586 if(1-((float)i)/10-(1-selectedlong[j])>0)
3588 glColor4f(1,1,1,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3589 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3593 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);
3595 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);
3597 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);
3599 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);
3605 if(mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==8||mainmenu==9||mainmenu==10||mainmenu==11||mainmenu==12||mainmenu==13||mainmenu==14||mainmenu==15||mainmenu==16||mainmenu==17)
3607 if(mainmenu!=5||j<6)
3610 if(mainmenu==12&&j==4)glColor4f(1,(sin(menupulse)+1)/2,(sin(menupulse)+1)/2,1);
3611 if(mainmenu==9&&j>accountprogress[accountactive]&&j<numchallengelevels)glColor4f(0.5,0,0,1);
3612 if(mainmenu==11&&j>accountprogress[accountactive]&&j<numchallengelevels)glColor4f(0.5,0,0,1);
3613 //if(1-((float)i)/10-(1-selectedlong[j])>0){
3614 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3616 if((mainmenu!=7||j!=0||!entername)&&(mainmenu!=13||j!=1)&&(mainmenu!=14||j!=1))text.glPrint(startx[j],starty[j],menustring[j],0,1,640,480);
3620 sprintf (string, "_");
3621 text.glPrint(startx[j]+(float)(displayselected)*10,starty[j],string,0,1,640,480);
3624 for(l=0;l<displaychars[k];l++){
3625 if(l<displaychars[k]){
3626 sprintf (string, "%c",displaytext[k][l]);
3627 text.glPrint(startx[j]+l*10,starty[j],string,0,1,640,480);
3635 sprintf (string, "Hooo!");
3636 text.glPrint(startx[0],starty[0],string,0,1,640,480);
3640 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3643 if(1-((float)i)/15-(1-selectedlong[j])>0)
3645 glColor4f(1,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3646 if(mainmenu==12&&j==4)glColor4f(1,(sin(menupulse)+1)/2,(sin(menupulse)+1)/2,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3647 if(mainmenu==9&&j>accountprogress[accountactive]&&j<numchallengelevels)glColor4f(0.5,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3648 if(mainmenu==11&&j>accountprogress[accountactive]&&j<numchallengelevels)glColor4f(0.5,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3649 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);
3650 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);
3651 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);
3652 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);
3653 if(mainmenu==7&&(j!=0||!entername))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);
3654 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);
3655 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);
3656 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);
3657 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);
3658 if(mainmenu==12)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);
3659 if(mainmenu==15)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);
3660 if(mainmenu==16)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);
3661 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);
3662 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);
3663 if(mainmenu==14&&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);
3666 sprintf (string, "_");
3667 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);
3670 for(l=0;l<displaychars[k];l++){
3671 if(l<displaychars[k]){
3672 sprintf (string, "%c",displaytext[k][l]);
3673 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);
3682 glClear(GL_DEPTH_BUFFER_BIT);
3683 glEnable(GL_ALPHA_TEST);
3684 glAlphaFunc(GL_GREATER, 0.001f);
3685 glEnable(GL_TEXTURE_2D);
3686 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3687 glDisable(GL_CULL_FACE);
3688 glDisable(GL_LIGHTING);
3689 if(j==6)glColor4f(1,1,1,1);
3690 else glColor4f(1,0,0,1);
3692 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3693 glPushMatrix(); // Store The Projection Matrix
3694 glLoadIdentity(); // Reset The Projection Matrix
3695 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3696 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3697 glPushMatrix(); // Store The Modelview Matrix
3698 glLoadIdentity(); // Reset The Modelview Matrix
3701 //Draw world, draw map
3702 glTranslatef(2,-5,0);
3704 if(j>6&&j<nummenuitems-1)
3706 XYZ linestart,lineend,offset;
3713 //float linestartx,lineendx,linestarty,lineendy,offsetx,offsety;
3714 linestart.x=(startx[j]+endx[j])/2;
3715 linestart.y=(starty[j]+endy[j])/2;
3716 if(j>=6+accountcampaignchoicesmade[accountactive]){
3717 linestart.x=(startx[6+accountcampaignchoicesmade[accountactive]]+endx[6+accountcampaignchoicesmade[accountactive]])/2;
3718 linestart.y=(starty[6+accountcampaignchoicesmade[accountactive]]+endy[6+accountcampaignchoicesmade[accountactive]])/2;
3720 lineend.x=(startx[j+1]+endx[j+1])/2;
3721 lineend.y=(starty[j+1]+endy[j+1])/2;
3722 offset=lineend-linestart;
3725 offset=DoRotation(offset,0,0,90);
3727 glDisable(GL_TEXTURE_2D);
3729 if(j<6+accountcampaignchoicesmade[accountactive]){
3730 glColor4f(0.5,0,0,1);
3734 if(j>=6+accountcampaignchoicesmade[accountactive]){
3740 linestart+=fac*4*startsize;
3741 lineend-=fac*4*endsize;
3743 if(!(j>7+accountcampaignchoicesmade[accountactive]+campaignchoicenum)){
3744 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3748 glVertex3f(linestart.x-offset.x*startsize, linestart.y-offset.y*startsize, 0.0f);
3750 glVertex3f(linestart.x+offset.x*startsize, linestart.y+offset.y*startsize, 0.0f);
3752 glVertex3f(lineend.x+offset.x*endsize, lineend.y+offset.y*endsize, 0.0f);
3754 glVertex3f(lineend.x-offset.x*endsize, lineend.y-offset.y*endsize, 0.0f);
3758 glEnable(GL_TEXTURE_2D);
3762 if(j==6)glBindTexture( GL_TEXTURE_2D, Mainmenuitems[7]);
3763 else glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
3764 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
3765 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
3766 if(j-7<accountcampaignchoicesmade[accountactive])glColor4f(0.5,0,0,1);
3767 if(j-7>=accountcampaignchoicesmade[accountactive])glColor4f(1,0,0,1);
3768 if(j==6)glColor4f(1,1,1,1);
3771 itemsize=abs(startx[j]-endx[j])/2;
3773 midpoint.x=(startx[j]+endx[j])/2;
3774 midpoint.y=(starty[j]+endy[j])/2;
3775 if(j>6&&(j-7<accountcampaignchoicesmade[accountactive]))itemsize*=.5;
3776 if(!(j-7>accountcampaignchoicesmade[accountactive]+campaignchoicenum))
3778 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3782 glVertex3f(midpoint.x-itemsize+movex[j]*transition, midpoint.y-itemsize+movey[j]*transition, 0.0f);
3784 glVertex3f(midpoint.x+itemsize+movex[j]*transition, midpoint.y-itemsize+movey[j]*transition, 0.0f);
3786 glVertex3f(midpoint.x+itemsize+movex[j]*transition, midpoint.y+itemsize+movey[j]*transition, 0.0f);
3788 glVertex3f(midpoint.x-itemsize+movex[j]*transition, midpoint.y+itemsize+movey[j]*transition, 0.0f);
3792 //glDisable(GL_ALPHA_TEST);
3793 if(j<4)glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3796 if(1-((float)i)/10-(1-selectedlong[j])>0)
3798 glColor4f(1,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3799 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3803 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);
3805 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);
3807 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);
3809 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);
3817 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3819 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3821 if(j-7>=accountcampaignchoicesmade[accountactive]){
3822 //glColor4f(0,0,0,1);
3823 //text.glPrintOutline(startx[j]+10-1.5,starty[j]-4-1.5,menustring[j],0,0.6*1.25,640,480);
3824 //glColor4f(1,0,0,1);
3825 //text.glPrint(startx[j]+10,starty[j]-4,menustring[j],0,0.6,640,480);
3826 text.glPrintOutlined(0.9,0,0,startx[j]+10,starty[j]-4,menustring[j],0,0.6,640,480);
3827 glDisable(GL_DEPTH_TEST);
3834 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3836 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3839 if(mainmenu==1||mainmenu==2)
3840 if(transition<.1||transition>.9){
3841 glClear(GL_DEPTH_BUFFER_BIT);
3842 glEnable(GL_ALPHA_TEST);
3843 glAlphaFunc(GL_GREATER, 0.001f);
3844 glEnable(GL_TEXTURE_2D);
3845 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3846 glDisable(GL_CULL_FACE);
3847 glDisable(GL_LIGHTING);
3849 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3850 glPushMatrix(); // Store The Projection Matrix
3851 glLoadIdentity(); // Reset The Projection Matrix
3852 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3853 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3854 glPushMatrix(); // Store The Modelview Matrix
3855 glLoadIdentity(); // Reset The Modelview Matrix
3857 glDisable(GL_TEXTURE_2D);
3858 if(transition<.1)glColor4f(1,0,0,1-(transition*10));
3859 if(transition>.9)glColor4f(1,0,0,1-((1-transition)*10));
3863 glVertex3f(190, 150, 0.0f);
3865 glVertex3f(640, 150, 0.0f);
3867 glVertex3f(640, 336, 0.0f);
3869 glVertex3f(190, 336, 0.0f);
3874 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3878 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3879 glPushMatrix(); // Store The Projection Matrix
3880 glLoadIdentity(); // Reset The Projection Matrix
3881 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
3882 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3883 glPushMatrix(); // Store The Modelview Matrix
3884 glLoadIdentity(); // Reset The Modelview Matrix
3885 glTranslatef(screenwidth/2,screenheight/2,0);
3887 glScalef((float)screenwidth/2,(float)screenheight/2,1);
3888 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3890 glEnable(GL_TEXTURE_2D);
3892 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
3893 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
3896 glTranslatef(mousecoordh-screenwidth/2,mousecoordv*-1+screenheight/2,0);
3897 glScalef((float)screenwidth/64,(float)screenwidth/64,1);
3898 glTranslatef(1,-1,0);
3899 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3901 glBindTexture( GL_TEXTURE_2D, cursortexture);
3903 //glScalef(.25,.25,.25);
3906 glVertex3f(-1, -1, 0.0f);
3908 glVertex3f(1, -1, 0.0f);
3910 glVertex3f(1, 1, 0.0f);
3912 glVertex3f(-1, 1, 0.0f);
3917 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3923 if(flashamount>1)flashamount=1;
3924 if(flashdelay<=0)flashamount-=multiplier;
3926 if(flashamount<0)flashamount=0;
3927 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3928 glDisable(GL_CULL_FACE);
3929 glDisable(GL_LIGHTING);
3930 glDisable(GL_TEXTURE_2D);
3932 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3933 glPushMatrix(); // Store The Projection Matrix
3934 glLoadIdentity(); // Reset The Projection Matrix
3935 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
3936 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3937 glPushMatrix(); // Store The Modelview Matrix
3938 glLoadIdentity(); // Reset The Modelview Matrix
3939 glScalef(screenwidth,screenheight,1);
3940 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3942 glColor4f(flashr,flashg,flashb,flashamount);
3944 glVertex3f(0, 0, 0.0f);
3945 glVertex3f(256, 0, 0.0f);
3946 glVertex3f(256, 256, 0.0f);
3947 glVertex3f(0, 256, 0.0f);
3949 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3950 glPopMatrix(); // Restore The Old Projection Matrix
3951 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3952 glPopMatrix(); // Restore The Old Projection Matrix
3953 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
3954 glEnable(GL_CULL_FACE);
3955 glDisable(GL_BLEND);
3960 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)||(!gameon&&gamestarted)){
3961 tempmult=multiplier;
3967 if(drawmode!=motionblurmode||mainmenu){
3969 // this prevents menus from rendering if you hit ESC during
3970 // motion blur sequences...maybe SDL is buffering differently?
3971 if(drawmode!=motionblurmode)
3978 //myassert(glGetError() == GL_NO_ERROR);
3979 glDrawBuffer(GL_BACK);
3980 glReadBuffer(GL_BACK);
3985 if(drawtoggle==2)drawtoggle=0;
3987 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)){
3988 multiplier=tempmult;
3990 //Jordan fixed your warning!