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"
33 extern int environment;
34 extern float texscale;
36 extern Terrain terrain;
37 //extern Sprites sprites;
38 extern float multiplier;
40 extern float viewdistance;
41 extern float fadestart;
42 extern float screenwidth,screenheight;
43 extern int kTextureSize;
44 extern FRUSTUM frustum;
46 extern Objects objects;
48 extern float usermousesensitivity;
50 extern float camerashake;
52 extern float slomodelay;
53 extern bool ismotionblur;
55 extern float blackout;
56 extern bool damageeffects;
58 extern bool texttoggle;
59 extern float blurness;
60 extern float targetblurness;
61 extern float playerdist;
62 extern bool cellophane;
64 extern float flashamount,flashr,flashg,flashb;
65 extern int flashdelay;
67 extern float motionbluramount;
69 extern bool alwaysblur;
71 extern bool tilt2weird;
72 extern bool tiltweird;
74 extern bool proportionweird;
75 extern bool vertexweird[6];
76 extern bool velocityblur;
77 extern bool debugmode;
79 extern int bloodtoggle;
80 extern int difficulty;
83 //extern int texdetail;
84 extern float texdetail;
85 extern bool musictoggle;
86 extern int tutoriallevel;
87 extern float smoketex;
88 extern float tutorialstagetime;
89 extern float tutorialmaxtime;
90 extern int tutorialstage;
91 extern bool againbonus;
92 extern float damagedealt;
93 extern bool invertmouse;
95 extern int numhotspots;
96 extern int killhotspot;
97 extern XYZ hotspot[40];
98 extern int hotspottype[40];
99 extern float hotspotsize[40];
100 extern char hotspottext[40][256];
101 extern int currenthotspot;;
103 extern bool campaign;
104 extern bool winfreeze;
106 extern float menupulse;
108 extern bool gamestart;
110 extern bool gamestarted;
112 extern bool showdamagebar;
115 normalmode, motionblurmode, radialzoommode,
116 realmotionblurmode, doublevisionmode, glowmode,
119 void Game::flash() { // shouldn't be that way, these should be attributes and Person class should not change rendering.
126 /*********************> DrawGLScene() <*****/
127 int Game::DrawGLScene(StereoSide side)
129 static float texcoordwidth,texcoordheight;
130 static float texviewwidth, texviewheight;
132 static GLubyte color;
133 static XYZ checkpoint;
134 static float tempmult;
136 static char string[256]="";
137 static char string2[256]="";
138 static char string3[256]="";
140 if ( stereomode == stereoAnaglyph ) {
142 case stereoLeft: glColorMask( 0.0, 1.0, 1.0, 1.0 ); break;
143 case stereoRight: glColorMask( 1.0, 0.0, 0.0, 1.0 ); break;
146 glColorMask( 1.0, 1.0, 1.0, 1.0 );
148 if ( stereomode == stereoHorizontalInterlaced || stereomode == stereoVerticalInterlaced ) {
149 glStencilFunc(side == stereoLeft ? GL_NOTEQUAL : GL_EQUAL, 0x01, 0x01);
153 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)){
160 numboundaries=mapradius*2;
161 if(numboundaries>360)numboundaries=360;
162 for(i=0;i<numboundaries;i++){
165 boundary[i]=mapcenter+DoRotation(boundary[i]*mapradius,0,i*(360/((float)(numboundaries))),0);
174 olddrawmode=drawmode;
175 if(ismotionblur&&!loading){
176 if((findLengthfast(&player[0].velocity)>200)&&velocityblur&&!cameramode){
177 drawmode=motionblurmode;
178 motionbluramount=200/(findLengthfast(&player[0].velocity));
181 if(player[0].damage-player[0].superpermanentdamage>(player[0].damagetolerance-player[0].superpermanentdamage)*1/2&&damageeffects&&!cameramode){
182 drawmode=doublevisionmode;
189 drawmode=motionblurmode;
191 slomodelay-=multiplier;
197 if((!changed&&!slomo)||loading){
199 if(ismotionblur&&(/*fps>100||*/alwaysblur)){
200 if(olddrawmode!=realmotionblurmode)
204 drawmode=realmotionblurmode;
205 }else if(olddrawmode==realmotionblurmode)
211 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted))
213 if((freeze||winfreeze)&&ismotionblur&&!mainmenu)
214 drawmode=radialzoommode;
216 if(winfreeze||mainmenu)drawmode=normalmode;
219 if(drawmode==glowmode){
224 DSpContext_FadeGamma(NULL,200,&color2);
229 drawtoggle=1-drawtoggle;
232 texviewwidth=kTextureSize;
233 if(texviewwidth>screenwidth)
234 texviewwidth=screenwidth;
235 texviewheight=kTextureSize;
236 if(texviewheight>screenheight)
237 texviewheight=screenheight;
239 texcoordwidth=screenwidth/kTextureSize;
240 texcoordheight=screenheight/kTextureSize;
247 glDrawBuffer(GL_BACK);
248 glReadBuffer(GL_BACK);
251 static XYZ terrainlight;
252 static float distance;
253 if(drawmode==normalmode)
254 ReSizeGLScene(90,.1f);
255 if(drawmode!=normalmode)
256 glViewport(0,0,texviewwidth,texviewheight);
257 glDepthFunc(GL_LEQUAL);
259 glAlphaFunc(GL_GREATER, 0.0001f);
260 glEnable(GL_ALPHA_TEST);
261 glClearColor(0.25f, 0.25f, 0.25f, 1.0f);
262 glClear(GL_DEPTH_BUFFER_BIT);
264 glMatrixMode (GL_MODELVIEW);
265 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
268 // Move the camera for the current eye's point of view.
269 // Reverse the movement if we're reversing stereo
270 glTranslatef((stereoseparation/2) * side * (stereoreverse ? -1 : 1), 0, 0);
273 if(!cameramode&&!freeze&&!winfreeze){
275 glRotatef(float(Random()%100)/10*camerashake/*+(woozy*woozy)/10*/,0,0,1);
277 glRotatef(rotation2+sin(woozy/2)*(player[0].damage/player[0].damagetolerance)*5,1,0,0);
278 glRotatef(rotation+sin(woozy)*(player[0].damage/player[0].damagetolerance)*5,0,1,0);
280 if(cameramode||freeze||winfreeze){
281 glRotatef(rotation2,1,0,0);
282 glRotatef(rotation,0,1,0);
285 if(environment==desertenvironment){
286 glRotatef((float)(abs(Random()%100))/3000-1,1,0,0);
287 glRotatef((float)(abs(Random()%100))/3000-1,0,1,0);
289 SetUpLight(&light,0);
292 //heat blur effect in desert
293 if(abs(blurness-targetblurness)<multiplier*10||abs(blurness-targetblurness)>2){
294 blurness=targetblurness;
295 targetblurness=(float)(abs(Random()%100))/40;
297 if(blurness<targetblurness)
298 blurness+=multiplier*5;
300 blurness-=multiplier*5;
302 if(environment==desertenvironment&&detail==2)
303 glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, blurness+.4 );
304 if(environment==desertenvironment){
305 glRotatef((float)(abs(Random()%100))/1000,1,0,0);
306 glRotatef((float)(abs(Random()%100))/1000,0,1,0);
309 glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0);
311 glTranslatef(-viewer.x,-viewer.y,-viewer.z);
312 frustum.GetFrustum();
314 //make shadow decals on terrain and objects
316 static float size,opacity,rotation;
318 for(k=0;k<numplayers;k++){
319 if(!player[k].skeleton.free&&player[k].playerdetail&&player[k].howactive<typesleeping)
320 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)
321 for(i=0;i<player[k].skeleton.num_joints;i++){
322 if(player[k].skeleton.joints[i].label==leftknee||player[k].skeleton.joints[i].label==rightknee||player[k].skeleton.joints[i].label==groin){
323 point=DoRotation(player[k].skeleton.joints[i].position,0,player[k].rotation,0)*player[k].scale+player[k].coords;
325 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;
326 if(k!=0&&tutoriallevel==1){
327 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;
329 terrain.MakeDecal(shadowdecal,point,size,opacity,rotation);
330 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
331 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
332 if(objects.position[j].y<player[k].coords.y||objects.type[j]==tunneltype||objects.type[j]==weirdtype){
333 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);
336 if(k!=0&&tutoriallevel==1){
337 opacity=.2+.2*sin(smoketex*6+i);
339 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
344 if((player[k].skeleton.free||player[k].howactive>=typesleeping)&&player[k].playerdetail)
345 if(frustum.SphereInFrustum(player[k].coords.x,player[k].coords.y,player[k].coords.z,player[k].scale*5)&&player[k].occluded<25)
346 for(i=0;i<player[k].skeleton.num_joints;i++){
347 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){
348 if(player[k].skeleton.free)
349 point=player[k].skeleton.joints[i].position*player[k].scale+player[k].coords;
351 point=DoRotation(player[k].skeleton.joints[i].position,0,player[k].rotation,0)*player[k].scale+player[k].coords;
353 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;
354 if(k!=0&&tutoriallevel==1){
355 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;
357 terrain.MakeDecal(shadowdecal,point,size,opacity*.7,rotation);
358 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
359 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
360 if(objects.position[j].y<player[k].coords.y||objects.type[j]==tunneltype||objects.type[j]==weirdtype){
361 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);
362 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);
365 if(k!=0&&tutoriallevel==1){
366 opacity=.2+.2*sin(smoketex*6+i);
368 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
374 if(!player[k].playerdetail)
375 if(frustum.SphereInFrustum(player[k].coords.x,player[k].coords.y,player[k].coords.z,player[k].scale*5)){
376 point=player[k].coords;
378 opacity=.4-(player[k].coords.y-terrain.getHeight(player[k].coords.x,player[k].coords.z))/5;
379 terrain.MakeDecal(shadowdecal,point,size,opacity*.7,rotation);
380 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
381 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
382 point=DoRotation(player[k].coords-objects.position[j],0,-objects.rotation[j],0);
385 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
391 glEnable(GL_TEXTURE_2D);
393 glEnable(GL_DEPTH_TEST);
394 glEnable(GL_CULL_FACE);
396 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
397 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
398 glBindTexture( GL_TEXTURE_2D, terraintexture);
400 glBindTexture( GL_TEXTURE_2D, terraintexture2);
402 //glBindTexture( GL_TEXTURE_2D, terraintexture3);
403 //glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
406 terrain.drawdecals();
409 glEnable(GL_CULL_FACE);
410 glEnable(GL_LIGHTING);
412 glEnable(GL_TEXTURE_2D);
415 glEnable(GL_COLOR_MATERIAL);
430 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
431 glEnable(GL_CULL_FACE);
432 glCullFace(GL_FRONT);
434 for(k=0;k<numplayers;k++){
435 if(k==0||tutoriallevel!=1){
437 glEnable(GL_LIGHTING);
438 terrainlight=terrain.getLighting(player[k].coords.x,player[k].coords.z);
439 distance=findDistancefast(&viewer,&player[k].coords);
440 distance=(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance;
441 glColor4f(terrainlight.x,terrainlight.y,terrainlight.z,distance);
445 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;
447 if(!player[k].occluded==0)
448 i=checkcollide(viewer,checkpoint,player[k].lastoccluded);
449 if(i==-1||player[k].occluded==0)
450 i=checkcollide(viewer,checkpoint);
452 player[k].occluded+=1;
453 player[k].lastoccluded=i;
455 player[k].occluded=0;
456 if(player[k].occluded<25)
457 player[k].DrawSkeleton();
463 if(!cameramode&&musictype==stream_fighttheme)
464 playerdist=findDistancefastflat(&player[0].coords,&viewer);
469 glEnable(GL_TEXTURE_2D);
475 if(frustum.SphereInFrustum(realhawkcoords.x+hawk.boundingspherecenter.x,realhawkcoords.y+hawk.boundingspherecenter.y,realhawkcoords.z+hawk.boundingspherecenter.z,2)){
476 glAlphaFunc(GL_GREATER, 0.0001f);
478 glDisable(GL_CULL_FACE);
479 glDisable(GL_LIGHTING);
481 glTranslatef(hawkcoords.x,hawkcoords.y,hawkcoords.z);
482 glRotatef(hawkrotation,0,1,0);
483 glTranslatef(25,0,0);
484 distance=findDistancefast(&viewer,&realhawkcoords)*1.2;
485 glColor4f(light.color[0],light.color[1],light.color[2],(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance);
486 if((viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance>1)
487 glColor4f(light.color[0],light.color[1],light.color[2],1);
488 if((viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance>0)
489 hawk.drawdifftex(hawktexture);
493 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
494 glEnable(GL_CULL_FACE);
495 glCullFace(GL_FRONT);
497 for(k=0;k<numplayers;k++){
498 if(!(k==0||tutoriallevel!=1)){
500 glEnable(GL_LIGHTING);
501 terrainlight=terrain.getLighting(player[k].coords.x,player[k].coords.z);
502 distance=findDistancefast(&viewer,&player[k].coords);
503 distance=(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance;
504 glColor4f(terrainlight.x,terrainlight.y,terrainlight.z,distance);
508 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;
510 if(!player[k].occluded==0)
511 i=checkcollide(viewer,checkpoint,player[k].lastoccluded);
512 if(i==-1||player[k].occluded==0)
513 i=checkcollide(viewer,checkpoint);
515 player[k].occluded+=1;
516 player[k].lastoccluded=i;
518 player[k].occluded=0;
519 if(player[k].occluded<25)
520 player[k].DrawSkeleton();
526 glEnable(GL_TEXTURE_2D);
531 glDisable(GL_COLOR_MATERIAL);
533 glDisable(GL_LIGHTING);
534 glDisable(GL_TEXTURE_2D);
540 //waypoints, pathpoints in editor
543 glDisable(GL_LIGHTING);
544 glDisable(GL_TEXTURE_2D);
545 glDisable(GL_COLOR_MATERIAL);
548 for(k=0;k<numplayers;k++){
549 if(player[k].numwaypoints>1){
550 glBegin(GL_LINE_LOOP);
551 for(i=0;i<player[k].numwaypoints;i++){
552 glVertex3f(player[k].waypoints[i].x,player[k].waypoints[i].y+.5,player[k].waypoints[i].z);
561 for(k=0;k<numpathpoints;k++){
562 if(numpathpointconnect[k]){
563 for(i=0;i<numpathpointconnect[k];i++){
564 glBegin(GL_LINE_LOOP);
565 glVertex3f(pathpoint[k].x,pathpoint[k].y+.5,pathpoint[k].z);
566 glVertex3f(pathpoint[pathpointconnect[k][i]].x,pathpoint[pathpointconnect[k][i]].y+.5,pathpoint[pathpointconnect[k][i]].z);
574 glVertex3f(pathpoint[pathpointselected].x,pathpoint[pathpointselected].y+.5,pathpoint[pathpointselected].z);
581 glEnable(GL_TEXTURE_2D);
582 glColor4f(.5,.5,.5,1);
584 sprintf (string, " ",(int)(fps));
585 text->glPrint(10,30,string,0,.8,screenwidth,screenheight);
588 if(bonus>0&&bonustime<1&&!winfreeze&&indialogue==-1/*bonustime<4*/){
589 const char *bonus_name;
590 if (bonus < bonus_count)
591 bonus_name = bonus_names[bonus];
593 bonus_name = "Excellent!"; // When does this happen?
595 glColor4f(0,0,0,1-bonustime);
596 text->glPrintOutline(1024/2-10*strlen(bonus_name)-4,768/16-4+768*4/5,bonus_name,1,2.5,1024,768);
597 glColor4f(1,0,0,1-bonustime);
598 text->glPrint(1024/2-10*strlen(bonus_name),768/16+768*4/5,bonus_name,1,2,1024,768);
600 sprintf (string, "%d",(int)bonusvalue);
601 glColor4f(0,0,0,1-bonustime);
602 text->glPrintOutline(1024/2-10*strlen(string)-4,768/16-4-20+768*4/5,string,1,2.5*.8,1024,768);
603 glColor4f(1,0,0,1-bonustime);
604 text->glPrint(1024/2-10*strlen(string),768/16-20+768*4/5,string,1,2*.8,1024,768);
605 glColor4f(.5,.5,.5,1);
608 if(tutoriallevel==1){
609 tutorialopac=tutorialmaxtime-tutorialstagetime;
610 if(tutorialopac>1)tutorialopac=1;
611 if(tutorialopac<0)tutorialopac=0;
613 sprintf (string, " ");
614 sprintf (string2, " ");
615 sprintf (string3, " ");
616 if(tutorialstage==0){
617 sprintf (string, " ");
618 sprintf (string2, " ");
619 sprintf (string3, " ");
621 if(tutorialstage==1){
622 sprintf (string, "Welcome to the Lugaru training level!");
623 sprintf (string2, " ");
624 sprintf (string3, " ");
626 if(tutorialstage==2){
627 sprintf (string, "BASIC MOVEMENT:");
628 sprintf (string2, " ");
629 sprintf (string3, " ");
631 if(tutorialstage==3){
632 sprintf (string, "You can move the mouse to rotate the camera.");
633 sprintf (string2, " ");
634 sprintf (string3, " ");
636 if(tutorialstage==4){
637 sprintf (string, "Try using the %s, %s, %s and %s keys to move around.",Input::keyToChar(forwardkey),Input::keyToChar(leftkey),Input::keyToChar(backkey),Input::keyToChar(rightkey));
638 sprintf (string2, "All movement is relative to the camera.");
639 sprintf (string3, " ");
641 if(tutorialstage==5){
642 sprintf (string, "Please press %s to jump.",Input::keyToChar(jumpkey));
643 sprintf (string2, "You can hold it longer to jump higher.");
644 sprintf (string3, " ");
646 if(tutorialstage==6){
647 sprintf (string, "You can press %s to crouch.",Input::keyToChar(crouchkey));
648 sprintf (string2, "You can jump higher from a crouching position.");
649 sprintf (string3, " ");
651 if(tutorialstage==7){
652 sprintf (string, "While running, you can press %s to roll.",Input::keyToChar(crouchkey));
653 sprintf (string2, " ");
654 sprintf (string3, " ");
656 if(tutorialstage==8){
657 sprintf (string, "While crouching, you can sneak around silently");
658 sprintf (string2, "using the movement keys.");
659 sprintf (string3, " ");
661 if(tutorialstage==9){
662 sprintf (string, "Release the crouch key while sneaking and hold the movement keys");
663 sprintf (string2, "to run animal-style.");
664 sprintf (string3, " ");
666 if(tutorialstage==10){
667 sprintf (string, "ADVANCED MOVEMENT:");
668 sprintf (string2, " ");
669 sprintf (string3, " ");
671 if(tutorialstage==11){
672 sprintf (string, "When you jump at a wall, you can hold %s again",Input::keyToChar(jumpkey));
673 sprintf (string2, "during impact to perform a walljump.");
674 sprintf (string3, "Be sure to use the movement keys to press against the wall");
676 if(tutorialstage==12){
677 sprintf (string, "While in the air, you can press crouch to flip.",Input::keyToChar(jumpkey));
678 sprintf (string2, "Walljumps and flips confuse enemies and give you more control.");
679 sprintf (string3, " ");
681 if(tutorialstage==13){
682 sprintf (string, "BASIC COMBAT:");
683 sprintf (string2, " ");
684 sprintf (string3, " ");
686 if(tutorialstage==14){
687 sprintf (string, "There is now an imaginary enemy");
688 sprintf (string2, "in the middle of the training area.");
689 sprintf (string3, " ");
691 if(tutorialstage==15){
692 if(attackkey==MOUSEBUTTON1)sprintf (string, "Click to attack when you are near an enemy.");
693 else sprintf (string, "Press %s to attack when you are near an enemy.",Input::keyToChar(attackkey));
694 sprintf (string2, "You can punch by standing still near an enemy and attacking.");
695 sprintf (string3, " ");
697 if(tutorialstage==16){
698 sprintf (string, "If you are close, you will perform a weak punch.");
699 sprintf (string2, "The weak punch is excellent for starting attack combinations.");
700 sprintf (string3, " ");
702 if(tutorialstage==17){
703 sprintf (string, "Attacking while running results in a spin kick.");
704 sprintf (string2, "This is one of your most powerful ground attacks.");
705 sprintf (string3, " ");
707 if(tutorialstage==18){
708 sprintf (string, "Sweep the enemy's legs out by attacking while crouched.");
709 sprintf (string2, "This is a very fast attack, and easy to follow up.");
710 sprintf (string3, " ");
712 if(tutorialstage==19){
713 sprintf (string, "When an enemy is on the ground, you can deal some extra");
714 sprintf (string2, "damage by running up and drop-kicking him.");
715 sprintf (string3, "(Try knocking them down with a sweep first)");
717 if(tutorialstage==20){
718 sprintf (string, "Your most powerful individual attack is the rabbit kick.");
719 if(attackkey==MOUSEBUTTON1)sprintf (string2, "Run at the enemy while holding the mouse button, and press");
720 else sprintf (string2, "Run at the enemy while holding %s, and press", Input::keyToChar(attackkey));
721 sprintf (string3, "the jump key (%s) to attack.",Input::keyToChar(jumpkey));
723 if(tutorialstage==21){
724 sprintf (string, "This attack is devastating if timed correctly.");
725 sprintf (string2, "Even if timed incorrectly, it will knock the enemy over.");
726 if(againbonus)sprintf (string3, "Try rabbit-kicking the imaginary enemy again.");
727 else sprintf (string3, "Try rabbit-kicking the imaginary enemy.");
729 if(tutorialstage==22){
730 sprintf (string, "If you sneak behind an enemy unnoticed, you can kill");
731 sprintf (string2, "him instantly. Move close behind this enemy");
732 sprintf (string3, "and attack.");
734 if(tutorialstage==23){
735 sprintf (string, "Another important attack is the wall kick. When an enemy");
736 sprintf (string2, "is near a wall, perform a walljump nearby and hold");
737 sprintf (string3, "the attack key during impact with the wall.");
739 if(tutorialstage==24){
740 sprintf (string, "You can tackle enemies by running at them animal-style");
741 if(attackkey==MOUSEBUTTON1)sprintf (string2, "and pressing jump (%s) or attack(mouse button).",Input::keyToChar(jumpkey));
742 else sprintf (string2, "and pressing jump (%s) or attack(%s).",Input::keyToChar(jumpkey),Input::keyToChar(attackkey));
743 sprintf (string3, "This is especially useful when they are running away.");
745 if(tutorialstage==25){
746 sprintf (string, "Dodge by pressing back and attack. Dodging is essential");
747 sprintf (string2, "against enemies with swords or other long weapons.");
748 sprintf (string3, " ");
750 if(tutorialstage==26){
751 sprintf (string, "REVERSALS AND COUNTER-REVERSALS");
752 sprintf (string2, " ");
753 sprintf (string3, " ");
755 if(tutorialstage==27){
756 sprintf (string, "The enemy can now reverse your attacks.");
757 sprintf (string2, " ");
758 sprintf (string3, " ");
760 if(tutorialstage==28){
761 sprintf (string, "If you attack, you will notice that the enemy now sometimes");
762 sprintf (string2, "catches your attack and uses it against you. Hold");
763 sprintf (string3, "crouch (%s) after attacking to escape from reversals.",Input::keyToChar(crouchkey));
765 if(tutorialstage==29){
766 sprintf (string, "Try escaping from two more reversals in a row.");
767 sprintf (string2, " ");
768 sprintf (string3, " ");
770 if(tutorialstage==30){
771 sprintf (string, "Good!");
772 sprintf (string2, " ");
773 sprintf (string3, " ");
775 if(tutorialstage==31){
776 sprintf (string, "To reverse an attack, you must tap crouch (%s) during the",Input::keyToChar(crouchkey));
777 sprintf (string2, "enemy's attack. You must also be close to the enemy;");
778 sprintf (string3, "this is especially important against armed opponents.");
780 if(tutorialstage==32){
781 sprintf (string, "The enemy can attack in %d seconds.", (int)(tutorialmaxtime-tutorialstagetime));
782 sprintf (string2, "This imaginary opponents attacks will be highlighted");
783 sprintf (string3, "to make this easier.");
785 if(tutorialstage==33){
786 sprintf (string, "Reverse three enemy attacks!");
787 sprintf (string2, " ");
788 sprintf (string3, " ");
790 if(tutorialstage==34){
791 sprintf (string, "Reverse two more enemy attacks!");
792 sprintf (string2, " ");
793 sprintf (string3, " ");
795 if(tutorialstage==35){
796 sprintf (string, "Reverse one more enemy attack!");
797 sprintf (string2, " ");
798 sprintf (string3, " ");
800 if(tutorialstage==36){
801 sprintf (string, "Excellent!");
802 sprintf (string2, " ");
803 sprintf (string3, " ");
805 if(tutorialstage==37){
806 sprintf (string, "Now spar with the enemy for %d more seconds.", (int)(tutorialmaxtime-tutorialstagetime));
807 sprintf (string2, "Damage dealt: %d",(int)damagedealt);
808 sprintf (string3, "Damage taken: %d.",(int)damagetaken);
810 if(tutorialstage==38){
811 sprintf (string, "WEAPONS:");
812 sprintf (string2, " ");
813 sprintf (string3, " ");
815 if(tutorialstage==39){
816 sprintf (string, "There is now an imaginary knife");
817 sprintf (string2, "in the center of the training area.");
818 sprintf (string3, " ");
820 if(tutorialstage==40){
821 sprintf (string, "Stand, roll or handspring over the knife");
822 sprintf (string2, "while pressing %s to pick it up.",Input::keyToChar(throwkey));
823 sprintf (string3, "You can crouch and press the same key to drop it again.");
825 if(tutorialstage==41){
826 sprintf (string, "You can equip and unequip weapons using the %s key.",Input::keyToChar(drawkey));
827 sprintf (string2, "Sometimes it is best to keep them unequipped to");
828 sprintf (string3, "prevent enemies from taking them. ");
830 if(tutorialstage==42){
831 sprintf (string, "The knife is the smallest weapon and the least encumbering.");
832 sprintf (string2, "You can equip or unequip it while standing, crouching,");
833 sprintf (string3, "running or flipping.");
835 if(tutorialstage==43){
836 sprintf (string, "You perform weapon attacks the same way as unarmed attacks,");
837 sprintf (string2, "but sharp weapons cause permanent damage, instead of the");
838 sprintf (string3, "temporary trauma from blunt weapons, fists and feet.");
840 if(tutorialstage==44){
841 sprintf (string, "The enemy now has your knife!");
842 sprintf (string2, "Please reverse two of his knife attacks.");
843 sprintf (string3, " ");
845 if(tutorialstage==45){
846 sprintf (string, "Please reverse one more of his knife attacks.");
847 sprintf (string2, " ");
848 sprintf (string3, " ");
850 if(tutorialstage==46){
851 sprintf (string, "Now he has a sword!");
852 sprintf (string2, "The sword has longer reach than your arms, so you");
853 sprintf (string3, "must move close to reverse the sword slash.");
855 if(tutorialstage==47){
856 sprintf (string, "Long weapons like the sword and staff are also useful for defense;");
857 sprintf (string2, "you can parry enemy weapon attacks by pressing the attack key");
858 sprintf (string3, "at the right time. Please try parrying the enemy's attacks!");
860 if(tutorialstage==48){
861 sprintf (string, "The staff is like the sword, but has two main attacks.");
862 sprintf (string2, "The standing smash is fast and effective, and the running");
863 sprintf (string3, "spin smash is slower and more powerful.");
865 if(tutorialstage==49){
866 sprintf (string, "When facing an enemy, you can throw the knife with %s.",Input::keyToChar(throwkey));
867 sprintf (string2, "It is possible to throw the knife while flipping,");
868 sprintf (string3, "but it is very inaccurate.");
870 if(tutorialstage==50){
871 sprintf (string, "You now know everything you can learn from training.");
872 sprintf (string2, "Everything else you must learn from experience!");
873 sprintf (string3, " ");
875 if(tutorialstage==51){
876 sprintf (string, "Walk out of the training area to return to the main menu.");
877 sprintf (string2, " ");
878 sprintf (string3, " ");
881 glColor4f(0,0,0,tutorialopac);
882 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);
883 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);
884 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);
885 glColor4f(1,1,1,tutorialopac);
886 text->glPrint(screenwidth/2-7.6*strlen(string)*screenwidth/1024,screenheight/16+screenheight*4/5,string,1,1.5*screenwidth/1024,screenwidth,screenheight);
887 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);
888 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);
890 sprintf (string, "Press 'tab' to skip to the next item.",Input::keyToChar(jumpkey));
891 sprintf (string2, "Press escape at any time to");
892 sprintf (string3, "pause or exit the tutorial.");
895 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);
896 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);
897 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);
898 glColor4f(0.5,0.5,0.5,1);
899 text->glPrint(screenwidth/2-7.6*strlen(string)*screenwidth/1024*.8,0+screenheight*1/10,string,1,1.5*screenwidth/1024*.8,screenwidth,screenheight);
900 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);
901 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);
905 if(numhotspots&&(bonustime>=1||bonus<=0||bonustime<0)&&!tutoriallevel){
907 float closestdist=-1;
909 closest=currenthotspot;
910 for(i=0;i<numhotspots;i++){
911 distance=findDistancefast(&player[0].coords,&hotspot[i]);
912 if(closestdist==-1||distance<closestdist){
913 if(findDistancefast(&player[0].coords,&hotspot[i])<hotspotsize[i]&&((hotspottype[i]<=10&&hotspottype[i]>=0)||(hotspottype[i]<=40&&hotspottype[i]>=20))){
914 closestdist=distance;
920 currenthotspot=closest;
921 if(currenthotspot!=-1){
922 if(hotspottype[closest]<=10){
923 if(findDistancefast(&player[0].coords,&hotspot[closest])<hotspotsize[closest])
926 tutorialopac=tutorialmaxtime-tutorialstagetime;
927 if(tutorialopac>1)tutorialopac=1;
928 if(tutorialopac<0)tutorialopac=0;
930 sprintf (string, "%s", hotspottext[closest]);
937 if(string[i]=='\n'||string[i]>'z'||string[i]<' '||string[i]=='\0'){
938 glColor4f(0,0,0,tutorialopac);
939 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);
940 glColor4f(1,1,1,tutorialopac);
941 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);
944 if(string[i]=='\0')done=1;
949 } else if (hotspottype[closest]>=20&&dialoguegonethrough[hotspottype[closest]-20]==0){
950 whichdialogue=hotspottype[closest]-20;
951 for(j=0;j<numdialogueboxes[whichdialogue];j++){
952 player[participantfocus[whichdialogue][j]].coords=participantlocation[whichdialogue][participantfocus[whichdialogue][j]];
953 player[participantfocus[whichdialogue][j]].rotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
954 player[participantfocus[whichdialogue][j]].targetrotation=participantrotation[whichdialogue][participantfocus[whichdialogue][j]];
955 player[participantfocus[whichdialogue][j]].velocity=0;
956 player[participantfocus[whichdialogue][j]].targetanimation=player[participantfocus[whichdialogue][j]].getIdle();
957 player[participantfocus[whichdialogue][j]].targetframe=0;
961 dialoguegonethrough[whichdialogue]++;
962 if(dialogueboxsound[whichdialogue][indialogue]!=0){
964 if(dialogueboxsound[whichdialogue][indialogue]==1)whichsoundplay=rabbitchitter;
965 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
966 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
967 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
968 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
969 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
970 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
971 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
972 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
973 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
974 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
975 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
976 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
977 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
978 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
979 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
980 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
981 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
982 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
983 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
984 emit_sound_at(whichsoundplay, player[participantfocus[whichdialogue][indialogue]].coords);
990 if(indialogue!=-1&&!mainmenu){
991 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
992 glDisable(GL_CULL_FACE);
993 glDisable(GL_LIGHTING);
994 glDisable(GL_TEXTURE_2D);
996 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
997 glPushMatrix(); // Store The Projection Matrix
998 glLoadIdentity(); // Reset The Projection Matrix
999 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1000 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1001 glPushMatrix(); // Store The Modelview Matrix
1002 glLoadIdentity(); // Reset The Modelview Matrix
1003 if(dialogueboxlocation[whichdialogue][indialogue]==1)glTranslatef(0,screenheight*3/4,0);
1004 glScalef(screenwidth,screenheight/4,1);
1005 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1008 glColor4f(dialogueboxcolor[whichdialogue][indialogue][0],dialogueboxcolor[whichdialogue][indialogue][1],dialogueboxcolor[whichdialogue][indialogue][2],0.7);
1010 glVertex3f(0, 0, 0.0f);
1011 glVertex3f(1, 0, 0.0f);
1012 glVertex3f(1, 1, 0.0f);
1013 glVertex3f(0, 1, 0.0f);
1015 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1016 glPopMatrix(); // Restore The Old Projection Matrix
1017 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1018 glPopMatrix(); // Restore The Old Projection Matrix
1019 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1020 glEnable(GL_CULL_FACE);
1021 glDisable(GL_BLEND);
1023 glEnable(GL_TEXTURE_2D);
1030 startx=screenwidth*1/5;
1031 if(dialogueboxlocation[whichdialogue][indialogue]==1)
1032 starty=screenheight/16+screenheight*4/5;
1033 if(dialogueboxlocation[whichdialogue][indialogue]==2)
1034 starty=screenheight*1/5-screenheight/16;
1043 for(i=0;i<(int)strlen(dialoguename[whichdialogue][indialogue]);i++){
1044 tempname[tempnum]=dialoguename[whichdialogue][indialogue][i];
1046 if(dialoguename[whichdialogue][indialogue][i]=='#'||dialoguename[whichdialogue][indialogue][i]=='\0')goodchar=0;
1050 tempname[tempnum]='\0';
1053 sprintf (string, "%s: ", tempname);
1055 if(dialogueboxcolor[whichdialogue][indialogue][0]+dialogueboxcolor[whichdialogue][indialogue][1]+dialogueboxcolor[whichdialogue][indialogue][2]<1.5){
1056 glColor4f(0,0,0,tutorialopac);
1057 text->glPrintOutline(startx-2*7.6*strlen(string)*screenwidth/1024-4,starty-4,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight);
1058 glColor4f(0.7,0.7,0.7,tutorialopac);
1059 text->glPrint(startx-2*7.6*strlen(string)*screenwidth/1024,starty,string,1,1.5*screenwidth/1024,screenwidth,screenheight);
1063 glColor4f(0,0,0,tutorialopac);
1064 text->glPrintOutline(startx-2*7.6*strlen(string)*screenwidth/1024-4,starty-4,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight);
1068 for(i=0;i<(int)strlen(dialoguetext[whichdialogue][indialogue])+1;i++){
1069 tempname[tempnum]=dialoguetext[whichdialogue][indialogue][i];
1070 if(dialoguetext[whichdialogue][indialogue][i]!='#')tempnum++;
1073 sprintf (string, "%s", tempname);
1080 if(string[i]=='\n'||string[i]>'z'||string[i]<' '||string[i]=='\0'){
1081 if(dialogueboxcolor[whichdialogue][indialogue][0]+dialogueboxcolor[whichdialogue][indialogue][1]+dialogueboxcolor[whichdialogue][indialogue][2]<1.5){
1082 glColor4f(0,0,0,tutorialopac);
1083 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);
1084 glColor4f(1,1,1,tutorialopac);
1085 text->glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/,starty-20*screenwidth/1024*line,string,1,1.5*screenwidth/1024,screenwidth,screenheight,lastline,i);
1089 glColor4f(0,0,0,tutorialopac);
1090 text->glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/,starty-20*screenwidth/1024*line,string,1,1.5*screenwidth/1024,screenwidth,screenheight,lastline,i);
1094 if(string[i]=='\0')done=1;
1101 if(!tutoriallevel&&!winfreeze&&indialogue==-1&&!mainmenu){
1104 sprintf (string, "Score: %d", (int)accountactive->getCampaignScore());
1106 sprintf (string, "Score: %d", (int)accountactive->getCampaignScore()+(int)bonustotal);
1108 if(!campaign)sprintf (string, "Score: %d", (int)bonustotal);
1110 text->glPrintOutline(1024/40-4,768/16-4+768*14/16,string,1,1.5*1.25,1024,768);
1112 text->glPrint(1024/40,768/16+768*14/16,string,1,1.5,1024,768);
1114 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1115 glDisable(GL_CULL_FACE);
1116 glDisable(GL_LIGHTING);
1117 glDisable(GL_TEXTURE_2D);
1119 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1120 glPushMatrix(); // Store The Projection Matrix
1121 glLoadIdentity(); // Reset The Projection Matrix
1122 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1123 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1124 glPushMatrix(); // Store The Modelview Matrix
1125 glLoadIdentity(); // Reset The Modelview Matrix
1126 glTranslatef(15,screenheight*17.5/20,0);
1127 glScalef(screenwidth/3+20,screenheight/20,1);
1128 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1130 glColor4f(0.0,0.4,0.0,0.7);
1131 float bar=((float)player[0].damage)/player[0].damagetolerance;
1133 glVertex3f((bar<1?bar:1),0,0.0f);
1134 glVertex3f(1,0,0.0f);
1135 glVertex3f(1,1,0.0f);
1136 glVertex3f((bar<1?bar:1),1,0.0f);
1138 glColor4f(0.1,0.0,0.0,1);
1139 bar = ((float)player[0].bloodloss)/player[0].damagetolerance;
1141 glVertex3f(0,0,0.0f);
1142 glVertex3f((bar<1?bar:1),0,0.0f);
1143 glVertex3f((bar<1?bar:1),1,0.0f);
1144 glVertex3f(0,1,0.0f);
1146 glColor4f(0.4,0.0,0.0,0.7);
1147 bar = ((float)player[0].damage)/player[0].damagetolerance;
1149 glVertex3f(0,0,0.0f);
1150 glVertex3f((bar<1?bar:1),0,0.0f);
1151 glVertex3f((bar<1?bar:1),1,0.0f);
1152 glVertex3f(0,1,0.0f);
1154 glColor4f(0.4,0.0,0.0,0.7);
1155 bar = ((float)player[0].permanentdamage)/player[0].damagetolerance;
1157 glVertex3f(0,0,0.0f);
1158 glVertex3f((bar<1?bar:1),0,0.0f);
1159 glVertex3f((bar<1?bar:1),1,0.0f);
1160 glVertex3f(0,1,0.0f);
1162 glColor4f(0.4,0.0,0.0,0.7);
1163 bar = ((float)player[0].superpermanentdamage)/player[0].damagetolerance;
1165 glVertex3f(0,0,0.0f);
1166 glVertex3f((bar<1?bar:1),0,0.0f);
1167 glVertex3f((bar<1?bar:1),1,0.0f);
1168 glVertex3f(0,1,0.0f);
1170 glColor4f(0.0,0.0,0.0,0.7);
1172 glBegin(GL_LINE_STRIP);
1173 glVertex3f(0,0,0.0f);
1174 glVertex3f(1,0,0.0f);
1175 glVertex3f(1,1,0.0f);
1176 glVertex3f(0,1,0.0f);
1177 glVertex3f(0,0,0.0f);
1180 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1181 glPopMatrix(); // Restore The Old Projection Matrix
1182 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1183 glPopMatrix(); // Restore The Old Projection Matrix
1184 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1185 glEnable(GL_CULL_FACE);
1186 glDisable(GL_BLEND);
1188 glEnable(GL_TEXTURE_2D);
1190 // writing the numbers :
1191 sprintf (string, "Damages : %d/%d (%d)",(int)(player[0].damage),(int)(player[0].damagetolerance),(int)(player[0].bloodloss));
1193 text->glPrintOutline(1024/40-4,768/16-4+768*14/16-40,string,1,1.5*1.25,1024,768);
1195 text->glPrint(1024/40,768/16+768*14/16-40,string,1,1.5,1024,768);
1199 glColor4f(.5,.5,.5,1);
1202 if((texttoggle||editorenabled)&&debugmode&&!mainmenu){
1203 sprintf (string, "The framespersecond is %d.",(int)(fps));
1204 text->glPrint(10,30,string,0,.8,1024,768);
1206 sprintf (string, "Name: %s", registrationname);
1207 text->glPrint(10,260,string,0,.8,1024,768);
1211 sprintf (string, "Map editor enabled.");
1213 sprintf (string, "Map editor disabled.");
1214 text->glPrint(10,60,string,0,.8,1024,768);
1216 sprintf (string, "Object size: %f",editorsize);
1217 text->glPrint(10,75,string,0,.8,1024,768);
1218 if(editorrotation>=0)sprintf (string, "Object rotation: %f",editorrotation);
1219 else sprintf (string, "Object rotation: Random");
1220 text->glPrint(10,90,string,0,.8,1024,768);
1221 if(editorrotation2>=0)sprintf (string, "Object rotation2: %f",editorrotation2);
1222 else sprintf (string, "Object rotation2: Random");
1223 text->glPrint(10,105,string,0,.8,1024,768);
1224 sprintf (string, "Object type: %d",editortype);
1225 text->glPrint(10,120,string,0,.8,1024,768);
1226 switch(editortype) {
1228 sprintf (string, "(box)");
1231 sprintf (string, "(tree)");
1234 sprintf (string, "(wall)");
1237 sprintf (string, "(weird)");
1240 sprintf (string, "(spike)");
1243 sprintf (string, "(rock)");
1246 sprintf (string, "(bush)");
1249 sprintf (string, "(tunnel)");
1252 sprintf (string, "(chimney)");
1255 sprintf (string, "(platform)");
1258 sprintf (string, "(cool)");
1261 sprintf (string, "(fire)");
1264 text->glPrint(130,120,string,0,.8,1024,768);
1266 sprintf (string, "Numplayers: %d",numplayers);
1267 text->glPrint(10,155,string,0,.8,1024,768);
1268 sprintf (string, "Player %d: numwaypoints: %d",numplayers,player[numplayers-1].numwaypoints);
1269 text->glPrint(10,140,string,0,.8,1024,768);
1271 sprintf (string, "Difficulty: %d",difficulty);
1272 text->glPrint(10,240,string,0,.8,1024,768);
1277 if(drawmode==glowmode){
1278 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1279 glDisable(GL_CULL_FACE);
1280 glDisable(GL_LIGHTING);
1281 glDisable(GL_TEXTURE_2D);
1283 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1284 glPushMatrix(); // Store The Projection Matrix
1285 glLoadIdentity(); // Reset The Projection Matrix
1286 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1287 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1288 glPushMatrix(); // Store The Modelview Matrix
1289 glLoadIdentity(); // Reset The Modelview Matrix
1290 glScalef(screenwidth,screenheight,1);
1291 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1293 glColor4f(0,0,0,.5);
1295 glVertex3f(0, 0, 0.0f);
1296 glVertex3f(256, 0, 0.0f);
1297 glVertex3f(256, 256, 0.0f);
1298 glVertex3f(0, 256, 0.0f);
1300 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1301 glPopMatrix(); // Restore The Old Projection Matrix
1302 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1303 glPopMatrix(); // Restore The Old Projection Matrix
1304 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1305 glEnable(GL_CULL_FACE);
1306 glDisable(GL_BLEND);
1310 if((((blackout&&damageeffects)||(player[0].bloodloss>0&&damageeffects&&player[0].blooddimamount>0)||player[0].dead)&&!cameramode)||console){
1311 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1312 glDisable(GL_CULL_FACE);
1313 glDisable(GL_LIGHTING);
1314 glDisable(GL_TEXTURE_2D);
1316 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1317 glPushMatrix(); // Store The Projection Matrix
1318 glLoadIdentity(); // Reset The Projection Matrix
1319 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1320 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1321 glPushMatrix(); // Store The Modelview Matrix
1322 glLoadIdentity(); // Reset The Modelview Matrix
1323 glScalef(screenwidth,screenheight,1);
1324 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1326 if(player[0].dead)blackout+=multiplier*3;
1327 if(player[0].dead==1)blackout=.4f;
1328 if(player[0].dead==2&&blackout>.6)blackout=.6;
1329 glColor4f(0,0,0,blackout);
1330 if(!player[0].dead){
1331 if((player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5))*.3<.3){
1332 glColor4f(0,0,0,player[0].blooddimamount*player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5)*.3);
1333 blackout=player[0].blooddimamount*player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5)*.3;
1336 glColor4f(0,0,0,player[0].blooddimamount*.3);
1337 blackout=player[0].blooddimamount*.3;
1340 if(console)glColor4f(.7,0,0,.2);
1342 glVertex3f(0, 0, 0.0f);
1343 glVertex3f(256, 0, 0.0f);
1344 glVertex3f(256, 256, 0.0f);
1345 glVertex3f(0, 256, 0.0f);
1347 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1348 glPopMatrix(); // Restore The Old Projection Matrix
1349 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1350 glPopMatrix(); // Restore The Old Projection Matrix
1351 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1352 glEnable(GL_CULL_FACE);
1353 glDisable(GL_BLEND);
1357 if(flashamount>0&&damageeffects) {
1358 if(flashamount>1)flashamount=1;
1359 if(flashdelay<=0)flashamount-=multiplier;
1361 if(flashamount<0)flashamount=0;
1362 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1363 glDisable(GL_CULL_FACE);
1364 glDisable(GL_LIGHTING);
1366 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1367 glPushMatrix(); // Store The Projection Matrix
1368 glLoadIdentity(); // Reset The Projection Matrix
1369 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1370 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1371 glPushMatrix(); // Store The Modelview Matrix
1372 glLoadIdentity(); // Reset The Modelview Matrix
1373 glScalef(screenwidth,screenheight,1);
1374 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1376 glColor4f(flashr,flashg,flashb,flashamount);
1378 glVertex3f(0, 0, 0.0f);
1379 glVertex3f(256, 0, 0.0f);
1380 glVertex3f(256, 256, 0.0f);
1381 glVertex3f(0, 256, 0.0f);
1383 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1384 glPopMatrix(); // Restore The Old Projection Matrix
1385 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1386 glPopMatrix(); // Restore The Old Projection Matrix
1387 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1388 glEnable(GL_CULL_FACE);
1389 glDisable(GL_BLEND);
1395 glEnable(GL_TEXTURE_2D);
1398 sprintf (string, " ]");
1399 text->glPrint(10,30+screenheight-330,string,0,1,screenwidth,screenheight);
1401 sprintf (string, "_");
1402 text->glPrint(30+(float)(displayselected)*10,30+(screenheight-330),string,0,1,screenwidth,screenheight);
1406 if((i!=0||chatting)&&displaytime[i]<4)
1407 for(j=0;j<displaychars[i];j++) {
1408 glColor4f(1,1,1,4-displaytime[i]);
1409 if(j<displaychars[i]) {
1410 sprintf (string, "%c",displaytext[i][j]);
1411 text->glPrint(30+j*10,30+i*20+(screenheight-330),string,0,1,screenwidth,screenheight);
1416 if(minimap&&indialogue==-1){
1417 float mapviewdist = 20000;
1419 glDisable(GL_DEPTH_TEST);
1420 glColor3f (1.0, 1.0, 1.0); // no coloring
1422 glEnable(GL_TEXTURE_2D);
1423 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1424 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1425 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1426 glDisable(GL_CULL_FACE);
1427 glDisable(GL_LIGHTING);
1429 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1430 glPushMatrix(); // Store The Projection Matrix
1431 glLoadIdentity(); // Reset The Projection Matrix
1432 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1433 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1434 glPushMatrix(); // Store The Modelview Matrix
1435 glLoadIdentity(); // Reset The Modelview Matrix
1436 glScalef((float)screenwidth/2,(float)screenwidth/2,1);
1437 glTranslatef(1.75,.25,0);
1438 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1446 int numliveplayers=0;
1448 for(i=0;i<numplayers;i++){
1449 if(!player[i].dead) numliveplayers++;
1454 for(i=0;i<objects.numobjects;i++){
1455 if(objects.type[i]==treetrunktype||objects.type[i]==boxtype){
1456 center+=objects.position[i];
1460 for(i=0;i<numplayers;i++){
1461 if(!player[i].dead)center+=player[i].coords;
1463 center/=numadd+numliveplayers;
1465 center=player[0].coords;
1467 float maxdistance=0;
1469 //~ int whichclosest;
1470 for(i=0;i<objects.numobjects;i++){
1471 tempdist=findDistancefast(¢er,&objects.position[i]);
1472 if(tempdist>maxdistance){
1474 maxdistance=tempdist;
1477 for(i=0;i<numplayers;i++){
1478 if(!player[i].dead){
1479 tempdist=findDistancefast(¢er,&player[i].coords);
1480 if(tempdist>maxdistance){
1482 maxdistance=tempdist;
1486 radius=fast_sqrt(maxdistance);
1490 glScalef(.25/radius*256*terrain.scale*.4,.25/radius*256*terrain.scale*.4,1);
1492 glScalef(1/(1/radius*256*terrain.scale*.4),1/(1/radius*256*terrain.scale*.4),1);
1494 glRotatef(player[0].lookrotation*-1+180,0,0,1);
1495 glTranslatef(-(center.x/terrain.scale/256*-2+1),(center.z/terrain.scale/256*-2+1),0);
1496 for(i=0;i<objects.numobjects;i++){
1497 if(objects.type[i]==treetrunktype){
1498 distcheck=findDistancefast(&player[0].coords,&objects.position[i]);
1499 if(distcheck<mapviewdist){
1500 glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
1501 glColor4f(0,.3,0,opac*(1-distcheck/mapviewdist));
1503 glTranslatef(objects.position[i].x/terrain.scale/256*-2+1,objects.position[i].z/terrain.scale/256*2-1,0);
1504 glRotatef(objects.rotation[i],0,0,1);
1505 glScalef(.003,.003,.003);
1508 glVertex3f(-1, -1, 0.0f);
1510 glVertex3f(1, -1, 0.0f);
1512 glVertex3f(1, 1, 0.0f);
1514 glVertex3f(-1, 1, 0.0f);
1519 if(objects.type[i]==boxtype){
1520 distcheck=findDistancefast(&player[0].coords,&objects.position[i]);
1521 if(distcheck<mapviewdist){
1522 glBindTexture( GL_TEXTURE_2D, Mapboxtexture);
1523 glColor4f(.4,.4,.4,opac*(1-distcheck/mapviewdist));
1525 glTranslatef(objects.position[i].x/terrain.scale/256*-2+1,objects.position[i].z/terrain.scale/256*2-1,0);
1526 glRotatef(objects.rotation[i],0,0,1);
1527 glScalef(.01*objects.scale[i],.01*objects.scale[i],.01*objects.scale[i]);
1530 glVertex3f(-1, -1, 0.0f);
1532 glVertex3f(1, -1, 0.0f);
1534 glVertex3f(1, 1, 0.0f);
1536 glVertex3f(-1, 1, 0.0f);
1543 glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
1544 for(i=0;i<numboundaries;i++){
1545 glColor4f(0,0,0,opac/3);
1547 glTranslatef(boundary[i].x/terrain.scale/256*-2+1,boundary[i].z/terrain.scale/256*2-1,0);
1548 glScalef(.002,.002,.002);
1551 glVertex3f(-1, -1, 0.0f);
1553 glVertex3f(1, -1, 0.0f);
1555 glVertex3f(1, 1, 0.0f);
1557 glVertex3f(-1, 1, 0.0f);
1562 for(i=0;i<numplayers;i++){
1563 distcheck=findDistancefast(&player[0].coords,&player[i].coords);
1564 if(distcheck<mapviewdist){
1566 glBindTexture( GL_TEXTURE_2D, Maparrowtexture);
1567 if(i==0)glColor4f(1,1,1,opac);
1568 else if(player[i].dead==2||player[i].howactive>typesleeping)glColor4f(0,0,0,opac*(1-distcheck/mapviewdist));
1569 else if(player[i].dead)glColor4f(.3,.3,.3,opac*(1-distcheck/mapviewdist));
1570 else if(player[i].aitype==attacktypecutoff)glColor4f(1,0,0,opac*(1-distcheck/mapviewdist));
1571 else if(player[i].aitype==passivetype)glColor4f(0,1,0,opac*(1-distcheck/mapviewdist));
1572 else glColor4f(1,1,0,1);
1573 glTranslatef(player[i].coords.x/terrain.scale/256*-2+1,player[i].coords.z/terrain.scale/256*2-1,0);
1574 glRotatef(player[i].rotation+180,0,0,1);
1575 glScalef(.005,.005,.005);
1578 glVertex3f(-1, -1, 0.0f);
1580 glVertex3f(1, -1, 0.0f);
1582 glVertex3f(1, 1, 0.0f);
1584 glVertex3f(-1, 1, 0.0f);
1590 glDisable(GL_TEXTURE_2D);
1591 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1592 glPopMatrix(); // Restore The Old Projection Matrix
1593 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1594 glPopMatrix(); // Restore The Old Projection Matrix
1595 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1596 glEnable(GL_CULL_FACE);
1597 glDisable(GL_BLEND);
1601 if(loading&&!stealthloading&&(!campaign||player[0].dead)){
1602 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1603 glDisable(GL_CULL_FACE);
1604 glDisable(GL_LIGHTING);
1605 glDisable(GL_TEXTURE_2D);
1607 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1608 glPushMatrix(); // Store The Projection Matrix
1609 glLoadIdentity(); // Reset The Projection Matrix
1610 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1611 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1612 glPushMatrix(); // Store The Modelview Matrix
1613 glLoadIdentity(); // Reset The Modelview Matrix
1614 glScalef(screenwidth,screenheight,1);
1615 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1617 glColor4f(0,0,0,.7);
1619 glVertex3f(0, 0, 0.0f);
1620 glVertex3f(256, 0, 0.0f);
1621 glVertex3f(256, 256, 0.0f);
1622 glVertex3f(0, 256, 0.0f);
1624 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1625 glPopMatrix(); // Restore The Old Projection Matrix
1626 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1627 glPopMatrix(); // Restore The Old Projection Matrix
1628 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1629 glEnable(GL_CULL_FACE);
1630 glDisable(GL_BLEND);
1634 glDisable(GL_DEPTH_TEST);
1635 glColor3f (1.0, 1.0, 1.0); // no coloring
1637 glEnable(GL_TEXTURE_2D);
1642 glEnable(GL_TEXTURE_2D);
1644 sprintf (string, "Loading...");
1645 text->glPrint(1024/2-90,768/2,string,1,2,1024,768);
1648 //if(ismotionblur)drawmode=motionblurmode;
1649 drawmode=normalmode;
1652 if(winfreeze&&!campaign){
1653 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1654 glDisable(GL_CULL_FACE);
1655 glDisable(GL_LIGHTING);
1656 glDisable(GL_TEXTURE_2D);
1658 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1659 glPushMatrix(); // Store The Projection Matrix
1660 glLoadIdentity(); // Reset The Projection Matrix
1661 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1662 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1663 glPushMatrix(); // Store The Modelview Matrix
1664 glLoadIdentity(); // Reset The Modelview Matrix
1665 glScalef(screenwidth,screenheight,1);
1666 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1668 glColor4f(0,0,0,.4);
1670 glVertex3f(0, 0, 0.0f);
1671 glVertex3f(256, 0, 0.0f);
1672 glVertex3f(256, 256, 0.0f);
1673 glVertex3f(0, 256, 0.0f);
1675 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1676 glPopMatrix(); // Restore The Old Projection Matrix
1677 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1678 glPopMatrix(); // Restore The Old Projection Matrix
1679 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1680 glEnable(GL_CULL_FACE);
1681 glDisable(GL_BLEND);
1685 glDisable(GL_DEPTH_TEST);
1686 glColor3f (1.0, 1.0, 1.0); // no coloring
1688 glEnable(GL_TEXTURE_2D);
1690 //Win Screen Won Victory
1692 glEnable(GL_TEXTURE_2D);
1694 sprintf (string, "Level Cleared!");
1695 text->glPrintOutlined(1024/2-strlen(string)*10,768*7/8,string,1,2,1024,768);
1697 sprintf (string, "Score: %d",(int)(bonustotal-startbonustotal));
1698 text->glPrintOutlined(1024/30,768*6/8,string,1,2,1024,768);
1701 sprintf (string, "Press Escape or Space to continue");
1703 sprintf (string, "Press Escape to return to menu or Space to continue");
1704 text->glPrintOutlined(640/2-strlen(string)*5,480*1/16,string,1,1,640,480);
1708 for(i=0;i<255;i++)string[i]='\0';
1709 sprintf (temp, "Time: %d:",(int)(((int)leveltime-(int)(leveltime)%60)/60));
1710 strcat(string,temp);
1711 if((int)(leveltime)%60<10)strcat(string,"0");
1712 sprintf (temp, "%d",(int)(leveltime)%60);
1713 strcat(string,temp);
1714 text->glPrintOutlined(1024/30,768*6/8-40,string,1,2,1024,768);
1717 int awards[award_count];
1718 int numawards = award_awards(awards);
1720 for (i = 0; i < numawards && i < 6; i++)
1721 text->glPrintOutlined(1024/30,768*6/8-90-40*i,award_names[awards[i]],1,2,1024,768);
1724 if(drawmode!=normalmode){
1725 glEnable(GL_TEXTURE_2D);
1727 if(!drawtoggle||drawmode!=realmotionblurmode||(drawtoggle==2||change==1)){
1730 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
1731 GLfloat subtractColor[4] = { 0.5, 0.5, 0.5, 0.0 };
1732 glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, subtractColor);
1733 //glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_SUBTRACT);
1734 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE);
1735 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_CONSTANT_EXT);
1736 glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 2.0f);
1738 glBindTexture( GL_TEXTURE_2D, screentexture);
1739 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1742 if((drawtoggle||change==1)&&drawmode==realmotionblurmode){
1744 glBindTexture( GL_TEXTURE_2D, screentexture2);
1745 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1747 if(!screentexture2){
1748 glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
1750 glGenTextures( 1, &screentexture2 );
1751 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
1753 glEnable(GL_TEXTURE_2D);
1754 glBindTexture( GL_TEXTURE_2D, screentexture2);
1755 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
1756 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
1758 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
1764 glClear(GL_DEPTH_BUFFER_BIT);
1765 ReSizeGLScene(90,.1f);
1766 glViewport(0,0,screenwidth,screenheight);
1768 if(drawmode!=normalmode){
1769 glDisable(GL_DEPTH_TEST);
1770 if(drawmode==motionblurmode){
1771 glDrawBuffer(GL_FRONT);
1772 glReadBuffer(GL_BACK);
1774 glColor3f (1.0, 1.0, 1.0); // no coloring
1776 glEnable(GL_TEXTURE_2D);
1777 glBindTexture( GL_TEXTURE_2D, screentexture);
1778 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1779 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1780 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1781 glDisable(GL_CULL_FACE);
1782 glDisable(GL_LIGHTING);
1784 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1785 glPushMatrix(); // Store The Projection Matrix
1786 glLoadIdentity(); // Reset The Projection Matrix
1787 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1788 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1789 glPushMatrix(); // Store The Modelview Matrix
1790 glLoadIdentity(); // Reset The Modelview Matrix
1791 glScalef((float)screenwidth/2,(float)screenheight/2,1);
1792 glTranslatef(1,1,0);
1793 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1795 if(drawmode==motionblurmode){
1796 if(motionbluramount<.2)motionbluramount=.2;
1797 //glColor4f(1,1,1,fast_sqrt(multiplier)*2.9*motionbluramount);
1798 glColor4f(1,1,1,motionbluramount);
1802 glVertex3f(-1, -1, 0.0f);
1803 glTexCoord2f(texcoordwidth,0);
1804 glVertex3f(1, -1, 0.0f);
1805 glTexCoord2f(texcoordwidth,texcoordheight);
1806 glVertex3f(1, 1, 0.0f);
1807 glTexCoord2f(0,texcoordheight);
1808 glVertex3f(-1, 1, 0.0f);
1812 if(drawmode==realmotionblurmode){
1813 glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
1814 glClear(GL_COLOR_BUFFER_BIT);
1815 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
1816 glBindTexture( GL_TEXTURE_2D, screentexture);
1817 glColor4f(1,1,1,.5);
1821 glVertex3f(-1, -1, 0.0f);
1822 glTexCoord2f(texcoordwidth,0);
1823 glVertex3f(1, -1, 0.0f);
1824 glTexCoord2f(texcoordwidth,texcoordheight);
1825 glVertex3f(1, 1, 0.0f);
1826 glTexCoord2f(0,texcoordheight);
1827 glVertex3f(-1, 1, 0.0f);
1830 glBindTexture( GL_TEXTURE_2D, screentexture2);
1831 glColor4f(1,1,1,.5);
1835 glVertex3f(-1, -1, 0.0f);
1836 glTexCoord2f(texcoordwidth,0);
1837 glVertex3f(1, -1, 0.0f);
1838 glTexCoord2f(texcoordwidth,texcoordheight);
1839 glVertex3f(1, 1, 0.0f);
1840 glTexCoord2f(0,texcoordheight);
1841 glVertex3f(-1, 1, 0.0f);
1844 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1846 if(drawmode==doublevisionmode){
1847 static float crosseyedness;
1848 crosseyedness=abs(player[0].damage-player[0].superpermanentdamage-(player[0].damagetolerance-player[0].superpermanentdamage)*1/2)/30;
1849 if(crosseyedness>1)crosseyedness=1;
1850 if(crosseyedness<0)crosseyedness=0;
1852 glDisable(GL_BLEND);
1857 glVertex3f(-1, -1, 0.0f);
1858 glTexCoord2f(texcoordwidth,0);
1859 glVertex3f(1, -1, 0.0f);
1860 glTexCoord2f(texcoordwidth,texcoordheight);
1861 glVertex3f(1, 1, 0.0f);
1862 glTexCoord2f(0,texcoordheight);
1863 glVertex3f(-1, 1, 0.0f);
1867 glColor4f(1,1,1,.5);
1870 glTranslatef(.015*crosseyedness,0,0);
1874 glVertex3f(-1, -1, 0.0f);
1875 glTexCoord2f(texcoordwidth,0);
1876 glVertex3f(1, -1, 0.0f);
1877 glTexCoord2f(texcoordwidth,texcoordheight);
1878 glVertex3f(1, 1, 0.0f);
1879 glTexCoord2f(0,texcoordheight);
1880 glVertex3f(-1, 1, 0.0f);
1885 if(drawmode==glowmode){
1886 glColor4f(.5,.5,.5,.5);
1888 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
1890 glTranslatef(.01,0,0);
1893 glVertex3f(-1, -1, 0.0f);
1894 glTexCoord2f(texcoordwidth,0);
1895 glVertex3f(1, -1, 0.0f);
1896 glTexCoord2f(texcoordwidth,texcoordheight);
1897 glVertex3f(1, 1, 0.0f);
1898 glTexCoord2f(0,texcoordheight);
1899 glVertex3f(-1, 1, 0.0f);
1903 glTranslatef(-.01,0,0);
1906 glVertex3f(-1, -1, 0.0f);
1907 glTexCoord2f(texcoordwidth,0);
1908 glVertex3f(1, -1, 0.0f);
1909 glTexCoord2f(texcoordwidth,texcoordheight);
1910 glVertex3f(1, 1, 0.0f);
1911 glTexCoord2f(0,texcoordheight);
1912 glVertex3f(-1, 1, 0.0f);
1916 glTranslatef(.0,.01,0);
1919 glVertex3f(-1, -1, 0.0f);
1920 glTexCoord2f(texcoordwidth,0);
1921 glVertex3f(1, -1, 0.0f);
1922 glTexCoord2f(texcoordwidth,texcoordheight);
1923 glVertex3f(1, 1, 0.0f);
1924 glTexCoord2f(0,texcoordheight);
1925 glVertex3f(-1, 1, 0.0f);
1929 glTranslatef(0,-.01,0);
1932 glVertex3f(-1, -1, 0.0f);
1933 glTexCoord2f(texcoordwidth,0);
1934 glVertex3f(1, -1, 0.0f);
1935 glTexCoord2f(texcoordwidth,texcoordheight);
1936 glVertex3f(1, 1, 0.0f);
1937 glTexCoord2f(0,texcoordheight);
1938 glVertex3f(-1, 1, 0.0f);
1942 if(drawmode==radialzoommode){
1944 //glRotatef((float)i*.1,0,0,1);
1945 glColor4f(1,1,1,1/((float)i+1));
1947 glScalef(1+(float)i*.01,1+(float)i*.01,1);
1950 glVertex3f(-1, -1, 0.0f);
1951 glTexCoord2f(texcoordwidth,0);
1952 glVertex3f(1, -1, 0.0f);
1953 glTexCoord2f(texcoordwidth,texcoordheight);
1954 glVertex3f(1, 1, 0.0f);
1955 glTexCoord2f(0,texcoordheight);
1956 glVertex3f(-1, 1, 0.0f);
1961 glDisable(GL_TEXTURE_2D);
1962 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1963 glPopMatrix(); // Restore The Old Projection Matrix
1964 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1965 glPopMatrix(); // Restore The Old Projection Matrix
1966 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1967 glEnable(GL_CULL_FACE);
1968 glDisable(GL_BLEND);
1973 glEnable(GL_TEXTURE_2D);
1976 if(consoleselected>=60)
1977 offset=consoleselected-60;
1978 sprintf (string, " ]");
1979 text->glPrint(10,30,string,0,1,1024,768);
1981 sprintf (string, "_");
1982 text->glPrint(30+(float)(consoleselected)*10-offset*10,30,string,0,1,1024,768);
1985 for(j=0;j<consolechars[i];j++){
1986 glColor4f(1,1,1,1-(float)(i)/16);
1987 if(j<consolechars[i]){
1988 sprintf (string, "%c",consoletext[i][j]);
1989 text->glPrint(30+j*10-offset*10,30+i*20,string,0,1,1024,768);
1995 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)){
1996 multiplier=tempmult;
2003 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)){
2004 tempmult=multiplier;
2009 if ( side == stereoRight || side == stereoCenter ) {
2010 if(drawmode!=motionblurmode||mainmenu){
2015 //myassert(glGetError() == GL_NO_ERROR);
2016 glDrawBuffer(GL_BACK);
2017 glReadBuffer(GL_BACK);
2022 if(drawtoggle==2)drawtoggle=0;
2024 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)){
2025 multiplier=tempmult;
2027 //Jordan fixed your warning!
2031 vector<string> Game::ListCampaigns() {
2032 DIR *campaigns = opendir(ConvertFileName(":Data:Campaigns"));
2033 struct dirent *campaign = NULL;
2035 perror("Problem while loading campaigns");
2036 cerr << "campaign folder was : " << ConvertFileName(":Data:Campaigns") << endl;
2039 vector<string> campaignNames;
2040 while ((campaign = readdir(campaigns)) != NULL) {
2041 string name(campaign->d_name);
2044 if(!name.compare(name.length()-4,4,".txt")) {
2045 campaignNames.push_back(name.substr(0,name.length()-4));
2048 closedir(campaigns);
2049 return campaignNames;
2052 void Game::LoadCampaign() {
2055 ifstream ipstream(ConvertFileName((":Data:Campaigns:"+accountactive->getCurrentCampaign()+".txt").c_str()));
2056 ipstream.ignore(256,':');
2058 ipstream >> numlevels;
2059 campaignlevels.clear();
2060 for(int i=0;i<numlevels;i++) {
2063 campaignlevels.push_back(cl);
2067 ifstream test(ConvertFileName((":Data:Textures:"+accountactive->getCurrentCampaign()+":World.png").c_str()));
2069 LoadTexture((":Data:Textures:"+accountactive->getCurrentCampaign()+":World.png").c_str(),&Mainmenuitems[7],0,0);
2071 LoadTexture(":Data:Textures:World.png",&Mainmenuitems[7],0,0);
2074 if(accountactive->getCampaignChoicesMade()==0) {
2075 accountactive->setCampaignScore(0);
2076 accountactive->resetFasttime();
2080 void Game::DrawMenu() {
2081 // !!! FIXME: hack: clamp framerate in menu so text input works correctly on fast systems.
2084 glDrawBuffer(GL_BACK);
2085 glReadBuffer(GL_BACK);
2086 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
2087 ReSizeGLScene(90,.1f);
2089 //draw menu background
2090 glClear(GL_DEPTH_BUFFER_BIT);
2091 glEnable(GL_ALPHA_TEST);
2092 glAlphaFunc(GL_GREATER, 0.001f);
2093 glEnable(GL_TEXTURE_2D);
2094 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
2095 glDisable(GL_CULL_FACE);
2096 glDisable(GL_LIGHTING);
2098 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2099 glPushMatrix(); // Store The Projection Matrix
2100 glLoadIdentity(); // Reset The Projection Matrix
2101 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
2102 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2103 glPushMatrix(); // Store The Modelview Matrix
2104 glLoadIdentity(); // Reset The Modelview Matrix
2105 glTranslatef(screenwidth/2,screenheight/2,0);
2107 glScalef((float)screenwidth/2,(float)screenheight/2,1);
2108 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
2109 glDisable(GL_BLEND);
2110 glColor4f(0,0,0,1.0);
2111 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2112 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2113 glDisable(GL_TEXTURE_2D);
2115 glVertex3f(-1,-1,0);
2116 glVertex3f(+1,-1,0);
2117 glVertex3f(+1,+1,0);
2118 glVertex3f(-1,+1,0);
2121 glColor4f(0.4,0.4,0.4,1.0);
2122 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2123 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2124 glEnable(GL_TEXTURE_2D);
2125 glBindTexture( GL_TEXTURE_2D, Mainmenuitems[4]);
2128 glVertex3f(-1,-1,0);
2130 glVertex3f(+1,-1,0);
2132 glVertex3f(+1,+1,0);
2134 glVertex3f(-1,+1,0);
2138 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2140 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2144 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2145 glPushMatrix(); // Store The Projection Matrix
2146 glLoadIdentity(); // Reset The Projection Matrix
2147 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
2148 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2149 glPushMatrix(); // Store The Modelview Matrix
2150 glLoadIdentity(); // Reset The Modelview Matrix
2151 glEnable(GL_TEXTURE_2D);
2156 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2158 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2161 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2162 glPushMatrix(); // Store The Projection Matrix
2163 glLoadIdentity(); // Reset The Projection Matrix
2164 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
2165 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2166 glPushMatrix(); // Store The Modelview Matrix
2167 glLoadIdentity(); // Reset The Modelview Matrix
2168 glTranslatef(screenwidth/2,screenheight/2,0);
2170 glScalef((float)screenwidth/2,(float)screenheight/2,1);
2171 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
2173 glEnable(GL_TEXTURE_2D);
2175 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2176 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2178 if(!waiting) { // hide the cursor while waiting for a key
2180 glTranslatef(mousecoordh-screenwidth/2,mousecoordv*-1+screenheight/2,0);
2181 glScalef((float)screenwidth/64,(float)screenwidth/64,1);
2182 glTranslatef(1,-1,0);
2183 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
2185 glBindTexture( GL_TEXTURE_2D, cursortexture);
2187 //glScalef(.25,.25,.25);
2190 glVertex3f(-1, -1, 0.0f);
2192 glVertex3f(1, -1, 0.0f);
2194 glVertex3f(1, 1, 0.0f);
2196 glVertex3f(-1, 1, 0.0f);
2202 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2209 if(flashamount>1)flashamount=1;
2210 if(flashdelay<=0)flashamount-=multiplier;
2212 if(flashamount<0)flashamount=0;
2213 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
2214 glDisable(GL_CULL_FACE);
2215 glDisable(GL_LIGHTING);
2216 glDisable(GL_TEXTURE_2D);
2218 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2219 glPushMatrix(); // Store The Projection Matrix
2220 glLoadIdentity(); // Reset The Projection Matrix
2221 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
2222 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2223 glPushMatrix(); // Store The Modelview Matrix
2224 glLoadIdentity(); // Reset The Modelview Matrix
2225 glScalef(screenwidth,screenheight,1);
2226 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
2228 glColor4f(flashr,flashg,flashb,flashamount);
2230 glVertex3f(0, 0, 0.0f);
2231 glVertex3f(256, 0, 0.0f);
2232 glVertex3f(256, 256, 0.0f);
2233 glVertex3f(0, 256, 0.0f);
2235 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2236 glPopMatrix(); // Restore The Old Projection Matrix
2237 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2238 glPopMatrix(); // Restore The Old Projection Matrix
2239 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
2240 glEnable(GL_CULL_FACE);
2241 glDisable(GL_BLEND);