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 OPENAL_SAMPLE *samp[100];
179 extern int channels[100];
180 extern "C" void PlaySoundEx(int channel, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
182 /*********************> DrawGLScene() <*****/
183 long long Game::MD5_string (char *string){
188 sprintf (temp, "%s",string);
191 while (i<256&&temp[i]!='\0'){
192 if(temp[i]%3==0)num+=temp[i]*124;
193 else if(temp[i]%3==1)num-=temp[i]*temp[i];
198 num=longlongabs(num);
201 while(num<LONGLONGCONST(5000000000000000)){
205 while(num>LONGLONGCONST(9900000000000000)){
211 //return 1111111111111111;
214 int Game::DrawGLScene(void)
216 static float texcoordwidth,texcoordheight;
217 static float texviewwidth, texviewheight;
219 static GLubyte color;
220 static float newbrightness;
221 static float changespeed;
222 static XYZ checkpoint;
223 static float tempmult;
225 static char string[256]="";
226 static char string2[256]="";
227 static char string3[256]="";
229 static float lastcheck;
231 lastcheck+=multiplier;
233 glColorMask( 1.0, 1.0, 1.0, 1.0 );
234 if(!registered)debugmode=0;
237 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)){
244 numboundaries=mapradius*2;
245 if(numboundaries>360)numboundaries=360;
246 for(i=0;i<numboundaries;i++){
249 boundary[i]=mapcenter+DoRotation(boundary[i]*mapradius,0,i*(360/((float)(numboundaries))),0);
258 olddrawmode=drawmode;
259 if(ismotionblur&&!loading){
260 if((findLengthfast(&player[0].velocity)>200)&&velocityblur&&!cameramode){
261 drawmode=motionblurmode;
262 motionbluramount=200/(findLengthfast(&player[0].velocity));
265 if(player[0].damage-player[0].superpermanentdamage>(player[0].damagetolerance-player[0].superpermanentdamage)*1/2&&damageeffects&&!cameramode){
266 drawmode=doublevisionmode;
273 drawmode=motionblurmode;
275 slomodelay-=multiplier;
276 if(slomodelay<0)slomo=0;
280 if((!changed&&!slomo)||loading){
282 if(ismotionblur&&(/*fps>100||*/alwaysblur)){
283 if(olddrawmode!=realmotionblurmode)change=1;
285 drawmode=realmotionblurmode;
287 else if(olddrawmode==realmotionblurmode)change=2;
291 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted))drawmode=normalmode;
292 if((freeze||winfreeze)&&ismotionblur&&!mainmenu)drawmode=radialzoommode;
294 if(winfreeze||mainmenu)drawmode=normalmode;
297 if(drawmode==glowmode){
303 DSpContext_FadeGamma(NULL,200,&color2);
307 if(drawtoggle!=2)drawtoggle=1-drawtoggle;
311 texviewwidth=kTextureSize;
312 if(texviewwidth>screenwidth)texviewwidth=screenwidth;
313 texviewheight=kTextureSize;
314 if(texviewheight>screenheight)texviewheight=screenheight;
316 texcoordwidth=screenwidth/kTextureSize;
317 texcoordheight=screenheight/kTextureSize;
318 if(texcoordwidth>1)texcoordwidth=1;
319 if(texcoordheight>1)texcoordheight=1;
322 glDrawBuffer(GL_BACK);
323 glReadBuffer(GL_BACK);
325 /*if(environment==desertenvironment)glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, (float)(abs(Random()%100))/50 );
326 else glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0);
328 if(abs(blurness-targetblurness)<multiplier*10||abs(blurness-targetblurness)>2){
329 blurness=targetblurness;
330 targetblurness=(float)(abs(Random()%100))/40;
332 if(blurness<targetblurness)blurness+=multiplier*5;
333 if(blurness>targetblurness)blurness-=multiplier*5;
336 static XYZ terrainlight;
337 static float distance;
338 //if(drawmode==normalmode)ReSizeGLScene(90,.1);
339 if(drawmode==normalmode)ReSizeGLScene(90,.1f);
340 if(drawmode!=normalmode)glViewport(0,0,texviewwidth,texviewheight);
341 glDepthFunc(GL_LEQUAL);
343 glAlphaFunc(GL_GREATER, 0.0001f);
344 glEnable(GL_ALPHA_TEST);
345 glClearColor(0.25f, 0.25f, 0.25f, 1.0f);
346 glClear(GL_DEPTH_BUFFER_BIT);
348 glMatrixMode (GL_MODELVIEW);
349 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
351 if(!cameramode&&!freeze&&!winfreeze){
352 glRotatef(float(Random()%100)/10*camerashake/*+(woozy*woozy)/10*/,0,0,1);
353 glRotatef(rotation2+sin(woozy/2)*(player[0].damage/player[0].damagetolerance)*5,1,0,0);
354 glRotatef(rotation+sin(woozy)*(player[0].damage/player[0].damagetolerance)*5,0,1,0);
356 if(cameramode||freeze||winfreeze){
357 //glRotatef(float(Random()%100)/10*camerashake/*+(woozy*woozy)/10*/,0,0,1);
358 glRotatef(rotation2,1,0,0);
359 glRotatef(rotation,0,1,0);
362 if(environment==desertenvironment){
363 glRotatef((float)(abs(Random()%100))/3000-1,1,0,0);
364 glRotatef((float)(abs(Random()%100))/3000-1,0,1,0);
365 //glRotatef(blurness/40-1,1,0,0);
366 //glRotatef(blurness/40-1,0,1,0);
368 SetUpLight(&light,0);
370 if(environment==desertenvironment&&detail==2)glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, blurness+.4 );
371 if(environment==desertenvironment){
372 glRotatef((float)(abs(Random()%100))/1000,1,0,0);
373 glRotatef((float)(abs(Random()%100))/1000,0,1,0);
376 glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0);
378 glTranslatef(-viewer.x,-viewer.y,-viewer.z);
379 frustum.GetFrustum();
383 static float size,opacity,rotation;
385 for(k=0;k<numplayers;k++){
386 if(!player[k].skeleton.free&&player[k].playerdetail&&player[k].howactive<typesleeping)
387 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)
388 for(i=0;i<player[k].skeleton.num_joints;i++){
389 if(player[k].skeleton.joints[i].label==leftknee||player[k].skeleton.joints[i].label==rightknee||player[k].skeleton.joints[i].label==groin){
390 point=DoRotation(player[k].skeleton.joints[i].position,0,player[k].rotation,0)*player[k].scale+player[k].coords;
392 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;
393 if(k!=0&&tutoriallevel==1){
394 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;
396 terrain.MakeDecal(shadowdecal,point,size,opacity,rotation);
397 if(terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz])
398 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
399 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
400 if(objects.position[j].y<player[k].coords.y||objects.type[j]==tunneltype||objects.type[j]==weirdtype){
401 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);
404 if(k!=0&&tutoriallevel==1){
405 opacity=.2+.2*sin(smoketex*6+i);
407 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
412 if((player[k].skeleton.free||player[k].howactive>=typesleeping)&&player[k].playerdetail)
413 if(frustum.SphereInFrustum(player[k].coords.x,player[k].coords.y,player[k].coords.z,player[k].scale*5)&&player[k].occluded<25)
414 for(i=0;i<player[k].skeleton.num_joints;i++){
415 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){
416 if(player[k].skeleton.free)point=player[k].skeleton.joints[i].position*player[k].scale+player[k].coords;
417 else point=DoRotation(player[k].skeleton.joints[i].position,0,player[k].rotation,0)*player[k].scale+player[k].coords;
419 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;
420 if(k!=0&&tutoriallevel==1){
421 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;
423 terrain.MakeDecal(shadowdecal,point,size,opacity*.7,rotation);
424 if(terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz])
425 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
426 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
427 if(objects.position[j].y<player[k].coords.y||objects.type[j]==tunneltype||objects.type[j]==weirdtype){
428 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);
429 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);
432 if(k!=0&&tutoriallevel==1){
433 opacity=.2+.2*sin(smoketex*6+i);
435 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
441 if(!player[k].playerdetail)
442 if(frustum.SphereInFrustum(player[k].coords.x,player[k].coords.y,player[k].coords.z,player[k].scale*5))
444 point=player[k].coords;
446 opacity=.4-(player[k].coords.y-terrain.getHeight(player[k].coords.x,player[k].coords.z))/5;
447 terrain.MakeDecal(shadowdecal,point,size,opacity*.7,rotation);
448 if(terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz])
449 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
450 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
451 point=DoRotation(player[k].coords-objects.position[j],0,-objects.rotation[j],0);
454 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
460 glEnable(GL_TEXTURE_2D);
462 glEnable(GL_DEPTH_TEST);
463 glEnable(GL_CULL_FACE);
465 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
466 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
467 glBindTexture( GL_TEXTURE_2D, terraintexture);
469 glBindTexture( GL_TEXTURE_2D, terraintexture2);
471 //glBindTexture( GL_TEXTURE_2D, terraintexture3);
472 //glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
475 terrain.drawdecals();
478 glEnable(GL_CULL_FACE);
479 glEnable(GL_LIGHTING);
481 glEnable(GL_TEXTURE_2D);
484 glEnable(GL_COLOR_MATERIAL);
499 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
500 glEnable(GL_CULL_FACE);
501 glCullFace(GL_FRONT);
503 for(k=0;k<numplayers;k++){
504 if(k==0||tutoriallevel!=1){
506 glEnable(GL_LIGHTING);
507 terrainlight=terrain.getLighting(player[k].coords.x,player[k].coords.z);
508 distance=findDistancefast(&viewer,&player[k].coords);
509 distance=(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance;
510 glColor4f(terrainlight.x,terrainlight.y,terrainlight.z,distance);
511 if(distance>=1)glDisable(GL_BLEND);
513 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;
515 if(!player[k].occluded==0)i=checkcollide(viewer,checkpoint,player[k].lastoccluded);
516 if(i==-1||player[k].occluded==0)i=checkcollide(viewer,checkpoint);
518 player[k].occluded+=1;
519 player[k].lastoccluded=i;
521 else player[k].occluded=0;
522 if(player[k].occluded<25)player[k].DrawSkeleton();
528 if(!cameramode&&musictype==stream_music2)playerdist=findDistancefastflat(&player[0].coords,&viewer);
529 else playerdist=-100;
532 glEnable(GL_TEXTURE_2D);
537 if(frustum.SphereInFrustum(realhawkcoords.x+hawk.boundingspherecenter.x,realhawkcoords.y+hawk.boundingspherecenter.y,realhawkcoords.z+hawk.boundingspherecenter.z,2)){
538 glAlphaFunc(GL_GREATER, 0.0001f);
540 glDisable(GL_CULL_FACE);
541 glDisable(GL_LIGHTING);
543 glTranslatef(hawkcoords.x,hawkcoords.y,hawkcoords.z);
544 glRotatef(hawkrotation,0,1,0);
545 glTranslatef(25,0,0);
546 distance=findDistancefast(&viewer,&realhawkcoords)*1.2;
547 glColor4f(light.color[0],light.color[1],light.color[2],(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance);
548 if((viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance>1)glColor4f(light.color[0],light.color[1],light.color[2],1);
549 if((viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance>0)
550 hawk.drawdifftex(hawktexture);
555 /*glEnable(GL_CULL_FACE);
556 glCullFace(GL_FRONT);
558 for(k=0;k<numplayers;k++){
560 glEnable(GL_LIGHTING);
561 terrainlight=terrain.getLighting(player[k].coords.x,player[k].coords.z);
562 distance=findDistancefast(&viewer,&player[k].coords);
563 distance=(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance;
564 glColor4f(terrainlight.x,terrainlight.y,terrainlight.z,distance);
565 if(distance>=1)glDisable(GL_BLEND);
567 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;
569 if(checkcollide(viewer,checkpoint)){
570 player[k].occluded+=1;
572 else player[k].occluded=0;
573 if(player[k].occluded<25)player[k].DrawSkeleton();
577 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
578 glEnable(GL_CULL_FACE);
579 glCullFace(GL_FRONT);
581 for(k=0;k<numplayers;k++){
582 if(!(k==0||tutoriallevel!=1)){
584 glEnable(GL_LIGHTING);
585 terrainlight=terrain.getLighting(player[k].coords.x,player[k].coords.z);
586 distance=findDistancefast(&viewer,&player[k].coords);
587 distance=(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance;
588 glColor4f(terrainlight.x,terrainlight.y,terrainlight.z,distance);
589 if(distance>=1)glDisable(GL_BLEND);
591 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;
593 if(!player[k].occluded==0)i=checkcollide(viewer,checkpoint,player[k].lastoccluded);
594 if(i==-1||player[k].occluded==0)i=checkcollide(viewer,checkpoint);
596 player[k].occluded+=1;
597 player[k].lastoccluded=i;
599 else player[k].occluded=0;
600 if(player[k].occluded<25)player[k].DrawSkeleton();
607 glEnable(GL_TEXTURE_2D);
612 glDisable(GL_COLOR_MATERIAL);
614 glDisable(GL_LIGHTING);
615 glDisable(GL_TEXTURE_2D);
623 glDisable(GL_LIGHTING);
624 glDisable(GL_TEXTURE_2D);
625 glDisable(GL_COLOR_MATERIAL);
628 for(k=0;k<numplayers;k++){
629 if(player[k].numwaypoints>1){
630 glBegin(GL_LINE_LOOP);
631 for(i=0;i<player[k].numwaypoints;i++){
632 glVertex3f(player[k].waypoints[i].x,player[k].waypoints[i].y+.5,player[k].waypoints[i].z);
641 for(k=0;k<numpathpoints;k++){
642 if(numpathpointconnect[k]){
643 for(i=0;i<numpathpointconnect[k];i++){
644 glBegin(GL_LINE_LOOP);
645 glVertex3f(pathpoint[k].x,pathpoint[k].y+.5,pathpoint[k].z);
646 glVertex3f(pathpoint[pathpointconnect[k][i]].x,pathpoint[pathpointconnect[k][i]].y+.5,pathpoint[pathpointconnect[k][i]].z);
654 glVertex3f(pathpoint[pathpointselected].x,pathpoint[pathpointselected].y+.5,pathpoint[pathpointselected].z);
661 glEnable(GL_TEXTURE_2D);
662 glColor4f(.5,.5,.5,1);
664 sprintf (string, " ",(int)(fps));
665 text.glPrint(10,30,string,0,.8,screenwidth,screenheight);
668 if(bonus>0&&bonustime<1&&!winfreeze&&indialogue==-1/*bonustime<4*/){
669 if(bonus==tracheotomy)sprintf (string, "Tracheotomy!");
670 else if(bonus==backstab)sprintf (string, "Backstabber!");
671 else if(bonus==spinecrusher)sprintf (string, "Spinecrusher!");
672 else if(bonus==ninja)sprintf (string, "Ninja Bonus!");
673 else if(bonus==style)sprintf (string, "Style Bonus!");
674 else if(bonus==cannon)sprintf (string, "Leg Cannon!");
675 else if(bonus==aimbonus)sprintf (string, "Nice Aim!");
676 else if(bonus==deepimpact)sprintf (string, "Heavy Impact!");
677 else if(bonus==touchofdeath)sprintf (string, "Touch of Death!");
678 else if(bonus==swordreversebonus)sprintf (string, "Sword Disarm!");
679 else if(bonus==staffreversebonus)sprintf (string, "Staff Disarm!");
680 else if(bonus==reverseko)sprintf (string, "Reversal KO!");
681 else if(bonus==solidhit)sprintf (string, "Solid Hit!");
682 else if(bonus==twoxcombo)sprintf (string, "2X Combo!");
683 else if(bonus==threexcombo)sprintf (string, "3X Combo!");
684 else if(bonus==fourxcombo)sprintf (string, "4X COMBO!");
685 else if(bonus==megacombo)sprintf (string, "MEGA COMBO!");
686 else if(bonus==Reversal)sprintf (string, "Reversal!");
687 else if(bonus==Stabbonus)sprintf (string, "Punctured!");
688 else if(bonus==Slicebonus)sprintf (string, "Sliced!");
689 else if(bonus==Bullseyebonus)sprintf (string, "Bullseye!");
690 else if(bonus==Slashbonus)sprintf (string, "Slashed!");
691 else if(bonus==Wolfbonus)sprintf (string, "WOLF SLAYER!");
692 else if(bonus==FinishedBonus)sprintf (string, "SLAIN!");
693 else if(bonus==TackleBonus)sprintf (string, "Tackle!");
694 else if(bonus==AboveBonus)sprintf (string, "Death from Above!");
695 else sprintf (string, "Excellent!");
697 glColor4f(0,0,0,1-bonustime);
698 text.glPrintOutline(1024/2-10*strlen(string)-4,768/16-4+768*4/5,string,1,2.5,1024,768);
699 glColor4f(1,0,0,1-bonustime);
700 text.glPrint(1024/2-10*strlen(string),768/16+768*4/5,string,1,2,1024,768);
702 sprintf (string, "%d",(int)bonusvalue);
703 glColor4f(0,0,0,1-bonustime);
704 text.glPrintOutline(1024/2-10*strlen(string)-4,768/16-4-20+768*4/5,string,1,2.5*.8,1024,768);
705 glColor4f(1,0,0,1-bonustime);
706 text.glPrint(1024/2-10*strlen(string),768/16-20+768*4/5,string,1,2*.8,1024,768);
707 glColor4f(.5,.5,.5,1);
710 if(tutoriallevel==1){
711 tutorialopac=tutorialmaxtime-tutorialstagetime;
712 if(tutorialopac>1)tutorialopac=1;
713 if(tutorialopac<0)tutorialopac=0;
715 sprintf (string, " ");
716 sprintf (string2, " ");
717 sprintf (string3, " ");
718 if(tutorialstage==0){
719 sprintf (string, " ");
720 sprintf (string2, " ");
721 sprintf (string3, " ");
723 if(tutorialstage==1){
724 sprintf (string, "Welcome to the Lugaru training level!");
725 sprintf (string2, " ");
726 sprintf (string3, " ");
728 if(tutorialstage==2){
729 sprintf (string, "BASIC MOVEMENT:");
730 sprintf (string2, " ");
731 sprintf (string3, " ");
733 if(tutorialstage==3){
734 sprintf (string, "You can move the mouse to rotate the camera.");
735 sprintf (string2, " ");
736 sprintf (string3, " ");
738 if(tutorialstage==4){
739 sprintf (string, "Try using the %s, %s, %s and %s keys to move around.",KeyToChar(forwardkey),KeyToChar(leftkey),KeyToChar(backkey),KeyToChar(rightkey));
740 sprintf (string2, "All movement is relative to the camera.");
741 sprintf (string3, " ");
743 if(tutorialstage==5){
744 sprintf (string, "Please press %s to jump.",KeyToChar(jumpkey));
745 sprintf (string2, "You can hold it longer to jump higher.");
746 sprintf (string3, " ");
748 if(tutorialstage==6){
749 sprintf (string, "You can press %s to crouch.",KeyToChar(crouchkey));
750 sprintf (string2, "You can jump higher from a crouching position.");
751 sprintf (string3, " ");
753 if(tutorialstage==7){
754 sprintf (string, "While running, you can press %s to roll.",KeyToChar(crouchkey));
755 sprintf (string2, " ");
756 sprintf (string3, " ");
758 if(tutorialstage==8){
759 sprintf (string, "While crouching, you can sneak around silently");
760 sprintf (string2, "using the movement keys.");
761 sprintf (string3, " ");
763 if(tutorialstage==9){
764 sprintf (string, "Release the crouch key while sneaking and hold the movement keys");
765 sprintf (string2, "to run animal-style.");
766 sprintf (string3, " ");
768 if(tutorialstage==10){
769 sprintf (string, "ADVANCED MOVEMENT:");
770 sprintf (string2, " ");
771 sprintf (string3, " ");
773 if(tutorialstage==11){
774 sprintf (string, "When you jump at a wall, you can hold %s again",KeyToChar(jumpkey));
775 sprintf (string2, "during impact to perform a walljump.");
776 sprintf (string3, "Be sure to use the movement keys to press against the wall");
778 if(tutorialstage==12){
779 sprintf (string, "While in the air, you can press crouch to flip.",KeyToChar(jumpkey));
780 sprintf (string2, "Walljumps and flips confuse enemies and give you more control.");
781 sprintf (string3, " ");
783 if(tutorialstage==13){
784 sprintf (string, "BASIC COMBAT:");
785 sprintf (string2, " ");
786 sprintf (string3, " ");
788 if(tutorialstage==14){
789 sprintf (string, "There is now an imaginary enemy");
790 sprintf (string2, "in the middle of the training area.");
791 sprintf (string3, " ");
793 if(tutorialstage==15){
794 if(attackkey==MAC_MOUSEBUTTON1)sprintf (string, "Click to attack when you are near an enemy.");
795 else sprintf (string, "Press %s to attack when you are near an enemy.",KeyToChar(attackkey));
796 sprintf (string2, "You can punch by standing still near an enemy and attacking.");
797 sprintf (string3, " ");
799 if(tutorialstage==16){
800 sprintf (string, "If you are close, you will perform a weak punch.");
801 sprintf (string2, "The weak punch is excellent for starting attack combinations.");
802 sprintf (string3, " ");
804 if(tutorialstage==17){
805 sprintf (string, "Attacking while running results in a spin kick.");
806 sprintf (string2, "This is one of your most powerful ground attacks.");
807 sprintf (string3, " ");
809 if(tutorialstage==18){
810 sprintf (string, "Sweep the enemy's legs out by attacking while crouched.");
811 sprintf (string2, "This is a very fast attack, and easy to follow up.");
812 sprintf (string3, " ");
814 if(tutorialstage==19){
815 sprintf (string, "When an enemy is on the ground, you can deal some extra");
816 sprintf (string2, "damage by running up and drop-kicking him.");
817 sprintf (string3, "(Try knocking them down with a sweep first)");
819 if(tutorialstage==20){
820 sprintf (string, "Your most powerful individual attack is the rabbit kick.");
821 if(attackkey==MAC_MOUSEBUTTON1)sprintf (string2, "Run at the enemy while holding the mouse button, and press");
822 else sprintf (string2, "Run at the enemy while holding %s, and press", KeyToChar(attackkey));
823 sprintf (string3, "the jump key (%s) to attack.",KeyToChar(jumpkey));
825 if(tutorialstage==21){
826 sprintf (string, "This attack is devastating if timed correctly.");
827 sprintf (string2, "Even if timed incorrectly, it will knock the enemy over.");
828 if(againbonus)sprintf (string3, "Try rabbit-kicking the imaginary enemy again.");
829 else sprintf (string3, "Try rabbit-kicking the imaginary enemy.");
831 if(tutorialstage==22){
832 sprintf (string, "If you sneak behind an enemy unnoticed, you can kill");
833 sprintf (string2, "him instantly. Move close behind this enemy");
834 sprintf (string3, "and attack.");
836 if(tutorialstage==23){
837 sprintf (string, "Another important attack is the wall kick. When an enemy");
838 sprintf (string2, "is near a wall, perform a walljump nearby and hold");
839 sprintf (string3, "the attack key during impact with the wall.");
841 if(tutorialstage==24){
842 sprintf (string, "You can tackle enemies by running at them animal-style");
843 if(attackkey==MAC_MOUSEBUTTON1)sprintf (string2, "and pressing jump (%s) or attack(mouse button).",KeyToChar(jumpkey));
844 else sprintf (string2, "and pressing jump (%s) or attack(%s).",KeyToChar(jumpkey),KeyToChar(attackkey));
845 sprintf (string3, "This is especially useful when they are running away.");
847 if(tutorialstage==25){
848 sprintf (string, "Dodge by pressing back and attack. Dodging is essential");
849 sprintf (string2, "against enemies with swords or other long weapons.");
850 sprintf (string3, " ");
852 if(tutorialstage==26){
853 sprintf (string, "REVERSALS AND COUNTER-REVERSALS");
854 sprintf (string2, " ");
855 sprintf (string3, " ");
857 if(tutorialstage==27){
858 sprintf (string, "The enemy can now reverse your attacks.");
859 sprintf (string2, " ");
860 sprintf (string3, " ");
862 if(tutorialstage==28){
863 sprintf (string, "If you attack, you will notice that the enemy now sometimes");
864 sprintf (string2, "catches your attack and uses it against you. Hold");
865 sprintf (string3, "crouch (%s) after attacking to escape from reversals.",KeyToChar(crouchkey));
867 if(tutorialstage==29){
868 sprintf (string, "Try escaping from two more reversals in a row.");
869 sprintf (string2, " ");
870 sprintf (string3, " ");
872 if(tutorialstage==30){
873 sprintf (string, "Good!");
874 sprintf (string2, " ");
875 sprintf (string3, " ");
877 if(tutorialstage==31){
878 sprintf (string, "To reverse an attack, you must tap crouch (%s) during the",KeyToChar(crouchkey));
879 sprintf (string2, "enemy's attack. You must also be close to the enemy;");
880 sprintf (string3, "this is especially important against armed opponents.");
882 if(tutorialstage==32){
883 sprintf (string, "The enemy can attack in %d seconds.", (int)(tutorialmaxtime-tutorialstagetime));
884 sprintf (string2, "This imaginary opponents attacks will be highlighted");
885 sprintf (string3, "to make this easier.");
887 if(tutorialstage==33){
888 sprintf (string, "Reverse three enemy attacks!");
889 sprintf (string2, " ");
890 sprintf (string3, " ");
892 if(tutorialstage==34){
893 sprintf (string, "Reverse two more enemy attacks!");
894 sprintf (string2, " ");
895 sprintf (string3, " ");
897 if(tutorialstage==35){
898 sprintf (string, "Reverse one more enemy attack!");
899 sprintf (string2, " ");
900 sprintf (string3, " ");
902 if(tutorialstage==36){
903 sprintf (string, "Excellent!");
904 sprintf (string2, " ");
905 sprintf (string3, " ");
907 if(tutorialstage==37){
908 sprintf (string, "Now spar with the enemy for %d more seconds.", (int)(tutorialmaxtime-tutorialstagetime));
909 sprintf (string2, "Damage dealt: %d",(int)damagedealt);
910 sprintf (string3, "Damage taken: %d.",(int)damagetaken);
912 if(tutorialstage==38){
913 sprintf (string, "WEAPONS:");
914 sprintf (string2, " ");
915 sprintf (string3, " ");
917 if(tutorialstage==39){
918 sprintf (string, "There is now an imaginary knife");
919 sprintf (string2, "in the center of the training area.");
920 sprintf (string3, " ");
922 if(tutorialstage==40){
923 sprintf (string, "Stand, roll or handspring over the knife");
924 sprintf (string2, "while pressing %s to pick it up.",KeyToChar(throwkey));
925 sprintf (string3, "You can crouch and press the same key to drop it again.");
927 if(tutorialstage==41){
928 sprintf (string, "You can equip and unequip weapons using the %s key.",KeyToChar(drawkey));
929 sprintf (string2, "Sometimes it is best to keep them unequipped to");
930 sprintf (string3, "prevent enemies from taking them. ");
932 if(tutorialstage==42){
933 sprintf (string, "The knife is the smallest weapon and the least encumbering.");
934 sprintf (string2, "You can equip or unequip it while standing, crouching,");
935 sprintf (string3, "running or flipping.");
937 if(tutorialstage==43){
938 sprintf (string, "You perform weapon attacks the same way as unarmed attacks,");
939 sprintf (string2, "but sharp weapons cause permanent damage, instead of the");
940 sprintf (string3, "temporary trauma from blunt weapons, fists and feet.");
942 if(tutorialstage==44){
943 sprintf (string, "The enemy now has your knife!");
944 sprintf (string2, "Please reverse two of his knife attacks.");
945 sprintf (string3, " ");
947 if(tutorialstage==45){
948 sprintf (string, "Please reverse one more of his knife attacks.");
949 sprintf (string2, " ");
950 sprintf (string3, " ");
952 if(tutorialstage==46){
953 sprintf (string, "Now he has a sword!");
954 sprintf (string2, "The sword has longer reach than your arms, so you");
955 sprintf (string3, "must move close to reverse the sword slash.");
957 if(tutorialstage==47){
958 sprintf (string, "Long weapons like the sword and staff are also useful for defense;");
959 sprintf (string2, "you can parry enemy weapon attacks by pressing the attack key");
960 sprintf (string3, "at the right time. Please try parrying the enemy's attacks!");
962 if(tutorialstage==48){
963 sprintf (string, "The staff is like the sword, but has two main attacks.");
964 sprintf (string2, "The standing smash is fast and effective, and the running");
965 sprintf (string3, "spin smash is slower and more powerful.");
967 if(tutorialstage==49){
968 sprintf (string, "When facing an enemy, you can throw the knife with %s.",KeyToChar(throwkey));
969 sprintf (string2, "It is possible to throw the knife while flipping,");
970 sprintf (string3, "but it is very inaccurate.");
972 if(tutorialstage==50){
973 sprintf (string, "You now know everything you can learn from training.");
974 sprintf (string2, "Everything else you must learn from experience!");
975 sprintf (string3, " ");
977 if(tutorialstage==51){
978 sprintf (string, "Walk out of the training area to return to the main menu.");
979 sprintf (string2, " ");
980 sprintf (string3, " ");
983 glColor4f(0,0,0,tutorialopac);
984 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);
985 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);
986 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);
987 glColor4f(1,1,1,tutorialopac);
988 text.glPrint(screenwidth/2-7.6*strlen(string)*screenwidth/1024,screenheight/16+screenheight*4/5,string,1,1.5*screenwidth/1024,screenwidth,screenheight);
989 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);
990 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);
992 sprintf (string, "Press 'tab' to skip to the next item.",KeyToChar(jumpkey));
993 sprintf (string2, "Press escape at any time to");
994 sprintf (string3, "pause or exit the tutorial.");
997 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);
998 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);
999 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);
1000 glColor4f(0.5,0.5,0.5,1);
1001 text.glPrint(screenwidth/2-7.6*strlen(string)*screenwidth/1024*.8,0+screenheight*1/10,string,1,1.5*screenwidth/1024*.8,screenwidth,screenheight);
1002 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);
1003 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);
1007 if(numhotspots&&(bonustime>=1||bonus<=0||bonustime<0)&&!tutoriallevel){
1009 float closestdist=-1;
1011 closest=currenthotspot;
1012 for(i=0;i<numhotspots;i++){
1013 distance=findDistancefast(&player[0].coords,&hotspot[i]);
1014 if(closestdist==-1||distance<closestdist){
1015 if(findDistancefast(&player[0].coords,&hotspot[i])<hotspotsize[i]&&((hotspottype[i]<=10&&hotspottype[i]>=0)||(hotspottype[i]<=40&&hotspottype[i]>=20))){
1016 closestdist=distance;
1022 currenthotspot=closest;
1023 if(currenthotspot!=-1){
1024 if(hotspottype[closest]<=10){
1025 if(findDistancefast(&player[0].coords,&hotspot[closest])<hotspotsize[closest])
1026 tutorialstagetime=0;
1028 tutorialopac=tutorialmaxtime-tutorialstagetime;
1029 if(tutorialopac>1)tutorialopac=1;
1030 if(tutorialopac<0)tutorialopac=0;
1032 sprintf (string, "%s", hotspottext[closest]);
1040 if(string[i]=='\n'||string[i]>'z'||string[i]<' '||string[i]=='\0'){
1041 glColor4f(0,0,0,tutorialopac);
1042 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);
1043 glColor4f(1,1,1,tutorialopac);
1044 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);
1047 if(string[i]=='\0')done=1;
1053 else if (hotspottype[closest]>=20&&dialoguegonethrough[hotspottype[closest]-20]==0){
1054 whichdialogue=hotspottype[closest]-20;
1055 for(j=0;j<numdialogueboxes[whichdialogue];j++){
1056 player[participantfocus[whichdialogue][j]].coords=participantlocation[whichdialogue][participantfocus[whichdialogue][j]];
1057 player[participantfocus[whichdialogue][j]].rotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
1058 player[participantfocus[whichdialogue][j]].targetrotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
1059 player[participantfocus[whichdialogue][j]].velocity=0;
1060 player[participantfocus[whichdialogue][j]].targetanimation=player[participantfocus[whichdialogue][j]].getIdle();
1061 player[participantfocus[whichdialogue][j]].targetframe=0;
1065 dialoguegonethrough[whichdialogue]++;
1066 if(dialogueboxsound[whichdialogue][indialogue]!=0){
1067 static float gLoc[3];
1068 static float vel[3];
1069 gLoc[0]=player[participantfocus[whichdialogue][indialogue]].coords.x;
1070 gLoc[1]=player[participantfocus[whichdialogue][indialogue]].coords.y;
1071 gLoc[2]=player[participantfocus[whichdialogue][indialogue]].coords.z;
1076 if(dialogueboxsound[whichdialogue][indialogue]==1)whichsoundplay=rabbitchitter;
1077 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
1078 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
1079 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
1080 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
1081 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
1082 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
1083 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
1084 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
1085 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
1086 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
1087 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
1088 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
1089 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
1090 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
1091 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
1092 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
1093 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
1094 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
1095 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
1096 PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, true);
1097 OPENAL_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
1098 OPENAL_SetVolume(channels[whichsoundplay], 256);
1099 OPENAL_SetPaused(channels[whichsoundplay], false);
1105 if(indialogue!=-1&&!mainmenu){
1106 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1107 glDisable(GL_CULL_FACE);
1108 glDisable(GL_LIGHTING);
1109 glDisable(GL_TEXTURE_2D);
1111 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1112 glPushMatrix(); // Store The Projection Matrix
1113 glLoadIdentity(); // Reset The Projection Matrix
1114 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1115 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1116 glPushMatrix(); // Store The Modelview Matrix
1117 glLoadIdentity(); // Reset The Modelview Matrix
1118 if(dialogueboxlocation[whichdialogue][indialogue]==1)glTranslatef(0,screenheight*3/4,0);
1119 glScalef(screenwidth,screenheight/4,1);
1120 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1123 glColor4f(dialogueboxcolor[whichdialogue][indialogue][0],dialogueboxcolor[whichdialogue][indialogue][1],dialogueboxcolor[whichdialogue][indialogue][2],0.7);
1125 glVertex3f(0, 0, 0.0f);
1126 glVertex3f(1, 0, 0.0f);
1127 glVertex3f(1, 1, 0.0f);
1128 glVertex3f(0, 1, 0.0f);
1130 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1131 glPopMatrix(); // Restore The Old Projection Matrix
1132 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1133 glPopMatrix(); // Restore The Old Projection Matrix
1134 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1135 glEnable(GL_CULL_FACE);
1136 glDisable(GL_BLEND);
1138 glEnable(GL_TEXTURE_2D);
1145 startx=screenwidth*1/5;
1146 if(dialogueboxlocation[whichdialogue][indialogue]==1)starty=screenheight/16+screenheight*4/5;
1147 if(dialogueboxlocation[whichdialogue][indialogue]==2)starty=screenheight*1/5-screenheight/16;
1149 // char tempname[64];
1153 // for(i=0;i<64;i++){
1158 for(i=0;i<(int)strlen(dialoguename[whichdialogue][indialogue]);i++){
1159 tempname[tempnum]=dialoguename[whichdialogue][indialogue][i];
1161 if(dialoguename[whichdialogue][indialogue][i]=='#'||dialoguename[whichdialogue][indialogue][i]=='\0')goodchar=0;
1162 //if(tempnum>2)if(tempname[tempnum-2]=='e'&&tempname[tempnum-1]=='r')goodchar=0;
1163 //if(tempnum>2)if(tempname[tempnum]=='r'&&tempname[0]=='a')goodchar=0;
1164 if(goodchar)tempnum++;
1165 else tempname[tempnum]='\0';
1168 sprintf (string, "%s: ", tempname);
1170 if(dialogueboxcolor[whichdialogue][indialogue][0]+dialogueboxcolor[whichdialogue][indialogue][1]+dialogueboxcolor[whichdialogue][indialogue][2]<1.5){
1171 glColor4f(0,0,0,tutorialopac);
1172 text.glPrintOutline(startx-2*7.6*strlen(string)*screenwidth/1024-4,starty-4,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight);
1173 glColor4f(0.7,0.7,0.7,tutorialopac);
1174 text.glPrint(startx-2*7.6*strlen(string)*screenwidth/1024,starty,string,1,1.5*screenwidth/1024,screenwidth,screenheight);
1178 glColor4f(0,0,0,tutorialopac);
1179 text.glPrintOutline(startx-2*7.6*strlen(string)*screenwidth/1024-4,starty-4,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight);
1184 for(i=0;i<(int)strlen(dialoguetext[whichdialogue][indialogue])+1;i++){
1185 tempname[tempnum]=dialoguetext[whichdialogue][indialogue][i];
1186 if(dialoguetext[whichdialogue][indialogue][i]!='#')tempnum++;
1190 sprintf (string, "%s", tempname);
1199 if(string[i]=='\n'||string[i]>'z'||string[i]<' '||string[i]=='\0'){
1200 if(dialogueboxcolor[whichdialogue][indialogue][0]+dialogueboxcolor[whichdialogue][indialogue][1]+dialogueboxcolor[whichdialogue][indialogue][2]<1.5){
1201 glColor4f(0,0,0,tutorialopac);
1202 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);
1203 glColor4f(1,1,1,tutorialopac);
1204 text.glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/,starty-20*screenwidth/1024*line,string,1,1.5*screenwidth/1024,screenwidth,screenheight,lastline,i);
1208 glColor4f(0,0,0,tutorialopac);
1209 text.glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/,starty-20*screenwidth/1024*line,string,1,1.5*screenwidth/1024,screenwidth,screenheight,lastline,i);
1213 if(string[i]=='\0')done=1;
1220 if(!tutoriallevel&&!winfreeze&&indialogue==-1&&!mainmenu){
1222 if(!scoreadded)sprintf (string, "Score: %d", (int)accountcampaignscore[accountactive]+(int)bonustotal);//(int)bonustotal);
1223 if(scoreadded)sprintf (string, "Score: %d", (int)accountcampaignscore[accountactive]);//(int)bonustotal);
1225 if(!campaign)sprintf (string, "Score: %d", (int)bonustotal);
1227 text.glPrintOutline(1024/40-4,768/16-4+768*14/16,string,1,1.5*1.25,1024,768);
1229 text.glPrint(1024/40,768/16+768*14/16,string,1,1.5,1024,768);
1232 glColor4f(.5,.5,.5,1);
1235 if((texttoggle||editorenabled)&&debugmode&&!mainmenu){
1236 sprintf (string, "The framespersecond is %d.",(int)(fps));
1237 text.glPrint(10,30,string,0,.8,1024,768);
1239 sprintf (string, "Name: %s", registrationname);
1240 text.glPrint(10,260,string,0,.8,1024,768);
1243 if(editorenabled)sprintf (string, "Map editor enabled.");
1244 if(!editorenabled)sprintf (string, "Map editor Disabled.");
1245 text.glPrint(10,60,string,0,.8,1024,768);
1247 sprintf (string, "Object size: %f",editorsize);
1248 text.glPrint(10,75,string,0,.8,1024,768);
1249 if(editorrotation>=0)sprintf (string, "Object rotation: %f",editorrotation);
1250 else sprintf (string, "Object rotation: Random");
1251 text.glPrint(10,90,string,0,.8,1024,768);
1252 if(editorrotation2>=0)sprintf (string, "Object rotation2: %f",editorrotation2);
1253 else sprintf (string, "Object rotation2: Random");
1254 text.glPrint(10,105,string,0,.8,1024,768);
1255 sprintf (string, "Object type: %d",editortype);
1256 text.glPrint(10,120,string,0,.8,1024,768);
1257 if(editortype==boxtype)sprintf (string, "(box)");
1258 if(editortype==treetrunktype)sprintf (string, "(tree)");
1259 if(editortype==walltype)sprintf (string, "(wall)");
1260 if(editortype==weirdtype)sprintf (string, "(weird)");
1261 if(editortype==spiketype)sprintf (string, "(spike)");
1262 if(editortype==rocktype)sprintf (string, "(rock)");
1263 if(editortype==bushtype)sprintf (string, "(bush)");
1264 if(editortype==tunneltype)sprintf (string, "(tunnel)");
1265 if(editortype==chimneytype)sprintf (string, "(chimney)");
1266 if(editortype==platformtype)sprintf (string, "(platform)");
1267 if(editortype==cooltype)sprintf (string, "(cool)");
1268 if(editortype==firetype)sprintf (string, "(fire)");
1269 text.glPrint(130,120,string,0,.8,1024,768);
1271 sprintf (string, "Numplayers: %d",numplayers);
1272 text.glPrint(10,155,string,0,.8,1024,768);
1273 sprintf (string, "Player %d: numwaypoints: %d",numplayers,player[numplayers-1].numwaypoints);
1274 text.glPrint(10,140,string,0,.8,1024,768);
1276 /*sprintf (string, "Coords are: %f %f %f",player[0].coords.x,player[0].coords.y,player[0].coords.z);
1277 text.glPrint(10,200,string,0,.8,1024,768);*/
1278 sprintf (string, "Difficulty: %d",difficulty);
1279 text.glPrint(10,240,string,0,.8,1024,768);
1281 sprintf (string, "lasthotspot: %d",hotspottype[numhotspots-1]);
1282 text.glPrint(10,240,string,0,.8,1024,768);
1283 sprintf (string, "killhotspot: %d",killhotspot);
1284 text.glPrint(10,220,string,0,.8,1024,768);
1285 sprintf (string, "winhotspot: %d",winhotspot);
1286 text.glPrint(10,200,string,0,.8,1024,768);*/
1291 if(drawmode==glowmode){
1292 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1293 glDisable(GL_CULL_FACE);
1294 glDisable(GL_LIGHTING);
1295 glDisable(GL_TEXTURE_2D);
1297 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1298 glPushMatrix(); // Store The Projection Matrix
1299 glLoadIdentity(); // Reset The Projection Matrix
1300 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1301 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1302 glPushMatrix(); // Store The Modelview Matrix
1303 glLoadIdentity(); // Reset The Modelview Matrix
1304 glScalef(screenwidth,screenheight,1);
1305 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1307 glColor4f(0,0,0,.5);
1309 glVertex3f(0, 0, 0.0f);
1310 glVertex3f(256, 0, 0.0f);
1311 glVertex3f(256, 256, 0.0f);
1312 glVertex3f(0, 256, 0.0f);
1314 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1315 glPopMatrix(); // Restore The Old Projection Matrix
1316 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1317 glPopMatrix(); // Restore The Old Projection Matrix
1318 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1319 glEnable(GL_CULL_FACE);
1320 glDisable(GL_BLEND);
1324 if((((blackout&&damageeffects)||(player[0].bloodloss>0&&damageeffects&&player[0].blooddimamount>0)||player[0].dead)&&!cameramode)||console){
1325 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1326 glDisable(GL_CULL_FACE);
1327 glDisable(GL_LIGHTING);
1328 glDisable(GL_TEXTURE_2D);
1330 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1331 glPushMatrix(); // Store The Projection Matrix
1332 glLoadIdentity(); // Reset The Projection Matrix
1333 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1334 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1335 glPushMatrix(); // Store The Modelview Matrix
1336 glLoadIdentity(); // Reset The Modelview Matrix
1337 glScalef(screenwidth,screenheight,1);
1338 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1340 if(player[0].dead)blackout+=multiplier*3;
1341 if(player[0].dead==1)blackout=.4f;
1342 if(player[0].dead==2&&blackout>.6)blackout=.6;
1343 glColor4f(0,0,0,blackout);
1344 if(!player[0].dead){
1345 if((player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5))*.3<.3){
1346 glColor4f(0,0,0,player[0].blooddimamount*player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5)*.3);
1347 blackout=player[0].blooddimamount*player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5)*.3;
1350 glColor4f(0,0,0,player[0].blooddimamount*.3);
1351 blackout=player[0].blooddimamount*.3;
1354 if(console)glColor4f(.7,0,0,.2);
1356 glVertex3f(0, 0, 0.0f);
1357 glVertex3f(256, 0, 0.0f);
1358 glVertex3f(256, 256, 0.0f);
1359 glVertex3f(0, 256, 0.0f);
1361 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1362 glPopMatrix(); // Restore The Old Projection Matrix
1363 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1364 glPopMatrix(); // Restore The Old Projection Matrix
1365 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1366 glEnable(GL_CULL_FACE);
1367 glDisable(GL_BLEND);
1371 if(flashamount>0&&damageeffects){
1372 if(flashamount>1)flashamount=1;
1373 if(flashdelay<=0)flashamount-=multiplier;
1375 if(flashamount<0)flashamount=0;
1376 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1377 glDisable(GL_CULL_FACE);
1378 glDisable(GL_LIGHTING);
1380 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1381 glPushMatrix(); // Store The Projection Matrix
1382 glLoadIdentity(); // Reset The Projection Matrix
1383 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1384 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1385 glPushMatrix(); // Store The Modelview Matrix
1386 glLoadIdentity(); // Reset The Modelview Matrix
1387 glScalef(screenwidth,screenheight,1);
1388 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1390 glColor4f(flashr,flashg,flashb,flashamount);
1392 glVertex3f(0, 0, 0.0f);
1393 glVertex3f(256, 0, 0.0f);
1394 glVertex3f(256, 256, 0.0f);
1395 glVertex3f(0, 256, 0.0f);
1397 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1398 glPopMatrix(); // Restore The Old Projection Matrix
1399 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1400 glPopMatrix(); // Restore The Old Projection Matrix
1401 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1402 glEnable(GL_CULL_FACE);
1403 glDisable(GL_BLEND);
1409 glEnable(GL_TEXTURE_2D);
1412 sprintf (string, " ]");
1413 text.glPrint(10,30+screenheight-330,string,0,1,screenwidth,screenheight);
1415 sprintf (string, "_");
1416 text.glPrint(30+(float)(displayselected)*10,30+(screenheight-330),string,0,1,screenwidth,screenheight);
1420 if((i!=0||chatting)&&displaytime[i]<4)
1421 for(j=0;j<displaychars[i];j++){
1422 glColor4f(1,1,1,4-displaytime[i]);
1423 if(j<displaychars[i]){
1424 sprintf (string, "%c",displaytext[i][j]);
1425 text.glPrint(30+j*10,30+i*20+(screenheight-330),string,0,1,screenwidth,screenheight);
1431 if(minimap&&indialogue==-1){
1435 glDisable(GL_DEPTH_TEST);
1436 glColor3f (1.0, 1.0, 1.0); // no coloring
1438 glEnable(GL_TEXTURE_2D);
1439 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1440 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1441 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1442 glDisable(GL_CULL_FACE);
1443 glDisable(GL_LIGHTING);
1445 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1446 glPushMatrix(); // Store The Projection Matrix
1447 glLoadIdentity(); // Reset The Projection Matrix
1448 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1449 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1450 glPushMatrix(); // Store The Modelview Matrix
1451 glLoadIdentity(); // Reset The Modelview Matrix
1452 glScalef((float)screenwidth/2,(float)screenwidth/2,1);
1453 glTranslatef(1.75,.25,0);
1454 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1464 int numliveplayers=0;
1465 for(i=0;i<numplayers;i++){
1466 if(!player[i].dead)numliveplayers++;
1472 for(i=0;i<objects.numobjects;i++){
1473 if(objects.type[i]==treetrunktype||objects.type[i]==boxtype){
1474 center+=objects.position[i];
1478 for(i=0;i<numplayers;i++){
1479 if(!player[i].dead)center+=player[i].coords;
1481 center/=numadd+numliveplayers;
1483 center=player[0].coords;
1485 float maxdistance=0;
1488 for(i=0;i<objects.numobjects;i++){
1489 tempdist=findDistancefast(¢er,&objects.position[i]);
1490 if(tempdist>maxdistance){
1492 maxdistance=tempdist;
1495 for(i=0;i<numplayers;i++){
1496 if(!player[i].dead){
1497 tempdist=findDistancefast(¢er,&player[i].coords);
1498 if(tempdist>maxdistance){
1500 maxdistance=tempdist;
1504 radius=fast_sqrt(maxdistance);
1508 glScalef(.25/radius*256*terrain.scale*.4,.25/radius*256*terrain.scale*.4,1);
1510 glScalef(1/(1/radius*256*terrain.scale*.4),1/(1/radius*256*terrain.scale*.4),1);
1511 /*float startx,starty,endx,endy;
1513 glTexCoord2f(1-(center.x-radius)/terrain.scale/256,(center.z-radius)/terrain.scale/256);
1514 glVertex3f(-1, -1, 0.0f);
1515 glTexCoord2f(1-(center.x+radius)/terrain.scale/256,(center.z-radius)/terrain.scale/256);
1516 glVertex3f(1, -1, 0.0f);
1517 glTexCoord2f(1-(center.x+radius)/terrain.scale/256,(center.z+radius)/terrain.scale/256);
1518 glVertex3f(1, 1, 0.0f);
1519 glTexCoord2f(1-(center.x-radius)/terrain.scale/256,(center.z+radius)/terrain.scale/256);
1520 glVertex3f(-1, 1, 0.0f);
1523 glRotatef(player[0].lookrotation*-1+180,0,0,1);
1524 glTranslatef(-(center.x/terrain.scale/256*-2+1),(center.z/terrain.scale/256*-2+1),0);
1525 for(i=0;i<objects.numobjects;i++){
1526 if(objects.type[i]==treetrunktype){
1527 distcheck=findDistancefast(&player[0].coords,&objects.position[i]);
1528 if(distcheck<mapviewdist){
1529 glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
1530 glColor4f(0,.3,0,opac*(1-distcheck/mapviewdist));
1532 glTranslatef(objects.position[i].x/terrain.scale/256*-2+1,objects.position[i].z/terrain.scale/256*2-1,0);
1533 glRotatef(objects.rotation[i],0,0,1);
1534 glScalef(.003,.003,.003);
1537 glVertex3f(-1, -1, 0.0f);
1539 glVertex3f(1, -1, 0.0f);
1541 glVertex3f(1, 1, 0.0f);
1543 glVertex3f(-1, 1, 0.0f);
1548 if(objects.type[i]==boxtype){
1549 distcheck=findDistancefast(&player[0].coords,&objects.position[i]);
1550 if(distcheck<mapviewdist){
1551 glBindTexture( GL_TEXTURE_2D, Mapboxtexture);
1552 glColor4f(.4,.4,.4,opac*(1-distcheck/mapviewdist));
1554 glTranslatef(objects.position[i].x/terrain.scale/256*-2+1,objects.position[i].z/terrain.scale/256*2-1,0);
1555 glRotatef(objects.rotation[i],0,0,1);
1556 glScalef(.01*objects.scale[i],.01*objects.scale[i],.01*objects.scale[i]);
1559 glVertex3f(-1, -1, 0.0f);
1561 glVertex3f(1, -1, 0.0f);
1563 glVertex3f(1, 1, 0.0f);
1565 glVertex3f(-1, 1, 0.0f);
1572 glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
1573 for(i=0;i<numboundaries;i++){
1574 glColor4f(0,0,0,opac/3);
1576 glTranslatef(boundary[i].x/terrain.scale/256*-2+1,boundary[i].z/terrain.scale/256*2-1,0);
1577 glScalef(.002,.002,.002);
1580 glVertex3f(-1, -1, 0.0f);
1582 glVertex3f(1, -1, 0.0f);
1584 glVertex3f(1, 1, 0.0f);
1586 glVertex3f(-1, 1, 0.0f);
1591 for(i=0;i<numplayers;i++){
1592 distcheck=findDistancefast(&player[0].coords,&player[i].coords);
1593 if(distcheck<mapviewdist){
1595 glBindTexture( GL_TEXTURE_2D, Maparrowtexture);
1596 if(i==0)glColor4f(1,1,1,opac);
1597 else if(player[i].dead==2||player[i].howactive>typesleeping)glColor4f(0,0,0,opac*(1-distcheck/mapviewdist));
1598 else if(player[i].dead)glColor4f(.3,.3,.3,opac*(1-distcheck/mapviewdist));
1599 else if(player[i].aitype==attacktypecutoff)glColor4f(1,0,0,opac*(1-distcheck/mapviewdist));
1600 else if(player[i].aitype==passivetype)glColor4f(0,1,0,opac*(1-distcheck/mapviewdist));
1601 else glColor4f(1,1,0,1);
1602 glTranslatef(player[i].coords.x/terrain.scale/256*-2+1,player[i].coords.z/terrain.scale/256*2-1,0);
1603 glRotatef(player[i].rotation+180,0,0,1);
1604 glScalef(.005,.005,.005);
1607 glVertex3f(-1, -1, 0.0f);
1609 glVertex3f(1, -1, 0.0f);
1611 glVertex3f(1, 1, 0.0f);
1613 glVertex3f(-1, 1, 0.0f);
1615 /*glBegin(GL_TRIANGLES);
1617 glVertex3f(-1, -1, 0.0f);
1619 glVertex3f(1, -1, 0.0f);
1621 glVertex3f(0, 1, 0.0f);
1626 /*glBegin(GL_QUADS);
1628 glVertex3f(-1, -1, 0.0f);
1630 glVertex3f(1, -1, 0.0f);
1632 glVertex3f(1, 1, 0.0f);
1634 glVertex3f(-1, 1, 0.0f);
1637 glDisable(GL_TEXTURE_2D);
1638 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1639 glPopMatrix(); // Restore The Old Projection Matrix
1640 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1641 glPopMatrix(); // Restore The Old Projection Matrix
1642 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1643 glEnable(GL_CULL_FACE);
1644 glDisable(GL_BLEND);
1650 drawmode=normalmode;
1654 if(loading&&!stealthloading&&(!campaign||player[0].dead)){
1655 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1656 glDisable(GL_CULL_FACE);
1657 glDisable(GL_LIGHTING);
1658 glDisable(GL_TEXTURE_2D);
1660 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1661 glPushMatrix(); // Store The Projection Matrix
1662 glLoadIdentity(); // Reset The Projection Matrix
1663 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1664 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1665 glPushMatrix(); // Store The Modelview Matrix
1666 glLoadIdentity(); // Reset The Modelview Matrix
1667 glScalef(screenwidth,screenheight,1);
1668 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1670 glColor4f(0,0,0,.7);
1672 glVertex3f(0, 0, 0.0f);
1673 glVertex3f(256, 0, 0.0f);
1674 glVertex3f(256, 256, 0.0f);
1675 glVertex3f(0, 256, 0.0f);
1677 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1678 glPopMatrix(); // Restore The Old Projection Matrix
1679 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1680 glPopMatrix(); // Restore The Old Projection Matrix
1681 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1682 glEnable(GL_CULL_FACE);
1683 glDisable(GL_BLEND);
1687 glDisable(GL_DEPTH_TEST);
1688 glColor3f (1.0, 1.0, 1.0); // no coloring
1690 glEnable(GL_TEXTURE_2D);
1691 /*glBindTexture( GL_TEXTURE_2D, logotexture);
1692 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1693 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1694 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1695 glDisable(GL_CULL_FACE);
1696 glDisable(GL_LIGHTING);
1698 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1699 glPushMatrix(); // Store The Projection Matrix
1700 glLoadIdentity(); // Reset The Projection Matrix
1701 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1702 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1703 glPushMatrix(); // Store The Modelview Matrix
1704 glLoadIdentity(); // Reset The Modelview Matrix
1705 glScalef((float)screenwidth/2,(float)screenwidth/2,1);
1706 glTranslatef(1.8,1.25,0);
1707 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1711 glScalef(.25,.25,.25);
1714 glVertex3f(-1, -1, 0.0f);
1716 glVertex3f(1, -1, 0.0f);
1718 glVertex3f(1, 1, 0.0f);
1720 glVertex3f(-1, 1, 0.0f);
1723 glDisable(GL_TEXTURE_2D);
1724 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1725 glPopMatrix(); // Restore The Old Projection Matrix
1726 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1727 glPopMatrix(); // Restore The Old Projection Matrix
1728 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1729 glEnable(GL_CULL_FACE);
1730 glDisable(GL_BLEND);
1736 glEnable(GL_TEXTURE_2D);
1738 sprintf (string, "Loading...");
1739 text.glPrint(1024/2-90,768/2,string,1,2,1024,768);
1742 //if(ismotionblur)drawmode=motionblurmode;
1743 drawmode=normalmode;
1746 if(winfreeze&&!campaign){
1747 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1748 glDisable(GL_CULL_FACE);
1749 glDisable(GL_LIGHTING);
1750 glDisable(GL_TEXTURE_2D);
1752 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1753 glPushMatrix(); // Store The Projection Matrix
1754 glLoadIdentity(); // Reset The Projection Matrix
1755 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1756 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1757 glPushMatrix(); // Store The Modelview Matrix
1758 glLoadIdentity(); // Reset The Modelview Matrix
1759 glScalef(screenwidth,screenheight,1);
1760 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1762 glColor4f(0,0,0,.4);
1764 glVertex3f(0, 0, 0.0f);
1765 glVertex3f(256, 0, 0.0f);
1766 glVertex3f(256, 256, 0.0f);
1767 glVertex3f(0, 256, 0.0f);
1769 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1770 glPopMatrix(); // Restore The Old Projection Matrix
1771 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1772 glPopMatrix(); // Restore The Old Projection Matrix
1773 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1774 glEnable(GL_CULL_FACE);
1775 glDisable(GL_BLEND);
1779 glDisable(GL_DEPTH_TEST);
1780 glColor3f (1.0, 1.0, 1.0); // no coloring
1782 glEnable(GL_TEXTURE_2D);
1783 /*glBindTexture( GL_TEXTURE_2D, logotexture);
1784 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1785 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1786 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1787 glDisable(GL_CULL_FACE);
1788 glDisable(GL_LIGHTING);
1790 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1791 glPushMatrix(); // Store The Projection Matrix
1792 glLoadIdentity(); // Reset The Projection Matrix
1793 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1794 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1795 glPushMatrix(); // Store The Modelview Matrix
1796 glLoadIdentity(); // Reset The Modelview Matrix
1797 glScalef((float)screenwidth/2,(float)screenwidth/2,1);
1798 glTranslatef(1.8,1.25,0);
1799 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1803 glScalef(.25,.25,.25);
1806 glVertex3f(-1, -1, 0.0f);
1808 glVertex3f(1, -1, 0.0f);
1810 glVertex3f(1, 1, 0.0f);
1812 glVertex3f(-1, 1, 0.0f);
1815 glDisable(GL_TEXTURE_2D);
1816 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1817 glPopMatrix(); // Restore The Old Projection Matrix
1818 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1819 glPopMatrix(); // Restore The Old Projection Matrix
1820 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1821 glEnable(GL_CULL_FACE);
1822 glDisable(GL_BLEND);
1830 if(damagetaken==0&&player[0].bloodloss==0){
1831 awards[numawards]=awardflawless;
1837 for(i=1;i<numplayers;i++){
1838 if(player[i].dead!=2)alldead=0;
1841 awards[numawards]=awardalldead;
1846 for(i=1;i<numplayers;i++){
1847 if(player[i].dead!=1)alldead=0;
1850 awards[numawards]=awardnodead;
1853 if(numresponded==0&&!numthrowkill){
1854 awards[numawards]=awardstealth;
1857 if(numattacks==numstaffattack&&numattacks>0){
1858 awards[numawards]=awardbojutsu;
1861 if(numattacks==numswordattack&&numattacks>0){
1862 awards[numawards]=awardswordsman;
1865 if(numattacks==numknifeattack&&numattacks>0){
1866 awards[numawards]=awardknifefighter;
1869 if(numattacks==numunarmedattack&&numthrowkill==0&&weapons.numweapons>0){
1870 awards[numawards]=awardkungfu;
1874 awards[numawards]=awardevasion;
1877 if(numflipfail==0&&numflipped+numwallflipped*2>20){
1878 awards[numawards]=awardacrobat;
1881 if(numthrowkill==numplayers-1){
1882 awards[numawards]=awardlongrange;
1887 for(i=1;i<numplayers;i++){
1888 if(player[i].dead!=2)alldead=0;
1890 if(numafterkill>0&&alldead){
1891 awards[numawards]=awardbrutal;
1894 if(numreversals>((float)numattacks)*.8&&numreversals>3){
1895 awards[numawards]=awardaikido;
1898 if(maxalarmed==1&&numplayers>2){
1899 awards[numawards]=awardstrategy;
1903 awards[numawards]=awardklutz;
1908 //Win Screen Won Victory
1910 glEnable(GL_TEXTURE_2D);
1912 sprintf (string, "Level Cleared!");
1913 text.glPrintOutlined(1024/2-strlen(string)*10,768*7/8,string,1,2,1024,768);
1915 sprintf (string, "Score: %d",(int)(bonustotal-startbonustotal));
1916 text.glPrintOutlined(1024/30,768*6/8,string,1,2,1024,768);
1918 if(!campaign)sprintf (string, "Press Escape to return to menu or Space to continue");
1919 if(campaign)sprintf (string, "Press Escape or Space to continue");
1920 text.glPrintOutlined(640/2-strlen(string)*5,480*1/16,string,1,1,640,480);
1924 for(i=0;i<255;i++)string[i]='\0';
1925 sprintf (temp, "Time: %d:",(int)(((int)leveltime-(int)(leveltime)%60)/60));
1926 strcat(string,temp);
1927 if((int)(leveltime)%60<10)strcat(string,"0");
1928 sprintf (temp, "%d",(int)(leveltime)%60);
1929 strcat(string,temp);
1930 text.glPrintOutlined(1024/30,768*6/8-40,string,1,2,1024,768);
1932 for(i=0;i<numawards;i++){
1934 if(awards[i]==awardklutz)sprintf (string, "Suicidal");
1935 if(awards[i]==awardflawless)sprintf (string, "Flawless!");
1936 if(awards[i]==awardalldead)sprintf (string, "Take no prisoners");
1937 if(awards[i]==awardnodead)sprintf (string, "Merciful");
1938 if(awards[i]==awardstealth)sprintf (string, "One with the shadows!");
1939 if(awards[i]==awardswordsman)sprintf (string, "Swordsman");
1940 if(awards[i]==awardkungfu)sprintf (string, "Unarmed!");
1941 if(awards[i]==awardknifefighter)sprintf (string, "Knife fighter");
1942 if(awards[i]==awardcoward)sprintf (string, "Coward");
1943 if(awards[i]==awardevasion)sprintf (string, "Escape artist");
1944 if(awards[i]==awardacrobat)sprintf (string, "Gymnast");
1945 if(awards[i]==awardlongrange)sprintf (string, "Blade slinger");
1946 if(awards[i]==awardbrutal)sprintf (string, "Brutal");
1947 if(awards[i]==awardhyper)sprintf (string, "Hyper");
1948 if(awards[i]==awardaikido)sprintf (string, "Aikido master!");
1949 if(awards[i]==awardrambo)sprintf (string, "Rambo");
1950 if(awards[i]==awardfast)sprintf (string, "Fast");
1951 if(awards[i]==awardrealfast)sprintf (string, "Real fast");
1952 if(awards[i]==awarddamnfast)sprintf (string, "Damn fast");
1953 if(awards[i]==awardstrategy)sprintf (string, "Divide and conquer");
1954 if(awards[i]==awardbojutsu)sprintf (string, "Bojutsu");
1955 text.glPrintOutlined(1024/30,768*6/8-90-40*i,string,1,2,1024,768);
1959 //drawmode=normalmode;
1962 if(drawmode!=normalmode){
1963 glEnable(GL_TEXTURE_2D);
1965 if(!drawtoggle||drawmode!=realmotionblurmode||(drawtoggle==2||change==1)){
1968 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
1969 GLfloat subtractColor[4] = { 0.5, 0.5, 0.5, 0.0 };
1970 glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, subtractColor);
1971 //glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_SUBTRACT);
1972 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE);
1973 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_CONSTANT_EXT);
1974 glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 2.0f);
1976 glBindTexture( GL_TEXTURE_2D, screentexture);
1977 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1980 if((drawtoggle||change==1)&&drawmode==realmotionblurmode){
1982 glBindTexture( GL_TEXTURE_2D, screentexture2);
1983 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1985 if(!screentexture2){
1986 glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
1988 glGenTextures( 1, &screentexture2 );
1989 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
1991 glEnable(GL_TEXTURE_2D);
1992 glBindTexture( GL_TEXTURE_2D, screentexture2);
1993 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
1994 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
1996 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
2002 glClear(GL_DEPTH_BUFFER_BIT);
2003 ReSizeGLScene(90,.1f);
2004 glViewport(0,0,screenwidth,screenheight);
2006 if(drawmode!=normalmode){
2007 glDisable(GL_DEPTH_TEST);
2008 if(drawmode==motionblurmode){
2009 glDrawBuffer(GL_FRONT);
2010 glReadBuffer(GL_BACK);
2011 //myassert(glGetError() == GL_NO_ERROR);
2014 glColor3f (1.0, 1.0, 1.0); // no coloring
2016 glEnable(GL_TEXTURE_2D);
2017 glBindTexture( GL_TEXTURE_2D, screentexture);
2018 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
2019 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
2020 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
2021 glDisable(GL_CULL_FACE);
2022 glDisable(GL_LIGHTING);
2024 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2025 glPushMatrix(); // Store The Projection Matrix
2026 glLoadIdentity(); // Reset The Projection Matrix
2027 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
2028 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2029 glPushMatrix(); // Store The Modelview Matrix
2030 glLoadIdentity(); // Reset The Modelview Matrix
2031 glScalef((float)screenwidth/2,(float)screenheight/2,1);
2032 glTranslatef(1,1,0);
2033 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
2035 if(drawmode==motionblurmode){
2036 if(motionbluramount<.2)motionbluramount=.2;
2037 //glColor4f(1,1,1,fast_sqrt(multiplier)*2.9*motionbluramount);
2038 glColor4f(1,1,1,motionbluramount);
2042 glVertex3f(-1, -1, 0.0f);
2043 glTexCoord2f(texcoordwidth,0);
2044 glVertex3f(1, -1, 0.0f);
2045 glTexCoord2f(texcoordwidth,texcoordheight);
2046 glVertex3f(1, 1, 0.0f);
2047 glTexCoord2f(0,texcoordheight);
2048 glVertex3f(-1, 1, 0.0f);
2052 if(drawmode==realmotionblurmode){
2053 glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
2054 glClear(GL_COLOR_BUFFER_BIT);
2055 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
2056 glBindTexture( GL_TEXTURE_2D, screentexture);
2057 glColor4f(1,1,1,.5);
2061 glVertex3f(-1, -1, 0.0f);
2062 glTexCoord2f(texcoordwidth,0);
2063 glVertex3f(1, -1, 0.0f);
2064 glTexCoord2f(texcoordwidth,texcoordheight);
2065 glVertex3f(1, 1, 0.0f);
2066 glTexCoord2f(0,texcoordheight);
2067 glVertex3f(-1, 1, 0.0f);
2070 glBindTexture( GL_TEXTURE_2D, screentexture2);
2071 glColor4f(1,1,1,.5);
2075 glVertex3f(-1, -1, 0.0f);
2076 glTexCoord2f(texcoordwidth,0);
2077 glVertex3f(1, -1, 0.0f);
2078 glTexCoord2f(texcoordwidth,texcoordheight);
2079 glVertex3f(1, 1, 0.0f);
2080 glTexCoord2f(0,texcoordheight);
2081 glVertex3f(-1, 1, 0.0f);
2084 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
2086 if(drawmode==doublevisionmode){
2087 static float crosseyedness;
2088 crosseyedness=abs(player[0].damage-player[0].superpermanentdamage-(player[0].damagetolerance-player[0].superpermanentdamage)*1/2)/30;
2089 if(crosseyedness>1)crosseyedness=1;
2090 if(crosseyedness<0)crosseyedness=0;
2092 glDisable(GL_BLEND);
2097 glVertex3f(-1, -1, 0.0f);
2098 glTexCoord2f(texcoordwidth,0);
2099 glVertex3f(1, -1, 0.0f);
2100 glTexCoord2f(texcoordwidth,texcoordheight);
2101 glVertex3f(1, 1, 0.0f);
2102 glTexCoord2f(0,texcoordheight);
2103 glVertex3f(-1, 1, 0.0f);
2107 glColor4f(1,1,1,.5);
2110 glTranslatef(.015*crosseyedness,0,0);
2114 glVertex3f(-1, -1, 0.0f);
2115 glTexCoord2f(texcoordwidth,0);
2116 glVertex3f(1, -1, 0.0f);
2117 glTexCoord2f(texcoordwidth,texcoordheight);
2118 glVertex3f(1, 1, 0.0f);
2119 glTexCoord2f(0,texcoordheight);
2120 glVertex3f(-1, 1, 0.0f);
2125 if(drawmode==glowmode){
2126 glColor4f(.5,.5,.5,.5);
2128 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
2130 glTranslatef(.01,0,0);
2133 glVertex3f(-1, -1, 0.0f);
2134 glTexCoord2f(texcoordwidth,0);
2135 glVertex3f(1, -1, 0.0f);
2136 glTexCoord2f(texcoordwidth,texcoordheight);
2137 glVertex3f(1, 1, 0.0f);
2138 glTexCoord2f(0,texcoordheight);
2139 glVertex3f(-1, 1, 0.0f);
2143 glTranslatef(-.01,0,0);
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);
2156 glTranslatef(.0,.01,0);
2159 glVertex3f(-1, -1, 0.0f);
2160 glTexCoord2f(texcoordwidth,0);
2161 glVertex3f(1, -1, 0.0f);
2162 glTexCoord2f(texcoordwidth,texcoordheight);
2163 glVertex3f(1, 1, 0.0f);
2164 glTexCoord2f(0,texcoordheight);
2165 glVertex3f(-1, 1, 0.0f);
2169 glTranslatef(0,-.01,0);
2172 glVertex3f(-1, -1, 0.0f);
2173 glTexCoord2f(texcoordwidth,0);
2174 glVertex3f(1, -1, 0.0f);
2175 glTexCoord2f(texcoordwidth,texcoordheight);
2176 glVertex3f(1, 1, 0.0f);
2177 glTexCoord2f(0,texcoordheight);
2178 glVertex3f(-1, 1, 0.0f);
2182 if(drawmode==radialzoommode){
2184 //glRotatef((float)i*.1,0,0,1);
2185 glColor4f(1,1,1,1/((float)i+1));
2187 glScalef(1+(float)i*.01,1+(float)i*.01,1);
2190 glVertex3f(-1, -1, 0.0f);
2191 glTexCoord2f(texcoordwidth,0);
2192 glVertex3f(1, -1, 0.0f);
2193 glTexCoord2f(texcoordwidth,texcoordheight);
2194 glVertex3f(1, 1, 0.0f);
2195 glTexCoord2f(0,texcoordheight);
2196 glVertex3f(-1, 1, 0.0f);
2201 glDisable(GL_TEXTURE_2D);
2202 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2203 glPopMatrix(); // Restore The Old Projection Matrix
2204 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2205 glPopMatrix(); // Restore The Old Projection Matrix
2206 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
2207 glEnable(GL_CULL_FACE);
2208 glDisable(GL_BLEND);
2213 glEnable(GL_TEXTURE_2D);
2218 if(consoleselected>=60)offset=consoleselected-60;
2219 sprintf (string, " ]");
2220 text.glPrint(10,30,string,0,1,1024,768);
2222 sprintf (string, "_");
2223 text.glPrint(30+(float)(consoleselected)*10-offset*10,30,string,0,1,1024,768);
2226 for(j=0;j<consolechars[i];j++){
2227 glColor4f(1,1,1,1-(float)(i)/16);
2228 if(j<consolechars[i]){
2229 sprintf (string, "%c",consoletext[i][j]);
2230 text.glPrint(30+j*10-offset*10,30+i*20,string,0,1,1024,768);
2238 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)||(mainmenu&&gameon)||(!gameon&&gamestarted)||(!gameon&&gamestarted)){
2239 multiplier=tempmult;
2244 // !!! FIXME: hack: clamp framerate in menu so text input works correctly on fast systems.
2247 glDrawBuffer(GL_BACK);
2248 glReadBuffer(GL_BACK);
2249 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
2250 ReSizeGLScene(90,.1f);
2253 temptexdetail=texdetail;
2254 if(texdetail>2)texdetail=2;
2255 if(mainmenu!=oldmainmenu&&oldmainmenu!=0){
2257 LoadTexture(":Data:Textures:Newgame.png",&Mainmenuitems[1],0,0);
2258 LoadTexture(":Data:Textures:Quit.png",&Mainmenuitems[3],0,0);
2259 /*if(oldmainmenu==1||oldmainmenu==0){
2260 LoadTexture(":Data:Textures:World.png",&Mainmenuitems[7],0,0);
2261 LoadTexture(":Data:Textures:Options.png",&Mainmenuitems[2],0,0);
2262 LoadTexture(":Data:Textures:Lugaru.png",&Mainmenuitems[0],0,0);
2267 LoadTexture(":Data:Textures:Resume.png",&Mainmenuitems[1],0,0);
2268 LoadTexture(":Data:Textures:Endgame.png",&Mainmenuitems[3],0,0);
2269 /*if(oldmainmenu==2||oldmainmenu==0){
2270 LoadTexture(":Data:Textures:World.png",&Mainmenuitems[7],0,0);
2271 LoadTexture(":Data:Textures:Options.png",&Mainmenuitems[2],0,0);
2272 LoadTexture(":Data:Textures:Lugaru.png",&Mainmenuitems[0],0,0);
2277 if(lastcheck>.5||oldmainmenu!=mainmenu){
2279 ifstream ipstream(ConvertFileName(":Data:Campaigns:main.txt"));
2280 //campaignnumlevels=0;
2281 //accountcampaignchoicesmade[accountactive]=0;
2282 ipstream.ignore(256,':');
2283 ipstream >> campaignnumlevels;
2284 for(i=0;i<campaignnumlevels;i++){
2285 ipstream.ignore(256,':');
2286 ipstream.ignore(256,':');
2287 ipstream.ignore(256,' ');
2288 ipstream >> campaignmapname[i];
2289 ipstream.ignore(256,':');
2290 ipstream >> campaigndescription[i];
2292 if(campaigndescription[i][j]=='_')campaigndescription[i][j]=' ';
2294 ipstream.ignore(256,':');
2295 ipstream >> campaignchoosenext[i];
2296 ipstream.ignore(256,':');
2297 ipstream >> campaignnumnext[i];
2298 if(campaignnumnext[i])
2299 for(j=0;j<campaignnumnext[i];j++){
2300 ipstream.ignore(256,':');
2301 ipstream >> campaignnextlevel[i][j];
2302 campaignnextlevel[i][j]-=1;
2304 ipstream.ignore(256,':');
2305 ipstream >> campaignlocationx[i];
2306 //campaignlocationx[i]-=30;
2307 ipstream.ignore(256,':');
2308 ipstream >> campaignlocationy[i];
2309 //campaignlocationy[i]+=30;
2313 for(i=0;i<campaignnumlevels;i++){
2315 levelhighlight[i]=0;
2320 if(accountcampaignchoicesmade[accountactive])
2321 for(i=0;i<accountcampaignchoicesmade[accountactive];i++){
2322 levelorder[i+1]=campaignnextlevel[levelorder[i]][accountcampaignchoices[accountactive][i]];
2323 levelvisible[levelorder[i+1]]=1;
2325 int whichlevelstart;
2326 whichlevelstart=accountcampaignchoicesmade[accountactive]-1;
2327 if(whichlevelstart<0){
2328 accountcampaignscore[accountactive]=0;
2329 accountcampaignfasttime[accountactive]=0;
2330 campaignchoicenum=1;
2331 campaignchoicewhich[0]=0;
2335 campaignchoicenum=campaignnumnext[levelorder[whichlevelstart]];
2336 if(campaignchoicenum==0){
2337 if(accountcampaignscore[accountactive]>accountcampaignhighscore[accountactive])accountcampaignhighscore[accountactive]=accountcampaignscore[accountactive];
2338 if(accountcampaignfasttime[accountactive]==0||accountcampaigntime[accountactive]<accountcampaignfasttime[accountactive])accountcampaignfasttime[accountactive]=accountcampaigntime[accountactive];
2340 if(campaignchoicenum)
2341 for(i=0;i<campaignchoicenum;i++){
2342 campaignchoicewhich[i]=campaignnextlevel[levelorder[whichlevelstart]][i];
2343 levelvisible[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
2344 levelhighlight[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
2357 texdetail=temptexdetail;
2359 /*if(mainmenu!=0)*/oldmainmenu=mainmenu;
2361 if(mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==8||mainmenu==9||mainmenu==10||mainmenu==119||mainmenu==12||mainmenu==13||mainmenu==14||mainmenu==15||mainmenu==16||mainmenu==17){
2362 glClear(GL_DEPTH_BUFFER_BIT);
2363 glEnable(GL_ALPHA_TEST);
2364 glAlphaFunc(GL_GREATER, 0.001f);
2365 glEnable(GL_TEXTURE_2D);
2366 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
2367 glDisable(GL_CULL_FACE);
2368 glDisable(GL_LIGHTING);
2370 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2371 glPushMatrix(); // Store The Projection Matrix
2372 glLoadIdentity(); // Reset The Projection Matrix
2373 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
2374 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2375 glPushMatrix(); // Store The Modelview Matrix
2376 glLoadIdentity(); // Reset The Modelview Matrix
2377 glTranslatef(screenwidth/2,screenheight/2,0);
2379 glScalef((float)screenwidth/2,(float)screenheight/2,1);
2380 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
2381 glDisable(GL_BLEND);
2382 glColor4f(0,0,0,1.0);
2383 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2384 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2385 glDisable(GL_TEXTURE_2D);
2387 //glScalef(.25,.25,.25);
2390 glVertex3f(-1, -1, 0.0f);
2392 glVertex3f(1, -1, 0.0f);
2394 glVertex3f(1, 1, 0.0f);
2396 glVertex3f(-1, 1, 0.0f);
2400 glColor4f(0.4,0.4,0.4,1.0);
2401 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2402 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2403 glEnable(GL_TEXTURE_2D);
2404 glBindTexture( GL_TEXTURE_2D, Mainmenuitems[4]);
2406 //glScalef(.25,.25,.25);
2409 glVertex3f(-1, -1, 0.0f);
2411 glVertex3f(1, -1, 0.0f);
2413 glVertex3f(1, 1, 0.0f);
2415 glVertex3f(-1, 1, 0.0f);
2420 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2422 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2426 if((float)newscreenwidth>(float)newscreenheight*1.61||(float)newscreenwidth<(float)newscreenheight*1.59)sprintf (menustring[0], "Resolution: %d*%d",(int)newscreenwidth,(int)newscreenheight);
2427 else sprintf (menustring[0], "Resolution: %d*%d (widescreen)",(int)newscreenwidth,(int)newscreenheight);
2430 endx[0]=startx[0]+strlen(menustring[0])*10;
2431 endy[0]=starty[0]+20;
2435 if(newdetail==2)sprintf (menustring[1], "Detail: High");
2436 else if(newdetail==1)sprintf (menustring[1], "Detail: Medium");
2437 else sprintf (menustring[1], "Detail: Low");
2440 endx[1]=startx[1]+strlen(menustring[1])*10;
2441 endy[1]=starty[1]+20;
2445 if(bloodtoggle==2)sprintf (menustring[2], "Blood: On, high detail (slower)");
2446 if(bloodtoggle==1)sprintf (menustring[2], "Blood: On, low detail");
2447 if(bloodtoggle==0)sprintf (menustring[2], "Blood: Off");
2450 endx[2]=startx[2]+strlen(menustring[2])*10;
2451 endy[2]=starty[2]+20;
2455 if(difficulty==2)sprintf (menustring[3], "Difficulty: Insane");
2456 if(difficulty==1)sprintf (menustring[3], "Difficulty: Difficult");
2457 if(difficulty==0)sprintf (menustring[3], "Difficulty: Easier");
2458 startx[3]=10+20-1000;
2460 endx[3]=startx[3]+strlen(menustring[3])*10;
2461 endy[3]=starty[3]+20;
2465 if(ismotionblur==1)sprintf (menustring[4], "Blur Effects: Enabled (less compatible)");
2466 if(ismotionblur==0)sprintf (menustring[4], "Blur Effects: Disabled (more compatible)");
2469 endx[4]=startx[4]+strlen(menustring[4])*10;
2470 endy[4]=starty[4]+20;
2474 if(decals==1)sprintf (menustring[5], "Decals: Enabled (slower)");
2475 if(decals==0)sprintf (menustring[5], "Decals: Disabled");
2478 endx[5]=startx[5]+strlen(menustring[5])*10;
2479 endy[5]=starty[5]+20;
2483 if(musictoggle==1)sprintf (menustring[6], "Music: Enabled");
2484 if(musictoggle==0)sprintf (menustring[6], "Music: Disabled");
2487 endx[6]=startx[6]+strlen(menustring[6])*10;
2488 endy[6]=starty[6]+20;
2492 if(invertmouse==1)sprintf (menustring[9], "Invert mouse: Yes");
2493 if(invertmouse==0)sprintf (menustring[9], "Invert mouse: No");
2496 endx[9]=startx[9]+strlen(menustring[9])*10;
2497 endy[9]=starty[9]+20;
2501 sprintf (menustring[10], "Mouse Speed: %d", (int)(usermousesensitivity*5));
2504 endx[10]=startx[10]+strlen(menustring[10])*10;
2505 endy[10]=starty[10]+20;
2509 sprintf (menustring[11], "Volume: %d%", (int)(volume*100));
2512 endx[11]=startx[11]+strlen(menustring[11])*10;
2513 endy[11]=starty[11]+20;
2517 sprintf (menustring[7], "-Configure Controls-");
2520 endx[7]=startx[7]+strlen(menustring[7])*10;
2521 endy[7]=starty[7]+20;
2525 if(newdetail==detail&&newscreenheight==(int)screenheight&&newscreenwidth==(int)screenwidth)sprintf (menustring[8], "Back");
2526 else sprintf (menustring[8], "Back (some changes take effect next time Lugaru is opened)");
2528 endx[8]=startx[8]+strlen(menustring[8])*10;
2530 endy[8]=starty[8]+20;
2537 if(keyselect!=0)sprintf (menustring[0], "Forwards: %s",KeyToChar(forwardkey));
2538 else sprintf (menustring[0], "Forwards: _");
2541 endx[0]=startx[0]+strlen(menustring[0])*10;
2542 endy[0]=starty[0]+20;
2546 if(keyselect!=1)sprintf (menustring[1], "Back: %s",KeyToChar(backkey));
2547 else sprintf (menustring[1], "Back: _");
2550 endx[1]=startx[1]+strlen(menustring[1])*10;
2551 endy[1]=starty[1]+20;
2555 if(keyselect!=2)sprintf (menustring[2], "Left: %s",KeyToChar(leftkey));
2556 else sprintf (menustring[2], "Left: _");
2559 endx[2]=startx[2]+strlen(menustring[2])*10;
2560 endy[2]=starty[2]+20;
2564 if(keyselect!=3)sprintf (menustring[3], "Right: %s",KeyToChar(rightkey));
2565 else sprintf (menustring[3], "Right: _");
2568 endx[3]=startx[3]+strlen(menustring[3])*10;
2569 endy[3]=starty[3]+20;
2573 if(keyselect!=4)sprintf (menustring[4], "Crouch: %s",KeyToChar(crouchkey));
2574 else sprintf (menustring[4], "Crouch: _");
2577 endx[4]=startx[4]+strlen(menustring[4])*10;
2578 endy[4]=starty[4]+20;
2582 if(keyselect!=5)sprintf (menustring[5], "Jump: %s",KeyToChar(jumpkey));
2583 else sprintf (menustring[5], "Jump: _");
2586 endx[5]=startx[5]+strlen(menustring[5])*10;
2587 endy[5]=starty[5]+20;
2591 if(keyselect!=6)sprintf (menustring[6], "Draw: %s",KeyToChar(drawkey));
2592 else sprintf (menustring[6], "Draw: _");
2595 endx[6]=startx[6]+strlen(menustring[6])*10;
2596 endy[6]=starty[6]+20;
2600 if(keyselect!=7)sprintf (menustring[7], "Throw: %s",KeyToChar(throwkey));
2601 else sprintf (menustring[7], "Throw: _");
2604 endx[7]=startx[7]+strlen(menustring[7])*10;
2605 endy[7]=starty[7]+20;
2609 if(keyselect!=8)sprintf (menustring[8], "Attack: %s",KeyToChar(attackkey));
2610 else sprintf (menustring[8], "Attack: _");
2613 endx[8]=startx[8]+strlen(menustring[8])*10;
2614 endy[8]=starty[8]+20;
2620 sprintf (menustring[9], "Back");
2622 endx[9]=startx[9]+strlen(menustring[9])*10;
2624 endy[9]=starty[9]+20;
2629 nummenuitems=7+accountcampaignchoicesmade[accountactive]+campaignchoicenum;
2631 sprintf (menustring[0], "%s",accountname[accountactive]);
2634 endx[0]=startx[0]+strlen(menustring[0])*10;
2635 endy[0]=starty[0]+20;
2639 sprintf (menustring[1], "Tutorial");
2642 endx[1]=startx[1]+strlen(menustring[1])*10;
2643 endy[1]=starty[1]+20;
2647 sprintf (menustring[2], "Challenge");
2650 endx[2]=startx[2]+strlen(menustring[2])*10;
2651 endy[2]=starty[2]+20;
2655 sprintf (menustring[3], "Delete User");
2658 endx[3]=startx[3]+strlen(menustring[3])*10;
2659 endy[3]=starty[3]+20;
2663 sprintf (menustring[4], "Main Menu");
2666 endx[4]=startx[4]+strlen(menustring[4])*10;
2667 endy[4]=starty[4]+20;
2671 sprintf (menustring[5], "Change User");
2673 endx[5]=startx[5]+strlen(menustring[5])*10;
2675 endy[5]=starty[5]+20;
2681 sprintf (menustring[6], "World");
2683 starty[6]=30+480-400-50;
2684 endx[6]=startx[6]+400;
2689 if(accountcampaignchoicesmade[accountactive])
2690 for(i=0;i<accountcampaignchoicesmade[accountactive];i++){
2691 sprintf (menustring[7+i], campaigndescription[levelorder[i]]);
2692 startx[7+i]=30+120+campaignlocationx[levelorder[i]]*400/512;
2693 starty[7+i]=30+30+(512-campaignlocationy[levelorder[i]])*400/512;
2694 endx[7+i]=startx[7+i]+10;
2695 endy[7+i]=starty[7+i]+10;
2700 if(campaignchoicenum>0)
2701 for(i=accountcampaignchoicesmade[accountactive];i<accountcampaignchoicesmade[accountactive]+campaignchoicenum;i++){
2702 sprintf (menustring[7+i], campaigndescription[levelorder[i]]);
2703 startx[7+i]=30+120+campaignlocationx[campaignchoicewhich[i-(accountcampaignchoicesmade[accountactive])]]*400/512;
2704 starty[7+i]=30+30+(512-campaignlocationy[campaignchoicewhich[i-(accountcampaignchoicesmade[accountactive])]])*400/512;
2705 endx[7+i]=startx[7+i]+10;
2706 endy[7+i]=starty[7+i]+10;
2711 /*sprintf (menustring[7], "Dot");
2712 startx[7]=120+260*400/512;
2713 starty[7]=30+(512-184)*400/512;
2714 endx[7]=startx[7]+10;
2715 endy[7]=starty[7]+10;
2719 sprintf (menustring[8], "Dot");
2720 startx[8]=120+129*400/512;
2721 starty[8]=30+(512-284)*400/512;
2722 endx[8]=startx[8]+10;
2723 endy[8]=starty[8]+10;
2727 sprintf (menustring[9], "Dot");
2728 startx[9]=120+358*400/512;
2729 starty[9]=30+(512-235)*400/512;
2730 endx[9]=startx[9]+10;
2731 endy[9]=starty[9]+10;
2735 sprintf (menustring[10], "Dot");
2736 startx[10]=120+359*400/512;
2737 starty[10]=30+(512-308)*400/512;
2738 endx[10]=startx[10]+10;
2739 endy[10]=starty[10]+10;
2743 sprintf (menustring[11], "Dot");
2744 startx[11]=120+288*400/512;
2745 starty[11]=30+(512-277)*400/512;
2746 endx[11]=startx[11]+10;
2747 endy[11]=starty[11]+10;
2755 sprintf (menustring[0], "Are you sure you want to delete this user?");
2758 endx[0]=startx[0]+strlen(menustring[0])*10;
2759 endy[0]=starty[0]+20;
2763 sprintf (menustring[1], "Yes");
2766 endx[1]=startx[1]+strlen(menustring[1])*10;
2767 endy[1]=starty[1]+20;
2771 sprintf (menustring[2], "No");
2774 endx[2]=startx[2]+strlen(menustring[2])*10;
2775 endy[2]=starty[2]+20;
2779 sprintf (menustring[3], "Extra 4");
2782 endx[3]=startx[3]+strlen(menustring[3])*10;
2783 endy[3]=starty[3]+20;
2787 sprintf (menustring[4], "Extra 5");
2790 endx[4]=startx[4]+strlen(menustring[4])*10;
2791 endy[4]=starty[4]+20;
2795 sprintf (menustring[5], "Back");
2797 endx[5]=startx[5]+strlen(menustring[5])*10;
2799 endy[5]=starty[5]+20;
2805 nummenuitems=numaccounts+2;
2810 sprintf (menustring[0], "New User");
2812 sprintf (menustring[0], "No More Users");
2815 endx[0]=startx[0]+strlen(menustring[0])*10;
2816 endy[0]=starty[0]+20;
2820 if(entername)startx[0]+=10;
2825 for(i=0;i<numaccounts;i++){
2826 sprintf (menustring[num], "%s",accountname[i]);
2828 starty[num]=360-20-20*num;
2829 endx[num]=startx[num]+strlen(menustring[num])*10;
2830 endy[num]=starty[num]+20;
2837 sprintf (menustring[num], "Back");
2839 endx[num]=startx[num]+strlen(menustring[num])*10;
2841 endy[num]=starty[num]+20;
2848 sprintf (menustring[0], "Easier");
2851 endx[0]=startx[0]+strlen(menustring[0])*10;
2852 endy[0]=starty[0]+20;
2856 sprintf (menustring[1], "Difficult");
2859 endx[1]=startx[1]+strlen(menustring[1])*10;
2860 endy[1]=starty[1]+20;
2864 sprintf (menustring[2], "Insane");
2867 endx[2]=startx[2]+strlen(menustring[2])*10;
2868 endy[2]=starty[2]+20;
2874 //tempncl=numchallengelevels;
2875 //numchallengelevels=9;
2876 nummenuitems=2+numchallengelevels;
2879 for(j=0;j<numchallengelevels;j++){
2880 for(i=0;i<255;i++)menustring[j][i]='\0';
2881 sprintf (temp, "Level %d",j+1);
2882 strcpy(menustring[j],temp);
2883 for(i=0;i<17;i++)if(menustring[j][i]=='\0')menustring[j][i]=' ';
2884 menustring[j][17]='\0';
2885 sprintf (temp, "%d",(int)accounthighscore[accountactive][j]);
2886 strcat(menustring[j],temp);
2887 for(i=18;i<32;i++)if(menustring[j][i]=='\0')menustring[j][i]=' ';
2888 menustring[j][32]='\0';
2889 sprintf (temp, "%d:",(int)(((int)accountfasttime[accountactive][j]-(int)(accountfasttime[accountactive][j])%60)/60));
2890 strcat(menustring[j],temp);
2891 if((int)(accountfasttime[accountactive][j])%60<10)strcat(menustring[j],"0");
2892 sprintf (temp, "%d",(int)(accountfasttime[accountactive][j])%60);
2893 strcat(menustring[j],temp);
2897 endx[j]=startx[j]+strlen(menustring[j])*10;
2898 endy[j]=starty[j]+20;
2903 sprintf (menustring[numchallengelevels], "Back");
2904 startx[numchallengelevels]=10;
2905 endx[numchallengelevels]=startx[numchallengelevels]+strlen(menustring[numchallengelevels])*10;
2906 starty[numchallengelevels]=10;
2907 endy[numchallengelevels]=starty[numchallengelevels]+20;
2908 movex[numchallengelevels]=0;
2909 movey[numchallengelevels]=0;
2911 sprintf (menustring[numchallengelevels+1], " High Score Best Time");
2912 startx[numchallengelevels+1]=10;
2913 starty[numchallengelevels+1]=440;
2914 endx[numchallengelevels+1]=startx[numchallengelevels+1]+strlen(menustring[numchallengelevels+1])*10;
2915 endy[numchallengelevels+1]=starty[numchallengelevels+1]+20;
2916 movex[numchallengelevels+1]=0;
2917 movey[numchallengelevels+1]=0;
2919 //numchallengelevels=tempncl;
2923 nummenuitems=2+numchallengelevels;
2926 for(j=0;j<numchallengelevels;j++){
2927 for(i=0;i<255;i++)menustring[j][i]='\0';
2928 sprintf (temp, "Level %d",j+1);
2929 strcpy(menustring[j],temp);
2930 for(i=0;i<17;i++)if(menustring[j][i]=='\0')menustring[j][i]=' ';
2931 menustring[j][17]='\0';
2932 sprintf (temp, "%d",(int)accounthighscore[accountactive][j]);
2933 strcat(menustring[j],temp);
2934 for(i=18;i<32;i++)if(menustring[j][i]=='\0')menustring[j][i]=' ';
2935 menustring[j][32]='\0';
2936 sprintf (temp, "%d:",(int)(((int)accountfasttime[accountactive][j]-(int)(accountfasttime[accountactive][j])%60)/60));
2937 strcat(menustring[j],temp);
2938 if((int)(accountfasttime[accountactive][j])%60<10)strcat(menustring[j],"0");
2939 sprintf (temp, "%d",(int)(accountfasttime[accountactive][j])%60);
2940 strcat(menustring[j],temp);
2944 endx[j]=startx[j]+strlen(menustring[j])*10;
2945 endy[j]=starty[j]+20;
2950 sprintf (menustring[numchallengelevels], "Back");
2951 startx[numchallengelevels]=10;
2952 endx[numchallengelevels]=startx[numchallengelevels]+strlen(menustring[numchallengelevels])*10;
2953 starty[numchallengelevels]=10;
2954 endy[numchallengelevels]=starty[numchallengelevels]+20;
2955 movex[numchallengelevels]=0;
2956 movey[numchallengelevels]=0;
2958 sprintf (menustring[numchallengelevels+1], " High Score Best Time");
2959 startx[numchallengelevels+1]=10;
2960 starty[numchallengelevels+1]=400;
2961 endx[numchallengelevels+1]=startx[numchallengelevels+1]+strlen(menustring[numchallengelevels+1])*10;
2962 endy[numchallengelevels+1]=starty[numchallengelevels+1]+20;
2963 movex[numchallengelevels+1]=0;
2964 movey[numchallengelevels+1]=0;
2971 sprintf (menustring[0], "Congratulations!");
2974 endx[0]=startx[0]+strlen(menustring[0])*10;
2975 endy[0]=starty[0]+20;
2979 sprintf (menustring[1], "You have avenged your family and");
2982 endx[1]=startx[1]+strlen(menustring[1])*10;
2983 endy[1]=starty[1]+20;
2987 sprintf (menustring[2], "restored peace to the island of Lugaru.");
2990 endx[2]=startx[2]+strlen(menustring[2])*10;
2991 endy[2]=starty[2]+20;
2995 sprintf (menustring[3], "Back");
2997 endx[3]=startx[3]+strlen(menustring[3])*10;
2999 endy[3]=starty[3]+20;
3003 for(i=0;i<255;i++)menustring[4][i]='\0';
3004 sprintf (temp, "Your score:");
3005 strcpy(menustring[4],temp);
3006 for(i=0;i<20;i++)if(menustring[4][i]=='\0')menustring[4][i]=' ';
3007 menustring[4][20]='\0';
3008 sprintf (temp, "%d",(int)accountcampaignscore[accountactive]);
3009 strcat(menustring[4],temp);
3011 endx[4]=startx[4]+strlen(menustring[4])*10;
3013 endy[4]=starty[4]+20;
3017 for(i=0;i<255;i++)menustring[5][i]='\0';
3018 sprintf (temp, "Your time:");
3019 strcpy(menustring[5],temp);
3020 for(i=0;i<20;i++)if(menustring[5][i]=='\0')menustring[5][i]=' ';
3021 menustring[5][20]='\0';
3022 sprintf (temp, "%d",(int)accountcampaigntime[accountactive]);
3023 strcat(menustring[5],temp);
3025 endx[5]=startx[5]+strlen(menustring[5])*10;
3027 endy[5]=starty[5]+20;
3031 for(i=0;i<255;i++)menustring[5][i]='\0';
3032 sprintf (temp, "Highest score:");
3033 strcpy(menustring[5],temp);
3034 for(i=0;i<20;i++)if(menustring[5][i]=='\0')menustring[5][i]=' ';
3035 menustring[5][20]='\0';
3036 sprintf (temp, "%d",(int)accountcampaignhighscore[accountactive]);
3037 strcat(menustring[5],temp);
3039 endx[5]=startx[5]+strlen(menustring[5])*10;
3041 endy[5]=starty[5]+20;
3045 for(i=0;i<255;i++)menustring[7][i]='\0';
3046 sprintf (temp, "Lowest time:");
3047 strcpy(menustring[7],temp);
3048 for(i=0;i<20;i++)if(menustring[7][i]=='\0')menustring[7][i]=' ';
3049 menustring[7][20]='\0';
3050 sprintf (temp, "%d",(int)accountcampaignfasttime[accountactive]);
3051 strcat(menustring[7],temp);
3053 endx[7]=startx[7]+strlen(menustring[7])*10;
3055 endy[7]=starty[7]+20;
3062 menupulse+=multiplier*2;
3067 sprintf (menustring[0], "Register now for only $19.95!");
3070 endx[0]=startx[0]+strlen(menustring[0])*10;
3071 endy[0]=starty[0]+20;
3075 sprintf (menustring[1], "Confront raiders, wolves, and more!");
3078 endx[1]=startx[1]+strlen(menustring[1])*10;
3079 endy[1]=starty[1]+20;
3083 sprintf (menustring[2], "Fight using swords, staves and armor!");
3086 endx[2]=startx[2]+strlen(menustring[2])*10;
3087 endy[2]=starty[2]+20;
3091 if(!tryquit)sprintf (menustring[3], "Back");
3092 else sprintf (menustring[3], "Quit");
3094 endx[3]=startx[3]+strlen(menustring[3])*10;
3096 endy[3]=starty[3]+20;
3100 sprintf (menustring[4], "Register now!");
3102 endx[4]=startx[4]+strlen(menustring[4])*10;
3104 endy[4]=starty[4]+20;
3108 sprintf (menustring[5], "Enter registration code!");
3110 endx[5]=startx[5]+strlen(menustring[5])*10;
3112 endy[5]=starty[5]+20;
3121 sprintf (menustring[0], "Thank you for supporting Wolfire Software!");
3124 endx[0]=startx[0]+strlen(menustring[0])*10;
3125 endy[0]=starty[0]+20;
3129 sprintf (menustring[1], "Back");
3131 endx[1]=startx[1]+strlen(menustring[1])*10;
3133 endy[1]=starty[1]+20;
3142 sprintf (menustring[0], "Sorry, that name/serial number combination is incorrect.");
3145 endx[0]=startx[0]+strlen(menustring[0])*10;
3146 endy[0]=starty[0]+20;
3150 sprintf (menustring[1], "Back");
3152 endx[1]=startx[1]+strlen(menustring[1])*10;
3154 endy[1]=starty[1]+20;
3158 sprintf (menustring[2], "Please make sure you are copying your name and serial");
3161 endx[2]=startx[2]+strlen(menustring[2])*10;
3162 endy[2]=starty[2]+20;
3166 sprintf (menustring[3], "number exactly as they appear in your email.");
3169 endx[3]=startx[3]+strlen(menustring[3])*10;
3170 endy[3]=starty[3]+20;
3174 sprintf (menustring[4], "Capitalization and punctuation matter!");
3177 endx[4]=startx[4]+strlen(menustring[4])*10;
3178 endy[4]=starty[4]+20;
3187 sprintf (menustring[0], "Please enter your name:");
3190 endx[0]=startx[0]+strlen(menustring[0])*10;
3191 endy[0]=starty[0]+20;
3195 sprintf (menustring[1], "Please enter your name:");
3198 endx[1]=startx[1]+strlen(menustring[1])*10;
3199 endy[1]=starty[1]+20;
3208 sprintf (menustring[0], "Please enter your number:");
3211 endx[0]=startx[0]+strlen(menustring[0])*10;
3212 endy[0]=starty[0]+20;
3216 sprintf (menustring[1], "Please enter your name:");
3219 endx[1]=startx[1]+strlen(menustring[1])*10;
3220 endy[1]=starty[1]+20;
3224 char tempstring[256];
3225 sprintf (tempstring, "%s", registrationname);
3231 longnum = MD5_string ( tempstring);
3232 //longnum = 1111111111111111;
3233 num1 = longnum/100000000;
3234 num2 = longnum%100000000;
3235 sprintf (tempstring, "%d-%d-%d-%d", num1/10000, num1%10000, num2/10000, num2%10000);
3237 sprintf (menustring[2], "%s", tempstring);
3240 endx[2]=startx[2]+strlen(menustring[2])*10;
3241 endy[2]=starty[2]+20;
3246 if(mainmenu==1||mainmenu==2){
3256 starty[1]=480-152-32;
3263 starty[2]=480-228-32;
3271 starty[3]=480-306-32;
3280 starty[3]=480-306-32;
3294 starty[4]=480-140-256;
3301 starty[5]=480-138-256;
3308 starty[6]=480-144-256;
3316 starty[4]=480-140-256;
3323 starty[5]=480-138-256;
3330 starty[6]=480-144-256;
3338 starty[4]=480-140-256;
3345 starty[5]=480-150-256;
3352 starty[6]=480-144-256;
3360 starty[4]=480-140-256;
3367 starty[5]=480-150-256;
3374 starty[6]=480-144-256;
3382 starty[4]=480-100-256;
3389 starty[5]=480-120-256;
3396 starty[6]=480-144-256;
3406 if(mainmenu==1||mainmenu==2)
3408 if((mousecoordh/screenwidth*640)>startx[i]&&(mousecoordh/screenwidth*640)<endx[i]&&480-(mousecoordv/screenheight*480)>starty[i]&&480-(mousecoordv/screenheight*480)<endy[i]){
3413 if(mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==8||mainmenu==9||mainmenu==10||mainmenu==11||mainmenu==12||mainmenu==13||mainmenu==14||mainmenu==15||mainmenu==16||mainmenu==17)
3414 for(i=0;i<nummenuitems;i++){
3415 if((mousecoordh/screenwidth*640)>startx[i]&&(mousecoordh/screenwidth*640)<endx[i]&&480-(mousecoordv/screenheight*480)>starty[i]&&480-(mousecoordv/screenheight*480)<endy[i]){
3416 if(mainmenu!=5)selected=i;
3417 if(mainmenu==5&&(i!=0&&i!=6))selected=i;
3418 if(mainmenu==9&&(i!=numchallengelevels+1))selected=i;
3419 if(mainmenu==11&&(i!=numchallengelevels+1))selected=i;
3424 for(i=0;i<nummenuitems;i++){
3425 if(selected==i)selectedlong[i]+=multiplier*5;
3426 if(selectedlong[i]>1)selectedlong[i]=1;
3427 if(selected!=i)selectedlong[i]-=multiplier*5;
3428 if(selectedlong[i]<0)selectedlong[i]=0;
3429 //if(i>=4)selectedlong[i]=.3;
3430 if(i>=4&&(mainmenu==1||mainmenu==2))selectedlong[i]=0;
3434 for(i=0;i<nummenuitems;i++){
3435 offsetx[i]=(startx[i]+endx[i])/2-(mousecoordh/screenwidth*640);
3436 offsety[i]=(starty[i]+endy[i])/2-(480-(mousecoordv/screenheight*480));
3441 if(i>=4&&(mainmenu==1||mainmenu==2)){
3442 offsetx[i]=(startx[i]+endx[i]+movex[i]*transition)/2-(640+190)/2;
3443 offsety[i]=(starty[i]+endy[i]+movey[i]*transition)/2-(336+150)/2;
3449 if(mainmenu==1||mainmenu==2){
3450 glClear(GL_DEPTH_BUFFER_BIT);
3451 glEnable(GL_ALPHA_TEST);
3452 glAlphaFunc(GL_GREATER, 0.001f);
3453 glEnable(GL_TEXTURE_2D);
3454 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3455 glDisable(GL_CULL_FACE);
3456 glDisable(GL_LIGHTING);
3458 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3459 glPushMatrix(); // Store The Projection Matrix
3460 glLoadIdentity(); // Reset The Projection Matrix
3461 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
3462 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3463 glPushMatrix(); // Store The Modelview Matrix
3464 glLoadIdentity(); // Reset The Modelview Matrix
3465 glTranslatef(screenwidth/2,screenheight/2,0);
3467 glScalef((float)screenwidth/2,(float)screenheight/2,1);
3468 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3469 glDisable(GL_BLEND);
3470 glColor4f(0,0,0,1.0);
3471 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
3472 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
3473 glDisable(GL_TEXTURE_2D);
3475 //glScalef(.25,.25,.25);
3478 glVertex3f(-1, -1, 0.0f);
3480 glVertex3f(1, -1, 0.0f);
3482 glVertex3f(1, 1, 0.0f);
3484 glVertex3f(-1, 1, 0.0f);
3488 glColor4f(0.4,0.4,0.4,1.0);
3489 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
3490 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
3491 glEnable(GL_TEXTURE_2D);
3492 glBindTexture( GL_TEXTURE_2D, Mainmenuitems[4]);
3494 //glScalef(.25,.25,.25);
3497 glVertex3f(-1, -1, 0.0f);
3499 glVertex3f(1, -1, 0.0f);
3501 glVertex3f(1, 1, 0.0f);
3503 glVertex3f(-1, 1, 0.0f);
3508 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3511 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3512 glPushMatrix(); // Store The Projection Matrix
3513 glLoadIdentity(); // Reset The Projection Matrix
3514 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3515 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3516 glPushMatrix(); // Store The Modelview Matrix
3517 glLoadIdentity(); // Reset The Modelview Matrix
3519 glDisable(GL_TEXTURE_2D);
3524 if(anim!=1)glVertex3f(190, 150, 0.0f);
3525 if(anim==1)glVertex3f(190+movex[4]*transition, 150, 0.0f);
3527 glVertex3f(640, 150, 0.0f);
3529 glVertex3f(640, 336, 0.0f);
3531 if(anim!=1)glVertex3f(190, 336, 0.0f);
3532 if(anim==1)glVertex3f(190+movex[4]*transition, 336, 0.0f);
3537 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3539 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3543 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3544 glPushMatrix(); // Store The Projection Matrix
3545 glLoadIdentity(); // Reset The Projection Matrix
3546 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3547 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3548 glPushMatrix(); // Store The Modelview Matrix
3549 glLoadIdentity(); // Reset The Modelview Matrix
3550 glEnable(GL_TEXTURE_2D);
3553 for(j=0;j<nummenuitems;j++)
3555 if(j<=3||(mainmenu!=1&&mainmenu!=2))
3557 //glDisable(GL_BLEND);
3558 glEnable(GL_ALPHA_TEST);
3560 //glDisable(GL_ALPHA_TEST);
3561 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3562 if(mainmenu==1||mainmenu==2)
3565 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3566 glBindTexture( GL_TEXTURE_2D, Mainmenuitems[j]);
3567 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
3568 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
3569 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3573 glVertex3f(startx[j]+movex[j]*transition, starty[j]+movey[j]*transition, 0.0f);
3575 glVertex3f(endx[j]+movex[j]*transition, starty[j]+movey[j]*transition, 0.0f);
3577 glVertex3f(endx[j]+movex[j]*transition, endy[j]+movey[j]*transition, 0.0f);
3579 glVertex3f(startx[j]+movex[j]*transition, endy[j]+movey[j]*transition, 0.0f);
3583 //glDisable(GL_ALPHA_TEST);
3584 if(j<4)glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3587 if(1-((float)i)/10-(1-selectedlong[j])>0)
3589 glColor4f(1,1,1,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3590 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3594 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);
3596 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);
3598 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);
3600 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);
3606 if(mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==8||mainmenu==9||mainmenu==10||mainmenu==11||mainmenu==12||mainmenu==13||mainmenu==14||mainmenu==15||mainmenu==16||mainmenu==17)
3608 if(mainmenu!=5||j<6)
3611 if(mainmenu==12&&j==4)glColor4f(1,(sin(menupulse)+1)/2,(sin(menupulse)+1)/2,1);
3612 if(mainmenu==9&&j>accountprogress[accountactive]&&j<numchallengelevels)glColor4f(0.5,0,0,1);
3613 if(mainmenu==11&&j>accountprogress[accountactive]&&j<numchallengelevels)glColor4f(0.5,0,0,1);
3614 //if(1-((float)i)/10-(1-selectedlong[j])>0){
3615 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3617 if((mainmenu!=7||j!=0||!entername)&&(mainmenu!=13||j!=1)&&(mainmenu!=14||j!=1))text.glPrint(startx[j],starty[j],menustring[j],0,1,640,480);
3621 sprintf (string, "_");
3622 text.glPrint(startx[j]+(float)(displayselected)*10,starty[j],string,0,1,640,480);
3625 for(l=0;l<displaychars[k];l++){
3626 if(l<displaychars[k]){
3627 sprintf (string, "%c",displaytext[k][l]);
3628 text.glPrint(startx[j]+l*10,starty[j],string,0,1,640,480);
3636 sprintf (string, "Hooo!");
3637 text.glPrint(startx[0],starty[0],string,0,1,640,480);
3641 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3644 if(1-((float)i)/15-(1-selectedlong[j])>0)
3646 glColor4f(1,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3647 if(mainmenu==12&&j==4)glColor4f(1,(sin(menupulse)+1)/2,(sin(menupulse)+1)/2,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3648 if(mainmenu==9&&j>accountprogress[accountactive]&&j<numchallengelevels)glColor4f(0.5,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3649 if(mainmenu==11&&j>accountprogress[accountactive]&&j<numchallengelevels)glColor4f(0.5,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3650 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);
3651 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);
3652 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);
3653 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);
3654 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);
3655 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);
3656 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);
3657 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);
3658 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);
3659 if(mainmenu==12)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4/*-((((float)i)/70)*strlen(menustring[j]))*3*/,starty[j]/*-i*1/2*/+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
3660 if(mainmenu==15)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4/*-((((float)i)/70)*strlen(menustring[j]))*3*/,starty[j]/*-i*1/2*/+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
3661 if(mainmenu==16)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4/*-((((float)i)/70)*strlen(menustring[j]))*3*/,starty[j]/*-i*1/2*/+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
3662 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);
3663 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);
3664 if(mainmenu==14&&j!=1)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4/*-((((float)i)/70)*strlen(menustring[j]))*3*/,starty[j]/*-i*1/2*/+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
3667 sprintf (string, "_");
3668 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);
3671 for(l=0;l<displaychars[k];l++){
3672 if(l<displaychars[k]){
3673 sprintf (string, "%c",displaytext[k][l]);
3674 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);
3683 glClear(GL_DEPTH_BUFFER_BIT);
3684 glEnable(GL_ALPHA_TEST);
3685 glAlphaFunc(GL_GREATER, 0.001f);
3686 glEnable(GL_TEXTURE_2D);
3687 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3688 glDisable(GL_CULL_FACE);
3689 glDisable(GL_LIGHTING);
3690 if(j==6)glColor4f(1,1,1,1);
3691 else glColor4f(1,0,0,1);
3693 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3694 glPushMatrix(); // Store The Projection Matrix
3695 glLoadIdentity(); // Reset The Projection Matrix
3696 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3697 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3698 glPushMatrix(); // Store The Modelview Matrix
3699 glLoadIdentity(); // Reset The Modelview Matrix
3702 //Draw world, draw map
3703 glTranslatef(2,-5,0);
3705 if(j>6&&j<nummenuitems-1)
3707 XYZ linestart,lineend,offset;
3714 //float linestartx,lineendx,linestarty,lineendy,offsetx,offsety;
3715 linestart.x=(startx[j]+endx[j])/2;
3716 linestart.y=(starty[j]+endy[j])/2;
3717 if(j>=6+accountcampaignchoicesmade[accountactive]){
3718 linestart.x=(startx[6+accountcampaignchoicesmade[accountactive]]+endx[6+accountcampaignchoicesmade[accountactive]])/2;
3719 linestart.y=(starty[6+accountcampaignchoicesmade[accountactive]]+endy[6+accountcampaignchoicesmade[accountactive]])/2;
3721 lineend.x=(startx[j+1]+endx[j+1])/2;
3722 lineend.y=(starty[j+1]+endy[j+1])/2;
3723 offset=lineend-linestart;
3726 offset=DoRotation(offset,0,0,90);
3728 glDisable(GL_TEXTURE_2D);
3730 if(j<6+accountcampaignchoicesmade[accountactive]){
3731 glColor4f(0.5,0,0,1);
3735 if(j>=6+accountcampaignchoicesmade[accountactive]){
3741 linestart+=fac*4*startsize;
3742 lineend-=fac*4*endsize;
3744 if(!(j>7+accountcampaignchoicesmade[accountactive]+campaignchoicenum)){
3745 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3749 glVertex3f(linestart.x-offset.x*startsize, linestart.y-offset.y*startsize, 0.0f);
3751 glVertex3f(linestart.x+offset.x*startsize, linestart.y+offset.y*startsize, 0.0f);
3753 glVertex3f(lineend.x+offset.x*endsize, lineend.y+offset.y*endsize, 0.0f);
3755 glVertex3f(lineend.x-offset.x*endsize, lineend.y-offset.y*endsize, 0.0f);
3759 glEnable(GL_TEXTURE_2D);
3763 if(j==6)glBindTexture( GL_TEXTURE_2D, Mainmenuitems[7]);
3764 else glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
3765 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
3766 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
3767 if(j-7<accountcampaignchoicesmade[accountactive])glColor4f(0.5,0,0,1);
3768 if(j-7>=accountcampaignchoicesmade[accountactive])glColor4f(1,0,0,1);
3769 if(j==6)glColor4f(1,1,1,1);
3772 itemsize=abs(startx[j]-endx[j])/2;
3774 midpoint.x=(startx[j]+endx[j])/2;
3775 midpoint.y=(starty[j]+endy[j])/2;
3776 if(j>6&&(j-7<accountcampaignchoicesmade[accountactive]))itemsize*=.5;
3777 if(!(j-7>accountcampaignchoicesmade[accountactive]+campaignchoicenum))
3779 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3783 glVertex3f(midpoint.x-itemsize+movex[j]*transition, midpoint.y-itemsize+movey[j]*transition, 0.0f);
3785 glVertex3f(midpoint.x+itemsize+movex[j]*transition, midpoint.y-itemsize+movey[j]*transition, 0.0f);
3787 glVertex3f(midpoint.x+itemsize+movex[j]*transition, midpoint.y+itemsize+movey[j]*transition, 0.0f);
3789 glVertex3f(midpoint.x-itemsize+movex[j]*transition, midpoint.y+itemsize+movey[j]*transition, 0.0f);
3793 //glDisable(GL_ALPHA_TEST);
3794 if(j<4)glBlendFunc(GL_SRC_ALPHA,GL_ONE);
3797 if(1-((float)i)/10-(1-selectedlong[j])>0)
3799 glColor4f(1,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
3800 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3804 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);
3806 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);
3808 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);
3810 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);
3818 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3820 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3822 if(j-7>=accountcampaignchoicesmade[accountactive]){
3823 //glColor4f(0,0,0,1);
3824 //text.glPrintOutline(startx[j]+10-1.5,starty[j]-4-1.5,menustring[j],0,0.6*1.25,640,480);
3825 //glColor4f(1,0,0,1);
3826 //text.glPrint(startx[j]+10,starty[j]-4,menustring[j],0,0.6,640,480);
3827 text.glPrintOutlined(0.9,0,0,startx[j]+10,starty[j]-4,menustring[j],0,0.6,640,480);
3828 glDisable(GL_DEPTH_TEST);
3835 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3837 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3840 if(mainmenu==1||mainmenu==2)
3841 if(transition<.1||transition>.9){
3842 glClear(GL_DEPTH_BUFFER_BIT);
3843 glEnable(GL_ALPHA_TEST);
3844 glAlphaFunc(GL_GREATER, 0.001f);
3845 glEnable(GL_TEXTURE_2D);
3846 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3847 glDisable(GL_CULL_FACE);
3848 glDisable(GL_LIGHTING);
3850 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3851 glPushMatrix(); // Store The Projection Matrix
3852 glLoadIdentity(); // Reset The Projection Matrix
3853 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
3854 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3855 glPushMatrix(); // Store The Modelview Matrix
3856 glLoadIdentity(); // Reset The Modelview Matrix
3858 glDisable(GL_TEXTURE_2D);
3859 if(transition<.1)glColor4f(1,0,0,1-(transition*10));
3860 if(transition>.9)glColor4f(1,0,0,1-((1-transition)*10));
3864 glVertex3f(190, 150, 0.0f);
3866 glVertex3f(640, 150, 0.0f);
3868 glVertex3f(640, 336, 0.0f);
3870 glVertex3f(190, 336, 0.0f);
3875 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3879 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3880 glPushMatrix(); // Store The Projection Matrix
3881 glLoadIdentity(); // Reset The Projection Matrix
3882 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
3883 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3884 glPushMatrix(); // Store The Modelview Matrix
3885 glLoadIdentity(); // Reset The Modelview Matrix
3886 glTranslatef(screenwidth/2,screenheight/2,0);
3888 glScalef((float)screenwidth/2,(float)screenheight/2,1);
3889 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3891 glEnable(GL_TEXTURE_2D);
3893 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
3894 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
3897 glTranslatef(mousecoordh-screenwidth/2,mousecoordv*-1+screenheight/2,0);
3898 glScalef((float)screenwidth/64,(float)screenwidth/64,1);
3899 glTranslatef(1,-1,0);
3900 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3902 glBindTexture( GL_TEXTURE_2D, cursortexture);
3904 //glScalef(.25,.25,.25);
3907 glVertex3f(-1, -1, 0.0f);
3909 glVertex3f(1, -1, 0.0f);
3911 glVertex3f(1, 1, 0.0f);
3913 glVertex3f(-1, 1, 0.0f);
3918 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3924 if(flashamount>1)flashamount=1;
3925 if(flashdelay<=0)flashamount-=multiplier;
3927 if(flashamount<0)flashamount=0;
3928 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
3929 glDisable(GL_CULL_FACE);
3930 glDisable(GL_LIGHTING);
3931 glDisable(GL_TEXTURE_2D);
3933 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3934 glPushMatrix(); // Store The Projection Matrix
3935 glLoadIdentity(); // Reset The Projection Matrix
3936 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
3937 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3938 glPushMatrix(); // Store The Modelview Matrix
3939 glLoadIdentity(); // Reset The Modelview Matrix
3940 glScalef(screenwidth,screenheight,1);
3941 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
3943 glColor4f(flashr,flashg,flashb,flashamount);
3945 glVertex3f(0, 0, 0.0f);
3946 glVertex3f(256, 0, 0.0f);
3947 glVertex3f(256, 256, 0.0f);
3948 glVertex3f(0, 256, 0.0f);
3950 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
3951 glPopMatrix(); // Restore The Old Projection Matrix
3952 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
3953 glPopMatrix(); // Restore The Old Projection Matrix
3954 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
3955 glEnable(GL_CULL_FACE);
3956 glDisable(GL_BLEND);
3961 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)||(!gameon&&gamestarted)){
3962 tempmult=multiplier;
3968 if(drawmode!=motionblurmode||mainmenu){
3970 // this prevents menus from rendering if you hit ESC during
3971 // motion blur sequences...maybe SDL is buffering differently?
3972 if(drawmode!=motionblurmode)
3979 //myassert(glGetError() == GL_NO_ERROR);
3980 glDrawBuffer(GL_BACK);
3981 glReadBuffer(GL_BACK);
3986 if(drawtoggle==2)drawtoggle=0;
3988 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)){
3989 multiplier=tempmult;
3991 //Jordan fixed your warning!