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/>.
23 #include "Audio/openal_wrapper.hpp"
24 #include "Level/Awards.hpp"
25 #include "Level/Dialog.hpp"
26 #include "Level/Hotspot.hpp"
27 #include "Menu/Menu.hpp"
28 #include "Utils/Input.hpp"
31 extern int environment;
32 extern float texscale;
34 extern Terrain terrain;
35 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;
45 extern float camerashake;
47 extern float slomodelay;
48 extern bool ismotionblur;
50 extern float blackout;
51 extern bool damageeffects;
53 extern bool texttoggle;
54 extern float blurness;
55 extern float targetblurness;
56 extern float playerdist;
57 extern bool cellophane;
59 extern float flashamount, flashr, flashg, flashb;
60 extern int flashdelay;
62 extern float motionbluramount;
64 extern bool alwaysblur;
65 extern bool velocityblur;
68 extern int bloodtoggle;
69 extern int difficulty;
71 extern float texdetail;
72 extern bool musictoggle;
73 extern int tutoriallevel;
74 extern float smoketex;
75 extern float tutorialstagetime;
76 extern float tutorialmaxtime;
77 extern int tutorialstage;
78 extern bool againbonus;
79 extern float damagedealt;
80 extern bool invertmouse;
83 extern bool winfreeze;
85 extern bool gamestart;
87 extern bool gamestarted;
89 extern bool showdamagebar;
94 int numboundaries = 0;
101 normalmode, motionblurmode, radialzoommode,
102 realmotionblurmode, doublevisionmode, glowmode,
105 void Game::flash(float amount, int delay) // shouldn't be that way, these should be attributes and Person class should not change rendering.
110 flashamount = amount;
116 /*********************> DrawGLScene() <*****/
117 int Game::DrawGLScene(StereoSide side)
119 static float texcoordwidth, texcoordheight;
120 static float texviewwidth, texviewheight;
122 static XYZ checkpoint;
123 static float tempmult;
125 static char string[256] = "";
126 static char string2[256] = "";
127 static char string3[256] = "";
128 static int drawmode = 0;
130 if ( stereomode == stereoAnaglyph ) {
133 glColorMask( 0.0, 1.0, 1.0, 1.0 );
136 glColorMask( 1.0, 0.0, 0.0, 1.0 );
142 glColorMask( 1.0, 1.0, 1.0, 1.0 );
144 if ( stereomode == stereoHorizontalInterlaced || stereomode == stereoVerticalInterlaced ) {
145 glStencilFunc(side == stereoLeft ? GL_NOTEQUAL : GL_EQUAL, 0x01, 0x01);
149 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted)) {
150 tempmult = multiplier;
156 numboundaries = mapradius * 2;
157 if (numboundaries > 360)
159 for (int i = 0; i < numboundaries; i++) {
162 boundary[i] = mapcenter + DoRotation(boundary[i] * mapradius, 0, i * (360 / ((float)(numboundaries))), 0);
171 int olddrawmode = drawmode;
172 if (ismotionblur && !loading) {
173 if ((findLengthfast(&Person::players[0]->velocity) > 200) && velocityblur && !cameramode) {
174 drawmode = motionblurmode;
175 motionbluramount = 200 / (findLengthfast(&Person::players[0]->velocity));
178 if (Person::players[0]->damage - Person::players[0]->superpermanentdamage > (Person::players[0]->damagetolerance - Person::players[0]->superpermanentdamage) * 1 / 2 && damageeffects && !cameramode) {
179 drawmode = doublevisionmode;
184 if (slomo && !loading) {
186 drawmode = motionblurmode;
187 motionbluramount = .2;
188 slomodelay -= multiplier;
194 if ((!changed && !slomo) || loading) {
195 drawmode = normalmode;
196 if (ismotionblur && (/*fps>100||*/alwaysblur)) {
197 if (olddrawmode != realmotionblurmode)
201 drawmode = realmotionblurmode;
202 } else if (olddrawmode == realmotionblurmode)
208 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted))
209 drawmode = normalmode;
210 if ((freeze || winfreeze) && ismotionblur && !mainmenu)
211 drawmode = radialzoommode;
213 if (winfreeze || mainmenu)
214 drawmode = normalmode;
217 drawtoggle = 1 - drawtoggle;
219 if (!texcoordwidth) {
220 texviewwidth = kTextureSize;
221 if (texviewwidth > screenwidth)
222 texviewwidth = screenwidth;
223 texviewheight = kTextureSize;
224 if (texviewheight > screenheight)
225 texviewheight = screenheight;
227 texcoordwidth = screenwidth / kTextureSize;
228 texcoordheight = screenheight / kTextureSize;
229 if (texcoordwidth > 1)
231 if (texcoordheight > 1)
235 glDrawBuffer(GL_BACK);
236 glReadBuffer(GL_BACK);
238 static XYZ terrainlight;
239 static float distance;
240 if (drawmode == normalmode)
241 Game::ReSizeGLScene(90, .1f);
242 if (drawmode != normalmode)
243 glViewport(0, 0, texviewwidth, texviewheight);
244 glDepthFunc(GL_LEQUAL);
246 glAlphaFunc(GL_GREATER, 0.0001f);
247 glEnable(GL_ALPHA_TEST);
248 glClearColor(0.25f, 0.25f, 0.25f, 1.0f);
249 glClear(GL_DEPTH_BUFFER_BIT);
251 glMatrixMode (GL_MODELVIEW);
252 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
255 // Move the camera for the current eye's point of view.
256 // Reverse the movement if we're reversing stereo
257 glTranslatef((stereoseparation / 2) * side * (stereoreverse ? -1 : 1), 0, 0);
260 if (!cameramode && !freeze && !winfreeze) {
262 glRotatef(float(Random() % 100) / 10 * camerashake/*+(woozy*woozy)/10*/, 0, 0, 1);
264 glRotatef(pitch + sin(woozy / 2) * (Person::players[0]->damage / Person::players[0]->damagetolerance) * 5, 1, 0, 0);
265 glRotatef(yaw + sin(woozy) * (Person::players[0]->damage / Person::players[0]->damagetolerance) * 5, 0, 1, 0);
267 if (cameramode || freeze || winfreeze) {
268 glRotatef(pitch, 1, 0, 0);
269 glRotatef(yaw, 0, 1, 0);
272 if (environment == desertenvironment) {
273 glRotatef((float)(abs(Random() % 100)) / 3000 - 1, 1, 0, 0);
274 glRotatef((float)(abs(Random() % 100)) / 3000 - 1, 0, 1, 0);
276 SetUpLight(&light, 0);
279 //heat blur effect in desert
280 if (abs(blurness - targetblurness) < multiplier * 10 || abs(blurness - targetblurness) > 2) {
281 blurness = targetblurness;
282 targetblurness = (float)(abs(Random() % 100)) / 40;
284 if (blurness < targetblurness)
285 blurness += multiplier * 5;
287 blurness -= multiplier * 5;
289 if (environment == desertenvironment && detail == 2)
290 glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, blurness + .4 );
291 if (environment == desertenvironment) {
292 glRotatef((float)(abs(Random() % 100)) / 1000, 1, 0, 0);
293 glRotatef((float)(abs(Random() % 100)) / 1000, 0, 1, 0);
296 glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0);
298 glTranslatef(-viewer.x, -viewer.y, -viewer.z);
299 frustum.GetFrustum();
301 //make shadow decals on terrain and objects
303 static float size, opacity, rotation;
305 for (unsigned k = 0; k < Person::players.size(); k++) {
306 if (!Person::players[k]->skeleton.free && Person::players[k]->playerdetail && Person::players[k]->howactive < typesleeping)
307 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)
308 for (unsigned i = 0; i < Person::players[k]->skeleton.joints.size(); i++) {
309 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) {
310 point = DoRotation(Person::players[k]->skeleton.joints[i].position, 0, Person::players[k]->yaw, 0) * Person::players[k]->scale + Person::players[k]->coords;
312 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;
313 if (k != 0 && tutoriallevel == 1) {
314 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;
316 terrain.MakeDecal(shadowdecal, point, size, opacity, rotation);
317 for (l = 0; l < terrain.patchobjectnum[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz]; l++) {
318 int j = terrain.patchobjects[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz][l];
319 if (objects.position[j].y < Person::players[k]->coords.y || objects.type[j] == tunneltype || objects.type[j] == weirdtype) {
320 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);
323 if (k != 0 && tutoriallevel == 1) {
324 opacity = .2 + .2 * sin(smoketex * 6 + i);
326 objects.model[j].MakeDecal(shadowdecal, &point, &size, &opacity, &rotation);
331 if ((Person::players[k]->skeleton.free || Person::players[k]->howactive >= typesleeping) && Person::players[k]->playerdetail)
332 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)
333 for (unsigned i = 0; i < Person::players[k]->skeleton.joints.size(); i++) {
334 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) {
335 if (Person::players[k]->skeleton.free)
336 point = Person::players[k]->skeleton.joints[i].position * Person::players[k]->scale + Person::players[k]->coords;
338 point = DoRotation(Person::players[k]->skeleton.joints[i].position, 0, Person::players[k]->yaw, 0) * Person::players[k]->scale + Person::players[k]->coords;
340 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;
341 if (k != 0 && tutoriallevel == 1) {
342 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;
344 terrain.MakeDecal(shadowdecal, point, size, opacity * .7, rotation);
345 for (l = 0; l < terrain.patchobjectnum[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz]; l++) {
346 int j = terrain.patchobjects[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz][l];
347 if (objects.position[j].y < Person::players[k]->coords.y || objects.type[j] == tunneltype || objects.type[j] == weirdtype) {
348 if (Person::players[k]->skeleton.free)
349 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);
351 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);
354 if (k != 0 && tutoriallevel == 1) {
355 opacity = .2 + .2 * sin(smoketex * 6 + i);
357 objects.model[j].MakeDecal(shadowdecal, &point, &size, &opacity, &rotation);
363 if (!Person::players[k]->playerdetail)
364 if (frustum.SphereInFrustum(Person::players[k]->coords.x, Person::players[k]->coords.y, Person::players[k]->coords.z, Person::players[k]->scale * 5)) {
365 point = Person::players[k]->coords;
367 opacity = .4 - (Person::players[k]->coords.y - terrain.getHeight(Person::players[k]->coords.x, Person::players[k]->coords.z)) / 5;
368 terrain.MakeDecal(shadowdecal, point, size, opacity * .7, rotation);
369 for (l = 0; l < terrain.patchobjectnum[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz]; l++) {
370 int j = terrain.patchobjects[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz][l];
371 point = DoRotation(Person::players[k]->coords - objects.position[j], 0, -objects.yaw[j], 0);
374 objects.model[j].MakeDecal(shadowdecal, &point, &size, &opacity, &rotation);
380 glEnable(GL_TEXTURE_2D);
382 glEnable(GL_DEPTH_TEST);
383 glEnable(GL_CULL_FACE);
385 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
386 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
387 terraintexture.bind();
389 terraintexture2.bind();
392 terrain.drawdecals();
395 glEnable(GL_CULL_FACE);
396 glEnable(GL_LIGHTING);
398 glEnable(GL_TEXTURE_2D);
401 glEnable(GL_COLOR_MATERIAL);
404 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
405 glEnable(GL_CULL_FACE);
406 glCullFace(GL_FRONT);
408 for (unsigned k = 0; k < Person::players.size(); k++) {
409 if (k == 0 || tutoriallevel != 1) {
411 glEnable(GL_LIGHTING);
412 terrainlight = terrain.getLighting(Person::players[k]->coords.x, Person::players[k]->coords.z);
413 distance = distsq(&viewer, &Person::players[k]->coords);
414 distance = (viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance;
415 glColor4f(terrainlight.x, terrainlight.y, terrainlight.z, distance);
418 if (distance >= .5) {
419 checkpoint = DoRotation(Person::players[k]->skeleton.joints[fabs(Random() % Person::players[k]->skeleton.joints.size())].position, 0, Person::players[k]->yaw, 0) * Person::players[k]->scale + Person::players[k]->coords;
422 if (Person::players[k]->occluded != 0)
423 i = checkcollide(viewer, checkpoint, Person::players[k]->lastoccluded);
425 i = checkcollide(viewer, checkpoint);
427 Person::players[k]->occluded += 1;
428 Person::players[k]->lastoccluded = i;
430 Person::players[k]->occluded = 0;
432 if (Person::players[k]->occluded < 25)
433 Person::players[k]->DrawSkeleton();
439 if (!cameramode && musictype == stream_fighttheme)
440 playerdist = distsqflat(&Person::players[0]->coords, &viewer);
445 glEnable(GL_TEXTURE_2D);
451 if (frustum.SphereInFrustum(realhawkcoords.x + hawk.boundingspherecenter.x, realhawkcoords.y + hawk.boundingspherecenter.y, realhawkcoords.z + hawk.boundingspherecenter.z, 2)) {
452 glAlphaFunc(GL_GREATER, 0.0001f);
454 glDisable(GL_CULL_FACE);
455 glDisable(GL_LIGHTING);
457 glTranslatef(hawkcoords.x, hawkcoords.y, hawkcoords.z);
458 glRotatef(hawkyaw, 0, 1, 0);
459 glTranslatef(25, 0, 0);
460 distance = distsq(&viewer, &realhawkcoords) * 1.2;
461 glColor4f(light.color[0], light.color[1], light.color[2], (viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance);
462 if ((viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance > 1)
463 glColor4f(light.color[0], light.color[1], light.color[2], 1);
464 if ((viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance > 0)
465 hawk.drawdifftex(hawktexture);
469 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
470 glEnable(GL_CULL_FACE);
471 glCullFace(GL_FRONT);
473 for (unsigned k = 0; k < Person::players.size(); k++) {
474 if (!(k == 0 || tutoriallevel != 1)) {
476 glEnable(GL_LIGHTING);
477 terrainlight = terrain.getLighting(Person::players[k]->coords.x, Person::players[k]->coords.z);
478 distance = distsq(&viewer, &Person::players[k]->coords);
479 distance = (viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance;
480 glColor4f(terrainlight.x, terrainlight.y, terrainlight.z, distance);
483 if (distance >= .5) {
484 checkpoint = DoRotation(Person::players[k]->skeleton.joints[fabs(Random() % Person::players[k]->skeleton.joints.size())].position, 0, Person::players[k]->yaw, 0) * Person::players[k]->scale + Person::players[k]->coords;
487 if (Person::players[k]->occluded != 0)
488 i = checkcollide(viewer, checkpoint, Person::players[k]->lastoccluded);
490 i = checkcollide(viewer, checkpoint);
492 Person::players[k]->occluded += 1;
493 Person::players[k]->lastoccluded = i;
495 Person::players[k]->occluded = 0;
497 if (Person::players[k]->occluded < 25)
498 Person::players[k]->DrawSkeleton();
504 glEnable(GL_TEXTURE_2D);
509 glDisable(GL_COLOR_MATERIAL);
511 glDisable(GL_LIGHTING);
512 glDisable(GL_TEXTURE_2D);
518 //waypoints, pathpoints in editor
521 glDisable(GL_LIGHTING);
522 glDisable(GL_TEXTURE_2D);
523 glDisable(GL_COLOR_MATERIAL);
524 glColor4f(1, 1, 0, 1);
526 for (unsigned k = 0; k < Person::players.size(); k++) {
527 if (Person::players[k]->numwaypoints > 1) {
528 glBegin(GL_LINE_LOOP);
529 for (int i = 0; i < Person::players[k]->numwaypoints; i++) {
530 glVertex3f(Person::players[k]->waypoints[i].x, Person::players[k]->waypoints[i].y + .5, Person::players[k]->waypoints[i].z);
537 if (numpathpoints > 1) {
538 glColor4f(0, 1, 0, 1);
539 for (unsigned k = 0; int(k) < numpathpoints; k++) {
540 if (numpathpointconnect[k]) {
541 for (int i = 0; i < numpathpointconnect[k]; i++) {
542 glBegin(GL_LINE_LOOP);
543 glVertex3f(pathpoint[k].x, pathpoint[k].y + .5, pathpoint[k].z);
544 glVertex3f(pathpoint[pathpointconnect[k][i]].x, pathpoint[pathpointconnect[k][i]].y + .5, pathpoint[pathpointconnect[k][i]].z);
549 glColor4f(1, 1, 1, 1);
552 glVertex3f(pathpoint[pathpointselected].x, pathpoint[pathpointselected].y + .5, pathpoint[pathpointselected].z);
559 glEnable(GL_TEXTURE_2D);
560 glColor4f(.5, .5, .5, 1);
563 if (bonus > 0 && bonustime < 1 && !winfreeze && !Dialog::inDialog()) {
564 const char *bonus_name;
565 if (bonus < bonus_count)
566 bonus_name = bonus_names[bonus];
568 bonus_name = "Excellent!"; // When does this happen?
570 glColor4f(0, 0, 0, 1 - bonustime);
571 text->glPrintOutline(1024 / 2 - 10 * strlen(bonus_name) - 4, 768 / 16 - 4 + 768 * 4 / 5, bonus_name, 1, 2.5, 1024, 768);
572 glColor4f(1, 0, 0, 1 - bonustime);
573 text->glPrint(1024 / 2 - 10 * strlen(bonus_name), 768 / 16 + 768 * 4 / 5, bonus_name, 1, 2, 1024, 768);
575 sprintf (string, "%d", (int)bonusvalue);
576 glColor4f(0, 0, 0, 1 - bonustime);
577 text->glPrintOutline(1024 / 2 - 10 * strlen(string) - 4, 768 / 16 - 4 - 20 + 768 * 4 / 5, string, 1, 2.5 * .8, 1024, 768);
578 glColor4f(1, 0, 0, 1 - bonustime);
579 text->glPrint(1024 / 2 - 10 * strlen(string), 768 / 16 - 20 + 768 * 4 / 5, string, 1, 2 * .8, 1024, 768);
580 glColor4f(.5, .5, .5, 1);
583 if (tutoriallevel == 1) {
584 tutorialopac = tutorialmaxtime - tutorialstagetime;
585 if (tutorialopac > 1)
587 if (tutorialopac < 0)
590 sprintf (string, " ");
591 sprintf (string2, " ");
592 sprintf (string3, " ");
593 if (tutorialstage == 0) {
594 sprintf (string, " ");
595 sprintf (string2, " ");
596 sprintf (string3, " ");
598 if (tutorialstage == 1) {
599 sprintf (string, "Welcome to the Lugaru training level!");
600 sprintf (string2, " ");
601 sprintf (string3, " ");
603 if (tutorialstage == 2) {
604 sprintf (string, "BASIC MOVEMENT:");
605 sprintf (string2, " ");
606 sprintf (string3, " ");
608 if (tutorialstage == 3) {
609 sprintf (string, "You can move the mouse to rotate the camera.");
610 sprintf (string2, " ");
611 sprintf (string3, " ");
613 if (tutorialstage == 4) {
614 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));
615 sprintf (string2, "All movement is relative to the camera.");
616 sprintf (string3, " ");
618 if (tutorialstage == 5) {
619 sprintf (string, "Please press %s to jump.", Input::keyToChar(jumpkey));
620 sprintf (string2, "You can hold it longer to jump higher.");
621 sprintf (string3, " ");
623 if (tutorialstage == 6) {
624 sprintf (string, "You can press %s to crouch.", Input::keyToChar(crouchkey));
625 sprintf (string2, "You can jump higher from a crouching position.");
626 sprintf (string3, " ");
628 if (tutorialstage == 7) {
629 sprintf (string, "While running, you can press %s to roll.", Input::keyToChar(crouchkey));
630 sprintf (string2, " ");
631 sprintf (string3, " ");
633 if (tutorialstage == 8) {
634 sprintf (string, "While crouching, you can sneak around silently");
635 sprintf (string2, "using the movement keys.");
636 sprintf (string3, " ");
638 if (tutorialstage == 9) {
639 sprintf (string, "Release the crouch key while sneaking and hold the movement keys");
640 sprintf (string2, "to run animal-style.");
641 sprintf (string3, " ");
643 if (tutorialstage == 10) {
644 sprintf (string, "ADVANCED MOVEMENT:");
645 sprintf (string2, " ");
646 sprintf (string3, " ");
648 if (tutorialstage == 11) {
649 sprintf (string, "When you jump at a wall, you can hold %s again", Input::keyToChar(jumpkey));
650 sprintf (string2, "during impact to perform a walljump.");
651 sprintf (string3, "Be sure to use the movement keys to press against the wall");
653 if (tutorialstage == 12) {
654 sprintf (string, "While in the air, you can press crouch to flip.");
655 sprintf (string2, "Walljumps and flips confuse enemies and give you more control.");
656 sprintf (string3, " ");
658 if (tutorialstage == 13) {
659 sprintf (string, "BASIC COMBAT:");
660 sprintf (string2, " ");
661 sprintf (string3, " ");
663 if (tutorialstage == 14) {
664 sprintf (string, "There is now an imaginary enemy");
665 sprintf (string2, "in the middle of the training area.");
666 sprintf (string3, " ");
668 if (tutorialstage == 15) {
669 if (attackkey == MOUSEBUTTON1)
670 sprintf (string, "Click to attack when you are near an enemy.");
672 sprintf (string, "Press %s to attack when you are near an enemy.", Input::keyToChar(attackkey));
673 sprintf (string2, "You can punch by standing still near an enemy and attacking.");
674 sprintf (string3, " ");
676 if (tutorialstage == 16) {
677 sprintf (string, "If you are close, you will perform a weak punch.");
678 sprintf (string2, "The weak punch is excellent for starting attack combinations.");
679 sprintf (string3, " ");
681 if (tutorialstage == 17) {
682 sprintf (string, "Attacking while running results in a spin kick.");
683 sprintf (string2, "This is one of your most powerful ground attacks.");
684 sprintf (string3, " ");
686 if (tutorialstage == 18) {
687 sprintf (string, "Sweep the enemy's legs out by attacking while crouched.");
688 sprintf (string2, "This is a very fast attack, and easy to follow up.");
689 sprintf (string3, " ");
691 if (tutorialstage == 19) {
692 sprintf (string, "When an enemy is on the ground, you can deal some extra");
693 sprintf (string2, "damage by running up and drop-kicking him.");
694 sprintf (string3, "(Try knocking them down with a sweep first)");
696 if (tutorialstage == 20) {
697 sprintf (string, "Your most powerful individual attack is the rabbit kick.");
698 if (attackkey == MOUSEBUTTON1)
699 sprintf (string2, "Run at the enemy while holding the mouse button, and press");
701 sprintf (string2, "Run at the enemy while holding %s, and press", Input::keyToChar(attackkey));
702 sprintf (string3, "the jump key (%s) to attack.", Input::keyToChar(jumpkey));
704 if (tutorialstage == 21) {
705 sprintf (string, "This attack is devastating if timed correctly.");
706 sprintf (string2, "Even if timed incorrectly, it will knock the enemy over.");
708 sprintf (string3, "Try rabbit-kicking the imaginary enemy again.");
710 sprintf (string3, "Try rabbit-kicking the imaginary enemy.");
712 if (tutorialstage == 22) {
713 sprintf (string, "If you sneak behind an enemy unnoticed, you can kill");
714 sprintf (string2, "him instantly. Move close behind this enemy");
715 sprintf (string3, "and attack.");
717 if (tutorialstage == 23) {
718 sprintf (string, "Another important attack is the wall kick. When an enemy");
719 sprintf (string2, "is near a wall, perform a walljump nearby and hold");
720 sprintf (string3, "the attack key during impact with the wall.");
722 if (tutorialstage == 24) {
723 sprintf (string, "You can tackle enemies by running at them animal-style");
724 if (attackkey == MOUSEBUTTON1)
725 sprintf (string2, "and pressing jump (%s) or attack(mouse button).", Input::keyToChar(jumpkey));
727 sprintf (string2, "and pressing jump (%s) or attack(%s).", Input::keyToChar(jumpkey), Input::keyToChar(attackkey));
728 sprintf (string3, "This is especially useful when they are running away.");
730 if (tutorialstage == 25) {
731 sprintf (string, "Dodge by pressing back and attack. Dodging is essential");
732 sprintf (string2, "against enemies with swords or other long weapons.");
733 sprintf (string3, " ");
735 if (tutorialstage == 26) {
736 sprintf (string, "REVERSALS AND COUNTER-REVERSALS");
737 sprintf (string2, " ");
738 sprintf (string3, " ");
740 if (tutorialstage == 27) {
741 sprintf (string, "The enemy can now reverse your attacks.");
742 sprintf (string2, " ");
743 sprintf (string3, " ");
745 if (tutorialstage == 28) {
746 sprintf (string, "If you attack, you will notice that the enemy now sometimes");
747 sprintf (string2, "catches your attack and uses it against you. Hold");
748 sprintf (string3, "crouch (%s) after attacking to escape from reversals.", Input::keyToChar(crouchkey));
750 if (tutorialstage == 29) {
751 sprintf (string, "Try escaping from two more reversals in a row.");
752 sprintf (string2, " ");
753 sprintf (string3, " ");
755 if (tutorialstage == 30) {
756 sprintf (string, "Good!");
757 sprintf (string2, " ");
758 sprintf (string3, " ");
760 if (tutorialstage == 31) {
761 sprintf (string, "To reverse an attack, you must tap crouch (%s) during the", Input::keyToChar(crouchkey));
762 sprintf (string2, "enemy's attack. You must also be close to the enemy;");
763 sprintf (string3, "this is especially important against armed opponents.");
765 if (tutorialstage == 32) {
766 sprintf (string, "The enemy can attack in %d seconds.", (int)(tutorialmaxtime - tutorialstagetime));
767 sprintf (string2, "This imaginary opponents attacks will be highlighted");
768 sprintf (string3, "to make this easier.");
770 if (tutorialstage == 33) {
771 sprintf (string, "Reverse three enemy attacks!");
772 sprintf (string2, " ");
773 sprintf (string3, " ");
775 if (tutorialstage == 34) {
776 sprintf (string, "Reverse two more enemy attacks!");
777 sprintf (string2, " ");
778 sprintf (string3, " ");
780 if (tutorialstage == 35) {
781 sprintf (string, "Reverse one more enemy attack!");
782 sprintf (string2, " ");
783 sprintf (string3, " ");
785 if (tutorialstage == 36) {
786 sprintf (string, "Excellent!");
787 sprintf (string2, " ");
788 sprintf (string3, " ");
790 if (tutorialstage == 37) {
791 sprintf (string, "Now spar with the enemy for %d more seconds.", (int)(tutorialmaxtime - tutorialstagetime));
792 sprintf (string2, "Damage dealt: %d", (int)damagedealt);
793 sprintf (string3, "Damage taken: %d.", (int)damagetaken);
795 if (tutorialstage == 38) {
796 sprintf (string, "WEAPONS:");
797 sprintf (string2, " ");
798 sprintf (string3, " ");
800 if (tutorialstage == 39) {
801 sprintf (string, "There is now an imaginary knife");
802 sprintf (string2, "in the center of the training area.");
803 sprintf (string3, " ");
805 if (tutorialstage == 40) {
806 sprintf (string, "Stand, roll or handspring over the knife");
807 sprintf (string2, "while pressing %s to pick it up.", Input::keyToChar(throwkey));
808 sprintf (string3, "You can crouch and press the same key to drop it again.");
810 if (tutorialstage == 41) {
811 sprintf (string, "You can equip and unequip weapons using the %s key.", Input::keyToChar(drawkey));
812 sprintf (string2, "Sometimes it is best to keep them unequipped to");
813 sprintf (string3, "prevent enemies from taking them. ");
815 if (tutorialstage == 42) {
816 sprintf (string, "The knife is the smallest weapon and the least encumbering.");
817 sprintf (string2, "You can equip or unequip it while standing, crouching,");
818 sprintf (string3, "running or flipping.");
820 if (tutorialstage == 43) {
821 sprintf (string, "You perform weapon attacks the same way as unarmed attacks,");
822 sprintf (string2, "but sharp weapons cause permanent damage, instead of the");
823 sprintf (string3, "temporary trauma from blunt weapons, fists and feet.");
825 if (tutorialstage == 44) {
826 sprintf (string, "The enemy now has your knife!");
827 sprintf (string2, "Please reverse two of his knife attacks.");
828 sprintf (string3, " ");
830 if (tutorialstage == 45) {
831 sprintf (string, "Please reverse one more of his knife attacks.");
832 sprintf (string2, " ");
833 sprintf (string3, " ");
835 if (tutorialstage == 46) {
836 sprintf (string, "Now he has a sword!");
837 sprintf (string2, "The sword has longer reach than your arms, so you");
838 sprintf (string3, "must move close to reverse the sword slash.");
840 if (tutorialstage == 47) {
841 sprintf (string, "Long weapons like the sword and staff are also useful for defense;");
842 sprintf (string2, "you can parry enemy weapon attacks by pressing the attack key");
843 sprintf (string3, "at the right time. Please try parrying the enemy's attacks!");
845 if (tutorialstage == 48) {
846 sprintf (string, "The staff is like the sword, but has two main attacks.");
847 sprintf (string2, "The standing smash is fast and effective, and the running");
848 sprintf (string3, "spin smash is slower and more powerful.");
850 if (tutorialstage == 49) {
851 sprintf (string, "When facing an enemy, you can throw the knife with %s.", Input::keyToChar(throwkey));
852 sprintf (string2, "It is possible to throw the knife while flipping,");
853 sprintf (string3, "but it is very inaccurate.");
855 if (tutorialstage == 50) {
856 sprintf (string, "You now know everything you can learn from training.");
857 sprintf (string2, "Everything else you must learn from experience!");
858 sprintf (string3, " ");
860 if (tutorialstage == 51) {
861 sprintf (string, "Walk out of the training area to return to the main menu.");
862 sprintf (string2, " ");
863 sprintf (string3, " ");
866 glColor4f(0, 0, 0, tutorialopac);
867 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);
868 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);
869 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);
870 glColor4f(1, 1, 1, tutorialopac);
871 text->glPrint(screenwidth / 2 - 7.6 * strlen(string)*screenwidth / 1024, screenheight / 16 + screenheight * 4 / 5, string, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight);
872 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);
873 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);
875 sprintf (string, "Press 'tab' to skip to the next item.");
876 sprintf (string2, "Press escape at any time to");
877 sprintf (string3, "pause or exit the tutorial.");
879 glColor4f(0, 0, 0, 1);
880 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);
881 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);
882 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);
883 glColor4f(0.5, 0.5, 0.5, 1);
884 text->glPrint(screenwidth / 2 - 7.6 * strlen(string)*screenwidth / 1024 * .8, 0 + screenheight * 1 / 10, string, 1, 1.5 * screenwidth / 1024 * .8, screenwidth, screenheight);
885 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);
886 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);
890 if (Hotspot::hotspots.size() && (bonustime >= 1 || bonus <= 0 || bonustime < 0) && !tutoriallevel) {
891 float closestdist = -1;
893 int closest = Hotspot::current;
894 for (unsigned i = 0; i < Hotspot::hotspots.size(); i++) {
895 distance = distsq(&Person::players[0]->coords, &Hotspot::hotspots[i].position);
896 if (closestdist == -1 || distance < closestdist) {
897 if (distsq(&Person::players[0]->coords, &Hotspot::hotspots[i].position) < Hotspot::hotspots[i].size && ((Hotspot::hotspots[i].type <= 10 && Hotspot::hotspots[i].type >= 0) || (Hotspot::hotspots[i].type <= 40 && Hotspot::hotspots[i].type >= 20))) {
898 closestdist = distance;
904 Hotspot::current = closest;
905 if (Hotspot::hotspots[closest].type <= 10) {
906 if (distsq(&Person::players[0]->coords, &Hotspot::hotspots[closest].position) < Hotspot::hotspots[closest].size)
907 tutorialstagetime = 0;
909 tutorialopac = tutorialmaxtime - tutorialstagetime;
910 if (tutorialopac > 1)
912 if (tutorialopac < 0)
915 sprintf (string, "%s", Hotspot::hotspots[closest].text);
922 if (string[i] == '\n' || string[i] > 'z' || string[i] < ' ' || string[i] == '\0') {
923 glColor4f(0, 0, 0, tutorialopac);
924 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);
925 glColor4f(1, 1, 1, tutorialopac);
926 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);
929 if (string[i] == '\0')
936 } else if ((Hotspot::hotspots[closest].type >= 20) && (Dialog::dialogs[Hotspot::hotspots[closest].type - 20].gonethrough == 0)) {
937 Dialog::whichdialogue = Hotspot::hotspots[closest].type - 20;
938 Dialog::currentDialog().play();
939 Dialog::currentDialog().gonethrough++;
944 if (Dialog::inDialog() && !mainmenu) {
945 glDisable(GL_DEPTH_TEST);
946 glDisable(GL_CULL_FACE);
947 glDisable(GL_LIGHTING);
948 glDisable(GL_TEXTURE_2D);
950 glMatrixMode(GL_PROJECTION);
953 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
954 glMatrixMode(GL_MODELVIEW);
957 if (Dialog::currentScene().location == 1)
958 glTranslatef(0, screenheight * 3 / 4, 0);
959 glScalef(screenwidth, screenheight / 4, 1);
960 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
963 glColor4f(Dialog::currentScene().color[0], Dialog::currentScene().color[1], Dialog::currentScene().color[2], 0.7);
965 glVertex3f(0, 0, 0.0f);
966 glVertex3f(1, 0, 0.0f);
967 glVertex3f(1, 1, 0.0f);
968 glVertex3f(0, 1, 0.0f);
970 glMatrixMode(GL_PROJECTION);
972 glMatrixMode(GL_MODELVIEW);
974 glEnable(GL_DEPTH_TEST);
975 glEnable(GL_CULL_FACE);
978 glEnable(GL_TEXTURE_2D);
985 startx = screenwidth * 1 / 5;
986 if (Dialog::currentScene().location == 1) {
987 starty = screenheight / 16 + screenheight * 4 / 5;
989 starty = screenheight * 1 / 5 - screenheight / 16;
992 // FIXME - What is that char[] building for?
995 for (int i = 0; i < 264; i++) {
999 for (unsigned i = 0; i < Dialog::currentScene().name.size(); i++) {
1000 tempname[tempnum] = Dialog::currentScene().name[i];
1001 if (tempname[tempnum] == '#' || tempname[tempnum] == '\0')
1002 tempname[tempnum] = '\0';
1007 sprintf (string, "%s: ", tempname);
1009 if (Dialog::currentScene().color[0] + Dialog::currentScene().color[1] + Dialog::currentScene().color[2] < 1.5) {
1010 glColor4f(0, 0, 0, tutorialopac);
1011 text->glPrintOutline(startx - 2 * 7.6 * strlen(string)*screenwidth / 1024 - 4, starty - 4, string, 1, 1.5 * 1.25 * screenwidth / 1024, screenwidth, screenheight);
1012 glColor4f(0.7, 0.7, 0.7, tutorialopac);
1013 text->glPrint(startx - 2 * 7.6 * strlen(string)*screenwidth / 1024, starty, string, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight);
1015 glColor4f(0, 0, 0, tutorialopac);
1016 text->glPrintOutline(startx - 2 * 7.6 * strlen(string)*screenwidth / 1024 - 4, starty - 4, string, 1, 1.5 * 1.25 * screenwidth / 1024, screenwidth, screenheight);
1020 for (unsigned i = 0; i < Dialog::currentScene().text.size() + 1; i++) {
1021 tempname[tempnum] = Dialog::currentScene().text[i];
1022 if (Dialog::currentScene().text[i] != '#')
1026 sprintf (string, "%s", tempname);
1033 if (string[i] == '\n' || string[i] > 'z' || string[i] < ' ' || string[i] == '\0') {
1034 if (Dialog::currentScene().color[0] + Dialog::currentScene().color[1] + Dialog::currentScene().color[2] < 1.5) {
1035 glColor4f(0, 0, 0, tutorialopac);
1036 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);
1037 glColor4f(1, 1, 1, tutorialopac);
1038 text->glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/, starty - 20 * screenwidth / 1024 * line, string, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight, lastline, i);
1040 glColor4f(0, 0, 0, tutorialopac);
1041 text->glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/, starty - 20 * screenwidth / 1024 * line, string, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight, lastline, i);
1045 if (string[i] == '\0')
1054 if (!tutoriallevel && !winfreeze && !Dialog::inDialog() && !mainmenu) {
1057 sprintf (string, "Score: %d", (int)Account::active().getCampaignScore());
1059 sprintf (string, "Score: %d", (int)Account::active().getCampaignScore() + (int)bonustotal);
1062 sprintf (string, "Score: %d", (int)bonustotal);
1063 glColor4f(0, 0, 0, 1);
1064 text->glPrintOutline(1024 / 40 - 4, 768 / 16 - 4 + 768 * 14 / 16, string, 1, 1.5 * 1.25, 1024, 768);
1065 glColor4f(1, 0, 0, 1);
1066 text->glPrint(1024 / 40, 768 / 16 + 768 * 14 / 16, string, 1, 1.5, 1024, 768);
1067 if (showdamagebar) {
1068 glDisable(GL_DEPTH_TEST);
1069 glDisable(GL_CULL_FACE);
1070 glDisable(GL_LIGHTING);
1071 glDisable(GL_TEXTURE_2D);
1073 glMatrixMode(GL_PROJECTION);
1076 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1077 glMatrixMode(GL_MODELVIEW);
1080 glTranslatef(15, screenheight * 17.5 / 20, 0);
1081 glScalef(screenwidth / 3 + 20, screenheight / 20, 1);
1082 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1084 glColor4f(0.0, 0.4, 0.0, 0.7);
1085 float bar = ((float)Person::players[0]->damage) / Person::players[0]->damagetolerance;
1087 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
1088 glVertex3f(1, 0, 0.0f);
1089 glVertex3f(1, 1, 0.0f);
1090 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
1092 glColor4f(0.1, 0.0, 0.0, 1);
1093 bar = ((float)Person::players[0]->bloodloss) / Person::players[0]->damagetolerance;
1095 glVertex3f(0, 0, 0.0f);
1096 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
1097 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
1098 glVertex3f(0, 1, 0.0f);
1100 glColor4f(0.4, 0.0, 0.0, 0.7);
1101 bar = ((float)Person::players[0]->damage) / Person::players[0]->damagetolerance;
1103 glVertex3f(0, 0, 0.0f);
1104 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
1105 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
1106 glVertex3f(0, 1, 0.0f);
1108 glColor4f(0.4, 0.0, 0.0, 0.7);
1109 bar = ((float)Person::players[0]->permanentdamage) / Person::players[0]->damagetolerance;
1111 glVertex3f(0, 0, 0.0f);
1112 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
1113 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
1114 glVertex3f(0, 1, 0.0f);
1116 glColor4f(0.4, 0.0, 0.0, 0.7);
1117 bar = ((float)Person::players[0]->superpermanentdamage) / Person::players[0]->damagetolerance;
1119 glVertex3f(0, 0, 0.0f);
1120 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
1121 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
1122 glVertex3f(0, 1, 0.0f);
1124 glColor4f(0.0, 0.0, 0.0, 0.7);
1126 glBegin(GL_LINE_STRIP);
1127 glVertex3f(0, 0, 0.0f);
1128 glVertex3f(1, 0, 0.0f);
1129 glVertex3f(1, 1, 0.0f);
1130 glVertex3f(0, 1, 0.0f);
1131 glVertex3f(0, 0, 0.0f);
1134 glMatrixMode(GL_PROJECTION);
1136 glMatrixMode(GL_MODELVIEW);
1138 glEnable(GL_DEPTH_TEST);
1139 glEnable(GL_CULL_FACE);
1140 glDisable(GL_BLEND);
1142 glEnable(GL_TEXTURE_2D);
1144 // writing the numbers :
1145 sprintf (string, "Damages : %d/%d (%d)", (int)(Person::players[0]->damage), (int)(Person::players[0]->damagetolerance), (int)(Person::players[0]->bloodloss));
1146 glColor4f(0, 0, 0, 1);
1147 text->glPrintOutline(1024 / 40 - 4, 768 / 16 - 4 + 768 * 14 / 16 - 40, string, 1, 1.5 * 1.25, 1024, 768);
1148 glColor4f(1, 0, 0, 1);
1149 text->glPrint(1024 / 40, 768 / 16 + 768 * 14 / 16 - 40, string, 1, 1.5, 1024, 768);
1153 glColor4f(.5, .5, .5, 1);
1156 if ((texttoggle || editorenabled) && devtools && !mainmenu) {
1157 sprintf (string, "The framespersecond is %d.", (int)(fps));
1158 text->glPrint(10, 30, string, 0, .8, 1024, 768);
1161 sprintf (string, "Map editor enabled.");
1163 sprintf (string, "Map editor disabled.");
1164 text->glPrint(10, 60, string, 0, .8, 1024, 768);
1165 if (editorenabled) {
1166 sprintf (string, "Object size: %f", editorsize);
1167 text->glPrint(10, 75, string, 0, .8, 1024, 768);
1169 sprintf (string, "Object yaw: %f", editoryaw);
1171 sprintf (string, "Object yaw: Random");
1172 text->glPrint(10, 90, string, 0, .8, 1024, 768);
1173 if (editorpitch >= 0)
1174 sprintf (string, "Object pitch: %f", editorpitch);
1176 sprintf (string, "Object pitch: Random");
1177 text->glPrint(10, 105, string, 0, .8, 1024, 768);
1178 sprintf (string, "Object type: %d", editortype);
1179 text->glPrint(10, 120, string, 0, .8, 1024, 768);
1180 switch (editortype) {
1182 sprintf (string, "(box)");
1185 sprintf (string, "(tree)");
1188 sprintf (string, "(wall)");
1191 sprintf (string, "(weird)");
1194 sprintf (string, "(spike)");
1197 sprintf (string, "(rock)");
1200 sprintf (string, "(bush)");
1203 sprintf (string, "(tunnel)");
1206 sprintf (string, "(chimney)");
1209 sprintf (string, "(platform)");
1212 sprintf (string, "(cool)");
1215 sprintf (string, "(fire)");
1218 text->glPrint(130, 120, string, 0, .8, 1024, 768);
1220 sprintf (string, "Numplayers: %lu", Person::players.size());
1221 text->glPrint(10, 155, string, 0, .8, 1024, 768);
1222 sprintf (string, "Player %d: numwaypoints: %d", (int(Person::players.size()) - 1), Person::players.back()->numwaypoints);
1223 text->glPrint(10, 140, string, 0, .8, 1024, 768);
1225 sprintf (string, "Difficulty: %d", difficulty);
1226 text->glPrint(10, 240, string, 0, .8, 1024, 768);
1231 if (drawmode == glowmode) {
1232 glDisable(GL_DEPTH_TEST);
1233 glDisable(GL_CULL_FACE);
1234 glDisable(GL_LIGHTING);
1235 glDisable(GL_TEXTURE_2D);
1237 glMatrixMode(GL_PROJECTION);
1240 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1241 glMatrixMode(GL_MODELVIEW);
1244 glScalef(screenwidth, screenheight, 1);
1245 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1247 glColor4f(0, 0, 0, .5);
1249 glVertex3f(0, 0, 0.0f);
1250 glVertex3f(256, 0, 0.0f);
1251 glVertex3f(256, 256, 0.0f);
1252 glVertex3f(0, 256, 0.0f);
1254 glMatrixMode(GL_PROJECTION);
1256 glMatrixMode(GL_MODELVIEW);
1258 glEnable(GL_DEPTH_TEST);
1259 glEnable(GL_CULL_FACE);
1260 glDisable(GL_BLEND);
1264 if ((((blackout && damageeffects) || (Person::players[0]->bloodloss > 0 && damageeffects && Person::players[0]->blooddimamount > 0) || Person::players[0]->dead) && !cameramode) || console) {
1265 glDisable(GL_DEPTH_TEST);
1266 glDisable(GL_CULL_FACE);
1267 glDisable(GL_LIGHTING);
1268 glDisable(GL_TEXTURE_2D);
1270 glMatrixMode(GL_PROJECTION);
1273 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1274 glMatrixMode(GL_MODELVIEW);
1277 glScalef(screenwidth, screenheight, 1);
1278 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1280 if (Person::players[0]->dead)
1281 blackout += multiplier * 3;
1282 if (Person::players[0]->dead == 1)
1284 if (Person::players[0]->dead == 2 && blackout > .6)
1286 glColor4f(0, 0, 0, blackout);
1287 if (!Person::players[0]->dead) {
1288 if ((Person::players[0]->bloodloss / Person::players[0]->damagetolerance * (sin(woozy) / 4 + .5))*.3 < .3) {
1289 glColor4f(0, 0, 0, Person::players[0]->blooddimamount * Person::players[0]->bloodloss / Person::players[0]->damagetolerance * (sin(woozy) / 4 + .5)*.3);
1290 blackout = Person::players[0]->blooddimamount * Person::players[0]->bloodloss / Person::players[0]->damagetolerance * (sin(woozy) / 4 + .5) * .3;
1292 glColor4f(0, 0, 0, Person::players[0]->blooddimamount * .3);
1293 blackout = Person::players[0]->blooddimamount * .3;
1297 glColor4f(.7, 0, 0, .2);
1299 glVertex3f(0, 0, 0.0f);
1300 glVertex3f(256, 0, 0.0f);
1301 glVertex3f(256, 256, 0.0f);
1302 glVertex3f(0, 256, 0.0f);
1304 glMatrixMode(GL_PROJECTION);
1306 glMatrixMode(GL_MODELVIEW);
1308 glEnable(GL_DEPTH_TEST);
1309 glEnable(GL_CULL_FACE);
1310 glDisable(GL_BLEND);
1314 if (flashamount > 0 && damageeffects) {
1315 if (flashamount > 1)
1317 if (flashdelay <= 0)
1318 flashamount -= multiplier;
1320 if (flashamount < 0)
1322 glDisable(GL_DEPTH_TEST);
1323 glDisable(GL_CULL_FACE);
1324 glDisable(GL_LIGHTING);
1326 glMatrixMode(GL_PROJECTION);
1329 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1330 glMatrixMode(GL_MODELVIEW);
1333 glScalef(screenwidth, screenheight, 1);
1334 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1336 glColor4f(flashr, flashg, flashb, flashamount);
1338 glVertex3f(0, 0, 0.0f);
1339 glVertex3f(256, 0, 0.0f);
1340 glVertex3f(256, 256, 0.0f);
1341 glVertex3f(0, 256, 0.0f);
1343 glMatrixMode(GL_PROJECTION);
1345 glMatrixMode(GL_MODELVIEW);
1347 glEnable(GL_DEPTH_TEST);
1348 glEnable(GL_CULL_FACE);
1349 glDisable(GL_BLEND);
1355 glEnable(GL_TEXTURE_2D);
1356 glColor4f(1, 1, 1, 1);
1357 for (unsigned i = 1; i < 15; i++)
1358 if (displaytime[i] < 4)
1359 for (unsigned j = 0; j < displaytext[i].size(); j++) {
1360 glColor4f(1, 1, 1, 4 - displaytime[i]);
1361 sprintf (string, "%c", displaytext[i][j]);
1362 text->glPrint(30 + j * 10, 30 + i * 20 + (screenheight - 330), string, 0, 1, screenwidth, screenheight);
1366 if (difficulty < 2 && !Dialog::inDialog()) { // minimap
1367 float mapviewdist = 20000;
1369 glDisable(GL_DEPTH_TEST);
1370 glColor3f (1.0, 1.0, 1.0); // no coloring
1372 glEnable(GL_TEXTURE_2D);
1373 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1374 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1375 glDisable(GL_DEPTH_TEST);
1376 glDisable(GL_CULL_FACE);
1377 glDisable(GL_LIGHTING);
1379 glMatrixMode(GL_PROJECTION);
1382 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1383 glMatrixMode(GL_MODELVIEW);
1386 glScalef((float)screenwidth / 2, (float)screenwidth / 2, 1);
1387 glTranslatef(1.75, .25, 0);
1388 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1390 glColor4f(1, 1, 1, 1);
1397 center = Person::players[0]->coords;
1401 glScalef(.25 / radius * 256 * terrain.scale * .4, .25 / radius * 256 * terrain.scale * .4, 1);
1403 glScalef(1 / (1 / radius * 256 * terrain.scale * .4), 1 / (1 / radius * 256 * terrain.scale * .4), 1);
1405 glRotatef(Person::players[0]->lookyaw * -1 + 180, 0, 0, 1);
1406 glTranslatef(-(center.x / terrain.scale / 256 * -2 + 1), (center.z / terrain.scale / 256 * -2 + 1), 0);
1407 for (int i = 0; i < objects.numobjects; i++) {
1408 if (objects.type[i] == treetrunktype) {
1409 distcheck = distsq(&Person::players[0]->coords, &objects.position[i]);
1410 if (distcheck < mapviewdist) {
1411 Mapcircletexture.bind();
1412 glColor4f(0, .3, 0, opac * (1 - distcheck / mapviewdist));
1414 glTranslatef(objects.position[i].x / terrain.scale / 256 * -2 + 1, objects.position[i].z / terrain.scale / 256 * 2 - 1, 0);
1415 glRotatef(objects.yaw[i], 0, 0, 1);
1416 glScalef(.003, .003, .003);
1419 glVertex3f(-1, -1, 0.0f);
1421 glVertex3f(1, -1, 0.0f);
1423 glVertex3f(1, 1, 0.0f);
1425 glVertex3f(-1, 1, 0.0f);
1430 if (objects.type[i] == boxtype) {
1431 distcheck = distsq(&Person::players[0]->coords, &objects.position[i]);
1432 if (distcheck < mapviewdist) {
1433 Mapboxtexture.bind();
1434 glColor4f(.4, .4, .4, opac * (1 - distcheck / mapviewdist));
1436 glTranslatef(objects.position[i].x / terrain.scale / 256 * -2 + 1, objects.position[i].z / terrain.scale / 256 * 2 - 1, 0);
1437 glRotatef(objects.yaw[i], 0, 0, 1);
1438 glScalef(.01 * objects.scale[i], .01 * objects.scale[i], .01 * objects.scale[i]);
1441 glVertex3f(-1, -1, 0.0f);
1443 glVertex3f(1, -1, 0.0f);
1445 glVertex3f(1, 1, 0.0f);
1447 glVertex3f(-1, 1, 0.0f);
1453 if (editorenabled) {
1454 Mapcircletexture.bind();
1455 for (int i = 0; i < numboundaries; i++) {
1456 glColor4f(0, 0, 0, opac / 3);
1458 glTranslatef(boundary[i].x / terrain.scale / 256 * -2 + 1, boundary[i].z / terrain.scale / 256 * 2 - 1, 0);
1459 glScalef(.002, .002, .002);
1462 glVertex3f(-1, -1, 0.0f);
1464 glVertex3f(1, -1, 0.0f);
1466 glVertex3f(1, 1, 0.0f);
1468 glVertex3f(-1, 1, 0.0f);
1473 for (unsigned i = 0; i < Person::players.size(); i++) {
1474 distcheck = distsq(&Person::players[0]->coords, &Person::players[i]->coords);
1475 if (distcheck < mapviewdist) {
1477 Maparrowtexture.bind();
1479 glColor4f(1, 1, 1, opac);
1480 else if (Person::players[i]->dead == 2 || Person::players[i]->howactive > typesleeping)
1481 glColor4f(0, 0, 0, opac * (1 - distcheck / mapviewdist));
1482 else if (Person::players[i]->dead)
1483 glColor4f(.3, .3, .3, opac * (1 - distcheck / mapviewdist));
1484 else if (Person::players[i]->aitype == attacktypecutoff)
1485 glColor4f(1, 0, 0, opac * (1 - distcheck / mapviewdist));
1486 else if (Person::players[i]->aitype == passivetype)
1487 glColor4f(0, 1, 0, opac * (1 - distcheck / mapviewdist));
1489 glColor4f(1, 1, 0, 1);
1490 glTranslatef(Person::players[i]->coords.x / terrain.scale / 256 * -2 + 1, Person::players[i]->coords.z / terrain.scale / 256 * 2 - 1, 0);
1491 glRotatef(Person::players[i]->yaw + 180, 0, 0, 1);
1492 glScalef(.005, .005, .005);
1495 glVertex3f(-1, -1, 0.0f);
1497 glVertex3f(1, -1, 0.0f);
1499 glVertex3f(1, 1, 0.0f);
1501 glVertex3f(-1, 1, 0.0f);
1507 glDisable(GL_TEXTURE_2D);
1508 glMatrixMode(GL_PROJECTION);
1510 glMatrixMode(GL_MODELVIEW);
1512 glEnable(GL_DEPTH_TEST);
1513 glEnable(GL_CULL_FACE);
1514 glDisable(GL_BLEND);
1518 if (loading && !stealthloading && (!campaign || Person::players[0]->dead)) {
1519 glDisable(GL_DEPTH_TEST);
1520 glDisable(GL_CULL_FACE);
1521 glDisable(GL_LIGHTING);
1522 glDisable(GL_TEXTURE_2D);
1524 glMatrixMode(GL_PROJECTION);
1527 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1528 glMatrixMode(GL_MODELVIEW);
1531 glScalef(screenwidth, screenheight, 1);
1532 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1534 glColor4f(0, 0, 0, .7);
1536 glVertex3f(0, 0, 0.0f);
1537 glVertex3f(256, 0, 0.0f);
1538 glVertex3f(256, 256, 0.0f);
1539 glVertex3f(0, 256, 0.0f);
1541 glMatrixMode(GL_PROJECTION);
1543 glMatrixMode(GL_MODELVIEW);
1545 glEnable(GL_DEPTH_TEST);
1546 glEnable(GL_CULL_FACE);
1547 glDisable(GL_BLEND);
1551 glDisable(GL_DEPTH_TEST);
1552 glColor3f (1.0, 1.0, 1.0); // no coloring
1554 glEnable(GL_TEXTURE_2D);
1559 glEnable(GL_TEXTURE_2D);
1560 glColor4f(1, 1, 1, 1);
1561 sprintf (string, "Loading...");
1562 text->glPrint(1024 / 2 - 90, 768 / 2, string, 1, 2, 1024, 768);
1565 drawmode = normalmode;
1568 if (winfreeze && !campaign) {
1569 glDisable(GL_DEPTH_TEST);
1570 glDisable(GL_CULL_FACE);
1571 glDisable(GL_LIGHTING);
1572 glDisable(GL_TEXTURE_2D);
1574 glMatrixMode(GL_PROJECTION);
1577 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1578 glMatrixMode(GL_MODELVIEW);
1581 glScalef(screenwidth, screenheight, 1);
1582 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1584 glColor4f(0, 0, 0, .4);
1586 glVertex3f(0, 0, 0.0f);
1587 glVertex3f(256, 0, 0.0f);
1588 glVertex3f(256, 256, 0.0f);
1589 glVertex3f(0, 256, 0.0f);
1591 glMatrixMode(GL_PROJECTION);
1593 glMatrixMode(GL_MODELVIEW);
1595 glEnable(GL_DEPTH_TEST);
1596 glEnable(GL_CULL_FACE);
1597 glDisable(GL_BLEND);
1601 glDisable(GL_DEPTH_TEST);
1602 glColor3f (1.0, 1.0, 1.0); // no coloring
1604 glEnable(GL_TEXTURE_2D);
1606 //Win Screen Won Victory
1608 glEnable(GL_TEXTURE_2D);
1609 glColor4f(1, 1, 1, 1);
1610 sprintf (string, "Level Cleared!");
1611 text->glPrintOutlined(1024 / 2 - strlen(string) * 10, 768 * 7 / 8, string, 1, 2, 1024, 768);
1613 sprintf (string, "Score: %d", (int)(bonustotal - startbonustotal));
1614 text->glPrintOutlined(1024 / 30, 768 * 6 / 8, string, 1, 2, 1024, 768);
1616 sprintf (string, "Press Escape to return to menu or Space to continue");
1617 text->glPrintOutlined(640 / 2 - strlen(string) * 5, 480 * 1 / 16, string, 1, 1, 640, 480);
1621 for (int i = 0; i < 255; i++)
1623 int wontime = (int)round(wonleveltime);
1624 sprintf (temp, "Time: %d:", int((wontime - wontime % 60) / 60));
1625 strcat(string, temp);
1626 if (wontime % 60 < 10)
1627 strcat(string, "0");
1628 sprintf (temp, "%d", wontime % 60);
1629 strcat(string, temp);
1630 text->glPrintOutlined(1024 / 30, 768 * 6 / 8 - 40, string, 1, 2, 1024, 768);
1633 int awards[award_count];
1634 int numawards = award_awards(awards);
1636 for (int i = 0; i < numawards && i < 6; i++)
1637 text->glPrintOutlined(1024 / 30, 768 * 6 / 8 - 90 - 40 * i, award_names[awards[i]], 1, 2, 1024, 768);
1640 if (drawmode != normalmode) {
1641 glEnable(GL_TEXTURE_2D);
1643 if (!drawtoggle || drawmode != realmotionblurmode || (drawtoggle == 2 || change == 1)) {
1644 if (screentexture) {
1646 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
1647 GLfloat subtractColor[4] = { 0.5, 0.5, 0.5, 0.0 };
1648 glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, subtractColor);
1649 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE);
1650 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_CONSTANT_EXT);
1651 glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 2.0f);
1653 glBindTexture( GL_TEXTURE_2D, screentexture);
1654 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1657 if ((drawtoggle || change == 1) && drawmode == realmotionblurmode) {
1658 if (screentexture2) {
1659 glBindTexture( GL_TEXTURE_2D, screentexture2);
1660 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1662 if (!screentexture2) {
1663 glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
1665 glGenTextures( 1, &screentexture2 );
1666 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
1668 glEnable(GL_TEXTURE_2D);
1669 glBindTexture( GL_TEXTURE_2D, screentexture2);
1670 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
1671 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
1673 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
1678 glClear(GL_DEPTH_BUFFER_BIT);
1679 Game::ReSizeGLScene(90, .1f);
1680 glViewport(0, 0, screenwidth, screenheight);
1682 if (drawmode != normalmode) {
1683 glDisable(GL_DEPTH_TEST);
1684 if (drawmode == motionblurmode) {
1685 glDrawBuffer(GL_FRONT);
1686 glReadBuffer(GL_BACK);
1688 glColor3f (1.0, 1.0, 1.0); // no coloring
1690 glEnable(GL_TEXTURE_2D);
1691 glBindTexture( GL_TEXTURE_2D, screentexture);
1692 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1693 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1694 glDisable(GL_DEPTH_TEST);
1695 glDisable(GL_CULL_FACE);
1696 glDisable(GL_LIGHTING);
1698 glMatrixMode(GL_PROJECTION);
1701 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1702 glMatrixMode(GL_MODELVIEW);
1705 glScalef((float)screenwidth / 2, (float)screenheight / 2, 1);
1706 glTranslatef(1, 1, 0);
1707 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1709 if (drawmode == motionblurmode) {
1710 if (motionbluramount < .2)
1711 motionbluramount = .2;
1712 glColor4f(1, 1, 1, motionbluramount);
1716 glVertex3f(-1, -1, 0.0f);
1717 glTexCoord2f(texcoordwidth, 0);
1718 glVertex3f(1, -1, 0.0f);
1719 glTexCoord2f(texcoordwidth, texcoordheight);
1720 glVertex3f(1, 1, 0.0f);
1721 glTexCoord2f(0, texcoordheight);
1722 glVertex3f(-1, 1, 0.0f);
1726 if (drawmode == realmotionblurmode) {
1727 glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
1728 glClear(GL_COLOR_BUFFER_BIT);
1729 glBlendFunc(GL_SRC_ALPHA, GL_ONE);
1730 glBindTexture( GL_TEXTURE_2D, screentexture);
1731 glColor4f(1, 1, 1, .5);
1735 glVertex3f(-1, -1, 0.0f);
1736 glTexCoord2f(texcoordwidth, 0);
1737 glVertex3f(1, -1, 0.0f);
1738 glTexCoord2f(texcoordwidth, texcoordheight);
1739 glVertex3f(1, 1, 0.0f);
1740 glTexCoord2f(0, texcoordheight);
1741 glVertex3f(-1, 1, 0.0f);
1744 glBindTexture( GL_TEXTURE_2D, screentexture2);
1745 glColor4f(1, 1, 1, .5);
1749 glVertex3f(-1, -1, 0.0f);
1750 glTexCoord2f(texcoordwidth, 0);
1751 glVertex3f(1, -1, 0.0f);
1752 glTexCoord2f(texcoordwidth, texcoordheight);
1753 glVertex3f(1, 1, 0.0f);
1754 glTexCoord2f(0, texcoordheight);
1755 glVertex3f(-1, 1, 0.0f);
1758 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1760 if (drawmode == doublevisionmode) {
1761 static float crosseyedness;
1762 crosseyedness = abs(Person::players[0]->damage - Person::players[0]->superpermanentdamage - (Person::players[0]->damagetolerance - Person::players[0]->superpermanentdamage) * 1 / 2) / 30;
1763 if (crosseyedness > 1)
1765 if (crosseyedness < 0)
1767 glColor4f(1, 1, 1, 1);
1768 glDisable(GL_BLEND);
1773 glVertex3f(-1, -1, 0.0f);
1774 glTexCoord2f(texcoordwidth, 0);
1775 glVertex3f(1, -1, 0.0f);
1776 glTexCoord2f(texcoordwidth, texcoordheight);
1777 glVertex3f(1, 1, 0.0f);
1778 glTexCoord2f(0, texcoordheight);
1779 glVertex3f(-1, 1, 0.0f);
1782 if (crosseyedness) {
1783 glColor4f(1, 1, 1, .5);
1786 glTranslatef(.015 * crosseyedness, 0, 0);
1790 glVertex3f(-1, -1, 0.0f);
1791 glTexCoord2f(texcoordwidth, 0);
1792 glVertex3f(1, -1, 0.0f);
1793 glTexCoord2f(texcoordwidth, texcoordheight);
1794 glVertex3f(1, 1, 0.0f);
1795 glTexCoord2f(0, texcoordheight);
1796 glVertex3f(-1, 1, 0.0f);
1801 if (drawmode == glowmode) {
1802 glColor4f(.5, .5, .5, .5);
1804 glBlendFunc(GL_SRC_ALPHA, GL_ONE);
1806 glTranslatef(.01, 0, 0);
1809 glVertex3f(-1, -1, 0.0f);
1810 glTexCoord2f(texcoordwidth, 0);
1811 glVertex3f(1, -1, 0.0f);
1812 glTexCoord2f(texcoordwidth, texcoordheight);
1813 glVertex3f(1, 1, 0.0f);
1814 glTexCoord2f(0, texcoordheight);
1815 glVertex3f(-1, 1, 0.0f);
1819 glTranslatef(-.01, 0, 0);
1822 glVertex3f(-1, -1, 0.0f);
1823 glTexCoord2f(texcoordwidth, 0);
1824 glVertex3f(1, -1, 0.0f);
1825 glTexCoord2f(texcoordwidth, texcoordheight);
1826 glVertex3f(1, 1, 0.0f);
1827 glTexCoord2f(0, texcoordheight);
1828 glVertex3f(-1, 1, 0.0f);
1832 glTranslatef(.0, .01, 0);
1835 glVertex3f(-1, -1, 0.0f);
1836 glTexCoord2f(texcoordwidth, 0);
1837 glVertex3f(1, -1, 0.0f);
1838 glTexCoord2f(texcoordwidth, texcoordheight);
1839 glVertex3f(1, 1, 0.0f);
1840 glTexCoord2f(0, texcoordheight);
1841 glVertex3f(-1, 1, 0.0f);
1845 glTranslatef(0, -.01, 0);
1848 glVertex3f(-1, -1, 0.0f);
1849 glTexCoord2f(texcoordwidth, 0);
1850 glVertex3f(1, -1, 0.0f);
1851 glTexCoord2f(texcoordwidth, texcoordheight);
1852 glVertex3f(1, 1, 0.0f);
1853 glTexCoord2f(0, texcoordheight);
1854 glVertex3f(-1, 1, 0.0f);
1858 if (drawmode == radialzoommode) {
1859 for (int i = 0; i < 3; i++) {
1860 glColor4f(1, 1, 1, 1 / ((float)i + 1));
1862 glScalef(1 + (float)i * .01, 1 + (float)i * .01, 1);
1865 glVertex3f(-1, -1, 0.0f);
1866 glTexCoord2f(texcoordwidth, 0);
1867 glVertex3f(1, -1, 0.0f);
1868 glTexCoord2f(texcoordwidth, texcoordheight);
1869 glVertex3f(1, 1, 0.0f);
1870 glTexCoord2f(0, texcoordheight);
1871 glVertex3f(-1, 1, 0.0f);
1876 glDisable(GL_TEXTURE_2D);
1877 glMatrixMode(GL_PROJECTION);
1879 glMatrixMode(GL_MODELVIEW);
1881 glEnable(GL_DEPTH_TEST);
1882 glEnable(GL_CULL_FACE);
1883 glDisable(GL_BLEND);
1888 glEnable(GL_TEXTURE_2D);
1889 glColor4f(1, 1, 1, 1);
1891 if (consoleselected >= 60)
1892 offset = consoleselected - 60;
1893 sprintf (string, " ]");
1894 text->glPrint(10, 30, string, 0, 1, 1024, 768);
1896 sprintf (string, "_");
1897 text->glPrint(30 + (float)(consoleselected) * 10 - offset * 10, 30, string, 0, 1, 1024, 768);
1899 for (unsigned i = 0; i < 15; i++)
1900 for (unsigned j = 0; j < consoletext[i].size(); j++) {
1901 glColor4f(1, 1, 1, 1 - (float)(i) / 16);
1902 sprintf (string, "%c", consoletext[i][j]);
1903 text->glPrint(30 + j * 10 - offset * 10, 30 + i * 20, string, 0, 1, 1024, 768);
1908 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted)) {
1909 multiplier = tempmult;
1916 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted)) {
1917 tempmult = multiplier;
1921 if ( side == stereoRight || side == stereoCenter ) {
1922 if (drawmode != motionblurmode || mainmenu) {
1927 glDrawBuffer(GL_BACK);
1928 glReadBuffer(GL_BACK);
1932 if (drawtoggle == 2)
1935 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted)) {
1936 multiplier = tempmult;
1938 //Jordan fixed your warning!
1944 // !!! FIXME: hack: clamp framerate in menu so text input works correctly on fast systems.
1947 glDrawBuffer(GL_BACK);
1948 glReadBuffer(GL_BACK);
1949 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
1950 Game::ReSizeGLScene(90, .1f);
1952 //draw menu background
1953 glClear(GL_DEPTH_BUFFER_BIT);
1954 glEnable(GL_ALPHA_TEST);
1955 glAlphaFunc(GL_GREATER, 0.001f);
1956 glEnable(GL_TEXTURE_2D);
1957 glDisable(GL_DEPTH_TEST);
1958 glDisable(GL_CULL_FACE);
1959 glDisable(GL_LIGHTING);
1961 glMatrixMode(GL_PROJECTION);
1964 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1965 glMatrixMode(GL_MODELVIEW);
1968 glTranslatef(screenwidth / 2, screenheight / 2, 0);
1970 glScalef((float)screenwidth / 2, (float)screenheight / 2, 1);
1971 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1972 glDisable(GL_BLEND);
1973 glColor4f(0, 0, 0, 1.0);
1974 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
1975 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
1976 glDisable(GL_TEXTURE_2D);
1978 glVertex3f(-1, -1, 0);
1979 glVertex3f(+1, -1, 0);
1980 glVertex3f(+1, +1, 0);
1981 glVertex3f(-1, +1, 0);
1984 glColor4f(0.4, 0.4, 0.4, 1.0);
1985 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
1986 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
1987 glEnable(GL_TEXTURE_2D);
1988 Game::Mainmenuitems[4].bind();
1991 glVertex3f(-1, -1, 0);
1993 glVertex3f(+1, -1, 0);
1995 glVertex3f(+1, +1, 0);
1997 glVertex3f(-1, +1, 0);
2001 glMatrixMode(GL_PROJECTION);
2003 glMatrixMode(GL_MODELVIEW);
2007 glMatrixMode(GL_PROJECTION);
2010 glOrtho(0, 640, 0, 480, -100, 100);
2011 glMatrixMode(GL_MODELVIEW);
2014 glEnable(GL_TEXTURE_2D);
2019 glMatrixMode(GL_PROJECTION);
2021 glMatrixMode(GL_MODELVIEW);
2024 glMatrixMode(GL_PROJECTION);
2027 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
2028 glMatrixMode(GL_MODELVIEW);
2031 glTranslatef(screenwidth / 2, screenheight / 2, 0);
2033 glScalef((float)screenwidth / 2, (float)screenheight / 2, 1);
2034 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
2036 glEnable(GL_TEXTURE_2D);
2037 glColor4f(1, 1, 1, 1);
2038 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2039 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2041 if (!Game::waiting) { // hide the cursor while waiting for a key
2043 glTranslatef(Game::mousecoordh - screenwidth / 2, Game::mousecoordv * -1 + screenheight / 2, 0);
2044 glScalef((float)screenwidth / 64, (float)screenwidth / 64, 1);
2045 glTranslatef(1, -1, 0);
2046 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
2047 glColor4f(1, 1, 1, 1);
2048 Game::cursortexture.bind();
2052 glVertex3f(-1, -1, 0.0f);
2054 glVertex3f(1, -1, 0.0f);
2056 glVertex3f(1, 1, 0.0f);
2058 glVertex3f(-1, 1, 0.0f);
2064 glMatrixMode(GL_PROJECTION);
2069 if (flashamount > 0) {
2070 if (flashamount > 1)
2072 if (flashdelay <= 0)
2073 flashamount -= multiplier;
2075 if (flashamount < 0)
2077 glDisable(GL_DEPTH_TEST);
2078 glDisable(GL_CULL_FACE);
2079 glDisable(GL_LIGHTING);
2080 glDisable(GL_TEXTURE_2D);
2082 glMatrixMode(GL_PROJECTION);
2085 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
2086 glMatrixMode(GL_MODELVIEW);
2089 glScalef(screenwidth, screenheight, 1);
2090 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
2092 glColor4f(flashr, flashg, flashb, flashamount);
2094 glVertex3f(0, 0, 0.0f);
2095 glVertex3f(256, 0, 0.0f);
2096 glVertex3f(256, 256, 0.0f);
2097 glVertex3f(0, 256, 0.0f);
2099 glMatrixMode(GL_PROJECTION);
2101 glMatrixMode(GL_MODELVIEW);
2103 glEnable(GL_DEPTH_TEST);
2104 glEnable(GL_CULL_FACE);
2105 glDisable(GL_BLEND);