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"
29 extern int environment;
30 extern float texscale;
32 extern Terrain terrain;
33 //extern Sprites sprites;
34 extern float multiplier;
36 extern float viewdistance;
37 extern float fadestart;
38 extern float screenwidth,screenheight;
39 extern int kTextureSize;
40 extern FRUSTUM frustum;
42 extern Objects objects;
44 extern float usermousesensitivity;
46 extern float camerashake;
48 extern float slomodelay;
49 extern bool ismotionblur;
51 extern float blackout;
52 extern bool damageeffects;
54 extern bool texttoggle;
55 extern float blurness;
56 extern float targetblurness;
57 extern float playerdist;
58 extern bool cellophane;
60 extern float flashamount,flashr,flashg,flashb;
61 extern int flashdelay;
63 extern float motionbluramount;
65 extern bool alwaysblur;
67 extern bool tilt2weird;
68 extern bool tiltweird;
70 extern bool proportionweird;
71 extern bool vertexweird[6];
72 extern bool velocityblur;
73 extern bool debugmode;
75 extern int bloodtoggle;
76 extern int difficulty;
79 //extern int texdetail;
80 extern float texdetail;
81 extern bool musictoggle;
82 extern int tutoriallevel;
83 extern float smoketex;
84 extern float tutorialstagetime;
85 extern float tutorialmaxtime;
86 extern int tutorialstage;
87 extern bool againbonus;
88 extern float damagedealt;
89 extern bool invertmouse;
91 extern int numhotspots;
92 extern int killhotspot;
93 extern XYZ hotspot[40];
94 extern int hotspottype[40];
95 extern float hotspotsize[40];
96 extern char hotspottext[40][256];
97 extern int currenthotspot;;
100 extern bool winfreeze;
102 extern float menupulse;
104 extern bool gamestart;
106 extern bool gamestarted;
108 extern bool showdamagebar;
113 int numboundaries = 0;
120 normalmode, motionblurmode, radialzoommode,
121 realmotionblurmode, doublevisionmode, glowmode,
124 void Game::flash() { // shouldn't be that way, these should be attributes and Person class should not change rendering.
134 /*********************> DrawGLScene() <*****/
135 int Game::DrawGLScene(StereoSide side)
137 static float texcoordwidth,texcoordheight;
138 static float texviewwidth, texviewheight;
140 static GLubyte color;
141 static XYZ checkpoint;
142 static float tempmult;
144 static char string[256]="";
145 static char string2[256]="";
146 static char string3[256]="";
147 static int drawmode = 0;
149 if ( stereomode == stereoAnaglyph ) {
151 case stereoLeft: glColorMask( 0.0, 1.0, 1.0, 1.0 ); break;
152 case stereoRight: glColorMask( 1.0, 0.0, 0.0, 1.0 ); break;
155 glColorMask( 1.0, 1.0, 1.0, 1.0 );
157 if ( stereomode == stereoHorizontalInterlaced || stereomode == stereoVerticalInterlaced ) {
158 glStencilFunc(side == stereoLeft ? GL_NOTEQUAL : GL_EQUAL, 0x01, 0x01);
162 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)){
169 numboundaries=mapradius*2;
170 if(numboundaries>360)numboundaries=360;
171 for(i=0;i<numboundaries;i++){
174 boundary[i]=mapcenter+DoRotation(boundary[i]*mapradius,0,i*(360/((float)(numboundaries))),0);
183 int olddrawmode=drawmode;
184 if(ismotionblur&&!loading){
185 if((findLengthfast(&player[0].velocity)>200)&&velocityblur&&!cameramode){
186 drawmode=motionblurmode;
187 motionbluramount=200/(findLengthfast(&player[0].velocity));
190 if(player[0].damage-player[0].superpermanentdamage>(player[0].damagetolerance-player[0].superpermanentdamage)*1/2&&damageeffects&&!cameramode){
191 drawmode=doublevisionmode;
198 drawmode=motionblurmode;
200 slomodelay-=multiplier;
206 if((!changed&&!slomo)||loading){
208 if(ismotionblur&&(/*fps>100||*/alwaysblur)){
209 if(olddrawmode!=realmotionblurmode)
213 drawmode=realmotionblurmode;
214 }else if(olddrawmode==realmotionblurmode)
220 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted))
222 if((freeze||winfreeze)&&ismotionblur&&!mainmenu)
223 drawmode=radialzoommode;
225 if(winfreeze||mainmenu)drawmode=normalmode;
228 if(drawmode==glowmode){
233 DSpContext_FadeGamma(NULL,200,&color2);
238 drawtoggle=1-drawtoggle;
241 texviewwidth=kTextureSize;
242 if(texviewwidth>screenwidth)
243 texviewwidth=screenwidth;
244 texviewheight=kTextureSize;
245 if(texviewheight>screenheight)
246 texviewheight=screenheight;
248 texcoordwidth=screenwidth/kTextureSize;
249 texcoordheight=screenheight/kTextureSize;
256 glDrawBuffer(GL_BACK);
257 glReadBuffer(GL_BACK);
260 static XYZ terrainlight;
261 static float distance;
262 if(drawmode==normalmode)
263 Game::ReSizeGLScene(90,.1f);
264 if(drawmode!=normalmode)
265 glViewport(0,0,texviewwidth,texviewheight);
266 glDepthFunc(GL_LEQUAL);
268 glAlphaFunc(GL_GREATER, 0.0001f);
269 glEnable(GL_ALPHA_TEST);
270 glClearColor(0.25f, 0.25f, 0.25f, 1.0f);
271 glClear(GL_DEPTH_BUFFER_BIT);
273 glMatrixMode (GL_MODELVIEW);
274 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
277 // Move the camera for the current eye's point of view.
278 // Reverse the movement if we're reversing stereo
279 glTranslatef((stereoseparation/2) * side * (stereoreverse ? -1 : 1), 0, 0);
282 if(!cameramode&&!freeze&&!winfreeze){
284 glRotatef(float(Random()%100)/10*camerashake/*+(woozy*woozy)/10*/,0,0,1);
286 glRotatef(pitch+sin(woozy/2)*(player[0].damage/player[0].damagetolerance)*5,1,0,0);
287 glRotatef(yaw+sin(woozy)*(player[0].damage/player[0].damagetolerance)*5,0,1,0);
289 if(cameramode||freeze||winfreeze){
290 glRotatef(pitch,1,0,0);
291 glRotatef(yaw,0,1,0);
294 if(environment==desertenvironment){
295 glRotatef((float)(abs(Random()%100))/3000-1,1,0,0);
296 glRotatef((float)(abs(Random()%100))/3000-1,0,1,0);
298 SetUpLight(&light,0);
301 //heat blur effect in desert
302 if(abs(blurness-targetblurness)<multiplier*10||abs(blurness-targetblurness)>2){
303 blurness=targetblurness;
304 targetblurness=(float)(abs(Random()%100))/40;
306 if(blurness<targetblurness)
307 blurness+=multiplier*5;
309 blurness-=multiplier*5;
311 if(environment==desertenvironment&&detail==2)
312 glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, blurness+.4 );
313 if(environment==desertenvironment){
314 glRotatef((float)(abs(Random()%100))/1000,1,0,0);
315 glRotatef((float)(abs(Random()%100))/1000,0,1,0);
318 glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0);
320 glTranslatef(-viewer.x,-viewer.y,-viewer.z);
321 frustum.GetFrustum();
323 //make shadow decals on terrain and objects
325 static float size,opacity,rotation;
327 for(k=0;k<numplayers;k++){
328 if(!player[k].skeleton.free&&player[k].playerdetail&&player[k].howactive<typesleeping)
329 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)
330 for(i=0;i<player[k].skeleton.num_joints;i++){
331 if(player[k].skeleton.joints[i].label==leftknee||player[k].skeleton.joints[i].label==rightknee||player[k].skeleton.joints[i].label==groin){
332 point=DoRotation(player[k].skeleton.joints[i].position,0,player[k].yaw,0)*player[k].scale+player[k].coords;
334 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;
335 if(k!=0&&tutoriallevel==1){
336 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;
338 terrain.MakeDecal(shadowdecal,point,size,opacity,rotation);
339 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
340 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
341 if(objects.position[j].y<player[k].coords.y||objects.type[j]==tunneltype||objects.type[j]==weirdtype){
342 point=DoRotation(DoRotation(player[k].skeleton.joints[i].position,0,player[k].yaw,0)*player[k].scale+player[k].coords-objects.position[j],0,-objects.yaw[j],0);
345 if(k!=0&&tutoriallevel==1){
346 opacity=.2+.2*sin(smoketex*6+i);
348 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
353 if((player[k].skeleton.free||player[k].howactive>=typesleeping)&&player[k].playerdetail)
354 if(frustum.SphereInFrustum(player[k].coords.x,player[k].coords.y,player[k].coords.z,player[k].scale*5)&&player[k].occluded<25)
355 for(i=0;i<player[k].skeleton.num_joints;i++){
356 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){
357 if(player[k].skeleton.free)
358 point=player[k].skeleton.joints[i].position*player[k].scale+player[k].coords;
360 point=DoRotation(player[k].skeleton.joints[i].position,0,player[k].yaw,0)*player[k].scale+player[k].coords;
362 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;
363 if(k!=0&&tutoriallevel==1){
364 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;
366 terrain.MakeDecal(shadowdecal,point,size,opacity*.7,rotation);
367 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
368 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
369 if(objects.position[j].y<player[k].coords.y||objects.type[j]==tunneltype||objects.type[j]==weirdtype){
370 if(player[k].skeleton.free)point=DoRotation(player[k].skeleton.joints[i].position*player[k].scale+player[k].coords-objects.position[j],0,-objects.yaw[j],0);
371 else point=DoRotation(DoRotation(player[k].skeleton.joints[i].position,0,player[k].yaw,0)*player[k].scale+player[k].coords-objects.position[j],0,-objects.yaw[j],0);
374 if(k!=0&&tutoriallevel==1){
375 opacity=.2+.2*sin(smoketex*6+i);
377 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
383 if(!player[k].playerdetail)
384 if(frustum.SphereInFrustum(player[k].coords.x,player[k].coords.y,player[k].coords.z,player[k].scale*5)){
385 point=player[k].coords;
387 opacity=.4-(player[k].coords.y-terrain.getHeight(player[k].coords.x,player[k].coords.z))/5;
388 terrain.MakeDecal(shadowdecal,point,size,opacity*.7,rotation);
389 for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
390 j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
391 point=DoRotation(player[k].coords-objects.position[j],0,-objects.yaw[j],0);
394 objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
400 glEnable(GL_TEXTURE_2D);
402 glEnable(GL_DEPTH_TEST);
403 glEnable(GL_CULL_FACE);
405 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
406 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
407 terraintexture.bind();
409 terraintexture2.bind();
411 //glBindTexture( GL_TEXTURE_2D, terraintexture3);
412 //glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
415 terrain.drawdecals();
418 glEnable(GL_CULL_FACE);
419 glEnable(GL_LIGHTING);
421 glEnable(GL_TEXTURE_2D);
424 glEnable(GL_COLOR_MATERIAL);
439 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
440 glEnable(GL_CULL_FACE);
441 glCullFace(GL_FRONT);
443 for(k=0;k<numplayers;k++){
444 if(k==0||tutoriallevel!=1){
446 glEnable(GL_LIGHTING);
447 terrainlight=terrain.getLighting(player[k].coords.x,player[k].coords.z);
448 distance=findDistancefast(&viewer,&player[k].coords);
449 distance=(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance;
450 glColor4f(terrainlight.x,terrainlight.y,terrainlight.z,distance);
454 checkpoint=DoRotation(player[k].skeleton.joints[abs(Random()%player[k].skeleton.num_joints)].position,0,player[k].yaw,0)*player[k].scale+player[k].coords;
456 if(!player[k].occluded==0)
457 i=checkcollide(viewer,checkpoint,player[k].lastoccluded);
458 if(i==-1||player[k].occluded==0)
459 i=checkcollide(viewer,checkpoint);
461 player[k].occluded+=1;
462 player[k].lastoccluded=i;
464 player[k].occluded=0;
465 if(player[k].occluded<25)
466 player[k].DrawSkeleton();
472 if(!cameramode&&musictype==stream_fighttheme)
473 playerdist=findDistancefastflat(&player[0].coords,&viewer);
478 glEnable(GL_TEXTURE_2D);
484 if(frustum.SphereInFrustum(realhawkcoords.x+hawk.boundingspherecenter.x,realhawkcoords.y+hawk.boundingspherecenter.y,realhawkcoords.z+hawk.boundingspherecenter.z,2)){
485 glAlphaFunc(GL_GREATER, 0.0001f);
487 glDisable(GL_CULL_FACE);
488 glDisable(GL_LIGHTING);
490 glTranslatef(hawkcoords.x,hawkcoords.y,hawkcoords.z);
491 glRotatef(hawkyaw,0,1,0);
492 glTranslatef(25,0,0);
493 distance=findDistancefast(&viewer,&realhawkcoords)*1.2;
494 glColor4f(light.color[0],light.color[1],light.color[2],(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance);
495 if((viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance>1)
496 glColor4f(light.color[0],light.color[1],light.color[2],1);
497 if((viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance>0)
498 hawk.drawdifftex(hawktexture);
502 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
503 glEnable(GL_CULL_FACE);
504 glCullFace(GL_FRONT);
506 for(k=0;k<numplayers;k++){
507 if(!(k==0||tutoriallevel!=1)){
509 glEnable(GL_LIGHTING);
510 terrainlight=terrain.getLighting(player[k].coords.x,player[k].coords.z);
511 distance=findDistancefast(&viewer,&player[k].coords);
512 distance=(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance;
513 glColor4f(terrainlight.x,terrainlight.y,terrainlight.z,distance);
517 checkpoint=DoRotation(player[k].skeleton.joints[abs(Random()%player[k].skeleton.num_joints)].position,0,player[k].yaw,0)*player[k].scale+player[k].coords;
519 if(!player[k].occluded==0)
520 i=checkcollide(viewer,checkpoint,player[k].lastoccluded);
521 if(i==-1||player[k].occluded==0)
522 i=checkcollide(viewer,checkpoint);
524 player[k].occluded+=1;
525 player[k].lastoccluded=i;
527 player[k].occluded=0;
528 if(player[k].occluded<25)
529 player[k].DrawSkeleton();
535 glEnable(GL_TEXTURE_2D);
540 glDisable(GL_COLOR_MATERIAL);
542 glDisable(GL_LIGHTING);
543 glDisable(GL_TEXTURE_2D);
549 //waypoints, pathpoints in editor
552 glDisable(GL_LIGHTING);
553 glDisable(GL_TEXTURE_2D);
554 glDisable(GL_COLOR_MATERIAL);
557 for(k=0;k<numplayers;k++){
558 if(player[k].numwaypoints>1){
559 glBegin(GL_LINE_LOOP);
560 for(i=0;i<player[k].numwaypoints;i++){
561 glVertex3f(player[k].waypoints[i].x,player[k].waypoints[i].y+.5,player[k].waypoints[i].z);
570 for(k=0;k<numpathpoints;k++){
571 if(numpathpointconnect[k]){
572 for(i=0;i<numpathpointconnect[k];i++){
573 glBegin(GL_LINE_LOOP);
574 glVertex3f(pathpoint[k].x,pathpoint[k].y+.5,pathpoint[k].z);
575 glVertex3f(pathpoint[pathpointconnect[k][i]].x,pathpoint[pathpointconnect[k][i]].y+.5,pathpoint[pathpointconnect[k][i]].z);
583 glVertex3f(pathpoint[pathpointselected].x,pathpoint[pathpointselected].y+.5,pathpoint[pathpointselected].z);
590 glEnable(GL_TEXTURE_2D);
591 glColor4f(.5,.5,.5,1);
593 sprintf (string, " ",(int)(fps));
594 text->glPrint(10,30,string,0,.8,screenwidth,screenheight);
597 if(bonus>0&&bonustime<1&&!winfreeze&&indialogue==-1/*bonustime<4*/){
598 const char *bonus_name;
599 if (bonus < bonus_count)
600 bonus_name = bonus_names[bonus];
602 bonus_name = "Excellent!"; // When does this happen?
604 glColor4f(0,0,0,1-bonustime);
605 text->glPrintOutline(1024/2-10*strlen(bonus_name)-4,768/16-4+768*4/5,bonus_name,1,2.5,1024,768);
606 glColor4f(1,0,0,1-bonustime);
607 text->glPrint(1024/2-10*strlen(bonus_name),768/16+768*4/5,bonus_name,1,2,1024,768);
609 sprintf (string, "%d",(int)bonusvalue);
610 glColor4f(0,0,0,1-bonustime);
611 text->glPrintOutline(1024/2-10*strlen(string)-4,768/16-4-20+768*4/5,string,1,2.5*.8,1024,768);
612 glColor4f(1,0,0,1-bonustime);
613 text->glPrint(1024/2-10*strlen(string),768/16-20+768*4/5,string,1,2*.8,1024,768);
614 glColor4f(.5,.5,.5,1);
617 if(tutoriallevel==1){
618 tutorialopac=tutorialmaxtime-tutorialstagetime;
619 if(tutorialopac>1)tutorialopac=1;
620 if(tutorialopac<0)tutorialopac=0;
622 sprintf (string, " ");
623 sprintf (string2, " ");
624 sprintf (string3, " ");
625 if(tutorialstage==0){
626 sprintf (string, " ");
627 sprintf (string2, " ");
628 sprintf (string3, " ");
630 if(tutorialstage==1){
631 sprintf (string, "Welcome to the Lugaru training level!");
632 sprintf (string2, " ");
633 sprintf (string3, " ");
635 if(tutorialstage==2){
636 sprintf (string, "BASIC MOVEMENT:");
637 sprintf (string2, " ");
638 sprintf (string3, " ");
640 if(tutorialstage==3){
641 sprintf (string, "You can move the mouse to rotate the camera.");
642 sprintf (string2, " ");
643 sprintf (string3, " ");
645 if(tutorialstage==4){
646 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));
647 sprintf (string2, "All movement is relative to the camera.");
648 sprintf (string3, " ");
650 if(tutorialstage==5){
651 sprintf (string, "Please press %s to jump.",Input::keyToChar(jumpkey));
652 sprintf (string2, "You can hold it longer to jump higher.");
653 sprintf (string3, " ");
655 if(tutorialstage==6){
656 sprintf (string, "You can press %s to crouch.",Input::keyToChar(crouchkey));
657 sprintf (string2, "You can jump higher from a crouching position.");
658 sprintf (string3, " ");
660 if(tutorialstage==7){
661 sprintf (string, "While running, you can press %s to roll.",Input::keyToChar(crouchkey));
662 sprintf (string2, " ");
663 sprintf (string3, " ");
665 if(tutorialstage==8){
666 sprintf (string, "While crouching, you can sneak around silently");
667 sprintf (string2, "using the movement keys.");
668 sprintf (string3, " ");
670 if(tutorialstage==9){
671 sprintf (string, "Release the crouch key while sneaking and hold the movement keys");
672 sprintf (string2, "to run animal-style.");
673 sprintf (string3, " ");
675 if(tutorialstage==10){
676 sprintf (string, "ADVANCED MOVEMENT:");
677 sprintf (string2, " ");
678 sprintf (string3, " ");
680 if(tutorialstage==11){
681 sprintf (string, "When you jump at a wall, you can hold %s again",Input::keyToChar(jumpkey));
682 sprintf (string2, "during impact to perform a walljump.");
683 sprintf (string3, "Be sure to use the movement keys to press against the wall");
685 if(tutorialstage==12){
686 sprintf (string, "While in the air, you can press crouch to flip.",Input::keyToChar(jumpkey));
687 sprintf (string2, "Walljumps and flips confuse enemies and give you more control.");
688 sprintf (string3, " ");
690 if(tutorialstage==13){
691 sprintf (string, "BASIC COMBAT:");
692 sprintf (string2, " ");
693 sprintf (string3, " ");
695 if(tutorialstage==14){
696 sprintf (string, "There is now an imaginary enemy");
697 sprintf (string2, "in the middle of the training area.");
698 sprintf (string3, " ");
700 if(tutorialstage==15){
701 if(attackkey==MOUSEBUTTON1)sprintf (string, "Click to attack when you are near an enemy.");
702 else sprintf (string, "Press %s to attack when you are near an enemy.",Input::keyToChar(attackkey));
703 sprintf (string2, "You can punch by standing still near an enemy and attacking.");
704 sprintf (string3, " ");
706 if(tutorialstage==16){
707 sprintf (string, "If you are close, you will perform a weak punch.");
708 sprintf (string2, "The weak punch is excellent for starting attack combinations.");
709 sprintf (string3, " ");
711 if(tutorialstage==17){
712 sprintf (string, "Attacking while running results in a spin kick.");
713 sprintf (string2, "This is one of your most powerful ground attacks.");
714 sprintf (string3, " ");
716 if(tutorialstage==18){
717 sprintf (string, "Sweep the enemy's legs out by attacking while crouched.");
718 sprintf (string2, "This is a very fast attack, and easy to follow up.");
719 sprintf (string3, " ");
721 if(tutorialstage==19){
722 sprintf (string, "When an enemy is on the ground, you can deal some extra");
723 sprintf (string2, "damage by running up and drop-kicking him.");
724 sprintf (string3, "(Try knocking them down with a sweep first)");
726 if(tutorialstage==20){
727 sprintf (string, "Your most powerful individual attack is the rabbit kick.");
728 if(attackkey==MOUSEBUTTON1)sprintf (string2, "Run at the enemy while holding the mouse button, and press");
729 else sprintf (string2, "Run at the enemy while holding %s, and press", Input::keyToChar(attackkey));
730 sprintf (string3, "the jump key (%s) to attack.",Input::keyToChar(jumpkey));
732 if(tutorialstage==21){
733 sprintf (string, "This attack is devastating if timed correctly.");
734 sprintf (string2, "Even if timed incorrectly, it will knock the enemy over.");
735 if(againbonus)sprintf (string3, "Try rabbit-kicking the imaginary enemy again.");
736 else sprintf (string3, "Try rabbit-kicking the imaginary enemy.");
738 if(tutorialstage==22){
739 sprintf (string, "If you sneak behind an enemy unnoticed, you can kill");
740 sprintf (string2, "him instantly. Move close behind this enemy");
741 sprintf (string3, "and attack.");
743 if(tutorialstage==23){
744 sprintf (string, "Another important attack is the wall kick. When an enemy");
745 sprintf (string2, "is near a wall, perform a walljump nearby and hold");
746 sprintf (string3, "the attack key during impact with the wall.");
748 if(tutorialstage==24){
749 sprintf (string, "You can tackle enemies by running at them animal-style");
750 if(attackkey==MOUSEBUTTON1)sprintf (string2, "and pressing jump (%s) or attack(mouse button).",Input::keyToChar(jumpkey));
751 else sprintf (string2, "and pressing jump (%s) or attack(%s).",Input::keyToChar(jumpkey),Input::keyToChar(attackkey));
752 sprintf (string3, "This is especially useful when they are running away.");
754 if(tutorialstage==25){
755 sprintf (string, "Dodge by pressing back and attack. Dodging is essential");
756 sprintf (string2, "against enemies with swords or other long weapons.");
757 sprintf (string3, " ");
759 if(tutorialstage==26){
760 sprintf (string, "REVERSALS AND COUNTER-REVERSALS");
761 sprintf (string2, " ");
762 sprintf (string3, " ");
764 if(tutorialstage==27){
765 sprintf (string, "The enemy can now reverse your attacks.");
766 sprintf (string2, " ");
767 sprintf (string3, " ");
769 if(tutorialstage==28){
770 sprintf (string, "If you attack, you will notice that the enemy now sometimes");
771 sprintf (string2, "catches your attack and uses it against you. Hold");
772 sprintf (string3, "crouch (%s) after attacking to escape from reversals.",Input::keyToChar(crouchkey));
774 if(tutorialstage==29){
775 sprintf (string, "Try escaping from two more reversals in a row.");
776 sprintf (string2, " ");
777 sprintf (string3, " ");
779 if(tutorialstage==30){
780 sprintf (string, "Good!");
781 sprintf (string2, " ");
782 sprintf (string3, " ");
784 if(tutorialstage==31){
785 sprintf (string, "To reverse an attack, you must tap crouch (%s) during the",Input::keyToChar(crouchkey));
786 sprintf (string2, "enemy's attack. You must also be close to the enemy;");
787 sprintf (string3, "this is especially important against armed opponents.");
789 if(tutorialstage==32){
790 sprintf (string, "The enemy can attack in %d seconds.", (int)(tutorialmaxtime-tutorialstagetime));
791 sprintf (string2, "This imaginary opponents attacks will be highlighted");
792 sprintf (string3, "to make this easier.");
794 if(tutorialstage==33){
795 sprintf (string, "Reverse three enemy attacks!");
796 sprintf (string2, " ");
797 sprintf (string3, " ");
799 if(tutorialstage==34){
800 sprintf (string, "Reverse two more enemy attacks!");
801 sprintf (string2, " ");
802 sprintf (string3, " ");
804 if(tutorialstage==35){
805 sprintf (string, "Reverse one more enemy attack!");
806 sprintf (string2, " ");
807 sprintf (string3, " ");
809 if(tutorialstage==36){
810 sprintf (string, "Excellent!");
811 sprintf (string2, " ");
812 sprintf (string3, " ");
814 if(tutorialstage==37){
815 sprintf (string, "Now spar with the enemy for %d more seconds.", (int)(tutorialmaxtime-tutorialstagetime));
816 sprintf (string2, "Damage dealt: %d",(int)damagedealt);
817 sprintf (string3, "Damage taken: %d.",(int)damagetaken);
819 if(tutorialstage==38){
820 sprintf (string, "WEAPONS:");
821 sprintf (string2, " ");
822 sprintf (string3, " ");
824 if(tutorialstage==39){
825 sprintf (string, "There is now an imaginary knife");
826 sprintf (string2, "in the center of the training area.");
827 sprintf (string3, " ");
829 if(tutorialstage==40){
830 sprintf (string, "Stand, roll or handspring over the knife");
831 sprintf (string2, "while pressing %s to pick it up.",Input::keyToChar(throwkey));
832 sprintf (string3, "You can crouch and press the same key to drop it again.");
834 if(tutorialstage==41){
835 sprintf (string, "You can equip and unequip weapons using the %s key.",Input::keyToChar(drawkey));
836 sprintf (string2, "Sometimes it is best to keep them unequipped to");
837 sprintf (string3, "prevent enemies from taking them. ");
839 if(tutorialstage==42){
840 sprintf (string, "The knife is the smallest weapon and the least encumbering.");
841 sprintf (string2, "You can equip or unequip it while standing, crouching,");
842 sprintf (string3, "running or flipping.");
844 if(tutorialstage==43){
845 sprintf (string, "You perform weapon attacks the same way as unarmed attacks,");
846 sprintf (string2, "but sharp weapons cause permanent damage, instead of the");
847 sprintf (string3, "temporary trauma from blunt weapons, fists and feet.");
849 if(tutorialstage==44){
850 sprintf (string, "The enemy now has your knife!");
851 sprintf (string2, "Please reverse two of his knife attacks.");
852 sprintf (string3, " ");
854 if(tutorialstage==45){
855 sprintf (string, "Please reverse one more of his knife attacks.");
856 sprintf (string2, " ");
857 sprintf (string3, " ");
859 if(tutorialstage==46){
860 sprintf (string, "Now he has a sword!");
861 sprintf (string2, "The sword has longer reach than your arms, so you");
862 sprintf (string3, "must move close to reverse the sword slash.");
864 if(tutorialstage==47){
865 sprintf (string, "Long weapons like the sword and staff are also useful for defense;");
866 sprintf (string2, "you can parry enemy weapon attacks by pressing the attack key");
867 sprintf (string3, "at the right time. Please try parrying the enemy's attacks!");
869 if(tutorialstage==48){
870 sprintf (string, "The staff is like the sword, but has two main attacks.");
871 sprintf (string2, "The standing smash is fast and effective, and the running");
872 sprintf (string3, "spin smash is slower and more powerful.");
874 if(tutorialstage==49){
875 sprintf (string, "When facing an enemy, you can throw the knife with %s.",Input::keyToChar(throwkey));
876 sprintf (string2, "It is possible to throw the knife while flipping,");
877 sprintf (string3, "but it is very inaccurate.");
879 if(tutorialstage==50){
880 sprintf (string, "You now know everything you can learn from training.");
881 sprintf (string2, "Everything else you must learn from experience!");
882 sprintf (string3, " ");
884 if(tutorialstage==51){
885 sprintf (string, "Walk out of the training area to return to the main menu.");
886 sprintf (string2, " ");
887 sprintf (string3, " ");
890 glColor4f(0,0,0,tutorialopac);
891 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);
892 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);
893 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);
894 glColor4f(1,1,1,tutorialopac);
895 text->glPrint(screenwidth/2-7.6*strlen(string)*screenwidth/1024,screenheight/16+screenheight*4/5,string,1,1.5*screenwidth/1024,screenwidth,screenheight);
896 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);
897 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);
899 sprintf (string, "Press 'tab' to skip to the next item.",Input::keyToChar(jumpkey));
900 sprintf (string2, "Press escape at any time to");
901 sprintf (string3, "pause or exit the tutorial.");
904 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);
905 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);
906 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);
907 glColor4f(0.5,0.5,0.5,1);
908 text->glPrint(screenwidth/2-7.6*strlen(string)*screenwidth/1024*.8,0+screenheight*1/10,string,1,1.5*screenwidth/1024*.8,screenwidth,screenheight);
909 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);
910 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);
914 if(numhotspots&&(bonustime>=1||bonus<=0||bonustime<0)&&!tutoriallevel){
916 float closestdist=-1;
918 closest=currenthotspot;
919 for(i=0;i<numhotspots;i++){
920 distance=findDistancefast(&player[0].coords,&hotspot[i]);
921 if(closestdist==-1||distance<closestdist){
922 if(findDistancefast(&player[0].coords,&hotspot[i])<hotspotsize[i]&&((hotspottype[i]<=10&&hotspottype[i]>=0)||(hotspottype[i]<=40&&hotspottype[i]>=20))){
923 closestdist=distance;
929 currenthotspot=closest;
930 if(currenthotspot!=-1){
931 if(hotspottype[closest]<=10){
932 if(findDistancefast(&player[0].coords,&hotspot[closest])<hotspotsize[closest])
935 tutorialopac=tutorialmaxtime-tutorialstagetime;
936 if(tutorialopac>1)tutorialopac=1;
937 if(tutorialopac<0)tutorialopac=0;
939 sprintf (string, "%s", hotspottext[closest]);
946 if(string[i]=='\n'||string[i]>'z'||string[i]<' '||string[i]=='\0'){
947 glColor4f(0,0,0,tutorialopac);
948 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);
949 glColor4f(1,1,1,tutorialopac);
950 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);
953 if(string[i]=='\0')done=1;
958 } else if (hotspottype[closest]>=20&&dialoguegonethrough[hotspottype[closest]-20]==0){
959 whichdialogue=hotspottype[closest]-20;
960 for(j=0;j<numdialogueboxes[whichdialogue];j++){
961 player[participantfocus[whichdialogue][j]].coords=participantlocation[whichdialogue][participantfocus[whichdialogue][j]];
962 player[participantfocus[whichdialogue][j]].yaw=participantyaw[whichdialogue][participantfocus[whichdialogue][j]];
963 player[participantfocus[whichdialogue][j]].targetyaw=participantyaw[whichdialogue][participantfocus[whichdialogue][j]];
964 player[participantfocus[whichdialogue][j]].velocity=0;
965 player[participantfocus[whichdialogue][j]].targetanimation=player[participantfocus[whichdialogue][j]].getIdle();
966 player[participantfocus[whichdialogue][j]].targetframe=0;
970 dialoguegonethrough[whichdialogue]++;
971 if(dialogueboxsound[whichdialogue][indialogue]!=0){
973 if(dialogueboxsound[whichdialogue][indialogue]==1)whichsoundplay=rabbitchitter;
974 if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
975 if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
976 if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
977 if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
978 if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
979 if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
980 if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
981 if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
982 if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
983 if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
984 if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
985 if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
986 if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
987 if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
988 if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
989 if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
990 if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
991 if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
992 if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
993 emit_sound_at(whichsoundplay, player[participantfocus[whichdialogue][indialogue]].coords);
999 if(indialogue!=-1&&!mainmenu){
1000 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1001 glDisable(GL_CULL_FACE);
1002 glDisable(GL_LIGHTING);
1003 glDisable(GL_TEXTURE_2D);
1005 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1006 glPushMatrix(); // Store The Projection Matrix
1007 glLoadIdentity(); // Reset The Projection Matrix
1008 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1009 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1010 glPushMatrix(); // Store The Modelview Matrix
1011 glLoadIdentity(); // Reset The Modelview Matrix
1012 if(dialogueboxlocation[whichdialogue][indialogue]==1)glTranslatef(0,screenheight*3/4,0);
1013 glScalef(screenwidth,screenheight/4,1);
1014 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1017 glColor4f(dialogueboxcolor[whichdialogue][indialogue][0],dialogueboxcolor[whichdialogue][indialogue][1],dialogueboxcolor[whichdialogue][indialogue][2],0.7);
1019 glVertex3f(0, 0, 0.0f);
1020 glVertex3f(1, 0, 0.0f);
1021 glVertex3f(1, 1, 0.0f);
1022 glVertex3f(0, 1, 0.0f);
1024 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1025 glPopMatrix(); // Restore The Old Projection Matrix
1026 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1027 glPopMatrix(); // Restore The Old Projection Matrix
1028 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1029 glEnable(GL_CULL_FACE);
1030 glDisable(GL_BLEND);
1032 glEnable(GL_TEXTURE_2D);
1039 startx=screenwidth*1/5;
1040 if(dialogueboxlocation[whichdialogue][indialogue]==1)
1041 starty=screenheight/16+screenheight*4/5;
1042 if(dialogueboxlocation[whichdialogue][indialogue]==2)
1043 starty=screenheight*1/5-screenheight/16;
1052 for(i=0;i<(int)strlen(dialoguename[whichdialogue][indialogue]);i++){
1053 tempname[tempnum]=dialoguename[whichdialogue][indialogue][i];
1055 if(dialoguename[whichdialogue][indialogue][i]=='#'||dialoguename[whichdialogue][indialogue][i]=='\0')goodchar=0;
1059 tempname[tempnum]='\0';
1062 sprintf (string, "%s: ", tempname);
1064 if(dialogueboxcolor[whichdialogue][indialogue][0]+dialogueboxcolor[whichdialogue][indialogue][1]+dialogueboxcolor[whichdialogue][indialogue][2]<1.5){
1065 glColor4f(0,0,0,tutorialopac);
1066 text->glPrintOutline(startx-2*7.6*strlen(string)*screenwidth/1024-4,starty-4,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight);
1067 glColor4f(0.7,0.7,0.7,tutorialopac);
1068 text->glPrint(startx-2*7.6*strlen(string)*screenwidth/1024,starty,string,1,1.5*screenwidth/1024,screenwidth,screenheight);
1072 glColor4f(0,0,0,tutorialopac);
1073 text->glPrintOutline(startx-2*7.6*strlen(string)*screenwidth/1024-4,starty-4,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight);
1077 for(i=0;i<(int)strlen(dialoguetext[whichdialogue][indialogue])+1;i++){
1078 tempname[tempnum]=dialoguetext[whichdialogue][indialogue][i];
1079 if(dialoguetext[whichdialogue][indialogue][i]!='#')tempnum++;
1082 sprintf (string, "%s", tempname);
1089 if(string[i]=='\n'||string[i]>'z'||string[i]<' '||string[i]=='\0'){
1090 if(dialogueboxcolor[whichdialogue][indialogue][0]+dialogueboxcolor[whichdialogue][indialogue][1]+dialogueboxcolor[whichdialogue][indialogue][2]<1.5){
1091 glColor4f(0,0,0,tutorialopac);
1092 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);
1093 glColor4f(1,1,1,tutorialopac);
1094 text->glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/,starty-20*screenwidth/1024*line,string,1,1.5*screenwidth/1024,screenwidth,screenheight,lastline,i);
1098 glColor4f(0,0,0,tutorialopac);
1099 text->glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/,starty-20*screenwidth/1024*line,string,1,1.5*screenwidth/1024,screenwidth,screenheight,lastline,i);
1103 if(string[i]=='\0')done=1;
1110 if(!tutoriallevel&&!winfreeze&&indialogue==-1&&!mainmenu){
1113 sprintf (string, "Score: %d", (int)accountactive->getCampaignScore());
1115 sprintf (string, "Score: %d", (int)accountactive->getCampaignScore()+(int)bonustotal);
1117 if(!campaign)sprintf (string, "Score: %d", (int)bonustotal);
1119 text->glPrintOutline(1024/40-4,768/16-4+768*14/16,string,1,1.5*1.25,1024,768);
1121 text->glPrint(1024/40,768/16+768*14/16,string,1,1.5,1024,768);
1123 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1124 glDisable(GL_CULL_FACE);
1125 glDisable(GL_LIGHTING);
1126 glDisable(GL_TEXTURE_2D);
1128 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1129 glPushMatrix(); // Store The Projection Matrix
1130 glLoadIdentity(); // Reset The Projection Matrix
1131 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1132 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1133 glPushMatrix(); // Store The Modelview Matrix
1134 glLoadIdentity(); // Reset The Modelview Matrix
1135 glTranslatef(15,screenheight*17.5/20,0);
1136 glScalef(screenwidth/3+20,screenheight/20,1);
1137 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1139 glColor4f(0.0,0.4,0.0,0.7);
1140 float bar=((float)player[0].damage)/player[0].damagetolerance;
1142 glVertex3f((bar<1?bar:1),0,0.0f);
1143 glVertex3f(1,0,0.0f);
1144 glVertex3f(1,1,0.0f);
1145 glVertex3f((bar<1?bar:1),1,0.0f);
1147 glColor4f(0.1,0.0,0.0,1);
1148 bar = ((float)player[0].bloodloss)/player[0].damagetolerance;
1150 glVertex3f(0,0,0.0f);
1151 glVertex3f((bar<1?bar:1),0,0.0f);
1152 glVertex3f((bar<1?bar:1),1,0.0f);
1153 glVertex3f(0,1,0.0f);
1155 glColor4f(0.4,0.0,0.0,0.7);
1156 bar = ((float)player[0].damage)/player[0].damagetolerance;
1158 glVertex3f(0,0,0.0f);
1159 glVertex3f((bar<1?bar:1),0,0.0f);
1160 glVertex3f((bar<1?bar:1),1,0.0f);
1161 glVertex3f(0,1,0.0f);
1163 glColor4f(0.4,0.0,0.0,0.7);
1164 bar = ((float)player[0].permanentdamage)/player[0].damagetolerance;
1166 glVertex3f(0,0,0.0f);
1167 glVertex3f((bar<1?bar:1),0,0.0f);
1168 glVertex3f((bar<1?bar:1),1,0.0f);
1169 glVertex3f(0,1,0.0f);
1171 glColor4f(0.4,0.0,0.0,0.7);
1172 bar = ((float)player[0].superpermanentdamage)/player[0].damagetolerance;
1174 glVertex3f(0,0,0.0f);
1175 glVertex3f((bar<1?bar:1),0,0.0f);
1176 glVertex3f((bar<1?bar:1),1,0.0f);
1177 glVertex3f(0,1,0.0f);
1179 glColor4f(0.0,0.0,0.0,0.7);
1181 glBegin(GL_LINE_STRIP);
1182 glVertex3f(0,0,0.0f);
1183 glVertex3f(1,0,0.0f);
1184 glVertex3f(1,1,0.0f);
1185 glVertex3f(0,1,0.0f);
1186 glVertex3f(0,0,0.0f);
1189 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1190 glPopMatrix(); // Restore The Old Projection Matrix
1191 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1192 glPopMatrix(); // Restore The Old Projection Matrix
1193 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1194 glEnable(GL_CULL_FACE);
1195 glDisable(GL_BLEND);
1197 glEnable(GL_TEXTURE_2D);
1199 // writing the numbers :
1200 sprintf (string, "Damages : %d/%d (%d)",(int)(player[0].damage),(int)(player[0].damagetolerance),(int)(player[0].bloodloss));
1202 text->glPrintOutline(1024/40-4,768/16-4+768*14/16-40,string,1,1.5*1.25,1024,768);
1204 text->glPrint(1024/40,768/16+768*14/16-40,string,1,1.5,1024,768);
1208 glColor4f(.5,.5,.5,1);
1211 if((texttoggle||editorenabled)&&debugmode&&!mainmenu){
1212 sprintf (string, "The framespersecond is %d.",(int)(fps));
1213 text->glPrint(10,30,string,0,.8,1024,768);
1216 sprintf (string, "Map editor enabled.");
1218 sprintf (string, "Map editor disabled.");
1219 text->glPrint(10,60,string,0,.8,1024,768);
1221 sprintf (string, "Object size: %f",editorsize);
1222 text->glPrint(10,75,string,0,.8,1024,768);
1223 if(editoryaw>=0)sprintf (string, "Object yaw: %f",editoryaw);
1224 else sprintf (string, "Object yaw: Random");
1225 text->glPrint(10,90,string,0,.8,1024,768);
1226 if(editorpitch>=0)sprintf (string, "Object pitch: %f",editorpitch);
1227 else sprintf (string, "Object pitch: Random");
1228 text->glPrint(10,105,string,0,.8,1024,768);
1229 sprintf (string, "Object type: %d",editortype);
1230 text->glPrint(10,120,string,0,.8,1024,768);
1231 switch(editortype) {
1233 sprintf (string, "(box)");
1236 sprintf (string, "(tree)");
1239 sprintf (string, "(wall)");
1242 sprintf (string, "(weird)");
1245 sprintf (string, "(spike)");
1248 sprintf (string, "(rock)");
1251 sprintf (string, "(bush)");
1254 sprintf (string, "(tunnel)");
1257 sprintf (string, "(chimney)");
1260 sprintf (string, "(platform)");
1263 sprintf (string, "(cool)");
1266 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, "Difficulty: %d",difficulty);
1277 text->glPrint(10,240,string,0,.8,1024,768);
1282 if(drawmode==glowmode){
1283 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1284 glDisable(GL_CULL_FACE);
1285 glDisable(GL_LIGHTING);
1286 glDisable(GL_TEXTURE_2D);
1288 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1289 glPushMatrix(); // Store The Projection Matrix
1290 glLoadIdentity(); // Reset The Projection Matrix
1291 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1292 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1293 glPushMatrix(); // Store The Modelview Matrix
1294 glLoadIdentity(); // Reset The Modelview Matrix
1295 glScalef(screenwidth,screenheight,1);
1296 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1298 glColor4f(0,0,0,.5);
1300 glVertex3f(0, 0, 0.0f);
1301 glVertex3f(256, 0, 0.0f);
1302 glVertex3f(256, 256, 0.0f);
1303 glVertex3f(0, 256, 0.0f);
1305 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1306 glPopMatrix(); // Restore The Old Projection Matrix
1307 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1308 glPopMatrix(); // Restore The Old Projection Matrix
1309 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1310 glEnable(GL_CULL_FACE);
1311 glDisable(GL_BLEND);
1315 if((((blackout&&damageeffects)||(player[0].bloodloss>0&&damageeffects&&player[0].blooddimamount>0)||player[0].dead)&&!cameramode)||console){
1316 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1317 glDisable(GL_CULL_FACE);
1318 glDisable(GL_LIGHTING);
1319 glDisable(GL_TEXTURE_2D);
1321 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1322 glPushMatrix(); // Store The Projection Matrix
1323 glLoadIdentity(); // Reset The Projection Matrix
1324 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1325 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1326 glPushMatrix(); // Store The Modelview Matrix
1327 glLoadIdentity(); // Reset The Modelview Matrix
1328 glScalef(screenwidth,screenheight,1);
1329 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1331 if(player[0].dead)blackout+=multiplier*3;
1332 if(player[0].dead==1)blackout=.4f;
1333 if(player[0].dead==2&&blackout>.6)blackout=.6;
1334 glColor4f(0,0,0,blackout);
1335 if(!player[0].dead){
1336 if((player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5))*.3<.3){
1337 glColor4f(0,0,0,player[0].blooddimamount*player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5)*.3);
1338 blackout=player[0].blooddimamount*player[0].bloodloss/player[0].damagetolerance*(sin(woozy)/4+.5)*.3;
1341 glColor4f(0,0,0,player[0].blooddimamount*.3);
1342 blackout=player[0].blooddimamount*.3;
1345 if(console)glColor4f(.7,0,0,.2);
1347 glVertex3f(0, 0, 0.0f);
1348 glVertex3f(256, 0, 0.0f);
1349 glVertex3f(256, 256, 0.0f);
1350 glVertex3f(0, 256, 0.0f);
1352 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1353 glPopMatrix(); // Restore The Old Projection Matrix
1354 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1355 glPopMatrix(); // Restore The Old Projection Matrix
1356 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1357 glEnable(GL_CULL_FACE);
1358 glDisable(GL_BLEND);
1362 if(flashamount>0&&damageeffects) {
1363 if(flashamount>1)flashamount=1;
1364 if(flashdelay<=0)flashamount-=multiplier;
1366 if(flashamount<0)flashamount=0;
1367 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1368 glDisable(GL_CULL_FACE);
1369 glDisable(GL_LIGHTING);
1371 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1372 glPushMatrix(); // Store The Projection Matrix
1373 glLoadIdentity(); // Reset The Projection Matrix
1374 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1375 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1376 glPushMatrix(); // Store The Modelview Matrix
1377 glLoadIdentity(); // Reset The Modelview Matrix
1378 glScalef(screenwidth,screenheight,1);
1379 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1381 glColor4f(flashr,flashg,flashb,flashamount);
1383 glVertex3f(0, 0, 0.0f);
1384 glVertex3f(256, 0, 0.0f);
1385 glVertex3f(256, 256, 0.0f);
1386 glVertex3f(0, 256, 0.0f);
1388 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1389 glPopMatrix(); // Restore The Old Projection Matrix
1390 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1391 glPopMatrix(); // Restore The Old Projection Matrix
1392 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1393 glEnable(GL_CULL_FACE);
1394 glDisable(GL_BLEND);
1400 glEnable(GL_TEXTURE_2D);
1403 sprintf (string, " ]");
1404 text->glPrint(10,30+screenheight-330,string,0,1,screenwidth,screenheight);
1406 sprintf (string, "_");
1407 text->glPrint(30+(float)(displayselected)*10,30+(screenheight-330),string,0,1,screenwidth,screenheight);
1411 if((i!=0||chatting)&&displaytime[i]<4)
1412 for(j=0;j<displaychars[i];j++) {
1413 glColor4f(1,1,1,4-displaytime[i]);
1414 if(j<displaychars[i]) {
1415 sprintf (string, "%c",displaytext[i][j]);
1416 text->glPrint(30+j*10,30+i*20+(screenheight-330),string,0,1,screenwidth,screenheight);
1421 if(difficulty<2&&indialogue==-1){ // minimap
1422 float mapviewdist = 20000;
1424 glDisable(GL_DEPTH_TEST);
1425 glColor3f (1.0, 1.0, 1.0); // no coloring
1427 glEnable(GL_TEXTURE_2D);
1428 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1429 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1430 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1431 glDisable(GL_CULL_FACE);
1432 glDisable(GL_LIGHTING);
1434 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1435 glPushMatrix(); // Store The Projection Matrix
1436 glLoadIdentity(); // Reset The Projection Matrix
1437 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1438 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1439 glPushMatrix(); // Store The Modelview Matrix
1440 glLoadIdentity(); // Reset The Modelview Matrix
1441 glScalef((float)screenwidth/2,(float)screenwidth/2,1);
1442 glTranslatef(1.75,.25,0);
1443 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1451 int numliveplayers=0;
1453 for(i=0;i<numplayers;i++){
1454 if(!player[i].dead) numliveplayers++;
1459 for(i=0;i<objects.numobjects;i++){
1460 if(objects.type[i]==treetrunktype||objects.type[i]==boxtype){
1461 center+=objects.position[i];
1465 for(i=0;i<numplayers;i++){
1466 if(!player[i].dead)center+=player[i].coords;
1468 center/=numadd+numliveplayers;
1470 center=player[0].coords;
1472 float maxdistance=0;
1474 //~ int whichclosest;
1475 for(i=0;i<objects.numobjects;i++){
1476 tempdist=findDistancefast(¢er,&objects.position[i]);
1477 if(tempdist>maxdistance){
1479 maxdistance=tempdist;
1482 for(i=0;i<numplayers;i++){
1483 if(!player[i].dead){
1484 tempdist=findDistancefast(¢er,&player[i].coords);
1485 if(tempdist>maxdistance){
1487 maxdistance=tempdist;
1491 radius=fast_sqrt(maxdistance);
1495 glScalef(.25/radius*256*terrain.scale*.4,.25/radius*256*terrain.scale*.4,1);
1497 glScalef(1/(1/radius*256*terrain.scale*.4),1/(1/radius*256*terrain.scale*.4),1);
1499 glRotatef(player[0].lookyaw*-1+180,0,0,1);
1500 glTranslatef(-(center.x/terrain.scale/256*-2+1),(center.z/terrain.scale/256*-2+1),0);
1501 for(i=0;i<objects.numobjects;i++){
1502 if(objects.type[i]==treetrunktype){
1503 distcheck=findDistancefast(&player[0].coords,&objects.position[i]);
1504 if(distcheck<mapviewdist){
1505 Mapcircletexture.bind();
1506 glColor4f(0,.3,0,opac*(1-distcheck/mapviewdist));
1508 glTranslatef(objects.position[i].x/terrain.scale/256*-2+1,objects.position[i].z/terrain.scale/256*2-1,0);
1509 glRotatef(objects.yaw[i],0,0,1);
1510 glScalef(.003,.003,.003);
1513 glVertex3f(-1, -1, 0.0f);
1515 glVertex3f(1, -1, 0.0f);
1517 glVertex3f(1, 1, 0.0f);
1519 glVertex3f(-1, 1, 0.0f);
1524 if(objects.type[i]==boxtype){
1525 distcheck=findDistancefast(&player[0].coords,&objects.position[i]);
1526 if(distcheck<mapviewdist){
1527 Mapboxtexture.bind();
1528 glColor4f(.4,.4,.4,opac*(1-distcheck/mapviewdist));
1530 glTranslatef(objects.position[i].x/terrain.scale/256*-2+1,objects.position[i].z/terrain.scale/256*2-1,0);
1531 glRotatef(objects.yaw[i],0,0,1);
1532 glScalef(.01*objects.scale[i],.01*objects.scale[i],.01*objects.scale[i]);
1535 glVertex3f(-1, -1, 0.0f);
1537 glVertex3f(1, -1, 0.0f);
1539 glVertex3f(1, 1, 0.0f);
1541 glVertex3f(-1, 1, 0.0f);
1548 Mapcircletexture.bind();
1549 for(i=0;i<numboundaries;i++){
1550 glColor4f(0,0,0,opac/3);
1552 glTranslatef(boundary[i].x/terrain.scale/256*-2+1,boundary[i].z/terrain.scale/256*2-1,0);
1553 glScalef(.002,.002,.002);
1556 glVertex3f(-1, -1, 0.0f);
1558 glVertex3f(1, -1, 0.0f);
1560 glVertex3f(1, 1, 0.0f);
1562 glVertex3f(-1, 1, 0.0f);
1567 for(i=0;i<numplayers;i++){
1568 distcheck=findDistancefast(&player[0].coords,&player[i].coords);
1569 if(distcheck<mapviewdist){
1571 Maparrowtexture.bind();
1572 if(i==0)glColor4f(1,1,1,opac);
1573 else if(player[i].dead==2||player[i].howactive>typesleeping)glColor4f(0,0,0,opac*(1-distcheck/mapviewdist));
1574 else if(player[i].dead)glColor4f(.3,.3,.3,opac*(1-distcheck/mapviewdist));
1575 else if(player[i].aitype==attacktypecutoff)glColor4f(1,0,0,opac*(1-distcheck/mapviewdist));
1576 else if(player[i].aitype==passivetype)glColor4f(0,1,0,opac*(1-distcheck/mapviewdist));
1577 else glColor4f(1,1,0,1);
1578 glTranslatef(player[i].coords.x/terrain.scale/256*-2+1,player[i].coords.z/terrain.scale/256*2-1,0);
1579 glRotatef(player[i].yaw+180,0,0,1);
1580 glScalef(.005,.005,.005);
1583 glVertex3f(-1, -1, 0.0f);
1585 glVertex3f(1, -1, 0.0f);
1587 glVertex3f(1, 1, 0.0f);
1589 glVertex3f(-1, 1, 0.0f);
1595 glDisable(GL_TEXTURE_2D);
1596 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1597 glPopMatrix(); // Restore The Old Projection Matrix
1598 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1599 glPopMatrix(); // Restore The Old Projection Matrix
1600 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1601 glEnable(GL_CULL_FACE);
1602 glDisable(GL_BLEND);
1606 if(loading&&!stealthloading&&(!campaign||player[0].dead)){
1607 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1608 glDisable(GL_CULL_FACE);
1609 glDisable(GL_LIGHTING);
1610 glDisable(GL_TEXTURE_2D);
1612 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1613 glPushMatrix(); // Store The Projection Matrix
1614 glLoadIdentity(); // Reset The Projection Matrix
1615 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1616 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1617 glPushMatrix(); // Store The Modelview Matrix
1618 glLoadIdentity(); // Reset The Modelview Matrix
1619 glScalef(screenwidth,screenheight,1);
1620 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1622 glColor4f(0,0,0,.7);
1624 glVertex3f(0, 0, 0.0f);
1625 glVertex3f(256, 0, 0.0f);
1626 glVertex3f(256, 256, 0.0f);
1627 glVertex3f(0, 256, 0.0f);
1629 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1630 glPopMatrix(); // Restore The Old Projection Matrix
1631 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1632 glPopMatrix(); // Restore The Old Projection Matrix
1633 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1634 glEnable(GL_CULL_FACE);
1635 glDisable(GL_BLEND);
1639 glDisable(GL_DEPTH_TEST);
1640 glColor3f (1.0, 1.0, 1.0); // no coloring
1642 glEnable(GL_TEXTURE_2D);
1647 glEnable(GL_TEXTURE_2D);
1649 sprintf (string, "Loading...");
1650 text->glPrint(1024/2-90,768/2,string,1,2,1024,768);
1653 //if(ismotionblur)drawmode=motionblurmode;
1654 drawmode=normalmode;
1657 if(winfreeze&&!campaign){
1658 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1659 glDisable(GL_CULL_FACE);
1660 glDisable(GL_LIGHTING);
1661 glDisable(GL_TEXTURE_2D);
1663 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1664 glPushMatrix(); // Store The Projection Matrix
1665 glLoadIdentity(); // Reset The Projection Matrix
1666 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1667 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1668 glPushMatrix(); // Store The Modelview Matrix
1669 glLoadIdentity(); // Reset The Modelview Matrix
1670 glScalef(screenwidth,screenheight,1);
1671 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1673 glColor4f(0,0,0,.4);
1675 glVertex3f(0, 0, 0.0f);
1676 glVertex3f(256, 0, 0.0f);
1677 glVertex3f(256, 256, 0.0f);
1678 glVertex3f(0, 256, 0.0f);
1680 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1681 glPopMatrix(); // Restore The Old Projection Matrix
1682 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1683 glPopMatrix(); // Restore The Old Projection Matrix
1684 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1685 glEnable(GL_CULL_FACE);
1686 glDisable(GL_BLEND);
1690 glDisable(GL_DEPTH_TEST);
1691 glColor3f (1.0, 1.0, 1.0); // no coloring
1693 glEnable(GL_TEXTURE_2D);
1695 //Win Screen Won Victory
1697 glEnable(GL_TEXTURE_2D);
1699 sprintf (string, "Level Cleared!");
1700 text->glPrintOutlined(1024/2-strlen(string)*10,768*7/8,string,1,2,1024,768);
1702 sprintf (string, "Score: %d",(int)(bonustotal-startbonustotal));
1703 text->glPrintOutlined(1024/30,768*6/8,string,1,2,1024,768);
1706 sprintf (string, "Press Escape or Space to continue");
1708 sprintf (string, "Press Escape to return to menu or Space to continue");
1709 text->glPrintOutlined(640/2-strlen(string)*5,480*1/16,string,1,1,640,480);
1713 for(i=0;i<255;i++)string[i]='\0';
1714 sprintf (temp, "Time: %d:",(int)(((int)leveltime-(int)(leveltime)%60)/60));
1715 strcat(string,temp);
1716 if((int)(leveltime)%60<10)strcat(string,"0");
1717 sprintf (temp, "%d",(int)(leveltime)%60);
1718 strcat(string,temp);
1719 text->glPrintOutlined(1024/30,768*6/8-40,string,1,2,1024,768);
1722 int awards[award_count];
1723 int numawards = award_awards(awards);
1725 for (i = 0; i < numawards && i < 6; i++)
1726 text->glPrintOutlined(1024/30,768*6/8-90-40*i,award_names[awards[i]],1,2,1024,768);
1729 if(drawmode!=normalmode){
1730 glEnable(GL_TEXTURE_2D);
1732 if(!drawtoggle||drawmode!=realmotionblurmode||(drawtoggle==2||change==1)){
1735 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
1736 GLfloat subtractColor[4] = { 0.5, 0.5, 0.5, 0.0 };
1737 glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, subtractColor);
1738 //glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_SUBTRACT);
1739 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE);
1740 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_CONSTANT_EXT);
1741 glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 2.0f);
1743 glBindTexture( GL_TEXTURE_2D, screentexture);
1744 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1747 if((drawtoggle||change==1)&&drawmode==realmotionblurmode){
1749 glBindTexture( GL_TEXTURE_2D, screentexture2);
1750 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1752 if(!screentexture2){
1753 glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
1755 glGenTextures( 1, &screentexture2 );
1756 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
1758 glEnable(GL_TEXTURE_2D);
1759 glBindTexture( GL_TEXTURE_2D, screentexture2);
1760 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
1761 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
1763 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
1769 glClear(GL_DEPTH_BUFFER_BIT);
1770 Game::ReSizeGLScene(90,.1f);
1771 glViewport(0,0,screenwidth,screenheight);
1773 if(drawmode!=normalmode){
1774 glDisable(GL_DEPTH_TEST);
1775 if(drawmode==motionblurmode){
1776 glDrawBuffer(GL_FRONT);
1777 glReadBuffer(GL_BACK);
1779 glColor3f (1.0, 1.0, 1.0); // no coloring
1781 glEnable(GL_TEXTURE_2D);
1782 glBindTexture( GL_TEXTURE_2D, screentexture);
1783 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1784 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1785 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1786 glDisable(GL_CULL_FACE);
1787 glDisable(GL_LIGHTING);
1789 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1790 glPushMatrix(); // Store The Projection Matrix
1791 glLoadIdentity(); // Reset The Projection Matrix
1792 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
1793 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1794 glPushMatrix(); // Store The Modelview Matrix
1795 glLoadIdentity(); // Reset The Modelview Matrix
1796 glScalef((float)screenwidth/2,(float)screenheight/2,1);
1797 glTranslatef(1,1,0);
1798 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1800 if(drawmode==motionblurmode){
1801 if(motionbluramount<.2)motionbluramount=.2;
1802 //glColor4f(1,1,1,fast_sqrt(multiplier)*2.9*motionbluramount);
1803 glColor4f(1,1,1,motionbluramount);
1807 glVertex3f(-1, -1, 0.0f);
1808 glTexCoord2f(texcoordwidth,0);
1809 glVertex3f(1, -1, 0.0f);
1810 glTexCoord2f(texcoordwidth,texcoordheight);
1811 glVertex3f(1, 1, 0.0f);
1812 glTexCoord2f(0,texcoordheight);
1813 glVertex3f(-1, 1, 0.0f);
1817 if(drawmode==realmotionblurmode){
1818 glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
1819 glClear(GL_COLOR_BUFFER_BIT);
1820 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
1821 glBindTexture( GL_TEXTURE_2D, screentexture);
1822 glColor4f(1,1,1,.5);
1826 glVertex3f(-1, -1, 0.0f);
1827 glTexCoord2f(texcoordwidth,0);
1828 glVertex3f(1, -1, 0.0f);
1829 glTexCoord2f(texcoordwidth,texcoordheight);
1830 glVertex3f(1, 1, 0.0f);
1831 glTexCoord2f(0,texcoordheight);
1832 glVertex3f(-1, 1, 0.0f);
1835 glBindTexture( GL_TEXTURE_2D, screentexture2);
1836 glColor4f(1,1,1,.5);
1840 glVertex3f(-1, -1, 0.0f);
1841 glTexCoord2f(texcoordwidth,0);
1842 glVertex3f(1, -1, 0.0f);
1843 glTexCoord2f(texcoordwidth,texcoordheight);
1844 glVertex3f(1, 1, 0.0f);
1845 glTexCoord2f(0,texcoordheight);
1846 glVertex3f(-1, 1, 0.0f);
1849 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
1851 if(drawmode==doublevisionmode){
1852 static float crosseyedness;
1853 crosseyedness=abs(player[0].damage-player[0].superpermanentdamage-(player[0].damagetolerance-player[0].superpermanentdamage)*1/2)/30;
1854 if(crosseyedness>1)crosseyedness=1;
1855 if(crosseyedness<0)crosseyedness=0;
1857 glDisable(GL_BLEND);
1862 glVertex3f(-1, -1, 0.0f);
1863 glTexCoord2f(texcoordwidth,0);
1864 glVertex3f(1, -1, 0.0f);
1865 glTexCoord2f(texcoordwidth,texcoordheight);
1866 glVertex3f(1, 1, 0.0f);
1867 glTexCoord2f(0,texcoordheight);
1868 glVertex3f(-1, 1, 0.0f);
1872 glColor4f(1,1,1,.5);
1875 glTranslatef(.015*crosseyedness,0,0);
1879 glVertex3f(-1, -1, 0.0f);
1880 glTexCoord2f(texcoordwidth,0);
1881 glVertex3f(1, -1, 0.0f);
1882 glTexCoord2f(texcoordwidth,texcoordheight);
1883 glVertex3f(1, 1, 0.0f);
1884 glTexCoord2f(0,texcoordheight);
1885 glVertex3f(-1, 1, 0.0f);
1890 if(drawmode==glowmode){
1891 glColor4f(.5,.5,.5,.5);
1893 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
1895 glTranslatef(.01,0,0);
1898 glVertex3f(-1, -1, 0.0f);
1899 glTexCoord2f(texcoordwidth,0);
1900 glVertex3f(1, -1, 0.0f);
1901 glTexCoord2f(texcoordwidth,texcoordheight);
1902 glVertex3f(1, 1, 0.0f);
1903 glTexCoord2f(0,texcoordheight);
1904 glVertex3f(-1, 1, 0.0f);
1908 glTranslatef(-.01,0,0);
1911 glVertex3f(-1, -1, 0.0f);
1912 glTexCoord2f(texcoordwidth,0);
1913 glVertex3f(1, -1, 0.0f);
1914 glTexCoord2f(texcoordwidth,texcoordheight);
1915 glVertex3f(1, 1, 0.0f);
1916 glTexCoord2f(0,texcoordheight);
1917 glVertex3f(-1, 1, 0.0f);
1921 glTranslatef(.0,.01,0);
1924 glVertex3f(-1, -1, 0.0f);
1925 glTexCoord2f(texcoordwidth,0);
1926 glVertex3f(1, -1, 0.0f);
1927 glTexCoord2f(texcoordwidth,texcoordheight);
1928 glVertex3f(1, 1, 0.0f);
1929 glTexCoord2f(0,texcoordheight);
1930 glVertex3f(-1, 1, 0.0f);
1934 glTranslatef(0,-.01,0);
1937 glVertex3f(-1, -1, 0.0f);
1938 glTexCoord2f(texcoordwidth,0);
1939 glVertex3f(1, -1, 0.0f);
1940 glTexCoord2f(texcoordwidth,texcoordheight);
1941 glVertex3f(1, 1, 0.0f);
1942 glTexCoord2f(0,texcoordheight);
1943 glVertex3f(-1, 1, 0.0f);
1947 if(drawmode==radialzoommode){
1949 //glRotatef((float)i*.1,0,0,1);
1950 glColor4f(1,1,1,1/((float)i+1));
1952 glScalef(1+(float)i*.01,1+(float)i*.01,1);
1955 glVertex3f(-1, -1, 0.0f);
1956 glTexCoord2f(texcoordwidth,0);
1957 glVertex3f(1, -1, 0.0f);
1958 glTexCoord2f(texcoordwidth,texcoordheight);
1959 glVertex3f(1, 1, 0.0f);
1960 glTexCoord2f(0,texcoordheight);
1961 glVertex3f(-1, 1, 0.0f);
1966 glDisable(GL_TEXTURE_2D);
1967 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1968 glPopMatrix(); // Restore The Old Projection Matrix
1969 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1970 glPopMatrix(); // Restore The Old Projection Matrix
1971 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1972 glEnable(GL_CULL_FACE);
1973 glDisable(GL_BLEND);
1978 glEnable(GL_TEXTURE_2D);
1981 if(consoleselected>=60)
1982 offset=consoleselected-60;
1983 sprintf (string, " ]");
1984 text->glPrint(10,30,string,0,1,1024,768);
1986 sprintf (string, "_");
1987 text->glPrint(30+(float)(consoleselected)*10-offset*10,30,string,0,1,1024,768);
1990 for(j=0;j<consolechars[i];j++){
1991 glColor4f(1,1,1,1-(float)(i)/16);
1992 if(j<consolechars[i]){
1993 sprintf (string, "%c",consoletext[i][j]);
1994 text->glPrint(30+j*10-offset*10,30+i*20,string,0,1,1024,768);
2000 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)){
2001 multiplier=tempmult;
2008 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)){
2009 tempmult=multiplier;
2014 if ( side == stereoRight || side == stereoCenter ) {
2015 if(drawmode!=motionblurmode||mainmenu){
2020 //myassert(glGetError() == GL_NO_ERROR);
2021 glDrawBuffer(GL_BACK);
2022 glReadBuffer(GL_BACK);
2027 if(drawtoggle==2)drawtoggle=0;
2029 if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)){
2030 multiplier=tempmult;
2032 //Jordan fixed your warning!
2037 // !!! FIXME: hack: clamp framerate in menu so text input works correctly on fast systems.
2040 glDrawBuffer(GL_BACK);
2041 glReadBuffer(GL_BACK);
2042 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
2043 Game::ReSizeGLScene(90,.1f);
2045 //draw menu background
2046 glClear(GL_DEPTH_BUFFER_BIT);
2047 glEnable(GL_ALPHA_TEST);
2048 glAlphaFunc(GL_GREATER, 0.001f);
2049 glEnable(GL_TEXTURE_2D);
2050 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
2051 glDisable(GL_CULL_FACE);
2052 glDisable(GL_LIGHTING);
2054 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2055 glPushMatrix(); // Store The Projection Matrix
2056 glLoadIdentity(); // Reset The Projection Matrix
2057 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
2058 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2059 glPushMatrix(); // Store The Modelview Matrix
2060 glLoadIdentity(); // Reset The Modelview Matrix
2061 glTranslatef(screenwidth/2,screenheight/2,0);
2063 glScalef((float)screenwidth/2,(float)screenheight/2,1);
2064 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
2065 glDisable(GL_BLEND);
2066 glColor4f(0,0,0,1.0);
2067 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2068 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2069 glDisable(GL_TEXTURE_2D);
2071 glVertex3f(-1,-1,0);
2072 glVertex3f(+1,-1,0);
2073 glVertex3f(+1,+1,0);
2074 glVertex3f(-1,+1,0);
2077 glColor4f(0.4,0.4,0.4,1.0);
2078 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2079 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2080 glEnable(GL_TEXTURE_2D);
2081 Game::Mainmenuitems[4].bind();
2084 glVertex3f(-1,-1,0);
2086 glVertex3f(+1,-1,0);
2088 glVertex3f(+1,+1,0);
2090 glVertex3f(-1,+1,0);
2094 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2096 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2100 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2101 glPushMatrix(); // Store The Projection Matrix
2102 glLoadIdentity(); // Reset The Projection Matrix
2103 glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
2104 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2105 glPushMatrix(); // Store The Modelview Matrix
2106 glLoadIdentity(); // Reset The Modelview Matrix
2107 glEnable(GL_TEXTURE_2D);
2112 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2114 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2117 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2118 glPushMatrix(); // Store The Projection Matrix
2119 glLoadIdentity(); // Reset The Projection Matrix
2120 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
2121 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2122 glPushMatrix(); // Store The Modelview Matrix
2123 glLoadIdentity(); // Reset The Modelview Matrix
2124 glTranslatef(screenwidth/2,screenheight/2,0);
2126 glScalef((float)screenwidth/2,(float)screenheight/2,1);
2127 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
2129 glEnable(GL_TEXTURE_2D);
2131 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2132 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2134 if(!Game::waiting) { // hide the cursor while waiting for a key
2136 glTranslatef(Game::mousecoordh-screenwidth/2,Game::mousecoordv*-1+screenheight/2,0);
2137 glScalef((float)screenwidth/64,(float)screenwidth/64,1);
2138 glTranslatef(1,-1,0);
2139 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
2141 Game::cursortexture.bind();
2143 //glScalef(.25,.25,.25);
2146 glVertex3f(-1, -1, 0.0f);
2148 glVertex3f(1, -1, 0.0f);
2150 glVertex3f(1, 1, 0.0f);
2152 glVertex3f(-1, 1, 0.0f);
2158 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2165 if(flashamount>1)flashamount=1;
2166 if(flashdelay<=0)flashamount-=multiplier;
2168 if(flashamount<0)flashamount=0;
2169 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
2170 glDisable(GL_CULL_FACE);
2171 glDisable(GL_LIGHTING);
2172 glDisable(GL_TEXTURE_2D);
2174 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2175 glPushMatrix(); // Store The Projection Matrix
2176 glLoadIdentity(); // Reset The Projection Matrix
2177 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
2178 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2179 glPushMatrix(); // Store The Modelview Matrix
2180 glLoadIdentity(); // Reset The Modelview Matrix
2181 glScalef(screenwidth,screenheight,1);
2182 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
2184 glColor4f(flashr,flashg,flashb,flashamount);
2186 glVertex3f(0, 0, 0.0f);
2187 glVertex3f(256, 0, 0.0f);
2188 glVertex3f(256, 256, 0.0f);
2189 glVertex3f(0, 256, 0.0f);
2191 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2192 glPopMatrix(); // Restore The Old Projection Matrix
2193 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2194 glPopMatrix(); // Restore The Old Projection Matrix
2195 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
2196 glEnable(GL_CULL_FACE);
2197 glDisable(GL_BLEND);