2 Copyright (C) 2003, 2010 - Wolfire Games
4 This file is part of Lugaru.
6 Lugaru is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; either version 2
9 of the License, or (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 See the GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 #include "openal_wrapper.h"
28 extern int environment;
29 extern float texscale;
31 extern Terrain terrain;
32 extern Sprites sprites;
33 extern float multiplier;
35 extern float viewdistance;
36 extern float fadestart;
37 extern float screenwidth,screenheight;
38 extern int kTextureSize;
39 extern FRUSTUM frustum;
41 extern Objects objects;
43 extern float usermousesensitivity;
45 extern float camerashake;
46 extern Weapons weapons;
47 extern Person player[maxplayers];
49 extern float slomodelay;
50 extern bool ismotionblur;
52 extern float blackout;
53 extern bool damageeffects;
55 extern int numplayers;
56 extern bool texttoggle;
57 extern float blurness;
58 extern float targetblurness;
59 extern float playerdist;
60 extern bool cellophane;
62 extern float flashamount,flashr,flashg,flashb;
63 extern int flashdelay;
65 extern float motionbluramount;
67 extern bool alwaysblur;
69 extern bool tilt2weird;
70 extern bool tiltweird;
72 extern bool proportionweird;
73 extern bool vertexweird[6];
74 extern bool velocityblur;
75 extern bool buttons[3];
76 extern bool debugmode;
78 extern int oldmainmenu;
79 extern int bloodtoggle;
80 extern int difficulty;
83 //extern int texdetail;
84 extern float texdetail;
85 extern bool musictoggle;
87 extern float bonusvalue;
88 extern float bonustotal;
89 extern float bonustime;
91 extern float startbonustotal;
92 extern float bonusnum[100];
93 extern int tutoriallevel;
94 extern float smoketex;
95 extern float tutorialstagetime;
96 extern float tutorialmaxtime;
97 extern int tutorialstage;
98 extern bool againbonus;
99 extern float damagedealt;
100 extern float damagetaken;
101 extern bool invertmouse;
103 extern int numhotspots;
104 extern int winhotspot;
105 extern int killhotspot;
106 extern XYZ hotspot[40];
107 extern int hotspottype[40];
108 extern float hotspotsize[40];
109 extern char hotspottext[40][256];
110 extern int currenthotspot;
112 extern int numaccounts;
113 extern int accountactive;
114 extern int accountdifficulty[10];
115 extern int accountprogress[10];
116 extern float accountpoints[10];
117 extern float accounthighscore[10][50];
118 extern float accountfasttime[10][50];
119 extern bool accountunlocked[10][60];
120 extern char accountname[10][256];
123 extern int numflipfail;
125 extern int numstaffattack;
126 extern int numswordattack;
127 extern int numknifeattack;
128 extern int numunarmedattack;
129 extern int numescaped;
130 extern int numflipped;
131 extern int numwallflipped;
132 extern int numthrowkill;
133 extern int numafterkill;
134 extern int numreversals;
135 extern int numattacks;
136 extern int maxalarmed;
137 extern int numresponded;
139 extern bool campaign;
140 extern bool winfreeze;
142 extern float menupulse;
144 extern bool gamestart;
146 extern int numdialogues;
147 extern int numdialogueboxes[max_dialogues];
148 extern int dialoguetype[max_dialogues];
149 extern int dialogueboxlocation[max_dialogues][max_dialoguelength];
150 extern float dialogueboxcolor[max_dialogues][max_dialoguelength][3];
151 extern int dialogueboxsound[max_dialogues][max_dialoguelength];
152 extern char dialoguetext[max_dialogues][max_dialoguelength][128];
153 extern char dialoguename[max_dialogues][max_dialoguelength][64];
154 extern XYZ dialoguecamera[max_dialogues][max_dialoguelength];
155 extern XYZ participantlocation[max_dialogues][10];
156 extern int participantfocus[max_dialogues][max_dialoguelength];
157 extern int participantaction[max_dialogues][max_dialoguelength];
158 extern float participantrotation[max_dialogues][10];
159 extern XYZ participantfacing[max_dialogues][max_dialoguelength][10];
160 extern float dialoguecamerarotation[max_dialogues][max_dialoguelength];
161 extern float dialoguecamerarotation2[max_dialogues][max_dialoguelength];
162 extern int indialogue;
163 extern int whichdialogue;
164 extern int directing;
165 extern float dialoguetime;
166 extern int dialoguegonethrough[20];
168 extern int accountcampaignchoicesmade[10];
169 extern int accountcampaignchoices[10][5000];
171 extern float accountcampaignhighscore[10];
172 extern float accountcampaignfasttime[10];
173 extern float accountcampaignscore[10];
174 extern float accountcampaigntime[10];
176 extern bool gamestarted;
178 extern bool showdamagebar;
180 extern OPENAL_SAMPLE *samp[100];
181 extern int channels[100];
182 extern "C" void PlaySoundEx(int channel, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
184 /*********************> DrawGLScene() <*****/
185 long long Game::MD5_string (char *string){
190 sprintf (temp, "%s",string);
193 while (i<256&&temp[i]!='\0'){
194 if(temp[i]%3==0)num+=temp[i]*124;
195 else if(temp[i]%3==1)num-=temp[i]*temp[i];
200 num=longlongabs(num);
203 while(num<LONGLONGCONST(5000000000000000)){
207 while(num>LONGLONGCONST(9900000000000000)){
213 //return 1111111111111111;
216 int Game::DrawGLScene(void)
218 static float texcoordwidth,texcoordheight;
219 static float texviewwidth, texviewheight;
221 static GLubyte color;
222 static float newbrightness;
223 static float changespeed;
224 static XYZ checkpoint;
225 static float tempmult;
227 static char string[256]="";
228 static char string2[256]="";
229 static char string3[256]="";
231 static float lastcheck;
233 lastcheck+=multiplier;
235 glColorMask( 1.0, 1.0, 1.0, 1.0 );
238 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)){
245 numboundaries=mapradius*2;
246 if(numboundaries>360)numboundaries=360;
247 for(i=0;i<numboundaries;i++){
250 boundary[i]=mapcenter+DoRotation(boundary[i]*mapradius,0,i*(360/((float)(numboundaries))),0);
259 olddrawmode=drawmode;
260 if(ismotionblur&&!loading){
261 if((findLengthfast(&player[0].velocity)>200)&&velocityblur&&!cameramode){
262 drawmode=motionblurmode;
263 motionbluramount=200/(findLengthfast(&player[0].velocity));
266 if(player[0].damage-player[0].superpermanentdamage>(player[0].damagetolerance-player[0].superpermanentdamage)*1/2&&damageeffects&&!cameramode){
267 drawmode=doublevisionmode;
274 drawmode=motionblurmode;
276 slomodelay-=multiplier;
277 if(slomodelay<0)slomo=0;
281 if((!changed&&!slomo)||loading){
283 if(ismotionblur&&(/*fps>100||*/alwaysblur)){
284 if(olddrawmode!=realmotionblurmode)change=1;
286 drawmode=realmotionblurmode;
288 else if(olddrawmode==realmotionblurmode)change=2;
292 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted))drawmode=normalmode;
293 if((freeze||winfreeze)&&ismotionblur&&!mainmenu)drawmode=radialzoommode;
295 if(winfreeze||mainmenu)drawmode=normalmode;
298 if(drawmode==glowmode){
304 DSpContext_FadeGamma(NULL,200,&color2);
308 if(drawtoggle!=2)drawtoggle=1-drawtoggle;
312 texviewwidth=kTextureSize;
313 if(texviewwidth>screenwidth)texviewwidth=screenwidth;
314 texviewheight=kTextureSize;
315 if(texviewheight>screenheight)texviewheight=screenheight;
317 texcoordwidth=screenwidth/kTextureSize;
318 texcoordheight=screenheight/kTextureSize;
319 if(texcoordwidth>1)texcoordwidth=1;
320 if(texcoordheight>1)texcoordheight=1;
323 glDrawBuffer(GL_BACK);
324 glReadBuffer(GL_BACK);
326 /*if(environment==desertenvironment)glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, (float)(abs(Random()%100))/50 );
327 else glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0);
329 if(abs(blurness-targetblurness)<multiplier*10||abs(blurness-targetblurness)>2){
330 blurness=targetblurness;
331 targetblurness=(float)(abs(Random()%100))/40;
333 if(blurness<targetblurness)blurness+=multiplier*5;
334 if(blurness>targetblurness)blurness-=multiplier*5;
337 static XYZ terrainlight;
338 static float distance;
339 //if(drawmode==normalmode)ReSizeGLScene(90,.1);
340 if(drawmode==normalmode)ReSizeGLScene(90,.1f);
341 if(drawmode!=normalmode)glViewport(0,0,texviewwidth,texviewheight);
342 glDepthFunc(GL_LEQUAL);
344 glAlphaFunc(GL_GREATER, 0.0001f);
345 glEnable(GL_ALPHA_TEST);
346 glClearColor(0.25f, 0.25f, 0.25f, 1.0f);
347 glClear(GL_DEPTH_BUFFER_BIT);
349 glMatrixMode (GL_MODELVIEW);
350 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
352 if(!cameramode&&!freeze&&!winfreeze){
353 glRotatef(float(Random()%100)/10*camerashake/*+(woozy*woozy)/10*/,0,0,1);
354 glRotatef(rotation2+sin(woozy/2)*(player[0].damage/player[0].damagetolerance)*5,1,0,0);
355 glRotatef(rotation+sin(woozy)*(player[0].damage/player[0].damagetolerance)*5,0,1,0);
357 if(cameramode||freeze||winfreeze){
358 //glRotatef(float(Random()%100)/10*camerashake/*+(woozy*woozy)/10*/,0,0,1);
359 glRotatef(rotation2,1,0,0);
360 glRotatef(rotation,0,1,0);
363 if(environment==desertenvironment){
364 glRotatef((float)(abs(Random()%100))/3000-1,1,0,0);
365 glRotatef((float)(abs(Random()%100))/3000-1,0,1,0);
366 //glRotatef(blurness/40-1,1,0,0);
367 //glRotatef(blurness/40-1,0,1,0);
369 SetUpLight(&light,0);
371 if(environment==desertenvironment&&detail==2)glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, blurness+.4 );
372 if(environment==desertenvironment){
373 glRotatef((float)(abs(Random()%100))/1000,1,0,0);
374 glRotatef((float)(abs(Random()%100))/1000,0,1,0);
377 glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0);
379 glTranslatef(-viewer.x,-viewer.y,-viewer.z);
380 frustum.GetFrustum();
384 static float size,opacity,rotation;
386 for(k=0;k<numplayers;k++){
387 if(!player[k].skeleton.free&&player[k].playerdetail&&player[k].howactive<typesleeping)
388 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)
389 for(i=0;i<player[k].skeleton.num_joints;i++){
390 if(player[k].skeleton.joints[i].label==leftknee||player[k].skeleton.joints[i].label==rightknee||player[k].skeleton.joints[i].label==groin){
391 point=DoRotation(player[k].skeleton.joints[i].position,0,player[k].rotation,0)*player[k].scale+player[k].coords;
393 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;
394 if(k!=0&&tutoriallevel==1){
395 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;
397 terrain.MakeDecal(shadowdecal,point,size,opacity,rotation);
398 if(terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz])
399 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
400 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
401 if(objects.position[j].y<player[k].coords.y||objects.type[j]==tunneltype||objects.type[j]==weirdtype){
402 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);
405 if(k!=0&&tutoriallevel==1){
406 opacity=.2+.2*sin(smoketex*6+i);
408 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
413 if((player[k].skeleton.free||player[k].howactive>=typesleeping)&&player[k].playerdetail)
414 if(frustum.SphereInFrustum(player[k].coords.x,player[k].coords.y,player[k].coords.z,player[k].scale*5)&&player[k].occluded<25)
415 for(i=0;i<player[k].skeleton.num_joints;i++){
416 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){
417 if(player[k].skeleton.free)point=player[k].skeleton.joints[i].position*player[k].scale+player[k].coords;
418 else point=DoRotation(player[k].skeleton.joints[i].position,0,player[k].rotation,0)*player[k].scale+player[k].coords;
420 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;
421 if(k!=0&&tutoriallevel==1){
422 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;
424 terrain.MakeDecal(shadowdecal,point,size,opacity*.7,rotation);
425 if(terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz])
426 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
427 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
428 if(objects.position[j].y<player[k].coords.y||objects.type[j]==tunneltype||objects.type[j]==weirdtype){
429 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);
430 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);
433 if(k!=0&&tutoriallevel==1){
434 opacity=.2+.2*sin(smoketex*6+i);
436 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
442 if(!player[k].playerdetail)
443 if(frustum.SphereInFrustum(player[k].coords.x,player[k].coords.y,player[k].coords.z,player[k].scale*5))
445 point=player[k].coords;
447 opacity=.4-(player[k].coords.y-terrain.getHeight(player[k].coords.x,player[k].coords.z))/5;
448 terrain.MakeDecal(shadowdecal,point,size,opacity*.7,rotation);
449 if(terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz])
450 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
451 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
452 point=DoRotation(player[k].coords-objects.position[j],0,-objects.rotation[j],0);
455 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
461 glEnable(GL_TEXTURE_2D);
463 glEnable(GL_DEPTH_TEST);
464 glEnable(GL_CULL_FACE);
466 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
467 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
468 glBindTexture( GL_TEXTURE_2D, terraintexture);
470 glBindTexture( GL_TEXTURE_2D, terraintexture2);
472 //glBindTexture( GL_TEXTURE_2D, terraintexture3);
473 //glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
476 terrain.drawdecals();
479 glEnable(GL_CULL_FACE);
480 glEnable(GL_LIGHTING);
482 glEnable(GL_TEXTURE_2D);
485 glEnable(GL_COLOR_MATERIAL);
500 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
501 glEnable(GL_CULL_FACE);
502 glCullFace(GL_FRONT);
504 for(k=0;k<numplayers;k++){
505 if(k==0||tutoriallevel!=1){
507 glEnable(GL_LIGHTING);
508 terrainlight=terrain.getLighting(player[k].coords.x,player[k].coords.z);
509 distance=findDistancefast(&viewer,&player[k].coords);
510 distance=(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance;
511 glColor4f(terrainlight.x,terrainlight.y,terrainlight.z,distance);
512 if(distance>=1)glDisable(GL_BLEND);
514 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;
516 if(!player[k].occluded==0)i=checkcollide(viewer,checkpoint,player[k].lastoccluded);
517 if(i==-1||player[k].occluded==0)i=checkcollide(viewer,checkpoint);
519 player[k].occluded+=1;
520 player[k].lastoccluded=i;
522 else player[k].occluded=0;
523 if(player[k].occluded<25)player[k].DrawSkeleton();
529 if(!cameramode&&musictype==stream_music2)playerdist=findDistancefastflat(&player[0].coords,&viewer);
530 else playerdist=-100;
533 glEnable(GL_TEXTURE_2D);
538 if(frustum.SphereInFrustum(realhawkcoords.x+hawk.boundingspherecenter.x,realhawkcoords.y+hawk.boundingspherecenter.y,realhawkcoords.z+hawk.boundingspherecenter.z,2)){
539 glAlphaFunc(GL_GREATER, 0.0001f);
541 glDisable(GL_CULL_FACE);
542 glDisable(GL_LIGHTING);
544 glTranslatef(hawkcoords.x,hawkcoords.y,hawkcoords.z);
545 glRotatef(hawkrotation,0,1,0);
546 glTranslatef(25,0,0);
547 distance=findDistancefast(&viewer,&realhawkcoords)*1.2;
548 glColor4f(light.color[0],light.color[1],light.color[2],(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance);
549 if((viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance>1)glColor4f(light.color[0],light.color[1],light.color[2],1);
550 if((viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance>0)
551 hawk.drawdifftex(hawktexture);
556 /*glEnable(GL_CULL_FACE);
557 glCullFace(GL_FRONT);
559 for(k=0;k<numplayers;k++){
561 glEnable(GL_LIGHTING);
562 terrainlight=terrain.getLighting(player[k].coords.x,player[k].coords.z);
563 distance=findDistancefast(&viewer,&player[k].coords);
564 distance=(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance;
565 glColor4f(terrainlight.x,terrainlight.y,terrainlight.z,distance);
566 if(distance>=1)glDisable(GL_BLEND);
568 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;
570 if(checkcollide(viewer,checkpoint)){
571 player[k].occluded+=1;
573 else player[k].occluded=0;
574 if(player[k].occluded<25)player[k].DrawSkeleton();
578 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
579 glEnable(GL_CULL_FACE);
580 glCullFace(GL_FRONT);
582 for(k=0;k<numplayers;k++){
583 if(!(k==0||tutoriallevel!=1)){
585 glEnable(GL_LIGHTING);
586 terrainlight=terrain.getLighting(player[k].coords.x,player[k].coords.z);
587 distance=findDistancefast(&viewer,&player[k].coords);
588 distance=(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance;
589 glColor4f(terrainlight.x,terrainlight.y,terrainlight.z,distance);
590 if(distance>=1)glDisable(GL_BLEND);
592 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;
594 if(!player[k].occluded==0)i=checkcollide(viewer,checkpoint,player[k].lastoccluded);
595 if(i==-1||player[k].occluded==0)i=checkcollide(viewer,checkpoint);
597 player[k].occluded+=1;
598 player[k].lastoccluded=i;
600 else player[k].occluded=0;
601 if(player[k].occluded<25)player[k].DrawSkeleton();
608 glEnable(GL_TEXTURE_2D);
613 glDisable(GL_COLOR_MATERIAL);
615 glDisable(GL_LIGHTING);
616 glDisable(GL_TEXTURE_2D);
624 glDisable(GL_LIGHTING);
625 glDisable(GL_TEXTURE_2D);
626 glDisable(GL_COLOR_MATERIAL);
629 for(k=0;k<numplayers;k++){
630 if(player[k].numwaypoints>1){
631 glBegin(GL_LINE_LOOP);
632 for(i=0;i<player[k].numwaypoints;i++){
633 glVertex3f(player[k].waypoints[i].x,player[k].waypoints[i].y+.5,player[k].waypoints[i].z);
642 for(k=0;k<numpathpoints;k++){
643 if(numpathpointconnect[k]){
644 for(i=0;i<numpathpointconnect[k];i++){
645 glBegin(GL_LINE_LOOP);
646 glVertex3f(pathpoint[k].x,pathpoint[k].y+.5,pathpoint[k].z);
647 glVertex3f(pathpoint[pathpointconnect[k][i]].x,pathpoint[pathpointconnect[k][i]].y+.5,pathpoint[pathpointconnect[k][i]].z);
655 glVertex3f(pathpoint[pathpointselected].x,pathpoint[pathpointselected].y+.5,pathpoint[pathpointselected].z);
662 glEnable(GL_TEXTURE_2D);
663 glColor4f(.5,.5,.5,1);
665 sprintf (string, " ",(int)(fps));
666 text.glPrint(10,30,string,0,.8,screenwidth,screenheight);
669 if(bonus>0&&bonustime<1&&!winfreeze&&indialogue==-1/*bonustime<4*/){
670 if(bonus==tracheotomy)sprintf (string, "Tracheotomy!");
671 else if(bonus==backstab)sprintf (string, "Backstabber!");
672 else if(bonus==spinecrusher)sprintf (string, "Spinecrusher!");
673 else if(bonus==ninja)sprintf (string, "Ninja Bonus!");
674 else if(bonus==style)sprintf (string, "Style Bonus!");
675 else if(bonus==cannon)sprintf (string, "Leg Cannon!");
676 else if(bonus==aimbonus)sprintf (string, "Nice Aim!");
677 else if(bonus==deepimpact)sprintf (string, "Heavy Impact!");
678 else if(bonus==touchofdeath)sprintf (string, "Touch of Death!");
679 else if(bonus==swordreversebonus)sprintf (string, "Sword Disarm!");
680 else if(bonus==staffreversebonus)sprintf (string, "Staff Disarm!");
681 else if(bonus==reverseko)sprintf (string, "Reversal KO!");
682 else if(bonus==solidhit)sprintf (string, "Solid Hit!");
683 else if(bonus==twoxcombo)sprintf (string, "2X Combo!");
684 else if(bonus==threexcombo)sprintf (string, "3X Combo!");
685 else if(bonus==fourxcombo)sprintf (string, "4X COMBO!");
686 else if(bonus==megacombo)sprintf (string, "MEGA COMBO!");
687 else if(bonus==Reversal)sprintf (string, "Reversal!");
688 else if(bonus==Stabbonus)sprintf (string, "Punctured!");
689 else if(bonus==Slicebonus)sprintf (string, "Sliced!");
690 else if(bonus==Bullseyebonus)sprintf (string, "Bullseye!");
691 else if(bonus==Slashbonus)sprintf (string, "Slashed!");
692 else if(bonus==Wolfbonus)sprintf (string, "WOLF SLAYER!");
693 else if(bonus==FinishedBonus)sprintf (string, "SLAIN!");
694 else if(bonus==TackleBonus)sprintf (string, "Tackle!");
695 else if(bonus==AboveBonus)sprintf (string, "Death from Above!");
696 else sprintf (string, "Excellent!");
698 glColor4f(0,0,0,1-bonustime);
699 text.glPrintOutline(1024/2-10*strlen(string)-4,768/16-4+768*4/5,string,1,2.5,1024,768);
700 glColor4f(1,0,0,1-bonustime);
701 text.glPrint(1024/2-10*strlen(string),768/16+768*4/5,string,1,2,1024,768);
703 sprintf (string, "%d",(int)bonusvalue);
704 glColor4f(0,0,0,1-bonustime);
705 text.glPrintOutline(1024/2-10*strlen(string)-4,768/16-4-20+768*4/5,string,1,2.5*.8,1024,768);
706 glColor4f(1,0,0,1-bonustime);
707 text.glPrint(1024/2-10*strlen(string),768/16-20+768*4/5,string,1,2*.8,1024,768);
708 glColor4f(.5,.5,.5,1);
711 if(tutoriallevel==1){
712 tutorialopac=tutorialmaxtime-tutorialstagetime;
713 if(tutorialopac>1)tutorialopac=1;
714 if(tutorialopac<0)tutorialopac=0;
716 sprintf (string, " ");
717 sprintf (string2, " ");
718 sprintf (string3, " ");
719 if(tutorialstage==0){
720 sprintf (string, " ");
721 sprintf (string2, " ");
722 sprintf (string3, " ");
724 if(tutorialstage==1){
725 sprintf (string, "Welcome to the Lugaru training level!");
726 sprintf (string2, " ");
727 sprintf (string3, " ");
729 if(tutorialstage==2){
730 sprintf (string, "BASIC MOVEMENT:");
731 sprintf (string2, " ");
732 sprintf (string3, " ");
734 if(tutorialstage==3){
735 sprintf (string, "You can move the mouse to rotate the camera.");
736 sprintf (string2, " ");
737 sprintf (string3, " ");
739 if(tutorialstage==4){
740 sprintf (string, "Try using the %s, %s, %s and %s keys to move around.",KeyToChar(forwardkey),KeyToChar(leftkey),KeyToChar(backkey),KeyToChar(rightkey));
741 sprintf (string2, "All movement is relative to the camera.");
742 sprintf (string3, " ");
744 if(tutorialstage==5){
745 sprintf (string, "Please press %s to jump.",KeyToChar(jumpkey));
746 sprintf (string2, "You can hold it longer to jump higher.");
747 sprintf (string3, " ");
749 if(tutorialstage==6){
750 sprintf (string, "You can press %s to crouch.",KeyToChar(crouchkey));
751 sprintf (string2, "You can jump higher from a crouching position.");
752 sprintf (string3, " ");
754 if(tutorialstage==7){
755 sprintf (string, "While running, you can press %s to roll.",KeyToChar(crouchkey));
756 sprintf (string2, " ");
757 sprintf (string3, " ");
759 if(tutorialstage==8){
760 sprintf (string, "While crouching, you can sneak around silently");
761 sprintf (string2, "using the movement keys.");
762 sprintf (string3, " ");
764 if(tutorialstage==9){
765 sprintf (string, "Release the crouch key while sneaking and hold the movement keys");
766 sprintf (string2, "to run animal-style.");
767 sprintf (string3, " ");
769 if(tutorialstage==10){
770 sprintf (string, "ADVANCED MOVEMENT:");
771 sprintf (string2, " ");
772 sprintf (string3, " ");
774 if(tutorialstage==11){
775 sprintf (string, "When you jump at a wall, you can hold %s again",KeyToChar(jumpkey));
776 sprintf (string2, "during impact to perform a walljump.");
777 sprintf (string3, "Be sure to use the movement keys to press against the wall");
779 if(tutorialstage==12){
780 sprintf (string, "While in the air, you can press crouch to flip.",KeyToChar(jumpkey));
781 sprintf (string2, "Walljumps and flips confuse enemies and give you more control.");
782 sprintf (string3, " ");
784 if(tutorialstage==13){
785 sprintf (string, "BASIC COMBAT:");
786 sprintf (string2, " ");
787 sprintf (string3, " ");
789 if(tutorialstage==14){
790 sprintf (string, "There is now an imaginary enemy");
791 sprintf (string2, "in the middle of the training area.");
792 sprintf (string3, " ");
794 if(tutorialstage==15){
795 if(attackkey==MAC_MOUSEBUTTON1)sprintf (string, "Click to attack when you are near an enemy.");
796 else sprintf (string, "Press %s to attack when you are near an enemy.",KeyToChar(attackkey));
797 sprintf (string2, "You can punch by standing still near an enemy and attacking.");
798 sprintf (string3, " ");
800 if(tutorialstage==16){
801 sprintf (string, "If you are close, you will perform a weak punch.");
802 sprintf (string2, "The weak punch is excellent for starting attack combinations.");
803 sprintf (string3, " ");
805 if(tutorialstage==17){
806 sprintf (string, "Attacking while running results in a spin kick.");
807 sprintf (string2, "This is one of your most powerful ground attacks.");
808 sprintf (string3, " ");
810 if(tutorialstage==18){
811 sprintf (string, "Sweep the enemy's legs out by attacking while crouched.");
812 sprintf (string2, "This is a very fast attack, and easy to follow up.");
813 sprintf (string3, " ");
815 if(tutorialstage==19){
816 sprintf (string, "When an enemy is on the ground, you can deal some extra");
817 sprintf (string2, "damage by running up and drop-kicking him.");
818 sprintf (string3, "(Try knocking them down with a sweep first)");
820 if(tutorialstage==20){
821 sprintf (string, "Your most powerful individual attack is the rabbit kick.");
822 if(attackkey==MAC_MOUSEBUTTON1)sprintf (string2, "Run at the enemy while holding the mouse button, and press");
823 else sprintf (string2, "Run at the enemy while holding %s, and press", KeyToChar(attackkey));
824 sprintf (string3, "the jump key (%s) to attack.",KeyToChar(jumpkey));
826 if(tutorialstage==21){
827 sprintf (string, "This attack is devastating if timed correctly.");
828 sprintf (string2, "Even if timed incorrectly, it will knock the enemy over.");
829 if(againbonus)sprintf (string3, "Try rabbit-kicking the imaginary enemy again.");
830 else sprintf (string3, "Try rabbit-kicking the imaginary enemy.");
832 if(tutorialstage==22){
833 sprintf (string, "If you sneak behind an enemy unnoticed, you can kill");
834 sprintf (string2, "him instantly. Move close behind this enemy");
835 sprintf (string3, "and attack.");
837 if(tutorialstage==23){
838 sprintf (string, "Another important attack is the wall kick. When an enemy");
839 sprintf (string2, "is near a wall, perform a walljump nearby and hold");
840 sprintf (string3, "the attack key during impact with the wall.");
842 if(tutorialstage==24){
843 sprintf (string, "You can tackle enemies by running at them animal-style");
844 if(attackkey==MAC_MOUSEBUTTON1)sprintf (string2, "and pressing jump (%s) or attack(mouse button).",KeyToChar(jumpkey));
845 else sprintf (string2, "and pressing jump (%s) or attack(%s).",KeyToChar(jumpkey),KeyToChar(attackkey));
846 sprintf (string3, "This is especially useful when they are running away.");
848 if(tutorialstage==25){
849 sprintf (string, "Dodge by pressing back and attack. Dodging is essential");
850 sprintf (string2, "against enemies with swords or other long weapons.");
851 sprintf (string3, " ");
853 if(tutorialstage==26){
854 sprintf (string, "REVERSALS AND COUNTER-REVERSALS");
855 sprintf (string2, " ");
856 sprintf (string3, " ");
858 if(tutorialstage==27){
859 sprintf (string, "The enemy can now reverse your attacks.");
860 sprintf (string2, " ");
861 sprintf (string3, " ");
863 if(tutorialstage==28){
864 sprintf (string, "If you attack, you will notice that the enemy now sometimes");
865 sprintf (string2, "catches your attack and uses it against you. Hold");
866 sprintf (string3, "crouch (%s) after attacking to escape from reversals.",KeyToChar(crouchkey));
868 if(tutorialstage==29){
869 sprintf (string, "Try escaping from two more reversals in a row.");
870 sprintf (string2, " ");
871 sprintf (string3, " ");
873 if(tutorialstage==30){
874 sprintf (string, "Good!");
875 sprintf (string2, " ");
876 sprintf (string3, " ");
878 if(tutorialstage==31){
879 sprintf (string, "To reverse an attack, you must tap crouch (%s) during the",KeyToChar(crouchkey));
880 sprintf (string2, "enemy's attack. You must also be close to the enemy;");
881 sprintf (string3, "this is especially important against armed opponents.");
883 if(tutorialstage==32){
884 sprintf (string, "The enemy can attack in %d seconds.", (int)(tutorialmaxtime-tutorialstagetime));
885 sprintf (string2, "This imaginary opponents attacks will be highlighted");
886 sprintf (string3, "to make this easier.");
888 if(tutorialstage==33){
889 sprintf (string, "Reverse three enemy attacks!");
890 sprintf (string2, " ");
891 sprintf (string3, " ");
893 if(tutorialstage==34){
894 sprintf (string, "Reverse two more enemy attacks!");
895 sprintf (string2, " ");
896 sprintf (string3, " ");
898 if(tutorialstage==35){
899 sprintf (string, "Reverse one more enemy attack!");
900 sprintf (string2, " ");
901 sprintf (string3, " ");
903 if(tutorialstage==36){
904 sprintf (string, "Excellent!");
905 sprintf (string2, " ");
906 sprintf (string3, " ");
908 if(tutorialstage==37){
909 sprintf (string, "Now spar with the enemy for %d more seconds.", (int)(tutorialmaxtime-tutorialstagetime));
910 sprintf (string2, "Damage dealt: %d",(int)damagedealt);
911 sprintf (string3, "Damage taken: %d.",(int)damagetaken);
913 if(tutorialstage==38){
914 sprintf (string, "WEAPONS:");
915 sprintf (string2, " ");
916 sprintf (string3, " ");
918 if(tutorialstage==39){
919 sprintf (string, "There is now an imaginary knife");
920 sprintf (string2, "in the center of the training area.");
921 sprintf (string3, " ");
923 if(tutorialstage==40){
924 sprintf (string, "Stand, roll or handspring over the knife");
925 sprintf (string2, "while pressing %s to pick it up.",KeyToChar(throwkey));
926 sprintf (string3, "You can crouch and press the same key to drop it again.");
928 if(tutorialstage==41){
929 sprintf (string, "You can equip and unequip weapons using the %s key.",KeyToChar(drawkey));
930 sprintf (string2, "Sometimes it is best to keep them unequipped to");
931 sprintf (string3, "prevent enemies from taking them. ");
933 if(tutorialstage==42){
934 sprintf (string, "The knife is the smallest weapon and the least encumbering.");
935 sprintf (string2, "You can equip or unequip it while standing, crouching,");
936 sprintf (string3, "running or flipping.");
938 if(tutorialstage==43){
939 sprintf (string, "You perform weapon attacks the same way as unarmed attacks,");
940 sprintf (string2, "but sharp weapons cause permanent damage, instead of the");
941 sprintf (string3, "temporary trauma from blunt weapons, fists and feet.");
943 if(tutorialstage==44){
944 sprintf (string, "The enemy now has your knife!");
945 sprintf (string2, "Please reverse two of his knife attacks.");
946 sprintf (string3, " ");
948 if(tutorialstage==45){
949 sprintf (string, "Please reverse one more of his knife attacks.");
950 sprintf (string2, " ");
951 sprintf (string3, " ");
953 if(tutorialstage==46){
954 sprintf (string, "Now he has a sword!");
955 sprintf (string2, "The sword has longer reach than your arms, so you");
956 sprintf (string3, "must move close to reverse the sword slash.");
958 if(tutorialstage==47){
959 sprintf (string, "Long weapons like the sword and staff are also useful for defense;");
960 sprintf (string2, "you can parry enemy weapon attacks by pressing the attack key");
961 sprintf (string3, "at the right time. Please try parrying the enemy's attacks!");
963 if(tutorialstage==48){
964 sprintf (string, "The staff is like the sword, but has two main attacks.");
965 sprintf (string2, "The standing smash is fast and effective, and the running");
966 sprintf (string3, "spin smash is slower and more powerful.");
968 if(tutorialstage==49){
969 sprintf (string, "When facing an enemy, you can throw the knife with %s.",KeyToChar(throwkey));
970 sprintf (string2, "It is possible to throw the knife while flipping,");
971 sprintf (string3, "but it is very inaccurate.");
973 if(tutorialstage==50){
974 sprintf (string, "You now know everything you can learn from training.");
975 sprintf (string2, "Everything else you must learn from experience!");
976 sprintf (string3, " ");
978 if(tutorialstage==51){
979 sprintf (string, "Walk out of the training area to return to the main menu.");
980 sprintf (string2, " ");
981 sprintf (string3, " ");
984 glColor4f(0,0,0,tutorialopac);
985 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);
986 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);
987 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);
988 glColor4f(1,1,1,tutorialopac);
989 text.glPrint(screenwidth/2-7.6*strlen(string)*screenwidth/1024,screenheight/16+screenheight*4/5,string,1,1.5*screenwidth/1024,screenwidth,screenheight);
990 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);
991 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);
993 sprintf (string, "Press 'tab' to skip to the next item.",KeyToChar(jumpkey));
994 sprintf (string2, "Press escape at any time to");
995 sprintf (string3, "pause or exit the tutorial.");
998 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);
999 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);
1000 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);
1001 glColor4f(0.5,0.5,0.5,1);
1002 text.glPrint(screenwidth/2-7.6*strlen(string)*screenwidth/1024*.8,0+screenheight*1/10,string,1,1.5*screenwidth/1024*.8,screenwidth,screenheight);
1003 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);
1004 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);
1008 if(numhotspots&&(bonustime>=1||bonus<=0||bonustime<0)&&!tutoriallevel){
1010 float closestdist=-1;
1012 closest=currenthotspot;
1013 for(i=0;i<numhotspots;i++){
1014 distance=findDistancefast(&player[0].coords,&hotspot[i]);
1015 if(closestdist==-1||distance<closestdist){
1016 if(findDistancefast(&player[0].coords,&hotspot[i])<hotspotsize[i]&&((hotspottype[i]<=10&&hotspottype[i]>=0)||(hotspottype[i]<=40&&hotspottype[i]>=20))){
1017 closestdist=distance;
1023 currenthotspot=closest;
1024 if(currenthotspot!=-1){
1025 if(hotspottype[closest]<=10){
1026 if(findDistancefast(&player[0].coords,&hotspot[closest])<hotspotsize[closest])
1027 tutorialstagetime=0;
1029 tutorialopac=tutorialmaxtime-tutorialstagetime;
1030 if(tutorialopac>1)tutorialopac=1;
1031 if(tutorialopac<0)tutorialopac=0;
1033 sprintf (string, "%s", hotspottext[closest]);
1041 if(string[i]=='\n'||string[i]>'z'||string[i]<' '||string[i]=='\0'){
1042 glColor4f(0,0,0,tutorialopac);
1043 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);
1044 glColor4f(1,1,1,tutorialopac);
1045 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);
1048 if(string[i]=='\0')done=1;
1054 else if (hotspottype[closest]>=20&&dialoguegonethrough[hotspottype[closest]-20]==0){
1055 whichdialogue=hotspottype[closest]-20;
1056 for(j=0;j<numdialogueboxes[whichdialogue];j++){
1057 player[participantfocus[whichdialogue][j]].coords=participantlocation[whichdialogue][participantfocus[whichdialogue][j]];
1058 player[participantfocus[whichdialogue][j]].rotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
1059 player[participantfocus[whichdialogue][j]].targetrotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
1060 player[participantfocus[whichdialogue][j]].velocity=0;
1061 player[participantfocus[whichdialogue][j]].targetanimation=player[participantfocus[whichdialogue][j]].getIdle();
1062 player[participantfocus[whichdialogue][j]].targetframe=0;
1066 dialoguegonethrough[whichdialogue]++;
1067 if(dialogueboxsound[whichdialogue][indialogue]!=0){
1068 static float gLoc[3];
1069 static float vel[3];
1070 gLoc[0]=player[participantfocus[whichdialogue][indialogue]].coords.x;
1071 gLoc[1]=player[participantfocus[whichdialogue][indialogue]].coords.y;
1072 gLoc[2]=player[participantfocus[whichdialogue][indialogue]].coords.z;
1077 if(dialogueboxsound[whichdialogue][indialogue]==1)whichsoundplay=rabbitchitter;
1078 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
1079 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
1080 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
1081 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
1082 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
1083 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
1084 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
1085 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
1086 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
1087 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
1088 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
1089 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
1090 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
1091 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
1092 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
1093 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
1094 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
1095 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
1096 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
1097 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, true);
1098 OPENAL_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
1099 OPENAL_SetVolume(channels[whichsoundplay], 256);
1100 OPENAL_SetPaused(channels[whichsoundplay], false);
1106 if(indialogue!=-1&&!mainmenu){
1107 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1108 glDisable(GL_CULL_FACE);
1109 glDisable(GL_LIGHTING);
1110 glDisable(GL_TEXTURE_2D);
1112 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1113 glPushMatrix(); // Store The Projection Matrix
1114 glLoadIdentity(); // Reset The Projection Matrix
1115 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1116 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1117 glPushMatrix(); // Store The Modelview Matrix
1118 glLoadIdentity(); // Reset The Modelview Matrix
1119 if(dialogueboxlocation[whichdialogue][indialogue]==1)glTranslatef(0,screenheight*3/4,0);
1120 glScalef(screenwidth,screenheight/4,1);
1121 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1124 glColor4f(dialogueboxcolor[whichdialogue][indialogue][0],dialogueboxcolor[whichdialogue][indialogue][1],dialogueboxcolor[whichdialogue][indialogue][2],0.7);
1126 glVertex3f(0, 0, 0.0f);
1127 glVertex3f(1, 0, 0.0f);
1128 glVertex3f(1, 1, 0.0f);
1129 glVertex3f(0, 1, 0.0f);
1131 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1132 glPopMatrix(); // Restore The Old Projection Matrix
1133 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1134 glPopMatrix(); // Restore The Old Projection Matrix
1135 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1136 glEnable(GL_CULL_FACE);
1137 glDisable(GL_BLEND);
1139 glEnable(GL_TEXTURE_2D);
1146 startx=screenwidth*1/5;
1147 if(dialogueboxlocation[whichdialogue][indialogue]==1)starty=screenheight/16+screenheight*4/5;
1148 if(dialogueboxlocation[whichdialogue][indialogue]==2)starty=screenheight*1/5-screenheight/16;
1150 // char tempname[64];
1154 // for(i=0;i<64;i++){
1159 for(i=0;i<(int)strlen(dialoguename[whichdialogue][indialogue]);i++){
1160 tempname[tempnum]=dialoguename[whichdialogue][indialogue][i];
1162 if(dialoguename[whichdialogue][indialogue][i]=='#'||dialoguename[whichdialogue][indialogue][i]=='\0')goodchar=0;
1163 //if(tempnum>2)if(tempname[tempnum-2]=='e'&&tempname[tempnum-1]=='r')goodchar=0;
1164 //if(tempnum>2)if(tempname[tempnum]=='r'&&tempname[0]=='a')goodchar=0;
1165 if(goodchar)tempnum++;
1166 else tempname[tempnum]='\0';
1169 sprintf (string, "%s: ", tempname);
1171 if(dialogueboxcolor[whichdialogue][indialogue][0]+dialogueboxcolor[whichdialogue][indialogue][1]+dialogueboxcolor[whichdialogue][indialogue][2]<1.5){
1172 glColor4f(0,0,0,tutorialopac);
1173 text.glPrintOutline(startx-2*7.6*strlen(string)*screenwidth/1024-4,starty-4,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight);
1174 glColor4f(0.7,0.7,0.7,tutorialopac);
1175 text.glPrint(startx-2*7.6*strlen(string)*screenwidth/1024,starty,string,1,1.5*screenwidth/1024,screenwidth,screenheight);
1179 glColor4f(0,0,0,tutorialopac);
1180 text.glPrintOutline(startx-2*7.6*strlen(string)*screenwidth/1024-4,starty-4,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight);
1185 for(i=0;i<(int)strlen(dialoguetext[whichdialogue][indialogue])+1;i++){
1186 tempname[tempnum]=dialoguetext[whichdialogue][indialogue][i];
1187 if(dialoguetext[whichdialogue][indialogue][i]!='#')tempnum++;
1191 sprintf (string, "%s", tempname);
1200 if(string[i]=='\n'||string[i]>'z'||string[i]<' '||string[i]=='\0'){
1201 if(dialogueboxcolor[whichdialogue][indialogue][0]+dialogueboxcolor[whichdialogue][indialogue][1]+dialogueboxcolor[whichdialogue][indialogue][2]<1.5){
1202 glColor4f(0,0,0,tutorialopac);
1203 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);
1204 glColor4f(1,1,1,tutorialopac);
1205 text.glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/,starty-20*screenwidth/1024*line,string,1,1.5*screenwidth/1024,screenwidth,screenheight,lastline,i);
1209 glColor4f(0,0,0,tutorialopac);
1210 text.glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/,starty-20*screenwidth/1024*line,string,1,1.5*screenwidth/1024,screenwidth,screenheight,lastline,i);
1214 if(string[i]=='\0')done=1;
1221 if(!tutoriallevel&&!winfreeze&&indialogue==-1&&!mainmenu){
1223 if(!scoreadded)sprintf (string, "Score: %d", (int)accountcampaignscore[accountactive]+(int)bonustotal);//(int)bonustotal);
1224 if(scoreadded)sprintf (string, "Score: %d", (int)accountcampaignscore[accountactive]);//(int)bonustotal);
1226 if(!campaign)sprintf (string, "Score: %d", (int)bonustotal);
1228 text.glPrintOutline(1024/40-4,768/16-4+768*14/16,string,1,1.5*1.25,1024,768);
1230 text.glPrint(1024/40,768/16+768*14/16,string,1,1.5,1024,768);
1232 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1233 glDisable(GL_CULL_FACE);
1234 glDisable(GL_LIGHTING);
1235 glDisable(GL_TEXTURE_2D);
1237 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1238 glPushMatrix(); // Store The Projection Matrix
1239 glLoadIdentity(); // Reset The Projection Matrix
1240 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1241 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1242 glPushMatrix(); // Store The Modelview Matrix
1243 glLoadIdentity(); // Reset The Modelview Matrix
1244 glTranslatef(15,screenheight*17.5/20,0);
1245 glScalef(screenwidth/3+20,screenheight/20,1);
1246 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1248 glColor4f(0.0,0.4,0.0,0.7);
1249 float bar=((float)player[0].damage)/player[0].damagetolerance;
1251 glVertex3f((bar<1?bar:1),0,0.0f);
1252 glVertex3f(1,0,0.0f);
1253 glVertex3f(1,1,0.0f);
1254 glVertex3f((bar<1?bar:1),1,0.0f);
1256 glColor4f(0.1,0.0,0.0,1);
1257 bar = ((float)player[0].bloodloss)/player[0].damagetolerance;
1259 glVertex3f(0,0,0.0f);
1260 glVertex3f((bar<1?bar:1),0,0.0f);
1261 glVertex3f((bar<1?bar:1),1,0.0f);
1262 glVertex3f(0,1,0.0f);
1264 glColor4f(0.4,0.0,0.0,0.7);
1265 bar = ((float)player[0].damage)/player[0].damagetolerance;
1267 glVertex3f(0,0,0.0f);
1268 glVertex3f((bar<1?bar:1),0,0.0f);
1269 glVertex3f((bar<1?bar:1),1,0.0f);
1270 glVertex3f(0,1,0.0f);
1272 glColor4f(0.4,0.0,0.0,0.7);
1273 bar = ((float)player[0].permanentdamage)/player[0].damagetolerance;
1275 glVertex3f(0,0,0.0f);
1276 glVertex3f((bar<1?bar:1),0,0.0f);
1277 glVertex3f((bar<1?bar:1),1,0.0f);
1278 glVertex3f(0,1,0.0f);
1280 glColor4f(0.4,0.0,0.0,0.7);
1281 bar = ((float)player[0].superpermanentdamage)/player[0].damagetolerance;
1283 glVertex3f(0,0,0.0f);
1284 glVertex3f((bar<1?bar:1),0,0.0f);
1285 glVertex3f((bar<1?bar:1),1,0.0f);
1286 glVertex3f(0,1,0.0f);
1288 glColor4f(0.0,0.0,0.0,0.7);
1290 glBegin(GL_LINE_STRIP);
1291 glVertex3f(0,0,0.0f);
1292 glVertex3f(1,0,0.0f);
1293 glVertex3f(1,1,0.0f);
1294 glVertex3f(0,1,0.0f);
1295 glVertex3f(0,0,0.0f);
1298 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1299 glPopMatrix(); // Restore The Old Projection Matrix
1300 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1301 glPopMatrix(); // Restore The Old Projection Matrix
1302 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1303 glEnable(GL_CULL_FACE);
1304 glDisable(GL_BLEND);
1306 glEnable(GL_TEXTURE_2D);
1308 // writing the numbers :
1309 sprintf (string, "Damages : %d/%d (%d)",(int)(player[0].damage),(int)(player[0].damagetolerance),(int)(player[0].bloodloss));
1311 text.glPrintOutline(1024/40-4,768/16-4+768*14/16-40,string,1,1.5*1.25,1024,768);
1313 text.glPrint(1024/40,768/16+768*14/16-40,string,1,1.5,1024,768);
1317 glColor4f(.5,.5,.5,1);
1320 if((texttoggle||editorenabled)&&debugmode&&!mainmenu){
1321 sprintf (string, "The framespersecond is %d.",(int)(fps));
1322 text.glPrint(10,30,string,0,.8,1024,768);
1324 sprintf (string, "Name: %s", registrationname);
1325 text.glPrint(10,260,string,0,.8,1024,768);
1328 if(editorenabled)sprintf (string, "Map editor enabled.");
1329 if(!editorenabled)sprintf (string, "Map editor Disabled.");
1330 text.glPrint(10,60,string,0,.8,1024,768);
1332 sprintf (string, "Object size: %f",editorsize);
1333 text.glPrint(10,75,string,0,.8,1024,768);
1334 if(editorrotation>=0)sprintf (string, "Object rotation: %f",editorrotation);
1335 else sprintf (string, "Object rotation: Random");
1336 text.glPrint(10,90,string,0,.8,1024,768);
1337 if(editorrotation2>=0)sprintf (string, "Object rotation2: %f",editorrotation2);
1338 else sprintf (string, "Object rotation2: Random");
1339 text.glPrint(10,105,string,0,.8,1024,768);
1340 sprintf (string, "Object type: %d",editortype);
1341 text.glPrint(10,120,string,0,.8,1024,768);
1342 if(editortype==boxtype)sprintf (string, "(box)");
1343 if(editortype==treetrunktype)sprintf (string, "(tree)");
1344 if(editortype==walltype)sprintf (string, "(wall)");
1345 if(editortype==weirdtype)sprintf (string, "(weird)");
1346 if(editortype==spiketype)sprintf (string, "(spike)");
1347 if(editortype==rocktype)sprintf (string, "(rock)");
1348 if(editortype==bushtype)sprintf (string, "(bush)");
1349 if(editortype==tunneltype)sprintf (string, "(tunnel)");
1350 if(editortype==chimneytype)sprintf (string, "(chimney)");
1351 if(editortype==platformtype)sprintf (string, "(platform)");
1352 if(editortype==cooltype)sprintf (string, "(cool)");
1353 if(editortype==firetype)sprintf (string, "(fire)");
1354 text.glPrint(130,120,string,0,.8,1024,768);
1356 sprintf (string, "Numplayers: %d",numplayers);
1357 text.glPrint(10,155,string,0,.8,1024,768);
1358 sprintf (string, "Player %d: numwaypoints: %d",numplayers,player[numplayers-1].numwaypoints);
1359 text.glPrint(10,140,string,0,.8,1024,768);
1361 /*sprintf (string, "Coords are: %f %f %f",player[0].coords.x,player[0].coords.y,player[0].coords.z);
1362 text.glPrint(10,200,string,0,.8,1024,768);*/
1363 sprintf (string, "Difficulty: %d",difficulty);
1364 text.glPrint(10,240,string,0,.8,1024,768);
1366 sprintf (string, "lasthotspot: %d",hotspottype[numhotspots-1]);
1367 text.glPrint(10,240,string,0,.8,1024,768);
1368 sprintf (string, "killhotspot: %d",killhotspot);
1369 text.glPrint(10,220,string,0,.8,1024,768);
1370 sprintf (string, "winhotspot: %d",winhotspot);
1371 text.glPrint(10,200,string,0,.8,1024,768);*/
1376 if(drawmode==glowmode){
1377 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1378 glDisable(GL_CULL_FACE);
1379 glDisable(GL_LIGHTING);
1380 glDisable(GL_TEXTURE_2D);
1382 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1383 glPushMatrix(); // Store The Projection Matrix
1384 glLoadIdentity(); // Reset The Projection Matrix
1385 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1386 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1387 glPushMatrix(); // Store The Modelview Matrix
1388 glLoadIdentity(); // Reset The Modelview Matrix
1389 glScalef(screenwidth,screenheight,1);
1390 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1392 glColor4f(0,0,0,.5);
1394 glVertex3f(0, 0, 0.0f);
1395 glVertex3f(256, 0, 0.0f);
1396 glVertex3f(256, 256, 0.0f);
1397 glVertex3f(0, 256, 0.0f);
1399 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1400 glPopMatrix(); // Restore The Old Projection Matrix
1401 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1402 glPopMatrix(); // Restore The Old Projection Matrix
1403 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1404 glEnable(GL_CULL_FACE);
1405 glDisable(GL_BLEND);
1409 if((((blackout&&damageeffects)||(player[0].bloodloss>0&&damageeffects&&player[0].blooddimamount>0)||player[0].dead)&&!cameramode)||console){
1410 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1411 glDisable(GL_CULL_FACE);
1412 glDisable(GL_LIGHTING);
1413 glDisable(GL_TEXTURE_2D);
1415 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1416 glPushMatrix(); // Store The Projection Matrix
1417 glLoadIdentity(); // Reset The Projection Matrix
1418 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1419 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1420 glPushMatrix(); // Store The Modelview Matrix
1421 glLoadIdentity(); // Reset The Modelview Matrix
1422 glScalef(screenwidth,screenheight,1);
1423 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1425 if(player[0].dead)blackout+=multiplier*3;
1426 if(player[0].dead==1)blackout=.4f;
1427 if(player[0].dead==2&&blackout>.6)blackout=.6;
1428 glColor4f(0,0,0,blackout);
1429 if(!player[0].dead){
1430 if((player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5))*.3<.3){
1431 glColor4f(0,0,0,player[0].blooddimamount*player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5)*.3);
1432 blackout=player[0].blooddimamount*player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5)*.3;
1435 glColor4f(0,0,0,player[0].blooddimamount*.3);
1436 blackout=player[0].blooddimamount*.3;
1439 if(console)glColor4f(.7,0,0,.2);
1441 glVertex3f(0, 0, 0.0f);
1442 glVertex3f(256, 0, 0.0f);
1443 glVertex3f(256, 256, 0.0f);
1444 glVertex3f(0, 256, 0.0f);
1446 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1447 glPopMatrix(); // Restore The Old Projection Matrix
1448 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1449 glPopMatrix(); // Restore The Old Projection Matrix
1450 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1451 glEnable(GL_CULL_FACE);
1452 glDisable(GL_BLEND);
1456 if(flashamount>0&&damageeffects){
1457 if(flashamount>1)flashamount=1;
1458 if(flashdelay<=0)flashamount-=multiplier;
1460 if(flashamount<0)flashamount=0;
1461 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1462 glDisable(GL_CULL_FACE);
1463 glDisable(GL_LIGHTING);
1465 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1466 glPushMatrix(); // Store The Projection Matrix
1467 glLoadIdentity(); // Reset The Projection Matrix
1468 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1469 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1470 glPushMatrix(); // Store The Modelview Matrix
1471 glLoadIdentity(); // Reset The Modelview Matrix
1472 glScalef(screenwidth,screenheight,1);
1473 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1475 glColor4f(flashr,flashg,flashb,flashamount);
1477 glVertex3f(0, 0, 0.0f);
1478 glVertex3f(256, 0, 0.0f);
1479 glVertex3f(256, 256, 0.0f);
1480 glVertex3f(0, 256, 0.0f);
1482 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1483 glPopMatrix(); // Restore The Old Projection Matrix
1484 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1485 glPopMatrix(); // Restore The Old Projection Matrix
1486 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1487 glEnable(GL_CULL_FACE);
1488 glDisable(GL_BLEND);
1494 glEnable(GL_TEXTURE_2D);
1497 sprintf (string, " ]");
1498 text.glPrint(10,30+screenheight-330,string,0,1,screenwidth,screenheight);
1500 sprintf (string, "_");
1501 text.glPrint(30+(float)(displayselected)*10,30+(screenheight-330),string,0,1,screenwidth,screenheight);
1505 if((i!=0||chatting)&&displaytime[i]<4)
1506 for(j=0;j<displaychars[i];j++){
1507 glColor4f(1,1,1,4-displaytime[i]);
1508 if(j<displaychars[i]){
1509 sprintf (string, "%c",displaytext[i][j]);
1510 text.glPrint(30+j*10,30+i*20+(screenheight-330),string,0,1,screenwidth,screenheight);
1516 if(minimap&&indialogue==-1){
1520 glDisable(GL_DEPTH_TEST);
1521 glColor3f (1.0, 1.0, 1.0); // no coloring
1523 glEnable(GL_TEXTURE_2D);
1524 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1525 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1526 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1527 glDisable(GL_CULL_FACE);
1528 glDisable(GL_LIGHTING);
1530 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1531 glPushMatrix(); // Store The Projection Matrix
1532 glLoadIdentity(); // Reset The Projection Matrix
1533 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1534 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1535 glPushMatrix(); // Store The Modelview Matrix
1536 glLoadIdentity(); // Reset The Modelview Matrix
1537 glScalef((float)screenwidth/2,(float)screenwidth/2,1);
1538 glTranslatef(1.75,.25,0);
1539 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1549 int numliveplayers=0;
1550 for(i=0;i<numplayers;i++){
1551 if(!player[i].dead)numliveplayers++;
1557 for(i=0;i<objects.numobjects;i++){
1558 if(objects.type[i]==treetrunktype||objects.type[i]==boxtype){
1559 center+=objects.position[i];
1563 for(i=0;i<numplayers;i++){
1564 if(!player[i].dead)center+=player[i].coords;
1566 center/=numadd+numliveplayers;
1568 center=player[0].coords;
1570 float maxdistance=0;
1573 for(i=0;i<objects.numobjects;i++){
1574 tempdist=findDistancefast(¢er,&objects.position[i]);
1575 if(tempdist>maxdistance){
1577 maxdistance=tempdist;
1580 for(i=0;i<numplayers;i++){
1581 if(!player[i].dead){
1582 tempdist=findDistancefast(¢er,&player[i].coords);
1583 if(tempdist>maxdistance){
1585 maxdistance=tempdist;
1589 radius=fast_sqrt(maxdistance);
1593 glScalef(.25/radius*256*terrain.scale*.4,.25/radius*256*terrain.scale*.4,1);
1595 glScalef(1/(1/radius*256*terrain.scale*.4),1/(1/radius*256*terrain.scale*.4),1);
1596 /*float startx,starty,endx,endy;
1598 glTexCoord2f(1-(center.x-radius)/terrain.scale/256,(center.z-radius)/terrain.scale/256);
1599 glVertex3f(-1, -1, 0.0f);
1600 glTexCoord2f(1-(center.x+radius)/terrain.scale/256,(center.z-radius)/terrain.scale/256);
1601 glVertex3f(1, -1, 0.0f);
1602 glTexCoord2f(1-(center.x+radius)/terrain.scale/256,(center.z+radius)/terrain.scale/256);
1603 glVertex3f(1, 1, 0.0f);
1604 glTexCoord2f(1-(center.x-radius)/terrain.scale/256,(center.z+radius)/terrain.scale/256);
1605 glVertex3f(-1, 1, 0.0f);
1608 glRotatef(player[0].lookrotation*-1+180,0,0,1);
1609 glTranslatef(-(center.x/terrain.scale/256*-2+1),(center.z/terrain.scale/256*-2+1),0);
1610 for(i=0;i<objects.numobjects;i++){
1611 if(objects.type[i]==treetrunktype){
1612 distcheck=findDistancefast(&player[0].coords,&objects.position[i]);
1613 if(distcheck<mapviewdist){
1614 glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
1615 glColor4f(0,.3,0,opac*(1-distcheck/mapviewdist));
1617 glTranslatef(objects.position[i].x/terrain.scale/256*-2+1,objects.position[i].z/terrain.scale/256*2-1,0);
1618 glRotatef(objects.rotation[i],0,0,1);
1619 glScalef(.003,.003,.003);
1622 glVertex3f(-1, -1, 0.0f);
1624 glVertex3f(1, -1, 0.0f);
1626 glVertex3f(1, 1, 0.0f);
1628 glVertex3f(-1, 1, 0.0f);
1633 if(objects.type[i]==boxtype){
1634 distcheck=findDistancefast(&player[0].coords,&objects.position[i]);
1635 if(distcheck<mapviewdist){
1636 glBindTexture( GL_TEXTURE_2D, Mapboxtexture);
1637 glColor4f(.4,.4,.4,opac*(1-distcheck/mapviewdist));
1639 glTranslatef(objects.position[i].x/terrain.scale/256*-2+1,objects.position[i].z/terrain.scale/256*2-1,0);
1640 glRotatef(objects.rotation[i],0,0,1);
1641 glScalef(.01*objects.scale[i],.01*objects.scale[i],.01*objects.scale[i]);
1644 glVertex3f(-1, -1, 0.0f);
1646 glVertex3f(1, -1, 0.0f);
1648 glVertex3f(1, 1, 0.0f);
1650 glVertex3f(-1, 1, 0.0f);
1657 glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
1658 for(i=0;i<numboundaries;i++){
1659 glColor4f(0,0,0,opac/3);
1661 glTranslatef(boundary[i].x/terrain.scale/256*-2+1,boundary[i].z/terrain.scale/256*2-1,0);
1662 glScalef(.002,.002,.002);
1665 glVertex3f(-1, -1, 0.0f);
1667 glVertex3f(1, -1, 0.0f);
1669 glVertex3f(1, 1, 0.0f);
1671 glVertex3f(-1, 1, 0.0f);
1676 for(i=0;i<numplayers;i++){
1677 distcheck=findDistancefast(&player[0].coords,&player[i].coords);
1678 if(distcheck<mapviewdist){
1680 glBindTexture( GL_TEXTURE_2D, Maparrowtexture);
1681 if(i==0)glColor4f(1,1,1,opac);
1682 else if(player[i].dead==2||player[i].howactive>typesleeping)glColor4f(0,0,0,opac*(1-distcheck/mapviewdist));
1683 else if(player[i].dead)glColor4f(.3,.3,.3,opac*(1-distcheck/mapviewdist));
1684 else if(player[i].aitype==attacktypecutoff)glColor4f(1,0,0,opac*(1-distcheck/mapviewdist));
1685 else if(player[i].aitype==passivetype)glColor4f(0,1,0,opac*(1-distcheck/mapviewdist));
1686 else glColor4f(1,1,0,1);
1687 glTranslatef(player[i].coords.x/terrain.scale/256*-2+1,player[i].coords.z/terrain.scale/256*2-1,0);
1688 glRotatef(player[i].rotation+180,0,0,1);
1689 glScalef(.005,.005,.005);
1692 glVertex3f(-1, -1, 0.0f);
1694 glVertex3f(1, -1, 0.0f);
1696 glVertex3f(1, 1, 0.0f);
1698 glVertex3f(-1, 1, 0.0f);
1700 /*glBegin(GL_TRIANGLES);
1702 glVertex3f(-1, -1, 0.0f);
1704 glVertex3f(1, -1, 0.0f);
1706 glVertex3f(0, 1, 0.0f);
1711 /*glBegin(GL_QUADS);
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 drawmode=normalmode;
1739 if(loading&&!stealthloading&&(!campaign||player[0].dead)){
1740 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1741 glDisable(GL_CULL_FACE);
1742 glDisable(GL_LIGHTING);
1743 glDisable(GL_TEXTURE_2D);
1745 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1746 glPushMatrix(); // Store The Projection Matrix
1747 glLoadIdentity(); // Reset The Projection Matrix
1748 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1749 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1750 glPushMatrix(); // Store The Modelview Matrix
1751 glLoadIdentity(); // Reset The Modelview Matrix
1752 glScalef(screenwidth,screenheight,1);
1753 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1755 glColor4f(0,0,0,.7);
1757 glVertex3f(0, 0, 0.0f);
1758 glVertex3f(256, 0, 0.0f);
1759 glVertex3f(256, 256, 0.0f);
1760 glVertex3f(0, 256, 0.0f);
1762 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1763 glPopMatrix(); // Restore The Old Projection Matrix
1764 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1765 glPopMatrix(); // Restore The Old Projection Matrix
1766 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1767 glEnable(GL_CULL_FACE);
1768 glDisable(GL_BLEND);
1772 glDisable(GL_DEPTH_TEST);
1773 glColor3f (1.0, 1.0, 1.0); // no coloring
1775 glEnable(GL_TEXTURE_2D);
1776 /*glBindTexture( GL_TEXTURE_2D, logotexture);
1777 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1778 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1779 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1780 glDisable(GL_CULL_FACE);
1781 glDisable(GL_LIGHTING);
1783 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1784 glPushMatrix(); // Store The Projection Matrix
1785 glLoadIdentity(); // Reset The Projection Matrix
1786 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1787 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1788 glPushMatrix(); // Store The Modelview Matrix
1789 glLoadIdentity(); // Reset The Modelview Matrix
1790 glScalef((float)screenwidth/2,(float)screenwidth/2,1);
1791 glTranslatef(1.8,1.25,0);
1792 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1796 glScalef(.25,.25,.25);
1799 glVertex3f(-1, -1, 0.0f);
1801 glVertex3f(1, -1, 0.0f);
1803 glVertex3f(1, 1, 0.0f);
1805 glVertex3f(-1, 1, 0.0f);
1808 glDisable(GL_TEXTURE_2D);
1809 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1810 glPopMatrix(); // Restore The Old Projection Matrix
1811 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1812 glPopMatrix(); // Restore The Old Projection Matrix
1813 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1814 glEnable(GL_CULL_FACE);
1815 glDisable(GL_BLEND);
1821 glEnable(GL_TEXTURE_2D);
1823 sprintf (string, "Loading...");
1824 text.glPrint(1024/2-90,768/2,string,1,2,1024,768);
1827 //if(ismotionblur)drawmode=motionblurmode;
1828 drawmode=normalmode;
1831 if(winfreeze&&!campaign){
1832 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1833 glDisable(GL_CULL_FACE);
1834 glDisable(GL_LIGHTING);
1835 glDisable(GL_TEXTURE_2D);
1837 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1838 glPushMatrix(); // Store The Projection Matrix
1839 glLoadIdentity(); // Reset The Projection Matrix
1840 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1841 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1842 glPushMatrix(); // Store The Modelview Matrix
1843 glLoadIdentity(); // Reset The Modelview Matrix
1844 glScalef(screenwidth,screenheight,1);
1845 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1847 glColor4f(0,0,0,.4);
1849 glVertex3f(0, 0, 0.0f);
1850 glVertex3f(256, 0, 0.0f);
1851 glVertex3f(256, 256, 0.0f);
1852 glVertex3f(0, 256, 0.0f);
1854 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1855 glPopMatrix(); // Restore The Old Projection Matrix
1856 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1857 glPopMatrix(); // Restore The Old Projection Matrix
1858 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1859 glEnable(GL_CULL_FACE);
1860 glDisable(GL_BLEND);
1864 glDisable(GL_DEPTH_TEST);
1865 glColor3f (1.0, 1.0, 1.0); // no coloring
1867 glEnable(GL_TEXTURE_2D);
1868 /*glBindTexture( GL_TEXTURE_2D, logotexture);
1869 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1870 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1871 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1872 glDisable(GL_CULL_FACE);
1873 glDisable(GL_LIGHTING);
1875 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1876 glPushMatrix(); // Store The Projection Matrix
1877 glLoadIdentity(); // Reset The Projection Matrix
1878 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1879 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1880 glPushMatrix(); // Store The Modelview Matrix
1881 glLoadIdentity(); // Reset The Modelview Matrix
1882 glScalef((float)screenwidth/2,(float)screenwidth/2,1);
1883 glTranslatef(1.8,1.25,0);
1884 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1888 glScalef(.25,.25,.25);
1891 glVertex3f(-1, -1, 0.0f);
1893 glVertex3f(1, -1, 0.0f);
1895 glVertex3f(1, 1, 0.0f);
1897 glVertex3f(-1, 1, 0.0f);
1900 glDisable(GL_TEXTURE_2D);
1901 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1902 glPopMatrix(); // Restore The Old Projection Matrix
1903 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1904 glPopMatrix(); // Restore The Old Projection Matrix
1905 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1906 glEnable(GL_CULL_FACE);
1907 glDisable(GL_BLEND);
1915 if(damagetaken==0&&player[0].bloodloss==0){
1916 awards[numawards]=awardflawless;
1922 for(i=1;i<numplayers;i++){
1923 if(player[i].dead!=2)alldead=0;
1926 awards[numawards]=awardalldead;
1931 for(i=1;i<numplayers;i++){
1932 if(player[i].dead!=1)alldead=0;
1935 awards[numawards]=awardnodead;
1938 if(numresponded==0&&!numthrowkill){
1939 awards[numawards]=awardstealth;
1942 if(numattacks==numstaffattack&&numattacks>0){
1943 awards[numawards]=awardbojutsu;
1946 if(numattacks==numswordattack&&numattacks>0){
1947 awards[numawards]=awardswordsman;
1950 if(numattacks==numknifeattack&&numattacks>0){
1951 awards[numawards]=awardknifefighter;
1954 if(numattacks==numunarmedattack&&numthrowkill==0&&weapons.numweapons>0){
1955 awards[numawards]=awardkungfu;
1959 awards[numawards]=awardevasion;
1962 if(numflipfail==0&&numflipped+numwallflipped*2>20){
1963 awards[numawards]=awardacrobat;
1966 if(numthrowkill==numplayers-1){
1967 awards[numawards]=awardlongrange;
1972 for(i=1;i<numplayers;i++){
1973 if(player[i].dead!=2)alldead=0;
1975 if(numafterkill>0&&alldead){
1976 awards[numawards]=awardbrutal;
1979 if(numreversals>((float)numattacks)*.8&&numreversals>3){
1980 awards[numawards]=awardaikido;
1983 if(maxalarmed==1&&numplayers>2){
1984 awards[numawards]=awardstrategy;
1988 awards[numawards]=awardklutz;
1993 //Win Screen Won Victory
1995 glEnable(GL_TEXTURE_2D);
1997 sprintf (string, "Level Cleared!");
1998 text.glPrintOutlined(1024/2-strlen(string)*10,768*7/8,string,1,2,1024,768);
2000 sprintf (string, "Score: %d",(int)(bonustotal-startbonustotal));
2001 text.glPrintOutlined(1024/30,768*6/8,string,1,2,1024,768);
2003 if(!campaign)sprintf (string, "Press Escape to return to menu or Space to continue");
2004 if(campaign)sprintf (string, "Press Escape or Space to continue");
2005 text.glPrintOutlined(640/2-strlen(string)*5,480*1/16,string,1,1,640,480);
2009 for(i=0;i<255;i++)string[i]='\0';
2010 sprintf (temp, "Time: %d:",(int)(((int)leveltime-(int)(leveltime)%60)/60));
2011 strcat(string,temp);
2012 if((int)(leveltime)%60<10)strcat(string,"0");
2013 sprintf (temp, "%d",(int)(leveltime)%60);
2014 strcat(string,temp);
2015 text.glPrintOutlined(1024/30,768*6/8-40,string,1,2,1024,768);
2017 for(i=0;i<numawards;i++){
2019 if(awards[i]==awardklutz)sprintf (string, "Suicidal");
2020 if(awards[i]==awardflawless)sprintf (string, "Flawless!");
2021 if(awards[i]==awardalldead)sprintf (string, "Take no prisoners");
2022 if(awards[i]==awardnodead)sprintf (string, "Merciful");
2023 if(awards[i]==awardstealth)sprintf (string, "One with the shadows!");
2024 if(awards[i]==awardswordsman)sprintf (string, "Swordsman");
2025 if(awards[i]==awardkungfu)sprintf (string, "Unarmed!");
2026 if(awards[i]==awardknifefighter)sprintf (string, "Knife fighter");
2027 if(awards[i]==awardcoward)sprintf (string, "Coward");
2028 if(awards[i]==awardevasion)sprintf (string, "Escape artist");
2029 if(awards[i]==awardacrobat)sprintf (string, "Gymnast");
2030 if(awards[i]==awardlongrange)sprintf (string, "Blade slinger");
2031 if(awards[i]==awardbrutal)sprintf (string, "Brutal");
2032 if(awards[i]==awardhyper)sprintf (string, "Hyper");
2033 if(awards[i]==awardaikido)sprintf (string, "Aikido master!");
2034 if(awards[i]==awardrambo)sprintf (string, "Rambo");
2035 if(awards[i]==awardfast)sprintf (string, "Fast");
2036 if(awards[i]==awardrealfast)sprintf (string, "Real fast");
2037 if(awards[i]==awarddamnfast)sprintf (string, "Damn fast");
2038 if(awards[i]==awardstrategy)sprintf (string, "Divide and conquer");
2039 if(awards[i]==awardbojutsu)sprintf (string, "Bojutsu");
2040 text.glPrintOutlined(1024/30,768*6/8-90-40*i,string,1,2,1024,768);
2044 //drawmode=normalmode;
2047 if(drawmode!=normalmode){
2048 glEnable(GL_TEXTURE_2D);
2050 if(!drawtoggle||drawmode!=realmotionblurmode||(drawtoggle==2||change==1)){
2053 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
2054 GLfloat subtractColor[4] = { 0.5, 0.5, 0.5, 0.0 };
2055 glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, subtractColor);
2056 //glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_SUBTRACT);
2057 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE);
2058 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_CONSTANT_EXT);
2059 glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 2.0f);
2061 glBindTexture( GL_TEXTURE_2D, screentexture);
2062 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
2065 if((drawtoggle||change==1)&&drawmode==realmotionblurmode){
2067 glBindTexture( GL_TEXTURE_2D, screentexture2);
2068 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
2070 if(!screentexture2){
2071 glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
2073 glGenTextures( 1, &screentexture2 );
2074 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
2076 glEnable(GL_TEXTURE_2D);
2077 glBindTexture( GL_TEXTURE_2D, screentexture2);
2078 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
2079 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
2081 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
2087 glClear(GL_DEPTH_BUFFER_BIT);
2088 ReSizeGLScene(90,.1f);
2089 glViewport(0,0,screenwidth,screenheight);
2091 if(drawmode!=normalmode){
2092 glDisable(GL_DEPTH_TEST);
2093 if(drawmode==motionblurmode){
2094 glDrawBuffer(GL_FRONT);
2095 glReadBuffer(GL_BACK);
2096 //myassert(glGetError() == GL_NO_ERROR);
2099 glColor3f (1.0, 1.0, 1.0); // no coloring
2101 glEnable(GL_TEXTURE_2D);
2102 glBindTexture( GL_TEXTURE_2D, screentexture);
2103 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
2104 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
2105 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
2106 glDisable(GL_CULL_FACE);
2107 glDisable(GL_LIGHTING);
2109 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2110 glPushMatrix(); // Store The Projection Matrix
2111 glLoadIdentity(); // Reset The Projection Matrix
2112 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
2113 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2114 glPushMatrix(); // Store The Modelview Matrix
2115 glLoadIdentity(); // Reset The Modelview Matrix
2116 glScalef((float)screenwidth/2,(float)screenheight/2,1);
2117 glTranslatef(1,1,0);
2118 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
2120 if(drawmode==motionblurmode){
2121 if(motionbluramount<.2)motionbluramount=.2;
2122 //glColor4f(1,1,1,fast_sqrt(multiplier)*2.9*motionbluramount);
2123 glColor4f(1,1,1,motionbluramount);
2127 glVertex3f(-1, -1, 0.0f);
2128 glTexCoord2f(texcoordwidth,0);
2129 glVertex3f(1, -1, 0.0f);
2130 glTexCoord2f(texcoordwidth,texcoordheight);
2131 glVertex3f(1, 1, 0.0f);
2132 glTexCoord2f(0,texcoordheight);
2133 glVertex3f(-1, 1, 0.0f);
2137 if(drawmode==realmotionblurmode){
2138 glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
2139 glClear(GL_COLOR_BUFFER_BIT);
2140 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
2141 glBindTexture( GL_TEXTURE_2D, screentexture);
2142 glColor4f(1,1,1,.5);
2146 glVertex3f(-1, -1, 0.0f);
2147 glTexCoord2f(texcoordwidth,0);
2148 glVertex3f(1, -1, 0.0f);
2149 glTexCoord2f(texcoordwidth,texcoordheight);
2150 glVertex3f(1, 1, 0.0f);
2151 glTexCoord2f(0,texcoordheight);
2152 glVertex3f(-1, 1, 0.0f);
2155 glBindTexture( GL_TEXTURE_2D, screentexture2);
2156 glColor4f(1,1,1,.5);
2160 glVertex3f(-1, -1, 0.0f);
2161 glTexCoord2f(texcoordwidth,0);
2162 glVertex3f(1, -1, 0.0f);
2163 glTexCoord2f(texcoordwidth,texcoordheight);
2164 glVertex3f(1, 1, 0.0f);
2165 glTexCoord2f(0,texcoordheight);
2166 glVertex3f(-1, 1, 0.0f);
2169 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
2171 if(drawmode==doublevisionmode){
2172 static float crosseyedness;
2173 crosseyedness=abs(player[0].damage-player[0].superpermanentdamage-(player[0].damagetolerance-player[0].superpermanentdamage)*1/2)/30;
2174 if(crosseyedness>1)crosseyedness=1;
2175 if(crosseyedness<0)crosseyedness=0;
2177 glDisable(GL_BLEND);
2182 glVertex3f(-1, -1, 0.0f);
2183 glTexCoord2f(texcoordwidth,0);
2184 glVertex3f(1, -1, 0.0f);
2185 glTexCoord2f(texcoordwidth,texcoordheight);
2186 glVertex3f(1, 1, 0.0f);
2187 glTexCoord2f(0,texcoordheight);
2188 glVertex3f(-1, 1, 0.0f);
2192 glColor4f(1,1,1,.5);
2195 glTranslatef(.015*crosseyedness,0,0);
2199 glVertex3f(-1, -1, 0.0f);
2200 glTexCoord2f(texcoordwidth,0);
2201 glVertex3f(1, -1, 0.0f);
2202 glTexCoord2f(texcoordwidth,texcoordheight);
2203 glVertex3f(1, 1, 0.0f);
2204 glTexCoord2f(0,texcoordheight);
2205 glVertex3f(-1, 1, 0.0f);
2210 if(drawmode==glowmode){
2211 glColor4f(.5,.5,.5,.5);
2213 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
2215 glTranslatef(.01,0,0);
2218 glVertex3f(-1, -1, 0.0f);
2219 glTexCoord2f(texcoordwidth,0);
2220 glVertex3f(1, -1, 0.0f);
2221 glTexCoord2f(texcoordwidth,texcoordheight);
2222 glVertex3f(1, 1, 0.0f);
2223 glTexCoord2f(0,texcoordheight);
2224 glVertex3f(-1, 1, 0.0f);
2228 glTranslatef(-.01,0,0);
2231 glVertex3f(-1, -1, 0.0f);
2232 glTexCoord2f(texcoordwidth,0);
2233 glVertex3f(1, -1, 0.0f);
2234 glTexCoord2f(texcoordwidth,texcoordheight);
2235 glVertex3f(1, 1, 0.0f);
2236 glTexCoord2f(0,texcoordheight);
2237 glVertex3f(-1, 1, 0.0f);
2241 glTranslatef(.0,.01,0);
2244 glVertex3f(-1, -1, 0.0f);
2245 glTexCoord2f(texcoordwidth,0);
2246 glVertex3f(1, -1, 0.0f);
2247 glTexCoord2f(texcoordwidth,texcoordheight);
2248 glVertex3f(1, 1, 0.0f);
2249 glTexCoord2f(0,texcoordheight);
2250 glVertex3f(-1, 1, 0.0f);
2254 glTranslatef(0,-.01,0);
2257 glVertex3f(-1, -1, 0.0f);
2258 glTexCoord2f(texcoordwidth,0);
2259 glVertex3f(1, -1, 0.0f);
2260 glTexCoord2f(texcoordwidth,texcoordheight);
2261 glVertex3f(1, 1, 0.0f);
2262 glTexCoord2f(0,texcoordheight);
2263 glVertex3f(-1, 1, 0.0f);
2267 if(drawmode==radialzoommode){
2269 //glRotatef((float)i*.1,0,0,1);
2270 glColor4f(1,1,1,1/((float)i+1));
2272 glScalef(1+(float)i*.01,1+(float)i*.01,1);
2275 glVertex3f(-1, -1, 0.0f);
2276 glTexCoord2f(texcoordwidth,0);
2277 glVertex3f(1, -1, 0.0f);
2278 glTexCoord2f(texcoordwidth,texcoordheight);
2279 glVertex3f(1, 1, 0.0f);
2280 glTexCoord2f(0,texcoordheight);
2281 glVertex3f(-1, 1, 0.0f);
2286 glDisable(GL_TEXTURE_2D);
2287 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2288 glPopMatrix(); // Restore The Old Projection Matrix
2289 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2290 glPopMatrix(); // Restore The Old Projection Matrix
2291 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
2292 glEnable(GL_CULL_FACE);
2293 glDisable(GL_BLEND);
2298 glEnable(GL_TEXTURE_2D);
2303 if(consoleselected>=60)offset=consoleselected-60;
2304 sprintf (string, " ]");
2305 text.glPrint(10,30,string,0,1,1024,768);
2307 sprintf (string, "_");
2308 text.glPrint(30+(float)(consoleselected)*10-offset*10,30,string,0,1,1024,768);
2311 for(j=0;j<consolechars[i];j++){
2312 glColor4f(1,1,1,1-(float)(i)/16);
2313 if(j<consolechars[i]){
2314 sprintf (string, "%c",consoletext[i][j]);
2315 text.glPrint(30+j*10-offset*10,30+i*20,string,0,1,1024,768);
2323 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)||(mainmenu&&gameon)||(!gameon&&gamestarted)||(!gameon&&gamestarted)){
2324 multiplier=tempmult;
2329 // !!! FIXME: hack: clamp framerate in menu so text input works correctly on fast systems.
2332 glDrawBuffer(GL_BACK);
2333 glReadBuffer(GL_BACK);
2334 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
2335 ReSizeGLScene(90,.1f);
2338 temptexdetail=texdetail;
2339 if(texdetail>2)texdetail=2;
2340 if(mainmenu!=oldmainmenu&&oldmainmenu!=0){
2342 LoadTexture(":Data:Textures:Newgame.png",&Mainmenuitems[1],0,0);
2343 LoadTexture(":Data:Textures:Quit.png",&Mainmenuitems[3],0,0);
2344 /*if(oldmainmenu==1||oldmainmenu==0){
2345 LoadTexture(":Data:Textures:World.png",&Mainmenuitems[7],0,0);
2346 LoadTexture(":Data:Textures:Options.png",&Mainmenuitems[2],0,0);
2347 LoadTexture(":Data:Textures:Lugaru.png",&Mainmenuitems[0],0,0);
2352 LoadTexture(":Data:Textures:Resume.png",&Mainmenuitems[1],0,0);
2353 LoadTexture(":Data:Textures:Endgame.png",&Mainmenuitems[3],0,0);
2354 /*if(oldmainmenu==2||oldmainmenu==0){
2355 LoadTexture(":Data:Textures:World.png",&Mainmenuitems[7],0,0);
2356 LoadTexture(":Data:Textures:Options.png",&Mainmenuitems[2],0,0);
2357 LoadTexture(":Data:Textures:Lugaru.png",&Mainmenuitems[0],0,0);
2362 if(lastcheck>.5||oldmainmenu!=mainmenu){
2364 ifstream ipstream(ConvertFileName(":Data:Campaigns:main.txt"));
2365 //campaignnumlevels=0;
2366 //accountcampaignchoicesmade[accountactive]=0;
2367 ipstream.ignore(256,':');
2368 ipstream >> campaignnumlevels;
2369 for(i=0;i<campaignnumlevels;i++){
2370 ipstream.ignore(256,':');
2371 ipstream.ignore(256,':');
2372 ipstream.ignore(256,' ');
2373 ipstream >> campaignmapname[i];
2374 ipstream.ignore(256,':');
2375 ipstream >> campaigndescription[i];
2377 if(campaigndescription[i][j]=='_')campaigndescription[i][j]=' ';
2379 ipstream.ignore(256,':');
2380 ipstream >> campaignchoosenext[i];
2381 ipstream.ignore(256,':');
2382 ipstream >> campaignnumnext[i];
2383 if(campaignnumnext[i])
2384 for(j=0;j<campaignnumnext[i];j++){
2385 ipstream.ignore(256,':');
2386 ipstream >> campaignnextlevel[i][j];
2387 campaignnextlevel[i][j]-=1;
2389 ipstream.ignore(256,':');
2390 ipstream >> campaignlocationx[i];
2391 //campaignlocationx[i]-=30;
2392 ipstream.ignore(256,':');
2393 ipstream >> campaignlocationy[i];
2394 //campaignlocationy[i]+=30;
2398 for(i=0;i<campaignnumlevels;i++){
2400 levelhighlight[i]=0;
2405 if(accountcampaignchoicesmade[accountactive])
2406 for(i=0;i<accountcampaignchoicesmade[accountactive];i++){
2407 levelorder[i+1]=campaignnextlevel[levelorder[i]][accountcampaignchoices[accountactive][i]];
2408 levelvisible[levelorder[i+1]]=1;
2410 int whichlevelstart;
2411 whichlevelstart=accountcampaignchoicesmade[accountactive]-1;
2412 if(whichlevelstart<0){
2413 accountcampaignscore[accountactive]=0;
2414 accountcampaignfasttime[accountactive]=0;
2415 campaignchoicenum=1;
2416 campaignchoicewhich[0]=0;
2420 campaignchoicenum=campaignnumnext[levelorder[whichlevelstart]];
2421 if(campaignchoicenum==0){
2422 if(accountcampaignscore[accountactive]>accountcampaignhighscore[accountactive])accountcampaignhighscore[accountactive]=accountcampaignscore[accountactive];
2423 if(accountcampaignfasttime[accountactive]==0||accountcampaigntime[accountactive]<accountcampaignfasttime[accountactive])accountcampaignfasttime[accountactive]=accountcampaigntime[accountactive];
2425 if(campaignchoicenum)
2426 for(i=0;i<campaignchoicenum;i++){
2427 campaignchoicewhich[i]=campaignnextlevel[levelorder[whichlevelstart]][i];
2428 levelvisible[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
2429 levelhighlight[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
2442 texdetail=temptexdetail;
2444 /*if(mainmenu!=0)*/oldmainmenu=mainmenu;
2446 if(mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==8||mainmenu==9||mainmenu==10||mainmenu==119||mainmenu==13||mainmenu==17){
2447 glClear(GL_DEPTH_BUFFER_BIT);
2448 glEnable(GL_ALPHA_TEST);
2449 glAlphaFunc(GL_GREATER, 0.001f);
2450 glEnable(GL_TEXTURE_2D);
2451 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
2452 glDisable(GL_CULL_FACE);
2453 glDisable(GL_LIGHTING);
2455 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2456 glPushMatrix(); // Store The Projection Matrix
2457 glLoadIdentity(); // Reset The Projection Matrix
2458 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
2459 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2460 glPushMatrix(); // Store The Modelview Matrix
2461 glLoadIdentity(); // Reset The Modelview Matrix
2462 glTranslatef(screenwidth/2,screenheight/2,0);
2464 glScalef((float)screenwidth/2,(float)screenheight/2,1);
2465 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
2466 glDisable(GL_BLEND);
2467 glColor4f(0,0,0,1.0);
2468 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2469 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2470 glDisable(GL_TEXTURE_2D);
2472 //glScalef(.25,.25,.25);
2475 glVertex3f(-1, -1, 0.0f);
2477 glVertex3f(1, -1, 0.0f);
2479 glVertex3f(1, 1, 0.0f);
2481 glVertex3f(-1, 1, 0.0f);
2485 glColor4f(0.4,0.4,0.4,1.0);
2486 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2487 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2488 glEnable(GL_TEXTURE_2D);
2489 glBindTexture( GL_TEXTURE_2D, Mainmenuitems[4]);
2491 //glScalef(.25,.25,.25);
2494 glVertex3f(-1, -1, 0.0f);
2496 glVertex3f(1, -1, 0.0f);
2498 glVertex3f(1, 1, 0.0f);
2500 glVertex3f(-1, 1, 0.0f);
2505 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2507 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2511 if((float)newscreenwidth>(float)newscreenheight*1.61||(float)newscreenwidth<(float)newscreenheight*1.59)sprintf (menustring[0], "Resolution: %d*%d",(int)newscreenwidth,(int)newscreenheight);
2512 else sprintf (menustring[0], "Resolution: %d*%d (widescreen)",(int)newscreenwidth,(int)newscreenheight);
2515 endx[0]=startx[0]+strlen(menustring[0])*10;
2516 endy[0]=starty[0]+20;
2520 if(newdetail==2)sprintf (menustring[1], "Detail: High");
2521 else if(newdetail==1)sprintf (menustring[1], "Detail: Medium");
2522 else sprintf (menustring[1], "Detail: Low");
2525 endx[1]=startx[1]+strlen(menustring[1])*10;
2526 endy[1]=starty[1]+20;
2530 if(bloodtoggle==2)sprintf (menustring[2], "Blood: On, high detail (slower)");
2531 if(bloodtoggle==1)sprintf (menustring[2], "Blood: On, low detail");
2532 if(bloodtoggle==0)sprintf (menustring[2], "Blood: Off");
2535 endx[2]=startx[2]+strlen(menustring[2])*10;
2536 endy[2]=starty[2]+20;
2540 if(difficulty==2)sprintf (menustring[3], "Difficulty: Insane");
2541 if(difficulty==1)sprintf (menustring[3], "Difficulty: Difficult");
2542 if(difficulty==0)sprintf (menustring[3], "Difficulty: Easier");
2543 startx[3]=10+20-1000;
2545 endx[3]=startx[3]+strlen(menustring[3])*10;
2546 endy[3]=starty[3]+20;
2550 if(ismotionblur==1)sprintf (menustring[4], "Blur Effects: Enabled (less compatible)");
2551 if(ismotionblur==0)sprintf (menustring[4], "Blur Effects: Disabled (more compatible)");
2554 endx[4]=startx[4]+strlen(menustring[4])*10;
2555 endy[4]=starty[4]+20;
2559 if(decals==1)sprintf (menustring[5], "Decals: Enabled (slower)");
2560 if(decals==0)sprintf (menustring[5], "Decals: Disabled");
2563 endx[5]=startx[5]+strlen(menustring[5])*10;
2564 endy[5]=starty[5]+20;
2568 if(musictoggle==1)sprintf (menustring[6], "Music: Enabled");
2569 if(musictoggle==0)sprintf (menustring[6], "Music: Disabled");
2572 endx[6]=startx[6]+strlen(menustring[6])*10;
2573 endy[6]=starty[6]+20;
2577 if(invertmouse==1)sprintf (menustring[9], "Invert mouse: Yes");
2578 if(invertmouse==0)sprintf (menustring[9], "Invert mouse: No");
2581 endx[9]=startx[9]+strlen(menustring[9])*10;
2582 endy[9]=starty[9]+20;
2586 sprintf (menustring[10], "Mouse Speed: %d", (int)(usermousesensitivity*5));
2589 endx[10]=startx[10]+strlen(menustring[10])*10;
2590 endy[10]=starty[10]+20;
2594 sprintf (menustring[11], "Volume: %d%%", (int)(volume*100));
2597 endx[11]=startx[11]+strlen(menustring[11])*10;
2598 endy[11]=starty[11]+20;
2602 sprintf (menustring[7], "-Configure Controls-");
2605 endx[7]=startx[7]+strlen(menustring[7])*10;
2606 endy[7]=starty[7]+20;
2610 if(newdetail==detail&&newscreenheight==(int)screenheight&&newscreenwidth==(int)screenwidth)sprintf (menustring[8], "Back");
2611 else sprintf (menustring[8], "Back (some changes take effect next time Lugaru is opened)");
2613 endx[8]=startx[8]+strlen(menustring[8])*10;
2615 endy[8]=starty[8]+20;
2622 if(keyselect!=0)sprintf (menustring[0], "Forwards: %s",KeyToChar(forwardkey));
2623 else sprintf (menustring[0], "Forwards: _");
2626 endx[0]=startx[0]+strlen(menustring[0])*10;
2627 endy[0]=starty[0]+20;
2631 if(keyselect!=1)sprintf (menustring[1], "Back: %s",KeyToChar(backkey));
2632 else sprintf (menustring[1], "Back: _");
2635 endx[1]=startx[1]+strlen(menustring[1])*10;
2636 endy[1]=starty[1]+20;
2640 if(keyselect!=2)sprintf (menustring[2], "Left: %s",KeyToChar(leftkey));
2641 else sprintf (menustring[2], "Left: _");
2644 endx[2]=startx[2]+strlen(menustring[2])*10;
2645 endy[2]=starty[2]+20;
2649 if(keyselect!=3)sprintf (menustring[3], "Right: %s",KeyToChar(rightkey));
2650 else sprintf (menustring[3], "Right: _");
2653 endx[3]=startx[3]+strlen(menustring[3])*10;
2654 endy[3]=starty[3]+20;
2658 if(keyselect!=4)sprintf (menustring[4], "Crouch: %s",KeyToChar(crouchkey));
2659 else sprintf (menustring[4], "Crouch: _");
2662 endx[4]=startx[4]+strlen(menustring[4])*10;
2663 endy[4]=starty[4]+20;
2667 if(keyselect!=5)sprintf (menustring[5], "Jump: %s",KeyToChar(jumpkey));
2668 else sprintf (menustring[5], "Jump: _");
2671 endx[5]=startx[5]+strlen(menustring[5])*10;
2672 endy[5]=starty[5]+20;
2676 if(keyselect!=6)sprintf (menustring[6], "Draw: %s",KeyToChar(drawkey));
2677 else sprintf (menustring[6], "Draw: _");
2680 endx[6]=startx[6]+strlen(menustring[6])*10;
2681 endy[6]=starty[6]+20;
2685 if(keyselect!=7)sprintf (menustring[7], "Throw: %s",KeyToChar(throwkey));
2686 else sprintf (menustring[7], "Throw: _");
2689 endx[7]=startx[7]+strlen(menustring[7])*10;
2690 endy[7]=starty[7]+20;
2694 if(keyselect!=8)sprintf (menustring[8], "Attack: %s",KeyToChar(attackkey));
2695 else sprintf (menustring[8], "Attack: _");
2698 endx[8]=startx[8]+strlen(menustring[8])*10;
2699 endy[8]=starty[8]+20;
2705 sprintf (menustring[9], "Back");
2707 endx[9]=startx[9]+strlen(menustring[9])*10;
2709 endy[9]=starty[9]+20;
2714 nummenuitems=7+accountcampaignchoicesmade[accountactive]+campaignchoicenum;
2716 sprintf (menustring[0], "%s",accountname[accountactive]);
2719 endx[0]=startx[0]+strlen(menustring[0])*10;
2720 endy[0]=starty[0]+20;
2724 sprintf (menustring[1], "Tutorial");
2727 endx[1]=startx[1]+strlen(menustring[1])*10;
2728 endy[1]=starty[1]+20;
2732 sprintf (menustring[2], "Challenge");
2735 endx[2]=startx[2]+strlen(menustring[2])*10;
2736 endy[2]=starty[2]+20;
2740 sprintf (menustring[3], "Delete User");
2743 endx[3]=startx[3]+strlen(menustring[3])*10;
2744 endy[3]=starty[3]+20;
2748 sprintf (menustring[4], "Main Menu");
2751 endx[4]=startx[4]+strlen(menustring[4])*10;
2752 endy[4]=starty[4]+20;
2756 sprintf (menustring[5], "Change User");
2758 endx[5]=startx[5]+strlen(menustring[5])*10;
2760 endy[5]=starty[5]+20;
2766 sprintf (menustring[6], "World");
2768 starty[6]=30+480-400-50;
2769 endx[6]=startx[6]+400;
2774 if(accountcampaignchoicesmade[accountactive])
2775 for(i=0;i<accountcampaignchoicesmade[accountactive];i++){
2776 sprintf (menustring[7+i], "%s", campaigndescription[levelorder[i]]);
2777 startx[7+i]=30+120+campaignlocationx[levelorder[i]]*400/512;
2778 starty[7+i]=30+30+(512-campaignlocationy[levelorder[i]])*400/512;
2779 endx[7+i]=startx[7+i]+10;
2780 endy[7+i]=starty[7+i]+10;
2785 if(campaignchoicenum>0)
2786 for(i=accountcampaignchoicesmade[accountactive];i<accountcampaignchoicesmade[accountactive]+campaignchoicenum;i++){
2787 sprintf (menustring[7+i], "%s", campaigndescription[levelorder[i]]);
2788 startx[7+i]=30+120+campaignlocationx[campaignchoicewhich[i-(accountcampaignchoicesmade[accountactive])]]*400/512;
2789 starty[7+i]=30+30+(512-campaignlocationy[campaignchoicewhich[i-(accountcampaignchoicesmade[accountactive])]])*400/512;
2790 endx[7+i]=startx[7+i]+10;
2791 endy[7+i]=starty[7+i]+10;
2796 /*sprintf (menustring[7], "Dot");
2797 startx[7]=120+260*400/512;
2798 starty[7]=30+(512-184)*400/512;
2799 endx[7]=startx[7]+10;
2800 endy[7]=starty[7]+10;
2804 sprintf (menustring[8], "Dot");
2805 startx[8]=120+129*400/512;
2806 starty[8]=30+(512-284)*400/512;
2807 endx[8]=startx[8]+10;
2808 endy[8]=starty[8]+10;
2812 sprintf (menustring[9], "Dot");
2813 startx[9]=120+358*400/512;
2814 starty[9]=30+(512-235)*400/512;
2815 endx[9]=startx[9]+10;
2816 endy[9]=starty[9]+10;
2820 sprintf (menustring[10], "Dot");
2821 startx[10]=120+359*400/512;
2822 starty[10]=30+(512-308)*400/512;
2823 endx[10]=startx[10]+10;
2824 endy[10]=starty[10]+10;
2828 sprintf (menustring[11], "Dot");
2829 startx[11]=120+288*400/512;
2830 starty[11]=30+(512-277)*400/512;
2831 endx[11]=startx[11]+10;
2832 endy[11]=starty[11]+10;
2840 sprintf (menustring[0], "Are you sure you want to delete this user?");
2843 endx[0]=startx[0]+strlen(menustring[0])*10;
2844 endy[0]=starty[0]+20;
2848 sprintf (menustring[1], "Yes");
2851 endx[1]=startx[1]+strlen(menustring[1])*10;
2852 endy[1]=starty[1]+20;
2856 sprintf (menustring[2], "No");
2859 endx[2]=startx[2]+strlen(menustring[2])*10;
2860 endy[2]=starty[2]+20;
2864 sprintf (menustring[3], "Extra 4");
2867 endx[3]=startx[3]+strlen(menustring[3])*10;
2868 endy[3]=starty[3]+20;
2872 sprintf (menustring[4], "Extra 5");
2875 endx[4]=startx[4]+strlen(menustring[4])*10;
2876 endy[4]=starty[4]+20;
2880 sprintf (menustring[5], "Back");
2882 endx[5]=startx[5]+strlen(menustring[5])*10;
2884 endy[5]=starty[5]+20;
2890 nummenuitems=numaccounts+2;
2895 sprintf (menustring[0], "New User");
2897 sprintf (menustring[0], "No More Users");
2900 endx[0]=startx[0]+strlen(menustring[0])*10;
2901 endy[0]=starty[0]+20;
2905 if(entername)startx[0]+=10;
2910 for(i=0;i<numaccounts;i++){
2911 sprintf (menustring[num], "%s",accountname[i]);
2913 starty[num]=360-20-20*num;
2914 endx[num]=startx[num]+strlen(menustring[num])*10;
2915 endy[num]=starty[num]+20;
2922 sprintf (menustring[num], "Back");
2924 endx[num]=startx[num]+strlen(menustring[num])*10;
2926 endy[num]=starty[num]+20;
2933 sprintf (menustring[0], "Easier");
2936 endx[0]=startx[0]+strlen(menustring[0])*10;
2937 endy[0]=starty[0]+20;
2941 sprintf (menustring[1], "Difficult");
2944 endx[1]=startx[1]+strlen(menustring[1])*10;
2945 endy[1]=starty[1]+20;
2949 sprintf (menustring[2], "Insane");
2952 endx[2]=startx[2]+strlen(menustring[2])*10;
2953 endy[2]=starty[2]+20;
2959 //tempncl=numchallengelevels;
2960 //numchallengelevels=9;
2961 nummenuitems=2+numchallengelevels;
2964 for(j=0;j<numchallengelevels;j++){
2965 for(i=0;i<255;i++)menustring[j][i]='\0';
2966 sprintf (temp, "Level %d",j+1);
2967 strcpy(menustring[j],temp);
2968 for(i=0;i<17;i++)if(menustring[j][i]=='\0')menustring[j][i]=' ';
2969 menustring[j][17]='\0';
2970 sprintf (temp, "%d",(int)accounthighscore[accountactive][j]);
2971 strcat(menustring[j],temp);
2972 for(i=18;i<32;i++)if(menustring[j][i]=='\0')menustring[j][i]=' ';
2973 menustring[j][32]='\0';
2974 sprintf (temp, "%d:",(int)(((int)accountfasttime[accountactive][j]-(int)(accountfasttime[accountactive][j])%60)/60));
2975 strcat(menustring[j],temp);
2976 if((int)(accountfasttime[accountactive][j])%60<10)strcat(menustring[j],"0");
2977 sprintf (temp, "%d",(int)(accountfasttime[accountactive][j])%60);
2978 strcat(menustring[j],temp);
2982 endx[j]=startx[j]+strlen(menustring[j])*10;
2983 endy[j]=starty[j]+20;
2988 sprintf (menustring[numchallengelevels], "Back");
2989 startx[numchallengelevels]=10;
2990 endx[numchallengelevels]=startx[numchallengelevels]+strlen(menustring[numchallengelevels])*10;
2991 starty[numchallengelevels]=10;
2992 endy[numchallengelevels]=starty[numchallengelevels]+20;
2993 movex[numchallengelevels]=0;
2994 movey[numchallengelevels]=0;
2996 sprintf (menustring[numchallengelevels+1], " High Score Best Time");
2997 startx[numchallengelevels+1]=10;
2998 starty[numchallengelevels+1]=440;
2999 endx[numchallengelevels+1]=startx[numchallengelevels+1]+strlen(menustring[numchallengelevels+1])*10;
3000 endy[numchallengelevels+1]=starty[numchallengelevels+1]+20;
3001 movex[numchallengelevels+1]=0;
3002 movey[numchallengelevels+1]=0;
3004 //numchallengelevels=tempncl;
3008 nummenuitems=2+numchallengelevels;
3011 for(j=0;j<numchallengelevels;j++){
3012 for(i=0;i<255;i++)menustring[j][i]='\0';
3013 sprintf (temp, "Level %d",j+1);
3014 strcpy(menustring[j],temp);
3015 for(i=0;i<17;i++)if(menustring[j][i]=='\0')menustring[j][i]=' ';
3016 menustring[j][17]='\0';
3017 sprintf (temp, "%d",(int)accounthighscore[accountactive][j]);
3018 strcat(menustring[j],temp);
3019 for(i=18;i<32;i++)if(menustring[j][i]=='\0')menustring[j][i]=' ';
3020 menustring[j][32]='\0';
3021 sprintf (temp, "%d:",(int)(((int)accountfasttime[accountactive][j]-(int)(accountfasttime[accountactive][j])%60)/60));
3022 strcat(menustring[j],temp);
3023 if((int)(accountfasttime[accountactive][j])%60<10)strcat(menustring[j],"0");
3024 sprintf (temp, "%d",(int)(accountfasttime[accountactive][j])%60);
3025 strcat(menustring[j],temp);
3029 endx[j]=startx[j]+strlen(menustring[j])*10;
3030 endy[j]=starty[j]+20;
3035 sprintf (menustring[numchallengelevels], "Back");
3036 startx[numchallengelevels]=10;
3037 endx[numchallengelevels]=startx[numchallengelevels]+strlen(menustring[numchallengelevels])*10;
3038 starty[numchallengelevels]=10;
3039 endy[numchallengelevels]=starty[numchallengelevels]+20;
3040 movex[numchallengelevels]=0;
3041 movey[numchallengelevels]=0;
3043 sprintf (menustring[numchallengelevels+1], " High Score Best Time");
3044 startx[numchallengelevels+1]=10;
3045 starty[numchallengelevels+1]=400;
3046 endx[numchallengelevels+1]=startx[numchallengelevels+1]+strlen(menustring[numchallengelevels+1])*10;
3047 endy[numchallengelevels+1]=starty[numchallengelevels+1]+20;
3048 movex[numchallengelevels+1]=0;
3049 movey[numchallengelevels+1]=0;
3056 sprintf (menustring[0], "Congratulations!");
3059 endx[0]=startx[0]+strlen(menustring[0])*10;
3060 endy[0]=starty[0]+20;
3064 sprintf (menustring[1], "You have avenged your family and");
3067 endx[1]=startx[1]+strlen(menustring[1])*10;
3068 endy[1]=starty[1]+20;
3072 sprintf (menustring[2], "restored peace to the island of Lugaru.");
3075 endx[2]=startx[2]+strlen(menustring[2])*10;
3076 endy[2]=starty[2]+20;
3080 sprintf (menustring[3], "Back");
3082 endx[3]=startx[3]+strlen(menustring[3])*10;
3084 endy[3]=starty[3]+20;
3088 for(i=0;i<255;i++)menustring[4][i]='\0';
3089 sprintf (temp, "Your score:");
3090 strcpy(menustring[4],temp);
3091 for(i=0;i<20;i++)if(menustring[4][i]=='\0')menustring[4][i]=' ';
3092 menustring[4][20]='\0';
3093 sprintf (temp, "%d",(int)accountcampaignscore[accountactive]);
3094 strcat(menustring[4],temp);
3096 endx[4]=startx[4]+strlen(menustring[4])*10;
3098 endy[4]=starty[4]+20;
3102 for(i=0;i<255;i++)menustring[5][i]='\0';
3103 sprintf (temp, "Your time:");
3104 strcpy(menustring[5],temp);
3105 for(i=0;i<20;i++)if(menustring[5][i]=='\0')menustring[5][i]=' ';
3106 menustring[5][20]='\0';
3107 sprintf (temp, "%d",(int)accountcampaigntime[accountactive]);
3108 strcat(menustring[5],temp);
3110 endx[5]=startx[5]+strlen(menustring[5])*10;
3112 endy[5]=starty[5]+20;
3116 for(i=0;i<255;i++)menustring[5][i]='\0';
3117 sprintf (temp, "Highest score:");
3118 strcpy(menustring[5],temp);
3119 for(i=0;i<20;i++)if(menustring[5][i]=='\0')menustring[5][i]=' ';
3120 menustring[5][20]='\0';
3121 sprintf (temp, "%d",(int)accountcampaignhighscore[accountactive]);
3122 strcat(menustring[5],temp);
3124 endx[5]=startx[5]+strlen(menustring[5])*10;
3126 endy[5]=starty[5]+20;
3130 for(i=0;i<255;i++)menustring[7][i]='\0';
3131 sprintf (temp, "Lowest time:");
3132 strcpy(menustring[7],temp);
3133 for(i=0;i<20;i++)if(menustring[7][i]=='\0')menustring[7][i]=' ';
3134 menustring[7][20]='\0';
3135 sprintf (temp, "%d",(int)accountcampaignfasttime[accountactive]);
3136 strcat(menustring[7],temp);
3138 endx[7]=startx[7]+strlen(menustring[7])*10;
3140 endy[7]=starty[7]+20;
3150 sprintf (menustring[0], "Please enter your name:");
3153 endx[0]=startx[0]+strlen(menustring[0])*10;
3154 endy[0]=starty[0]+20;
3158 sprintf (menustring[1], "Please enter your name:");
3161 endx[1]=startx[1]+strlen(menustring[1])*10;
3162 endy[1]=starty[1]+20;
3166 if(mainmenu==1||mainmenu==2){
3176 starty[1]=480-152-32;
3183 starty[2]=480-228-32;
3191 starty[3]=480-306-32;
3200 starty[3]=480-306-32;
3214 starty[4]=480-140-256;
3221 starty[5]=480-138-256;
3228 starty[6]=480-144-256;
3236 starty[4]=480-140-256;
3243 starty[5]=480-138-256;
3250 starty[6]=480-144-256;
3258 starty[4]=480-140-256;
3265 starty[5]=480-150-256;
3272 starty[6]=480-144-256;
3280 starty[4]=480-140-256;
3287 starty[5]=480-150-256;
3294 starty[6]=480-144-256;
3302 starty[4]=480-100-256;
3309 starty[5]=480-120-256;
3316 starty[6]=480-144-256;
3326 if(mainmenu==1||mainmenu==2)
3328 if((mousecoordh/screenwidth*640)>startx[i]&&(mousecoordh/screenwidth*640)<endx[i]&&480-(mousecoordv/screenheight*480)>starty[i]&&480-(mousecoordv/screenheight*480)<endy[i]){
3333 if(mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==8||mainmenu==9||mainmenu==10||mainmenu==11||mainmenu==13||mainmenu==17)
3334 for(i=0;i<nummenuitems;i++){
3335 if((mousecoordh/screenwidth*640)>startx[i]&&(mousecoordh/screenwidth*640)<endx[i]&&480-(mousecoordv/screenheight*480)>starty[i]&&480-(mousecoordv/screenheight*480)<endy[i]){
3336 if(mainmenu!=5)selected=i;
3337 if(mainmenu==5&&(i!=0&&i!=6))selected=i;
3338 if(mainmenu==9&&(i!=numchallengelevels+1))selected=i;
3339 if(mainmenu==11&&(i!=numchallengelevels+1))selected=i;
3344 for(i=0;i<nummenuitems;i++){
3345 if(selected==i)selectedlong[i]+=multiplier*5;
3346 if(selectedlong[i]>1)selectedlong[i]=1;
3347 if(selected!=i)selectedlong[i]-=multiplier*5;
3348 if(selectedlong[i]<0)selectedlong[i]=0;
3349 //if(i>=4)selectedlong[i]=.3;
3350 if(i>=4&&(mainmenu==1||mainmenu==2))selectedlong[i]=0;
3354 for(i=0;i<nummenuitems;i++){
3355 offsetx[i]=(startx[i]+endx[i])/2-(mousecoordh/screenwidth*640);
3356 offsety[i]=(starty[i]+endy[i])/2-(480-(mousecoordv/screenheight*480));
3361 if(i>=4&&(mainmenu==1||mainmenu==2)){
3362 offsetx[i]=(startx[i]+endx[i]+movex[i]*transition)/2-(640+190)/2;
3363 offsety[i]=(starty[i]+endy[i]+movey[i]*transition)/2-(336+150)/2;
3369 if(mainmenu==1||mainmenu==2){
3370 glClear(GL_DEPTH_BUFFER_BIT);
3371 glEnable(GL_ALPHA_TEST);
3372 glAlphaFunc(GL_GREATER, 0.001f);
3373 glEnable(GL_TEXTURE_2D);
3374 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3375 glDisable(GL_CULL_FACE);
3376 glDisable(GL_LIGHTING);
3378 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3379 glPushMatrix(); // Store The Projection Matrix
3380 glLoadIdentity(); // Reset The Projection Matrix
3381 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
3382 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3383 glPushMatrix(); // Store The Modelview Matrix
3384 glLoadIdentity(); // Reset The Modelview Matrix
3385 glTranslatef(screenwidth/2,screenheight/2,0);
3387 glScalef((float)screenwidth/2,(float)screenheight/2,1);
3388 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3389 glDisable(GL_BLEND);
3390 glColor4f(0,0,0,1.0);
3391 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
3392 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
3393 glDisable(GL_TEXTURE_2D);
3395 //glScalef(.25,.25,.25);
3398 glVertex3f(-1, -1, 0.0f);
3400 glVertex3f(1, -1, 0.0f);
3402 glVertex3f(1, 1, 0.0f);
3404 glVertex3f(-1, 1, 0.0f);
3408 glColor4f(0.4,0.4,0.4,1.0);
3409 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
3410 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
3411 glEnable(GL_TEXTURE_2D);
3412 glBindTexture( GL_TEXTURE_2D, Mainmenuitems[4]);
3414 //glScalef(.25,.25,.25);
3417 glVertex3f(-1, -1, 0.0f);
3419 glVertex3f(1, -1, 0.0f);
3421 glVertex3f(1, 1, 0.0f);
3423 glVertex3f(-1, 1, 0.0f);
3428 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3431 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3432 glPushMatrix(); // Store The Projection Matrix
3433 glLoadIdentity(); // Reset The Projection Matrix
3434 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3435 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3436 glPushMatrix(); // Store The Modelview Matrix
3437 glLoadIdentity(); // Reset The Modelview Matrix
3439 glDisable(GL_TEXTURE_2D);
3444 if(anim!=1)glVertex3f(190, 150, 0.0f);
3445 if(anim==1)glVertex3f(190+movex[4]*transition, 150, 0.0f);
3447 glVertex3f(640, 150, 0.0f);
3449 glVertex3f(640, 336, 0.0f);
3451 if(anim!=1)glVertex3f(190, 336, 0.0f);
3452 if(anim==1)glVertex3f(190+movex[4]*transition, 336, 0.0f);
3457 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3459 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3463 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3464 glPushMatrix(); // Store The Projection Matrix
3465 glLoadIdentity(); // Reset The Projection Matrix
3466 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3467 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3468 glPushMatrix(); // Store The Modelview Matrix
3469 glLoadIdentity(); // Reset The Modelview Matrix
3470 glEnable(GL_TEXTURE_2D);
3473 for(j=0;j<nummenuitems;j++)
3475 if(j<=3||(mainmenu!=1&&mainmenu!=2))
3477 //glDisable(GL_BLEND);
3478 glEnable(GL_ALPHA_TEST);
3480 //glDisable(GL_ALPHA_TEST);
3481 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3482 if(mainmenu==1||mainmenu==2)
3485 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3486 glBindTexture( GL_TEXTURE_2D, Mainmenuitems[j]);
3487 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
3488 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
3489 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3493 glVertex3f(startx[j]+movex[j]*transition, starty[j]+movey[j]*transition, 0.0f);
3495 glVertex3f(endx[j]+movex[j]*transition, starty[j]+movey[j]*transition, 0.0f);
3497 glVertex3f(endx[j]+movex[j]*transition, endy[j]+movey[j]*transition, 0.0f);
3499 glVertex3f(startx[j]+movex[j]*transition, endy[j]+movey[j]*transition, 0.0f);
3503 //glDisable(GL_ALPHA_TEST);
3504 if(j<4)glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3507 if(1-((float)i)/10-(1-selectedlong[j])>0)
3509 glColor4f(1,1,1,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3510 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3514 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);
3516 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);
3518 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);
3520 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);
3526 if(mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==8||mainmenu==9||mainmenu==10||mainmenu==11||mainmenu==13||mainmenu==17)
3528 if(mainmenu!=5||j<6)
3531 if(mainmenu==9&&j>accountprogress[accountactive]&&j<numchallengelevels)glColor4f(0.5,0,0,1);
3532 if(mainmenu==11&&j>accountprogress[accountactive]&&j<numchallengelevels)glColor4f(0.5,0,0,1);
3533 //if(1-((float)i)/10-(1-selectedlong[j])>0){
3534 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3536 if(mainmenu!=7||j!=0||!entername)text.glPrint(startx[j],starty[j],menustring[j],0,1,640,480);
3540 sprintf (string, "_");
3541 text.glPrint(startx[j]+(float)(displayselected)*10,starty[j],string,0,1,640,480);
3544 for(l=0;l<displaychars[k];l++){
3545 if(l<displaychars[k]){
3546 sprintf (string, "%c",displaytext[k][l]);
3547 text.glPrint(startx[j]+l*10,starty[j],string,0,1,640,480);
3555 sprintf (string, "Hooo!");
3556 text.glPrint(startx[0],starty[0],string,0,1,640,480);
3560 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3563 if(1-((float)i)/15-(1-selectedlong[j])>0)
3565 glColor4f(1,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3566 if(mainmenu==9&&j>accountprogress[accountactive]&&j<numchallengelevels)glColor4f(0.5,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3567 if(mainmenu==11&&j>accountprogress[accountactive]&&j<numchallengelevels)glColor4f(0.5,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3568 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);
3569 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);
3570 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);
3571 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);
3572 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);
3573 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);
3574 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);
3575 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);
3576 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);
3577 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);
3578 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);
3581 sprintf (string, "_");
3582 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);
3585 for(l=0;l<displaychars[k];l++){
3586 if(l<displaychars[k]){
3587 sprintf (string, "%c",displaytext[k][l]);
3588 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);
3597 glClear(GL_DEPTH_BUFFER_BIT);
3598 glEnable(GL_ALPHA_TEST);
3599 glAlphaFunc(GL_GREATER, 0.001f);
3600 glEnable(GL_TEXTURE_2D);
3601 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3602 glDisable(GL_CULL_FACE);
3603 glDisable(GL_LIGHTING);
3604 if(j==6)glColor4f(1,1,1,1);
3605 else glColor4f(1,0,0,1);
3607 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3608 glPushMatrix(); // Store The Projection Matrix
3609 glLoadIdentity(); // Reset The Projection Matrix
3610 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3611 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3612 glPushMatrix(); // Store The Modelview Matrix
3613 glLoadIdentity(); // Reset The Modelview Matrix
3616 //Draw world, draw map
3617 glTranslatef(2,-5,0);
3619 if(j>6&&j<nummenuitems-1)
3621 XYZ linestart,lineend,offset;
3628 //float linestartx,lineendx,linestarty,lineendy,offsetx,offsety;
3629 linestart.x=(startx[j]+endx[j])/2;
3630 linestart.y=(starty[j]+endy[j])/2;
3631 if(j>=6+accountcampaignchoicesmade[accountactive]){
3632 linestart.x=(startx[6+accountcampaignchoicesmade[accountactive]]+endx[6+accountcampaignchoicesmade[accountactive]])/2;
3633 linestart.y=(starty[6+accountcampaignchoicesmade[accountactive]]+endy[6+accountcampaignchoicesmade[accountactive]])/2;
3635 lineend.x=(startx[j+1]+endx[j+1])/2;
3636 lineend.y=(starty[j+1]+endy[j+1])/2;
3637 offset=lineend-linestart;
3640 offset=DoRotation(offset,0,0,90);
3642 glDisable(GL_TEXTURE_2D);
3644 if(j<6+accountcampaignchoicesmade[accountactive]){
3645 glColor4f(0.5,0,0,1);
3649 if(j>=6+accountcampaignchoicesmade[accountactive]){
3655 linestart+=fac*4*startsize;
3656 lineend-=fac*4*endsize;
3658 if(!(j>7+accountcampaignchoicesmade[accountactive]+campaignchoicenum)){
3659 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3663 glVertex3f(linestart.x-offset.x*startsize, linestart.y-offset.y*startsize, 0.0f);
3665 glVertex3f(linestart.x+offset.x*startsize, linestart.y+offset.y*startsize, 0.0f);
3667 glVertex3f(lineend.x+offset.x*endsize, lineend.y+offset.y*endsize, 0.0f);
3669 glVertex3f(lineend.x-offset.x*endsize, lineend.y-offset.y*endsize, 0.0f);
3673 glEnable(GL_TEXTURE_2D);
3677 if(j==6)glBindTexture( GL_TEXTURE_2D, Mainmenuitems[7]);
3678 else glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
3679 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
3680 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
3681 if(j-7<accountcampaignchoicesmade[accountactive])glColor4f(0.5,0,0,1);
3682 if(j-7>=accountcampaignchoicesmade[accountactive])glColor4f(1,0,0,1);
3683 if(j==6)glColor4f(1,1,1,1);
3686 itemsize=abs(startx[j]-endx[j])/2;
3688 midpoint.x=(startx[j]+endx[j])/2;
3689 midpoint.y=(starty[j]+endy[j])/2;
3690 if(j>6&&(j-7<accountcampaignchoicesmade[accountactive]))itemsize*=.5;
3691 if(!(j-7>accountcampaignchoicesmade[accountactive]+campaignchoicenum))
3693 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3697 glVertex3f(midpoint.x-itemsize+movex[j]*transition, midpoint.y-itemsize+movey[j]*transition, 0.0f);
3699 glVertex3f(midpoint.x+itemsize+movex[j]*transition, midpoint.y-itemsize+movey[j]*transition, 0.0f);
3701 glVertex3f(midpoint.x+itemsize+movex[j]*transition, midpoint.y+itemsize+movey[j]*transition, 0.0f);
3703 glVertex3f(midpoint.x-itemsize+movex[j]*transition, midpoint.y+itemsize+movey[j]*transition, 0.0f);
3707 //glDisable(GL_ALPHA_TEST);
3708 if(j<4)glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3711 if(1-((float)i)/10-(1-selectedlong[j])>0)
3713 glColor4f(1,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3714 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3718 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);
3720 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);
3722 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);
3724 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);
3732 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3734 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3736 if(j-7>=accountcampaignchoicesmade[accountactive]){
3737 //glColor4f(0,0,0,1);
3738 //text.glPrintOutline(startx[j]+10-1.5,starty[j]-4-1.5,menustring[j],0,0.6*1.25,640,480);
3739 //glColor4f(1,0,0,1);
3740 //text.glPrint(startx[j]+10,starty[j]-4,menustring[j],0,0.6,640,480);
3741 text.glPrintOutlined(0.9,0,0,startx[j]+10,starty[j]-4,menustring[j],0,0.6,640,480);
3742 glDisable(GL_DEPTH_TEST);
3749 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3751 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3754 if(mainmenu==1||mainmenu==2)
3755 if(transition<.1||transition>.9){
3756 glClear(GL_DEPTH_BUFFER_BIT);
3757 glEnable(GL_ALPHA_TEST);
3758 glAlphaFunc(GL_GREATER, 0.001f);
3759 glEnable(GL_TEXTURE_2D);
3760 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3761 glDisable(GL_CULL_FACE);
3762 glDisable(GL_LIGHTING);
3764 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3765 glPushMatrix(); // Store The Projection Matrix
3766 glLoadIdentity(); // Reset The Projection Matrix
3767 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3768 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3769 glPushMatrix(); // Store The Modelview Matrix
3770 glLoadIdentity(); // Reset The Modelview Matrix
3772 glDisable(GL_TEXTURE_2D);
3773 if(transition<.1)glColor4f(1,0,0,1-(transition*10));
3774 if(transition>.9)glColor4f(1,0,0,1-((1-transition)*10));
3778 glVertex3f(190, 150, 0.0f);
3780 glVertex3f(640, 150, 0.0f);
3782 glVertex3f(640, 336, 0.0f);
3784 glVertex3f(190, 336, 0.0f);
3789 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3793 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3794 glPushMatrix(); // Store The Projection Matrix
3795 glLoadIdentity(); // Reset The Projection Matrix
3796 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
3797 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3798 glPushMatrix(); // Store The Modelview Matrix
3799 glLoadIdentity(); // Reset The Modelview Matrix
3800 glTranslatef(screenwidth/2,screenheight/2,0);
3802 glScalef((float)screenwidth/2,(float)screenheight/2,1);
3803 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3805 glEnable(GL_TEXTURE_2D);
3807 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
3808 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
3811 glTranslatef(mousecoordh-screenwidth/2,mousecoordv*-1+screenheight/2,0);
3812 glScalef((float)screenwidth/64,(float)screenwidth/64,1);
3813 glTranslatef(1,-1,0);
3814 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3816 glBindTexture( GL_TEXTURE_2D, cursortexture);
3818 //glScalef(.25,.25,.25);
3821 glVertex3f(-1, -1, 0.0f);
3823 glVertex3f(1, -1, 0.0f);
3825 glVertex3f(1, 1, 0.0f);
3827 glVertex3f(-1, 1, 0.0f);
3832 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3838 if(flashamount>1)flashamount=1;
3839 if(flashdelay<=0)flashamount-=multiplier;
3841 if(flashamount<0)flashamount=0;
3842 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3843 glDisable(GL_CULL_FACE);
3844 glDisable(GL_LIGHTING);
3845 glDisable(GL_TEXTURE_2D);
3847 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3848 glPushMatrix(); // Store The Projection Matrix
3849 glLoadIdentity(); // Reset The Projection Matrix
3850 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
3851 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3852 glPushMatrix(); // Store The Modelview Matrix
3853 glLoadIdentity(); // Reset The Modelview Matrix
3854 glScalef(screenwidth,screenheight,1);
3855 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3857 glColor4f(flashr,flashg,flashb,flashamount);
3859 glVertex3f(0, 0, 0.0f);
3860 glVertex3f(256, 0, 0.0f);
3861 glVertex3f(256, 256, 0.0f);
3862 glVertex3f(0, 256, 0.0f);
3864 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3865 glPopMatrix(); // Restore The Old Projection Matrix
3866 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3867 glPopMatrix(); // Restore The Old Projection Matrix
3868 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
3869 glEnable(GL_CULL_FACE);
3870 glDisable(GL_BLEND);
3875 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)||(!gameon&&gamestarted)){
3876 tempmult=multiplier;
3882 if(drawmode!=motionblurmode||mainmenu){
3887 //myassert(glGetError() == GL_NO_ERROR);
3888 glDrawBuffer(GL_BACK);
3889 glReadBuffer(GL_BACK);
3894 if(drawtoggle==2)drawtoggle=0;
3896 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)){
3897 multiplier=tempmult;
3899 //Jordan fixed your warning!