2 Copyright (C) 2003, 2010 - Wolfire Games
3 Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
5 This file is part of Lugaru.
7 Lugaru is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 Lugaru is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
22 #include "openal_wrapper.h"
28 extern int environment;
29 extern float texscale;
31 extern Terrain terrain;
32 extern float multiplier;
33 extern float viewdistance;
34 extern float fadestart;
35 extern float screenwidth, screenheight;
36 extern int kTextureSize;
37 extern FRUSTUM frustum;
39 extern Objects objects;
41 extern float usermousesensitivity;
42 extern float camerashake;
44 extern float slomodelay;
45 extern bool ismotionblur;
47 extern float blackout;
48 extern bool damageeffects;
50 extern bool texttoggle;
51 extern float blurness;
52 extern float targetblurness;
53 extern float playerdist;
54 extern bool cellophane;
56 extern float flashamount, flashr, flashg, flashb;
57 extern int flashdelay;
59 extern float motionbluramount;
61 extern bool alwaysblur;
62 extern bool velocityblur;
63 extern bool debugmode;
65 extern int bloodtoggle;
66 extern int difficulty;
68 extern float texdetail;
69 extern bool musictoggle;
70 extern int tutoriallevel;
71 extern float smoketex;
72 extern float tutorialstagetime;
73 extern float tutorialmaxtime;
74 extern int tutorialstage;
75 extern bool againbonus;
76 extern float damagedealt;
77 extern bool invertmouse;
79 extern int numhotspots;
80 extern int killhotspot;
81 extern XYZ hotspot[40];
82 extern int hotspottype[40];
83 extern float hotspotsize[40];
84 extern char hotspottext[40][256];
85 extern int currenthotspot;;
88 extern bool winfreeze;
90 extern bool gamestart;
92 extern bool gamestarted;
94 extern bool showdamagebar;
99 int numboundaries = 0;
106 normalmode, motionblurmode, radialzoommode,
107 realmotionblurmode, doublevisionmode, glowmode,
110 void Game::flash(float amount, int delay) // shouldn't be that way, these should be attributes and Person class should not change rendering.
115 flashamount = amount;
121 /*********************> DrawGLScene() <*****/
122 int Game::DrawGLScene(StereoSide side)
124 static float texcoordwidth, texcoordheight;
125 static float texviewwidth, texviewheight;
127 static XYZ checkpoint;
128 static float tempmult;
130 static char string[256] = "";
131 static char string2[256] = "";
132 static char string3[256] = "";
133 static int drawmode = 0;
135 if ( stereomode == stereoAnaglyph ) {
138 glColorMask( 0.0, 1.0, 1.0, 1.0 );
141 glColorMask( 1.0, 0.0, 0.0, 1.0 );
147 glColorMask( 1.0, 1.0, 1.0, 1.0 );
149 if ( stereomode == stereoHorizontalInterlaced || stereomode == stereoVerticalInterlaced ) {
150 glStencilFunc(side == stereoLeft ? GL_NOTEQUAL : GL_EQUAL, 0x01, 0x01);
154 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted)) {
155 tempmult = multiplier;
161 numboundaries = mapradius * 2;
162 if (numboundaries > 360)
164 for (int i = 0; i < numboundaries; i++) {
167 boundary[i] = mapcenter + DoRotation(boundary[i] * mapradius, 0, i * (360 / ((float)(numboundaries))), 0);
176 int olddrawmode = drawmode;
177 if (ismotionblur && !loading) {
178 if ((findLengthfast(&Person::players[0]->velocity) > 200) && velocityblur && !cameramode) {
179 drawmode = motionblurmode;
180 motionbluramount = 200 / (findLengthfast(&Person::players[0]->velocity));
183 if (Person::players[0]->damage - Person::players[0]->superpermanentdamage > (Person::players[0]->damagetolerance - Person::players[0]->superpermanentdamage) * 1 / 2 && damageeffects && !cameramode) {
184 drawmode = doublevisionmode;
189 if (slomo && !loading) {
191 drawmode = motionblurmode;
192 motionbluramount = .2;
193 slomodelay -= multiplier;
199 if ((!changed && !slomo) || loading) {
200 drawmode = normalmode;
201 if (ismotionblur && (/*fps>100||*/alwaysblur)) {
202 if (olddrawmode != realmotionblurmode)
206 drawmode = realmotionblurmode;
207 } else if (olddrawmode == realmotionblurmode)
213 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted))
214 drawmode = normalmode;
215 if ((freeze || winfreeze) && ismotionblur && !mainmenu)
216 drawmode = radialzoommode;
218 if (winfreeze || mainmenu)
219 drawmode = normalmode;
222 drawtoggle = 1 - drawtoggle;
224 if (!texcoordwidth) {
225 texviewwidth = kTextureSize;
226 if (texviewwidth > screenwidth)
227 texviewwidth = screenwidth;
228 texviewheight = kTextureSize;
229 if (texviewheight > screenheight)
230 texviewheight = screenheight;
232 texcoordwidth = screenwidth / kTextureSize;
233 texcoordheight = screenheight / kTextureSize;
234 if (texcoordwidth > 1)
236 if (texcoordheight > 1)
240 glDrawBuffer(GL_BACK);
241 glReadBuffer(GL_BACK);
243 static XYZ terrainlight;
244 static float distance;
245 if (drawmode == normalmode)
246 Game::ReSizeGLScene(90, .1f);
247 if (drawmode != normalmode)
248 glViewport(0, 0, texviewwidth, texviewheight);
249 glDepthFunc(GL_LEQUAL);
251 glAlphaFunc(GL_GREATER, 0.0001f);
252 glEnable(GL_ALPHA_TEST);
253 glClearColor(0.25f, 0.25f, 0.25f, 1.0f);
254 glClear(GL_DEPTH_BUFFER_BIT);
256 glMatrixMode (GL_MODELVIEW);
257 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
260 // Move the camera for the current eye's point of view.
261 // Reverse the movement if we're reversing stereo
262 glTranslatef((stereoseparation / 2) * side * (stereoreverse ? -1 : 1), 0, 0);
265 if (!cameramode && !freeze && !winfreeze) {
267 glRotatef(float(Random() % 100) / 10 * camerashake/*+(woozy*woozy)/10*/, 0, 0, 1);
269 glRotatef(pitch + sin(woozy / 2) * (Person::players[0]->damage / Person::players[0]->damagetolerance) * 5, 1, 0, 0);
270 glRotatef(yaw + sin(woozy) * (Person::players[0]->damage / Person::players[0]->damagetolerance) * 5, 0, 1, 0);
272 if (cameramode || freeze || winfreeze) {
273 glRotatef(pitch, 1, 0, 0);
274 glRotatef(yaw, 0, 1, 0);
277 if (environment == desertenvironment) {
278 glRotatef((float)(abs(Random() % 100)) / 3000 - 1, 1, 0, 0);
279 glRotatef((float)(abs(Random() % 100)) / 3000 - 1, 0, 1, 0);
281 SetUpLight(&light, 0);
284 //heat blur effect in desert
285 if (abs(blurness - targetblurness) < multiplier * 10 || abs(blurness - targetblurness) > 2) {
286 blurness = targetblurness;
287 targetblurness = (float)(abs(Random() % 100)) / 40;
289 if (blurness < targetblurness)
290 blurness += multiplier * 5;
292 blurness -= multiplier * 5;
294 if (environment == desertenvironment && detail == 2)
295 glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, blurness + .4 );
296 if (environment == desertenvironment) {
297 glRotatef((float)(abs(Random() % 100)) / 1000, 1, 0, 0);
298 glRotatef((float)(abs(Random() % 100)) / 1000, 0, 1, 0);
301 glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0);
303 glTranslatef(-viewer.x, -viewer.y, -viewer.z);
304 frustum.GetFrustum();
306 //make shadow decals on terrain and objects
308 static float size, opacity, rotation;
310 for (unsigned k = 0; k < Person::players.size(); k++) {
311 if (!Person::players[k]->skeleton.free && Person::players[k]->playerdetail && Person::players[k]->howactive < typesleeping)
312 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)
313 for (int i = 0; i < Person::players[k]->skeleton.num_joints; i++) {
314 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) {
315 point = DoRotation(Person::players[k]->skeleton.joints[i].position, 0, Person::players[k]->yaw, 0) * Person::players[k]->scale + Person::players[k]->coords;
317 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;
318 if (k != 0 && tutoriallevel == 1) {
319 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;
321 terrain.MakeDecal(shadowdecal, point, size, opacity, rotation);
322 for (l = 0; l < terrain.patchobjectnum[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz]; l++) {
323 int j = terrain.patchobjects[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz][l];
324 if (objects.position[j].y < Person::players[k]->coords.y || objects.type[j] == tunneltype || objects.type[j] == weirdtype) {
325 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);
328 if (k != 0 && tutoriallevel == 1) {
329 opacity = .2 + .2 * sin(smoketex * 6 + i);
331 objects.model[j].MakeDecal(shadowdecal, &point, &size, &opacity, &rotation);
336 if ((Person::players[k]->skeleton.free || Person::players[k]->howactive >= typesleeping) && Person::players[k]->playerdetail)
337 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)
338 for (int i = 0; i < Person::players[k]->skeleton.num_joints; i++) {
339 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) {
340 if (Person::players[k]->skeleton.free)
341 point = Person::players[k]->skeleton.joints[i].position * Person::players[k]->scale + Person::players[k]->coords;
343 point = DoRotation(Person::players[k]->skeleton.joints[i].position, 0, Person::players[k]->yaw, 0) * Person::players[k]->scale + Person::players[k]->coords;
345 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;
346 if (k != 0 && tutoriallevel == 1) {
347 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;
349 terrain.MakeDecal(shadowdecal, point, size, opacity * .7, rotation);
350 for (l = 0; l < terrain.patchobjectnum[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz]; l++) {
351 int j = terrain.patchobjects[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz][l];
352 if (objects.position[j].y < Person::players[k]->coords.y || objects.type[j] == tunneltype || objects.type[j] == weirdtype) {
353 if (Person::players[k]->skeleton.free)
354 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);
356 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);
359 if (k != 0 && tutoriallevel == 1) {
360 opacity = .2 + .2 * sin(smoketex * 6 + i);
362 objects.model[j].MakeDecal(shadowdecal, &point, &size, &opacity, &rotation);
368 if (!Person::players[k]->playerdetail)
369 if (frustum.SphereInFrustum(Person::players[k]->coords.x, Person::players[k]->coords.y, Person::players[k]->coords.z, Person::players[k]->scale * 5)) {
370 point = Person::players[k]->coords;
372 opacity = .4 - (Person::players[k]->coords.y - terrain.getHeight(Person::players[k]->coords.x, Person::players[k]->coords.z)) / 5;
373 terrain.MakeDecal(shadowdecal, point, size, opacity * .7, rotation);
374 for (l = 0; l < terrain.patchobjectnum[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz]; l++) {
375 int j = terrain.patchobjects[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz][l];
376 point = DoRotation(Person::players[k]->coords - objects.position[j], 0, -objects.yaw[j], 0);
379 objects.model[j].MakeDecal(shadowdecal, &point, &size, &opacity, &rotation);
385 glEnable(GL_TEXTURE_2D);
387 glEnable(GL_DEPTH_TEST);
388 glEnable(GL_CULL_FACE);
390 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
391 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
392 terraintexture.bind();
394 terraintexture2.bind();
397 terrain.drawdecals();
400 glEnable(GL_CULL_FACE);
401 glEnable(GL_LIGHTING);
403 glEnable(GL_TEXTURE_2D);
406 glEnable(GL_COLOR_MATERIAL);
409 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
410 glEnable(GL_CULL_FACE);
411 glCullFace(GL_FRONT);
413 for (unsigned k = 0; k < Person::players.size(); k++) {
414 if (k == 0 || tutoriallevel != 1) {
416 glEnable(GL_LIGHTING);
417 terrainlight = terrain.getLighting(Person::players[k]->coords.x, Person::players[k]->coords.z);
418 distance = distsq(&viewer, &Person::players[k]->coords);
419 distance = (viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance;
420 glColor4f(terrainlight.x, terrainlight.y, terrainlight.z, distance);
423 if (distance >= .5) {
424 checkpoint = DoRotation(Person::players[k]->skeleton.joints[abs(Random() % Person::players[k]->skeleton.num_joints)].position, 0, Person::players[k]->yaw, 0) * Person::players[k]->scale + Person::players[k]->coords;
427 if (Person::players[k]->occluded != 0)
428 i = checkcollide(viewer, checkpoint, Person::players[k]->lastoccluded);
430 i = checkcollide(viewer, checkpoint);
432 Person::players[k]->occluded += 1;
433 Person::players[k]->lastoccluded = i;
435 Person::players[k]->occluded = 0;
437 if (Person::players[k]->occluded < 25)
438 Person::players[k]->DrawSkeleton();
444 if (!cameramode && musictype == stream_fighttheme)
445 playerdist = distsqflat(&Person::players[0]->coords, &viewer);
450 glEnable(GL_TEXTURE_2D);
456 if (frustum.SphereInFrustum(realhawkcoords.x + hawk.boundingspherecenter.x, realhawkcoords.y + hawk.boundingspherecenter.y, realhawkcoords.z + hawk.boundingspherecenter.z, 2)) {
457 glAlphaFunc(GL_GREATER, 0.0001f);
459 glDisable(GL_CULL_FACE);
460 glDisable(GL_LIGHTING);
462 glTranslatef(hawkcoords.x, hawkcoords.y, hawkcoords.z);
463 glRotatef(hawkyaw, 0, 1, 0);
464 glTranslatef(25, 0, 0);
465 distance = distsq(&viewer, &realhawkcoords) * 1.2;
466 glColor4f(light.color[0], light.color[1], light.color[2], (viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance);
467 if ((viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance > 1)
468 glColor4f(light.color[0], light.color[1], light.color[2], 1);
469 if ((viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance > 0)
470 hawk.drawdifftex(hawktexture);
474 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
475 glEnable(GL_CULL_FACE);
476 glCullFace(GL_FRONT);
478 for (unsigned k = 0; k < Person::players.size(); k++) {
479 if (!(k == 0 || tutoriallevel != 1)) {
481 glEnable(GL_LIGHTING);
482 terrainlight = terrain.getLighting(Person::players[k]->coords.x, Person::players[k]->coords.z);
483 distance = distsq(&viewer, &Person::players[k]->coords);
484 distance = (viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance;
485 glColor4f(terrainlight.x, terrainlight.y, terrainlight.z, distance);
488 if (distance >= .5) {
489 checkpoint = DoRotation(Person::players[k]->skeleton.joints[abs(Random() % Person::players[k]->skeleton.num_joints)].position, 0, Person::players[k]->yaw, 0) * Person::players[k]->scale + Person::players[k]->coords;
492 if (Person::players[k]->occluded != 0)
493 i = checkcollide(viewer, checkpoint, Person::players[k]->lastoccluded);
495 i = checkcollide(viewer, checkpoint);
497 Person::players[k]->occluded += 1;
498 Person::players[k]->lastoccluded = i;
500 Person::players[k]->occluded = 0;
502 if (Person::players[k]->occluded < 25)
503 Person::players[k]->DrawSkeleton();
509 glEnable(GL_TEXTURE_2D);
514 glDisable(GL_COLOR_MATERIAL);
516 glDisable(GL_LIGHTING);
517 glDisable(GL_TEXTURE_2D);
523 //waypoints, pathpoints in editor
526 glDisable(GL_LIGHTING);
527 glDisable(GL_TEXTURE_2D);
528 glDisable(GL_COLOR_MATERIAL);
529 glColor4f(1, 1, 0, 1);
531 for (unsigned k = 0; k < Person::players.size(); k++) {
532 if (Person::players[k]->numwaypoints > 1) {
533 glBegin(GL_LINE_LOOP);
534 for (int i = 0; i < Person::players[k]->numwaypoints; i++) {
535 glVertex3f(Person::players[k]->waypoints[i].x, Person::players[k]->waypoints[i].y + .5, Person::players[k]->waypoints[i].z);
542 if (numpathpoints > 1) {
543 glColor4f(0, 1, 0, 1);
544 for (unsigned k = 0; int(k) < numpathpoints; k++) {
545 if (numpathpointconnect[k]) {
546 for (int i = 0; i < numpathpointconnect[k]; i++) {
547 glBegin(GL_LINE_LOOP);
548 glVertex3f(pathpoint[k].x, pathpoint[k].y + .5, pathpoint[k].z);
549 glVertex3f(pathpoint[pathpointconnect[k][i]].x, pathpoint[pathpointconnect[k][i]].y + .5, pathpoint[pathpointconnect[k][i]].z);
554 glColor4f(1, 1, 1, 1);
557 glVertex3f(pathpoint[pathpointselected].x, pathpoint[pathpointselected].y + .5, pathpoint[pathpointselected].z);
564 glEnable(GL_TEXTURE_2D);
565 glColor4f(.5, .5, .5, 1);
568 if (bonus > 0 && bonustime < 1 && !winfreeze && indialogue == -1/*bonustime<4*/) {
569 const char *bonus_name;
570 if (bonus < bonus_count)
571 bonus_name = bonus_names[bonus];
573 bonus_name = "Excellent!"; // When does this happen?
575 glColor4f(0, 0, 0, 1 - bonustime);
576 text->glPrintOutline(1024 / 2 - 10 * strlen(bonus_name) - 4, 768 / 16 - 4 + 768 * 4 / 5, bonus_name, 1, 2.5, 1024, 768);
577 glColor4f(1, 0, 0, 1 - bonustime);
578 text->glPrint(1024 / 2 - 10 * strlen(bonus_name), 768 / 16 + 768 * 4 / 5, bonus_name, 1, 2, 1024, 768);
580 sprintf (string, "%d", (int)bonusvalue);
581 glColor4f(0, 0, 0, 1 - bonustime);
582 text->glPrintOutline(1024 / 2 - 10 * strlen(string) - 4, 768 / 16 - 4 - 20 + 768 * 4 / 5, string, 1, 2.5 * .8, 1024, 768);
583 glColor4f(1, 0, 0, 1 - bonustime);
584 text->glPrint(1024 / 2 - 10 * strlen(string), 768 / 16 - 20 + 768 * 4 / 5, string, 1, 2 * .8, 1024, 768);
585 glColor4f(.5, .5, .5, 1);
588 if (tutoriallevel == 1) {
589 tutorialopac = tutorialmaxtime - tutorialstagetime;
590 if (tutorialopac > 1)
592 if (tutorialopac < 0)
595 sprintf (string, " ");
596 sprintf (string2, " ");
597 sprintf (string3, " ");
598 if (tutorialstage == 0) {
599 sprintf (string, " ");
600 sprintf (string2, " ");
601 sprintf (string3, " ");
603 if (tutorialstage == 1) {
604 sprintf (string, "Welcome to the Lugaru training level!");
605 sprintf (string2, " ");
606 sprintf (string3, " ");
608 if (tutorialstage == 2) {
609 sprintf (string, "BASIC MOVEMENT:");
610 sprintf (string2, " ");
611 sprintf (string3, " ");
613 if (tutorialstage == 3) {
614 sprintf (string, "You can move the mouse to rotate the camera.");
615 sprintf (string2, " ");
616 sprintf (string3, " ");
618 if (tutorialstage == 4) {
619 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));
620 sprintf (string2, "All movement is relative to the camera.");
621 sprintf (string3, " ");
623 if (tutorialstage == 5) {
624 sprintf (string, "Please press %s to jump.", Input::keyToChar(jumpkey));
625 sprintf (string2, "You can hold it longer to jump higher.");
626 sprintf (string3, " ");
628 if (tutorialstage == 6) {
629 sprintf (string, "You can press %s to crouch.", Input::keyToChar(crouchkey));
630 sprintf (string2, "You can jump higher from a crouching position.");
631 sprintf (string3, " ");
633 if (tutorialstage == 7) {
634 sprintf (string, "While running, you can press %s to roll.", Input::keyToChar(crouchkey));
635 sprintf (string2, " ");
636 sprintf (string3, " ");
638 if (tutorialstage == 8) {
639 sprintf (string, "While crouching, you can sneak around silently");
640 sprintf (string2, "using the movement keys.");
641 sprintf (string3, " ");
643 if (tutorialstage == 9) {
644 sprintf (string, "Release the crouch key while sneaking and hold the movement keys");
645 sprintf (string2, "to run animal-style.");
646 sprintf (string3, " ");
648 if (tutorialstage == 10) {
649 sprintf (string, "ADVANCED MOVEMENT:");
650 sprintf (string2, " ");
651 sprintf (string3, " ");
653 if (tutorialstage == 11) {
654 sprintf (string, "When you jump at a wall, you can hold %s again", Input::keyToChar(jumpkey));
655 sprintf (string2, "during impact to perform a walljump.");
656 sprintf (string3, "Be sure to use the movement keys to press against the wall");
658 if (tutorialstage == 12) {
659 sprintf (string, "While in the air, you can press crouch to flip.");
660 sprintf (string2, "Walljumps and flips confuse enemies and give you more control.");
661 sprintf (string3, " ");
663 if (tutorialstage == 13) {
664 sprintf (string, "BASIC COMBAT:");
665 sprintf (string2, " ");
666 sprintf (string3, " ");
668 if (tutorialstage == 14) {
669 sprintf (string, "There is now an imaginary enemy");
670 sprintf (string2, "in the middle of the training area.");
671 sprintf (string3, " ");
673 if (tutorialstage == 15) {
674 if (attackkey == MOUSEBUTTON1)
675 sprintf (string, "Click to attack when you are near an enemy.");
677 sprintf (string, "Press %s to attack when you are near an enemy.", Input::keyToChar(attackkey));
678 sprintf (string2, "You can punch by standing still near an enemy and attacking.");
679 sprintf (string3, " ");
681 if (tutorialstage == 16) {
682 sprintf (string, "If you are close, you will perform a weak punch.");
683 sprintf (string2, "The weak punch is excellent for starting attack combinations.");
684 sprintf (string3, " ");
686 if (tutorialstage == 17) {
687 sprintf (string, "Attacking while running results in a spin kick.");
688 sprintf (string2, "This is one of your most powerful ground attacks.");
689 sprintf (string3, " ");
691 if (tutorialstage == 18) {
692 sprintf (string, "Sweep the enemy's legs out by attacking while crouched.");
693 sprintf (string2, "This is a very fast attack, and easy to follow up.");
694 sprintf (string3, " ");
696 if (tutorialstage == 19) {
697 sprintf (string, "When an enemy is on the ground, you can deal some extra");
698 sprintf (string2, "damage by running up and drop-kicking him.");
699 sprintf (string3, "(Try knocking them down with a sweep first)");
701 if (tutorialstage == 20) {
702 sprintf (string, "Your most powerful individual attack is the rabbit kick.");
703 if (attackkey == MOUSEBUTTON1)
704 sprintf (string2, "Run at the enemy while holding the mouse button, and press");
706 sprintf (string2, "Run at the enemy while holding %s, and press", Input::keyToChar(attackkey));
707 sprintf (string3, "the jump key (%s) to attack.", Input::keyToChar(jumpkey));
709 if (tutorialstage == 21) {
710 sprintf (string, "This attack is devastating if timed correctly.");
711 sprintf (string2, "Even if timed incorrectly, it will knock the enemy over.");
713 sprintf (string3, "Try rabbit-kicking the imaginary enemy again.");
715 sprintf (string3, "Try rabbit-kicking the imaginary enemy.");
717 if (tutorialstage == 22) {
718 sprintf (string, "If you sneak behind an enemy unnoticed, you can kill");
719 sprintf (string2, "him instantly. Move close behind this enemy");
720 sprintf (string3, "and attack.");
722 if (tutorialstage == 23) {
723 sprintf (string, "Another important attack is the wall kick. When an enemy");
724 sprintf (string2, "is near a wall, perform a walljump nearby and hold");
725 sprintf (string3, "the attack key during impact with the wall.");
727 if (tutorialstage == 24) {
728 sprintf (string, "You can tackle enemies by running at them animal-style");
729 if (attackkey == MOUSEBUTTON1)
730 sprintf (string2, "and pressing jump (%s) or attack(mouse button).", Input::keyToChar(jumpkey));
732 sprintf (string2, "and pressing jump (%s) or attack(%s).", Input::keyToChar(jumpkey), Input::keyToChar(attackkey));
733 sprintf (string3, "This is especially useful when they are running away.");
735 if (tutorialstage == 25) {
736 sprintf (string, "Dodge by pressing back and attack. Dodging is essential");
737 sprintf (string2, "against enemies with swords or other long weapons.");
738 sprintf (string3, " ");
740 if (tutorialstage == 26) {
741 sprintf (string, "REVERSALS AND COUNTER-REVERSALS");
742 sprintf (string2, " ");
743 sprintf (string3, " ");
745 if (tutorialstage == 27) {
746 sprintf (string, "The enemy can now reverse your attacks.");
747 sprintf (string2, " ");
748 sprintf (string3, " ");
750 if (tutorialstage == 28) {
751 sprintf (string, "If you attack, you will notice that the enemy now sometimes");
752 sprintf (string2, "catches your attack and uses it against you. Hold");
753 sprintf (string3, "crouch (%s) after attacking to escape from reversals.", Input::keyToChar(crouchkey));
755 if (tutorialstage == 29) {
756 sprintf (string, "Try escaping from two more reversals in a row.");
757 sprintf (string2, " ");
758 sprintf (string3, " ");
760 if (tutorialstage == 30) {
761 sprintf (string, "Good!");
762 sprintf (string2, " ");
763 sprintf (string3, " ");
765 if (tutorialstage == 31) {
766 sprintf (string, "To reverse an attack, you must tap crouch (%s) during the", Input::keyToChar(crouchkey));
767 sprintf (string2, "enemy's attack. You must also be close to the enemy;");
768 sprintf (string3, "this is especially important against armed opponents.");
770 if (tutorialstage == 32) {
771 sprintf (string, "The enemy can attack in %d seconds.", (int)(tutorialmaxtime - tutorialstagetime));
772 sprintf (string2, "This imaginary opponents attacks will be highlighted");
773 sprintf (string3, "to make this easier.");
775 if (tutorialstage == 33) {
776 sprintf (string, "Reverse three enemy attacks!");
777 sprintf (string2, " ");
778 sprintf (string3, " ");
780 if (tutorialstage == 34) {
781 sprintf (string, "Reverse two more enemy attacks!");
782 sprintf (string2, " ");
783 sprintf (string3, " ");
785 if (tutorialstage == 35) {
786 sprintf (string, "Reverse one more enemy attack!");
787 sprintf (string2, " ");
788 sprintf (string3, " ");
790 if (tutorialstage == 36) {
791 sprintf (string, "Excellent!");
792 sprintf (string2, " ");
793 sprintf (string3, " ");
795 if (tutorialstage == 37) {
796 sprintf (string, "Now spar with the enemy for %d more seconds.", (int)(tutorialmaxtime - tutorialstagetime));
797 sprintf (string2, "Damage dealt: %d", (int)damagedealt);
798 sprintf (string3, "Damage taken: %d.", (int)damagetaken);
800 if (tutorialstage == 38) {
801 sprintf (string, "WEAPONS:");
802 sprintf (string2, " ");
803 sprintf (string3, " ");
805 if (tutorialstage == 39) {
806 sprintf (string, "There is now an imaginary knife");
807 sprintf (string2, "in the center of the training area.");
808 sprintf (string3, " ");
810 if (tutorialstage == 40) {
811 sprintf (string, "Stand, roll or handspring over the knife");
812 sprintf (string2, "while pressing %s to pick it up.", Input::keyToChar(throwkey));
813 sprintf (string3, "You can crouch and press the same key to drop it again.");
815 if (tutorialstage == 41) {
816 sprintf (string, "You can equip and unequip weapons using the %s key.", Input::keyToChar(drawkey));
817 sprintf (string2, "Sometimes it is best to keep them unequipped to");
818 sprintf (string3, "prevent enemies from taking them. ");
820 if (tutorialstage == 42) {
821 sprintf (string, "The knife is the smallest weapon and the least encumbering.");
822 sprintf (string2, "You can equip or unequip it while standing, crouching,");
823 sprintf (string3, "running or flipping.");
825 if (tutorialstage == 43) {
826 sprintf (string, "You perform weapon attacks the same way as unarmed attacks,");
827 sprintf (string2, "but sharp weapons cause permanent damage, instead of the");
828 sprintf (string3, "temporary trauma from blunt weapons, fists and feet.");
830 if (tutorialstage == 44) {
831 sprintf (string, "The enemy now has your knife!");
832 sprintf (string2, "Please reverse two of his knife attacks.");
833 sprintf (string3, " ");
835 if (tutorialstage == 45) {
836 sprintf (string, "Please reverse one more of his knife attacks.");
837 sprintf (string2, " ");
838 sprintf (string3, " ");
840 if (tutorialstage == 46) {
841 sprintf (string, "Now he has a sword!");
842 sprintf (string2, "The sword has longer reach than your arms, so you");
843 sprintf (string3, "must move close to reverse the sword slash.");
845 if (tutorialstage == 47) {
846 sprintf (string, "Long weapons like the sword and staff are also useful for defense;");
847 sprintf (string2, "you can parry enemy weapon attacks by pressing the attack key");
848 sprintf (string3, "at the right time. Please try parrying the enemy's attacks!");
850 if (tutorialstage == 48) {
851 sprintf (string, "The staff is like the sword, but has two main attacks.");
852 sprintf (string2, "The standing smash is fast and effective, and the running");
853 sprintf (string3, "spin smash is slower and more powerful.");
855 if (tutorialstage == 49) {
856 sprintf (string, "When facing an enemy, you can throw the knife with %s.", Input::keyToChar(throwkey));
857 sprintf (string2, "It is possible to throw the knife while flipping,");
858 sprintf (string3, "but it is very inaccurate.");
860 if (tutorialstage == 50) {
861 sprintf (string, "You now know everything you can learn from training.");
862 sprintf (string2, "Everything else you must learn from experience!");
863 sprintf (string3, " ");
865 if (tutorialstage == 51) {
866 sprintf (string, "Walk out of the training area to return to the main menu.");
867 sprintf (string2, " ");
868 sprintf (string3, " ");
871 glColor4f(0, 0, 0, tutorialopac);
872 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);
873 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);
874 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);
875 glColor4f(1, 1, 1, tutorialopac);
876 text->glPrint(screenwidth / 2 - 7.6 * strlen(string)*screenwidth / 1024, screenheight / 16 + screenheight * 4 / 5, string, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight);
877 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);
878 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);
880 sprintf (string, "Press 'tab' to skip to the next item.");
881 sprintf (string2, "Press escape at any time to");
882 sprintf (string3, "pause or exit the tutorial.");
884 glColor4f(0, 0, 0, 1);
885 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);
886 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);
887 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);
888 glColor4f(0.5, 0.5, 0.5, 1);
889 text->glPrint(screenwidth / 2 - 7.6 * strlen(string)*screenwidth / 1024 * .8, 0 + screenheight * 1 / 10, string, 1, 1.5 * screenwidth / 1024 * .8, screenwidth, screenheight);
890 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);
891 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);
895 if (numhotspots && (bonustime >= 1 || bonus <= 0 || bonustime < 0) && !tutoriallevel) {
896 float closestdist = -1;
898 int closest = currenthotspot;
899 for (int i = 0; i < numhotspots; i++) {
900 distance = distsq(&Person::players[0]->coords, &hotspot[i]);
901 if (closestdist == -1 || distance < closestdist) {
902 if (distsq(&Person::players[0]->coords, &hotspot[i]) < hotspotsize[i] && ((hotspottype[i] <= 10 && hotspottype[i] >= 0) || (hotspottype[i] <= 40 && hotspottype[i] >= 20))) {
903 closestdist = distance;
909 currenthotspot = closest;
910 if (currenthotspot != -1) {
911 if (hotspottype[closest] <= 10) {
912 if (distsq(&Person::players[0]->coords, &hotspot[closest]) < hotspotsize[closest])
913 tutorialstagetime = 0;
915 tutorialopac = tutorialmaxtime - tutorialstagetime;
916 if (tutorialopac > 1)
918 if (tutorialopac < 0)
921 sprintf (string, "%s", hotspottext[closest]);
928 if (string[i] == '\n' || string[i] > 'z' || string[i] < ' ' || string[i] == '\0') {
929 glColor4f(0, 0, 0, tutorialopac);
930 text->glPrintOutline(screenwidth / 2 - 7.6 * (i - lastline)*screenwidth / 1024 - 4, screenheight / 16 - 4 + screenheight * 4 / 5 - 20 * screenwidth / 1024 * line, string, 1, 1.5 * 1.25 * screenwidth / 1024, screenwidth, screenheight, lastline, i);
931 glColor4f(1, 1, 1, tutorialopac);
932 text->glPrint(screenwidth / 2 - 7.6 * (i - lastline)*screenwidth / 1024, screenheight / 16 + screenheight * 4 / 5 - 20 * screenwidth / 1024 * line, string, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight, lastline, i);
935 if (string[i] == '\0')
942 } else if (hotspottype[closest] >= 20 && dialoguegonethrough[hotspottype[closest] - 20] == 0) {
943 whichdialogue = hotspottype[closest] - 20;
944 for (int j = 0; j < numdialogueboxes[whichdialogue]; j++) {
945 Person::players[participantfocus[whichdialogue][j]]->coords = participantlocation[whichdialogue][participantfocus[whichdialogue][j]];
946 Person::players[participantfocus[whichdialogue][j]]->yaw = participantyaw[whichdialogue][participantfocus[whichdialogue][j]];
947 Person::players[participantfocus[whichdialogue][j]]->targetyaw = participantyaw[whichdialogue][participantfocus[whichdialogue][j]];
948 Person::players[participantfocus[whichdialogue][j]]->velocity = 0;
949 Person::players[participantfocus[whichdialogue][j]]->animTarget = Person::players[participantfocus[whichdialogue][j]]->getIdle();
950 Person::players[participantfocus[whichdialogue][j]]->frameTarget = 0;
954 dialoguegonethrough[whichdialogue]++;
955 if (dialogueboxsound[whichdialogue][indialogue] != 0) {
957 if (dialogueboxsound[whichdialogue][indialogue] == 1) whichsoundplay = rabbitchitter;
958 if (dialogueboxsound[whichdialogue][indialogue] == 2) whichsoundplay = rabbitchitter2;
959 if (dialogueboxsound[whichdialogue][indialogue] == 3) whichsoundplay = rabbitpainsound;
960 if (dialogueboxsound[whichdialogue][indialogue] == 4) whichsoundplay = rabbitpain1sound;
961 if (dialogueboxsound[whichdialogue][indialogue] == 5) whichsoundplay = rabbitattacksound;
962 if (dialogueboxsound[whichdialogue][indialogue] == 6) whichsoundplay = rabbitattack2sound;
963 if (dialogueboxsound[whichdialogue][indialogue] == 7) whichsoundplay = rabbitattack3sound;
964 if (dialogueboxsound[whichdialogue][indialogue] == 8) whichsoundplay = rabbitattack4sound;
965 if (dialogueboxsound[whichdialogue][indialogue] == 9) whichsoundplay = growlsound;
966 if (dialogueboxsound[whichdialogue][indialogue] == 10) whichsoundplay = growl2sound;
967 if (dialogueboxsound[whichdialogue][indialogue] == 11) whichsoundplay = snarlsound;
968 if (dialogueboxsound[whichdialogue][indialogue] == 12) whichsoundplay = snarl2sound;
969 if (dialogueboxsound[whichdialogue][indialogue] == 13) whichsoundplay = barksound;
970 if (dialogueboxsound[whichdialogue][indialogue] == 14) whichsoundplay = bark2sound;
971 if (dialogueboxsound[whichdialogue][indialogue] == 15) whichsoundplay = bark3sound;
972 if (dialogueboxsound[whichdialogue][indialogue] == 16) whichsoundplay = barkgrowlsound;
973 if (dialogueboxsound[whichdialogue][indialogue] == -1) whichsoundplay = fireendsound;
974 if (dialogueboxsound[whichdialogue][indialogue] == -2) whichsoundplay = firestartsound;
975 if (dialogueboxsound[whichdialogue][indialogue] == -3) whichsoundplay = consolesuccesssound;
976 if (dialogueboxsound[whichdialogue][indialogue] == -4) whichsoundplay = consolefailsound;
977 emit_sound_at(whichsoundplay, Person::players[participantfocus[whichdialogue][indialogue]]->coords);
983 if (indialogue != -1 && !mainmenu) {
984 glDisable(GL_DEPTH_TEST);
985 glDisable(GL_CULL_FACE);
986 glDisable(GL_LIGHTING);
987 glDisable(GL_TEXTURE_2D);
989 glMatrixMode(GL_PROJECTION);
992 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
993 glMatrixMode(GL_MODELVIEW);
996 if (dialogueboxlocation[whichdialogue][indialogue] == 1)
997 glTranslatef(0, screenheight * 3 / 4, 0);
998 glScalef(screenwidth, screenheight / 4, 1);
999 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1002 glColor4f(dialogueboxcolor[whichdialogue][indialogue][0], dialogueboxcolor[whichdialogue][indialogue][1], dialogueboxcolor[whichdialogue][indialogue][2], 0.7);
1004 glVertex3f(0, 0, 0.0f);
1005 glVertex3f(1, 0, 0.0f);
1006 glVertex3f(1, 1, 0.0f);
1007 glVertex3f(0, 1, 0.0f);
1009 glMatrixMode(GL_PROJECTION);
1011 glMatrixMode(GL_MODELVIEW);
1013 glEnable(GL_DEPTH_TEST);
1014 glEnable(GL_CULL_FACE);
1015 glDisable(GL_BLEND);
1017 glEnable(GL_TEXTURE_2D);
1024 startx = screenwidth * 1 / 5;
1025 if (dialogueboxlocation[whichdialogue][indialogue] == 1)
1026 starty = screenheight / 16 + screenheight * 4 / 5;
1027 if (dialogueboxlocation[whichdialogue][indialogue] == 2)
1028 starty = screenheight * 1 / 5 - screenheight / 16;
1033 for (int i = 0; i < 264; i++) {
1037 for (int i = 0; i < (int)strlen(dialoguename[whichdialogue][indialogue]); i++) {
1038 tempname[tempnum] = dialoguename[whichdialogue][indialogue][i];
1040 if (dialoguename[whichdialogue][indialogue][i] == '#' || dialoguename[whichdialogue][indialogue][i] == '\0')
1045 tempname[tempnum] = '\0';
1048 sprintf (string, "%s: ", tempname);
1050 if (dialogueboxcolor[whichdialogue][indialogue][0] + dialogueboxcolor[whichdialogue][indialogue][1] + dialogueboxcolor[whichdialogue][indialogue][2] < 1.5) {
1051 glColor4f(0, 0, 0, tutorialopac);
1052 text->glPrintOutline(startx - 2 * 7.6 * strlen(string)*screenwidth / 1024 - 4, starty - 4, string, 1, 1.5 * 1.25 * screenwidth / 1024, screenwidth, screenheight);
1053 glColor4f(0.7, 0.7, 0.7, tutorialopac);
1054 text->glPrint(startx - 2 * 7.6 * strlen(string)*screenwidth / 1024, starty, string, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight);
1056 glColor4f(0, 0, 0, tutorialopac);
1057 text->glPrintOutline(startx - 2 * 7.6 * strlen(string)*screenwidth / 1024 - 4, starty - 4, string, 1, 1.5 * 1.25 * screenwidth / 1024, screenwidth, screenheight);
1061 for (int i = 0; i < (int)strlen(dialoguetext[whichdialogue][indialogue]) + 1; i++) {
1062 tempname[tempnum] = dialoguetext[whichdialogue][indialogue][i];
1063 if (dialoguetext[whichdialogue][indialogue][i] != '#')
1067 sprintf (string, "%s", tempname);
1074 if (string[i] == '\n' || string[i] > 'z' || string[i] < ' ' || string[i] == '\0') {
1075 if (dialogueboxcolor[whichdialogue][indialogue][0] + dialogueboxcolor[whichdialogue][indialogue][1] + dialogueboxcolor[whichdialogue][indialogue][2] < 1.5) {
1076 glColor4f(0, 0, 0, tutorialopac);
1077 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);
1078 glColor4f(1, 1, 1, tutorialopac);
1079 text->glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/, starty - 20 * screenwidth / 1024 * line, string, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight, lastline, i);
1081 glColor4f(0, 0, 0, tutorialopac);
1082 text->glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/, starty - 20 * screenwidth / 1024 * line, string, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight, lastline, i);
1086 if (string[i] == '\0')
1095 if (!tutoriallevel && !winfreeze && indialogue == -1 && !mainmenu) {
1098 sprintf (string, "Score: %d", (int)accountactive->getCampaignScore());
1100 sprintf (string, "Score: %d", (int)accountactive->getCampaignScore() + (int)bonustotal);
1103 sprintf (string, "Score: %d", (int)bonustotal);
1104 glColor4f(0, 0, 0, 1);
1105 text->glPrintOutline(1024 / 40 - 4, 768 / 16 - 4 + 768 * 14 / 16, string, 1, 1.5 * 1.25, 1024, 768);
1106 glColor4f(1, 0, 0, 1);
1107 text->glPrint(1024 / 40, 768 / 16 + 768 * 14 / 16, string, 1, 1.5, 1024, 768);
1108 if (showdamagebar) {
1109 glDisable(GL_DEPTH_TEST);
1110 glDisable(GL_CULL_FACE);
1111 glDisable(GL_LIGHTING);
1112 glDisable(GL_TEXTURE_2D);
1114 glMatrixMode(GL_PROJECTION);
1117 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1118 glMatrixMode(GL_MODELVIEW);
1121 glTranslatef(15, screenheight * 17.5 / 20, 0);
1122 glScalef(screenwidth / 3 + 20, screenheight / 20, 1);
1123 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1125 glColor4f(0.0, 0.4, 0.0, 0.7);
1126 float bar = ((float)Person::players[0]->damage) / Person::players[0]->damagetolerance;
1128 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
1129 glVertex3f(1, 0, 0.0f);
1130 glVertex3f(1, 1, 0.0f);
1131 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
1133 glColor4f(0.1, 0.0, 0.0, 1);
1134 bar = ((float)Person::players[0]->bloodloss) / Person::players[0]->damagetolerance;
1136 glVertex3f(0, 0, 0.0f);
1137 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
1138 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
1139 glVertex3f(0, 1, 0.0f);
1141 glColor4f(0.4, 0.0, 0.0, 0.7);
1142 bar = ((float)Person::players[0]->damage) / Person::players[0]->damagetolerance;
1144 glVertex3f(0, 0, 0.0f);
1145 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
1146 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
1147 glVertex3f(0, 1, 0.0f);
1149 glColor4f(0.4, 0.0, 0.0, 0.7);
1150 bar = ((float)Person::players[0]->permanentdamage) / Person::players[0]->damagetolerance;
1152 glVertex3f(0, 0, 0.0f);
1153 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
1154 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
1155 glVertex3f(0, 1, 0.0f);
1157 glColor4f(0.4, 0.0, 0.0, 0.7);
1158 bar = ((float)Person::players[0]->superpermanentdamage) / Person::players[0]->damagetolerance;
1160 glVertex3f(0, 0, 0.0f);
1161 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
1162 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
1163 glVertex3f(0, 1, 0.0f);
1165 glColor4f(0.0, 0.0, 0.0, 0.7);
1167 glBegin(GL_LINE_STRIP);
1168 glVertex3f(0, 0, 0.0f);
1169 glVertex3f(1, 0, 0.0f);
1170 glVertex3f(1, 1, 0.0f);
1171 glVertex3f(0, 1, 0.0f);
1172 glVertex3f(0, 0, 0.0f);
1175 glMatrixMode(GL_PROJECTION);
1177 glMatrixMode(GL_MODELVIEW);
1179 glEnable(GL_DEPTH_TEST);
1180 glEnable(GL_CULL_FACE);
1181 glDisable(GL_BLEND);
1183 glEnable(GL_TEXTURE_2D);
1185 // writing the numbers :
1186 sprintf (string, "Damages : %d/%d (%d)", (int)(Person::players[0]->damage), (int)(Person::players[0]->damagetolerance), (int)(Person::players[0]->bloodloss));
1187 glColor4f(0, 0, 0, 1);
1188 text->glPrintOutline(1024 / 40 - 4, 768 / 16 - 4 + 768 * 14 / 16 - 40, string, 1, 1.5 * 1.25, 1024, 768);
1189 glColor4f(1, 0, 0, 1);
1190 text->glPrint(1024 / 40, 768 / 16 + 768 * 14 / 16 - 40, string, 1, 1.5, 1024, 768);
1194 glColor4f(.5, .5, .5, 1);
1197 if ((texttoggle || editorenabled) && debugmode && !mainmenu) {
1198 sprintf (string, "The framespersecond is %d.", (int)(fps));
1199 text->glPrint(10, 30, string, 0, .8, 1024, 768);
1202 sprintf (string, "Map editor enabled.");
1204 sprintf (string, "Map editor disabled.");
1205 text->glPrint(10, 60, string, 0, .8, 1024, 768);
1206 if (editorenabled) {
1207 sprintf (string, "Object size: %f", editorsize);
1208 text->glPrint(10, 75, string, 0, .8, 1024, 768);
1210 sprintf (string, "Object yaw: %f", editoryaw);
1212 sprintf (string, "Object yaw: Random");
1213 text->glPrint(10, 90, string, 0, .8, 1024, 768);
1214 if (editorpitch >= 0)
1215 sprintf (string, "Object pitch: %f", editorpitch);
1217 sprintf (string, "Object pitch: Random");
1218 text->glPrint(10, 105, string, 0, .8, 1024, 768);
1219 sprintf (string, "Object type: %d", editortype);
1220 text->glPrint(10, 120, string, 0, .8, 1024, 768);
1221 switch (editortype) {
1223 sprintf (string, "(box)");
1226 sprintf (string, "(tree)");
1229 sprintf (string, "(wall)");
1232 sprintf (string, "(weird)");
1235 sprintf (string, "(spike)");
1238 sprintf (string, "(rock)");
1241 sprintf (string, "(bush)");
1244 sprintf (string, "(tunnel)");
1247 sprintf (string, "(chimney)");
1250 sprintf (string, "(platform)");
1253 sprintf (string, "(cool)");
1256 sprintf (string, "(fire)");
1259 text->glPrint(130, 120, string, 0, .8, 1024, 768);
1261 sprintf (string, "Numplayers: %lu", Person::players.size());
1262 text->glPrint(10, 155, string, 0, .8, 1024, 768);
1263 sprintf (string, "Player %d: numwaypoints: %d", (int(Person::players.size()) - 1), Person::players.back()->numwaypoints);
1264 text->glPrint(10, 140, string, 0, .8, 1024, 768);
1266 sprintf (string, "Difficulty: %d", difficulty);
1267 text->glPrint(10, 240, string, 0, .8, 1024, 768);
1272 if (drawmode == glowmode) {
1273 glDisable(GL_DEPTH_TEST);
1274 glDisable(GL_CULL_FACE);
1275 glDisable(GL_LIGHTING);
1276 glDisable(GL_TEXTURE_2D);
1278 glMatrixMode(GL_PROJECTION);
1281 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1282 glMatrixMode(GL_MODELVIEW);
1285 glScalef(screenwidth, screenheight, 1);
1286 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1288 glColor4f(0, 0, 0, .5);
1290 glVertex3f(0, 0, 0.0f);
1291 glVertex3f(256, 0, 0.0f);
1292 glVertex3f(256, 256, 0.0f);
1293 glVertex3f(0, 256, 0.0f);
1295 glMatrixMode(GL_PROJECTION);
1297 glMatrixMode(GL_MODELVIEW);
1299 glEnable(GL_DEPTH_TEST);
1300 glEnable(GL_CULL_FACE);
1301 glDisable(GL_BLEND);
1305 if ((((blackout && damageeffects) || (Person::players[0]->bloodloss > 0 && damageeffects && Person::players[0]->blooddimamount > 0) || Person::players[0]->dead) && !cameramode) || console) {
1306 glDisable(GL_DEPTH_TEST);
1307 glDisable(GL_CULL_FACE);
1308 glDisable(GL_LIGHTING);
1309 glDisable(GL_TEXTURE_2D);
1311 glMatrixMode(GL_PROJECTION);
1314 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1315 glMatrixMode(GL_MODELVIEW);
1318 glScalef(screenwidth, screenheight, 1);
1319 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1321 if (Person::players[0]->dead)
1322 blackout += multiplier * 3;
1323 if (Person::players[0]->dead == 1)
1325 if (Person::players[0]->dead == 2 && blackout > .6)
1327 glColor4f(0, 0, 0, blackout);
1328 if (!Person::players[0]->dead) {
1329 if ((Person::players[0]->bloodloss / Person::players[0]->damagetolerance * (sin(woozy) / 4 + .5))*.3 < .3) {
1330 glColor4f(0, 0, 0, Person::players[0]->blooddimamount * Person::players[0]->bloodloss / Person::players[0]->damagetolerance * (sin(woozy) / 4 + .5)*.3);
1331 blackout = Person::players[0]->blooddimamount * Person::players[0]->bloodloss / Person::players[0]->damagetolerance * (sin(woozy) / 4 + .5) * .3;
1333 glColor4f(0, 0, 0, Person::players[0]->blooddimamount * .3);
1334 blackout = Person::players[0]->blooddimamount * .3;
1338 glColor4f(.7, 0, 0, .2);
1340 glVertex3f(0, 0, 0.0f);
1341 glVertex3f(256, 0, 0.0f);
1342 glVertex3f(256, 256, 0.0f);
1343 glVertex3f(0, 256, 0.0f);
1345 glMatrixMode(GL_PROJECTION);
1347 glMatrixMode(GL_MODELVIEW);
1349 glEnable(GL_DEPTH_TEST);
1350 glEnable(GL_CULL_FACE);
1351 glDisable(GL_BLEND);
1355 if (flashamount > 0 && damageeffects) {
1356 if (flashamount > 1)
1358 if (flashdelay <= 0)
1359 flashamount -= multiplier;
1361 if (flashamount < 0)
1363 glDisable(GL_DEPTH_TEST);
1364 glDisable(GL_CULL_FACE);
1365 glDisable(GL_LIGHTING);
1367 glMatrixMode(GL_PROJECTION);
1370 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1371 glMatrixMode(GL_MODELVIEW);
1374 glScalef(screenwidth, screenheight, 1);
1375 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1377 glColor4f(flashr, flashg, flashb, flashamount);
1379 glVertex3f(0, 0, 0.0f);
1380 glVertex3f(256, 0, 0.0f);
1381 glVertex3f(256, 256, 0.0f);
1382 glVertex3f(0, 256, 0.0f);
1384 glMatrixMode(GL_PROJECTION);
1386 glMatrixMode(GL_MODELVIEW);
1388 glEnable(GL_DEPTH_TEST);
1389 glEnable(GL_CULL_FACE);
1390 glDisable(GL_BLEND);
1396 glEnable(GL_TEXTURE_2D);
1397 glColor4f(1, 1, 1, 1);
1398 for (unsigned i = 1; i < 15; i++)
1399 if (displaytime[i] < 4)
1400 for (unsigned j = 0; j < displaytext[i].size(); j++) {
1401 glColor4f(1, 1, 1, 4 - displaytime[i]);
1402 sprintf (string, "%c", displaytext[i][j]);
1403 text->glPrint(30 + j * 10, 30 + i * 20 + (screenheight - 330), string, 0, 1, screenwidth, screenheight);
1407 if (difficulty < 2 && indialogue == -1) { // minimap
1408 float mapviewdist = 20000;
1410 glDisable(GL_DEPTH_TEST);
1411 glColor3f (1.0, 1.0, 1.0); // no coloring
1413 glEnable(GL_TEXTURE_2D);
1414 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1415 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1416 glDisable(GL_DEPTH_TEST);
1417 glDisable(GL_CULL_FACE);
1418 glDisable(GL_LIGHTING);
1420 glMatrixMode(GL_PROJECTION);
1423 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1424 glMatrixMode(GL_MODELVIEW);
1427 glScalef((float)screenwidth / 2, (float)screenwidth / 2, 1);
1428 glTranslatef(1.75, .25, 0);
1429 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1431 glColor4f(1, 1, 1, 1);
1438 center = Person::players[0]->coords;
1442 glScalef(.25 / radius * 256 * terrain.scale * .4, .25 / radius * 256 * terrain.scale * .4, 1);
1444 glScalef(1 / (1 / radius * 256 * terrain.scale * .4), 1 / (1 / radius * 256 * terrain.scale * .4), 1);
1446 glRotatef(Person::players[0]->lookyaw * -1 + 180, 0, 0, 1);
1447 glTranslatef(-(center.x / terrain.scale / 256 * -2 + 1), (center.z / terrain.scale / 256 * -2 + 1), 0);
1448 for (int i = 0; i < objects.numobjects; i++) {
1449 if (objects.type[i] == treetrunktype) {
1450 distcheck = distsq(&Person::players[0]->coords, &objects.position[i]);
1451 if (distcheck < mapviewdist) {
1452 Mapcircletexture.bind();
1453 glColor4f(0, .3, 0, opac * (1 - distcheck / mapviewdist));
1455 glTranslatef(objects.position[i].x / terrain.scale / 256 * -2 + 1, objects.position[i].z / terrain.scale / 256 * 2 - 1, 0);
1456 glRotatef(objects.yaw[i], 0, 0, 1);
1457 glScalef(.003, .003, .003);
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 if (objects.type[i] == boxtype) {
1472 distcheck = distsq(&Person::players[0]->coords, &objects.position[i]);
1473 if (distcheck < mapviewdist) {
1474 Mapboxtexture.bind();
1475 glColor4f(.4, .4, .4, opac * (1 - distcheck / mapviewdist));
1477 glTranslatef(objects.position[i].x / terrain.scale / 256 * -2 + 1, objects.position[i].z / terrain.scale / 256 * 2 - 1, 0);
1478 glRotatef(objects.yaw[i], 0, 0, 1);
1479 glScalef(.01 * objects.scale[i], .01 * objects.scale[i], .01 * objects.scale[i]);
1482 glVertex3f(-1, -1, 0.0f);
1484 glVertex3f(1, -1, 0.0f);
1486 glVertex3f(1, 1, 0.0f);
1488 glVertex3f(-1, 1, 0.0f);
1494 if (editorenabled) {
1495 Mapcircletexture.bind();
1496 for (int i = 0; i < numboundaries; i++) {
1497 glColor4f(0, 0, 0, opac / 3);
1499 glTranslatef(boundary[i].x / terrain.scale / 256 * -2 + 1, boundary[i].z / terrain.scale / 256 * 2 - 1, 0);
1500 glScalef(.002, .002, .002);
1503 glVertex3f(-1, -1, 0.0f);
1505 glVertex3f(1, -1, 0.0f);
1507 glVertex3f(1, 1, 0.0f);
1509 glVertex3f(-1, 1, 0.0f);
1514 for (unsigned i = 0; i < Person::players.size(); i++) {
1515 distcheck = distsq(&Person::players[0]->coords, &Person::players[i]->coords);
1516 if (distcheck < mapviewdist) {
1518 Maparrowtexture.bind();
1520 glColor4f(1, 1, 1, opac);
1521 else if (Person::players[i]->dead == 2 || Person::players[i]->howactive > typesleeping)
1522 glColor4f(0, 0, 0, opac * (1 - distcheck / mapviewdist));
1523 else if (Person::players[i]->dead)
1524 glColor4f(.3, .3, .3, opac * (1 - distcheck / mapviewdist));
1525 else if (Person::players[i]->aitype == attacktypecutoff)
1526 glColor4f(1, 0, 0, opac * (1 - distcheck / mapviewdist));
1527 else if (Person::players[i]->aitype == passivetype)
1528 glColor4f(0, 1, 0, opac * (1 - distcheck / mapviewdist));
1530 glColor4f(1, 1, 0, 1);
1531 glTranslatef(Person::players[i]->coords.x / terrain.scale / 256 * -2 + 1, Person::players[i]->coords.z / terrain.scale / 256 * 2 - 1, 0);
1532 glRotatef(Person::players[i]->yaw + 180, 0, 0, 1);
1533 glScalef(.005, .005, .005);
1536 glVertex3f(-1, -1, 0.0f);
1538 glVertex3f(1, -1, 0.0f);
1540 glVertex3f(1, 1, 0.0f);
1542 glVertex3f(-1, 1, 0.0f);
1548 glDisable(GL_TEXTURE_2D);
1549 glMatrixMode(GL_PROJECTION);
1551 glMatrixMode(GL_MODELVIEW);
1553 glEnable(GL_DEPTH_TEST);
1554 glEnable(GL_CULL_FACE);
1555 glDisable(GL_BLEND);
1559 if (loading && !stealthloading && (!campaign || Person::players[0]->dead)) {
1560 glDisable(GL_DEPTH_TEST);
1561 glDisable(GL_CULL_FACE);
1562 glDisable(GL_LIGHTING);
1563 glDisable(GL_TEXTURE_2D);
1565 glMatrixMode(GL_PROJECTION);
1568 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1569 glMatrixMode(GL_MODELVIEW);
1572 glScalef(screenwidth, screenheight, 1);
1573 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1575 glColor4f(0, 0, 0, .7);
1577 glVertex3f(0, 0, 0.0f);
1578 glVertex3f(256, 0, 0.0f);
1579 glVertex3f(256, 256, 0.0f);
1580 glVertex3f(0, 256, 0.0f);
1582 glMatrixMode(GL_PROJECTION);
1584 glMatrixMode(GL_MODELVIEW);
1586 glEnable(GL_DEPTH_TEST);
1587 glEnable(GL_CULL_FACE);
1588 glDisable(GL_BLEND);
1592 glDisable(GL_DEPTH_TEST);
1593 glColor3f (1.0, 1.0, 1.0); // no coloring
1595 glEnable(GL_TEXTURE_2D);
1600 glEnable(GL_TEXTURE_2D);
1601 glColor4f(1, 1, 1, 1);
1602 sprintf (string, "Loading...");
1603 text->glPrint(1024 / 2 - 90, 768 / 2, string, 1, 2, 1024, 768);
1606 drawmode = normalmode;
1609 if (winfreeze && !campaign) {
1610 glDisable(GL_DEPTH_TEST);
1611 glDisable(GL_CULL_FACE);
1612 glDisable(GL_LIGHTING);
1613 glDisable(GL_TEXTURE_2D);
1615 glMatrixMode(GL_PROJECTION);
1618 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1619 glMatrixMode(GL_MODELVIEW);
1622 glScalef(screenwidth, screenheight, 1);
1623 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1625 glColor4f(0, 0, 0, .4);
1627 glVertex3f(0, 0, 0.0f);
1628 glVertex3f(256, 0, 0.0f);
1629 glVertex3f(256, 256, 0.0f);
1630 glVertex3f(0, 256, 0.0f);
1632 glMatrixMode(GL_PROJECTION);
1634 glMatrixMode(GL_MODELVIEW);
1636 glEnable(GL_DEPTH_TEST);
1637 glEnable(GL_CULL_FACE);
1638 glDisable(GL_BLEND);
1642 glDisable(GL_DEPTH_TEST);
1643 glColor3f (1.0, 1.0, 1.0); // no coloring
1645 glEnable(GL_TEXTURE_2D);
1647 //Win Screen Won Victory
1649 glEnable(GL_TEXTURE_2D);
1650 glColor4f(1, 1, 1, 1);
1651 sprintf (string, "Level Cleared!");
1652 text->glPrintOutlined(1024 / 2 - strlen(string) * 10, 768 * 7 / 8, string, 1, 2, 1024, 768);
1654 sprintf (string, "Score: %d", (int)(bonustotal - startbonustotal));
1655 text->glPrintOutlined(1024 / 30, 768 * 6 / 8, string, 1, 2, 1024, 768);
1658 sprintf (string, "Press Escape or Space to continue");
1660 sprintf (string, "Press Escape to return to menu or Space to continue");
1661 text->glPrintOutlined(640 / 2 - strlen(string) * 5, 480 * 1 / 16, string, 1, 1, 640, 480);
1665 for (int i = 0; i < 255; i++)
1667 sprintf (temp, "Time: %d:", (int)(((int)leveltime - (int)(leveltime) % 60) / 60));
1668 strcat(string, temp);
1669 if ((int)(leveltime) % 60 < 10)
1670 strcat(string, "0");
1671 sprintf (temp, "%d", (int)(leveltime) % 60);
1672 strcat(string, temp);
1673 text->glPrintOutlined(1024 / 30, 768 * 6 / 8 - 40, string, 1, 2, 1024, 768);
1676 int awards[award_count];
1677 int numawards = award_awards(awards);
1679 for (int i = 0; i < numawards && i < 6; i++)
1680 text->glPrintOutlined(1024 / 30, 768 * 6 / 8 - 90 - 40 * i, award_names[awards[i]], 1, 2, 1024, 768);
1683 if (drawmode != normalmode) {
1684 glEnable(GL_TEXTURE_2D);
1686 if (!drawtoggle || drawmode != realmotionblurmode || (drawtoggle == 2 || change == 1)) {
1687 if (screentexture) {
1689 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
1690 GLfloat subtractColor[4] = { 0.5, 0.5, 0.5, 0.0 };
1691 glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, subtractColor);
1692 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE);
1693 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_CONSTANT_EXT);
1694 glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 2.0f);
1696 glBindTexture( GL_TEXTURE_2D, screentexture);
1697 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1700 if ((drawtoggle || change == 1) && drawmode == realmotionblurmode) {
1701 if (screentexture2) {
1702 glBindTexture( GL_TEXTURE_2D, screentexture2);
1703 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1705 if (!screentexture2) {
1706 glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
1708 glGenTextures( 1, &screentexture2 );
1709 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
1711 glEnable(GL_TEXTURE_2D);
1712 glBindTexture( GL_TEXTURE_2D, screentexture2);
1713 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
1714 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
1716 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
1721 glClear(GL_DEPTH_BUFFER_BIT);
1722 Game::ReSizeGLScene(90, .1f);
1723 glViewport(0, 0, screenwidth, screenheight);
1725 if (drawmode != normalmode) {
1726 glDisable(GL_DEPTH_TEST);
1727 if (drawmode == motionblurmode) {
1728 glDrawBuffer(GL_FRONT);
1729 glReadBuffer(GL_BACK);
1731 glColor3f (1.0, 1.0, 1.0); // no coloring
1733 glEnable(GL_TEXTURE_2D);
1734 glBindTexture( GL_TEXTURE_2D, screentexture);
1735 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1736 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1737 glDisable(GL_DEPTH_TEST);
1738 glDisable(GL_CULL_FACE);
1739 glDisable(GL_LIGHTING);
1741 glMatrixMode(GL_PROJECTION);
1744 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1745 glMatrixMode(GL_MODELVIEW);
1748 glScalef((float)screenwidth / 2, (float)screenheight / 2, 1);
1749 glTranslatef(1, 1, 0);
1750 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1752 if (drawmode == motionblurmode) {
1753 if (motionbluramount < .2)
1754 motionbluramount = .2;
1755 glColor4f(1, 1, 1, motionbluramount);
1759 glVertex3f(-1, -1, 0.0f);
1760 glTexCoord2f(texcoordwidth, 0);
1761 glVertex3f(1, -1, 0.0f);
1762 glTexCoord2f(texcoordwidth, texcoordheight);
1763 glVertex3f(1, 1, 0.0f);
1764 glTexCoord2f(0, texcoordheight);
1765 glVertex3f(-1, 1, 0.0f);
1769 if (drawmode == realmotionblurmode) {
1770 glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
1771 glClear(GL_COLOR_BUFFER_BIT);
1772 glBlendFunc(GL_SRC_ALPHA, GL_ONE);
1773 glBindTexture( GL_TEXTURE_2D, screentexture);
1774 glColor4f(1, 1, 1, .5);
1778 glVertex3f(-1, -1, 0.0f);
1779 glTexCoord2f(texcoordwidth, 0);
1780 glVertex3f(1, -1, 0.0f);
1781 glTexCoord2f(texcoordwidth, texcoordheight);
1782 glVertex3f(1, 1, 0.0f);
1783 glTexCoord2f(0, texcoordheight);
1784 glVertex3f(-1, 1, 0.0f);
1787 glBindTexture( GL_TEXTURE_2D, screentexture2);
1788 glColor4f(1, 1, 1, .5);
1792 glVertex3f(-1, -1, 0.0f);
1793 glTexCoord2f(texcoordwidth, 0);
1794 glVertex3f(1, -1, 0.0f);
1795 glTexCoord2f(texcoordwidth, texcoordheight);
1796 glVertex3f(1, 1, 0.0f);
1797 glTexCoord2f(0, texcoordheight);
1798 glVertex3f(-1, 1, 0.0f);
1801 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1803 if (drawmode == doublevisionmode) {
1804 static float crosseyedness;
1805 crosseyedness = abs(Person::players[0]->damage - Person::players[0]->superpermanentdamage - (Person::players[0]->damagetolerance - Person::players[0]->superpermanentdamage) * 1 / 2) / 30;
1806 if (crosseyedness > 1)
1808 if (crosseyedness < 0)
1810 glColor4f(1, 1, 1, 1);
1811 glDisable(GL_BLEND);
1816 glVertex3f(-1, -1, 0.0f);
1817 glTexCoord2f(texcoordwidth, 0);
1818 glVertex3f(1, -1, 0.0f);
1819 glTexCoord2f(texcoordwidth, texcoordheight);
1820 glVertex3f(1, 1, 0.0f);
1821 glTexCoord2f(0, texcoordheight);
1822 glVertex3f(-1, 1, 0.0f);
1825 if (crosseyedness) {
1826 glColor4f(1, 1, 1, .5);
1829 glTranslatef(.015 * crosseyedness, 0, 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);
1844 if (drawmode == glowmode) {
1845 glColor4f(.5, .5, .5, .5);
1847 glBlendFunc(GL_SRC_ALPHA, GL_ONE);
1849 glTranslatef(.01, 0, 0);
1852 glVertex3f(-1, -1, 0.0f);
1853 glTexCoord2f(texcoordwidth, 0);
1854 glVertex3f(1, -1, 0.0f);
1855 glTexCoord2f(texcoordwidth, texcoordheight);
1856 glVertex3f(1, 1, 0.0f);
1857 glTexCoord2f(0, texcoordheight);
1858 glVertex3f(-1, 1, 0.0f);
1862 glTranslatef(-.01, 0, 0);
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);
1875 glTranslatef(.0, .01, 0);
1878 glVertex3f(-1, -1, 0.0f);
1879 glTexCoord2f(texcoordwidth, 0);
1880 glVertex3f(1, -1, 0.0f);
1881 glTexCoord2f(texcoordwidth, texcoordheight);
1882 glVertex3f(1, 1, 0.0f);
1883 glTexCoord2f(0, texcoordheight);
1884 glVertex3f(-1, 1, 0.0f);
1888 glTranslatef(0, -.01, 0);
1891 glVertex3f(-1, -1, 0.0f);
1892 glTexCoord2f(texcoordwidth, 0);
1893 glVertex3f(1, -1, 0.0f);
1894 glTexCoord2f(texcoordwidth, texcoordheight);
1895 glVertex3f(1, 1, 0.0f);
1896 glTexCoord2f(0, texcoordheight);
1897 glVertex3f(-1, 1, 0.0f);
1901 if (drawmode == radialzoommode) {
1902 for (int i = 0; i < 3; i++) {
1903 glColor4f(1, 1, 1, 1 / ((float)i + 1));
1905 glScalef(1 + (float)i * .01, 1 + (float)i * .01, 1);
1908 glVertex3f(-1, -1, 0.0f);
1909 glTexCoord2f(texcoordwidth, 0);
1910 glVertex3f(1, -1, 0.0f);
1911 glTexCoord2f(texcoordwidth, texcoordheight);
1912 glVertex3f(1, 1, 0.0f);
1913 glTexCoord2f(0, texcoordheight);
1914 glVertex3f(-1, 1, 0.0f);
1919 glDisable(GL_TEXTURE_2D);
1920 glMatrixMode(GL_PROJECTION);
1922 glMatrixMode(GL_MODELVIEW);
1924 glEnable(GL_DEPTH_TEST);
1925 glEnable(GL_CULL_FACE);
1926 glDisable(GL_BLEND);
1931 glEnable(GL_TEXTURE_2D);
1932 glColor4f(1, 1, 1, 1);
1934 if (consoleselected >= 60)
1935 offset = consoleselected - 60;
1936 sprintf (string, " ]");
1937 text->glPrint(10, 30, string, 0, 1, 1024, 768);
1939 sprintf (string, "_");
1940 text->glPrint(30 + (float)(consoleselected) * 10 - offset * 10, 30, string, 0, 1, 1024, 768);
1942 for (unsigned i = 0; i < 15; i++)
1943 for (unsigned j = 0; j < consoletext[i].size(); j++) {
1944 glColor4f(1, 1, 1, 1 - (float)(i) / 16);
1945 sprintf (string, "%c", consoletext[i][j]);
1946 text->glPrint(30 + j * 10 - offset * 10, 30 + i * 20, string, 0, 1, 1024, 768);
1951 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted)) {
1952 multiplier = tempmult;
1959 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted)) {
1960 tempmult = multiplier;
1964 if ( side == stereoRight || side == stereoCenter ) {
1965 if (drawmode != motionblurmode || mainmenu) {
1970 glDrawBuffer(GL_BACK);
1971 glReadBuffer(GL_BACK);
1975 if (drawtoggle == 2)
1978 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted)) {
1979 multiplier = tempmult;
1981 //Jordan fixed your warning!
1987 // !!! FIXME: hack: clamp framerate in menu so text input works correctly on fast systems.
1990 glDrawBuffer(GL_BACK);
1991 glReadBuffer(GL_BACK);
1992 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
1993 Game::ReSizeGLScene(90, .1f);
1995 //draw menu background
1996 glClear(GL_DEPTH_BUFFER_BIT);
1997 glEnable(GL_ALPHA_TEST);
1998 glAlphaFunc(GL_GREATER, 0.001f);
1999 glEnable(GL_TEXTURE_2D);
2000 glDisable(GL_DEPTH_TEST);
2001 glDisable(GL_CULL_FACE);
2002 glDisable(GL_LIGHTING);
2004 glMatrixMode(GL_PROJECTION);
2007 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
2008 glMatrixMode(GL_MODELVIEW);
2011 glTranslatef(screenwidth / 2, screenheight / 2, 0);
2013 glScalef((float)screenwidth / 2, (float)screenheight / 2, 1);
2014 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
2015 glDisable(GL_BLEND);
2016 glColor4f(0, 0, 0, 1.0);
2017 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2018 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2019 glDisable(GL_TEXTURE_2D);
2021 glVertex3f(-1, -1, 0);
2022 glVertex3f(+1, -1, 0);
2023 glVertex3f(+1, +1, 0);
2024 glVertex3f(-1, +1, 0);
2027 glColor4f(0.4, 0.4, 0.4, 1.0);
2028 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2029 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2030 glEnable(GL_TEXTURE_2D);
2031 Game::Mainmenuitems[4].bind();
2034 glVertex3f(-1, -1, 0);
2036 glVertex3f(+1, -1, 0);
2038 glVertex3f(+1, +1, 0);
2040 glVertex3f(-1, +1, 0);
2044 glMatrixMode(GL_PROJECTION);
2046 glMatrixMode(GL_MODELVIEW);
2050 glMatrixMode(GL_PROJECTION);
2053 glOrtho(0, 640, 0, 480, -100, 100);
2054 glMatrixMode(GL_MODELVIEW);
2057 glEnable(GL_TEXTURE_2D);
2062 glMatrixMode(GL_PROJECTION);
2064 glMatrixMode(GL_MODELVIEW);
2067 glMatrixMode(GL_PROJECTION);
2070 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
2071 glMatrixMode(GL_MODELVIEW);
2074 glTranslatef(screenwidth / 2, screenheight / 2, 0);
2076 glScalef((float)screenwidth / 2, (float)screenheight / 2, 1);
2077 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
2079 glEnable(GL_TEXTURE_2D);
2080 glColor4f(1, 1, 1, 1);
2081 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2082 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2084 if (!Game::waiting) { // hide the cursor while waiting for a key
2086 glTranslatef(Game::mousecoordh - screenwidth / 2, Game::mousecoordv * -1 + screenheight / 2, 0);
2087 glScalef((float)screenwidth / 64, (float)screenwidth / 64, 1);
2088 glTranslatef(1, -1, 0);
2089 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
2090 glColor4f(1, 1, 1, 1);
2091 Game::cursortexture.bind();
2095 glVertex3f(-1, -1, 0.0f);
2097 glVertex3f(1, -1, 0.0f);
2099 glVertex3f(1, 1, 0.0f);
2101 glVertex3f(-1, 1, 0.0f);
2107 glMatrixMode(GL_PROJECTION);
2112 if (flashamount > 0) {
2113 if (flashamount > 1)
2115 if (flashdelay <= 0)
2116 flashamount -= multiplier;
2118 if (flashamount < 0)
2120 glDisable(GL_DEPTH_TEST);
2121 glDisable(GL_CULL_FACE);
2122 glDisable(GL_LIGHTING);
2123 glDisable(GL_TEXTURE_2D);
2125 glMatrixMode(GL_PROJECTION);
2128 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
2129 glMatrixMode(GL_MODELVIEW);
2132 glScalef(screenwidth, screenheight, 1);
2133 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
2135 glColor4f(flashr, flashg, flashb, flashamount);
2137 glVertex3f(0, 0, 0.0f);
2138 glVertex3f(256, 0, 0.0f);
2139 glVertex3f(256, 256, 0.0f);
2140 glVertex3f(0, 256, 0.0f);
2142 glMatrixMode(GL_PROJECTION);
2144 glMatrixMode(GL_MODELVIEW);
2146 glEnable(GL_DEPTH_TEST);
2147 glEnable(GL_CULL_FACE);
2148 glDisable(GL_BLEND);