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)numboundaries = 360;
176 for (i = 0; i < numboundaries; i++) {
179 boundary[i] = mapcenter + DoRotation(boundary[i] * mapradius, 0, i * (360 / ((float)(numboundaries))), 0);
188 int olddrawmode = drawmode;
189 if (ismotionblur && !loading) {
190 if ((findLengthfast(&player[0].velocity) > 200) && velocityblur && !cameramode) {
191 drawmode = motionblurmode;
192 motionbluramount = 200 / (findLengthfast(&player[0].velocity));
195 if (player[0].damage - player[0].superpermanentdamage > (player[0].damagetolerance - player[0].superpermanentdamage) * 1 / 2 && damageeffects && !cameramode) {
196 drawmode = doublevisionmode;
201 if (slomo && !loading) {
203 drawmode = motionblurmode;
204 motionbluramount = .2;
205 slomodelay -= multiplier;
211 if ((!changed && !slomo) || loading) {
212 drawmode = normalmode;
213 if (ismotionblur && (/*fps>100||*/alwaysblur)) {
214 if (olddrawmode != realmotionblurmode)
218 drawmode = realmotionblurmode;
219 } else if (olddrawmode == realmotionblurmode)
225 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted))
226 drawmode = normalmode;
227 if ((freeze || winfreeze) && ismotionblur && !mainmenu)
228 drawmode = radialzoommode;
230 if (winfreeze || mainmenu)drawmode = normalmode;
233 if (drawmode == glowmode) {
238 DSpContext_FadeGamma(NULL, 200, &color2);
243 drawtoggle = 1 - drawtoggle;
245 if (!texcoordwidth) {
246 texviewwidth = kTextureSize;
247 if (texviewwidth > screenwidth)
248 texviewwidth = screenwidth;
249 texviewheight = kTextureSize;
250 if (texviewheight > screenheight)
251 texviewheight = screenheight;
253 texcoordwidth = screenwidth / kTextureSize;
254 texcoordheight = screenheight / kTextureSize;
255 if (texcoordwidth > 1)
257 if (texcoordheight > 1)
261 glDrawBuffer(GL_BACK);
262 glReadBuffer(GL_BACK);
265 static XYZ terrainlight;
266 static float distance;
267 if (drawmode == normalmode)
268 Game::ReSizeGLScene(90, .1f);
269 if (drawmode != normalmode)
270 glViewport(0, 0, texviewwidth, texviewheight);
271 glDepthFunc(GL_LEQUAL);
273 glAlphaFunc(GL_GREATER, 0.0001f);
274 glEnable(GL_ALPHA_TEST);
275 glClearColor(0.25f, 0.25f, 0.25f, 1.0f);
276 glClear(GL_DEPTH_BUFFER_BIT);
278 glMatrixMode (GL_MODELVIEW);
279 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
282 // Move the camera for the current eye's point of view.
283 // Reverse the movement if we're reversing stereo
284 glTranslatef((stereoseparation / 2) * side * (stereoreverse ? -1 : 1), 0, 0);
287 if (!cameramode && !freeze && !winfreeze) {
289 glRotatef(float(Random() % 100) / 10 * camerashake/*+(woozy*woozy)/10*/, 0, 0, 1);
291 glRotatef(pitch + sin(woozy / 2) * (player[0].damage / player[0].damagetolerance) * 5, 1, 0, 0);
292 glRotatef(yaw + sin(woozy) * (player[0].damage / player[0].damagetolerance) * 5, 0, 1, 0);
294 if (cameramode || freeze || winfreeze) {
295 glRotatef(pitch, 1, 0, 0);
296 glRotatef(yaw, 0, 1, 0);
299 if (environment == desertenvironment) {
300 glRotatef((float)(abs(Random() % 100)) / 3000 - 1, 1, 0, 0);
301 glRotatef((float)(abs(Random() % 100)) / 3000 - 1, 0, 1, 0);
303 SetUpLight(&light, 0);
306 //heat blur effect in desert
307 if (abs(blurness - targetblurness) < multiplier * 10 || abs(blurness - targetblurness) > 2) {
308 blurness = targetblurness;
309 targetblurness = (float)(abs(Random() % 100)) / 40;
311 if (blurness < targetblurness)
312 blurness += multiplier * 5;
314 blurness -= multiplier * 5;
316 if (environment == desertenvironment && detail == 2)
317 glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, blurness + .4 );
318 if (environment == desertenvironment) {
319 glRotatef((float)(abs(Random() % 100)) / 1000, 1, 0, 0);
320 glRotatef((float)(abs(Random() % 100)) / 1000, 0, 1, 0);
323 glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0);
325 glTranslatef(-viewer.x, -viewer.y, -viewer.z);
326 frustum.GetFrustum();
328 //make shadow decals on terrain and objects
330 static float size, opacity, rotation;
332 for (k = 0; k < numplayers; k++) {
333 if (!player[k].skeleton.free && player[k].playerdetail && player[k].howactive < typesleeping)
334 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)
335 for (i = 0; i < player[k].skeleton.num_joints; i++) {
336 if (player[k].skeleton.joints[i].label == leftknee || player[k].skeleton.joints[i].label == rightknee || player[k].skeleton.joints[i].label == groin) {
337 point = DoRotation(player[k].skeleton.joints[i].position, 0, player[k].yaw, 0) * player[k].scale + player[k].coords;
339 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;
340 if (k != 0 && tutoriallevel == 1) {
341 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;
343 terrain.MakeDecal(shadowdecal, point, size, opacity, rotation);
344 for (l = 0; l < terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz]; l++) {
345 j = terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
346 if (objects.position[j].y < player[k].coords.y || objects.type[j] == tunneltype || objects.type[j] == weirdtype) {
347 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);
350 if (k != 0 && tutoriallevel == 1) {
351 opacity = .2 + .2 * sin(smoketex * 6 + i);
353 objects.model[j].MakeDecal(shadowdecal, &point, &size, &opacity, &rotation);
358 if ((player[k].skeleton.free || player[k].howactive >= typesleeping) && player[k].playerdetail)
359 if (frustum.SphereInFrustum(player[k].coords.x, player[k].coords.y, player[k].coords.z, player[k].scale * 5) && player[k].occluded < 25)
360 for (i = 0; i < player[k].skeleton.num_joints; i++) {
361 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) {
362 if (player[k].skeleton.free)
363 point = player[k].skeleton.joints[i].position * player[k].scale + player[k].coords;
365 point = DoRotation(player[k].skeleton.joints[i].position, 0, player[k].yaw, 0) * player[k].scale + player[k].coords;
367 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;
368 if (k != 0 && tutoriallevel == 1) {
369 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;
371 terrain.MakeDecal(shadowdecal, point, size, opacity * .7, rotation);
372 for (l = 0; l < terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz]; l++) {
373 j = terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
374 if (objects.position[j].y < player[k].coords.y || objects.type[j] == tunneltype || objects.type[j] == weirdtype) {
375 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);
376 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);
379 if (k != 0 && tutoriallevel == 1) {
380 opacity = .2 + .2 * sin(smoketex * 6 + i);
382 objects.model[j].MakeDecal(shadowdecal, &point, &size, &opacity, &rotation);
388 if (!player[k].playerdetail)
389 if (frustum.SphereInFrustum(player[k].coords.x, player[k].coords.y, player[k].coords.z, player[k].scale * 5)) {
390 point = player[k].coords;
392 opacity = .4 - (player[k].coords.y - terrain.getHeight(player[k].coords.x, player[k].coords.z)) / 5;
393 terrain.MakeDecal(shadowdecal, point, size, opacity * .7, rotation);
394 for (l = 0; l < terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz]; l++) {
395 j = terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
396 point = DoRotation(player[k].coords - objects.position[j], 0, -objects.yaw[j], 0);
399 objects.model[j].MakeDecal(shadowdecal, &point, &size, &opacity, &rotation);
405 glEnable(GL_TEXTURE_2D);
407 glEnable(GL_DEPTH_TEST);
408 glEnable(GL_CULL_FACE);
410 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
411 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
412 terraintexture.bind();
414 terraintexture2.bind();
416 //glBindTexture( GL_TEXTURE_2D, terraintexture3);
417 //glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
420 terrain.drawdecals();
423 glEnable(GL_CULL_FACE);
424 glEnable(GL_LIGHTING);
426 glEnable(GL_TEXTURE_2D);
429 glEnable(GL_COLOR_MATERIAL);
444 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
445 glEnable(GL_CULL_FACE);
446 glCullFace(GL_FRONT);
448 for (k = 0; k < numplayers; k++) {
449 if (k == 0 || tutoriallevel != 1) {
451 glEnable(GL_LIGHTING);
452 terrainlight = terrain.getLighting(player[k].coords.x, player[k].coords.z);
453 distance = distsq(&viewer, &player[k].coords);
454 distance = (viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance;
455 glColor4f(terrainlight.x, terrainlight.y, terrainlight.z, distance);
458 if (distance >= .5) {
459 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;
461 if (!player[k].occluded == 0)
462 i = checkcollide(viewer, checkpoint, player[k].lastoccluded);
463 if (i == -1 || player[k].occluded == 0)
464 i = checkcollide(viewer, checkpoint);
466 player[k].occluded += 1;
467 player[k].lastoccluded = i;
469 player[k].occluded = 0;
470 if (player[k].occluded < 25)
471 player[k].DrawSkeleton();
477 if (!cameramode && musictype == stream_fighttheme)
478 playerdist = distsqflat(&player[0].coords, &viewer);
483 glEnable(GL_TEXTURE_2D);
489 if (frustum.SphereInFrustum(realhawkcoords.x + hawk.boundingspherecenter.x, realhawkcoords.y + hawk.boundingspherecenter.y, realhawkcoords.z + hawk.boundingspherecenter.z, 2)) {
490 glAlphaFunc(GL_GREATER, 0.0001f);
492 glDisable(GL_CULL_FACE);
493 glDisable(GL_LIGHTING);
495 glTranslatef(hawkcoords.x, hawkcoords.y, hawkcoords.z);
496 glRotatef(hawkyaw, 0, 1, 0);
497 glTranslatef(25, 0, 0);
498 distance = distsq(&viewer, &realhawkcoords) * 1.2;
499 glColor4f(light.color[0], light.color[1], light.color[2], (viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance);
500 if ((viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance > 1)
501 glColor4f(light.color[0], light.color[1], light.color[2], 1);
502 if ((viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance > 0)
503 hawk.drawdifftex(hawktexture);
507 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
508 glEnable(GL_CULL_FACE);
509 glCullFace(GL_FRONT);
511 for (k = 0; k < numplayers; k++) {
512 if (!(k == 0 || tutoriallevel != 1)) {
514 glEnable(GL_LIGHTING);
515 terrainlight = terrain.getLighting(player[k].coords.x, player[k].coords.z);
516 distance = distsq(&viewer, &player[k].coords);
517 distance = (viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance;
518 glColor4f(terrainlight.x, terrainlight.y, terrainlight.z, distance);
521 if (distance >= .5) {
522 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;
524 if (!player[k].occluded == 0)
525 i = checkcollide(viewer, checkpoint, player[k].lastoccluded);
526 if (i == -1 || player[k].occluded == 0)
527 i = checkcollide(viewer, checkpoint);
529 player[k].occluded += 1;
530 player[k].lastoccluded = i;
532 player[k].occluded = 0;
533 if (player[k].occluded < 25)
534 player[k].DrawSkeleton();
540 glEnable(GL_TEXTURE_2D);
545 glDisable(GL_COLOR_MATERIAL);
547 glDisable(GL_LIGHTING);
548 glDisable(GL_TEXTURE_2D);
554 //waypoints, pathpoints in editor
557 glDisable(GL_LIGHTING);
558 glDisable(GL_TEXTURE_2D);
559 glDisable(GL_COLOR_MATERIAL);
560 glColor4f(1, 1, 0, 1);
562 for (k = 0; k < numplayers; k++) {
563 if (player[k].numwaypoints > 1) {
564 glBegin(GL_LINE_LOOP);
565 for (i = 0; i < player[k].numwaypoints; i++) {
566 glVertex3f(player[k].waypoints[i].x, player[k].waypoints[i].y + .5, player[k].waypoints[i].z);
573 if (numpathpoints > 1) {
574 glColor4f(0, 1, 0, 1);
575 for (k = 0; k < numpathpoints; k++) {
576 if (numpathpointconnect[k]) {
577 for (i = 0; i < numpathpointconnect[k]; i++) {
578 glBegin(GL_LINE_LOOP);
579 glVertex3f(pathpoint[k].x, pathpoint[k].y + .5, pathpoint[k].z);
580 glVertex3f(pathpoint[pathpointconnect[k][i]].x, pathpoint[pathpointconnect[k][i]].y + .5, pathpoint[pathpointconnect[k][i]].z);
585 glColor4f(1, 1, 1, 1);
588 glVertex3f(pathpoint[pathpointselected].x, pathpoint[pathpointselected].y + .5, pathpoint[pathpointselected].z);
595 glEnable(GL_TEXTURE_2D);
596 glColor4f(.5, .5, .5, 1);
598 sprintf (string, " ", (int)(fps));
599 text->glPrint(10, 30, string, 0, .8, screenwidth, screenheight);
602 if (bonus > 0 && bonustime < 1 && !winfreeze && indialogue == -1/*bonustime<4*/) {
603 const char *bonus_name;
604 if (bonus < bonus_count)
605 bonus_name = bonus_names[bonus];
607 bonus_name = "Excellent!"; // When does this happen?
609 glColor4f(0, 0, 0, 1 - bonustime);
610 text->glPrintOutline(1024 / 2 - 10 * strlen(bonus_name) - 4, 768 / 16 - 4 + 768 * 4 / 5, bonus_name, 1, 2.5, 1024, 768);
611 glColor4f(1, 0, 0, 1 - bonustime);
612 text->glPrint(1024 / 2 - 10 * strlen(bonus_name), 768 / 16 + 768 * 4 / 5, bonus_name, 1, 2, 1024, 768);
614 sprintf (string, "%d", (int)bonusvalue);
615 glColor4f(0, 0, 0, 1 - bonustime);
616 text->glPrintOutline(1024 / 2 - 10 * strlen(string) - 4, 768 / 16 - 4 - 20 + 768 * 4 / 5, string, 1, 2.5 * .8, 1024, 768);
617 glColor4f(1, 0, 0, 1 - bonustime);
618 text->glPrint(1024 / 2 - 10 * strlen(string), 768 / 16 - 20 + 768 * 4 / 5, string, 1, 2 * .8, 1024, 768);
619 glColor4f(.5, .5, .5, 1);
622 if (tutoriallevel == 1) {
623 tutorialopac = tutorialmaxtime - tutorialstagetime;
624 if (tutorialopac > 1)tutorialopac = 1;
625 if (tutorialopac < 0)tutorialopac = 0;
627 sprintf (string, " ");
628 sprintf (string2, " ");
629 sprintf (string3, " ");
630 if (tutorialstage == 0) {
631 sprintf (string, " ");
632 sprintf (string2, " ");
633 sprintf (string3, " ");
635 if (tutorialstage == 1) {
636 sprintf (string, "Welcome to the Lugaru training level!");
637 sprintf (string2, " ");
638 sprintf (string3, " ");
640 if (tutorialstage == 2) {
641 sprintf (string, "BASIC MOVEMENT:");
642 sprintf (string2, " ");
643 sprintf (string3, " ");
645 if (tutorialstage == 3) {
646 sprintf (string, "You can move the mouse to rotate the camera.");
647 sprintf (string2, " ");
648 sprintf (string3, " ");
650 if (tutorialstage == 4) {
651 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));
652 sprintf (string2, "All movement is relative to the camera.");
653 sprintf (string3, " ");
655 if (tutorialstage == 5) {
656 sprintf (string, "Please press %s to jump.", Input::keyToChar(jumpkey));
657 sprintf (string2, "You can hold it longer to jump higher.");
658 sprintf (string3, " ");
660 if (tutorialstage == 6) {
661 sprintf (string, "You can press %s to crouch.", Input::keyToChar(crouchkey));
662 sprintf (string2, "You can jump higher from a crouching position.");
663 sprintf (string3, " ");
665 if (tutorialstage == 7) {
666 sprintf (string, "While running, you can press %s to roll.", Input::keyToChar(crouchkey));
667 sprintf (string2, " ");
668 sprintf (string3, " ");
670 if (tutorialstage == 8) {
671 sprintf (string, "While crouching, you can sneak around silently");
672 sprintf (string2, "using the movement keys.");
673 sprintf (string3, " ");
675 if (tutorialstage == 9) {
676 sprintf (string, "Release the crouch key while sneaking and hold the movement keys");
677 sprintf (string2, "to run animal-style.");
678 sprintf (string3, " ");
680 if (tutorialstage == 10) {
681 sprintf (string, "ADVANCED MOVEMENT:");
682 sprintf (string2, " ");
683 sprintf (string3, " ");
685 if (tutorialstage == 11) {
686 sprintf (string, "When you jump at a wall, you can hold %s again", Input::keyToChar(jumpkey));
687 sprintf (string2, "during impact to perform a walljump.");
688 sprintf (string3, "Be sure to use the movement keys to press against the wall");
690 if (tutorialstage == 12) {
691 sprintf (string, "While in the air, you can press crouch to flip.", Input::keyToChar(jumpkey));
692 sprintf (string2, "Walljumps and flips confuse enemies and give you more control.");
693 sprintf (string3, " ");
695 if (tutorialstage == 13) {
696 sprintf (string, "BASIC COMBAT:");
697 sprintf (string2, " ");
698 sprintf (string3, " ");
700 if (tutorialstage == 14) {
701 sprintf (string, "There is now an imaginary enemy");
702 sprintf (string2, "in the middle of the training area.");
703 sprintf (string3, " ");
705 if (tutorialstage == 15) {
706 if (attackkey == MOUSEBUTTON1)sprintf (string, "Click to attack when you are near an enemy.");
707 else sprintf (string, "Press %s to attack when you are near an enemy.", Input::keyToChar(attackkey));
708 sprintf (string2, "You can punch by standing still near an enemy and attacking.");
709 sprintf (string3, " ");
711 if (tutorialstage == 16) {
712 sprintf (string, "If you are close, you will perform a weak punch.");
713 sprintf (string2, "The weak punch is excellent for starting attack combinations.");
714 sprintf (string3, " ");
716 if (tutorialstage == 17) {
717 sprintf (string, "Attacking while running results in a spin kick.");
718 sprintf (string2, "This is one of your most powerful ground attacks.");
719 sprintf (string3, " ");
721 if (tutorialstage == 18) {
722 sprintf (string, "Sweep the enemy's legs out by attacking while crouched.");
723 sprintf (string2, "This is a very fast attack, and easy to follow up.");
724 sprintf (string3, " ");
726 if (tutorialstage == 19) {
727 sprintf (string, "When an enemy is on the ground, you can deal some extra");
728 sprintf (string2, "damage by running up and drop-kicking him.");
729 sprintf (string3, "(Try knocking them down with a sweep first)");
731 if (tutorialstage == 20) {
732 sprintf (string, "Your most powerful individual attack is the rabbit kick.");
733 if (attackkey == MOUSEBUTTON1)sprintf (string2, "Run at the enemy while holding the mouse button, and press");
734 else sprintf (string2, "Run at the enemy while holding %s, and press", Input::keyToChar(attackkey));
735 sprintf (string3, "the jump key (%s) to attack.", Input::keyToChar(jumpkey));
737 if (tutorialstage == 21) {
738 sprintf (string, "This attack is devastating if timed correctly.");
739 sprintf (string2, "Even if timed incorrectly, it will knock the enemy over.");
740 if (againbonus)sprintf (string3, "Try rabbit-kicking the imaginary enemy again.");
741 else sprintf (string3, "Try rabbit-kicking the imaginary enemy.");
743 if (tutorialstage == 22) {
744 sprintf (string, "If you sneak behind an enemy unnoticed, you can kill");
745 sprintf (string2, "him instantly. Move close behind this enemy");
746 sprintf (string3, "and attack.");
748 if (tutorialstage == 23) {
749 sprintf (string, "Another important attack is the wall kick. When an enemy");
750 sprintf (string2, "is near a wall, perform a walljump nearby and hold");
751 sprintf (string3, "the attack key during impact with the wall.");
753 if (tutorialstage == 24) {
754 sprintf (string, "You can tackle enemies by running at them animal-style");
755 if (attackkey == MOUSEBUTTON1)sprintf (string2, "and pressing jump (%s) or attack(mouse button).", Input::keyToChar(jumpkey));
756 else sprintf (string2, "and pressing jump (%s) or attack(%s).", Input::keyToChar(jumpkey), Input::keyToChar(attackkey));
757 sprintf (string3, "This is especially useful when they are running away.");
759 if (tutorialstage == 25) {
760 sprintf (string, "Dodge by pressing back and attack. Dodging is essential");
761 sprintf (string2, "against enemies with swords or other long weapons.");
762 sprintf (string3, " ");
764 if (tutorialstage == 26) {
765 sprintf (string, "REVERSALS AND COUNTER-REVERSALS");
766 sprintf (string2, " ");
767 sprintf (string3, " ");
769 if (tutorialstage == 27) {
770 sprintf (string, "The enemy can now reverse your attacks.");
771 sprintf (string2, " ");
772 sprintf (string3, " ");
774 if (tutorialstage == 28) {
775 sprintf (string, "If you attack, you will notice that the enemy now sometimes");
776 sprintf (string2, "catches your attack and uses it against you. Hold");
777 sprintf (string3, "crouch (%s) after attacking to escape from reversals.", Input::keyToChar(crouchkey));
779 if (tutorialstage == 29) {
780 sprintf (string, "Try escaping from two more reversals in a row.");
781 sprintf (string2, " ");
782 sprintf (string3, " ");
784 if (tutorialstage == 30) {
785 sprintf (string, "Good!");
786 sprintf (string2, " ");
787 sprintf (string3, " ");
789 if (tutorialstage == 31) {
790 sprintf (string, "To reverse an attack, you must tap crouch (%s) during the", Input::keyToChar(crouchkey));
791 sprintf (string2, "enemy's attack. You must also be close to the enemy;");
792 sprintf (string3, "this is especially important against armed opponents.");
794 if (tutorialstage == 32) {
795 sprintf (string, "The enemy can attack in %d seconds.", (int)(tutorialmaxtime - tutorialstagetime));
796 sprintf (string2, "This imaginary opponents attacks will be highlighted");
797 sprintf (string3, "to make this easier.");
799 if (tutorialstage == 33) {
800 sprintf (string, "Reverse three enemy attacks!");
801 sprintf (string2, " ");
802 sprintf (string3, " ");
804 if (tutorialstage == 34) {
805 sprintf (string, "Reverse two more enemy attacks!");
806 sprintf (string2, " ");
807 sprintf (string3, " ");
809 if (tutorialstage == 35) {
810 sprintf (string, "Reverse one more enemy attack!");
811 sprintf (string2, " ");
812 sprintf (string3, " ");
814 if (tutorialstage == 36) {
815 sprintf (string, "Excellent!");
816 sprintf (string2, " ");
817 sprintf (string3, " ");
819 if (tutorialstage == 37) {
820 sprintf (string, "Now spar with the enemy for %d more seconds.", (int)(tutorialmaxtime - tutorialstagetime));
821 sprintf (string2, "Damage dealt: %d", (int)damagedealt);
822 sprintf (string3, "Damage taken: %d.", (int)damagetaken);
824 if (tutorialstage == 38) {
825 sprintf (string, "WEAPONS:");
826 sprintf (string2, " ");
827 sprintf (string3, " ");
829 if (tutorialstage == 39) {
830 sprintf (string, "There is now an imaginary knife");
831 sprintf (string2, "in the center of the training area.");
832 sprintf (string3, " ");
834 if (tutorialstage == 40) {
835 sprintf (string, "Stand, roll or handspring over the knife");
836 sprintf (string2, "while pressing %s to pick it up.", Input::keyToChar(throwkey));
837 sprintf (string3, "You can crouch and press the same key to drop it again.");
839 if (tutorialstage == 41) {
840 sprintf (string, "You can equip and unequip weapons using the %s key.", Input::keyToChar(drawkey));
841 sprintf (string2, "Sometimes it is best to keep them unequipped to");
842 sprintf (string3, "prevent enemies from taking them. ");
844 if (tutorialstage == 42) {
845 sprintf (string, "The knife is the smallest weapon and the least encumbering.");
846 sprintf (string2, "You can equip or unequip it while standing, crouching,");
847 sprintf (string3, "running or flipping.");
849 if (tutorialstage == 43) {
850 sprintf (string, "You perform weapon attacks the same way as unarmed attacks,");
851 sprintf (string2, "but sharp weapons cause permanent damage, instead of the");
852 sprintf (string3, "temporary trauma from blunt weapons, fists and feet.");
854 if (tutorialstage == 44) {
855 sprintf (string, "The enemy now has your knife!");
856 sprintf (string2, "Please reverse two of his knife attacks.");
857 sprintf (string3, " ");
859 if (tutorialstage == 45) {
860 sprintf (string, "Please reverse one more of his knife attacks.");
861 sprintf (string2, " ");
862 sprintf (string3, " ");
864 if (tutorialstage == 46) {
865 sprintf (string, "Now he has a sword!");
866 sprintf (string2, "The sword has longer reach than your arms, so you");
867 sprintf (string3, "must move close to reverse the sword slash.");
869 if (tutorialstage == 47) {
870 sprintf (string, "Long weapons like the sword and staff are also useful for defense;");
871 sprintf (string2, "you can parry enemy weapon attacks by pressing the attack key");
872 sprintf (string3, "at the right time. Please try parrying the enemy's attacks!");
874 if (tutorialstage == 48) {
875 sprintf (string, "The staff is like the sword, but has two main attacks.");
876 sprintf (string2, "The standing smash is fast and effective, and the running");
877 sprintf (string3, "spin smash is slower and more powerful.");
879 if (tutorialstage == 49) {
880 sprintf (string, "When facing an enemy, you can throw the knife with %s.", Input::keyToChar(throwkey));
881 sprintf (string2, "It is possible to throw the knife while flipping,");
882 sprintf (string3, "but it is very inaccurate.");
884 if (tutorialstage == 50) {
885 sprintf (string, "You now know everything you can learn from training.");
886 sprintf (string2, "Everything else you must learn from experience!");
887 sprintf (string3, " ");
889 if (tutorialstage == 51) {
890 sprintf (string, "Walk out of the training area to return to the main menu.");
891 sprintf (string2, " ");
892 sprintf (string3, " ");
895 glColor4f(0, 0, 0, tutorialopac);
896 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);
897 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);
898 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);
899 glColor4f(1, 1, 1, tutorialopac);
900 text->glPrint(screenwidth / 2 - 7.6 * strlen(string)*screenwidth / 1024, screenheight / 16 + screenheight * 4 / 5, string, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight);
901 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);
902 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);
904 sprintf (string, "Press 'tab' to skip to the next item.", Input::keyToChar(jumpkey));
905 sprintf (string2, "Press escape at any time to");
906 sprintf (string3, "pause or exit the tutorial.");
908 glColor4f(0, 0, 0, 1);
909 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);
910 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);
911 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);
912 glColor4f(0.5, 0.5, 0.5, 1);
913 text->glPrint(screenwidth / 2 - 7.6 * strlen(string)*screenwidth / 1024 * .8, 0 + screenheight * 1 / 10, string, 1, 1.5 * screenwidth / 1024 * .8, screenwidth, screenheight);
914 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);
915 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);
919 if (numhotspots && (bonustime >= 1 || bonus <= 0 || bonustime < 0) && !tutoriallevel) {
921 float closestdist = -1;
923 closest = currenthotspot;
924 for (i = 0; i < numhotspots; i++) {
925 distance = distsq(&player[0].coords, &hotspot[i]);
926 if (closestdist == -1 || distance < closestdist) {
927 if (distsq(&player[0].coords, &hotspot[i]) < hotspotsize[i] && ((hotspottype[i] <= 10 && hotspottype[i] >= 0) || (hotspottype[i] <= 40 && hotspottype[i] >= 20))) {
928 closestdist = distance;
934 currenthotspot = closest;
935 if (currenthotspot != -1) {
936 if (hotspottype[closest] <= 10) {
937 if (distsq(&player[0].coords, &hotspot[closest]) < hotspotsize[closest])
938 tutorialstagetime = 0;
940 tutorialopac = tutorialmaxtime - tutorialstagetime;
941 if (tutorialopac > 1)tutorialopac = 1;
942 if (tutorialopac < 0)tutorialopac = 0;
944 sprintf (string, "%s", hotspottext[closest]);
951 if (string[i] == '\n' || string[i] > 'z' || string[i] < ' ' || string[i] == '\0') {
952 glColor4f(0, 0, 0, tutorialopac);
953 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);
954 glColor4f(1, 1, 1, tutorialopac);
955 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);
958 if (string[i] == '\0')done = 1;
960 if (i >= 255)done = 1;
963 } else if (hotspottype[closest] >= 20 && dialoguegonethrough[hotspottype[closest] - 20] == 0) {
964 whichdialogue = hotspottype[closest] - 20;
965 for (j = 0; j < numdialogueboxes[whichdialogue]; j++) {
966 player[participantfocus[whichdialogue][j]].coords = participantlocation[whichdialogue][participantfocus[whichdialogue][j]];
967 player[participantfocus[whichdialogue][j]].yaw = participantyaw[whichdialogue][participantfocus[whichdialogue][j]];
968 player[participantfocus[whichdialogue][j]].targetyaw = participantyaw[whichdialogue][participantfocus[whichdialogue][j]];
969 player[participantfocus[whichdialogue][j]].velocity = 0;
970 player[participantfocus[whichdialogue][j]].animTarget = player[participantfocus[whichdialogue][j]].getIdle();
971 player[participantfocus[whichdialogue][j]].frameTarget = 0;
975 dialoguegonethrough[whichdialogue]++;
976 if (dialogueboxsound[whichdialogue][indialogue] != 0) {
978 if (dialogueboxsound[whichdialogue][indialogue] == 1)whichsoundplay = rabbitchitter;
979 if (dialogueboxsound[whichdialogue][indialogue] == 2)whichsoundplay = rabbitchitter2;
980 if (dialogueboxsound[whichdialogue][indialogue] == 3)whichsoundplay = rabbitpainsound;
981 if (dialogueboxsound[whichdialogue][indialogue] == 4)whichsoundplay = rabbitpain1sound;
982 if (dialogueboxsound[whichdialogue][indialogue] == 5)whichsoundplay = rabbitattacksound;
983 if (dialogueboxsound[whichdialogue][indialogue] == 6)whichsoundplay = rabbitattack2sound;
984 if (dialogueboxsound[whichdialogue][indialogue] == 7)whichsoundplay = rabbitattack3sound;
985 if (dialogueboxsound[whichdialogue][indialogue] == 8)whichsoundplay = rabbitattack4sound;
986 if (dialogueboxsound[whichdialogue][indialogue] == 9)whichsoundplay = growlsound;
987 if (dialogueboxsound[whichdialogue][indialogue] == 10)whichsoundplay = growl2sound;
988 if (dialogueboxsound[whichdialogue][indialogue] == 11)whichsoundplay = snarlsound;
989 if (dialogueboxsound[whichdialogue][indialogue] == 12)whichsoundplay = snarl2sound;
990 if (dialogueboxsound[whichdialogue][indialogue] == 13)whichsoundplay = barksound;
991 if (dialogueboxsound[whichdialogue][indialogue] == 14)whichsoundplay = bark2sound;
992 if (dialogueboxsound[whichdialogue][indialogue] == 15)whichsoundplay = bark3sound;
993 if (dialogueboxsound[whichdialogue][indialogue] == 16)whichsoundplay = barkgrowlsound;
994 if (dialogueboxsound[whichdialogue][indialogue] == -1)whichsoundplay = fireendsound;
995 if (dialogueboxsound[whichdialogue][indialogue] == -2)whichsoundplay = firestartsound;
996 if (dialogueboxsound[whichdialogue][indialogue] == -3)whichsoundplay = consolesuccesssound;
997 if (dialogueboxsound[whichdialogue][indialogue] == -4)whichsoundplay = consolefailsound;
998 emit_sound_at(whichsoundplay, player[participantfocus[whichdialogue][indialogue]].coords);
1004 if (indialogue != -1 && !mainmenu) {
1005 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1006 glDisable(GL_CULL_FACE);
1007 glDisable(GL_LIGHTING);
1008 glDisable(GL_TEXTURE_2D);
1010 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1011 glPushMatrix(); // Store The Projection Matrix
1012 glLoadIdentity(); // Reset The Projection Matrix
1013 glOrtho(0, screenwidth, 0, screenheight, -100, 100); // Set Up An Ortho Screen
1014 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1015 glPushMatrix(); // Store The Modelview Matrix
1016 glLoadIdentity(); // Reset The Modelview Matrix
1017 if (dialogueboxlocation[whichdialogue][indialogue] == 1)glTranslatef(0, screenheight * 3 / 4, 0);
1018 glScalef(screenwidth, screenheight / 4, 1);
1019 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1022 glColor4f(dialogueboxcolor[whichdialogue][indialogue][0], dialogueboxcolor[whichdialogue][indialogue][1], dialogueboxcolor[whichdialogue][indialogue][2], 0.7);
1024 glVertex3f(0, 0, 0.0f);
1025 glVertex3f(1, 0, 0.0f);
1026 glVertex3f(1, 1, 0.0f);
1027 glVertex3f(0, 1, 0.0f);
1029 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1030 glPopMatrix(); // Restore The Old Projection Matrix
1031 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1032 glPopMatrix(); // Restore The Old Projection Matrix
1033 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1034 glEnable(GL_CULL_FACE);
1035 glDisable(GL_BLEND);
1037 glEnable(GL_TEXTURE_2D);
1044 startx = screenwidth * 1 / 5;
1045 if (dialogueboxlocation[whichdialogue][indialogue] == 1)
1046 starty = screenheight / 16 + screenheight * 4 / 5;
1047 if (dialogueboxlocation[whichdialogue][indialogue] == 2)
1048 starty = screenheight * 1 / 5 - screenheight / 16;
1053 for (i = 0; i < 264; i++) {
1057 for (i = 0; i < (int)strlen(dialoguename[whichdialogue][indialogue]); i++) {
1058 tempname[tempnum] = dialoguename[whichdialogue][indialogue][i];
1060 if (dialoguename[whichdialogue][indialogue][i] == '#' || dialoguename[whichdialogue][indialogue][i] == '\0')goodchar = 0;
1064 tempname[tempnum] = '\0';
1067 sprintf (string, "%s: ", tempname);
1069 if (dialogueboxcolor[whichdialogue][indialogue][0] + dialogueboxcolor[whichdialogue][indialogue][1] + dialogueboxcolor[whichdialogue][indialogue][2] < 1.5) {
1070 glColor4f(0, 0, 0, tutorialopac);
1071 text->glPrintOutline(startx - 2 * 7.6 * strlen(string)*screenwidth / 1024 - 4, starty - 4, string, 1, 1.5 * 1.25 * screenwidth / 1024, screenwidth, screenheight);
1072 glColor4f(0.7, 0.7, 0.7, tutorialopac);
1073 text->glPrint(startx - 2 * 7.6 * strlen(string)*screenwidth / 1024, starty, string, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight);
1075 glColor4f(0, 0, 0, tutorialopac);
1076 text->glPrintOutline(startx - 2 * 7.6 * strlen(string)*screenwidth / 1024 - 4, starty - 4, string, 1, 1.5 * 1.25 * screenwidth / 1024, screenwidth, screenheight);
1080 for (i = 0; i < (int)strlen(dialoguetext[whichdialogue][indialogue]) + 1; i++) {
1081 tempname[tempnum] = dialoguetext[whichdialogue][indialogue][i];
1082 if (dialoguetext[whichdialogue][indialogue][i] != '#')tempnum++;
1085 sprintf (string, "%s", tempname);
1092 if (string[i] == '\n' || string[i] > 'z' || string[i] < ' ' || string[i] == '\0') {
1093 if (dialogueboxcolor[whichdialogue][indialogue][0] + dialogueboxcolor[whichdialogue][indialogue][1] + dialogueboxcolor[whichdialogue][indialogue][2] < 1.5) {
1094 glColor4f(0, 0, 0, tutorialopac);
1095 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);
1096 glColor4f(1, 1, 1, tutorialopac);
1097 text->glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/, starty - 20 * screenwidth / 1024 * line, string, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight, lastline, i);
1099 glColor4f(0, 0, 0, tutorialopac);
1100 text->glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/, starty - 20 * screenwidth / 1024 * line, string, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight, lastline, i);
1104 if (string[i] == '\0')done = 1;
1106 if (i >= 255)done = 1;
1111 if (!tutoriallevel && !winfreeze && indialogue == -1 && !mainmenu) {
1114 sprintf (string, "Score: %d", (int)accountactive->getCampaignScore());
1116 sprintf (string, "Score: %d", (int)accountactive->getCampaignScore() + (int)bonustotal);
1118 if (!campaign)sprintf (string, "Score: %d", (int)bonustotal);
1119 glColor4f(0, 0, 0, 1);
1120 text->glPrintOutline(1024 / 40 - 4, 768 / 16 - 4 + 768 * 14 / 16, string, 1, 1.5 * 1.25, 1024, 768);
1121 glColor4f(1, 0, 0, 1);
1122 text->glPrint(1024 / 40, 768 / 16 + 768 * 14 / 16, string, 1, 1.5, 1024, 768);
1123 if (showdamagebar) {
1124 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1125 glDisable(GL_CULL_FACE);
1126 glDisable(GL_LIGHTING);
1127 glDisable(GL_TEXTURE_2D);
1129 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1130 glPushMatrix(); // Store The Projection Matrix
1131 glLoadIdentity(); // Reset The Projection Matrix
1132 glOrtho(0, screenwidth, 0, screenheight, -100, 100); // Set Up An Ortho Screen
1133 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1134 glPushMatrix(); // Store The Modelview Matrix
1135 glLoadIdentity(); // Reset The Modelview Matrix
1136 glTranslatef(15, screenheight * 17.5 / 20, 0);
1137 glScalef(screenwidth / 3 + 20, screenheight / 20, 1);
1138 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1140 glColor4f(0.0, 0.4, 0.0, 0.7);
1141 float bar = ((float)player[0].damage) / player[0].damagetolerance;
1143 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
1144 glVertex3f(1, 0, 0.0f);
1145 glVertex3f(1, 1, 0.0f);
1146 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
1148 glColor4f(0.1, 0.0, 0.0, 1);
1149 bar = ((float)player[0].bloodloss) / player[0].damagetolerance;
1151 glVertex3f(0, 0, 0.0f);
1152 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
1153 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
1154 glVertex3f(0, 1, 0.0f);
1156 glColor4f(0.4, 0.0, 0.0, 0.7);
1157 bar = ((float)player[0].damage) / player[0].damagetolerance;
1159 glVertex3f(0, 0, 0.0f);
1160 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
1161 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
1162 glVertex3f(0, 1, 0.0f);
1164 glColor4f(0.4, 0.0, 0.0, 0.7);
1165 bar = ((float)player[0].permanentdamage) / player[0].damagetolerance;
1167 glVertex3f(0, 0, 0.0f);
1168 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
1169 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
1170 glVertex3f(0, 1, 0.0f);
1172 glColor4f(0.4, 0.0, 0.0, 0.7);
1173 bar = ((float)player[0].superpermanentdamage) / player[0].damagetolerance;
1175 glVertex3f(0, 0, 0.0f);
1176 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
1177 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
1178 glVertex3f(0, 1, 0.0f);
1180 glColor4f(0.0, 0.0, 0.0, 0.7);
1182 glBegin(GL_LINE_STRIP);
1183 glVertex3f(0, 0, 0.0f);
1184 glVertex3f(1, 0, 0.0f);
1185 glVertex3f(1, 1, 0.0f);
1186 glVertex3f(0, 1, 0.0f);
1187 glVertex3f(0, 0, 0.0f);
1190 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1191 glPopMatrix(); // Restore The Old Projection Matrix
1192 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1193 glPopMatrix(); // Restore The Old Projection Matrix
1194 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1195 glEnable(GL_CULL_FACE);
1196 glDisable(GL_BLEND);
1198 glEnable(GL_TEXTURE_2D);
1200 // writing the numbers :
1201 sprintf (string, "Damages : %d/%d (%d)", (int)(player[0].damage), (int)(player[0].damagetolerance), (int)(player[0].bloodloss));
1202 glColor4f(0, 0, 0, 1);
1203 text->glPrintOutline(1024 / 40 - 4, 768 / 16 - 4 + 768 * 14 / 16 - 40, string, 1, 1.5 * 1.25, 1024, 768);
1204 glColor4f(1, 0, 0, 1);
1205 text->glPrint(1024 / 40, 768 / 16 + 768 * 14 / 16 - 40, string, 1, 1.5, 1024, 768);
1209 glColor4f(.5, .5, .5, 1);
1212 if ((texttoggle || editorenabled) && debugmode && !mainmenu) {
1213 sprintf (string, "The framespersecond is %d.", (int)(fps));
1214 text->glPrint(10, 30, string, 0, .8, 1024, 768);
1217 sprintf (string, "Map editor enabled.");
1219 sprintf (string, "Map editor disabled.");
1220 text->glPrint(10, 60, string, 0, .8, 1024, 768);
1221 if (editorenabled) {
1222 sprintf (string, "Object size: %f", editorsize);
1223 text->glPrint(10, 75, string, 0, .8, 1024, 768);
1224 if (editoryaw >= 0)sprintf (string, "Object yaw: %f", editoryaw);
1225 else sprintf (string, "Object yaw: Random");
1226 text->glPrint(10, 90, string, 0, .8, 1024, 768);
1227 if (editorpitch >= 0)sprintf (string, "Object pitch: %f", editorpitch);
1228 else sprintf (string, "Object pitch: Random");
1229 text->glPrint(10, 105, string, 0, .8, 1024, 768);
1230 sprintf (string, "Object type: %d", editortype);
1231 text->glPrint(10, 120, string, 0, .8, 1024, 768);
1232 switch (editortype) {
1234 sprintf (string, "(box)");
1237 sprintf (string, "(tree)");
1240 sprintf (string, "(wall)");
1243 sprintf (string, "(weird)");
1246 sprintf (string, "(spike)");
1249 sprintf (string, "(rock)");
1252 sprintf (string, "(bush)");
1255 sprintf (string, "(tunnel)");
1258 sprintf (string, "(chimney)");
1261 sprintf (string, "(platform)");
1264 sprintf (string, "(cool)");
1267 sprintf (string, "(fire)");
1270 text->glPrint(130, 120, string, 0, .8, 1024, 768);
1272 sprintf (string, "Numplayers: %d", numplayers);
1273 text->glPrint(10, 155, string, 0, .8, 1024, 768);
1274 sprintf (string, "Player %d: numwaypoints: %d", numplayers, player[numplayers - 1].numwaypoints);
1275 text->glPrint(10, 140, string, 0, .8, 1024, 768);
1277 sprintf (string, "Difficulty: %d", difficulty);
1278 text->glPrint(10, 240, string, 0, .8, 1024, 768);
1283 if (drawmode == glowmode) {
1284 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1285 glDisable(GL_CULL_FACE);
1286 glDisable(GL_LIGHTING);
1287 glDisable(GL_TEXTURE_2D);
1289 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1290 glPushMatrix(); // Store The Projection Matrix
1291 glLoadIdentity(); // Reset The Projection Matrix
1292 glOrtho(0, screenwidth, 0, screenheight, -100, 100); // Set Up An Ortho Screen
1293 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1294 glPushMatrix(); // Store The Modelview Matrix
1295 glLoadIdentity(); // Reset The Modelview Matrix
1296 glScalef(screenwidth, screenheight, 1);
1297 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1299 glColor4f(0, 0, 0, .5);
1301 glVertex3f(0, 0, 0.0f);
1302 glVertex3f(256, 0, 0.0f);
1303 glVertex3f(256, 256, 0.0f);
1304 glVertex3f(0, 256, 0.0f);
1306 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1307 glPopMatrix(); // Restore The Old Projection Matrix
1308 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1309 glPopMatrix(); // Restore The Old Projection Matrix
1310 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
1311 glEnable(GL_CULL_FACE);
1312 glDisable(GL_BLEND);
1316 if ((((blackout && damageeffects) || (player[0].bloodloss > 0 && damageeffects && player[0].blooddimamount > 0) || player[0].dead) && !cameramode) || console) {
1317 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
1318 glDisable(GL_CULL_FACE);
1319 glDisable(GL_LIGHTING);
1320 glDisable(GL_TEXTURE_2D);
1322 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
1323 glPushMatrix(); // Store The Projection Matrix
1324 glLoadIdentity(); // Reset The Projection Matrix
1325 glOrtho(0, screenwidth, 0, screenheight, -100, 100); // Set Up An Ortho Screen
1326 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
1327 glPushMatrix(); // Store The Modelview Matrix
1328 glLoadIdentity(); // Reset The Modelview Matrix
1329 glScalef(screenwidth, screenheight, 1);
1330 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1332 if (player[0].dead)blackout += multiplier * 3;
1333 if (player[0].dead == 1)blackout = .4f;
1334 if (player[0].dead == 2 && blackout > .6)blackout = .6;
1335 glColor4f(0, 0, 0, blackout);
1336 if (!player[0].dead) {
1337 if ((player[0].bloodloss / player[0].damagetolerance * (sin(woozy) / 4 + .5))*.3 < .3) {
1338 glColor4f(0, 0, 0, player[0].blooddimamount * player[0].bloodloss / player[0].damagetolerance * (sin(woozy) / 4 + .5)*.3);
1339 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);
1401 glColor4f(1, 1, 1, 1);
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);
1410 for (i = 0; i < 15; i++)
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);
1445 glColor4f(1, 1, 1, 1);
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 = distsq(¢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 = distsq(¢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 = distsq(&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 = distsq(&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);
1547 if (editorenabled) {
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 = distsq(&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);
1648 glColor4f(1, 1, 1, 1);
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);
1698 glColor4f(1, 1, 1, 1);
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)) {
1733 if (screentexture) {
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) {
1748 if (screentexture2) {
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;
1856 glColor4f(1, 1, 1, 1);
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);
1871 if (crosseyedness) {
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) {
1948 for (i = 0; i < 3; i++) {
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);
1979 glColor4f(1, 1, 1, 1);
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);
1989 for (i = 0; i < 15; i++)
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!
2038 // !!! FIXME: hack: clamp framerate in menu so text input works correctly on fast systems.
2041 glDrawBuffer(GL_BACK);
2042 glReadBuffer(GL_BACK);
2043 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
2044 Game::ReSizeGLScene(90, .1f);
2046 //draw menu background
2047 glClear(GL_DEPTH_BUFFER_BIT);
2048 glEnable(GL_ALPHA_TEST);
2049 glAlphaFunc(GL_GREATER, 0.001f);
2050 glEnable(GL_TEXTURE_2D);
2051 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
2052 glDisable(GL_CULL_FACE);
2053 glDisable(GL_LIGHTING);
2055 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2056 glPushMatrix(); // Store The Projection Matrix
2057 glLoadIdentity(); // Reset The Projection Matrix
2058 glOrtho(0, screenwidth, 0, screenheight, -100, 100); // Set Up An Ortho Screen
2059 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2060 glPushMatrix(); // Store The Modelview Matrix
2061 glLoadIdentity(); // Reset The Modelview Matrix
2062 glTranslatef(screenwidth / 2, screenheight / 2, 0);
2064 glScalef((float)screenwidth / 2, (float)screenheight / 2, 1);
2065 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
2066 glDisable(GL_BLEND);
2067 glColor4f(0, 0, 0, 1.0);
2068 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2069 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2070 glDisable(GL_TEXTURE_2D);
2072 glVertex3f(-1, -1, 0);
2073 glVertex3f(+1, -1, 0);
2074 glVertex3f(+1, +1, 0);
2075 glVertex3f(-1, +1, 0);
2078 glColor4f(0.4, 0.4, 0.4, 1.0);
2079 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2080 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2081 glEnable(GL_TEXTURE_2D);
2082 Game::Mainmenuitems[4].bind();
2085 glVertex3f(-1, -1, 0);
2087 glVertex3f(+1, -1, 0);
2089 glVertex3f(+1, +1, 0);
2091 glVertex3f(-1, +1, 0);
2095 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2097 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2101 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2102 glPushMatrix(); // Store The Projection Matrix
2103 glLoadIdentity(); // Reset The Projection Matrix
2104 glOrtho(0, 640, 0, 480, -100, 100); // Set Up An Ortho Screen
2105 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2106 glPushMatrix(); // Store The Modelview Matrix
2107 glLoadIdentity(); // Reset The Modelview Matrix
2108 glEnable(GL_TEXTURE_2D);
2113 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2115 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2118 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2119 glPushMatrix(); // Store The Projection Matrix
2120 glLoadIdentity(); // Reset The Projection Matrix
2121 glOrtho(0, screenwidth, 0, screenheight, -100, 100); // Set Up An Ortho Screen
2122 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
2123 glPushMatrix(); // Store The Modelview Matrix
2124 glLoadIdentity(); // Reset The Modelview Matrix
2125 glTranslatef(screenwidth / 2, screenheight / 2, 0);
2127 glScalef((float)screenwidth / 2, (float)screenheight / 2, 1);
2128 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
2130 glEnable(GL_TEXTURE_2D);
2131 glColor4f(1, 1, 1, 1);
2132 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2133 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2135 if (!Game::waiting) { // hide the cursor while waiting for a key
2137 glTranslatef(Game::mousecoordh - screenwidth / 2, Game::mousecoordv * -1 + screenheight / 2, 0);
2138 glScalef((float)screenwidth / 64, (float)screenwidth / 64, 1);
2139 glTranslatef(1, -1, 0);
2140 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
2141 glColor4f(1, 1, 1, 1);
2142 Game::cursortexture.bind();
2144 //glScalef(.25,.25,.25);
2147 glVertex3f(-1, -1, 0.0f);
2149 glVertex3f(1, -1, 0.0f);
2151 glVertex3f(1, 1, 0.0f);
2153 glVertex3f(-1, 1, 0.0f);
2159 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
2164 if (flashamount > 0) {
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);