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);
1437 int numliveplayers = 0;
1439 for (unsigned i = 0; i < Person::players.size(); i++) {
1440 if (!Person::players[i]->dead)
1446 for (int i = 0; i < objects.numobjects; i++) {
1447 if (objects.type[i] == treetrunktype || objects.type[i] == boxtype) {
1448 center += objects.position[i];
1452 for (unsigned i = 0; i < Person::players.size(); i++) {
1453 if (!Person::players[i]->dead)
1454 center += Person::players[i]->coords;
1456 center /= numadd + numliveplayers;
1458 center = Person::players[0]->coords;
1460 float maxdistance = 0;
1462 for (int i = 0; i < objects.numobjects; i++) {
1463 tempdist = distsq(¢er, &objects.position[i]);
1464 if (tempdist > maxdistance) {
1465 maxdistance = tempdist;
1468 for (unsigned i = 0; i < Person::players.size(); i++) {
1469 if (!Person::players[i]->dead) {
1470 tempdist = distsq(¢er, &Person::players[i]->coords);
1471 if (tempdist > maxdistance) {
1472 maxdistance = tempdist;
1478 glScalef(.25 / radius * 256 * terrain.scale * .4, .25 / radius * 256 * terrain.scale * .4, 1);
1480 glScalef(1 / (1 / radius * 256 * terrain.scale * .4), 1 / (1 / radius * 256 * terrain.scale * .4), 1);
1482 glRotatef(Person::players[0]->lookyaw * -1 + 180, 0, 0, 1);
1483 glTranslatef(-(center.x / terrain.scale / 256 * -2 + 1), (center.z / terrain.scale / 256 * -2 + 1), 0);
1484 for (int i = 0; i < objects.numobjects; i++) {
1485 if (objects.type[i] == treetrunktype) {
1486 distcheck = distsq(&Person::players[0]->coords, &objects.position[i]);
1487 if (distcheck < mapviewdist) {
1488 Mapcircletexture.bind();
1489 glColor4f(0, .3, 0, opac * (1 - distcheck / mapviewdist));
1491 glTranslatef(objects.position[i].x / terrain.scale / 256 * -2 + 1, objects.position[i].z / terrain.scale / 256 * 2 - 1, 0);
1492 glRotatef(objects.yaw[i], 0, 0, 1);
1493 glScalef(.003, .003, .003);
1496 glVertex3f(-1, -1, 0.0f);
1498 glVertex3f(1, -1, 0.0f);
1500 glVertex3f(1, 1, 0.0f);
1502 glVertex3f(-1, 1, 0.0f);
1507 if (objects.type[i] == boxtype) {
1508 distcheck = distsq(&Person::players[0]->coords, &objects.position[i]);
1509 if (distcheck < mapviewdist) {
1510 Mapboxtexture.bind();
1511 glColor4f(.4, .4, .4, opac * (1 - distcheck / mapviewdist));
1513 glTranslatef(objects.position[i].x / terrain.scale / 256 * -2 + 1, objects.position[i].z / terrain.scale / 256 * 2 - 1, 0);
1514 glRotatef(objects.yaw[i], 0, 0, 1);
1515 glScalef(.01 * objects.scale[i], .01 * objects.scale[i], .01 * objects.scale[i]);
1518 glVertex3f(-1, -1, 0.0f);
1520 glVertex3f(1, -1, 0.0f);
1522 glVertex3f(1, 1, 0.0f);
1524 glVertex3f(-1, 1, 0.0f);
1530 if (editorenabled) {
1531 Mapcircletexture.bind();
1532 for (int i = 0; i < numboundaries; i++) {
1533 glColor4f(0, 0, 0, opac / 3);
1535 glTranslatef(boundary[i].x / terrain.scale / 256 * -2 + 1, boundary[i].z / terrain.scale / 256 * 2 - 1, 0);
1536 glScalef(.002, .002, .002);
1539 glVertex3f(-1, -1, 0.0f);
1541 glVertex3f(1, -1, 0.0f);
1543 glVertex3f(1, 1, 0.0f);
1545 glVertex3f(-1, 1, 0.0f);
1550 for (unsigned i = 0; i < Person::players.size(); i++) {
1551 distcheck = distsq(&Person::players[0]->coords, &Person::players[i]->coords);
1552 if (distcheck < mapviewdist) {
1554 Maparrowtexture.bind();
1556 glColor4f(1, 1, 1, opac);
1557 else if (Person::players[i]->dead == 2 || Person::players[i]->howactive > typesleeping)
1558 glColor4f(0, 0, 0, opac * (1 - distcheck / mapviewdist));
1559 else if (Person::players[i]->dead)
1560 glColor4f(.3, .3, .3, opac * (1 - distcheck / mapviewdist));
1561 else if (Person::players[i]->aitype == attacktypecutoff)
1562 glColor4f(1, 0, 0, opac * (1 - distcheck / mapviewdist));
1563 else if (Person::players[i]->aitype == passivetype)
1564 glColor4f(0, 1, 0, opac * (1 - distcheck / mapviewdist));
1566 glColor4f(1, 1, 0, 1);
1567 glTranslatef(Person::players[i]->coords.x / terrain.scale / 256 * -2 + 1, Person::players[i]->coords.z / terrain.scale / 256 * 2 - 1, 0);
1568 glRotatef(Person::players[i]->yaw + 180, 0, 0, 1);
1569 glScalef(.005, .005, .005);
1572 glVertex3f(-1, -1, 0.0f);
1574 glVertex3f(1, -1, 0.0f);
1576 glVertex3f(1, 1, 0.0f);
1578 glVertex3f(-1, 1, 0.0f);
1584 glDisable(GL_TEXTURE_2D);
1585 glMatrixMode(GL_PROJECTION);
1587 glMatrixMode(GL_MODELVIEW);
1589 glEnable(GL_DEPTH_TEST);
1590 glEnable(GL_CULL_FACE);
1591 glDisable(GL_BLEND);
1595 if (loading && !stealthloading && (!campaign || Person::players[0]->dead)) {
1596 glDisable(GL_DEPTH_TEST);
1597 glDisable(GL_CULL_FACE);
1598 glDisable(GL_LIGHTING);
1599 glDisable(GL_TEXTURE_2D);
1601 glMatrixMode(GL_PROJECTION);
1604 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1605 glMatrixMode(GL_MODELVIEW);
1608 glScalef(screenwidth, screenheight, 1);
1609 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1611 glColor4f(0, 0, 0, .7);
1613 glVertex3f(0, 0, 0.0f);
1614 glVertex3f(256, 0, 0.0f);
1615 glVertex3f(256, 256, 0.0f);
1616 glVertex3f(0, 256, 0.0f);
1618 glMatrixMode(GL_PROJECTION);
1620 glMatrixMode(GL_MODELVIEW);
1622 glEnable(GL_DEPTH_TEST);
1623 glEnable(GL_CULL_FACE);
1624 glDisable(GL_BLEND);
1628 glDisable(GL_DEPTH_TEST);
1629 glColor3f (1.0, 1.0, 1.0); // no coloring
1631 glEnable(GL_TEXTURE_2D);
1636 glEnable(GL_TEXTURE_2D);
1637 glColor4f(1, 1, 1, 1);
1638 sprintf (string, "Loading...");
1639 text->glPrint(1024 / 2 - 90, 768 / 2, string, 1, 2, 1024, 768);
1642 drawmode = normalmode;
1645 if (winfreeze && !campaign) {
1646 glDisable(GL_DEPTH_TEST);
1647 glDisable(GL_CULL_FACE);
1648 glDisable(GL_LIGHTING);
1649 glDisable(GL_TEXTURE_2D);
1651 glMatrixMode(GL_PROJECTION);
1654 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1655 glMatrixMode(GL_MODELVIEW);
1658 glScalef(screenwidth, screenheight, 1);
1659 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1661 glColor4f(0, 0, 0, .4);
1663 glVertex3f(0, 0, 0.0f);
1664 glVertex3f(256, 0, 0.0f);
1665 glVertex3f(256, 256, 0.0f);
1666 glVertex3f(0, 256, 0.0f);
1668 glMatrixMode(GL_PROJECTION);
1670 glMatrixMode(GL_MODELVIEW);
1672 glEnable(GL_DEPTH_TEST);
1673 glEnable(GL_CULL_FACE);
1674 glDisable(GL_BLEND);
1678 glDisable(GL_DEPTH_TEST);
1679 glColor3f (1.0, 1.0, 1.0); // no coloring
1681 glEnable(GL_TEXTURE_2D);
1683 //Win Screen Won Victory
1685 glEnable(GL_TEXTURE_2D);
1686 glColor4f(1, 1, 1, 1);
1687 sprintf (string, "Level Cleared!");
1688 text->glPrintOutlined(1024 / 2 - strlen(string) * 10, 768 * 7 / 8, string, 1, 2, 1024, 768);
1690 sprintf (string, "Score: %d", (int)(bonustotal - startbonustotal));
1691 text->glPrintOutlined(1024 / 30, 768 * 6 / 8, string, 1, 2, 1024, 768);
1694 sprintf (string, "Press Escape or Space to continue");
1696 sprintf (string, "Press Escape to return to menu or Space to continue");
1697 text->glPrintOutlined(640 / 2 - strlen(string) * 5, 480 * 1 / 16, string, 1, 1, 640, 480);
1701 for (int i = 0; i < 255; i++)
1703 sprintf (temp, "Time: %d:", (int)(((int)leveltime - (int)(leveltime) % 60) / 60));
1704 strcat(string, temp);
1705 if ((int)(leveltime) % 60 < 10)
1706 strcat(string, "0");
1707 sprintf (temp, "%d", (int)(leveltime) % 60);
1708 strcat(string, temp);
1709 text->glPrintOutlined(1024 / 30, 768 * 6 / 8 - 40, string, 1, 2, 1024, 768);
1712 int awards[award_count];
1713 int numawards = award_awards(awards);
1715 for (int i = 0; i < numawards && i < 6; i++)
1716 text->glPrintOutlined(1024 / 30, 768 * 6 / 8 - 90 - 40 * i, award_names[awards[i]], 1, 2, 1024, 768);
1719 if (drawmode != normalmode) {
1720 glEnable(GL_TEXTURE_2D);
1722 if (!drawtoggle || drawmode != realmotionblurmode || (drawtoggle == 2 || change == 1)) {
1723 if (screentexture) {
1725 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
1726 GLfloat subtractColor[4] = { 0.5, 0.5, 0.5, 0.0 };
1727 glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, subtractColor);
1728 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE);
1729 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_CONSTANT_EXT);
1730 glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 2.0f);
1732 glBindTexture( GL_TEXTURE_2D, screentexture);
1733 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1736 if ((drawtoggle || change == 1) && drawmode == realmotionblurmode) {
1737 if (screentexture2) {
1738 glBindTexture( GL_TEXTURE_2D, screentexture2);
1739 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1741 if (!screentexture2) {
1742 glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
1744 glGenTextures( 1, &screentexture2 );
1745 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
1747 glEnable(GL_TEXTURE_2D);
1748 glBindTexture( GL_TEXTURE_2D, screentexture2);
1749 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
1750 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
1752 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
1757 glClear(GL_DEPTH_BUFFER_BIT);
1758 Game::ReSizeGLScene(90, .1f);
1759 glViewport(0, 0, screenwidth, screenheight);
1761 if (drawmode != normalmode) {
1762 glDisable(GL_DEPTH_TEST);
1763 if (drawmode == motionblurmode) {
1764 glDrawBuffer(GL_FRONT);
1765 glReadBuffer(GL_BACK);
1767 glColor3f (1.0, 1.0, 1.0); // no coloring
1769 glEnable(GL_TEXTURE_2D);
1770 glBindTexture( GL_TEXTURE_2D, screentexture);
1771 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1772 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1773 glDisable(GL_DEPTH_TEST);
1774 glDisable(GL_CULL_FACE);
1775 glDisable(GL_LIGHTING);
1777 glMatrixMode(GL_PROJECTION);
1780 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1781 glMatrixMode(GL_MODELVIEW);
1784 glScalef((float)screenwidth / 2, (float)screenheight / 2, 1);
1785 glTranslatef(1, 1, 0);
1786 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1788 if (drawmode == motionblurmode) {
1789 if (motionbluramount < .2)
1790 motionbluramount = .2;
1791 glColor4f(1, 1, 1, motionbluramount);
1795 glVertex3f(-1, -1, 0.0f);
1796 glTexCoord2f(texcoordwidth, 0);
1797 glVertex3f(1, -1, 0.0f);
1798 glTexCoord2f(texcoordwidth, texcoordheight);
1799 glVertex3f(1, 1, 0.0f);
1800 glTexCoord2f(0, texcoordheight);
1801 glVertex3f(-1, 1, 0.0f);
1805 if (drawmode == realmotionblurmode) {
1806 glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
1807 glClear(GL_COLOR_BUFFER_BIT);
1808 glBlendFunc(GL_SRC_ALPHA, GL_ONE);
1809 glBindTexture( GL_TEXTURE_2D, screentexture);
1810 glColor4f(1, 1, 1, .5);
1814 glVertex3f(-1, -1, 0.0f);
1815 glTexCoord2f(texcoordwidth, 0);
1816 glVertex3f(1, -1, 0.0f);
1817 glTexCoord2f(texcoordwidth, texcoordheight);
1818 glVertex3f(1, 1, 0.0f);
1819 glTexCoord2f(0, texcoordheight);
1820 glVertex3f(-1, 1, 0.0f);
1823 glBindTexture( GL_TEXTURE_2D, screentexture2);
1824 glColor4f(1, 1, 1, .5);
1828 glVertex3f(-1, -1, 0.0f);
1829 glTexCoord2f(texcoordwidth, 0);
1830 glVertex3f(1, -1, 0.0f);
1831 glTexCoord2f(texcoordwidth, texcoordheight);
1832 glVertex3f(1, 1, 0.0f);
1833 glTexCoord2f(0, texcoordheight);
1834 glVertex3f(-1, 1, 0.0f);
1837 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1839 if (drawmode == doublevisionmode) {
1840 static float crosseyedness;
1841 crosseyedness = abs(Person::players[0]->damage - Person::players[0]->superpermanentdamage - (Person::players[0]->damagetolerance - Person::players[0]->superpermanentdamage) * 1 / 2) / 30;
1842 if (crosseyedness > 1)
1844 if (crosseyedness < 0)
1846 glColor4f(1, 1, 1, 1);
1847 glDisable(GL_BLEND);
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);
1861 if (crosseyedness) {
1862 glColor4f(1, 1, 1, .5);
1865 glTranslatef(.015 * crosseyedness, 0, 0);
1869 glVertex3f(-1, -1, 0.0f);
1870 glTexCoord2f(texcoordwidth, 0);
1871 glVertex3f(1, -1, 0.0f);
1872 glTexCoord2f(texcoordwidth, texcoordheight);
1873 glVertex3f(1, 1, 0.0f);
1874 glTexCoord2f(0, texcoordheight);
1875 glVertex3f(-1, 1, 0.0f);
1880 if (drawmode == glowmode) {
1881 glColor4f(.5, .5, .5, .5);
1883 glBlendFunc(GL_SRC_ALPHA, GL_ONE);
1885 glTranslatef(.01, 0, 0);
1888 glVertex3f(-1, -1, 0.0f);
1889 glTexCoord2f(texcoordwidth, 0);
1890 glVertex3f(1, -1, 0.0f);
1891 glTexCoord2f(texcoordwidth, texcoordheight);
1892 glVertex3f(1, 1, 0.0f);
1893 glTexCoord2f(0, texcoordheight);
1894 glVertex3f(-1, 1, 0.0f);
1898 glTranslatef(-.01, 0, 0);
1901 glVertex3f(-1, -1, 0.0f);
1902 glTexCoord2f(texcoordwidth, 0);
1903 glVertex3f(1, -1, 0.0f);
1904 glTexCoord2f(texcoordwidth, texcoordheight);
1905 glVertex3f(1, 1, 0.0f);
1906 glTexCoord2f(0, texcoordheight);
1907 glVertex3f(-1, 1, 0.0f);
1911 glTranslatef(.0, .01, 0);
1914 glVertex3f(-1, -1, 0.0f);
1915 glTexCoord2f(texcoordwidth, 0);
1916 glVertex3f(1, -1, 0.0f);
1917 glTexCoord2f(texcoordwidth, texcoordheight);
1918 glVertex3f(1, 1, 0.0f);
1919 glTexCoord2f(0, texcoordheight);
1920 glVertex3f(-1, 1, 0.0f);
1924 glTranslatef(0, -.01, 0);
1927 glVertex3f(-1, -1, 0.0f);
1928 glTexCoord2f(texcoordwidth, 0);
1929 glVertex3f(1, -1, 0.0f);
1930 glTexCoord2f(texcoordwidth, texcoordheight);
1931 glVertex3f(1, 1, 0.0f);
1932 glTexCoord2f(0, texcoordheight);
1933 glVertex3f(-1, 1, 0.0f);
1937 if (drawmode == radialzoommode) {
1938 for (int i = 0; i < 3; i++) {
1939 glColor4f(1, 1, 1, 1 / ((float)i + 1));
1941 glScalef(1 + (float)i * .01, 1 + (float)i * .01, 1);
1944 glVertex3f(-1, -1, 0.0f);
1945 glTexCoord2f(texcoordwidth, 0);
1946 glVertex3f(1, -1, 0.0f);
1947 glTexCoord2f(texcoordwidth, texcoordheight);
1948 glVertex3f(1, 1, 0.0f);
1949 glTexCoord2f(0, texcoordheight);
1950 glVertex3f(-1, 1, 0.0f);
1955 glDisable(GL_TEXTURE_2D);
1956 glMatrixMode(GL_PROJECTION);
1958 glMatrixMode(GL_MODELVIEW);
1960 glEnable(GL_DEPTH_TEST);
1961 glEnable(GL_CULL_FACE);
1962 glDisable(GL_BLEND);
1967 glEnable(GL_TEXTURE_2D);
1968 glColor4f(1, 1, 1, 1);
1970 if (consoleselected >= 60)
1971 offset = consoleselected - 60;
1972 sprintf (string, " ]");
1973 text->glPrint(10, 30, string, 0, 1, 1024, 768);
1975 sprintf (string, "_");
1976 text->glPrint(30 + (float)(consoleselected) * 10 - offset * 10, 30, string, 0, 1, 1024, 768);
1978 for (unsigned i = 0; i < 15; i++)
1979 for (unsigned j = 0; j < consoletext[i].size(); j++) {
1980 glColor4f(1, 1, 1, 1 - (float)(i) / 16);
1981 sprintf (string, "%c", consoletext[i][j]);
1982 text->glPrint(30 + j * 10 - offset * 10, 30 + i * 20, string, 0, 1, 1024, 768);
1987 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted)) {
1988 multiplier = tempmult;
1995 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted)) {
1996 tempmult = multiplier;
2000 if ( side == stereoRight || side == stereoCenter ) {
2001 if (drawmode != motionblurmode || mainmenu) {
2006 glDrawBuffer(GL_BACK);
2007 glReadBuffer(GL_BACK);
2011 if (drawtoggle == 2)
2014 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted)) {
2015 multiplier = tempmult;
2017 //Jordan fixed your warning!
2023 // !!! FIXME: hack: clamp framerate in menu so text input works correctly on fast systems.
2026 glDrawBuffer(GL_BACK);
2027 glReadBuffer(GL_BACK);
2028 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
2029 Game::ReSizeGLScene(90, .1f);
2031 //draw menu background
2032 glClear(GL_DEPTH_BUFFER_BIT);
2033 glEnable(GL_ALPHA_TEST);
2034 glAlphaFunc(GL_GREATER, 0.001f);
2035 glEnable(GL_TEXTURE_2D);
2036 glDisable(GL_DEPTH_TEST);
2037 glDisable(GL_CULL_FACE);
2038 glDisable(GL_LIGHTING);
2040 glMatrixMode(GL_PROJECTION);
2043 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
2044 glMatrixMode(GL_MODELVIEW);
2047 glTranslatef(screenwidth / 2, screenheight / 2, 0);
2049 glScalef((float)screenwidth / 2, (float)screenheight / 2, 1);
2050 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
2051 glDisable(GL_BLEND);
2052 glColor4f(0, 0, 0, 1.0);
2053 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2054 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2055 glDisable(GL_TEXTURE_2D);
2057 glVertex3f(-1, -1, 0);
2058 glVertex3f(+1, -1, 0);
2059 glVertex3f(+1, +1, 0);
2060 glVertex3f(-1, +1, 0);
2063 glColor4f(0.4, 0.4, 0.4, 1.0);
2064 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2065 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2066 glEnable(GL_TEXTURE_2D);
2067 Game::Mainmenuitems[4].bind();
2070 glVertex3f(-1, -1, 0);
2072 glVertex3f(+1, -1, 0);
2074 glVertex3f(+1, +1, 0);
2076 glVertex3f(-1, +1, 0);
2080 glMatrixMode(GL_PROJECTION);
2082 glMatrixMode(GL_MODELVIEW);
2086 glMatrixMode(GL_PROJECTION);
2089 glOrtho(0, 640, 0, 480, -100, 100);
2090 glMatrixMode(GL_MODELVIEW);
2093 glEnable(GL_TEXTURE_2D);
2098 glMatrixMode(GL_PROJECTION);
2100 glMatrixMode(GL_MODELVIEW);
2103 glMatrixMode(GL_PROJECTION);
2106 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
2107 glMatrixMode(GL_MODELVIEW);
2110 glTranslatef(screenwidth / 2, screenheight / 2, 0);
2112 glScalef((float)screenwidth / 2, (float)screenheight / 2, 1);
2113 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
2115 glEnable(GL_TEXTURE_2D);
2116 glColor4f(1, 1, 1, 1);
2117 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2118 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2120 if (!Game::waiting) { // hide the cursor while waiting for a key
2122 glTranslatef(Game::mousecoordh - screenwidth / 2, Game::mousecoordv * -1 + screenheight / 2, 0);
2123 glScalef((float)screenwidth / 64, (float)screenwidth / 64, 1);
2124 glTranslatef(1, -1, 0);
2125 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
2126 glColor4f(1, 1, 1, 1);
2127 Game::cursortexture.bind();
2131 glVertex3f(-1, -1, 0.0f);
2133 glVertex3f(1, -1, 0.0f);
2135 glVertex3f(1, 1, 0.0f);
2137 glVertex3f(-1, 1, 0.0f);
2143 glMatrixMode(GL_PROJECTION);
2148 if (flashamount > 0) {
2149 if (flashamount > 1)
2151 if (flashdelay <= 0)
2152 flashamount -= multiplier;
2154 if (flashamount < 0)
2156 glDisable(GL_DEPTH_TEST);
2157 glDisable(GL_CULL_FACE);
2158 glDisable(GL_LIGHTING);
2159 glDisable(GL_TEXTURE_2D);
2161 glMatrixMode(GL_PROJECTION);
2164 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
2165 glMatrixMode(GL_MODELVIEW);
2168 glScalef(screenwidth, screenheight, 1);
2169 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
2171 glColor4f(flashr, flashg, flashb, flashamount);
2173 glVertex3f(0, 0, 0.0f);
2174 glVertex3f(256, 0, 0.0f);
2175 glVertex3f(256, 256, 0.0f);
2176 glVertex3f(0, 256, 0.0f);
2178 glMatrixMode(GL_PROJECTION);
2180 glMatrixMode(GL_MODELVIEW);
2182 glEnable(GL_DEPTH_TEST);
2183 glEnable(GL_CULL_FACE);
2184 glDisable(GL_BLEND);