2 Copyright (C) 2003, 2010 - Wolfire Games
3 Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
5 This file is part of Lugaru.
7 Lugaru is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 Lugaru is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
22 #include "openal_wrapper.h"
29 extern int environment;
30 extern float texscale;
32 extern Terrain terrain;
33 extern float multiplier;
34 extern float viewdistance;
35 extern float fadestart;
36 extern float screenwidth, screenheight;
37 extern int kTextureSize;
38 extern FRUSTUM frustum;
40 extern Objects objects;
42 extern float usermousesensitivity;
43 extern float camerashake;
45 extern float slomodelay;
46 extern bool ismotionblur;
48 extern float blackout;
49 extern bool damageeffects;
51 extern bool texttoggle;
52 extern float blurness;
53 extern float targetblurness;
54 extern float playerdist;
55 extern bool cellophane;
57 extern float flashamount, flashr, flashg, flashb;
58 extern int flashdelay;
60 extern float motionbluramount;
62 extern bool alwaysblur;
63 extern bool velocityblur;
64 extern bool debugmode;
66 extern int bloodtoggle;
67 extern int difficulty;
69 extern float texdetail;
70 extern bool musictoggle;
71 extern int tutoriallevel;
72 extern float smoketex;
73 extern float tutorialstagetime;
74 extern float tutorialmaxtime;
75 extern int tutorialstage;
76 extern bool againbonus;
77 extern float damagedealt;
78 extern bool invertmouse;
80 extern int numhotspots;
81 extern int killhotspot;
82 extern XYZ hotspot[40];
83 extern int hotspottype[40];
84 extern float hotspotsize[40];
85 extern char hotspottext[40][256];
86 extern int currenthotspot;
89 extern bool winfreeze;
91 extern bool gamestart;
93 extern bool gamestarted;
95 extern bool showdamagebar;
100 int numboundaries = 0;
107 normalmode, motionblurmode, radialzoommode,
108 realmotionblurmode, doublevisionmode, glowmode,
111 void Game::flash(float amount, int delay) // shouldn't be that way, these should be attributes and Person class should not change rendering.
116 flashamount = amount;
122 /*********************> DrawGLScene() <*****/
123 int Game::DrawGLScene(StereoSide side)
125 static float texcoordwidth, texcoordheight;
126 static float texviewwidth, texviewheight;
128 static XYZ checkpoint;
129 static float tempmult;
131 static char string[256] = "";
132 static char string2[256] = "";
133 static char string3[256] = "";
134 static int drawmode = 0;
136 if ( stereomode == stereoAnaglyph ) {
139 glColorMask( 0.0, 1.0, 1.0, 1.0 );
142 glColorMask( 1.0, 0.0, 0.0, 1.0 );
148 glColorMask( 1.0, 1.0, 1.0, 1.0 );
150 if ( stereomode == stereoHorizontalInterlaced || stereomode == stereoVerticalInterlaced ) {
151 glStencilFunc(side == stereoLeft ? GL_NOTEQUAL : GL_EQUAL, 0x01, 0x01);
155 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted)) {
156 tempmult = multiplier;
162 numboundaries = mapradius * 2;
163 if (numboundaries > 360)
165 for (int i = 0; i < numboundaries; i++) {
168 boundary[i] = mapcenter + DoRotation(boundary[i] * mapradius, 0, i * (360 / ((float)(numboundaries))), 0);
177 int olddrawmode = drawmode;
178 if (ismotionblur && !loading) {
179 if ((findLengthfast(&Person::players[0]->velocity) > 200) && velocityblur && !cameramode) {
180 drawmode = motionblurmode;
181 motionbluramount = 200 / (findLengthfast(&Person::players[0]->velocity));
184 if (Person::players[0]->damage - Person::players[0]->superpermanentdamage > (Person::players[0]->damagetolerance - Person::players[0]->superpermanentdamage) * 1 / 2 && damageeffects && !cameramode) {
185 drawmode = doublevisionmode;
190 if (slomo && !loading) {
192 drawmode = motionblurmode;
193 motionbluramount = .2;
194 slomodelay -= multiplier;
200 if ((!changed && !slomo) || loading) {
201 drawmode = normalmode;
202 if (ismotionblur && (/*fps>100||*/alwaysblur)) {
203 if (olddrawmode != realmotionblurmode)
207 drawmode = realmotionblurmode;
208 } else if (olddrawmode == realmotionblurmode)
214 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted))
215 drawmode = normalmode;
216 if ((freeze || winfreeze) && ismotionblur && !mainmenu)
217 drawmode = radialzoommode;
219 if (winfreeze || mainmenu)
220 drawmode = normalmode;
223 drawtoggle = 1 - drawtoggle;
225 if (!texcoordwidth) {
226 texviewwidth = kTextureSize;
227 if (texviewwidth > screenwidth)
228 texviewwidth = screenwidth;
229 texviewheight = kTextureSize;
230 if (texviewheight > screenheight)
231 texviewheight = screenheight;
233 texcoordwidth = screenwidth / kTextureSize;
234 texcoordheight = screenheight / kTextureSize;
235 if (texcoordwidth > 1)
237 if (texcoordheight > 1)
241 glDrawBuffer(GL_BACK);
242 glReadBuffer(GL_BACK);
244 static XYZ terrainlight;
245 static float distance;
246 if (drawmode == normalmode)
247 Game::ReSizeGLScene(90, .1f);
248 if (drawmode != normalmode)
249 glViewport(0, 0, texviewwidth, texviewheight);
250 glDepthFunc(GL_LEQUAL);
252 glAlphaFunc(GL_GREATER, 0.0001f);
253 glEnable(GL_ALPHA_TEST);
254 glClearColor(0.25f, 0.25f, 0.25f, 1.0f);
255 glClear(GL_DEPTH_BUFFER_BIT);
257 glMatrixMode (GL_MODELVIEW);
258 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
261 // Move the camera for the current eye's point of view.
262 // Reverse the movement if we're reversing stereo
263 glTranslatef((stereoseparation / 2) * side * (stereoreverse ? -1 : 1), 0, 0);
266 if (!cameramode && !freeze && !winfreeze) {
268 glRotatef(float(Random() % 100) / 10 * camerashake/*+(woozy*woozy)/10*/, 0, 0, 1);
270 glRotatef(pitch + sin(woozy / 2) * (Person::players[0]->damage / Person::players[0]->damagetolerance) * 5, 1, 0, 0);
271 glRotatef(yaw + sin(woozy) * (Person::players[0]->damage / Person::players[0]->damagetolerance) * 5, 0, 1, 0);
273 if (cameramode || freeze || winfreeze) {
274 glRotatef(pitch, 1, 0, 0);
275 glRotatef(yaw, 0, 1, 0);
278 if (environment == desertenvironment) {
279 glRotatef((float)(abs(Random() % 100)) / 3000 - 1, 1, 0, 0);
280 glRotatef((float)(abs(Random() % 100)) / 3000 - 1, 0, 1, 0);
282 SetUpLight(&light, 0);
285 //heat blur effect in desert
286 if (abs(blurness - targetblurness) < multiplier * 10 || abs(blurness - targetblurness) > 2) {
287 blurness = targetblurness;
288 targetblurness = (float)(abs(Random() % 100)) / 40;
290 if (blurness < targetblurness)
291 blurness += multiplier * 5;
293 blurness -= multiplier * 5;
295 if (environment == desertenvironment && detail == 2)
296 glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, blurness + .4 );
297 if (environment == desertenvironment) {
298 glRotatef((float)(abs(Random() % 100)) / 1000, 1, 0, 0);
299 glRotatef((float)(abs(Random() % 100)) / 1000, 0, 1, 0);
302 glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0);
304 glTranslatef(-viewer.x, -viewer.y, -viewer.z);
305 frustum.GetFrustum();
307 //make shadow decals on terrain and objects
309 static float size, opacity, rotation;
311 for (unsigned k = 0; k < Person::players.size(); k++) {
312 if (!Person::players[k]->skeleton.free && Person::players[k]->playerdetail && Person::players[k]->howactive < typesleeping)
313 if (frustum.SphereInFrustum(Person::players[k]->coords.x, Person::players[k]->coords.y + Person::players[k]->scale * 3, Person::players[k]->coords.z, Person::players[k]->scale * 7) && Person::players[k]->occluded < 25)
314 for (int i = 0; i < Person::players[k]->skeleton.num_joints; i++) {
315 if (Person::players[k]->skeleton.joints[i].label == leftknee || Person::players[k]->skeleton.joints[i].label == rightknee || Person::players[k]->skeleton.joints[i].label == groin) {
316 point = DoRotation(Person::players[k]->skeleton.joints[i].position, 0, Person::players[k]->yaw, 0) * Person::players[k]->scale + Person::players[k]->coords;
318 opacity = .4 - Person::players[k]->skeleton.joints[i].position.y * Person::players[k]->scale / 5 - (Person::players[k]->coords.y - terrain.getHeight(Person::players[k]->coords.x, Person::players[k]->coords.z)) / 10;
319 if (k != 0 && tutoriallevel == 1) {
320 opacity = .2 + .2 * sin(smoketex * 6 + i) - Person::players[k]->skeleton.joints[i].position.y * Person::players[k]->scale / 5 - (Person::players[k]->coords.y - terrain.getHeight(Person::players[k]->coords.x, Person::players[k]->coords.z)) / 10;
322 terrain.MakeDecal(shadowdecal, point, size, opacity, rotation);
323 for (l = 0; l < terrain.patchobjectnum[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz]; l++) {
324 int j = terrain.patchobjects[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz][l];
325 if (objects.position[j].y < Person::players[k]->coords.y || objects.type[j] == tunneltype || objects.type[j] == weirdtype) {
326 point = DoRotation(DoRotation(Person::players[k]->skeleton.joints[i].position, 0, Person::players[k]->yaw, 0) * Person::players[k]->scale + Person::players[k]->coords - objects.position[j], 0, -objects.yaw[j], 0);
329 if (k != 0 && tutoriallevel == 1) {
330 opacity = .2 + .2 * sin(smoketex * 6 + i);
332 objects.model[j].MakeDecal(shadowdecal, &point, &size, &opacity, &rotation);
337 if ((Person::players[k]->skeleton.free || Person::players[k]->howactive >= typesleeping) && Person::players[k]->playerdetail)
338 if (frustum.SphereInFrustum(Person::players[k]->coords.x, Person::players[k]->coords.y, Person::players[k]->coords.z, Person::players[k]->scale * 5) && Person::players[k]->occluded < 25)
339 for (int i = 0; i < Person::players[k]->skeleton.num_joints; i++) {
340 if (Person::players[k]->skeleton.joints[i].label == leftknee || Person::players[k]->skeleton.joints[i].label == rightknee || Person::players[k]->skeleton.joints[i].label == groin || Person::players[k]->skeleton.joints[i].label == leftelbow || Person::players[k]->skeleton.joints[i].label == rightelbow || Person::players[k]->skeleton.joints[i].label == neck) {
341 if (Person::players[k]->skeleton.free)
342 point = Person::players[k]->skeleton.joints[i].position * Person::players[k]->scale + Person::players[k]->coords;
344 point = DoRotation(Person::players[k]->skeleton.joints[i].position, 0, Person::players[k]->yaw, 0) * Person::players[k]->scale + Person::players[k]->coords;
346 opacity = .4 - Person::players[k]->skeleton.joints[i].position.y * Person::players[k]->scale / 5 - (Person::players[k]->coords.y - terrain.getHeight(Person::players[k]->coords.x, Person::players[k]->coords.z)) / 5;
347 if (k != 0 && tutoriallevel == 1) {
348 opacity = .2 + .2 * sin(smoketex * 6 + i) - Person::players[k]->skeleton.joints[i].position.y * Person::players[k]->scale / 5 - (Person::players[k]->coords.y - terrain.getHeight(Person::players[k]->coords.x, Person::players[k]->coords.z)) / 10;
350 terrain.MakeDecal(shadowdecal, point, size, opacity * .7, rotation);
351 for (l = 0; l < terrain.patchobjectnum[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz]; l++) {
352 int j = terrain.patchobjects[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz][l];
353 if (objects.position[j].y < Person::players[k]->coords.y || objects.type[j] == tunneltype || objects.type[j] == weirdtype) {
354 if (Person::players[k]->skeleton.free)
355 point = DoRotation(Person::players[k]->skeleton.joints[i].position * Person::players[k]->scale + Person::players[k]->coords - objects.position[j], 0, -objects.yaw[j], 0);
357 point = DoRotation(DoRotation(Person::players[k]->skeleton.joints[i].position, 0, Person::players[k]->yaw, 0) * Person::players[k]->scale + Person::players[k]->coords - objects.position[j], 0, -objects.yaw[j], 0);
360 if (k != 0 && tutoriallevel == 1) {
361 opacity = .2 + .2 * sin(smoketex * 6 + i);
363 objects.model[j].MakeDecal(shadowdecal, &point, &size, &opacity, &rotation);
369 if (!Person::players[k]->playerdetail)
370 if (frustum.SphereInFrustum(Person::players[k]->coords.x, Person::players[k]->coords.y, Person::players[k]->coords.z, Person::players[k]->scale * 5)) {
371 point = Person::players[k]->coords;
373 opacity = .4 - (Person::players[k]->coords.y - terrain.getHeight(Person::players[k]->coords.x, Person::players[k]->coords.z)) / 5;
374 terrain.MakeDecal(shadowdecal, point, size, opacity * .7, rotation);
375 for (l = 0; l < terrain.patchobjectnum[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz]; l++) {
376 int j = terrain.patchobjects[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz][l];
377 point = DoRotation(Person::players[k]->coords - objects.position[j], 0, -objects.yaw[j], 0);
380 objects.model[j].MakeDecal(shadowdecal, &point, &size, &opacity, &rotation);
386 glEnable(GL_TEXTURE_2D);
388 glEnable(GL_DEPTH_TEST);
389 glEnable(GL_CULL_FACE);
391 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
392 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
393 terraintexture.bind();
395 terraintexture2.bind();
398 terrain.drawdecals();
401 glEnable(GL_CULL_FACE);
402 glEnable(GL_LIGHTING);
404 glEnable(GL_TEXTURE_2D);
407 glEnable(GL_COLOR_MATERIAL);
410 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
411 glEnable(GL_CULL_FACE);
412 glCullFace(GL_FRONT);
414 for (unsigned k = 0; k < Person::players.size(); k++) {
415 if (k == 0 || tutoriallevel != 1) {
417 glEnable(GL_LIGHTING);
418 terrainlight = terrain.getLighting(Person::players[k]->coords.x, Person::players[k]->coords.z);
419 distance = distsq(&viewer, &Person::players[k]->coords);
420 distance = (viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance;
421 glColor4f(terrainlight.x, terrainlight.y, terrainlight.z, distance);
424 if (distance >= .5) {
425 checkpoint = DoRotation(Person::players[k]->skeleton.joints[abs(Random() % Person::players[k]->skeleton.num_joints)].position, 0, Person::players[k]->yaw, 0) * Person::players[k]->scale + Person::players[k]->coords;
428 if (Person::players[k]->occluded != 0)
429 i = checkcollide(viewer, checkpoint, Person::players[k]->lastoccluded);
431 i = checkcollide(viewer, checkpoint);
433 Person::players[k]->occluded += 1;
434 Person::players[k]->lastoccluded = i;
436 Person::players[k]->occluded = 0;
438 if (Person::players[k]->occluded < 25)
439 Person::players[k]->DrawSkeleton();
445 if (!cameramode && musictype == stream_fighttheme)
446 playerdist = distsqflat(&Person::players[0]->coords, &viewer);
451 glEnable(GL_TEXTURE_2D);
457 if (frustum.SphereInFrustum(realhawkcoords.x + hawk.boundingspherecenter.x, realhawkcoords.y + hawk.boundingspherecenter.y, realhawkcoords.z + hawk.boundingspherecenter.z, 2)) {
458 glAlphaFunc(GL_GREATER, 0.0001f);
460 glDisable(GL_CULL_FACE);
461 glDisable(GL_LIGHTING);
463 glTranslatef(hawkcoords.x, hawkcoords.y, hawkcoords.z);
464 glRotatef(hawkyaw, 0, 1, 0);
465 glTranslatef(25, 0, 0);
466 distance = distsq(&viewer, &realhawkcoords) * 1.2;
467 glColor4f(light.color[0], light.color[1], light.color[2], (viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance);
468 if ((viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance > 1)
469 glColor4f(light.color[0], light.color[1], light.color[2], 1);
470 if ((viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance > 0)
471 hawk.drawdifftex(hawktexture);
475 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
476 glEnable(GL_CULL_FACE);
477 glCullFace(GL_FRONT);
479 for (unsigned k = 0; k < Person::players.size(); k++) {
480 if (!(k == 0 || tutoriallevel != 1)) {
482 glEnable(GL_LIGHTING);
483 terrainlight = terrain.getLighting(Person::players[k]->coords.x, Person::players[k]->coords.z);
484 distance = distsq(&viewer, &Person::players[k]->coords);
485 distance = (viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance;
486 glColor4f(terrainlight.x, terrainlight.y, terrainlight.z, distance);
489 if (distance >= .5) {
490 checkpoint = DoRotation(Person::players[k]->skeleton.joints[abs(Random() % Person::players[k]->skeleton.num_joints)].position, 0, Person::players[k]->yaw, 0) * Person::players[k]->scale + Person::players[k]->coords;
493 if (Person::players[k]->occluded != 0)
494 i = checkcollide(viewer, checkpoint, Person::players[k]->lastoccluded);
496 i = checkcollide(viewer, checkpoint);
498 Person::players[k]->occluded += 1;
499 Person::players[k]->lastoccluded = i;
501 Person::players[k]->occluded = 0;
503 if (Person::players[k]->occluded < 25)
504 Person::players[k]->DrawSkeleton();
510 glEnable(GL_TEXTURE_2D);
515 glDisable(GL_COLOR_MATERIAL);
517 glDisable(GL_LIGHTING);
518 glDisable(GL_TEXTURE_2D);
524 //waypoints, pathpoints in editor
527 glDisable(GL_LIGHTING);
528 glDisable(GL_TEXTURE_2D);
529 glDisable(GL_COLOR_MATERIAL);
530 glColor4f(1, 1, 0, 1);
532 for (unsigned k = 0; k < Person::players.size(); k++) {
533 if (Person::players[k]->numwaypoints > 1) {
534 glBegin(GL_LINE_LOOP);
535 for (int i = 0; i < Person::players[k]->numwaypoints; i++) {
536 glVertex3f(Person::players[k]->waypoints[i].x, Person::players[k]->waypoints[i].y + .5, Person::players[k]->waypoints[i].z);
543 if (numpathpoints > 1) {
544 glColor4f(0, 1, 0, 1);
545 for (unsigned k = 0; int(k) < numpathpoints; k++) {
546 if (numpathpointconnect[k]) {
547 for (int i = 0; i < numpathpointconnect[k]; i++) {
548 glBegin(GL_LINE_LOOP);
549 glVertex3f(pathpoint[k].x, pathpoint[k].y + .5, pathpoint[k].z);
550 glVertex3f(pathpoint[pathpointconnect[k][i]].x, pathpoint[pathpointconnect[k][i]].y + .5, pathpoint[pathpointconnect[k][i]].z);
555 glColor4f(1, 1, 1, 1);
558 glVertex3f(pathpoint[pathpointselected].x, pathpoint[pathpointselected].y + .5, pathpoint[pathpointselected].z);
565 glEnable(GL_TEXTURE_2D);
566 glColor4f(.5, .5, .5, 1);
569 if (bonus > 0 && bonustime < 1 && !winfreeze && !Dialog::inDialog()) {
570 const char *bonus_name;
571 if (bonus < bonus_count)
572 bonus_name = bonus_names[bonus];
574 bonus_name = "Excellent!"; // When does this happen?
576 glColor4f(0, 0, 0, 1 - bonustime);
577 text->glPrintOutline(1024 / 2 - 10 * strlen(bonus_name) - 4, 768 / 16 - 4 + 768 * 4 / 5, bonus_name, 1, 2.5, 1024, 768);
578 glColor4f(1, 0, 0, 1 - bonustime);
579 text->glPrint(1024 / 2 - 10 * strlen(bonus_name), 768 / 16 + 768 * 4 / 5, bonus_name, 1, 2, 1024, 768);
581 sprintf (string, "%d", (int)bonusvalue);
582 glColor4f(0, 0, 0, 1 - bonustime);
583 text->glPrintOutline(1024 / 2 - 10 * strlen(string) - 4, 768 / 16 - 4 - 20 + 768 * 4 / 5, string, 1, 2.5 * .8, 1024, 768);
584 glColor4f(1, 0, 0, 1 - bonustime);
585 text->glPrint(1024 / 2 - 10 * strlen(string), 768 / 16 - 20 + 768 * 4 / 5, string, 1, 2 * .8, 1024, 768);
586 glColor4f(.5, .5, .5, 1);
589 if (tutoriallevel == 1) {
590 tutorialopac = tutorialmaxtime - tutorialstagetime;
591 if (tutorialopac > 1)
593 if (tutorialopac < 0)
596 sprintf (string, " ");
597 sprintf (string2, " ");
598 sprintf (string3, " ");
599 if (tutorialstage == 0) {
600 sprintf (string, " ");
601 sprintf (string2, " ");
602 sprintf (string3, " ");
604 if (tutorialstage == 1) {
605 sprintf (string, "Welcome to the Lugaru training level!");
606 sprintf (string2, " ");
607 sprintf (string3, " ");
609 if (tutorialstage == 2) {
610 sprintf (string, "BASIC MOVEMENT:");
611 sprintf (string2, " ");
612 sprintf (string3, " ");
614 if (tutorialstage == 3) {
615 sprintf (string, "You can move the mouse to rotate the camera.");
616 sprintf (string2, " ");
617 sprintf (string3, " ");
619 if (tutorialstage == 4) {
620 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));
621 sprintf (string2, "All movement is relative to the camera.");
622 sprintf (string3, " ");
624 if (tutorialstage == 5) {
625 sprintf (string, "Please press %s to jump.", Input::keyToChar(jumpkey));
626 sprintf (string2, "You can hold it longer to jump higher.");
627 sprintf (string3, " ");
629 if (tutorialstage == 6) {
630 sprintf (string, "You can press %s to crouch.", Input::keyToChar(crouchkey));
631 sprintf (string2, "You can jump higher from a crouching position.");
632 sprintf (string3, " ");
634 if (tutorialstage == 7) {
635 sprintf (string, "While running, you can press %s to roll.", Input::keyToChar(crouchkey));
636 sprintf (string2, " ");
637 sprintf (string3, " ");
639 if (tutorialstage == 8) {
640 sprintf (string, "While crouching, you can sneak around silently");
641 sprintf (string2, "using the movement keys.");
642 sprintf (string3, " ");
644 if (tutorialstage == 9) {
645 sprintf (string, "Release the crouch key while sneaking and hold the movement keys");
646 sprintf (string2, "to run animal-style.");
647 sprintf (string3, " ");
649 if (tutorialstage == 10) {
650 sprintf (string, "ADVANCED MOVEMENT:");
651 sprintf (string2, " ");
652 sprintf (string3, " ");
654 if (tutorialstage == 11) {
655 sprintf (string, "When you jump at a wall, you can hold %s again", Input::keyToChar(jumpkey));
656 sprintf (string2, "during impact to perform a walljump.");
657 sprintf (string3, "Be sure to use the movement keys to press against the wall");
659 if (tutorialstage == 12) {
660 sprintf (string, "While in the air, you can press crouch to flip.");
661 sprintf (string2, "Walljumps and flips confuse enemies and give you more control.");
662 sprintf (string3, " ");
664 if (tutorialstage == 13) {
665 sprintf (string, "BASIC COMBAT:");
666 sprintf (string2, " ");
667 sprintf (string3, " ");
669 if (tutorialstage == 14) {
670 sprintf (string, "There is now an imaginary enemy");
671 sprintf (string2, "in the middle of the training area.");
672 sprintf (string3, " ");
674 if (tutorialstage == 15) {
675 if (attackkey == MOUSEBUTTON1)
676 sprintf (string, "Click to attack when you are near an enemy.");
678 sprintf (string, "Press %s to attack when you are near an enemy.", Input::keyToChar(attackkey));
679 sprintf (string2, "You can punch by standing still near an enemy and attacking.");
680 sprintf (string3, " ");
682 if (tutorialstage == 16) {
683 sprintf (string, "If you are close, you will perform a weak punch.");
684 sprintf (string2, "The weak punch is excellent for starting attack combinations.");
685 sprintf (string3, " ");
687 if (tutorialstage == 17) {
688 sprintf (string, "Attacking while running results in a spin kick.");
689 sprintf (string2, "This is one of your most powerful ground attacks.");
690 sprintf (string3, " ");
692 if (tutorialstage == 18) {
693 sprintf (string, "Sweep the enemy's legs out by attacking while crouched.");
694 sprintf (string2, "This is a very fast attack, and easy to follow up.");
695 sprintf (string3, " ");
697 if (tutorialstage == 19) {
698 sprintf (string, "When an enemy is on the ground, you can deal some extra");
699 sprintf (string2, "damage by running up and drop-kicking him.");
700 sprintf (string3, "(Try knocking them down with a sweep first)");
702 if (tutorialstage == 20) {
703 sprintf (string, "Your most powerful individual attack is the rabbit kick.");
704 if (attackkey == MOUSEBUTTON1)
705 sprintf (string2, "Run at the enemy while holding the mouse button, and press");
707 sprintf (string2, "Run at the enemy while holding %s, and press", Input::keyToChar(attackkey));
708 sprintf (string3, "the jump key (%s) to attack.", Input::keyToChar(jumpkey));
710 if (tutorialstage == 21) {
711 sprintf (string, "This attack is devastating if timed correctly.");
712 sprintf (string2, "Even if timed incorrectly, it will knock the enemy over.");
714 sprintf (string3, "Try rabbit-kicking the imaginary enemy again.");
716 sprintf (string3, "Try rabbit-kicking the imaginary enemy.");
718 if (tutorialstage == 22) {
719 sprintf (string, "If you sneak behind an enemy unnoticed, you can kill");
720 sprintf (string2, "him instantly. Move close behind this enemy");
721 sprintf (string3, "and attack.");
723 if (tutorialstage == 23) {
724 sprintf (string, "Another important attack is the wall kick. When an enemy");
725 sprintf (string2, "is near a wall, perform a walljump nearby and hold");
726 sprintf (string3, "the attack key during impact with the wall.");
728 if (tutorialstage == 24) {
729 sprintf (string, "You can tackle enemies by running at them animal-style");
730 if (attackkey == MOUSEBUTTON1)
731 sprintf (string2, "and pressing jump (%s) or attack(mouse button).", Input::keyToChar(jumpkey));
733 sprintf (string2, "and pressing jump (%s) or attack(%s).", Input::keyToChar(jumpkey), Input::keyToChar(attackkey));
734 sprintf (string3, "This is especially useful when they are running away.");
736 if (tutorialstage == 25) {
737 sprintf (string, "Dodge by pressing back and attack. Dodging is essential");
738 sprintf (string2, "against enemies with swords or other long weapons.");
739 sprintf (string3, " ");
741 if (tutorialstage == 26) {
742 sprintf (string, "REVERSALS AND COUNTER-REVERSALS");
743 sprintf (string2, " ");
744 sprintf (string3, " ");
746 if (tutorialstage == 27) {
747 sprintf (string, "The enemy can now reverse your attacks.");
748 sprintf (string2, " ");
749 sprintf (string3, " ");
751 if (tutorialstage == 28) {
752 sprintf (string, "If you attack, you will notice that the enemy now sometimes");
753 sprintf (string2, "catches your attack and uses it against you. Hold");
754 sprintf (string3, "crouch (%s) after attacking to escape from reversals.", Input::keyToChar(crouchkey));
756 if (tutorialstage == 29) {
757 sprintf (string, "Try escaping from two more reversals in a row.");
758 sprintf (string2, " ");
759 sprintf (string3, " ");
761 if (tutorialstage == 30) {
762 sprintf (string, "Good!");
763 sprintf (string2, " ");
764 sprintf (string3, " ");
766 if (tutorialstage == 31) {
767 sprintf (string, "To reverse an attack, you must tap crouch (%s) during the", Input::keyToChar(crouchkey));
768 sprintf (string2, "enemy's attack. You must also be close to the enemy;");
769 sprintf (string3, "this is especially important against armed opponents.");
771 if (tutorialstage == 32) {
772 sprintf (string, "The enemy can attack in %d seconds.", (int)(tutorialmaxtime - tutorialstagetime));
773 sprintf (string2, "This imaginary opponents attacks will be highlighted");
774 sprintf (string3, "to make this easier.");
776 if (tutorialstage == 33) {
777 sprintf (string, "Reverse three enemy attacks!");
778 sprintf (string2, " ");
779 sprintf (string3, " ");
781 if (tutorialstage == 34) {
782 sprintf (string, "Reverse two more enemy attacks!");
783 sprintf (string2, " ");
784 sprintf (string3, " ");
786 if (tutorialstage == 35) {
787 sprintf (string, "Reverse one more enemy attack!");
788 sprintf (string2, " ");
789 sprintf (string3, " ");
791 if (tutorialstage == 36) {
792 sprintf (string, "Excellent!");
793 sprintf (string2, " ");
794 sprintf (string3, " ");
796 if (tutorialstage == 37) {
797 sprintf (string, "Now spar with the enemy for %d more seconds.", (int)(tutorialmaxtime - tutorialstagetime));
798 sprintf (string2, "Damage dealt: %d", (int)damagedealt);
799 sprintf (string3, "Damage taken: %d.", (int)damagetaken);
801 if (tutorialstage == 38) {
802 sprintf (string, "WEAPONS:");
803 sprintf (string2, " ");
804 sprintf (string3, " ");
806 if (tutorialstage == 39) {
807 sprintf (string, "There is now an imaginary knife");
808 sprintf (string2, "in the center of the training area.");
809 sprintf (string3, " ");
811 if (tutorialstage == 40) {
812 sprintf (string, "Stand, roll or handspring over the knife");
813 sprintf (string2, "while pressing %s to pick it up.", Input::keyToChar(throwkey));
814 sprintf (string3, "You can crouch and press the same key to drop it again.");
816 if (tutorialstage == 41) {
817 sprintf (string, "You can equip and unequip weapons using the %s key.", Input::keyToChar(drawkey));
818 sprintf (string2, "Sometimes it is best to keep them unequipped to");
819 sprintf (string3, "prevent enemies from taking them. ");
821 if (tutorialstage == 42) {
822 sprintf (string, "The knife is the smallest weapon and the least encumbering.");
823 sprintf (string2, "You can equip or unequip it while standing, crouching,");
824 sprintf (string3, "running or flipping.");
826 if (tutorialstage == 43) {
827 sprintf (string, "You perform weapon attacks the same way as unarmed attacks,");
828 sprintf (string2, "but sharp weapons cause permanent damage, instead of the");
829 sprintf (string3, "temporary trauma from blunt weapons, fists and feet.");
831 if (tutorialstage == 44) {
832 sprintf (string, "The enemy now has your knife!");
833 sprintf (string2, "Please reverse two of his knife attacks.");
834 sprintf (string3, " ");
836 if (tutorialstage == 45) {
837 sprintf (string, "Please reverse one more of his knife attacks.");
838 sprintf (string2, " ");
839 sprintf (string3, " ");
841 if (tutorialstage == 46) {
842 sprintf (string, "Now he has a sword!");
843 sprintf (string2, "The sword has longer reach than your arms, so you");
844 sprintf (string3, "must move close to reverse the sword slash.");
846 if (tutorialstage == 47) {
847 sprintf (string, "Long weapons like the sword and staff are also useful for defense;");
848 sprintf (string2, "you can parry enemy weapon attacks by pressing the attack key");
849 sprintf (string3, "at the right time. Please try parrying the enemy's attacks!");
851 if (tutorialstage == 48) {
852 sprintf (string, "The staff is like the sword, but has two main attacks.");
853 sprintf (string2, "The standing smash is fast and effective, and the running");
854 sprintf (string3, "spin smash is slower and more powerful.");
856 if (tutorialstage == 49) {
857 sprintf (string, "When facing an enemy, you can throw the knife with %s.", Input::keyToChar(throwkey));
858 sprintf (string2, "It is possible to throw the knife while flipping,");
859 sprintf (string3, "but it is very inaccurate.");
861 if (tutorialstage == 50) {
862 sprintf (string, "You now know everything you can learn from training.");
863 sprintf (string2, "Everything else you must learn from experience!");
864 sprintf (string3, " ");
866 if (tutorialstage == 51) {
867 sprintf (string, "Walk out of the training area to return to the main menu.");
868 sprintf (string2, " ");
869 sprintf (string3, " ");
872 glColor4f(0, 0, 0, tutorialopac);
873 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);
874 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);
875 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);
876 glColor4f(1, 1, 1, tutorialopac);
877 text->glPrint(screenwidth / 2 - 7.6 * strlen(string)*screenwidth / 1024, screenheight / 16 + screenheight * 4 / 5, string, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight);
878 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);
879 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);
881 sprintf (string, "Press 'tab' to skip to the next item.");
882 sprintf (string2, "Press escape at any time to");
883 sprintf (string3, "pause or exit the tutorial.");
885 glColor4f(0, 0, 0, 1);
886 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);
887 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);
888 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);
889 glColor4f(0.5, 0.5, 0.5, 1);
890 text->glPrint(screenwidth / 2 - 7.6 * strlen(string)*screenwidth / 1024 * .8, 0 + screenheight * 1 / 10, string, 1, 1.5 * screenwidth / 1024 * .8, screenwidth, screenheight);
891 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);
892 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);
896 if (numhotspots && (bonustime >= 1 || bonus <= 0 || bonustime < 0) && !tutoriallevel) {
897 float closestdist = -1;
899 int closest = currenthotspot;
900 for (int i = 0; i < numhotspots; i++) {
901 distance = distsq(&Person::players[0]->coords, &hotspot[i]);
902 if (closestdist == -1 || distance < closestdist) {
903 if (distsq(&Person::players[0]->coords, &hotspot[i]) < hotspotsize[i] && ((hotspottype[i] <= 10 && hotspottype[i] >= 0) || (hotspottype[i] <= 40 && hotspottype[i] >= 20))) {
904 closestdist = distance;
910 currenthotspot = closest;
911 if (hotspottype[closest] <= 10) {
912 if (distsq(&Person::players[0]->coords, &hotspot[closest]) < hotspotsize[closest])
913 tutorialstagetime = 0;
915 tutorialopac = tutorialmaxtime - tutorialstagetime;
916 if (tutorialopac > 1)
918 if (tutorialopac < 0)
921 sprintf (string, "%s", hotspottext[closest]);
928 if (string[i] == '\n' || string[i] > 'z' || string[i] < ' ' || string[i] == '\0') {
929 glColor4f(0, 0, 0, tutorialopac);
930 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);
931 glColor4f(1, 1, 1, tutorialopac);
932 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);
935 if (string[i] == '\0')
942 } else if ((hotspottype[closest] >= 20) && (Dialog::dialogs[hotspottype[closest] - 20].gonethrough == 0)) {
943 Dialog::whichdialogue = hotspottype[closest] - 20;
944 Dialog::currentDialog().play();
945 Dialog::currentDialog().gonethrough++;
950 if (Dialog::inDialog() && !mainmenu) {
951 glDisable(GL_DEPTH_TEST);
952 glDisable(GL_CULL_FACE);
953 glDisable(GL_LIGHTING);
954 glDisable(GL_TEXTURE_2D);
956 glMatrixMode(GL_PROJECTION);
959 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
960 glMatrixMode(GL_MODELVIEW);
963 if (Dialog::currentScene().location == 1)
964 glTranslatef(0, screenheight * 3 / 4, 0);
965 glScalef(screenwidth, screenheight / 4, 1);
966 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
969 glColor4f(Dialog::currentScene().color[0], Dialog::currentScene().color[1], Dialog::currentScene().color[2], 0.7);
971 glVertex3f(0, 0, 0.0f);
972 glVertex3f(1, 0, 0.0f);
973 glVertex3f(1, 1, 0.0f);
974 glVertex3f(0, 1, 0.0f);
976 glMatrixMode(GL_PROJECTION);
978 glMatrixMode(GL_MODELVIEW);
980 glEnable(GL_DEPTH_TEST);
981 glEnable(GL_CULL_FACE);
984 glEnable(GL_TEXTURE_2D);
991 startx = screenwidth * 1 / 5;
992 if (Dialog::currentScene().location == 1)
993 starty = screenheight / 16 + screenheight * 4 / 5;
994 if (Dialog::currentScene().location == 2)
995 starty = screenheight * 1 / 5 - screenheight / 16;
999 for (int i = 0; i < 264; i++) {
1003 for (int i = 0; i < Dialog::currentScene().name.size(); i++) {
1004 tempname[tempnum] = Dialog::currentScene().name[i];
1005 if (tempname[tempnum] == '#' || tempname[tempnum] == '\0')
1006 tempname[tempnum] = '\0';
1011 sprintf (string, "%s: ", tempname);
1013 if (Dialog::currentScene().color[0] + Dialog::currentScene().color[1] + Dialog::currentScene().color[2] < 1.5) {
1014 glColor4f(0, 0, 0, tutorialopac);
1015 text->glPrintOutline(startx - 2 * 7.6 * strlen(string)*screenwidth / 1024 - 4, starty - 4, string, 1, 1.5 * 1.25 * screenwidth / 1024, screenwidth, screenheight);
1016 glColor4f(0.7, 0.7, 0.7, tutorialopac);
1017 text->glPrint(startx - 2 * 7.6 * strlen(string)*screenwidth / 1024, starty, string, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight);
1019 glColor4f(0, 0, 0, tutorialopac);
1020 text->glPrintOutline(startx - 2 * 7.6 * strlen(string)*screenwidth / 1024 - 4, starty - 4, string, 1, 1.5 * 1.25 * screenwidth / 1024, screenwidth, screenheight);
1024 for (int i = 0; i < Dialog::currentScene().text.size() + 1; i++) {
1025 tempname[tempnum] = Dialog::currentScene().text[i];
1026 if (Dialog::currentScene().text[i] != '#')
1030 sprintf (string, "%s", tempname);
1037 if (string[i] == '\n' || string[i] > 'z' || string[i] < ' ' || string[i] == '\0') {
1038 if (Dialog::currentScene().color[0] + Dialog::currentScene().color[1] + Dialog::currentScene().color[2] < 1.5) {
1039 glColor4f(0, 0, 0, tutorialopac);
1040 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);
1041 glColor4f(1, 1, 1, tutorialopac);
1042 text->glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/, starty - 20 * screenwidth / 1024 * line, string, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight, lastline, i);
1044 glColor4f(0, 0, 0, tutorialopac);
1045 text->glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/, starty - 20 * screenwidth / 1024 * line, string, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight, lastline, i);
1049 if (string[i] == '\0')
1058 if (!tutoriallevel && !winfreeze && !Dialog::inDialog() && !mainmenu) {
1061 sprintf (string, "Score: %d", (int)accountactive->getCampaignScore());
1063 sprintf (string, "Score: %d", (int)accountactive->getCampaignScore() + (int)bonustotal);
1066 sprintf (string, "Score: %d", (int)bonustotal);
1067 glColor4f(0, 0, 0, 1);
1068 text->glPrintOutline(1024 / 40 - 4, 768 / 16 - 4 + 768 * 14 / 16, string, 1, 1.5 * 1.25, 1024, 768);
1069 glColor4f(1, 0, 0, 1);
1070 text->glPrint(1024 / 40, 768 / 16 + 768 * 14 / 16, string, 1, 1.5, 1024, 768);
1071 if (showdamagebar) {
1072 glDisable(GL_DEPTH_TEST);
1073 glDisable(GL_CULL_FACE);
1074 glDisable(GL_LIGHTING);
1075 glDisable(GL_TEXTURE_2D);
1077 glMatrixMode(GL_PROJECTION);
1080 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1081 glMatrixMode(GL_MODELVIEW);
1084 glTranslatef(15, screenheight * 17.5 / 20, 0);
1085 glScalef(screenwidth / 3 + 20, screenheight / 20, 1);
1086 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1088 glColor4f(0.0, 0.4, 0.0, 0.7);
1089 float bar = ((float)Person::players[0]->damage) / Person::players[0]->damagetolerance;
1091 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
1092 glVertex3f(1, 0, 0.0f);
1093 glVertex3f(1, 1, 0.0f);
1094 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
1096 glColor4f(0.1, 0.0, 0.0, 1);
1097 bar = ((float)Person::players[0]->bloodloss) / Person::players[0]->damagetolerance;
1099 glVertex3f(0, 0, 0.0f);
1100 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
1101 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
1102 glVertex3f(0, 1, 0.0f);
1104 glColor4f(0.4, 0.0, 0.0, 0.7);
1105 bar = ((float)Person::players[0]->damage) / Person::players[0]->damagetolerance;
1107 glVertex3f(0, 0, 0.0f);
1108 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
1109 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
1110 glVertex3f(0, 1, 0.0f);
1112 glColor4f(0.4, 0.0, 0.0, 0.7);
1113 bar = ((float)Person::players[0]->permanentdamage) / Person::players[0]->damagetolerance;
1115 glVertex3f(0, 0, 0.0f);
1116 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
1117 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
1118 glVertex3f(0, 1, 0.0f);
1120 glColor4f(0.4, 0.0, 0.0, 0.7);
1121 bar = ((float)Person::players[0]->superpermanentdamage) / Person::players[0]->damagetolerance;
1123 glVertex3f(0, 0, 0.0f);
1124 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
1125 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
1126 glVertex3f(0, 1, 0.0f);
1128 glColor4f(0.0, 0.0, 0.0, 0.7);
1130 glBegin(GL_LINE_STRIP);
1131 glVertex3f(0, 0, 0.0f);
1132 glVertex3f(1, 0, 0.0f);
1133 glVertex3f(1, 1, 0.0f);
1134 glVertex3f(0, 1, 0.0f);
1135 glVertex3f(0, 0, 0.0f);
1138 glMatrixMode(GL_PROJECTION);
1140 glMatrixMode(GL_MODELVIEW);
1142 glEnable(GL_DEPTH_TEST);
1143 glEnable(GL_CULL_FACE);
1144 glDisable(GL_BLEND);
1146 glEnable(GL_TEXTURE_2D);
1148 // writing the numbers :
1149 sprintf (string, "Damages : %d/%d (%d)", (int)(Person::players[0]->damage), (int)(Person::players[0]->damagetolerance), (int)(Person::players[0]->bloodloss));
1150 glColor4f(0, 0, 0, 1);
1151 text->glPrintOutline(1024 / 40 - 4, 768 / 16 - 4 + 768 * 14 / 16 - 40, string, 1, 1.5 * 1.25, 1024, 768);
1152 glColor4f(1, 0, 0, 1);
1153 text->glPrint(1024 / 40, 768 / 16 + 768 * 14 / 16 - 40, string, 1, 1.5, 1024, 768);
1157 glColor4f(.5, .5, .5, 1);
1160 if ((texttoggle || editorenabled) && debugmode && !mainmenu) {
1161 sprintf (string, "The framespersecond is %d.", (int)(fps));
1162 text->glPrint(10, 30, string, 0, .8, 1024, 768);
1165 sprintf (string, "Map editor enabled.");
1167 sprintf (string, "Map editor disabled.");
1168 text->glPrint(10, 60, string, 0, .8, 1024, 768);
1169 if (editorenabled) {
1170 sprintf (string, "Object size: %f", editorsize);
1171 text->glPrint(10, 75, string, 0, .8, 1024, 768);
1173 sprintf (string, "Object yaw: %f", editoryaw);
1175 sprintf (string, "Object yaw: Random");
1176 text->glPrint(10, 90, string, 0, .8, 1024, 768);
1177 if (editorpitch >= 0)
1178 sprintf (string, "Object pitch: %f", editorpitch);
1180 sprintf (string, "Object pitch: Random");
1181 text->glPrint(10, 105, string, 0, .8, 1024, 768);
1182 sprintf (string, "Object type: %d", editortype);
1183 text->glPrint(10, 120, string, 0, .8, 1024, 768);
1184 switch (editortype) {
1186 sprintf (string, "(box)");
1189 sprintf (string, "(tree)");
1192 sprintf (string, "(wall)");
1195 sprintf (string, "(weird)");
1198 sprintf (string, "(spike)");
1201 sprintf (string, "(rock)");
1204 sprintf (string, "(bush)");
1207 sprintf (string, "(tunnel)");
1210 sprintf (string, "(chimney)");
1213 sprintf (string, "(platform)");
1216 sprintf (string, "(cool)");
1219 sprintf (string, "(fire)");
1222 text->glPrint(130, 120, string, 0, .8, 1024, 768);
1224 sprintf (string, "Numplayers: %lu", Person::players.size());
1225 text->glPrint(10, 155, string, 0, .8, 1024, 768);
1226 sprintf (string, "Player %d: numwaypoints: %d", (int(Person::players.size()) - 1), Person::players.back()->numwaypoints);
1227 text->glPrint(10, 140, string, 0, .8, 1024, 768);
1229 sprintf (string, "Difficulty: %d", difficulty);
1230 text->glPrint(10, 240, string, 0, .8, 1024, 768);
1235 if (drawmode == glowmode) {
1236 glDisable(GL_DEPTH_TEST);
1237 glDisable(GL_CULL_FACE);
1238 glDisable(GL_LIGHTING);
1239 glDisable(GL_TEXTURE_2D);
1241 glMatrixMode(GL_PROJECTION);
1244 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1245 glMatrixMode(GL_MODELVIEW);
1248 glScalef(screenwidth, screenheight, 1);
1249 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1251 glColor4f(0, 0, 0, .5);
1253 glVertex3f(0, 0, 0.0f);
1254 glVertex3f(256, 0, 0.0f);
1255 glVertex3f(256, 256, 0.0f);
1256 glVertex3f(0, 256, 0.0f);
1258 glMatrixMode(GL_PROJECTION);
1260 glMatrixMode(GL_MODELVIEW);
1262 glEnable(GL_DEPTH_TEST);
1263 glEnable(GL_CULL_FACE);
1264 glDisable(GL_BLEND);
1268 if ((((blackout && damageeffects) || (Person::players[0]->bloodloss > 0 && damageeffects && Person::players[0]->blooddimamount > 0) || Person::players[0]->dead) && !cameramode) || console) {
1269 glDisable(GL_DEPTH_TEST);
1270 glDisable(GL_CULL_FACE);
1271 glDisable(GL_LIGHTING);
1272 glDisable(GL_TEXTURE_2D);
1274 glMatrixMode(GL_PROJECTION);
1277 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1278 glMatrixMode(GL_MODELVIEW);
1281 glScalef(screenwidth, screenheight, 1);
1282 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1284 if (Person::players[0]->dead)
1285 blackout += multiplier * 3;
1286 if (Person::players[0]->dead == 1)
1288 if (Person::players[0]->dead == 2 && blackout > .6)
1290 glColor4f(0, 0, 0, blackout);
1291 if (!Person::players[0]->dead) {
1292 if ((Person::players[0]->bloodloss / Person::players[0]->damagetolerance * (sin(woozy) / 4 + .5))*.3 < .3) {
1293 glColor4f(0, 0, 0, Person::players[0]->blooddimamount * Person::players[0]->bloodloss / Person::players[0]->damagetolerance * (sin(woozy) / 4 + .5)*.3);
1294 blackout = Person::players[0]->blooddimamount * Person::players[0]->bloodloss / Person::players[0]->damagetolerance * (sin(woozy) / 4 + .5) * .3;
1296 glColor4f(0, 0, 0, Person::players[0]->blooddimamount * .3);
1297 blackout = Person::players[0]->blooddimamount * .3;
1301 glColor4f(.7, 0, 0, .2);
1303 glVertex3f(0, 0, 0.0f);
1304 glVertex3f(256, 0, 0.0f);
1305 glVertex3f(256, 256, 0.0f);
1306 glVertex3f(0, 256, 0.0f);
1308 glMatrixMode(GL_PROJECTION);
1310 glMatrixMode(GL_MODELVIEW);
1312 glEnable(GL_DEPTH_TEST);
1313 glEnable(GL_CULL_FACE);
1314 glDisable(GL_BLEND);
1318 if (flashamount > 0 && damageeffects) {
1319 if (flashamount > 1)
1321 if (flashdelay <= 0)
1322 flashamount -= multiplier;
1324 if (flashamount < 0)
1326 glDisable(GL_DEPTH_TEST);
1327 glDisable(GL_CULL_FACE);
1328 glDisable(GL_LIGHTING);
1330 glMatrixMode(GL_PROJECTION);
1333 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1334 glMatrixMode(GL_MODELVIEW);
1337 glScalef(screenwidth, screenheight, 1);
1338 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1340 glColor4f(flashr, flashg, flashb, flashamount);
1342 glVertex3f(0, 0, 0.0f);
1343 glVertex3f(256, 0, 0.0f);
1344 glVertex3f(256, 256, 0.0f);
1345 glVertex3f(0, 256, 0.0f);
1347 glMatrixMode(GL_PROJECTION);
1349 glMatrixMode(GL_MODELVIEW);
1351 glEnable(GL_DEPTH_TEST);
1352 glEnable(GL_CULL_FACE);
1353 glDisable(GL_BLEND);
1359 glEnable(GL_TEXTURE_2D);
1360 glColor4f(1, 1, 1, 1);
1361 for (unsigned i = 1; i < 15; i++)
1362 if (displaytime[i] < 4)
1363 for (unsigned j = 0; j < displaytext[i].size(); j++) {
1364 glColor4f(1, 1, 1, 4 - displaytime[i]);
1365 sprintf (string, "%c", displaytext[i][j]);
1366 text->glPrint(30 + j * 10, 30 + i * 20 + (screenheight - 330), string, 0, 1, screenwidth, screenheight);
1370 if (difficulty < 2 && !Dialog::inDialog()) { // minimap
1371 float mapviewdist = 20000;
1373 glDisable(GL_DEPTH_TEST);
1374 glColor3f (1.0, 1.0, 1.0); // no coloring
1376 glEnable(GL_TEXTURE_2D);
1377 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1378 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1379 glDisable(GL_DEPTH_TEST);
1380 glDisable(GL_CULL_FACE);
1381 glDisable(GL_LIGHTING);
1383 glMatrixMode(GL_PROJECTION);
1386 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1387 glMatrixMode(GL_MODELVIEW);
1390 glScalef((float)screenwidth / 2, (float)screenwidth / 2, 1);
1391 glTranslatef(1.75, .25, 0);
1392 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1394 glColor4f(1, 1, 1, 1);
1401 center = Person::players[0]->coords;
1405 glScalef(.25 / radius * 256 * terrain.scale * .4, .25 / radius * 256 * terrain.scale * .4, 1);
1407 glScalef(1 / (1 / radius * 256 * terrain.scale * .4), 1 / (1 / radius * 256 * terrain.scale * .4), 1);
1409 glRotatef(Person::players[0]->lookyaw * -1 + 180, 0, 0, 1);
1410 glTranslatef(-(center.x / terrain.scale / 256 * -2 + 1), (center.z / terrain.scale / 256 * -2 + 1), 0);
1411 for (int i = 0; i < objects.numobjects; i++) {
1412 if (objects.type[i] == treetrunktype) {
1413 distcheck = distsq(&Person::players[0]->coords, &objects.position[i]);
1414 if (distcheck < mapviewdist) {
1415 Mapcircletexture.bind();
1416 glColor4f(0, .3, 0, opac * (1 - distcheck / mapviewdist));
1418 glTranslatef(objects.position[i].x / terrain.scale / 256 * -2 + 1, objects.position[i].z / terrain.scale / 256 * 2 - 1, 0);
1419 glRotatef(objects.yaw[i], 0, 0, 1);
1420 glScalef(.003, .003, .003);
1423 glVertex3f(-1, -1, 0.0f);
1425 glVertex3f(1, -1, 0.0f);
1427 glVertex3f(1, 1, 0.0f);
1429 glVertex3f(-1, 1, 0.0f);
1434 if (objects.type[i] == boxtype) {
1435 distcheck = distsq(&Person::players[0]->coords, &objects.position[i]);
1436 if (distcheck < mapviewdist) {
1437 Mapboxtexture.bind();
1438 glColor4f(.4, .4, .4, opac * (1 - distcheck / mapviewdist));
1440 glTranslatef(objects.position[i].x / terrain.scale / 256 * -2 + 1, objects.position[i].z / terrain.scale / 256 * 2 - 1, 0);
1441 glRotatef(objects.yaw[i], 0, 0, 1);
1442 glScalef(.01 * objects.scale[i], .01 * objects.scale[i], .01 * objects.scale[i]);
1445 glVertex3f(-1, -1, 0.0f);
1447 glVertex3f(1, -1, 0.0f);
1449 glVertex3f(1, 1, 0.0f);
1451 glVertex3f(-1, 1, 0.0f);
1457 if (editorenabled) {
1458 Mapcircletexture.bind();
1459 for (int i = 0; i < numboundaries; i++) {
1460 glColor4f(0, 0, 0, opac / 3);
1462 glTranslatef(boundary[i].x / terrain.scale / 256 * -2 + 1, boundary[i].z / terrain.scale / 256 * 2 - 1, 0);
1463 glScalef(.002, .002, .002);
1466 glVertex3f(-1, -1, 0.0f);
1468 glVertex3f(1, -1, 0.0f);
1470 glVertex3f(1, 1, 0.0f);
1472 glVertex3f(-1, 1, 0.0f);
1477 for (unsigned i = 0; i < Person::players.size(); i++) {
1478 distcheck = distsq(&Person::players[0]->coords, &Person::players[i]->coords);
1479 if (distcheck < mapviewdist) {
1481 Maparrowtexture.bind();
1483 glColor4f(1, 1, 1, opac);
1484 else if (Person::players[i]->dead == 2 || Person::players[i]->howactive > typesleeping)
1485 glColor4f(0, 0, 0, opac * (1 - distcheck / mapviewdist));
1486 else if (Person::players[i]->dead)
1487 glColor4f(.3, .3, .3, opac * (1 - distcheck / mapviewdist));
1488 else if (Person::players[i]->aitype == attacktypecutoff)
1489 glColor4f(1, 0, 0, opac * (1 - distcheck / mapviewdist));
1490 else if (Person::players[i]->aitype == passivetype)
1491 glColor4f(0, 1, 0, opac * (1 - distcheck / mapviewdist));
1493 glColor4f(1, 1, 0, 1);
1494 glTranslatef(Person::players[i]->coords.x / terrain.scale / 256 * -2 + 1, Person::players[i]->coords.z / terrain.scale / 256 * 2 - 1, 0);
1495 glRotatef(Person::players[i]->yaw + 180, 0, 0, 1);
1496 glScalef(.005, .005, .005);
1499 glVertex3f(-1, -1, 0.0f);
1501 glVertex3f(1, -1, 0.0f);
1503 glVertex3f(1, 1, 0.0f);
1505 glVertex3f(-1, 1, 0.0f);
1511 glDisable(GL_TEXTURE_2D);
1512 glMatrixMode(GL_PROJECTION);
1514 glMatrixMode(GL_MODELVIEW);
1516 glEnable(GL_DEPTH_TEST);
1517 glEnable(GL_CULL_FACE);
1518 glDisable(GL_BLEND);
1522 if (loading && !stealthloading && (!campaign || Person::players[0]->dead)) {
1523 glDisable(GL_DEPTH_TEST);
1524 glDisable(GL_CULL_FACE);
1525 glDisable(GL_LIGHTING);
1526 glDisable(GL_TEXTURE_2D);
1528 glMatrixMode(GL_PROJECTION);
1531 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1532 glMatrixMode(GL_MODELVIEW);
1535 glScalef(screenwidth, screenheight, 1);
1536 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1538 glColor4f(0, 0, 0, .7);
1540 glVertex3f(0, 0, 0.0f);
1541 glVertex3f(256, 0, 0.0f);
1542 glVertex3f(256, 256, 0.0f);
1543 glVertex3f(0, 256, 0.0f);
1545 glMatrixMode(GL_PROJECTION);
1547 glMatrixMode(GL_MODELVIEW);
1549 glEnable(GL_DEPTH_TEST);
1550 glEnable(GL_CULL_FACE);
1551 glDisable(GL_BLEND);
1555 glDisable(GL_DEPTH_TEST);
1556 glColor3f (1.0, 1.0, 1.0); // no coloring
1558 glEnable(GL_TEXTURE_2D);
1563 glEnable(GL_TEXTURE_2D);
1564 glColor4f(1, 1, 1, 1);
1565 sprintf (string, "Loading...");
1566 text->glPrint(1024 / 2 - 90, 768 / 2, string, 1, 2, 1024, 768);
1569 drawmode = normalmode;
1572 if (winfreeze && !campaign) {
1573 glDisable(GL_DEPTH_TEST);
1574 glDisable(GL_CULL_FACE);
1575 glDisable(GL_LIGHTING);
1576 glDisable(GL_TEXTURE_2D);
1578 glMatrixMode(GL_PROJECTION);
1581 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1582 glMatrixMode(GL_MODELVIEW);
1585 glScalef(screenwidth, screenheight, 1);
1586 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1588 glColor4f(0, 0, 0, .4);
1590 glVertex3f(0, 0, 0.0f);
1591 glVertex3f(256, 0, 0.0f);
1592 glVertex3f(256, 256, 0.0f);
1593 glVertex3f(0, 256, 0.0f);
1595 glMatrixMode(GL_PROJECTION);
1597 glMatrixMode(GL_MODELVIEW);
1599 glEnable(GL_DEPTH_TEST);
1600 glEnable(GL_CULL_FACE);
1601 glDisable(GL_BLEND);
1605 glDisable(GL_DEPTH_TEST);
1606 glColor3f (1.0, 1.0, 1.0); // no coloring
1608 glEnable(GL_TEXTURE_2D);
1610 //Win Screen Won Victory
1612 glEnable(GL_TEXTURE_2D);
1613 glColor4f(1, 1, 1, 1);
1614 sprintf (string, "Level Cleared!");
1615 text->glPrintOutlined(1024 / 2 - strlen(string) * 10, 768 * 7 / 8, string, 1, 2, 1024, 768);
1617 sprintf (string, "Score: %d", (int)(bonustotal - startbonustotal));
1618 text->glPrintOutlined(1024 / 30, 768 * 6 / 8, string, 1, 2, 1024, 768);
1621 sprintf (string, "Press Escape or Space to continue");
1623 sprintf (string, "Press Escape to return to menu or Space to continue");
1624 text->glPrintOutlined(640 / 2 - strlen(string) * 5, 480 * 1 / 16, string, 1, 1, 640, 480);
1628 for (int i = 0; i < 255; i++)
1630 sprintf (temp, "Time: %d:", (int)(((int)leveltime - (int)(leveltime) % 60) / 60));
1631 strcat(string, temp);
1632 if ((int)(leveltime) % 60 < 10)
1633 strcat(string, "0");
1634 sprintf (temp, "%d", (int)(leveltime) % 60);
1635 strcat(string, temp);
1636 text->glPrintOutlined(1024 / 30, 768 * 6 / 8 - 40, string, 1, 2, 1024, 768);
1639 int awards[award_count];
1640 int numawards = award_awards(awards);
1642 for (int i = 0; i < numawards && i < 6; i++)
1643 text->glPrintOutlined(1024 / 30, 768 * 6 / 8 - 90 - 40 * i, award_names[awards[i]], 1, 2, 1024, 768);
1646 if (drawmode != normalmode) {
1647 glEnable(GL_TEXTURE_2D);
1649 if (!drawtoggle || drawmode != realmotionblurmode || (drawtoggle == 2 || change == 1)) {
1650 if (screentexture) {
1652 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
1653 GLfloat subtractColor[4] = { 0.5, 0.5, 0.5, 0.0 };
1654 glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, subtractColor);
1655 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE);
1656 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_CONSTANT_EXT);
1657 glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 2.0f);
1659 glBindTexture( GL_TEXTURE_2D, screentexture);
1660 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1663 if ((drawtoggle || change == 1) && drawmode == realmotionblurmode) {
1664 if (screentexture2) {
1665 glBindTexture( GL_TEXTURE_2D, screentexture2);
1666 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1668 if (!screentexture2) {
1669 glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
1671 glGenTextures( 1, &screentexture2 );
1672 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
1674 glEnable(GL_TEXTURE_2D);
1675 glBindTexture( GL_TEXTURE_2D, screentexture2);
1676 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
1677 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
1679 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
1684 glClear(GL_DEPTH_BUFFER_BIT);
1685 Game::ReSizeGLScene(90, .1f);
1686 glViewport(0, 0, screenwidth, screenheight);
1688 if (drawmode != normalmode) {
1689 glDisable(GL_DEPTH_TEST);
1690 if (drawmode == motionblurmode) {
1691 glDrawBuffer(GL_FRONT);
1692 glReadBuffer(GL_BACK);
1694 glColor3f (1.0, 1.0, 1.0); // no coloring
1696 glEnable(GL_TEXTURE_2D);
1697 glBindTexture( GL_TEXTURE_2D, screentexture);
1698 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1699 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1700 glDisable(GL_DEPTH_TEST);
1701 glDisable(GL_CULL_FACE);
1702 glDisable(GL_LIGHTING);
1704 glMatrixMode(GL_PROJECTION);
1707 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1708 glMatrixMode(GL_MODELVIEW);
1711 glScalef((float)screenwidth / 2, (float)screenheight / 2, 1);
1712 glTranslatef(1, 1, 0);
1713 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1715 if (drawmode == motionblurmode) {
1716 if (motionbluramount < .2)
1717 motionbluramount = .2;
1718 glColor4f(1, 1, 1, motionbluramount);
1722 glVertex3f(-1, -1, 0.0f);
1723 glTexCoord2f(texcoordwidth, 0);
1724 glVertex3f(1, -1, 0.0f);
1725 glTexCoord2f(texcoordwidth, texcoordheight);
1726 glVertex3f(1, 1, 0.0f);
1727 glTexCoord2f(0, texcoordheight);
1728 glVertex3f(-1, 1, 0.0f);
1732 if (drawmode == realmotionblurmode) {
1733 glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
1734 glClear(GL_COLOR_BUFFER_BIT);
1735 glBlendFunc(GL_SRC_ALPHA, GL_ONE);
1736 glBindTexture( GL_TEXTURE_2D, screentexture);
1737 glColor4f(1, 1, 1, .5);
1741 glVertex3f(-1, -1, 0.0f);
1742 glTexCoord2f(texcoordwidth, 0);
1743 glVertex3f(1, -1, 0.0f);
1744 glTexCoord2f(texcoordwidth, texcoordheight);
1745 glVertex3f(1, 1, 0.0f);
1746 glTexCoord2f(0, texcoordheight);
1747 glVertex3f(-1, 1, 0.0f);
1750 glBindTexture( GL_TEXTURE_2D, screentexture2);
1751 glColor4f(1, 1, 1, .5);
1755 glVertex3f(-1, -1, 0.0f);
1756 glTexCoord2f(texcoordwidth, 0);
1757 glVertex3f(1, -1, 0.0f);
1758 glTexCoord2f(texcoordwidth, texcoordheight);
1759 glVertex3f(1, 1, 0.0f);
1760 glTexCoord2f(0, texcoordheight);
1761 glVertex3f(-1, 1, 0.0f);
1764 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1766 if (drawmode == doublevisionmode) {
1767 static float crosseyedness;
1768 crosseyedness = abs(Person::players[0]->damage - Person::players[0]->superpermanentdamage - (Person::players[0]->damagetolerance - Person::players[0]->superpermanentdamage) * 1 / 2) / 30;
1769 if (crosseyedness > 1)
1771 if (crosseyedness < 0)
1773 glColor4f(1, 1, 1, 1);
1774 glDisable(GL_BLEND);
1779 glVertex3f(-1, -1, 0.0f);
1780 glTexCoord2f(texcoordwidth, 0);
1781 glVertex3f(1, -1, 0.0f);
1782 glTexCoord2f(texcoordwidth, texcoordheight);
1783 glVertex3f(1, 1, 0.0f);
1784 glTexCoord2f(0, texcoordheight);
1785 glVertex3f(-1, 1, 0.0f);
1788 if (crosseyedness) {
1789 glColor4f(1, 1, 1, .5);
1792 glTranslatef(.015 * crosseyedness, 0, 0);
1796 glVertex3f(-1, -1, 0.0f);
1797 glTexCoord2f(texcoordwidth, 0);
1798 glVertex3f(1, -1, 0.0f);
1799 glTexCoord2f(texcoordwidth, texcoordheight);
1800 glVertex3f(1, 1, 0.0f);
1801 glTexCoord2f(0, texcoordheight);
1802 glVertex3f(-1, 1, 0.0f);
1807 if (drawmode == glowmode) {
1808 glColor4f(.5, .5, .5, .5);
1810 glBlendFunc(GL_SRC_ALPHA, GL_ONE);
1812 glTranslatef(.01, 0, 0);
1815 glVertex3f(-1, -1, 0.0f);
1816 glTexCoord2f(texcoordwidth, 0);
1817 glVertex3f(1, -1, 0.0f);
1818 glTexCoord2f(texcoordwidth, texcoordheight);
1819 glVertex3f(1, 1, 0.0f);
1820 glTexCoord2f(0, texcoordheight);
1821 glVertex3f(-1, 1, 0.0f);
1825 glTranslatef(-.01, 0, 0);
1828 glVertex3f(-1, -1, 0.0f);
1829 glTexCoord2f(texcoordwidth, 0);
1830 glVertex3f(1, -1, 0.0f);
1831 glTexCoord2f(texcoordwidth, texcoordheight);
1832 glVertex3f(1, 1, 0.0f);
1833 glTexCoord2f(0, texcoordheight);
1834 glVertex3f(-1, 1, 0.0f);
1838 glTranslatef(.0, .01, 0);
1841 glVertex3f(-1, -1, 0.0f);
1842 glTexCoord2f(texcoordwidth, 0);
1843 glVertex3f(1, -1, 0.0f);
1844 glTexCoord2f(texcoordwidth, texcoordheight);
1845 glVertex3f(1, 1, 0.0f);
1846 glTexCoord2f(0, texcoordheight);
1847 glVertex3f(-1, 1, 0.0f);
1851 glTranslatef(0, -.01, 0);
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 == radialzoommode) {
1865 for (int i = 0; i < 3; i++) {
1866 glColor4f(1, 1, 1, 1 / ((float)i + 1));
1868 glScalef(1 + (float)i * .01, 1 + (float)i * .01, 1);
1871 glVertex3f(-1, -1, 0.0f);
1872 glTexCoord2f(texcoordwidth, 0);
1873 glVertex3f(1, -1, 0.0f);
1874 glTexCoord2f(texcoordwidth, texcoordheight);
1875 glVertex3f(1, 1, 0.0f);
1876 glTexCoord2f(0, texcoordheight);
1877 glVertex3f(-1, 1, 0.0f);
1882 glDisable(GL_TEXTURE_2D);
1883 glMatrixMode(GL_PROJECTION);
1885 glMatrixMode(GL_MODELVIEW);
1887 glEnable(GL_DEPTH_TEST);
1888 glEnable(GL_CULL_FACE);
1889 glDisable(GL_BLEND);
1894 glEnable(GL_TEXTURE_2D);
1895 glColor4f(1, 1, 1, 1);
1897 if (consoleselected >= 60)
1898 offset = consoleselected - 60;
1899 sprintf (string, " ]");
1900 text->glPrint(10, 30, string, 0, 1, 1024, 768);
1902 sprintf (string, "_");
1903 text->glPrint(30 + (float)(consoleselected) * 10 - offset * 10, 30, string, 0, 1, 1024, 768);
1905 for (unsigned i = 0; i < 15; i++)
1906 for (unsigned j = 0; j < consoletext[i].size(); j++) {
1907 glColor4f(1, 1, 1, 1 - (float)(i) / 16);
1908 sprintf (string, "%c", consoletext[i][j]);
1909 text->glPrint(30 + j * 10 - offset * 10, 30 + i * 20, string, 0, 1, 1024, 768);
1914 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted)) {
1915 multiplier = tempmult;
1922 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted)) {
1923 tempmult = multiplier;
1927 if ( side == stereoRight || side == stereoCenter ) {
1928 if (drawmode != motionblurmode || mainmenu) {
1933 glDrawBuffer(GL_BACK);
1934 glReadBuffer(GL_BACK);
1938 if (drawtoggle == 2)
1941 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted)) {
1942 multiplier = tempmult;
1944 //Jordan fixed your warning!
1950 // !!! FIXME: hack: clamp framerate in menu so text input works correctly on fast systems.
1953 glDrawBuffer(GL_BACK);
1954 glReadBuffer(GL_BACK);
1955 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
1956 Game::ReSizeGLScene(90, .1f);
1958 //draw menu background
1959 glClear(GL_DEPTH_BUFFER_BIT);
1960 glEnable(GL_ALPHA_TEST);
1961 glAlphaFunc(GL_GREATER, 0.001f);
1962 glEnable(GL_TEXTURE_2D);
1963 glDisable(GL_DEPTH_TEST);
1964 glDisable(GL_CULL_FACE);
1965 glDisable(GL_LIGHTING);
1967 glMatrixMode(GL_PROJECTION);
1970 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1971 glMatrixMode(GL_MODELVIEW);
1974 glTranslatef(screenwidth / 2, screenheight / 2, 0);
1976 glScalef((float)screenwidth / 2, (float)screenheight / 2, 1);
1977 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1978 glDisable(GL_BLEND);
1979 glColor4f(0, 0, 0, 1.0);
1980 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
1981 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
1982 glDisable(GL_TEXTURE_2D);
1984 glVertex3f(-1, -1, 0);
1985 glVertex3f(+1, -1, 0);
1986 glVertex3f(+1, +1, 0);
1987 glVertex3f(-1, +1, 0);
1990 glColor4f(0.4, 0.4, 0.4, 1.0);
1991 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
1992 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
1993 glEnable(GL_TEXTURE_2D);
1994 Game::Mainmenuitems[4].bind();
1997 glVertex3f(-1, -1, 0);
1999 glVertex3f(+1, -1, 0);
2001 glVertex3f(+1, +1, 0);
2003 glVertex3f(-1, +1, 0);
2007 glMatrixMode(GL_PROJECTION);
2009 glMatrixMode(GL_MODELVIEW);
2013 glMatrixMode(GL_PROJECTION);
2016 glOrtho(0, 640, 0, 480, -100, 100);
2017 glMatrixMode(GL_MODELVIEW);
2020 glEnable(GL_TEXTURE_2D);
2025 glMatrixMode(GL_PROJECTION);
2027 glMatrixMode(GL_MODELVIEW);
2030 glMatrixMode(GL_PROJECTION);
2033 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
2034 glMatrixMode(GL_MODELVIEW);
2037 glTranslatef(screenwidth / 2, screenheight / 2, 0);
2039 glScalef((float)screenwidth / 2, (float)screenheight / 2, 1);
2040 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
2042 glEnable(GL_TEXTURE_2D);
2043 glColor4f(1, 1, 1, 1);
2044 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2045 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2047 if (!Game::waiting) { // hide the cursor while waiting for a key
2049 glTranslatef(Game::mousecoordh - screenwidth / 2, Game::mousecoordv * -1 + screenheight / 2, 0);
2050 glScalef((float)screenwidth / 64, (float)screenwidth / 64, 1);
2051 glTranslatef(1, -1, 0);
2052 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
2053 glColor4f(1, 1, 1, 1);
2054 Game::cursortexture.bind();
2058 glVertex3f(-1, -1, 0.0f);
2060 glVertex3f(1, -1, 0.0f);
2062 glVertex3f(1, 1, 0.0f);
2064 glVertex3f(-1, 1, 0.0f);
2070 glMatrixMode(GL_PROJECTION);
2075 if (flashamount > 0) {
2076 if (flashamount > 1)
2078 if (flashdelay <= 0)
2079 flashamount -= multiplier;
2081 if (flashamount < 0)
2083 glDisable(GL_DEPTH_TEST);
2084 glDisable(GL_CULL_FACE);
2085 glDisable(GL_LIGHTING);
2086 glDisable(GL_TEXTURE_2D);
2088 glMatrixMode(GL_PROJECTION);
2091 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
2092 glMatrixMode(GL_MODELVIEW);
2095 glScalef(screenwidth, screenheight, 1);
2096 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
2098 glColor4f(flashr, flashg, flashb, flashamount);
2100 glVertex3f(0, 0, 0.0f);
2101 glVertex3f(256, 0, 0.0f);
2102 glVertex3f(256, 256, 0.0f);
2103 glVertex3f(0, 256, 0.0f);
2105 glMatrixMode(GL_PROJECTION);
2107 glMatrixMode(GL_MODELVIEW);
2109 glEnable(GL_DEPTH_TEST);
2110 glEnable(GL_CULL_FACE);
2111 glDisable(GL_BLEND);