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 (int 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 (int 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[abs(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[abs(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 (int 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;
988 if (Dialog::currentScene().location == 2)
989 starty = screenheight * 1 / 5 - screenheight / 16;
993 for (int i = 0; i < 264; i++) {
997 for (int i = 0; i < Dialog::currentScene().name.size(); i++) {
998 tempname[tempnum] = Dialog::currentScene().name[i];
999 if (tempname[tempnum] == '#' || tempname[tempnum] == '\0')
1000 tempname[tempnum] = '\0';
1005 sprintf (string, "%s: ", tempname);
1007 if (Dialog::currentScene().color[0] + Dialog::currentScene().color[1] + Dialog::currentScene().color[2] < 1.5) {
1008 glColor4f(0, 0, 0, tutorialopac);
1009 text->glPrintOutline(startx - 2 * 7.6 * strlen(string)*screenwidth / 1024 - 4, starty - 4, string, 1, 1.5 * 1.25 * screenwidth / 1024, screenwidth, screenheight);
1010 glColor4f(0.7, 0.7, 0.7, tutorialopac);
1011 text->glPrint(startx - 2 * 7.6 * strlen(string)*screenwidth / 1024, starty, string, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight);
1013 glColor4f(0, 0, 0, tutorialopac);
1014 text->glPrintOutline(startx - 2 * 7.6 * strlen(string)*screenwidth / 1024 - 4, starty - 4, string, 1, 1.5 * 1.25 * screenwidth / 1024, screenwidth, screenheight);
1018 for (int i = 0; i < Dialog::currentScene().text.size() + 1; i++) {
1019 tempname[tempnum] = Dialog::currentScene().text[i];
1020 if (Dialog::currentScene().text[i] != '#')
1024 sprintf (string, "%s", tempname);
1031 if (string[i] == '\n' || string[i] > 'z' || string[i] < ' ' || string[i] == '\0') {
1032 if (Dialog::currentScene().color[0] + Dialog::currentScene().color[1] + Dialog::currentScene().color[2] < 1.5) {
1033 glColor4f(0, 0, 0, tutorialopac);
1034 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);
1035 glColor4f(1, 1, 1, tutorialopac);
1036 text->glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/, starty - 20 * screenwidth / 1024 * line, string, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight, lastline, i);
1038 glColor4f(0, 0, 0, tutorialopac);
1039 text->glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/, starty - 20 * screenwidth / 1024 * line, string, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight, lastline, i);
1043 if (string[i] == '\0')
1052 if (!tutoriallevel && !winfreeze && !Dialog::inDialog() && !mainmenu) {
1055 sprintf (string, "Score: %d", (int)Account::active().getCampaignScore());
1057 sprintf (string, "Score: %d", (int)Account::active().getCampaignScore() + (int)bonustotal);
1060 sprintf (string, "Score: %d", (int)bonustotal);
1061 glColor4f(0, 0, 0, 1);
1062 text->glPrintOutline(1024 / 40 - 4, 768 / 16 - 4 + 768 * 14 / 16, string, 1, 1.5 * 1.25, 1024, 768);
1063 glColor4f(1, 0, 0, 1);
1064 text->glPrint(1024 / 40, 768 / 16 + 768 * 14 / 16, string, 1, 1.5, 1024, 768);
1065 if (showdamagebar) {
1066 glDisable(GL_DEPTH_TEST);
1067 glDisable(GL_CULL_FACE);
1068 glDisable(GL_LIGHTING);
1069 glDisable(GL_TEXTURE_2D);
1071 glMatrixMode(GL_PROJECTION);
1074 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1075 glMatrixMode(GL_MODELVIEW);
1078 glTranslatef(15, screenheight * 17.5 / 20, 0);
1079 glScalef(screenwidth / 3 + 20, screenheight / 20, 1);
1080 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1082 glColor4f(0.0, 0.4, 0.0, 0.7);
1083 float bar = ((float)Person::players[0]->damage) / Person::players[0]->damagetolerance;
1085 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
1086 glVertex3f(1, 0, 0.0f);
1087 glVertex3f(1, 1, 0.0f);
1088 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
1090 glColor4f(0.1, 0.0, 0.0, 1);
1091 bar = ((float)Person::players[0]->bloodloss) / Person::players[0]->damagetolerance;
1093 glVertex3f(0, 0, 0.0f);
1094 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
1095 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
1096 glVertex3f(0, 1, 0.0f);
1098 glColor4f(0.4, 0.0, 0.0, 0.7);
1099 bar = ((float)Person::players[0]->damage) / Person::players[0]->damagetolerance;
1101 glVertex3f(0, 0, 0.0f);
1102 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
1103 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
1104 glVertex3f(0, 1, 0.0f);
1106 glColor4f(0.4, 0.0, 0.0, 0.7);
1107 bar = ((float)Person::players[0]->permanentdamage) / Person::players[0]->damagetolerance;
1109 glVertex3f(0, 0, 0.0f);
1110 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
1111 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
1112 glVertex3f(0, 1, 0.0f);
1114 glColor4f(0.4, 0.0, 0.0, 0.7);
1115 bar = ((float)Person::players[0]->superpermanentdamage) / Person::players[0]->damagetolerance;
1117 glVertex3f(0, 0, 0.0f);
1118 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
1119 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
1120 glVertex3f(0, 1, 0.0f);
1122 glColor4f(0.0, 0.0, 0.0, 0.7);
1124 glBegin(GL_LINE_STRIP);
1125 glVertex3f(0, 0, 0.0f);
1126 glVertex3f(1, 0, 0.0f);
1127 glVertex3f(1, 1, 0.0f);
1128 glVertex3f(0, 1, 0.0f);
1129 glVertex3f(0, 0, 0.0f);
1132 glMatrixMode(GL_PROJECTION);
1134 glMatrixMode(GL_MODELVIEW);
1136 glEnable(GL_DEPTH_TEST);
1137 glEnable(GL_CULL_FACE);
1138 glDisable(GL_BLEND);
1140 glEnable(GL_TEXTURE_2D);
1142 // writing the numbers :
1143 sprintf (string, "Damages : %d/%d (%d)", (int)(Person::players[0]->damage), (int)(Person::players[0]->damagetolerance), (int)(Person::players[0]->bloodloss));
1144 glColor4f(0, 0, 0, 1);
1145 text->glPrintOutline(1024 / 40 - 4, 768 / 16 - 4 + 768 * 14 / 16 - 40, string, 1, 1.5 * 1.25, 1024, 768);
1146 glColor4f(1, 0, 0, 1);
1147 text->glPrint(1024 / 40, 768 / 16 + 768 * 14 / 16 - 40, string, 1, 1.5, 1024, 768);
1151 glColor4f(.5, .5, .5, 1);
1154 if ((texttoggle || editorenabled) && devtools && !mainmenu) {
1155 sprintf (string, "The framespersecond is %d.", (int)(fps));
1156 text->glPrint(10, 30, string, 0, .8, 1024, 768);
1159 sprintf (string, "Map editor enabled.");
1161 sprintf (string, "Map editor disabled.");
1162 text->glPrint(10, 60, string, 0, .8, 1024, 768);
1163 if (editorenabled) {
1164 sprintf (string, "Object size: %f", editorsize);
1165 text->glPrint(10, 75, string, 0, .8, 1024, 768);
1167 sprintf (string, "Object yaw: %f", editoryaw);
1169 sprintf (string, "Object yaw: Random");
1170 text->glPrint(10, 90, string, 0, .8, 1024, 768);
1171 if (editorpitch >= 0)
1172 sprintf (string, "Object pitch: %f", editorpitch);
1174 sprintf (string, "Object pitch: Random");
1175 text->glPrint(10, 105, string, 0, .8, 1024, 768);
1176 sprintf (string, "Object type: %d", editortype);
1177 text->glPrint(10, 120, string, 0, .8, 1024, 768);
1178 switch (editortype) {
1180 sprintf (string, "(box)");
1183 sprintf (string, "(tree)");
1186 sprintf (string, "(wall)");
1189 sprintf (string, "(weird)");
1192 sprintf (string, "(spike)");
1195 sprintf (string, "(rock)");
1198 sprintf (string, "(bush)");
1201 sprintf (string, "(tunnel)");
1204 sprintf (string, "(chimney)");
1207 sprintf (string, "(platform)");
1210 sprintf (string, "(cool)");
1213 sprintf (string, "(fire)");
1216 text->glPrint(130, 120, string, 0, .8, 1024, 768);
1218 sprintf (string, "Numplayers: %lu", Person::players.size());
1219 text->glPrint(10, 155, string, 0, .8, 1024, 768);
1220 sprintf (string, "Player %d: numwaypoints: %d", (int(Person::players.size()) - 1), Person::players.back()->numwaypoints);
1221 text->glPrint(10, 140, string, 0, .8, 1024, 768);
1223 sprintf (string, "Difficulty: %d", difficulty);
1224 text->glPrint(10, 240, string, 0, .8, 1024, 768);
1229 if (drawmode == glowmode) {
1230 glDisable(GL_DEPTH_TEST);
1231 glDisable(GL_CULL_FACE);
1232 glDisable(GL_LIGHTING);
1233 glDisable(GL_TEXTURE_2D);
1235 glMatrixMode(GL_PROJECTION);
1238 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1239 glMatrixMode(GL_MODELVIEW);
1242 glScalef(screenwidth, screenheight, 1);
1243 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1245 glColor4f(0, 0, 0, .5);
1247 glVertex3f(0, 0, 0.0f);
1248 glVertex3f(256, 0, 0.0f);
1249 glVertex3f(256, 256, 0.0f);
1250 glVertex3f(0, 256, 0.0f);
1252 glMatrixMode(GL_PROJECTION);
1254 glMatrixMode(GL_MODELVIEW);
1256 glEnable(GL_DEPTH_TEST);
1257 glEnable(GL_CULL_FACE);
1258 glDisable(GL_BLEND);
1262 if ((((blackout && damageeffects) || (Person::players[0]->bloodloss > 0 && damageeffects && Person::players[0]->blooddimamount > 0) || Person::players[0]->dead) && !cameramode) || console) {
1263 glDisable(GL_DEPTH_TEST);
1264 glDisable(GL_CULL_FACE);
1265 glDisable(GL_LIGHTING);
1266 glDisable(GL_TEXTURE_2D);
1268 glMatrixMode(GL_PROJECTION);
1271 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1272 glMatrixMode(GL_MODELVIEW);
1275 glScalef(screenwidth, screenheight, 1);
1276 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1278 if (Person::players[0]->dead)
1279 blackout += multiplier * 3;
1280 if (Person::players[0]->dead == 1)
1282 if (Person::players[0]->dead == 2 && blackout > .6)
1284 glColor4f(0, 0, 0, blackout);
1285 if (!Person::players[0]->dead) {
1286 if ((Person::players[0]->bloodloss / Person::players[0]->damagetolerance * (sin(woozy) / 4 + .5))*.3 < .3) {
1287 glColor4f(0, 0, 0, Person::players[0]->blooddimamount * Person::players[0]->bloodloss / Person::players[0]->damagetolerance * (sin(woozy) / 4 + .5)*.3);
1288 blackout = Person::players[0]->blooddimamount * Person::players[0]->bloodloss / Person::players[0]->damagetolerance * (sin(woozy) / 4 + .5) * .3;
1290 glColor4f(0, 0, 0, Person::players[0]->blooddimamount * .3);
1291 blackout = Person::players[0]->blooddimamount * .3;
1295 glColor4f(.7, 0, 0, .2);
1297 glVertex3f(0, 0, 0.0f);
1298 glVertex3f(256, 0, 0.0f);
1299 glVertex3f(256, 256, 0.0f);
1300 glVertex3f(0, 256, 0.0f);
1302 glMatrixMode(GL_PROJECTION);
1304 glMatrixMode(GL_MODELVIEW);
1306 glEnable(GL_DEPTH_TEST);
1307 glEnable(GL_CULL_FACE);
1308 glDisable(GL_BLEND);
1312 if (flashamount > 0 && damageeffects) {
1313 if (flashamount > 1)
1315 if (flashdelay <= 0)
1316 flashamount -= multiplier;
1318 if (flashamount < 0)
1320 glDisable(GL_DEPTH_TEST);
1321 glDisable(GL_CULL_FACE);
1322 glDisable(GL_LIGHTING);
1324 glMatrixMode(GL_PROJECTION);
1327 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1328 glMatrixMode(GL_MODELVIEW);
1331 glScalef(screenwidth, screenheight, 1);
1332 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1334 glColor4f(flashr, flashg, flashb, flashamount);
1336 glVertex3f(0, 0, 0.0f);
1337 glVertex3f(256, 0, 0.0f);
1338 glVertex3f(256, 256, 0.0f);
1339 glVertex3f(0, 256, 0.0f);
1341 glMatrixMode(GL_PROJECTION);
1343 glMatrixMode(GL_MODELVIEW);
1345 glEnable(GL_DEPTH_TEST);
1346 glEnable(GL_CULL_FACE);
1347 glDisable(GL_BLEND);
1353 glEnable(GL_TEXTURE_2D);
1354 glColor4f(1, 1, 1, 1);
1355 for (unsigned i = 1; i < 15; i++)
1356 if (displaytime[i] < 4)
1357 for (unsigned j = 0; j < displaytext[i].size(); j++) {
1358 glColor4f(1, 1, 1, 4 - displaytime[i]);
1359 sprintf (string, "%c", displaytext[i][j]);
1360 text->glPrint(30 + j * 10, 30 + i * 20 + (screenheight - 330), string, 0, 1, screenwidth, screenheight);
1364 if (difficulty < 2 && !Dialog::inDialog()) { // minimap
1365 float mapviewdist = 20000;
1367 glDisable(GL_DEPTH_TEST);
1368 glColor3f (1.0, 1.0, 1.0); // no coloring
1370 glEnable(GL_TEXTURE_2D);
1371 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1372 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1373 glDisable(GL_DEPTH_TEST);
1374 glDisable(GL_CULL_FACE);
1375 glDisable(GL_LIGHTING);
1377 glMatrixMode(GL_PROJECTION);
1380 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1381 glMatrixMode(GL_MODELVIEW);
1384 glScalef((float)screenwidth / 2, (float)screenwidth / 2, 1);
1385 glTranslatef(1.75, .25, 0);
1386 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1388 glColor4f(1, 1, 1, 1);
1395 center = Person::players[0]->coords;
1399 glScalef(.25 / radius * 256 * terrain.scale * .4, .25 / radius * 256 * terrain.scale * .4, 1);
1401 glScalef(1 / (1 / radius * 256 * terrain.scale * .4), 1 / (1 / radius * 256 * terrain.scale * .4), 1);
1403 glRotatef(Person::players[0]->lookyaw * -1 + 180, 0, 0, 1);
1404 glTranslatef(-(center.x / terrain.scale / 256 * -2 + 1), (center.z / terrain.scale / 256 * -2 + 1), 0);
1405 for (int i = 0; i < objects.numobjects; i++) {
1406 if (objects.type[i] == treetrunktype) {
1407 distcheck = distsq(&Person::players[0]->coords, &objects.position[i]);
1408 if (distcheck < mapviewdist) {
1409 Mapcircletexture.bind();
1410 glColor4f(0, .3, 0, opac * (1 - distcheck / mapviewdist));
1412 glTranslatef(objects.position[i].x / terrain.scale / 256 * -2 + 1, objects.position[i].z / terrain.scale / 256 * 2 - 1, 0);
1413 glRotatef(objects.yaw[i], 0, 0, 1);
1414 glScalef(.003, .003, .003);
1417 glVertex3f(-1, -1, 0.0f);
1419 glVertex3f(1, -1, 0.0f);
1421 glVertex3f(1, 1, 0.0f);
1423 glVertex3f(-1, 1, 0.0f);
1428 if (objects.type[i] == boxtype) {
1429 distcheck = distsq(&Person::players[0]->coords, &objects.position[i]);
1430 if (distcheck < mapviewdist) {
1431 Mapboxtexture.bind();
1432 glColor4f(.4, .4, .4, opac * (1 - distcheck / mapviewdist));
1434 glTranslatef(objects.position[i].x / terrain.scale / 256 * -2 + 1, objects.position[i].z / terrain.scale / 256 * 2 - 1, 0);
1435 glRotatef(objects.yaw[i], 0, 0, 1);
1436 glScalef(.01 * objects.scale[i], .01 * objects.scale[i], .01 * objects.scale[i]);
1439 glVertex3f(-1, -1, 0.0f);
1441 glVertex3f(1, -1, 0.0f);
1443 glVertex3f(1, 1, 0.0f);
1445 glVertex3f(-1, 1, 0.0f);
1451 if (editorenabled) {
1452 Mapcircletexture.bind();
1453 for (int i = 0; i < numboundaries; i++) {
1454 glColor4f(0, 0, 0, opac / 3);
1456 glTranslatef(boundary[i].x / terrain.scale / 256 * -2 + 1, boundary[i].z / terrain.scale / 256 * 2 - 1, 0);
1457 glScalef(.002, .002, .002);
1460 glVertex3f(-1, -1, 0.0f);
1462 glVertex3f(1, -1, 0.0f);
1464 glVertex3f(1, 1, 0.0f);
1466 glVertex3f(-1, 1, 0.0f);
1471 for (unsigned i = 0; i < Person::players.size(); i++) {
1472 distcheck = distsq(&Person::players[0]->coords, &Person::players[i]->coords);
1473 if (distcheck < mapviewdist) {
1475 Maparrowtexture.bind();
1477 glColor4f(1, 1, 1, opac);
1478 else if (Person::players[i]->dead == 2 || Person::players[i]->howactive > typesleeping)
1479 glColor4f(0, 0, 0, opac * (1 - distcheck / mapviewdist));
1480 else if (Person::players[i]->dead)
1481 glColor4f(.3, .3, .3, opac * (1 - distcheck / mapviewdist));
1482 else if (Person::players[i]->aitype == attacktypecutoff)
1483 glColor4f(1, 0, 0, opac * (1 - distcheck / mapviewdist));
1484 else if (Person::players[i]->aitype == passivetype)
1485 glColor4f(0, 1, 0, opac * (1 - distcheck / mapviewdist));
1487 glColor4f(1, 1, 0, 1);
1488 glTranslatef(Person::players[i]->coords.x / terrain.scale / 256 * -2 + 1, Person::players[i]->coords.z / terrain.scale / 256 * 2 - 1, 0);
1489 glRotatef(Person::players[i]->yaw + 180, 0, 0, 1);
1490 glScalef(.005, .005, .005);
1493 glVertex3f(-1, -1, 0.0f);
1495 glVertex3f(1, -1, 0.0f);
1497 glVertex3f(1, 1, 0.0f);
1499 glVertex3f(-1, 1, 0.0f);
1505 glDisable(GL_TEXTURE_2D);
1506 glMatrixMode(GL_PROJECTION);
1508 glMatrixMode(GL_MODELVIEW);
1510 glEnable(GL_DEPTH_TEST);
1511 glEnable(GL_CULL_FACE);
1512 glDisable(GL_BLEND);
1516 if (loading && !stealthloading && (!campaign || Person::players[0]->dead)) {
1517 glDisable(GL_DEPTH_TEST);
1518 glDisable(GL_CULL_FACE);
1519 glDisable(GL_LIGHTING);
1520 glDisable(GL_TEXTURE_2D);
1522 glMatrixMode(GL_PROJECTION);
1525 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1526 glMatrixMode(GL_MODELVIEW);
1529 glScalef(screenwidth, screenheight, 1);
1530 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1532 glColor4f(0, 0, 0, .7);
1534 glVertex3f(0, 0, 0.0f);
1535 glVertex3f(256, 0, 0.0f);
1536 glVertex3f(256, 256, 0.0f);
1537 glVertex3f(0, 256, 0.0f);
1539 glMatrixMode(GL_PROJECTION);
1541 glMatrixMode(GL_MODELVIEW);
1543 glEnable(GL_DEPTH_TEST);
1544 glEnable(GL_CULL_FACE);
1545 glDisable(GL_BLEND);
1549 glDisable(GL_DEPTH_TEST);
1550 glColor3f (1.0, 1.0, 1.0); // no coloring
1552 glEnable(GL_TEXTURE_2D);
1557 glEnable(GL_TEXTURE_2D);
1558 glColor4f(1, 1, 1, 1);
1559 sprintf (string, "Loading...");
1560 text->glPrint(1024 / 2 - 90, 768 / 2, string, 1, 2, 1024, 768);
1563 drawmode = normalmode;
1566 if (winfreeze && !campaign) {
1567 glDisable(GL_DEPTH_TEST);
1568 glDisable(GL_CULL_FACE);
1569 glDisable(GL_LIGHTING);
1570 glDisable(GL_TEXTURE_2D);
1572 glMatrixMode(GL_PROJECTION);
1575 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1576 glMatrixMode(GL_MODELVIEW);
1579 glScalef(screenwidth, screenheight, 1);
1580 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1582 glColor4f(0, 0, 0, .4);
1584 glVertex3f(0, 0, 0.0f);
1585 glVertex3f(256, 0, 0.0f);
1586 glVertex3f(256, 256, 0.0f);
1587 glVertex3f(0, 256, 0.0f);
1589 glMatrixMode(GL_PROJECTION);
1591 glMatrixMode(GL_MODELVIEW);
1593 glEnable(GL_DEPTH_TEST);
1594 glEnable(GL_CULL_FACE);
1595 glDisable(GL_BLEND);
1599 glDisable(GL_DEPTH_TEST);
1600 glColor3f (1.0, 1.0, 1.0); // no coloring
1602 glEnable(GL_TEXTURE_2D);
1604 //Win Screen Won Victory
1606 glEnable(GL_TEXTURE_2D);
1607 glColor4f(1, 1, 1, 1);
1608 sprintf (string, "Level Cleared!");
1609 text->glPrintOutlined(1024 / 2 - strlen(string) * 10, 768 * 7 / 8, string, 1, 2, 1024, 768);
1611 sprintf (string, "Score: %d", (int)(bonustotal - startbonustotal));
1612 text->glPrintOutlined(1024 / 30, 768 * 6 / 8, string, 1, 2, 1024, 768);
1614 sprintf (string, "Press Escape to return to menu or Space to continue");
1615 text->glPrintOutlined(640 / 2 - strlen(string) * 5, 480 * 1 / 16, string, 1, 1, 640, 480);
1619 for (int i = 0; i < 255; i++)
1621 int wontime = (int)round(wonleveltime);
1622 sprintf (temp, "Time: %d:", int((wontime - wontime % 60) / 60));
1623 strcat(string, temp);
1624 if (wontime % 60 < 10)
1625 strcat(string, "0");
1626 sprintf (temp, "%d", wontime % 60);
1627 strcat(string, temp);
1628 text->glPrintOutlined(1024 / 30, 768 * 6 / 8 - 40, string, 1, 2, 1024, 768);
1631 int awards[award_count];
1632 int numawards = award_awards(awards);
1634 for (int i = 0; i < numawards && i < 6; i++)
1635 text->glPrintOutlined(1024 / 30, 768 * 6 / 8 - 90 - 40 * i, award_names[awards[i]], 1, 2, 1024, 768);
1638 if (drawmode != normalmode) {
1639 glEnable(GL_TEXTURE_2D);
1641 if (!drawtoggle || drawmode != realmotionblurmode || (drawtoggle == 2 || change == 1)) {
1642 if (screentexture) {
1644 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
1645 GLfloat subtractColor[4] = { 0.5, 0.5, 0.5, 0.0 };
1646 glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, subtractColor);
1647 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE);
1648 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_CONSTANT_EXT);
1649 glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 2.0f);
1651 glBindTexture( GL_TEXTURE_2D, screentexture);
1652 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1655 if ((drawtoggle || change == 1) && drawmode == realmotionblurmode) {
1656 if (screentexture2) {
1657 glBindTexture( GL_TEXTURE_2D, screentexture2);
1658 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1660 if (!screentexture2) {
1661 glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
1663 glGenTextures( 1, &screentexture2 );
1664 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
1666 glEnable(GL_TEXTURE_2D);
1667 glBindTexture( GL_TEXTURE_2D, screentexture2);
1668 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
1669 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
1671 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
1676 glClear(GL_DEPTH_BUFFER_BIT);
1677 Game::ReSizeGLScene(90, .1f);
1678 glViewport(0, 0, screenwidth, screenheight);
1680 if (drawmode != normalmode) {
1681 glDisable(GL_DEPTH_TEST);
1682 if (drawmode == motionblurmode) {
1683 glDrawBuffer(GL_FRONT);
1684 glReadBuffer(GL_BACK);
1686 glColor3f (1.0, 1.0, 1.0); // no coloring
1688 glEnable(GL_TEXTURE_2D);
1689 glBindTexture( GL_TEXTURE_2D, screentexture);
1690 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1691 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1692 glDisable(GL_DEPTH_TEST);
1693 glDisable(GL_CULL_FACE);
1694 glDisable(GL_LIGHTING);
1696 glMatrixMode(GL_PROJECTION);
1699 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1700 glMatrixMode(GL_MODELVIEW);
1703 glScalef((float)screenwidth / 2, (float)screenheight / 2, 1);
1704 glTranslatef(1, 1, 0);
1705 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1707 if (drawmode == motionblurmode) {
1708 if (motionbluramount < .2)
1709 motionbluramount = .2;
1710 glColor4f(1, 1, 1, motionbluramount);
1714 glVertex3f(-1, -1, 0.0f);
1715 glTexCoord2f(texcoordwidth, 0);
1716 glVertex3f(1, -1, 0.0f);
1717 glTexCoord2f(texcoordwidth, texcoordheight);
1718 glVertex3f(1, 1, 0.0f);
1719 glTexCoord2f(0, texcoordheight);
1720 glVertex3f(-1, 1, 0.0f);
1724 if (drawmode == realmotionblurmode) {
1725 glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
1726 glClear(GL_COLOR_BUFFER_BIT);
1727 glBlendFunc(GL_SRC_ALPHA, GL_ONE);
1728 glBindTexture( GL_TEXTURE_2D, screentexture);
1729 glColor4f(1, 1, 1, .5);
1733 glVertex3f(-1, -1, 0.0f);
1734 glTexCoord2f(texcoordwidth, 0);
1735 glVertex3f(1, -1, 0.0f);
1736 glTexCoord2f(texcoordwidth, texcoordheight);
1737 glVertex3f(1, 1, 0.0f);
1738 glTexCoord2f(0, texcoordheight);
1739 glVertex3f(-1, 1, 0.0f);
1742 glBindTexture( GL_TEXTURE_2D, screentexture2);
1743 glColor4f(1, 1, 1, .5);
1747 glVertex3f(-1, -1, 0.0f);
1748 glTexCoord2f(texcoordwidth, 0);
1749 glVertex3f(1, -1, 0.0f);
1750 glTexCoord2f(texcoordwidth, texcoordheight);
1751 glVertex3f(1, 1, 0.0f);
1752 glTexCoord2f(0, texcoordheight);
1753 glVertex3f(-1, 1, 0.0f);
1756 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1758 if (drawmode == doublevisionmode) {
1759 static float crosseyedness;
1760 crosseyedness = abs(Person::players[0]->damage - Person::players[0]->superpermanentdamage - (Person::players[0]->damagetolerance - Person::players[0]->superpermanentdamage) * 1 / 2) / 30;
1761 if (crosseyedness > 1)
1763 if (crosseyedness < 0)
1765 glColor4f(1, 1, 1, 1);
1766 glDisable(GL_BLEND);
1771 glVertex3f(-1, -1, 0.0f);
1772 glTexCoord2f(texcoordwidth, 0);
1773 glVertex3f(1, -1, 0.0f);
1774 glTexCoord2f(texcoordwidth, texcoordheight);
1775 glVertex3f(1, 1, 0.0f);
1776 glTexCoord2f(0, texcoordheight);
1777 glVertex3f(-1, 1, 0.0f);
1780 if (crosseyedness) {
1781 glColor4f(1, 1, 1, .5);
1784 glTranslatef(.015 * crosseyedness, 0, 0);
1788 glVertex3f(-1, -1, 0.0f);
1789 glTexCoord2f(texcoordwidth, 0);
1790 glVertex3f(1, -1, 0.0f);
1791 glTexCoord2f(texcoordwidth, texcoordheight);
1792 glVertex3f(1, 1, 0.0f);
1793 glTexCoord2f(0, texcoordheight);
1794 glVertex3f(-1, 1, 0.0f);
1799 if (drawmode == glowmode) {
1800 glColor4f(.5, .5, .5, .5);
1802 glBlendFunc(GL_SRC_ALPHA, GL_ONE);
1804 glTranslatef(.01, 0, 0);
1807 glVertex3f(-1, -1, 0.0f);
1808 glTexCoord2f(texcoordwidth, 0);
1809 glVertex3f(1, -1, 0.0f);
1810 glTexCoord2f(texcoordwidth, texcoordheight);
1811 glVertex3f(1, 1, 0.0f);
1812 glTexCoord2f(0, texcoordheight);
1813 glVertex3f(-1, 1, 0.0f);
1817 glTranslatef(-.01, 0, 0);
1820 glVertex3f(-1, -1, 0.0f);
1821 glTexCoord2f(texcoordwidth, 0);
1822 glVertex3f(1, -1, 0.0f);
1823 glTexCoord2f(texcoordwidth, texcoordheight);
1824 glVertex3f(1, 1, 0.0f);
1825 glTexCoord2f(0, texcoordheight);
1826 glVertex3f(-1, 1, 0.0f);
1830 glTranslatef(.0, .01, 0);
1833 glVertex3f(-1, -1, 0.0f);
1834 glTexCoord2f(texcoordwidth, 0);
1835 glVertex3f(1, -1, 0.0f);
1836 glTexCoord2f(texcoordwidth, texcoordheight);
1837 glVertex3f(1, 1, 0.0f);
1838 glTexCoord2f(0, texcoordheight);
1839 glVertex3f(-1, 1, 0.0f);
1843 glTranslatef(0, -.01, 0);
1846 glVertex3f(-1, -1, 0.0f);
1847 glTexCoord2f(texcoordwidth, 0);
1848 glVertex3f(1, -1, 0.0f);
1849 glTexCoord2f(texcoordwidth, texcoordheight);
1850 glVertex3f(1, 1, 0.0f);
1851 glTexCoord2f(0, texcoordheight);
1852 glVertex3f(-1, 1, 0.0f);
1856 if (drawmode == radialzoommode) {
1857 for (int i = 0; i < 3; i++) {
1858 glColor4f(1, 1, 1, 1 / ((float)i + 1));
1860 glScalef(1 + (float)i * .01, 1 + (float)i * .01, 1);
1863 glVertex3f(-1, -1, 0.0f);
1864 glTexCoord2f(texcoordwidth, 0);
1865 glVertex3f(1, -1, 0.0f);
1866 glTexCoord2f(texcoordwidth, texcoordheight);
1867 glVertex3f(1, 1, 0.0f);
1868 glTexCoord2f(0, texcoordheight);
1869 glVertex3f(-1, 1, 0.0f);
1874 glDisable(GL_TEXTURE_2D);
1875 glMatrixMode(GL_PROJECTION);
1877 glMatrixMode(GL_MODELVIEW);
1879 glEnable(GL_DEPTH_TEST);
1880 glEnable(GL_CULL_FACE);
1881 glDisable(GL_BLEND);
1886 glEnable(GL_TEXTURE_2D);
1887 glColor4f(1, 1, 1, 1);
1889 if (consoleselected >= 60)
1890 offset = consoleselected - 60;
1891 sprintf (string, " ]");
1892 text->glPrint(10, 30, string, 0, 1, 1024, 768);
1894 sprintf (string, "_");
1895 text->glPrint(30 + (float)(consoleselected) * 10 - offset * 10, 30, string, 0, 1, 1024, 768);
1897 for (unsigned i = 0; i < 15; i++)
1898 for (unsigned j = 0; j < consoletext[i].size(); j++) {
1899 glColor4f(1, 1, 1, 1 - (float)(i) / 16);
1900 sprintf (string, "%c", consoletext[i][j]);
1901 text->glPrint(30 + j * 10 - offset * 10, 30 + i * 20, string, 0, 1, 1024, 768);
1906 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted)) {
1907 multiplier = tempmult;
1914 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted)) {
1915 tempmult = multiplier;
1919 if ( side == stereoRight || side == stereoCenter ) {
1920 if (drawmode != motionblurmode || mainmenu) {
1925 glDrawBuffer(GL_BACK);
1926 glReadBuffer(GL_BACK);
1930 if (drawtoggle == 2)
1933 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted)) {
1934 multiplier = tempmult;
1936 //Jordan fixed your warning!
1942 // !!! FIXME: hack: clamp framerate in menu so text input works correctly on fast systems.
1945 glDrawBuffer(GL_BACK);
1946 glReadBuffer(GL_BACK);
1947 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
1948 Game::ReSizeGLScene(90, .1f);
1950 //draw menu background
1951 glClear(GL_DEPTH_BUFFER_BIT);
1952 glEnable(GL_ALPHA_TEST);
1953 glAlphaFunc(GL_GREATER, 0.001f);
1954 glEnable(GL_TEXTURE_2D);
1955 glDisable(GL_DEPTH_TEST);
1956 glDisable(GL_CULL_FACE);
1957 glDisable(GL_LIGHTING);
1959 glMatrixMode(GL_PROJECTION);
1962 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1963 glMatrixMode(GL_MODELVIEW);
1966 glTranslatef(screenwidth / 2, screenheight / 2, 0);
1968 glScalef((float)screenwidth / 2, (float)screenheight / 2, 1);
1969 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1970 glDisable(GL_BLEND);
1971 glColor4f(0, 0, 0, 1.0);
1972 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
1973 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
1974 glDisable(GL_TEXTURE_2D);
1976 glVertex3f(-1, -1, 0);
1977 glVertex3f(+1, -1, 0);
1978 glVertex3f(+1, +1, 0);
1979 glVertex3f(-1, +1, 0);
1982 glColor4f(0.4, 0.4, 0.4, 1.0);
1983 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
1984 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
1985 glEnable(GL_TEXTURE_2D);
1986 Game::Mainmenuitems[4].bind();
1989 glVertex3f(-1, -1, 0);
1991 glVertex3f(+1, -1, 0);
1993 glVertex3f(+1, +1, 0);
1995 glVertex3f(-1, +1, 0);
1999 glMatrixMode(GL_PROJECTION);
2001 glMatrixMode(GL_MODELVIEW);
2005 glMatrixMode(GL_PROJECTION);
2008 glOrtho(0, 640, 0, 480, -100, 100);
2009 glMatrixMode(GL_MODELVIEW);
2012 glEnable(GL_TEXTURE_2D);
2017 glMatrixMode(GL_PROJECTION);
2019 glMatrixMode(GL_MODELVIEW);
2022 glMatrixMode(GL_PROJECTION);
2025 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
2026 glMatrixMode(GL_MODELVIEW);
2029 glTranslatef(screenwidth / 2, screenheight / 2, 0);
2031 glScalef((float)screenwidth / 2, (float)screenheight / 2, 1);
2032 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
2034 glEnable(GL_TEXTURE_2D);
2035 glColor4f(1, 1, 1, 1);
2036 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2037 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2039 if (!Game::waiting) { // hide the cursor while waiting for a key
2041 glTranslatef(Game::mousecoordh - screenwidth / 2, Game::mousecoordv * -1 + screenheight / 2, 0);
2042 glScalef((float)screenwidth / 64, (float)screenwidth / 64, 1);
2043 glTranslatef(1, -1, 0);
2044 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
2045 glColor4f(1, 1, 1, 1);
2046 Game::cursortexture.bind();
2050 glVertex3f(-1, -1, 0.0f);
2052 glVertex3f(1, -1, 0.0f);
2054 glVertex3f(1, 1, 0.0f);
2056 glVertex3f(-1, 1, 0.0f);
2062 glMatrixMode(GL_PROJECTION);
2067 if (flashamount > 0) {
2068 if (flashamount > 1)
2070 if (flashdelay <= 0)
2071 flashamount -= multiplier;
2073 if (flashamount < 0)
2075 glDisable(GL_DEPTH_TEST);
2076 glDisable(GL_CULL_FACE);
2077 glDisable(GL_LIGHTING);
2078 glDisable(GL_TEXTURE_2D);
2080 glMatrixMode(GL_PROJECTION);
2083 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
2084 glMatrixMode(GL_MODELVIEW);
2087 glScalef(screenwidth, screenheight, 1);
2088 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
2090 glColor4f(flashr, flashg, flashb, flashamount);
2092 glVertex3f(0, 0, 0.0f);
2093 glVertex3f(256, 0, 0.0f);
2094 glVertex3f(256, 256, 0.0f);
2095 glVertex3f(0, 256, 0.0f);
2097 glMatrixMode(GL_PROJECTION);
2099 glMatrixMode(GL_MODELVIEW);
2101 glEnable(GL_DEPTH_TEST);
2102 glEnable(GL_CULL_FACE);
2103 glDisable(GL_BLEND);