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 (hotspottype[closest] <= 10) {
911 if (distsq(&Person::players[0]->coords, &hotspot[closest]) < hotspotsize[closest])
912 tutorialstagetime = 0;
914 tutorialopac = tutorialmaxtime - tutorialstagetime;
915 if (tutorialopac > 1)
917 if (tutorialopac < 0)
920 sprintf (string, "%s", hotspottext[closest]);
927 if (string[i] == '\n' || string[i] > 'z' || string[i] < ' ' || string[i] == '\0') {
928 glColor4f(0, 0, 0, tutorialopac);
929 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);
930 glColor4f(1, 1, 1, tutorialopac);
931 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);
934 if (string[i] == '\0')
941 } else if (hotspottype[closest] >= 20 && dialoguegonethrough[hotspottype[closest] - 20] == 0) {
942 whichdialogue = hotspottype[closest] - 20;
943 for (int j = 0; j < numdialogueboxes[whichdialogue]; j++) {
944 Person::players[participantfocus[whichdialogue][j]]->coords = participantlocation[whichdialogue][participantfocus[whichdialogue][j]];
945 Person::players[participantfocus[whichdialogue][j]]->yaw = participantyaw[whichdialogue][participantfocus[whichdialogue][j]];
946 Person::players[participantfocus[whichdialogue][j]]->targetyaw = participantyaw[whichdialogue][participantfocus[whichdialogue][j]];
947 Person::players[participantfocus[whichdialogue][j]]->velocity = 0;
948 Person::players[participantfocus[whichdialogue][j]]->animTarget = Person::players[participantfocus[whichdialogue][j]]->getIdle();
949 Person::players[participantfocus[whichdialogue][j]]->frameTarget = 0;
953 dialoguegonethrough[whichdialogue]++;
954 if (dialogueboxsound[whichdialogue][indialogue] != 0) {
956 if (dialogueboxsound[whichdialogue][indialogue] == 1) whichsoundplay = rabbitchitter;
957 if (dialogueboxsound[whichdialogue][indialogue] == 2) whichsoundplay = rabbitchitter2;
958 if (dialogueboxsound[whichdialogue][indialogue] == 3) whichsoundplay = rabbitpainsound;
959 if (dialogueboxsound[whichdialogue][indialogue] == 4) whichsoundplay = rabbitpain1sound;
960 if (dialogueboxsound[whichdialogue][indialogue] == 5) whichsoundplay = rabbitattacksound;
961 if (dialogueboxsound[whichdialogue][indialogue] == 6) whichsoundplay = rabbitattack2sound;
962 if (dialogueboxsound[whichdialogue][indialogue] == 7) whichsoundplay = rabbitattack3sound;
963 if (dialogueboxsound[whichdialogue][indialogue] == 8) whichsoundplay = rabbitattack4sound;
964 if (dialogueboxsound[whichdialogue][indialogue] == 9) whichsoundplay = growlsound;
965 if (dialogueboxsound[whichdialogue][indialogue] == 10) whichsoundplay = growl2sound;
966 if (dialogueboxsound[whichdialogue][indialogue] == 11) whichsoundplay = snarlsound;
967 if (dialogueboxsound[whichdialogue][indialogue] == 12) whichsoundplay = snarl2sound;
968 if (dialogueboxsound[whichdialogue][indialogue] == 13) whichsoundplay = barksound;
969 if (dialogueboxsound[whichdialogue][indialogue] == 14) whichsoundplay = bark2sound;
970 if (dialogueboxsound[whichdialogue][indialogue] == 15) whichsoundplay = bark3sound;
971 if (dialogueboxsound[whichdialogue][indialogue] == 16) whichsoundplay = barkgrowlsound;
972 if (dialogueboxsound[whichdialogue][indialogue] == -1) whichsoundplay = fireendsound;
973 if (dialogueboxsound[whichdialogue][indialogue] == -2) whichsoundplay = firestartsound;
974 if (dialogueboxsound[whichdialogue][indialogue] == -3) whichsoundplay = consolesuccesssound;
975 if (dialogueboxsound[whichdialogue][indialogue] == -4) whichsoundplay = consolefailsound;
976 emit_sound_at(whichsoundplay, Person::players[participantfocus[whichdialogue][indialogue]]->coords);
982 if (indialogue != -1 && !mainmenu) {
983 glDisable(GL_DEPTH_TEST);
984 glDisable(GL_CULL_FACE);
985 glDisable(GL_LIGHTING);
986 glDisable(GL_TEXTURE_2D);
988 glMatrixMode(GL_PROJECTION);
991 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
992 glMatrixMode(GL_MODELVIEW);
995 if (dialogueboxlocation[whichdialogue][indialogue] == 1)
996 glTranslatef(0, screenheight * 3 / 4, 0);
997 glScalef(screenwidth, screenheight / 4, 1);
998 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1001 glColor4f(dialogueboxcolor[whichdialogue][indialogue][0], dialogueboxcolor[whichdialogue][indialogue][1], dialogueboxcolor[whichdialogue][indialogue][2], 0.7);
1003 glVertex3f(0, 0, 0.0f);
1004 glVertex3f(1, 0, 0.0f);
1005 glVertex3f(1, 1, 0.0f);
1006 glVertex3f(0, 1, 0.0f);
1008 glMatrixMode(GL_PROJECTION);
1010 glMatrixMode(GL_MODELVIEW);
1012 glEnable(GL_DEPTH_TEST);
1013 glEnable(GL_CULL_FACE);
1014 glDisable(GL_BLEND);
1016 glEnable(GL_TEXTURE_2D);
1023 startx = screenwidth * 1 / 5;
1024 if (dialogueboxlocation[whichdialogue][indialogue] == 1)
1025 starty = screenheight / 16 + screenheight * 4 / 5;
1026 if (dialogueboxlocation[whichdialogue][indialogue] == 2)
1027 starty = screenheight * 1 / 5 - screenheight / 16;
1032 for (int i = 0; i < 264; i++) {
1036 for (int i = 0; i < (int)strlen(dialoguename[whichdialogue][indialogue]); i++) {
1037 tempname[tempnum] = dialoguename[whichdialogue][indialogue][i];
1039 if (dialoguename[whichdialogue][indialogue][i] == '#' || dialoguename[whichdialogue][indialogue][i] == '\0')
1044 tempname[tempnum] = '\0';
1047 sprintf (string, "%s: ", tempname);
1049 if (dialogueboxcolor[whichdialogue][indialogue][0] + dialogueboxcolor[whichdialogue][indialogue][1] + dialogueboxcolor[whichdialogue][indialogue][2] < 1.5) {
1050 glColor4f(0, 0, 0, tutorialopac);
1051 text->glPrintOutline(startx - 2 * 7.6 * strlen(string)*screenwidth / 1024 - 4, starty - 4, string, 1, 1.5 * 1.25 * screenwidth / 1024, screenwidth, screenheight);
1052 glColor4f(0.7, 0.7, 0.7, tutorialopac);
1053 text->glPrint(startx - 2 * 7.6 * strlen(string)*screenwidth / 1024, starty, string, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight);
1055 glColor4f(0, 0, 0, tutorialopac);
1056 text->glPrintOutline(startx - 2 * 7.6 * strlen(string)*screenwidth / 1024 - 4, starty - 4, string, 1, 1.5 * 1.25 * screenwidth / 1024, screenwidth, screenheight);
1060 for (int i = 0; i < (int)strlen(dialoguetext[whichdialogue][indialogue]) + 1; i++) {
1061 tempname[tempnum] = dialoguetext[whichdialogue][indialogue][i];
1062 if (dialoguetext[whichdialogue][indialogue][i] != '#')
1066 sprintf (string, "%s", tempname);
1073 if (string[i] == '\n' || string[i] > 'z' || string[i] < ' ' || string[i] == '\0') {
1074 if (dialogueboxcolor[whichdialogue][indialogue][0] + dialogueboxcolor[whichdialogue][indialogue][1] + dialogueboxcolor[whichdialogue][indialogue][2] < 1.5) {
1075 glColor4f(0, 0, 0, tutorialopac);
1076 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);
1077 glColor4f(1, 1, 1, tutorialopac);
1078 text->glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/, starty - 20 * screenwidth / 1024 * line, string, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight, lastline, i);
1080 glColor4f(0, 0, 0, tutorialopac);
1081 text->glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/, starty - 20 * screenwidth / 1024 * line, string, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight, lastline, i);
1085 if (string[i] == '\0')
1094 if (!tutoriallevel && !winfreeze && indialogue == -1 && !mainmenu) {
1097 sprintf (string, "Score: %d", (int)accountactive->getCampaignScore());
1099 sprintf (string, "Score: %d", (int)accountactive->getCampaignScore() + (int)bonustotal);
1102 sprintf (string, "Score: %d", (int)bonustotal);
1103 glColor4f(0, 0, 0, 1);
1104 text->glPrintOutline(1024 / 40 - 4, 768 / 16 - 4 + 768 * 14 / 16, string, 1, 1.5 * 1.25, 1024, 768);
1105 glColor4f(1, 0, 0, 1);
1106 text->glPrint(1024 / 40, 768 / 16 + 768 * 14 / 16, string, 1, 1.5, 1024, 768);
1107 if (showdamagebar) {
1108 glDisable(GL_DEPTH_TEST);
1109 glDisable(GL_CULL_FACE);
1110 glDisable(GL_LIGHTING);
1111 glDisable(GL_TEXTURE_2D);
1113 glMatrixMode(GL_PROJECTION);
1116 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1117 glMatrixMode(GL_MODELVIEW);
1120 glTranslatef(15, screenheight * 17.5 / 20, 0);
1121 glScalef(screenwidth / 3 + 20, screenheight / 20, 1);
1122 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1124 glColor4f(0.0, 0.4, 0.0, 0.7);
1125 float bar = ((float)Person::players[0]->damage) / Person::players[0]->damagetolerance;
1127 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
1128 glVertex3f(1, 0, 0.0f);
1129 glVertex3f(1, 1, 0.0f);
1130 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
1132 glColor4f(0.1, 0.0, 0.0, 1);
1133 bar = ((float)Person::players[0]->bloodloss) / Person::players[0]->damagetolerance;
1135 glVertex3f(0, 0, 0.0f);
1136 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
1137 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
1138 glVertex3f(0, 1, 0.0f);
1140 glColor4f(0.4, 0.0, 0.0, 0.7);
1141 bar = ((float)Person::players[0]->damage) / Person::players[0]->damagetolerance;
1143 glVertex3f(0, 0, 0.0f);
1144 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
1145 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
1146 glVertex3f(0, 1, 0.0f);
1148 glColor4f(0.4, 0.0, 0.0, 0.7);
1149 bar = ((float)Person::players[0]->permanentdamage) / Person::players[0]->damagetolerance;
1151 glVertex3f(0, 0, 0.0f);
1152 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
1153 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
1154 glVertex3f(0, 1, 0.0f);
1156 glColor4f(0.4, 0.0, 0.0, 0.7);
1157 bar = ((float)Person::players[0]->superpermanentdamage) / Person::players[0]->damagetolerance;
1159 glVertex3f(0, 0, 0.0f);
1160 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
1161 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
1162 glVertex3f(0, 1, 0.0f);
1164 glColor4f(0.0, 0.0, 0.0, 0.7);
1166 glBegin(GL_LINE_STRIP);
1167 glVertex3f(0, 0, 0.0f);
1168 glVertex3f(1, 0, 0.0f);
1169 glVertex3f(1, 1, 0.0f);
1170 glVertex3f(0, 1, 0.0f);
1171 glVertex3f(0, 0, 0.0f);
1174 glMatrixMode(GL_PROJECTION);
1176 glMatrixMode(GL_MODELVIEW);
1178 glEnable(GL_DEPTH_TEST);
1179 glEnable(GL_CULL_FACE);
1180 glDisable(GL_BLEND);
1182 glEnable(GL_TEXTURE_2D);
1184 // writing the numbers :
1185 sprintf (string, "Damages : %d/%d (%d)", (int)(Person::players[0]->damage), (int)(Person::players[0]->damagetolerance), (int)(Person::players[0]->bloodloss));
1186 glColor4f(0, 0, 0, 1);
1187 text->glPrintOutline(1024 / 40 - 4, 768 / 16 - 4 + 768 * 14 / 16 - 40, string, 1, 1.5 * 1.25, 1024, 768);
1188 glColor4f(1, 0, 0, 1);
1189 text->glPrint(1024 / 40, 768 / 16 + 768 * 14 / 16 - 40, string, 1, 1.5, 1024, 768);
1193 glColor4f(.5, .5, .5, 1);
1196 if ((texttoggle || editorenabled) && debugmode && !mainmenu) {
1197 sprintf (string, "The framespersecond is %d.", (int)(fps));
1198 text->glPrint(10, 30, string, 0, .8, 1024, 768);
1201 sprintf (string, "Map editor enabled.");
1203 sprintf (string, "Map editor disabled.");
1204 text->glPrint(10, 60, string, 0, .8, 1024, 768);
1205 if (editorenabled) {
1206 sprintf (string, "Object size: %f", editorsize);
1207 text->glPrint(10, 75, string, 0, .8, 1024, 768);
1209 sprintf (string, "Object yaw: %f", editoryaw);
1211 sprintf (string, "Object yaw: Random");
1212 text->glPrint(10, 90, string, 0, .8, 1024, 768);
1213 if (editorpitch >= 0)
1214 sprintf (string, "Object pitch: %f", editorpitch);
1216 sprintf (string, "Object pitch: Random");
1217 text->glPrint(10, 105, string, 0, .8, 1024, 768);
1218 sprintf (string, "Object type: %d", editortype);
1219 text->glPrint(10, 120, string, 0, .8, 1024, 768);
1220 switch (editortype) {
1222 sprintf (string, "(box)");
1225 sprintf (string, "(tree)");
1228 sprintf (string, "(wall)");
1231 sprintf (string, "(weird)");
1234 sprintf (string, "(spike)");
1237 sprintf (string, "(rock)");
1240 sprintf (string, "(bush)");
1243 sprintf (string, "(tunnel)");
1246 sprintf (string, "(chimney)");
1249 sprintf (string, "(platform)");
1252 sprintf (string, "(cool)");
1255 sprintf (string, "(fire)");
1258 text->glPrint(130, 120, string, 0, .8, 1024, 768);
1260 sprintf (string, "Numplayers: %lu", Person::players.size());
1261 text->glPrint(10, 155, string, 0, .8, 1024, 768);
1262 sprintf (string, "Player %d: numwaypoints: %d", (int(Person::players.size()) - 1), Person::players.back()->numwaypoints);
1263 text->glPrint(10, 140, string, 0, .8, 1024, 768);
1265 sprintf (string, "Difficulty: %d", difficulty);
1266 text->glPrint(10, 240, string, 0, .8, 1024, 768);
1271 if (drawmode == glowmode) {
1272 glDisable(GL_DEPTH_TEST);
1273 glDisable(GL_CULL_FACE);
1274 glDisable(GL_LIGHTING);
1275 glDisable(GL_TEXTURE_2D);
1277 glMatrixMode(GL_PROJECTION);
1280 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1281 glMatrixMode(GL_MODELVIEW);
1284 glScalef(screenwidth, screenheight, 1);
1285 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1287 glColor4f(0, 0, 0, .5);
1289 glVertex3f(0, 0, 0.0f);
1290 glVertex3f(256, 0, 0.0f);
1291 glVertex3f(256, 256, 0.0f);
1292 glVertex3f(0, 256, 0.0f);
1294 glMatrixMode(GL_PROJECTION);
1296 glMatrixMode(GL_MODELVIEW);
1298 glEnable(GL_DEPTH_TEST);
1299 glEnable(GL_CULL_FACE);
1300 glDisable(GL_BLEND);
1304 if ((((blackout && damageeffects) || (Person::players[0]->bloodloss > 0 && damageeffects && Person::players[0]->blooddimamount > 0) || Person::players[0]->dead) && !cameramode) || console) {
1305 glDisable(GL_DEPTH_TEST);
1306 glDisable(GL_CULL_FACE);
1307 glDisable(GL_LIGHTING);
1308 glDisable(GL_TEXTURE_2D);
1310 glMatrixMode(GL_PROJECTION);
1313 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1314 glMatrixMode(GL_MODELVIEW);
1317 glScalef(screenwidth, screenheight, 1);
1318 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1320 if (Person::players[0]->dead)
1321 blackout += multiplier * 3;
1322 if (Person::players[0]->dead == 1)
1324 if (Person::players[0]->dead == 2 && blackout > .6)
1326 glColor4f(0, 0, 0, blackout);
1327 if (!Person::players[0]->dead) {
1328 if ((Person::players[0]->bloodloss / Person::players[0]->damagetolerance * (sin(woozy) / 4 + .5))*.3 < .3) {
1329 glColor4f(0, 0, 0, Person::players[0]->blooddimamount * Person::players[0]->bloodloss / Person::players[0]->damagetolerance * (sin(woozy) / 4 + .5)*.3);
1330 blackout = Person::players[0]->blooddimamount * Person::players[0]->bloodloss / Person::players[0]->damagetolerance * (sin(woozy) / 4 + .5) * .3;
1332 glColor4f(0, 0, 0, Person::players[0]->blooddimamount * .3);
1333 blackout = Person::players[0]->blooddimamount * .3;
1337 glColor4f(.7, 0, 0, .2);
1339 glVertex3f(0, 0, 0.0f);
1340 glVertex3f(256, 0, 0.0f);
1341 glVertex3f(256, 256, 0.0f);
1342 glVertex3f(0, 256, 0.0f);
1344 glMatrixMode(GL_PROJECTION);
1346 glMatrixMode(GL_MODELVIEW);
1348 glEnable(GL_DEPTH_TEST);
1349 glEnable(GL_CULL_FACE);
1350 glDisable(GL_BLEND);
1354 if (flashamount > 0 && damageeffects) {
1355 if (flashamount > 1)
1357 if (flashdelay <= 0)
1358 flashamount -= multiplier;
1360 if (flashamount < 0)
1362 glDisable(GL_DEPTH_TEST);
1363 glDisable(GL_CULL_FACE);
1364 glDisable(GL_LIGHTING);
1366 glMatrixMode(GL_PROJECTION);
1369 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1370 glMatrixMode(GL_MODELVIEW);
1373 glScalef(screenwidth, screenheight, 1);
1374 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1376 glColor4f(flashr, flashg, flashb, flashamount);
1378 glVertex3f(0, 0, 0.0f);
1379 glVertex3f(256, 0, 0.0f);
1380 glVertex3f(256, 256, 0.0f);
1381 glVertex3f(0, 256, 0.0f);
1383 glMatrixMode(GL_PROJECTION);
1385 glMatrixMode(GL_MODELVIEW);
1387 glEnable(GL_DEPTH_TEST);
1388 glEnable(GL_CULL_FACE);
1389 glDisable(GL_BLEND);
1395 glEnable(GL_TEXTURE_2D);
1396 glColor4f(1, 1, 1, 1);
1397 for (unsigned i = 1; i < 15; i++)
1398 if (displaytime[i] < 4)
1399 for (unsigned j = 0; j < displaytext[i].size(); j++) {
1400 glColor4f(1, 1, 1, 4 - displaytime[i]);
1401 sprintf (string, "%c", displaytext[i][j]);
1402 text->glPrint(30 + j * 10, 30 + i * 20 + (screenheight - 330), string, 0, 1, screenwidth, screenheight);
1406 if (difficulty < 2 && indialogue == -1) { // minimap
1407 float mapviewdist = 20000;
1409 glDisable(GL_DEPTH_TEST);
1410 glColor3f (1.0, 1.0, 1.0); // no coloring
1412 glEnable(GL_TEXTURE_2D);
1413 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1414 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1415 glDisable(GL_DEPTH_TEST);
1416 glDisable(GL_CULL_FACE);
1417 glDisable(GL_LIGHTING);
1419 glMatrixMode(GL_PROJECTION);
1422 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1423 glMatrixMode(GL_MODELVIEW);
1426 glScalef((float)screenwidth / 2, (float)screenwidth / 2, 1);
1427 glTranslatef(1.75, .25, 0);
1428 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1430 glColor4f(1, 1, 1, 1);
1437 center = Person::players[0]->coords;
1441 glScalef(.25 / radius * 256 * terrain.scale * .4, .25 / radius * 256 * terrain.scale * .4, 1);
1443 glScalef(1 / (1 / radius * 256 * terrain.scale * .4), 1 / (1 / radius * 256 * terrain.scale * .4), 1);
1445 glRotatef(Person::players[0]->lookyaw * -1 + 180, 0, 0, 1);
1446 glTranslatef(-(center.x / terrain.scale / 256 * -2 + 1), (center.z / terrain.scale / 256 * -2 + 1), 0);
1447 for (int i = 0; i < objects.numobjects; i++) {
1448 if (objects.type[i] == treetrunktype) {
1449 distcheck = distsq(&Person::players[0]->coords, &objects.position[i]);
1450 if (distcheck < mapviewdist) {
1451 Mapcircletexture.bind();
1452 glColor4f(0, .3, 0, opac * (1 - distcheck / mapviewdist));
1454 glTranslatef(objects.position[i].x / terrain.scale / 256 * -2 + 1, objects.position[i].z / terrain.scale / 256 * 2 - 1, 0);
1455 glRotatef(objects.yaw[i], 0, 0, 1);
1456 glScalef(.003, .003, .003);
1459 glVertex3f(-1, -1, 0.0f);
1461 glVertex3f(1, -1, 0.0f);
1463 glVertex3f(1, 1, 0.0f);
1465 glVertex3f(-1, 1, 0.0f);
1470 if (objects.type[i] == boxtype) {
1471 distcheck = distsq(&Person::players[0]->coords, &objects.position[i]);
1472 if (distcheck < mapviewdist) {
1473 Mapboxtexture.bind();
1474 glColor4f(.4, .4, .4, opac * (1 - distcheck / mapviewdist));
1476 glTranslatef(objects.position[i].x / terrain.scale / 256 * -2 + 1, objects.position[i].z / terrain.scale / 256 * 2 - 1, 0);
1477 glRotatef(objects.yaw[i], 0, 0, 1);
1478 glScalef(.01 * objects.scale[i], .01 * objects.scale[i], .01 * objects.scale[i]);
1481 glVertex3f(-1, -1, 0.0f);
1483 glVertex3f(1, -1, 0.0f);
1485 glVertex3f(1, 1, 0.0f);
1487 glVertex3f(-1, 1, 0.0f);
1493 if (editorenabled) {
1494 Mapcircletexture.bind();
1495 for (int i = 0; i < numboundaries; i++) {
1496 glColor4f(0, 0, 0, opac / 3);
1498 glTranslatef(boundary[i].x / terrain.scale / 256 * -2 + 1, boundary[i].z / terrain.scale / 256 * 2 - 1, 0);
1499 glScalef(.002, .002, .002);
1502 glVertex3f(-1, -1, 0.0f);
1504 glVertex3f(1, -1, 0.0f);
1506 glVertex3f(1, 1, 0.0f);
1508 glVertex3f(-1, 1, 0.0f);
1513 for (unsigned i = 0; i < Person::players.size(); i++) {
1514 distcheck = distsq(&Person::players[0]->coords, &Person::players[i]->coords);
1515 if (distcheck < mapviewdist) {
1517 Maparrowtexture.bind();
1519 glColor4f(1, 1, 1, opac);
1520 else if (Person::players[i]->dead == 2 || Person::players[i]->howactive > typesleeping)
1521 glColor4f(0, 0, 0, opac * (1 - distcheck / mapviewdist));
1522 else if (Person::players[i]->dead)
1523 glColor4f(.3, .3, .3, opac * (1 - distcheck / mapviewdist));
1524 else if (Person::players[i]->aitype == attacktypecutoff)
1525 glColor4f(1, 0, 0, opac * (1 - distcheck / mapviewdist));
1526 else if (Person::players[i]->aitype == passivetype)
1527 glColor4f(0, 1, 0, opac * (1 - distcheck / mapviewdist));
1529 glColor4f(1, 1, 0, 1);
1530 glTranslatef(Person::players[i]->coords.x / terrain.scale / 256 * -2 + 1, Person::players[i]->coords.z / terrain.scale / 256 * 2 - 1, 0);
1531 glRotatef(Person::players[i]->yaw + 180, 0, 0, 1);
1532 glScalef(.005, .005, .005);
1535 glVertex3f(-1, -1, 0.0f);
1537 glVertex3f(1, -1, 0.0f);
1539 glVertex3f(1, 1, 0.0f);
1541 glVertex3f(-1, 1, 0.0f);
1547 glDisable(GL_TEXTURE_2D);
1548 glMatrixMode(GL_PROJECTION);
1550 glMatrixMode(GL_MODELVIEW);
1552 glEnable(GL_DEPTH_TEST);
1553 glEnable(GL_CULL_FACE);
1554 glDisable(GL_BLEND);
1558 if (loading && !stealthloading && (!campaign || Person::players[0]->dead)) {
1559 glDisable(GL_DEPTH_TEST);
1560 glDisable(GL_CULL_FACE);
1561 glDisable(GL_LIGHTING);
1562 glDisable(GL_TEXTURE_2D);
1564 glMatrixMode(GL_PROJECTION);
1567 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1568 glMatrixMode(GL_MODELVIEW);
1571 glScalef(screenwidth, screenheight, 1);
1572 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1574 glColor4f(0, 0, 0, .7);
1576 glVertex3f(0, 0, 0.0f);
1577 glVertex3f(256, 0, 0.0f);
1578 glVertex3f(256, 256, 0.0f);
1579 glVertex3f(0, 256, 0.0f);
1581 glMatrixMode(GL_PROJECTION);
1583 glMatrixMode(GL_MODELVIEW);
1585 glEnable(GL_DEPTH_TEST);
1586 glEnable(GL_CULL_FACE);
1587 glDisable(GL_BLEND);
1591 glDisable(GL_DEPTH_TEST);
1592 glColor3f (1.0, 1.0, 1.0); // no coloring
1594 glEnable(GL_TEXTURE_2D);
1599 glEnable(GL_TEXTURE_2D);
1600 glColor4f(1, 1, 1, 1);
1601 sprintf (string, "Loading...");
1602 text->glPrint(1024 / 2 - 90, 768 / 2, string, 1, 2, 1024, 768);
1605 drawmode = normalmode;
1608 if (winfreeze && !campaign) {
1609 glDisable(GL_DEPTH_TEST);
1610 glDisable(GL_CULL_FACE);
1611 glDisable(GL_LIGHTING);
1612 glDisable(GL_TEXTURE_2D);
1614 glMatrixMode(GL_PROJECTION);
1617 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1618 glMatrixMode(GL_MODELVIEW);
1621 glScalef(screenwidth, screenheight, 1);
1622 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1624 glColor4f(0, 0, 0, .4);
1626 glVertex3f(0, 0, 0.0f);
1627 glVertex3f(256, 0, 0.0f);
1628 glVertex3f(256, 256, 0.0f);
1629 glVertex3f(0, 256, 0.0f);
1631 glMatrixMode(GL_PROJECTION);
1633 glMatrixMode(GL_MODELVIEW);
1635 glEnable(GL_DEPTH_TEST);
1636 glEnable(GL_CULL_FACE);
1637 glDisable(GL_BLEND);
1641 glDisable(GL_DEPTH_TEST);
1642 glColor3f (1.0, 1.0, 1.0); // no coloring
1644 glEnable(GL_TEXTURE_2D);
1646 //Win Screen Won Victory
1648 glEnable(GL_TEXTURE_2D);
1649 glColor4f(1, 1, 1, 1);
1650 sprintf (string, "Level Cleared!");
1651 text->glPrintOutlined(1024 / 2 - strlen(string) * 10, 768 * 7 / 8, string, 1, 2, 1024, 768);
1653 sprintf (string, "Score: %d", (int)(bonustotal - startbonustotal));
1654 text->glPrintOutlined(1024 / 30, 768 * 6 / 8, string, 1, 2, 1024, 768);
1657 sprintf (string, "Press Escape or Space to continue");
1659 sprintf (string, "Press Escape to return to menu or Space to continue");
1660 text->glPrintOutlined(640 / 2 - strlen(string) * 5, 480 * 1 / 16, string, 1, 1, 640, 480);
1664 for (int i = 0; i < 255; i++)
1666 sprintf (temp, "Time: %d:", (int)(((int)leveltime - (int)(leveltime) % 60) / 60));
1667 strcat(string, temp);
1668 if ((int)(leveltime) % 60 < 10)
1669 strcat(string, "0");
1670 sprintf (temp, "%d", (int)(leveltime) % 60);
1671 strcat(string, temp);
1672 text->glPrintOutlined(1024 / 30, 768 * 6 / 8 - 40, string, 1, 2, 1024, 768);
1675 int awards[award_count];
1676 int numawards = award_awards(awards);
1678 for (int i = 0; i < numawards && i < 6; i++)
1679 text->glPrintOutlined(1024 / 30, 768 * 6 / 8 - 90 - 40 * i, award_names[awards[i]], 1, 2, 1024, 768);
1682 if (drawmode != normalmode) {
1683 glEnable(GL_TEXTURE_2D);
1685 if (!drawtoggle || drawmode != realmotionblurmode || (drawtoggle == 2 || change == 1)) {
1686 if (screentexture) {
1688 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
1689 GLfloat subtractColor[4] = { 0.5, 0.5, 0.5, 0.0 };
1690 glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, subtractColor);
1691 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE);
1692 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_CONSTANT_EXT);
1693 glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 2.0f);
1695 glBindTexture( GL_TEXTURE_2D, screentexture);
1696 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1699 if ((drawtoggle || change == 1) && drawmode == realmotionblurmode) {
1700 if (screentexture2) {
1701 glBindTexture( GL_TEXTURE_2D, screentexture2);
1702 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1704 if (!screentexture2) {
1705 glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
1707 glGenTextures( 1, &screentexture2 );
1708 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
1710 glEnable(GL_TEXTURE_2D);
1711 glBindTexture( GL_TEXTURE_2D, screentexture2);
1712 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
1713 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
1715 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
1720 glClear(GL_DEPTH_BUFFER_BIT);
1721 Game::ReSizeGLScene(90, .1f);
1722 glViewport(0, 0, screenwidth, screenheight);
1724 if (drawmode != normalmode) {
1725 glDisable(GL_DEPTH_TEST);
1726 if (drawmode == motionblurmode) {
1727 glDrawBuffer(GL_FRONT);
1728 glReadBuffer(GL_BACK);
1730 glColor3f (1.0, 1.0, 1.0); // no coloring
1732 glEnable(GL_TEXTURE_2D);
1733 glBindTexture( GL_TEXTURE_2D, screentexture);
1734 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1735 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1736 glDisable(GL_DEPTH_TEST);
1737 glDisable(GL_CULL_FACE);
1738 glDisable(GL_LIGHTING);
1740 glMatrixMode(GL_PROJECTION);
1743 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1744 glMatrixMode(GL_MODELVIEW);
1747 glScalef((float)screenwidth / 2, (float)screenheight / 2, 1);
1748 glTranslatef(1, 1, 0);
1749 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1751 if (drawmode == motionblurmode) {
1752 if (motionbluramount < .2)
1753 motionbluramount = .2;
1754 glColor4f(1, 1, 1, motionbluramount);
1758 glVertex3f(-1, -1, 0.0f);
1759 glTexCoord2f(texcoordwidth, 0);
1760 glVertex3f(1, -1, 0.0f);
1761 glTexCoord2f(texcoordwidth, texcoordheight);
1762 glVertex3f(1, 1, 0.0f);
1763 glTexCoord2f(0, texcoordheight);
1764 glVertex3f(-1, 1, 0.0f);
1768 if (drawmode == realmotionblurmode) {
1769 glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
1770 glClear(GL_COLOR_BUFFER_BIT);
1771 glBlendFunc(GL_SRC_ALPHA, GL_ONE);
1772 glBindTexture( GL_TEXTURE_2D, screentexture);
1773 glColor4f(1, 1, 1, .5);
1777 glVertex3f(-1, -1, 0.0f);
1778 glTexCoord2f(texcoordwidth, 0);
1779 glVertex3f(1, -1, 0.0f);
1780 glTexCoord2f(texcoordwidth, texcoordheight);
1781 glVertex3f(1, 1, 0.0f);
1782 glTexCoord2f(0, texcoordheight);
1783 glVertex3f(-1, 1, 0.0f);
1786 glBindTexture( GL_TEXTURE_2D, screentexture2);
1787 glColor4f(1, 1, 1, .5);
1791 glVertex3f(-1, -1, 0.0f);
1792 glTexCoord2f(texcoordwidth, 0);
1793 glVertex3f(1, -1, 0.0f);
1794 glTexCoord2f(texcoordwidth, texcoordheight);
1795 glVertex3f(1, 1, 0.0f);
1796 glTexCoord2f(0, texcoordheight);
1797 glVertex3f(-1, 1, 0.0f);
1800 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1802 if (drawmode == doublevisionmode) {
1803 static float crosseyedness;
1804 crosseyedness = abs(Person::players[0]->damage - Person::players[0]->superpermanentdamage - (Person::players[0]->damagetolerance - Person::players[0]->superpermanentdamage) * 1 / 2) / 30;
1805 if (crosseyedness > 1)
1807 if (crosseyedness < 0)
1809 glColor4f(1, 1, 1, 1);
1810 glDisable(GL_BLEND);
1815 glVertex3f(-1, -1, 0.0f);
1816 glTexCoord2f(texcoordwidth, 0);
1817 glVertex3f(1, -1, 0.0f);
1818 glTexCoord2f(texcoordwidth, texcoordheight);
1819 glVertex3f(1, 1, 0.0f);
1820 glTexCoord2f(0, texcoordheight);
1821 glVertex3f(-1, 1, 0.0f);
1824 if (crosseyedness) {
1825 glColor4f(1, 1, 1, .5);
1828 glTranslatef(.015 * crosseyedness, 0, 0);
1832 glVertex3f(-1, -1, 0.0f);
1833 glTexCoord2f(texcoordwidth, 0);
1834 glVertex3f(1, -1, 0.0f);
1835 glTexCoord2f(texcoordwidth, texcoordheight);
1836 glVertex3f(1, 1, 0.0f);
1837 glTexCoord2f(0, texcoordheight);
1838 glVertex3f(-1, 1, 0.0f);
1843 if (drawmode == glowmode) {
1844 glColor4f(.5, .5, .5, .5);
1846 glBlendFunc(GL_SRC_ALPHA, GL_ONE);
1848 glTranslatef(.01, 0, 0);
1851 glVertex3f(-1, -1, 0.0f);
1852 glTexCoord2f(texcoordwidth, 0);
1853 glVertex3f(1, -1, 0.0f);
1854 glTexCoord2f(texcoordwidth, texcoordheight);
1855 glVertex3f(1, 1, 0.0f);
1856 glTexCoord2f(0, texcoordheight);
1857 glVertex3f(-1, 1, 0.0f);
1861 glTranslatef(-.01, 0, 0);
1864 glVertex3f(-1, -1, 0.0f);
1865 glTexCoord2f(texcoordwidth, 0);
1866 glVertex3f(1, -1, 0.0f);
1867 glTexCoord2f(texcoordwidth, texcoordheight);
1868 glVertex3f(1, 1, 0.0f);
1869 glTexCoord2f(0, texcoordheight);
1870 glVertex3f(-1, 1, 0.0f);
1874 glTranslatef(.0, .01, 0);
1877 glVertex3f(-1, -1, 0.0f);
1878 glTexCoord2f(texcoordwidth, 0);
1879 glVertex3f(1, -1, 0.0f);
1880 glTexCoord2f(texcoordwidth, texcoordheight);
1881 glVertex3f(1, 1, 0.0f);
1882 glTexCoord2f(0, texcoordheight);
1883 glVertex3f(-1, 1, 0.0f);
1887 glTranslatef(0, -.01, 0);
1890 glVertex3f(-1, -1, 0.0f);
1891 glTexCoord2f(texcoordwidth, 0);
1892 glVertex3f(1, -1, 0.0f);
1893 glTexCoord2f(texcoordwidth, texcoordheight);
1894 glVertex3f(1, 1, 0.0f);
1895 glTexCoord2f(0, texcoordheight);
1896 glVertex3f(-1, 1, 0.0f);
1900 if (drawmode == radialzoommode) {
1901 for (int i = 0; i < 3; i++) {
1902 glColor4f(1, 1, 1, 1 / ((float)i + 1));
1904 glScalef(1 + (float)i * .01, 1 + (float)i * .01, 1);
1907 glVertex3f(-1, -1, 0.0f);
1908 glTexCoord2f(texcoordwidth, 0);
1909 glVertex3f(1, -1, 0.0f);
1910 glTexCoord2f(texcoordwidth, texcoordheight);
1911 glVertex3f(1, 1, 0.0f);
1912 glTexCoord2f(0, texcoordheight);
1913 glVertex3f(-1, 1, 0.0f);
1918 glDisable(GL_TEXTURE_2D);
1919 glMatrixMode(GL_PROJECTION);
1921 glMatrixMode(GL_MODELVIEW);
1923 glEnable(GL_DEPTH_TEST);
1924 glEnable(GL_CULL_FACE);
1925 glDisable(GL_BLEND);
1930 glEnable(GL_TEXTURE_2D);
1931 glColor4f(1, 1, 1, 1);
1933 if (consoleselected >= 60)
1934 offset = consoleselected - 60;
1935 sprintf (string, " ]");
1936 text->glPrint(10, 30, string, 0, 1, 1024, 768);
1938 sprintf (string, "_");
1939 text->glPrint(30 + (float)(consoleselected) * 10 - offset * 10, 30, string, 0, 1, 1024, 768);
1941 for (unsigned i = 0; i < 15; i++)
1942 for (unsigned j = 0; j < consoletext[i].size(); j++) {
1943 glColor4f(1, 1, 1, 1 - (float)(i) / 16);
1944 sprintf (string, "%c", consoletext[i][j]);
1945 text->glPrint(30 + j * 10 - offset * 10, 30 + i * 20, string, 0, 1, 1024, 768);
1950 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted)) {
1951 multiplier = tempmult;
1958 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted)) {
1959 tempmult = multiplier;
1963 if ( side == stereoRight || side == stereoCenter ) {
1964 if (drawmode != motionblurmode || mainmenu) {
1969 glDrawBuffer(GL_BACK);
1970 glReadBuffer(GL_BACK);
1974 if (drawtoggle == 2)
1977 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted)) {
1978 multiplier = tempmult;
1980 //Jordan fixed your warning!
1986 // !!! FIXME: hack: clamp framerate in menu so text input works correctly on fast systems.
1989 glDrawBuffer(GL_BACK);
1990 glReadBuffer(GL_BACK);
1991 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
1992 Game::ReSizeGLScene(90, .1f);
1994 //draw menu background
1995 glClear(GL_DEPTH_BUFFER_BIT);
1996 glEnable(GL_ALPHA_TEST);
1997 glAlphaFunc(GL_GREATER, 0.001f);
1998 glEnable(GL_TEXTURE_2D);
1999 glDisable(GL_DEPTH_TEST);
2000 glDisable(GL_CULL_FACE);
2001 glDisable(GL_LIGHTING);
2003 glMatrixMode(GL_PROJECTION);
2006 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
2007 glMatrixMode(GL_MODELVIEW);
2010 glTranslatef(screenwidth / 2, screenheight / 2, 0);
2012 glScalef((float)screenwidth / 2, (float)screenheight / 2, 1);
2013 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
2014 glDisable(GL_BLEND);
2015 glColor4f(0, 0, 0, 1.0);
2016 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2017 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2018 glDisable(GL_TEXTURE_2D);
2020 glVertex3f(-1, -1, 0);
2021 glVertex3f(+1, -1, 0);
2022 glVertex3f(+1, +1, 0);
2023 glVertex3f(-1, +1, 0);
2026 glColor4f(0.4, 0.4, 0.4, 1.0);
2027 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2028 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2029 glEnable(GL_TEXTURE_2D);
2030 Game::Mainmenuitems[4].bind();
2033 glVertex3f(-1, -1, 0);
2035 glVertex3f(+1, -1, 0);
2037 glVertex3f(+1, +1, 0);
2039 glVertex3f(-1, +1, 0);
2043 glMatrixMode(GL_PROJECTION);
2045 glMatrixMode(GL_MODELVIEW);
2049 glMatrixMode(GL_PROJECTION);
2052 glOrtho(0, 640, 0, 480, -100, 100);
2053 glMatrixMode(GL_MODELVIEW);
2056 glEnable(GL_TEXTURE_2D);
2061 glMatrixMode(GL_PROJECTION);
2063 glMatrixMode(GL_MODELVIEW);
2066 glMatrixMode(GL_PROJECTION);
2069 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
2070 glMatrixMode(GL_MODELVIEW);
2073 glTranslatef(screenwidth / 2, screenheight / 2, 0);
2075 glScalef((float)screenwidth / 2, (float)screenheight / 2, 1);
2076 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
2078 glEnable(GL_TEXTURE_2D);
2079 glColor4f(1, 1, 1, 1);
2080 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2081 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2083 if (!Game::waiting) { // hide the cursor while waiting for a key
2085 glTranslatef(Game::mousecoordh - screenwidth / 2, Game::mousecoordv * -1 + screenheight / 2, 0);
2086 glScalef((float)screenwidth / 64, (float)screenwidth / 64, 1);
2087 glTranslatef(1, -1, 0);
2088 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
2089 glColor4f(1, 1, 1, 1);
2090 Game::cursortexture.bind();
2094 glVertex3f(-1, -1, 0.0f);
2096 glVertex3f(1, -1, 0.0f);
2098 glVertex3f(1, 1, 0.0f);
2100 glVertex3f(-1, 1, 0.0f);
2106 glMatrixMode(GL_PROJECTION);
2111 if (flashamount > 0) {
2112 if (flashamount > 1)
2114 if (flashdelay <= 0)
2115 flashamount -= multiplier;
2117 if (flashamount < 0)
2119 glDisable(GL_DEPTH_TEST);
2120 glDisable(GL_CULL_FACE);
2121 glDisable(GL_LIGHTING);
2122 glDisable(GL_TEXTURE_2D);
2124 glMatrixMode(GL_PROJECTION);
2127 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
2128 glMatrixMode(GL_MODELVIEW);
2131 glScalef(screenwidth, screenheight, 1);
2132 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
2134 glColor4f(flashr, flashg, flashb, flashamount);
2136 glVertex3f(0, 0, 0.0f);
2137 glVertex3f(256, 0, 0.0f);
2138 glVertex3f(256, 256, 0.0f);
2139 glVertex3f(0, 256, 0.0f);
2141 glMatrixMode(GL_PROJECTION);
2143 glMatrixMode(GL_MODELVIEW);
2145 glEnable(GL_DEPTH_TEST);
2146 glEnable(GL_CULL_FACE);
2147 glDisable(GL_BLEND);