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.
135 /*********************> DrawGLScene() <*****/
136 int Game::DrawGLScene(StereoSide side)
138 static float texcoordwidth, texcoordheight;
139 static float texviewwidth, texviewheight;
140 static int i, j, k, l;
141 static GLubyte color;
142 static XYZ checkpoint;
143 static float tempmult;
145 static char string[256] = "";
146 static char string2[256] = "";
147 static char string3[256] = "";
148 static int drawmode = 0;
150 if ( stereomode == stereoAnaglyph ) {
153 glColorMask( 0.0, 1.0, 1.0, 1.0 );
156 glColorMask( 1.0, 0.0, 0.0, 1.0 );
160 glColorMask( 1.0, 1.0, 1.0, 1.0 );
162 if ( stereomode == stereoHorizontalInterlaced || stereomode == stereoVerticalInterlaced ) {
163 glStencilFunc(side == stereoLeft ? GL_NOTEQUAL : GL_EQUAL, 0x01, 0x01);
167 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted)) {
168 tempmult = multiplier;
174 numboundaries = mapradius * 2;
175 if (numboundaries > 360)
177 for (i = 0; i < numboundaries; i++) {
180 boundary[i] = mapcenter + DoRotation(boundary[i] * mapradius, 0, i * (360 / ((float)(numboundaries))), 0);
189 int olddrawmode = drawmode;
190 if (ismotionblur && !loading) {
191 if ((findLengthfast(&player[0].velocity) > 200) && velocityblur && !cameramode) {
192 drawmode = motionblurmode;
193 motionbluramount = 200 / (findLengthfast(&player[0].velocity));
196 if (player[0].damage - player[0].superpermanentdamage > (player[0].damagetolerance - player[0].superpermanentdamage) * 1 / 2 && damageeffects && !cameramode) {
197 drawmode = doublevisionmode;
202 if (slomo && !loading) {
204 drawmode = motionblurmode;
205 motionbluramount = .2;
206 slomodelay -= multiplier;
212 if ((!changed && !slomo) || loading) {
213 drawmode = normalmode;
214 if (ismotionblur && (/*fps>100||*/alwaysblur)) {
215 if (olddrawmode != realmotionblurmode)
219 drawmode = realmotionblurmode;
220 } else if (olddrawmode == realmotionblurmode)
226 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted))
227 drawmode = normalmode;
228 if ((freeze || winfreeze) && ismotionblur && !mainmenu)
229 drawmode = radialzoommode;
231 if (winfreeze || mainmenu)
232 drawmode = normalmode;
235 if (drawmode == glowmode) {
240 DSpContext_FadeGamma(NULL, 200, &color2);
245 drawtoggle = 1 - drawtoggle;
247 if (!texcoordwidth) {
248 texviewwidth = kTextureSize;
249 if (texviewwidth > screenwidth)
250 texviewwidth = screenwidth;
251 texviewheight = kTextureSize;
252 if (texviewheight > screenheight)
253 texviewheight = screenheight;
255 texcoordwidth = screenwidth / kTextureSize;
256 texcoordheight = screenheight / kTextureSize;
257 if (texcoordwidth > 1)
259 if (texcoordheight > 1)
263 glDrawBuffer(GL_BACK);
264 glReadBuffer(GL_BACK);
267 static XYZ terrainlight;
268 static float distance;
269 if (drawmode == normalmode)
270 Game::ReSizeGLScene(90, .1f);
271 if (drawmode != normalmode)
272 glViewport(0, 0, texviewwidth, texviewheight);
273 glDepthFunc(GL_LEQUAL);
275 glAlphaFunc(GL_GREATER, 0.0001f);
276 glEnable(GL_ALPHA_TEST);
277 glClearColor(0.25f, 0.25f, 0.25f, 1.0f);
278 glClear(GL_DEPTH_BUFFER_BIT);
280 glMatrixMode (GL_MODELVIEW);
281 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
284 // Move the camera for the current eye's point of view.
285 // Reverse the movement if we're reversing stereo
286 glTranslatef((stereoseparation / 2) * side * (stereoreverse ? -1 : 1), 0, 0);
289 if (!cameramode && !freeze && !winfreeze) {
291 glRotatef(float(Random() % 100) / 10 * camerashake/*+(woozy*woozy)/10*/, 0, 0, 1);
293 glRotatef(pitch + sin(woozy / 2) * (player[0].damage / player[0].damagetolerance) * 5, 1, 0, 0);
294 glRotatef(yaw + sin(woozy) * (player[0].damage / player[0].damagetolerance) * 5, 0, 1, 0);
296 if (cameramode || freeze || winfreeze) {
297 glRotatef(pitch, 1, 0, 0);
298 glRotatef(yaw, 0, 1, 0);
301 if (environment == desertenvironment) {
302 glRotatef((float)(abs(Random() % 100)) / 3000 - 1, 1, 0, 0);
303 glRotatef((float)(abs(Random() % 100)) / 3000 - 1, 0, 1, 0);
305 SetUpLight(&light, 0);
308 //heat blur effect in desert
309 if (abs(blurness - targetblurness) < multiplier * 10 || abs(blurness - targetblurness) > 2) {
310 blurness = targetblurness;
311 targetblurness = (float)(abs(Random() % 100)) / 40;
313 if (blurness < targetblurness)
314 blurness += multiplier * 5;
316 blurness -= multiplier * 5;
318 if (environment == desertenvironment && detail == 2)
319 glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, blurness + .4 );
320 if (environment == desertenvironment) {
321 glRotatef((float)(abs(Random() % 100)) / 1000, 1, 0, 0);
322 glRotatef((float)(abs(Random() % 100)) / 1000, 0, 1, 0);
325 glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0);
327 glTranslatef(-viewer.x, -viewer.y, -viewer.z);
328 frustum.GetFrustum();
330 //make shadow decals on terrain and objects
332 static float size, opacity, rotation;
334 for (k = 0; k < numplayers; k++) {
335 if (!player[k].skeleton.free && player[k].playerdetail && player[k].howactive < typesleeping)
336 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)
337 for (i = 0; i < player[k].skeleton.num_joints; i++) {
338 if (player[k].skeleton.joints[i].label == leftknee || player[k].skeleton.joints[i].label == rightknee || player[k].skeleton.joints[i].label == groin) {
339 point = DoRotation(player[k].skeleton.joints[i].position, 0, player[k].yaw, 0) * player[k].scale + player[k].coords;
341 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;
342 if (k != 0 && tutoriallevel == 1) {
343 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;
345 terrain.MakeDecal(shadowdecal, point, size, opacity, rotation);
346 for (l = 0; l < terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz]; l++) {
347 j = terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
348 if (objects.position[j].y < player[k].coords.y || objects.type[j] == tunneltype || objects.type[j] == weirdtype) {
349 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);
352 if (k != 0 && tutoriallevel == 1) {
353 opacity = .2 + .2 * sin(smoketex * 6 + i);
355 objects.model[j].MakeDecal(shadowdecal, &point, &size, &opacity, &rotation);
360 if ((player[k].skeleton.free || player[k].howactive >= typesleeping) && player[k].playerdetail)
361 if (frustum.SphereInFrustum(player[k].coords.x, player[k].coords.y, player[k].coords.z, player[k].scale * 5) && player[k].occluded < 25)
362 for (i = 0; i < player[k].skeleton.num_joints; i++) {
363 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) {
364 if (player[k].skeleton.free)
365 point = player[k].skeleton.joints[i].position * player[k].scale + player[k].coords;
367 point = DoRotation(player[k].skeleton.joints[i].position, 0, player[k].yaw, 0) * player[k].scale + player[k].coords;
369 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;
370 if (k != 0 && tutoriallevel == 1) {
371 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;
373 terrain.MakeDecal(shadowdecal, point, size, opacity * .7, rotation);
374 for (l = 0; l < terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz]; l++) {
375 j = terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
376 if (objects.position[j].y < player[k].coords.y || objects.type[j] == tunneltype || objects.type[j] == weirdtype) {
377 if (player[k].skeleton.free)
378 point = DoRotation(player[k].skeleton.joints[i].position * player[k].scale + player[k].coords - objects.position[j], 0, -objects.yaw[j], 0);
380 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);
383 if (k != 0 && tutoriallevel == 1) {
384 opacity = .2 + .2 * sin(smoketex * 6 + i);
386 objects.model[j].MakeDecal(shadowdecal, &point, &size, &opacity, &rotation);
392 if (!player[k].playerdetail)
393 if (frustum.SphereInFrustum(player[k].coords.x, player[k].coords.y, player[k].coords.z, player[k].scale * 5)) {
394 point = player[k].coords;
396 opacity = .4 - (player[k].coords.y - terrain.getHeight(player[k].coords.x, player[k].coords.z)) / 5;
397 terrain.MakeDecal(shadowdecal, point, size, opacity * .7, rotation);
398 for (l = 0; l < terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz]; l++) {
399 j = terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
400 point = DoRotation(player[k].coords - objects.position[j], 0, -objects.yaw[j], 0);
403 objects.model[j].MakeDecal(shadowdecal, &point, &size, &opacity, &rotation);
409 glEnable(GL_TEXTURE_2D);
411 glEnable(GL_DEPTH_TEST);
412 glEnable(GL_CULL_FACE);
414 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
415 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
416 terraintexture.bind();
418 terraintexture2.bind();
420 //glBindTexture( GL_TEXTURE_2D, terraintexture3);
421 //glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
424 terrain.drawdecals();
427 glEnable(GL_CULL_FACE);
428 glEnable(GL_LIGHTING);
430 glEnable(GL_TEXTURE_2D);
433 glEnable(GL_COLOR_MATERIAL);
448 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
449 glEnable(GL_CULL_FACE);
450 glCullFace(GL_FRONT);
452 for (k = 0; k < numplayers; k++) {
453 if (k == 0 || tutoriallevel != 1) {
455 glEnable(GL_LIGHTING);
456 terrainlight = terrain.getLighting(player[k].coords.x, player[k].coords.z);
457 distance = distsq(&viewer, &player[k].coords);
458 distance = (viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance;
459 glColor4f(terrainlight.x, terrainlight.y, terrainlight.z, distance);
462 if (distance >= .5) {
463 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;
465 if (!player[k].occluded == 0)
466 i = checkcollide(viewer, checkpoint, player[k].lastoccluded);
467 if (i == -1 || player[k].occluded == 0)
468 i = checkcollide(viewer, checkpoint);
470 player[k].occluded += 1;
471 player[k].lastoccluded = i;
473 player[k].occluded = 0;
475 if (player[k].occluded < 25)
476 player[k].DrawSkeleton();
482 if (!cameramode && musictype == stream_fighttheme)
483 playerdist = distsqflat(&player[0].coords, &viewer);
488 glEnable(GL_TEXTURE_2D);
494 if (frustum.SphereInFrustum(realhawkcoords.x + hawk.boundingspherecenter.x, realhawkcoords.y + hawk.boundingspherecenter.y, realhawkcoords.z + hawk.boundingspherecenter.z, 2)) {
495 glAlphaFunc(GL_GREATER, 0.0001f);
497 glDisable(GL_CULL_FACE);
498 glDisable(GL_LIGHTING);
500 glTranslatef(hawkcoords.x, hawkcoords.y, hawkcoords.z);
501 glRotatef(hawkyaw, 0, 1, 0);
502 glTranslatef(25, 0, 0);
503 distance = distsq(&viewer, &realhawkcoords) * 1.2;
504 glColor4f(light.color[0], light.color[1], light.color[2], (viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance);
505 if ((viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance > 1)
506 glColor4f(light.color[0], light.color[1], light.color[2], 1);
507 if ((viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance > 0)
508 hawk.drawdifftex(hawktexture);
512 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
513 glEnable(GL_CULL_FACE);
514 glCullFace(GL_FRONT);
516 for (k = 0; k < numplayers; k++) {
517 if (!(k == 0 || tutoriallevel != 1)) {
519 glEnable(GL_LIGHTING);
520 terrainlight = terrain.getLighting(player[k].coords.x, player[k].coords.z);
521 distance = distsq(&viewer, &player[k].coords);
522 distance = (viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance;
523 glColor4f(terrainlight.x, terrainlight.y, terrainlight.z, distance);
526 if (distance >= .5) {
527 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;
529 if (!player[k].occluded == 0)
530 i = checkcollide(viewer, checkpoint, player[k].lastoccluded);
531 if (i == -1 || player[k].occluded == 0)
532 i = checkcollide(viewer, checkpoint);
534 player[k].occluded += 1;
535 player[k].lastoccluded = i;
537 player[k].occluded = 0;
539 if (player[k].occluded < 25)
540 player[k].DrawSkeleton();
546 glEnable(GL_TEXTURE_2D);
551 glDisable(GL_COLOR_MATERIAL);
553 glDisable(GL_LIGHTING);
554 glDisable(GL_TEXTURE_2D);
560 //waypoints, pathpoints in editor
563 glDisable(GL_LIGHTING);
564 glDisable(GL_TEXTURE_2D);
565 glDisable(GL_COLOR_MATERIAL);
566 glColor4f(1, 1, 0, 1);
568 for (k = 0; k < numplayers; k++) {
569 if (player[k].numwaypoints > 1) {
570 glBegin(GL_LINE_LOOP);
571 for (i = 0; i < player[k].numwaypoints; i++) {
572 glVertex3f(player[k].waypoints[i].x, player[k].waypoints[i].y + .5, player[k].waypoints[i].z);
579 if (numpathpoints > 1) {
580 glColor4f(0, 1, 0, 1);
581 for (k = 0; k < numpathpoints; k++) {
582 if (numpathpointconnect[k]) {
583 for (i = 0; i < numpathpointconnect[k]; i++) {
584 glBegin(GL_LINE_LOOP);
585 glVertex3f(pathpoint[k].x, pathpoint[k].y + .5, pathpoint[k].z);
586 glVertex3f(pathpoint[pathpointconnect[k][i]].x, pathpoint[pathpointconnect[k][i]].y + .5, pathpoint[pathpointconnect[k][i]].z);
591 glColor4f(1, 1, 1, 1);
594 glVertex3f(pathpoint[pathpointselected].x, pathpoint[pathpointselected].y + .5, pathpoint[pathpointselected].z);
601 glEnable(GL_TEXTURE_2D);
602 glColor4f(.5, .5, .5, 1);
604 sprintf (string, " ", (int)(fps));
605 text->glPrint(10, 30, string, 0, .8, screenwidth, screenheight);
608 if (bonus > 0 && bonustime < 1 && !winfreeze && indialogue == -1/*bonustime<4*/) {
609 const char *bonus_name;
610 if (bonus < bonus_count)
611 bonus_name = bonus_names[bonus];
613 bonus_name = "Excellent!"; // When does this happen?
615 glColor4f(0, 0, 0, 1 - bonustime);
616 text->glPrintOutline(1024 / 2 - 10 * strlen(bonus_name) - 4, 768 / 16 - 4 + 768 * 4 / 5, bonus_name, 1, 2.5, 1024, 768);
617 glColor4f(1, 0, 0, 1 - bonustime);
618 text->glPrint(1024 / 2 - 10 * strlen(bonus_name), 768 / 16 + 768 * 4 / 5, bonus_name, 1, 2, 1024, 768);
620 sprintf (string, "%d", (int)bonusvalue);
621 glColor4f(0, 0, 0, 1 - bonustime);
622 text->glPrintOutline(1024 / 2 - 10 * strlen(string) - 4, 768 / 16 - 4 - 20 + 768 * 4 / 5, string, 1, 2.5 * .8, 1024, 768);
623 glColor4f(1, 0, 0, 1 - bonustime);
624 text->glPrint(1024 / 2 - 10 * strlen(string), 768 / 16 - 20 + 768 * 4 / 5, string, 1, 2 * .8, 1024, 768);
625 glColor4f(.5, .5, .5, 1);
628 if (tutoriallevel == 1) {
629 tutorialopac = tutorialmaxtime - tutorialstagetime;
630 if (tutorialopac > 1)
632 if (tutorialopac < 0)
635 sprintf (string, " ");
636 sprintf (string2, " ");
637 sprintf (string3, " ");
638 if (tutorialstage == 0) {
639 sprintf (string, " ");
640 sprintf (string2, " ");
641 sprintf (string3, " ");
643 if (tutorialstage == 1) {
644 sprintf (string, "Welcome to the Lugaru training level!");
645 sprintf (string2, " ");
646 sprintf (string3, " ");
648 if (tutorialstage == 2) {
649 sprintf (string, "BASIC MOVEMENT:");
650 sprintf (string2, " ");
651 sprintf (string3, " ");
653 if (tutorialstage == 3) {
654 sprintf (string, "You can move the mouse to rotate the camera.");
655 sprintf (string2, " ");
656 sprintf (string3, " ");
658 if (tutorialstage == 4) {
659 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));
660 sprintf (string2, "All movement is relative to the camera.");
661 sprintf (string3, " ");
663 if (tutorialstage == 5) {
664 sprintf (string, "Please press %s to jump.", Input::keyToChar(jumpkey));
665 sprintf (string2, "You can hold it longer to jump higher.");
666 sprintf (string3, " ");
668 if (tutorialstage == 6) {
669 sprintf (string, "You can press %s to crouch.", Input::keyToChar(crouchkey));
670 sprintf (string2, "You can jump higher from a crouching position.");
671 sprintf (string3, " ");
673 if (tutorialstage == 7) {
674 sprintf (string, "While running, you can press %s to roll.", Input::keyToChar(crouchkey));
675 sprintf (string2, " ");
676 sprintf (string3, " ");
678 if (tutorialstage == 8) {
679 sprintf (string, "While crouching, you can sneak around silently");
680 sprintf (string2, "using the movement keys.");
681 sprintf (string3, " ");
683 if (tutorialstage == 9) {
684 sprintf (string, "Release the crouch key while sneaking and hold the movement keys");
685 sprintf (string2, "to run animal-style.");
686 sprintf (string3, " ");
688 if (tutorialstage == 10) {
689 sprintf (string, "ADVANCED MOVEMENT:");
690 sprintf (string2, " ");
691 sprintf (string3, " ");
693 if (tutorialstage == 11) {
694 sprintf (string, "When you jump at a wall, you can hold %s again", Input::keyToChar(jumpkey));
695 sprintf (string2, "during impact to perform a walljump.");
696 sprintf (string3, "Be sure to use the movement keys to press against the wall");
698 if (tutorialstage == 12) {
699 sprintf (string, "While in the air, you can press crouch to flip.", Input::keyToChar(jumpkey));
700 sprintf (string2, "Walljumps and flips confuse enemies and give you more control.");
701 sprintf (string3, " ");
703 if (tutorialstage == 13) {
704 sprintf (string, "BASIC COMBAT:");
705 sprintf (string2, " ");
706 sprintf (string3, " ");
708 if (tutorialstage == 14) {
709 sprintf (string, "There is now an imaginary enemy");
710 sprintf (string2, "in the middle of the training area.");
711 sprintf (string3, " ");
713 if (tutorialstage == 15) {
714 if (attackkey == MOUSEBUTTON1)
715 sprintf (string, "Click to attack when you are near an enemy.");
717 sprintf (string, "Press %s to attack when you are near an enemy.", Input::keyToChar(attackkey));
718 sprintf (string2, "You can punch by standing still near an enemy and attacking.");
719 sprintf (string3, " ");
721 if (tutorialstage == 16) {
722 sprintf (string, "If you are close, you will perform a weak punch.");
723 sprintf (string2, "The weak punch is excellent for starting attack combinations.");
724 sprintf (string3, " ");
726 if (tutorialstage == 17) {
727 sprintf (string, "Attacking while running results in a spin kick.");
728 sprintf (string2, "This is one of your most powerful ground attacks.");
729 sprintf (string3, " ");
731 if (tutorialstage == 18) {
732 sprintf (string, "Sweep the enemy's legs out by attacking while crouched.");
733 sprintf (string2, "This is a very fast attack, and easy to follow up.");
734 sprintf (string3, " ");
736 if (tutorialstage == 19) {
737 sprintf (string, "When an enemy is on the ground, you can deal some extra");
738 sprintf (string2, "damage by running up and drop-kicking him.");
739 sprintf (string3, "(Try knocking them down with a sweep first)");
741 if (tutorialstage == 20) {
742 sprintf (string, "Your most powerful individual attack is the rabbit kick.");
743 if (attackkey == MOUSEBUTTON1)
744 sprintf (string2, "Run at the enemy while holding the mouse button, and press");
746 sprintf (string2, "Run at the enemy while holding %s, and press", Input::keyToChar(attackkey));
747 sprintf (string3, "the jump key (%s) to attack.", Input::keyToChar(jumpkey));
749 if (tutorialstage == 21) {
750 sprintf (string, "This attack is devastating if timed correctly.");
751 sprintf (string2, "Even if timed incorrectly, it will knock the enemy over.");
753 sprintf (string3, "Try rabbit-kicking the imaginary enemy again.");
755 sprintf (string3, "Try rabbit-kicking the imaginary enemy.");
757 if (tutorialstage == 22) {
758 sprintf (string, "If you sneak behind an enemy unnoticed, you can kill");
759 sprintf (string2, "him instantly. Move close behind this enemy");
760 sprintf (string3, "and attack.");
762 if (tutorialstage == 23) {
763 sprintf (string, "Another important attack is the wall kick. When an enemy");
764 sprintf (string2, "is near a wall, perform a walljump nearby and hold");
765 sprintf (string3, "the attack key during impact with the wall.");
767 if (tutorialstage == 24) {
768 sprintf (string, "You can tackle enemies by running at them animal-style");
769 if (attackkey == MOUSEBUTTON1)
770 sprintf (string2, "and pressing jump (%s) or attack(mouse button).", Input::keyToChar(jumpkey));
772 sprintf (string2, "and pressing jump (%s) or attack(%s).", Input::keyToChar(jumpkey), Input::keyToChar(attackkey));
773 sprintf (string3, "This is especially useful when they are running away.");
775 if (tutorialstage == 25) {
776 sprintf (string, "Dodge by pressing back and attack. Dodging is essential");
777 sprintf (string2, "against enemies with swords or other long weapons.");
778 sprintf (string3, " ");
780 if (tutorialstage == 26) {
781 sprintf (string, "REVERSALS AND COUNTER-REVERSALS");
782 sprintf (string2, " ");
783 sprintf (string3, " ");
785 if (tutorialstage == 27) {
786 sprintf (string, "The enemy can now reverse your attacks.");
787 sprintf (string2, " ");
788 sprintf (string3, " ");
790 if (tutorialstage == 28) {
791 sprintf (string, "If you attack, you will notice that the enemy now sometimes");
792 sprintf (string2, "catches your attack and uses it against you. Hold");
793 sprintf (string3, "crouch (%s) after attacking to escape from reversals.", Input::keyToChar(crouchkey));
795 if (tutorialstage == 29) {
796 sprintf (string, "Try escaping from two more reversals in a row.");
797 sprintf (string2, " ");
798 sprintf (string3, " ");
800 if (tutorialstage == 30) {
801 sprintf (string, "Good!");
802 sprintf (string2, " ");
803 sprintf (string3, " ");
805 if (tutorialstage == 31) {
806 sprintf (string, "To reverse an attack, you must tap crouch (%s) during the", Input::keyToChar(crouchkey));
807 sprintf (string2, "enemy's attack. You must also be close to the enemy;");
808 sprintf (string3, "this is especially important against armed opponents.");
810 if (tutorialstage == 32) {
811 sprintf (string, "The enemy can attack in %d seconds.", (int)(tutorialmaxtime - tutorialstagetime));
812 sprintf (string2, "This imaginary opponents attacks will be highlighted");
813 sprintf (string3, "to make this easier.");
815 if (tutorialstage == 33) {
816 sprintf (string, "Reverse three enemy attacks!");
817 sprintf (string2, " ");
818 sprintf (string3, " ");
820 if (tutorialstage == 34) {
821 sprintf (string, "Reverse two more enemy attacks!");
822 sprintf (string2, " ");
823 sprintf (string3, " ");
825 if (tutorialstage == 35) {
826 sprintf (string, "Reverse one more enemy attack!");
827 sprintf (string2, " ");
828 sprintf (string3, " ");
830 if (tutorialstage == 36) {
831 sprintf (string, "Excellent!");
832 sprintf (string2, " ");
833 sprintf (string3, " ");
835 if (tutorialstage == 37) {
836 sprintf (string, "Now spar with the enemy for %d more seconds.", (int)(tutorialmaxtime - tutorialstagetime));
837 sprintf (string2, "Damage dealt: %d", (int)damagedealt);
838 sprintf (string3, "Damage taken: %d.", (int)damagetaken);
840 if (tutorialstage == 38) {
841 sprintf (string, "WEAPONS:");
842 sprintf (string2, " ");
843 sprintf (string3, " ");
845 if (tutorialstage == 39) {
846 sprintf (string, "There is now an imaginary knife");
847 sprintf (string2, "in the center of the training area.");
848 sprintf (string3, " ");
850 if (tutorialstage == 40) {
851 sprintf (string, "Stand, roll or handspring over the knife");
852 sprintf (string2, "while pressing %s to pick it up.", Input::keyToChar(throwkey));
853 sprintf (string3, "You can crouch and press the same key to drop it again.");
855 if (tutorialstage == 41) {
856 sprintf (string, "You can equip and unequip weapons using the %s key.", Input::keyToChar(drawkey));
857 sprintf (string2, "Sometimes it is best to keep them unequipped to");
858 sprintf (string3, "prevent enemies from taking them. ");
860 if (tutorialstage == 42) {
861 sprintf (string, "The knife is the smallest weapon and the least encumbering.");
862 sprintf (string2, "You can equip or unequip it while standing, crouching,");
863 sprintf (string3, "running or flipping.");
865 if (tutorialstage == 43) {
866 sprintf (string, "You perform weapon attacks the same way as unarmed attacks,");
867 sprintf (string2, "but sharp weapons cause permanent damage, instead of the");
868 sprintf (string3, "temporary trauma from blunt weapons, fists and feet.");
870 if (tutorialstage == 44) {
871 sprintf (string, "The enemy now has your knife!");
872 sprintf (string2, "Please reverse two of his knife attacks.");
873 sprintf (string3, " ");
875 if (tutorialstage == 45) {
876 sprintf (string, "Please reverse one more of his knife attacks.");
877 sprintf (string2, " ");
878 sprintf (string3, " ");
880 if (tutorialstage == 46) {
881 sprintf (string, "Now he has a sword!");
882 sprintf (string2, "The sword has longer reach than your arms, so you");
883 sprintf (string3, "must move close to reverse the sword slash.");
885 if (tutorialstage == 47) {
886 sprintf (string, "Long weapons like the sword and staff are also useful for defense;");
887 sprintf (string2, "you can parry enemy weapon attacks by pressing the attack key");
888 sprintf (string3, "at the right time. Please try parrying the enemy's attacks!");
890 if (tutorialstage == 48) {
891 sprintf (string, "The staff is like the sword, but has two main attacks.");
892 sprintf (string2, "The standing smash is fast and effective, and the running");
893 sprintf (string3, "spin smash is slower and more powerful.");
895 if (tutorialstage == 49) {
896 sprintf (string, "When facing an enemy, you can throw the knife with %s.", Input::keyToChar(throwkey));
897 sprintf (string2, "It is possible to throw the knife while flipping,");
898 sprintf (string3, "but it is very inaccurate.");
900 if (tutorialstage == 50) {
901 sprintf (string, "You now know everything you can learn from training.");
902 sprintf (string2, "Everything else you must learn from experience!");
903 sprintf (string3, " ");
905 if (tutorialstage == 51) {
906 sprintf (string, "Walk out of the training area to return to the main menu.");
907 sprintf (string2, " ");
908 sprintf (string3, " ");
911 glColor4f(0, 0, 0, tutorialopac);
912 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);
913 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);
914 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);
915 glColor4f(1, 1, 1, tutorialopac);
916 text->glPrint(screenwidth / 2 - 7.6 * strlen(string)*screenwidth / 1024, screenheight / 16 + screenheight * 4 / 5, string, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight);
917 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);
918 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);
920 sprintf (string, "Press 'tab' to skip to the next item.", Input::keyToChar(jumpkey));
921 sprintf (string2, "Press escape at any time to");
922 sprintf (string3, "pause or exit the tutorial.");
924 glColor4f(0, 0, 0, 1);
925 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);
926 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);
927 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);
928 glColor4f(0.5, 0.5, 0.5, 1);
929 text->glPrint(screenwidth / 2 - 7.6 * strlen(string)*screenwidth / 1024 * .8, 0 + screenheight * 1 / 10, string, 1, 1.5 * screenwidth / 1024 * .8, screenwidth, screenheight);
930 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);
931 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);
935 if (numhotspots && (bonustime >= 1 || bonus <= 0 || bonustime < 0) && !tutoriallevel) {
937 float closestdist = -1;
939 closest = currenthotspot;
940 for (i = 0; i < numhotspots; i++) {
941 distance = distsq(&player[0].coords, &hotspot[i]);
942 if (closestdist == -1 || distance < closestdist) {
943 if (distsq(&player[0].coords, &hotspot[i]) < hotspotsize[i] && ((hotspottype[i] <= 10 && hotspottype[i] >= 0) || (hotspottype[i] <= 40 && hotspottype[i] >= 20))) {
944 closestdist = distance;
950 currenthotspot = closest;
951 if (currenthotspot != -1) {
952 if (hotspottype[closest] <= 10) {
953 if (distsq(&player[0].coords, &hotspot[closest]) < hotspotsize[closest])
954 tutorialstagetime = 0;
956 tutorialopac = tutorialmaxtime - tutorialstagetime;
957 if (tutorialopac > 1)
959 if (tutorialopac < 0)
962 sprintf (string, "%s", hotspottext[closest]);
969 if (string[i] == '\n' || string[i] > 'z' || string[i] < ' ' || string[i] == '\0') {
970 glColor4f(0, 0, 0, tutorialopac);
971 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);
972 glColor4f(1, 1, 1, tutorialopac);
973 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);
976 if (string[i] == '\0')
983 } else if (hotspottype[closest] >= 20 && dialoguegonethrough[hotspottype[closest] - 20] == 0) {
984 whichdialogue = hotspottype[closest] - 20;
985 for (j = 0; j < numdialogueboxes[whichdialogue]; j++) {
986 player[participantfocus[whichdialogue][j]].coords = participantlocation[whichdialogue][participantfocus[whichdialogue][j]];
987 player[participantfocus[whichdialogue][j]].yaw = participantyaw[whichdialogue][participantfocus[whichdialogue][j]];
988 player[participantfocus[whichdialogue][j]].targetyaw = participantyaw[whichdialogue][participantfocus[whichdialogue][j]];
989 player[participantfocus[whichdialogue][j]].velocity = 0;
990 player[participantfocus[whichdialogue][j]].animTarget = player[participantfocus[whichdialogue][j]].getIdle();
991 player[participantfocus[whichdialogue][j]].frameTarget = 0;
995 dialoguegonethrough[whichdialogue]++;
996 if (dialogueboxsound[whichdialogue][indialogue] != 0) {
998 if (dialogueboxsound[whichdialogue][indialogue] == 1) whichsoundplay = rabbitchitter;
999 if (dialogueboxsound[whichdialogue][indialogue] == 2) whichsoundplay = rabbitchitter2;
1000 if (dialogueboxsound[whichdialogue][indialogue] == 3) whichsoundplay = rabbitpainsound;
1001 if (dialogueboxsound[whichdialogue][indialogue] == 4) whichsoundplay = rabbitpain1sound;
1002 if (dialogueboxsound[whichdialogue][indialogue] == 5) whichsoundplay = rabbitattacksound;
1003 if (dialogueboxsound[whichdialogue][indialogue] == 6) whichsoundplay = rabbitattack2sound;
1004 if (dialogueboxsound[whichdialogue][indialogue] == 7) whichsoundplay = rabbitattack3sound;
1005 if (dialogueboxsound[whichdialogue][indialogue] == 8) whichsoundplay = rabbitattack4sound;
1006 if (dialogueboxsound[whichdialogue][indialogue] == 9) whichsoundplay = growlsound;
1007 if (dialogueboxsound[whichdialogue][indialogue] == 10) whichsoundplay = growl2sound;
1008 if (dialogueboxsound[whichdialogue][indialogue] == 11) whichsoundplay = snarlsound;
1009 if (dialogueboxsound[whichdialogue][indialogue] == 12) whichsoundplay = snarl2sound;
1010 if (dialogueboxsound[whichdialogue][indialogue] == 13) whichsoundplay = barksound;
1011 if (dialogueboxsound[whichdialogue][indialogue] == 14) whichsoundplay = bark2sound;
1012 if (dialogueboxsound[whichdialogue][indialogue] == 15) whichsoundplay = bark3sound;
1013 if (dialogueboxsound[whichdialogue][indialogue] == 16) whichsoundplay = barkgrowlsound;
1014 if (dialogueboxsound[whichdialogue][indialogue] == -1) whichsoundplay = fireendsound;
1015 if (dialogueboxsound[whichdialogue][indialogue] == -2) whichsoundplay = firestartsound;
1016 if (dialogueboxsound[whichdialogue][indialogue] == -3) whichsoundplay = consolesuccesssound;
1017 if (dialogueboxsound[whichdialogue][indialogue] == -4) whichsoundplay = consolefailsound;
1018 emit_sound_at(whichsoundplay, player[participantfocus[whichdialogue][indialogue]].coords);
1024 if (indialogue != -1 && !mainmenu) {
1025 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1026 glDisable(GL_CULL_FACE);
1027 glDisable(GL_LIGHTING);
1028 glDisable(GL_TEXTURE_2D);
1030 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1031 glPushMatrix(); // Store The Projection Matrix
1032 glLoadIdentity(); // Reset The Projection Matrix
1033 glOrtho(0, screenwidth, 0, screenheight, -100, 100); // Set Up An Ortho Screen
1034 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1035 glPushMatrix(); // Store The Modelview Matrix
1036 glLoadIdentity(); // Reset The Modelview Matrix
1037 if (dialogueboxlocation[whichdialogue][indialogue] == 1)
1038 glTranslatef(0, screenheight * 3 / 4, 0);
1039 glScalef(screenwidth, screenheight / 4, 1);
1040 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1043 glColor4f(dialogueboxcolor[whichdialogue][indialogue][0], dialogueboxcolor[whichdialogue][indialogue][1], dialogueboxcolor[whichdialogue][indialogue][2], 0.7);
1045 glVertex3f(0, 0, 0.0f);
1046 glVertex3f(1, 0, 0.0f);
1047 glVertex3f(1, 1, 0.0f);
1048 glVertex3f(0, 1, 0.0f);
1050 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1051 glPopMatrix(); // Restore The Old Projection Matrix
1052 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1053 glPopMatrix(); // Restore The Old Projection Matrix
1054 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1055 glEnable(GL_CULL_FACE);
1056 glDisable(GL_BLEND);
1058 glEnable(GL_TEXTURE_2D);
1065 startx = screenwidth * 1 / 5;
1066 if (dialogueboxlocation[whichdialogue][indialogue] == 1)
1067 starty = screenheight / 16 + screenheight * 4 / 5;
1068 if (dialogueboxlocation[whichdialogue][indialogue] == 2)
1069 starty = screenheight * 1 / 5 - screenheight / 16;
1074 for (i = 0; i < 264; i++) {
1078 for (i = 0; i < (int)strlen(dialoguename[whichdialogue][indialogue]); i++) {
1079 tempname[tempnum] = dialoguename[whichdialogue][indialogue][i];
1081 if (dialoguename[whichdialogue][indialogue][i] == '#' || dialoguename[whichdialogue][indialogue][i] == '\0')
1086 tempname[tempnum] = '\0';
1089 sprintf (string, "%s: ", tempname);
1091 if (dialogueboxcolor[whichdialogue][indialogue][0] + dialogueboxcolor[whichdialogue][indialogue][1] + dialogueboxcolor[whichdialogue][indialogue][2] < 1.5) {
1092 glColor4f(0, 0, 0, tutorialopac);
1093 text->glPrintOutline(startx - 2 * 7.6 * strlen(string)*screenwidth / 1024 - 4, starty - 4, string, 1, 1.5 * 1.25 * screenwidth / 1024, screenwidth, screenheight);
1094 glColor4f(0.7, 0.7, 0.7, tutorialopac);
1095 text->glPrint(startx - 2 * 7.6 * strlen(string)*screenwidth / 1024, starty, string, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight);
1097 glColor4f(0, 0, 0, tutorialopac);
1098 text->glPrintOutline(startx - 2 * 7.6 * strlen(string)*screenwidth / 1024 - 4, starty - 4, string, 1, 1.5 * 1.25 * screenwidth / 1024, screenwidth, screenheight);
1102 for (i = 0; i < (int)strlen(dialoguetext[whichdialogue][indialogue]) + 1; i++) {
1103 tempname[tempnum] = dialoguetext[whichdialogue][indialogue][i];
1104 if (dialoguetext[whichdialogue][indialogue][i] != '#')
1108 sprintf (string, "%s", tempname);
1115 if (string[i] == '\n' || string[i] > 'z' || string[i] < ' ' || string[i] == '\0') {
1116 if (dialogueboxcolor[whichdialogue][indialogue][0] + dialogueboxcolor[whichdialogue][indialogue][1] + dialogueboxcolor[whichdialogue][indialogue][2] < 1.5) {
1117 glColor4f(0, 0, 0, tutorialopac);
1118 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);
1119 glColor4f(1, 1, 1, tutorialopac);
1120 text->glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/, starty - 20 * screenwidth / 1024 * line, string, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight, lastline, i);
1122 glColor4f(0, 0, 0, tutorialopac);
1123 text->glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/, starty - 20 * screenwidth / 1024 * line, string, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight, lastline, i);
1127 if (string[i] == '\0')
1136 if (!tutoriallevel && !winfreeze && indialogue == -1 && !mainmenu) {
1139 sprintf (string, "Score: %d", (int)accountactive->getCampaignScore());
1141 sprintf (string, "Score: %d", (int)accountactive->getCampaignScore() + (int)bonustotal);
1144 sprintf (string, "Score: %d", (int)bonustotal);
1145 glColor4f(0, 0, 0, 1);
1146 text->glPrintOutline(1024 / 40 - 4, 768 / 16 - 4 + 768 * 14 / 16, string, 1, 1.5 * 1.25, 1024, 768);
1147 glColor4f(1, 0, 0, 1);
1148 text->glPrint(1024 / 40, 768 / 16 + 768 * 14 / 16, string, 1, 1.5, 1024, 768);
1149 if (showdamagebar) {
1150 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1151 glDisable(GL_CULL_FACE);
1152 glDisable(GL_LIGHTING);
1153 glDisable(GL_TEXTURE_2D);
1155 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1156 glPushMatrix(); // Store The Projection Matrix
1157 glLoadIdentity(); // Reset The Projection Matrix
1158 glOrtho(0, screenwidth, 0, screenheight, -100, 100); // Set Up An Ortho Screen
1159 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1160 glPushMatrix(); // Store The Modelview Matrix
1161 glLoadIdentity(); // Reset The Modelview Matrix
1162 glTranslatef(15, screenheight * 17.5 / 20, 0);
1163 glScalef(screenwidth / 3 + 20, screenheight / 20, 1);
1164 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1166 glColor4f(0.0, 0.4, 0.0, 0.7);
1167 float bar = ((float)player[0].damage) / player[0].damagetolerance;
1169 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
1170 glVertex3f(1, 0, 0.0f);
1171 glVertex3f(1, 1, 0.0f);
1172 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
1174 glColor4f(0.1, 0.0, 0.0, 1);
1175 bar = ((float)player[0].bloodloss) / player[0].damagetolerance;
1177 glVertex3f(0, 0, 0.0f);
1178 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
1179 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
1180 glVertex3f(0, 1, 0.0f);
1182 glColor4f(0.4, 0.0, 0.0, 0.7);
1183 bar = ((float)player[0].damage) / player[0].damagetolerance;
1185 glVertex3f(0, 0, 0.0f);
1186 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
1187 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
1188 glVertex3f(0, 1, 0.0f);
1190 glColor4f(0.4, 0.0, 0.0, 0.7);
1191 bar = ((float)player[0].permanentdamage) / player[0].damagetolerance;
1193 glVertex3f(0, 0, 0.0f);
1194 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
1195 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
1196 glVertex3f(0, 1, 0.0f);
1198 glColor4f(0.4, 0.0, 0.0, 0.7);
1199 bar = ((float)player[0].superpermanentdamage) / player[0].damagetolerance;
1201 glVertex3f(0, 0, 0.0f);
1202 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
1203 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
1204 glVertex3f(0, 1, 0.0f);
1206 glColor4f(0.0, 0.0, 0.0, 0.7);
1208 glBegin(GL_LINE_STRIP);
1209 glVertex3f(0, 0, 0.0f);
1210 glVertex3f(1, 0, 0.0f);
1211 glVertex3f(1, 1, 0.0f);
1212 glVertex3f(0, 1, 0.0f);
1213 glVertex3f(0, 0, 0.0f);
1216 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1217 glPopMatrix(); // Restore The Old Projection Matrix
1218 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1219 glPopMatrix(); // Restore The Old Projection Matrix
1220 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1221 glEnable(GL_CULL_FACE);
1222 glDisable(GL_BLEND);
1224 glEnable(GL_TEXTURE_2D);
1226 // writing the numbers :
1227 sprintf (string, "Damages : %d/%d (%d)", (int)(player[0].damage), (int)(player[0].damagetolerance), (int)(player[0].bloodloss));
1228 glColor4f(0, 0, 0, 1);
1229 text->glPrintOutline(1024 / 40 - 4, 768 / 16 - 4 + 768 * 14 / 16 - 40, string, 1, 1.5 * 1.25, 1024, 768);
1230 glColor4f(1, 0, 0, 1);
1231 text->glPrint(1024 / 40, 768 / 16 + 768 * 14 / 16 - 40, string, 1, 1.5, 1024, 768);
1235 glColor4f(.5, .5, .5, 1);
1238 if ((texttoggle || editorenabled) && debugmode && !mainmenu) {
1239 sprintf (string, "The framespersecond is %d.", (int)(fps));
1240 text->glPrint(10, 30, string, 0, .8, 1024, 768);
1243 sprintf (string, "Map editor enabled.");
1245 sprintf (string, "Map editor disabled.");
1246 text->glPrint(10, 60, string, 0, .8, 1024, 768);
1247 if (editorenabled) {
1248 sprintf (string, "Object size: %f", editorsize);
1249 text->glPrint(10, 75, string, 0, .8, 1024, 768);
1251 sprintf (string, "Object yaw: %f", editoryaw);
1253 sprintf (string, "Object yaw: Random");
1254 text->glPrint(10, 90, string, 0, .8, 1024, 768);
1255 if (editorpitch >= 0)
1256 sprintf (string, "Object pitch: %f", editorpitch);
1258 sprintf (string, "Object pitch: Random");
1259 text->glPrint(10, 105, string, 0, .8, 1024, 768);
1260 sprintf (string, "Object type: %d", editortype);
1261 text->glPrint(10, 120, string, 0, .8, 1024, 768);
1262 switch (editortype) {
1264 sprintf (string, "(box)");
1267 sprintf (string, "(tree)");
1270 sprintf (string, "(wall)");
1273 sprintf (string, "(weird)");
1276 sprintf (string, "(spike)");
1279 sprintf (string, "(rock)");
1282 sprintf (string, "(bush)");
1285 sprintf (string, "(tunnel)");
1288 sprintf (string, "(chimney)");
1291 sprintf (string, "(platform)");
1294 sprintf (string, "(cool)");
1297 sprintf (string, "(fire)");
1300 text->glPrint(130, 120, string, 0, .8, 1024, 768);
1302 sprintf (string, "Numplayers: %d", numplayers);
1303 text->glPrint(10, 155, string, 0, .8, 1024, 768);
1304 sprintf (string, "Player %d: numwaypoints: %d", numplayers, player[numplayers - 1].numwaypoints);
1305 text->glPrint(10, 140, string, 0, .8, 1024, 768);
1307 sprintf (string, "Difficulty: %d", difficulty);
1308 text->glPrint(10, 240, string, 0, .8, 1024, 768);
1313 if (drawmode == glowmode) {
1314 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1315 glDisable(GL_CULL_FACE);
1316 glDisable(GL_LIGHTING);
1317 glDisable(GL_TEXTURE_2D);
1319 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1320 glPushMatrix(); // Store The Projection Matrix
1321 glLoadIdentity(); // Reset The Projection Matrix
1322 glOrtho(0, screenwidth, 0, screenheight, -100, 100); // Set Up An Ortho Screen
1323 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1324 glPushMatrix(); // Store The Modelview Matrix
1325 glLoadIdentity(); // Reset The Modelview Matrix
1326 glScalef(screenwidth, screenheight, 1);
1327 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1329 glColor4f(0, 0, 0, .5);
1331 glVertex3f(0, 0, 0.0f);
1332 glVertex3f(256, 0, 0.0f);
1333 glVertex3f(256, 256, 0.0f);
1334 glVertex3f(0, 256, 0.0f);
1336 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1337 glPopMatrix(); // Restore The Old Projection Matrix
1338 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1339 glPopMatrix(); // Restore The Old Projection Matrix
1340 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1341 glEnable(GL_CULL_FACE);
1342 glDisable(GL_BLEND);
1346 if ((((blackout && damageeffects) || (player[0].bloodloss > 0 && damageeffects && player[0].blooddimamount > 0) || player[0].dead) && !cameramode) || console) {
1347 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1348 glDisable(GL_CULL_FACE);
1349 glDisable(GL_LIGHTING);
1350 glDisable(GL_TEXTURE_2D);
1352 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1353 glPushMatrix(); // Store The Projection Matrix
1354 glLoadIdentity(); // Reset The Projection Matrix
1355 glOrtho(0, screenwidth, 0, screenheight, -100, 100); // Set Up An Ortho Screen
1356 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1357 glPushMatrix(); // Store The Modelview Matrix
1358 glLoadIdentity(); // Reset The Modelview Matrix
1359 glScalef(screenwidth, screenheight, 1);
1360 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1363 blackout += multiplier * 3;
1364 if (player[0].dead == 1)
1366 if (player[0].dead == 2 && blackout > .6)
1368 glColor4f(0, 0, 0, blackout);
1369 if (!player[0].dead) {
1370 if ((player[0].bloodloss / player[0].damagetolerance * (sin(woozy) / 4 + .5))*.3 < .3) {
1371 glColor4f(0, 0, 0, player[0].blooddimamount * player[0].bloodloss / player[0].damagetolerance * (sin(woozy) / 4 + .5)*.3);
1372 blackout = player[0].blooddimamount * player[0].bloodloss / player[0].damagetolerance * (sin(woozy) / 4 + .5) * .3;
1374 glColor4f(0, 0, 0, player[0].blooddimamount * .3);
1375 blackout = player[0].blooddimamount * .3;
1379 glColor4f(.7, 0, 0, .2);
1381 glVertex3f(0, 0, 0.0f);
1382 glVertex3f(256, 0, 0.0f);
1383 glVertex3f(256, 256, 0.0f);
1384 glVertex3f(0, 256, 0.0f);
1386 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1387 glPopMatrix(); // Restore The Old Projection Matrix
1388 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1389 glPopMatrix(); // Restore The Old Projection Matrix
1390 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1391 glEnable(GL_CULL_FACE);
1392 glDisable(GL_BLEND);
1396 if (flashamount > 0 && damageeffects) {
1397 if (flashamount > 1)
1399 if (flashdelay <= 0)
1400 flashamount -= multiplier;
1402 if (flashamount < 0)
1404 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1405 glDisable(GL_CULL_FACE);
1406 glDisable(GL_LIGHTING);
1408 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1409 glPushMatrix(); // Store The Projection Matrix
1410 glLoadIdentity(); // Reset The Projection Matrix
1411 glOrtho(0, screenwidth, 0, screenheight, -100, 100); // Set Up An Ortho Screen
1412 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1413 glPushMatrix(); // Store The Modelview Matrix
1414 glLoadIdentity(); // Reset The Modelview Matrix
1415 glScalef(screenwidth, screenheight, 1);
1416 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1418 glColor4f(flashr, flashg, flashb, flashamount);
1420 glVertex3f(0, 0, 0.0f);
1421 glVertex3f(256, 0, 0.0f);
1422 glVertex3f(256, 256, 0.0f);
1423 glVertex3f(0, 256, 0.0f);
1425 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1426 glPopMatrix(); // Restore The Old Projection Matrix
1427 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1428 glPopMatrix(); // Restore The Old Projection Matrix
1429 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1430 glEnable(GL_CULL_FACE);
1431 glDisable(GL_BLEND);
1437 glEnable(GL_TEXTURE_2D);
1438 glColor4f(1, 1, 1, 1);
1440 sprintf (string, " ]");
1441 text->glPrint(10, 30 + screenheight - 330, string, 0, 1, screenwidth, screenheight);
1443 sprintf (string, "_");
1444 text->glPrint(30 + (float)(displayselected) * 10, 30 + (screenheight - 330), string, 0, 1, screenwidth, screenheight);
1447 for (i = 0; i < 15; i++)
1448 if ((i != 0 || chatting) && displaytime[i] < 4)
1449 for (j = 0; j < displaychars[i]; j++) {
1450 glColor4f(1, 1, 1, 4 - displaytime[i]);
1451 if (j < displaychars[i]) {
1452 sprintf (string, "%c", displaytext[i][j]);
1453 text->glPrint(30 + j * 10, 30 + i * 20 + (screenheight - 330), string, 0, 1, screenwidth, screenheight);
1458 if (difficulty < 2 && indialogue == -1) { // minimap
1459 float mapviewdist = 20000;
1461 glDisable(GL_DEPTH_TEST);
1462 glColor3f (1.0, 1.0, 1.0); // no coloring
1464 glEnable(GL_TEXTURE_2D);
1465 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1466 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1467 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1468 glDisable(GL_CULL_FACE);
1469 glDisable(GL_LIGHTING);
1471 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1472 glPushMatrix(); // Store The Projection Matrix
1473 glLoadIdentity(); // Reset The Projection Matrix
1474 glOrtho(0, screenwidth, 0, screenheight, -100, 100); // Set Up An Ortho Screen
1475 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1476 glPushMatrix(); // Store The Modelview Matrix
1477 glLoadIdentity(); // Reset The Modelview Matrix
1478 glScalef((float)screenwidth / 2, (float)screenwidth / 2, 1);
1479 glTranslatef(1.75, .25, 0);
1480 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1482 glColor4f(1, 1, 1, 1);
1488 int numliveplayers = 0;
1490 for (i = 0; i < numplayers; i++) {
1491 if (!player[i].dead)
1497 for (i = 0; i < objects.numobjects; i++) {
1498 if (objects.type[i] == treetrunktype || objects.type[i] == boxtype) {
1499 center += objects.position[i];
1503 for (i = 0; i < numplayers; i++) {
1504 if (!player[i].dead)
1505 center += player[i].coords;
1507 center /= numadd + numliveplayers;
1509 center = player[0].coords;
1511 float maxdistance = 0;
1513 //~ int whichclosest;
1514 for (i = 0; i < objects.numobjects; i++) {
1515 tempdist = distsq(¢er, &objects.position[i]);
1516 if (tempdist > maxdistance) {
1518 maxdistance = tempdist;
1521 for (i = 0; i < numplayers; i++) {
1522 if (!player[i].dead) {
1523 tempdist = distsq(¢er, &player[i].coords);
1524 if (tempdist > maxdistance) {
1526 maxdistance = tempdist;
1530 radius = fast_sqrt(maxdistance);
1534 glScalef(.25 / radius * 256 * terrain.scale * .4, .25 / radius * 256 * terrain.scale * .4, 1);
1536 glScalef(1 / (1 / radius * 256 * terrain.scale * .4), 1 / (1 / radius * 256 * terrain.scale * .4), 1);
1538 glRotatef(player[0].lookyaw * -1 + 180, 0, 0, 1);
1539 glTranslatef(-(center.x / terrain.scale / 256 * -2 + 1), (center.z / terrain.scale / 256 * -2 + 1), 0);
1540 for (i = 0; i < objects.numobjects; i++) {
1541 if (objects.type[i] == treetrunktype) {
1542 distcheck = distsq(&player[0].coords, &objects.position[i]);
1543 if (distcheck < mapviewdist) {
1544 Mapcircletexture.bind();
1545 glColor4f(0, .3, 0, opac * (1 - distcheck / mapviewdist));
1547 glTranslatef(objects.position[i].x / terrain.scale / 256 * -2 + 1, objects.position[i].z / terrain.scale / 256 * 2 - 1, 0);
1548 glRotatef(objects.yaw[i], 0, 0, 1);
1549 glScalef(.003, .003, .003);
1552 glVertex3f(-1, -1, 0.0f);
1554 glVertex3f(1, -1, 0.0f);
1556 glVertex3f(1, 1, 0.0f);
1558 glVertex3f(-1, 1, 0.0f);
1563 if (objects.type[i] == boxtype) {
1564 distcheck = distsq(&player[0].coords, &objects.position[i]);
1565 if (distcheck < mapviewdist) {
1566 Mapboxtexture.bind();
1567 glColor4f(.4, .4, .4, opac * (1 - distcheck / mapviewdist));
1569 glTranslatef(objects.position[i].x / terrain.scale / 256 * -2 + 1, objects.position[i].z / terrain.scale / 256 * 2 - 1, 0);
1570 glRotatef(objects.yaw[i], 0, 0, 1);
1571 glScalef(.01 * objects.scale[i], .01 * objects.scale[i], .01 * objects.scale[i]);
1574 glVertex3f(-1, -1, 0.0f);
1576 glVertex3f(1, -1, 0.0f);
1578 glVertex3f(1, 1, 0.0f);
1580 glVertex3f(-1, 1, 0.0f);
1586 if (editorenabled) {
1587 Mapcircletexture.bind();
1588 for (i = 0; i < numboundaries; i++) {
1589 glColor4f(0, 0, 0, opac / 3);
1591 glTranslatef(boundary[i].x / terrain.scale / 256 * -2 + 1, boundary[i].z / terrain.scale / 256 * 2 - 1, 0);
1592 glScalef(.002, .002, .002);
1595 glVertex3f(-1, -1, 0.0f);
1597 glVertex3f(1, -1, 0.0f);
1599 glVertex3f(1, 1, 0.0f);
1601 glVertex3f(-1, 1, 0.0f);
1606 for (i = 0; i < numplayers; i++) {
1607 distcheck = distsq(&player[0].coords, &player[i].coords);
1608 if (distcheck < mapviewdist) {
1610 Maparrowtexture.bind();
1612 glColor4f(1, 1, 1, opac);
1613 else if (player[i].dead == 2 || player[i].howactive > typesleeping)
1614 glColor4f(0, 0, 0, opac * (1 - distcheck / mapviewdist));
1615 else if (player[i].dead)
1616 glColor4f(.3, .3, .3, opac * (1 - distcheck / mapviewdist));
1617 else if (player[i].aitype == attacktypecutoff)
1618 glColor4f(1, 0, 0, opac * (1 - distcheck / mapviewdist));
1619 else if (player[i].aitype == passivetype)
1620 glColor4f(0, 1, 0, opac * (1 - distcheck / mapviewdist));
1622 glColor4f(1, 1, 0, 1);
1623 glTranslatef(player[i].coords.x / terrain.scale / 256 * -2 + 1, player[i].coords.z / terrain.scale / 256 * 2 - 1, 0);
1624 glRotatef(player[i].yaw + 180, 0, 0, 1);
1625 glScalef(.005, .005, .005);
1628 glVertex3f(-1, -1, 0.0f);
1630 glVertex3f(1, -1, 0.0f);
1632 glVertex3f(1, 1, 0.0f);
1634 glVertex3f(-1, 1, 0.0f);
1640 glDisable(GL_TEXTURE_2D);
1641 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1642 glPopMatrix(); // Restore The Old Projection Matrix
1643 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1644 glPopMatrix(); // Restore The Old Projection Matrix
1645 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1646 glEnable(GL_CULL_FACE);
1647 glDisable(GL_BLEND);
1651 if (loading && !stealthloading && (!campaign || player[0].dead)) {
1652 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1653 glDisable(GL_CULL_FACE);
1654 glDisable(GL_LIGHTING);
1655 glDisable(GL_TEXTURE_2D);
1657 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1658 glPushMatrix(); // Store The Projection Matrix
1659 glLoadIdentity(); // Reset The Projection Matrix
1660 glOrtho(0, screenwidth, 0, screenheight, -100, 100); // Set Up An Ortho Screen
1661 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1662 glPushMatrix(); // Store The Modelview Matrix
1663 glLoadIdentity(); // Reset The Modelview Matrix
1664 glScalef(screenwidth, screenheight, 1);
1665 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1667 glColor4f(0, 0, 0, .7);
1669 glVertex3f(0, 0, 0.0f);
1670 glVertex3f(256, 0, 0.0f);
1671 glVertex3f(256, 256, 0.0f);
1672 glVertex3f(0, 256, 0.0f);
1674 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1675 glPopMatrix(); // Restore The Old Projection Matrix
1676 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1677 glPopMatrix(); // Restore The Old Projection Matrix
1678 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1679 glEnable(GL_CULL_FACE);
1680 glDisable(GL_BLEND);
1684 glDisable(GL_DEPTH_TEST);
1685 glColor3f (1.0, 1.0, 1.0); // no coloring
1687 glEnable(GL_TEXTURE_2D);
1692 glEnable(GL_TEXTURE_2D);
1693 glColor4f(1, 1, 1, 1);
1694 sprintf (string, "Loading...");
1695 text->glPrint(1024 / 2 - 90, 768 / 2, string, 1, 2, 1024, 768);
1698 //if(ismotionblur)drawmode=motionblurmode;
1699 drawmode = normalmode;
1702 if (winfreeze && !campaign) {
1703 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1704 glDisable(GL_CULL_FACE);
1705 glDisable(GL_LIGHTING);
1706 glDisable(GL_TEXTURE_2D);
1708 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1709 glPushMatrix(); // Store The Projection Matrix
1710 glLoadIdentity(); // Reset The Projection Matrix
1711 glOrtho(0, screenwidth, 0, screenheight, -100, 100); // Set Up An Ortho Screen
1712 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1713 glPushMatrix(); // Store The Modelview Matrix
1714 glLoadIdentity(); // Reset The Modelview Matrix
1715 glScalef(screenwidth, screenheight, 1);
1716 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1718 glColor4f(0, 0, 0, .4);
1720 glVertex3f(0, 0, 0.0f);
1721 glVertex3f(256, 0, 0.0f);
1722 glVertex3f(256, 256, 0.0f);
1723 glVertex3f(0, 256, 0.0f);
1725 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1726 glPopMatrix(); // Restore The Old Projection Matrix
1727 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1728 glPopMatrix(); // Restore The Old Projection Matrix
1729 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1730 glEnable(GL_CULL_FACE);
1731 glDisable(GL_BLEND);
1735 glDisable(GL_DEPTH_TEST);
1736 glColor3f (1.0, 1.0, 1.0); // no coloring
1738 glEnable(GL_TEXTURE_2D);
1740 //Win Screen Won Victory
1742 glEnable(GL_TEXTURE_2D);
1743 glColor4f(1, 1, 1, 1);
1744 sprintf (string, "Level Cleared!");
1745 text->glPrintOutlined(1024 / 2 - strlen(string) * 10, 768 * 7 / 8, string, 1, 2, 1024, 768);
1747 sprintf (string, "Score: %d", (int)(bonustotal - startbonustotal));
1748 text->glPrintOutlined(1024 / 30, 768 * 6 / 8, string, 1, 2, 1024, 768);
1751 sprintf (string, "Press Escape or Space to continue");
1753 sprintf (string, "Press Escape to return to menu or Space to continue");
1754 text->glPrintOutlined(640 / 2 - strlen(string) * 5, 480 * 1 / 16, string, 1, 1, 640, 480);
1758 for (i = 0; i < 255; i++)string[i] = '\0';
1759 sprintf (temp, "Time: %d:", (int)(((int)leveltime - (int)(leveltime) % 60) / 60));
1760 strcat(string, temp);
1761 if ((int)(leveltime) % 60 < 10)
1762 strcat(string, "0");
1763 sprintf (temp, "%d", (int)(leveltime) % 60);
1764 strcat(string, temp);
1765 text->glPrintOutlined(1024 / 30, 768 * 6 / 8 - 40, string, 1, 2, 1024, 768);
1768 int awards[award_count];
1769 int numawards = award_awards(awards);
1771 for (i = 0; i < numawards && i < 6; i++)
1772 text->glPrintOutlined(1024 / 30, 768 * 6 / 8 - 90 - 40 * i, award_names[awards[i]], 1, 2, 1024, 768);
1775 if (drawmode != normalmode) {
1776 glEnable(GL_TEXTURE_2D);
1778 if (!drawtoggle || drawmode != realmotionblurmode || (drawtoggle == 2 || change == 1)) {
1779 if (screentexture) {
1781 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
1782 GLfloat subtractColor[4] = { 0.5, 0.5, 0.5, 0.0 };
1783 glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, subtractColor);
1784 //glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_SUBTRACT);
1785 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE);
1786 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_CONSTANT_EXT);
1787 glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 2.0f);
1789 glBindTexture( GL_TEXTURE_2D, screentexture);
1790 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1793 if ((drawtoggle || change == 1) && drawmode == realmotionblurmode) {
1794 if (screentexture2) {
1795 glBindTexture( GL_TEXTURE_2D, screentexture2);
1796 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1798 if (!screentexture2) {
1799 glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
1801 glGenTextures( 1, &screentexture2 );
1802 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
1804 glEnable(GL_TEXTURE_2D);
1805 glBindTexture( GL_TEXTURE_2D, screentexture2);
1806 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
1807 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
1809 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
1815 glClear(GL_DEPTH_BUFFER_BIT);
1816 Game::ReSizeGLScene(90, .1f);
1817 glViewport(0, 0, screenwidth, screenheight);
1819 if (drawmode != normalmode) {
1820 glDisable(GL_DEPTH_TEST);
1821 if (drawmode == motionblurmode) {
1822 glDrawBuffer(GL_FRONT);
1823 glReadBuffer(GL_BACK);
1825 glColor3f (1.0, 1.0, 1.0); // no coloring
1827 glEnable(GL_TEXTURE_2D);
1828 glBindTexture( GL_TEXTURE_2D, screentexture);
1829 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1830 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1831 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1832 glDisable(GL_CULL_FACE);
1833 glDisable(GL_LIGHTING);
1835 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1836 glPushMatrix(); // Store The Projection Matrix
1837 glLoadIdentity(); // Reset The Projection Matrix
1838 glOrtho(0, screenwidth, 0, screenheight, -100, 100); // Set Up An Ortho Screen
1839 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1840 glPushMatrix(); // Store The Modelview Matrix
1841 glLoadIdentity(); // Reset The Modelview Matrix
1842 glScalef((float)screenwidth / 2, (float)screenheight / 2, 1);
1843 glTranslatef(1, 1, 0);
1844 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1846 if (drawmode == motionblurmode) {
1847 if (motionbluramount < .2)
1848 motionbluramount = .2;
1849 //glColor4f(1,1,1,fast_sqrt(multiplier)*2.9*motionbluramount);
1850 glColor4f(1, 1, 1, motionbluramount);
1854 glVertex3f(-1, -1, 0.0f);
1855 glTexCoord2f(texcoordwidth, 0);
1856 glVertex3f(1, -1, 0.0f);
1857 glTexCoord2f(texcoordwidth, texcoordheight);
1858 glVertex3f(1, 1, 0.0f);
1859 glTexCoord2f(0, texcoordheight);
1860 glVertex3f(-1, 1, 0.0f);
1864 if (drawmode == realmotionblurmode) {
1865 glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
1866 glClear(GL_COLOR_BUFFER_BIT);
1867 glBlendFunc(GL_SRC_ALPHA, GL_ONE);
1868 glBindTexture( GL_TEXTURE_2D, screentexture);
1869 glColor4f(1, 1, 1, .5);
1873 glVertex3f(-1, -1, 0.0f);
1874 glTexCoord2f(texcoordwidth, 0);
1875 glVertex3f(1, -1, 0.0f);
1876 glTexCoord2f(texcoordwidth, texcoordheight);
1877 glVertex3f(1, 1, 0.0f);
1878 glTexCoord2f(0, texcoordheight);
1879 glVertex3f(-1, 1, 0.0f);
1882 glBindTexture( GL_TEXTURE_2D, screentexture2);
1883 glColor4f(1, 1, 1, .5);
1887 glVertex3f(-1, -1, 0.0f);
1888 glTexCoord2f(texcoordwidth, 0);
1889 glVertex3f(1, -1, 0.0f);
1890 glTexCoord2f(texcoordwidth, texcoordheight);
1891 glVertex3f(1, 1, 0.0f);
1892 glTexCoord2f(0, texcoordheight);
1893 glVertex3f(-1, 1, 0.0f);
1896 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1898 if (drawmode == doublevisionmode) {
1899 static float crosseyedness;
1900 crosseyedness = abs(player[0].damage - player[0].superpermanentdamage - (player[0].damagetolerance - player[0].superpermanentdamage) * 1 / 2) / 30;
1901 if (crosseyedness > 1)
1903 if (crosseyedness < 0)
1905 glColor4f(1, 1, 1, 1);
1906 glDisable(GL_BLEND);
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);
1920 if (crosseyedness) {
1921 glColor4f(1, 1, 1, .5);
1924 glTranslatef(.015 * crosseyedness, 0, 0);
1928 glVertex3f(-1, -1, 0.0f);
1929 glTexCoord2f(texcoordwidth, 0);
1930 glVertex3f(1, -1, 0.0f);
1931 glTexCoord2f(texcoordwidth, texcoordheight);
1932 glVertex3f(1, 1, 0.0f);
1933 glTexCoord2f(0, texcoordheight);
1934 glVertex3f(-1, 1, 0.0f);
1939 if (drawmode == glowmode) {
1940 glColor4f(.5, .5, .5, .5);
1942 glBlendFunc(GL_SRC_ALPHA, GL_ONE);
1944 glTranslatef(.01, 0, 0);
1947 glVertex3f(-1, -1, 0.0f);
1948 glTexCoord2f(texcoordwidth, 0);
1949 glVertex3f(1, -1, 0.0f);
1950 glTexCoord2f(texcoordwidth, texcoordheight);
1951 glVertex3f(1, 1, 0.0f);
1952 glTexCoord2f(0, texcoordheight);
1953 glVertex3f(-1, 1, 0.0f);
1957 glTranslatef(-.01, 0, 0);
1960 glVertex3f(-1, -1, 0.0f);
1961 glTexCoord2f(texcoordwidth, 0);
1962 glVertex3f(1, -1, 0.0f);
1963 glTexCoord2f(texcoordwidth, texcoordheight);
1964 glVertex3f(1, 1, 0.0f);
1965 glTexCoord2f(0, texcoordheight);
1966 glVertex3f(-1, 1, 0.0f);
1970 glTranslatef(.0, .01, 0);
1973 glVertex3f(-1, -1, 0.0f);
1974 glTexCoord2f(texcoordwidth, 0);
1975 glVertex3f(1, -1, 0.0f);
1976 glTexCoord2f(texcoordwidth, texcoordheight);
1977 glVertex3f(1, 1, 0.0f);
1978 glTexCoord2f(0, texcoordheight);
1979 glVertex3f(-1, 1, 0.0f);
1983 glTranslatef(0, -.01, 0);
1986 glVertex3f(-1, -1, 0.0f);
1987 glTexCoord2f(texcoordwidth, 0);
1988 glVertex3f(1, -1, 0.0f);
1989 glTexCoord2f(texcoordwidth, texcoordheight);
1990 glVertex3f(1, 1, 0.0f);
1991 glTexCoord2f(0, texcoordheight);
1992 glVertex3f(-1, 1, 0.0f);
1996 if (drawmode == radialzoommode) {
1997 for (i = 0; i < 3; i++) {
1998 //glRotatef((float)i*.1,0,0,1);
1999 glColor4f(1, 1, 1, 1 / ((float)i + 1));
2001 glScalef(1 + (float)i * .01, 1 + (float)i * .01, 1);
2004 glVertex3f(-1, -1, 0.0f);
2005 glTexCoord2f(texcoordwidth, 0);
2006 glVertex3f(1, -1, 0.0f);
2007 glTexCoord2f(texcoordwidth, texcoordheight);
2008 glVertex3f(1, 1, 0.0f);
2009 glTexCoord2f(0, texcoordheight);
2010 glVertex3f(-1, 1, 0.0f);
2015 glDisable(GL_TEXTURE_2D);
2016 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2017 glPopMatrix(); // Restore The Old Projection Matrix
2018 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2019 glPopMatrix(); // Restore The Old Projection Matrix
2020 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
2021 glEnable(GL_CULL_FACE);
2022 glDisable(GL_BLEND);
2027 glEnable(GL_TEXTURE_2D);
2028 glColor4f(1, 1, 1, 1);
2030 if (consoleselected >= 60)
2031 offset = consoleselected - 60;
2032 sprintf (string, " ]");
2033 text->glPrint(10, 30, string, 0, 1, 1024, 768);
2035 sprintf (string, "_");
2036 text->glPrint(30 + (float)(consoleselected) * 10 - offset * 10, 30, string, 0, 1, 1024, 768);
2038 for (i = 0; i < 15; i++)
2039 for (j = 0; j < consolechars[i]; j++) {
2040 glColor4f(1, 1, 1, 1 - (float)(i) / 16);
2041 if (j < consolechars[i]) {
2042 sprintf (string, "%c", consoletext[i][j]);
2043 text->glPrint(30 + j * 10 - offset * 10, 30 + i * 20, string, 0, 1, 1024, 768);
2049 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted)) {
2050 multiplier = tempmult;
2057 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted)) {
2058 tempmult = multiplier;
2063 if ( side == stereoRight || side == stereoCenter ) {
2064 if (drawmode != motionblurmode || mainmenu) {
2069 //myassert(glGetError() == GL_NO_ERROR);
2070 glDrawBuffer(GL_BACK);
2071 glReadBuffer(GL_BACK);
2076 if (drawtoggle == 2)
2079 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted)) {
2080 multiplier = tempmult;
2082 //Jordan fixed your warning!
2088 // !!! FIXME: hack: clamp framerate in menu so text input works correctly on fast systems.
2091 glDrawBuffer(GL_BACK);
2092 glReadBuffer(GL_BACK);
2093 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
2094 Game::ReSizeGLScene(90, .1f);
2096 //draw menu background
2097 glClear(GL_DEPTH_BUFFER_BIT);
2098 glEnable(GL_ALPHA_TEST);
2099 glAlphaFunc(GL_GREATER, 0.001f);
2100 glEnable(GL_TEXTURE_2D);
2101 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
2102 glDisable(GL_CULL_FACE);
2103 glDisable(GL_LIGHTING);
2105 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2106 glPushMatrix(); // Store The Projection Matrix
2107 glLoadIdentity(); // Reset The Projection Matrix
2108 glOrtho(0, screenwidth, 0, screenheight, -100, 100); // Set Up An Ortho Screen
2109 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2110 glPushMatrix(); // Store The Modelview Matrix
2111 glLoadIdentity(); // Reset The Modelview Matrix
2112 glTranslatef(screenwidth / 2, screenheight / 2, 0);
2114 glScalef((float)screenwidth / 2, (float)screenheight / 2, 1);
2115 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
2116 glDisable(GL_BLEND);
2117 glColor4f(0, 0, 0, 1.0);
2118 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2119 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2120 glDisable(GL_TEXTURE_2D);
2122 glVertex3f(-1, -1, 0);
2123 glVertex3f(+1, -1, 0);
2124 glVertex3f(+1, +1, 0);
2125 glVertex3f(-1, +1, 0);
2128 glColor4f(0.4, 0.4, 0.4, 1.0);
2129 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2130 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2131 glEnable(GL_TEXTURE_2D);
2132 Game::Mainmenuitems[4].bind();
2135 glVertex3f(-1, -1, 0);
2137 glVertex3f(+1, -1, 0);
2139 glVertex3f(+1, +1, 0);
2141 glVertex3f(-1, +1, 0);
2145 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2147 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2151 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2152 glPushMatrix(); // Store The Projection Matrix
2153 glLoadIdentity(); // Reset The Projection Matrix
2154 glOrtho(0, 640, 0, 480, -100, 100); // Set Up An Ortho Screen
2155 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2156 glPushMatrix(); // Store The Modelview Matrix
2157 glLoadIdentity(); // Reset The Modelview Matrix
2158 glEnable(GL_TEXTURE_2D);
2163 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2165 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2168 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2169 glPushMatrix(); // Store The Projection Matrix
2170 glLoadIdentity(); // Reset The Projection Matrix
2171 glOrtho(0, screenwidth, 0, screenheight, -100, 100); // Set Up An Ortho Screen
2172 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2173 glPushMatrix(); // Store The Modelview Matrix
2174 glLoadIdentity(); // Reset The Modelview Matrix
2175 glTranslatef(screenwidth / 2, screenheight / 2, 0);
2177 glScalef((float)screenwidth / 2, (float)screenheight / 2, 1);
2178 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
2180 glEnable(GL_TEXTURE_2D);
2181 glColor4f(1, 1, 1, 1);
2182 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2183 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2185 if (!Game::waiting) { // hide the cursor while waiting for a key
2187 glTranslatef(Game::mousecoordh - screenwidth / 2, Game::mousecoordv * -1 + screenheight / 2, 0);
2188 glScalef((float)screenwidth / 64, (float)screenwidth / 64, 1);
2189 glTranslatef(1, -1, 0);
2190 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
2191 glColor4f(1, 1, 1, 1);
2192 Game::cursortexture.bind();
2194 //glScalef(.25,.25,.25);
2197 glVertex3f(-1, -1, 0.0f);
2199 glVertex3f(1, -1, 0.0f);
2201 glVertex3f(1, 1, 0.0f);
2203 glVertex3f(-1, 1, 0.0f);
2209 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2214 if (flashamount > 0) {
2215 if (flashamount > 1)
2217 if (flashdelay <= 0)
2218 flashamount -= multiplier;
2220 if (flashamount < 0)
2222 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
2223 glDisable(GL_CULL_FACE);
2224 glDisable(GL_LIGHTING);
2225 glDisable(GL_TEXTURE_2D);
2227 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2228 glPushMatrix(); // Store The Projection Matrix
2229 glLoadIdentity(); // Reset The Projection Matrix
2230 glOrtho(0, screenwidth, 0, screenheight, -100, 100); // Set Up An Ortho Screen
2231 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2232 glPushMatrix(); // Store The Modelview Matrix
2233 glLoadIdentity(); // Reset The Modelview Matrix
2234 glScalef(screenwidth, screenheight, 1);
2235 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
2237 glColor4f(flashr, flashg, flashb, flashamount);
2239 glVertex3f(0, 0, 0.0f);
2240 glVertex3f(256, 0, 0.0f);
2241 glVertex3f(256, 256, 0.0f);
2242 glVertex3f(0, 256, 0.0f);
2244 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2245 glPopMatrix(); // Restore The Old Projection Matrix
2246 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2247 glPopMatrix(); // Restore The Old Projection Matrix
2248 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
2249 glEnable(GL_CULL_FACE);
2250 glDisable(GL_BLEND);