2 Copyright (C) 2003, 2010 - Wolfire Games
4 This file is part of Lugaru.
6 Lugaru is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 Lugaru is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
21 #include "openal_wrapper.h"
27 extern int environment;
28 extern float texscale;
30 extern Terrain terrain;
31 //extern Sprites sprites;
32 extern float multiplier;
34 extern float viewdistance;
35 extern float fadestart;
36 extern float screenwidth, screenheight;
37 extern int kTextureSize;
38 extern FRUSTUM frustum;
40 extern Objects objects;
42 extern float usermousesensitivity;
44 extern float camerashake;
46 extern float slomodelay;
47 extern bool ismotionblur;
49 extern float blackout;
50 extern bool damageeffects;
52 extern bool texttoggle;
53 extern float blurness;
54 extern float targetblurness;
55 extern float playerdist;
56 extern bool cellophane;
58 extern float flashamount, flashr, flashg, flashb;
59 extern int flashdelay;
61 extern float motionbluramount;
63 extern bool alwaysblur;
65 extern bool tilt2weird;
66 extern bool tiltweird;
68 extern bool proportionweird;
69 extern bool vertexweird[6];
70 extern bool velocityblur;
71 extern bool debugmode;
73 extern int bloodtoggle;
74 extern int difficulty;
77 //extern int texdetail;
78 extern float texdetail;
79 extern bool musictoggle;
80 extern int tutoriallevel;
81 extern float smoketex;
82 extern float tutorialstagetime;
83 extern float tutorialmaxtime;
84 extern int tutorialstage;
85 extern bool againbonus;
86 extern float damagedealt;
87 extern bool invertmouse;
89 extern int numhotspots;
90 extern int killhotspot;
91 extern XYZ hotspot[40];
92 extern int hotspottype[40];
93 extern float hotspotsize[40];
94 extern char hotspottext[40][256];
95 extern int currenthotspot;;
98 extern bool winfreeze;
100 extern float menupulse;
102 extern bool gamestart;
104 extern bool gamestarted;
106 extern bool showdamagebar;
111 int numboundaries = 0;
118 normalmode, motionblurmode, radialzoommode,
119 realmotionblurmode, doublevisionmode, glowmode,
122 void Game::flash() // shouldn't be that way, these should be attributes and Person class should not change rendering.
133 /*********************> DrawGLScene() <*****/
134 int Game::DrawGLScene(StereoSide side)
136 static float texcoordwidth, texcoordheight;
137 static float texviewwidth, texviewheight;
139 static XYZ checkpoint;
140 static float tempmult;
142 static char string[256] = "";
143 static char string2[256] = "";
144 static char string3[256] = "";
145 static int drawmode = 0;
147 if ( stereomode == stereoAnaglyph ) {
150 glColorMask( 0.0, 1.0, 1.0, 1.0 );
153 glColorMask( 1.0, 0.0, 0.0, 1.0 );
159 glColorMask( 1.0, 1.0, 1.0, 1.0 );
161 if ( stereomode == stereoHorizontalInterlaced || stereomode == stereoVerticalInterlaced ) {
162 glStencilFunc(side == stereoLeft ? GL_NOTEQUAL : GL_EQUAL, 0x01, 0x01);
166 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted)) {
167 tempmult = multiplier;
173 numboundaries = mapradius * 2;
174 if (numboundaries > 360)
176 for (int i = 0; i < numboundaries; i++) {
179 boundary[i] = mapcenter + DoRotation(boundary[i] * mapradius, 0, i * (360 / ((float)(numboundaries))), 0);
188 int olddrawmode = drawmode;
189 if (ismotionblur && !loading) {
190 if ((findLengthfast(&Person::players[0]->velocity) > 200) && velocityblur && !cameramode) {
191 drawmode = motionblurmode;
192 motionbluramount = 200 / (findLengthfast(&Person::players[0]->velocity));
195 if (Person::players[0]->damage - Person::players[0]->superpermanentdamage > (Person::players[0]->damagetolerance - Person::players[0]->superpermanentdamage) * 1 / 2 && damageeffects && !cameramode) {
196 drawmode = doublevisionmode;
201 if (slomo && !loading) {
203 drawmode = motionblurmode;
204 motionbluramount = .2;
205 slomodelay -= multiplier;
211 if ((!changed && !slomo) || loading) {
212 drawmode = normalmode;
213 if (ismotionblur && (/*fps>100||*/alwaysblur)) {
214 if (olddrawmode != realmotionblurmode)
218 drawmode = realmotionblurmode;
219 } else if (olddrawmode == realmotionblurmode)
225 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted))
226 drawmode = normalmode;
227 if ((freeze || winfreeze) && ismotionblur && !mainmenu)
228 drawmode = radialzoommode;
230 if (winfreeze || mainmenu)
231 drawmode = normalmode;
234 if (drawmode == glowmode) {
239 DSpContext_FadeGamma(NULL, 200, &color2);
244 drawtoggle = 1 - drawtoggle;
246 if (!texcoordwidth) {
247 texviewwidth = kTextureSize;
248 if (texviewwidth > screenwidth)
249 texviewwidth = screenwidth;
250 texviewheight = kTextureSize;
251 if (texviewheight > screenheight)
252 texviewheight = screenheight;
254 texcoordwidth = screenwidth / kTextureSize;
255 texcoordheight = screenheight / kTextureSize;
256 if (texcoordwidth > 1)
258 if (texcoordheight > 1)
262 glDrawBuffer(GL_BACK);
263 glReadBuffer(GL_BACK);
265 static XYZ terrainlight;
266 static float distance;
267 if (drawmode == normalmode)
268 Game::ReSizeGLScene(90, .1f);
269 if (drawmode != normalmode)
270 glViewport(0, 0, texviewwidth, texviewheight);
271 glDepthFunc(GL_LEQUAL);
273 glAlphaFunc(GL_GREATER, 0.0001f);
274 glEnable(GL_ALPHA_TEST);
275 glClearColor(0.25f, 0.25f, 0.25f, 1.0f);
276 glClear(GL_DEPTH_BUFFER_BIT);
278 glMatrixMode (GL_MODELVIEW);
279 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
282 // Move the camera for the current eye's point of view.
283 // Reverse the movement if we're reversing stereo
284 glTranslatef((stereoseparation / 2) * side * (stereoreverse ? -1 : 1), 0, 0);
287 if (!cameramode && !freeze && !winfreeze) {
289 glRotatef(float(Random() % 100) / 10 * camerashake/*+(woozy*woozy)/10*/, 0, 0, 1);
291 glRotatef(pitch + sin(woozy / 2) * (Person::players[0]->damage / Person::players[0]->damagetolerance) * 5, 1, 0, 0);
292 glRotatef(yaw + sin(woozy) * (Person::players[0]->damage / Person::players[0]->damagetolerance) * 5, 0, 1, 0);
294 if (cameramode || freeze || winfreeze) {
295 glRotatef(pitch, 1, 0, 0);
296 glRotatef(yaw, 0, 1, 0);
299 if (environment == desertenvironment) {
300 glRotatef((float)(abs(Random() % 100)) / 3000 - 1, 1, 0, 0);
301 glRotatef((float)(abs(Random() % 100)) / 3000 - 1, 0, 1, 0);
303 SetUpLight(&light, 0);
306 //heat blur effect in desert
307 if (abs(blurness - targetblurness) < multiplier * 10 || abs(blurness - targetblurness) > 2) {
308 blurness = targetblurness;
309 targetblurness = (float)(abs(Random() % 100)) / 40;
311 if (blurness < targetblurness)
312 blurness += multiplier * 5;
314 blurness -= multiplier * 5;
316 if (environment == desertenvironment && detail == 2)
317 glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, blurness + .4 );
318 if (environment == desertenvironment) {
319 glRotatef((float)(abs(Random() % 100)) / 1000, 1, 0, 0);
320 glRotatef((float)(abs(Random() % 100)) / 1000, 0, 1, 0);
323 glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0);
325 glTranslatef(-viewer.x, -viewer.y, -viewer.z);
326 frustum.GetFrustum();
328 //make shadow decals on terrain and objects
330 static float size, opacity, rotation;
332 for (unsigned k = 0; k < Person::players.size(); k++) {
333 if (!Person::players[k]->skeleton.free && Person::players[k]->playerdetail && Person::players[k]->howactive < typesleeping)
334 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)
335 for (int i = 0; i < Person::players[k]->skeleton.num_joints; i++) {
336 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) {
337 point = DoRotation(Person::players[k]->skeleton.joints[i].position, 0, Person::players[k]->yaw, 0) * Person::players[k]->scale + Person::players[k]->coords;
339 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;
340 if (k != 0 && tutoriallevel == 1) {
341 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;
343 terrain.MakeDecal(shadowdecal, point, size, opacity, rotation);
344 for (l = 0; l < terrain.patchobjectnum[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz]; l++) {
345 int j = terrain.patchobjects[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz][l];
346 if (objects.position[j].y < Person::players[k]->coords.y || objects.type[j] == tunneltype || objects.type[j] == weirdtype) {
347 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);
350 if (k != 0 && tutoriallevel == 1) {
351 opacity = .2 + .2 * sin(smoketex * 6 + i);
353 objects.model[j].MakeDecal(shadowdecal, &point, &size, &opacity, &rotation);
358 if ((Person::players[k]->skeleton.free || Person::players[k]->howactive >= typesleeping) && Person::players[k]->playerdetail)
359 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)
360 for (int i = 0; i < Person::players[k]->skeleton.num_joints; i++) {
361 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) {
362 if (Person::players[k]->skeleton.free)
363 point = Person::players[k]->skeleton.joints[i].position * Person::players[k]->scale + Person::players[k]->coords;
365 point = DoRotation(Person::players[k]->skeleton.joints[i].position, 0, Person::players[k]->yaw, 0) * Person::players[k]->scale + Person::players[k]->coords;
367 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;
368 if (k != 0 && tutoriallevel == 1) {
369 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;
371 terrain.MakeDecal(shadowdecal, point, size, opacity * .7, rotation);
372 for (l = 0; l < terrain.patchobjectnum[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz]; l++) {
373 int j = terrain.patchobjects[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz][l];
374 if (objects.position[j].y < Person::players[k]->coords.y || objects.type[j] == tunneltype || objects.type[j] == weirdtype) {
375 if (Person::players[k]->skeleton.free)
376 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);
378 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);
381 if (k != 0 && tutoriallevel == 1) {
382 opacity = .2 + .2 * sin(smoketex * 6 + i);
384 objects.model[j].MakeDecal(shadowdecal, &point, &size, &opacity, &rotation);
390 if (!Person::players[k]->playerdetail)
391 if (frustum.SphereInFrustum(Person::players[k]->coords.x, Person::players[k]->coords.y, Person::players[k]->coords.z, Person::players[k]->scale * 5)) {
392 point = Person::players[k]->coords;
394 opacity = .4 - (Person::players[k]->coords.y - terrain.getHeight(Person::players[k]->coords.x, Person::players[k]->coords.z)) / 5;
395 terrain.MakeDecal(shadowdecal, point, size, opacity * .7, rotation);
396 for (l = 0; l < terrain.patchobjectnum[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz]; l++) {
397 int j = terrain.patchobjects[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz][l];
398 point = DoRotation(Person::players[k]->coords - objects.position[j], 0, -objects.yaw[j], 0);
401 objects.model[j].MakeDecal(shadowdecal, &point, &size, &opacity, &rotation);
407 glEnable(GL_TEXTURE_2D);
409 glEnable(GL_DEPTH_TEST);
410 glEnable(GL_CULL_FACE);
412 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
413 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
414 terraintexture.bind();
416 terraintexture2.bind();
419 terrain.drawdecals();
422 glEnable(GL_CULL_FACE);
423 glEnable(GL_LIGHTING);
425 glEnable(GL_TEXTURE_2D);
428 glEnable(GL_COLOR_MATERIAL);
443 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
444 glEnable(GL_CULL_FACE);
445 glCullFace(GL_FRONT);
447 for (unsigned k = 0; k < Person::players.size(); k++) {
448 if (k == 0 || tutoriallevel != 1) {
450 glEnable(GL_LIGHTING);
451 terrainlight = terrain.getLighting(Person::players[k]->coords.x, Person::players[k]->coords.z);
452 distance = distsq(&viewer, &Person::players[k]->coords);
453 distance = (viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance;
454 glColor4f(terrainlight.x, terrainlight.y, terrainlight.z, distance);
457 if (distance >= .5) {
458 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;
461 if (Person::players[k]->occluded != 0)
462 i = checkcollide(viewer, checkpoint, Person::players[k]->lastoccluded);
464 i = checkcollide(viewer, checkpoint);
466 Person::players[k]->occluded += 1;
467 Person::players[k]->lastoccluded = i;
469 Person::players[k]->occluded = 0;
471 if (Person::players[k]->occluded < 25)
472 Person::players[k]->DrawSkeleton();
478 if (!cameramode && musictype == stream_fighttheme)
479 playerdist = distsqflat(&Person::players[0]->coords, &viewer);
484 glEnable(GL_TEXTURE_2D);
490 if (frustum.SphereInFrustum(realhawkcoords.x + hawk.boundingspherecenter.x, realhawkcoords.y + hawk.boundingspherecenter.y, realhawkcoords.z + hawk.boundingspherecenter.z, 2)) {
491 glAlphaFunc(GL_GREATER, 0.0001f);
493 glDisable(GL_CULL_FACE);
494 glDisable(GL_LIGHTING);
496 glTranslatef(hawkcoords.x, hawkcoords.y, hawkcoords.z);
497 glRotatef(hawkyaw, 0, 1, 0);
498 glTranslatef(25, 0, 0);
499 distance = distsq(&viewer, &realhawkcoords) * 1.2;
500 glColor4f(light.color[0], light.color[1], light.color[2], (viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance);
501 if ((viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance > 1)
502 glColor4f(light.color[0], light.color[1], light.color[2], 1);
503 if ((viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance > 0)
504 hawk.drawdifftex(hawktexture);
508 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
509 glEnable(GL_CULL_FACE);
510 glCullFace(GL_FRONT);
512 for (unsigned k = 0; k < Person::players.size(); k++) {
513 if (!(k == 0 || tutoriallevel != 1)) {
515 glEnable(GL_LIGHTING);
516 terrainlight = terrain.getLighting(Person::players[k]->coords.x, Person::players[k]->coords.z);
517 distance = distsq(&viewer, &Person::players[k]->coords);
518 distance = (viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance;
519 glColor4f(terrainlight.x, terrainlight.y, terrainlight.z, distance);
522 if (distance >= .5) {
523 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;
526 if (Person::players[k]->occluded != 0)
527 i = checkcollide(viewer, checkpoint, Person::players[k]->lastoccluded);
529 i = checkcollide(viewer, checkpoint);
531 Person::players[k]->occluded += 1;
532 Person::players[k]->lastoccluded = i;
534 Person::players[k]->occluded = 0;
536 if (Person::players[k]->occluded < 25)
537 Person::players[k]->DrawSkeleton();
543 glEnable(GL_TEXTURE_2D);
548 glDisable(GL_COLOR_MATERIAL);
550 glDisable(GL_LIGHTING);
551 glDisable(GL_TEXTURE_2D);
557 //waypoints, pathpoints in editor
560 glDisable(GL_LIGHTING);
561 glDisable(GL_TEXTURE_2D);
562 glDisable(GL_COLOR_MATERIAL);
563 glColor4f(1, 1, 0, 1);
565 for (unsigned k = 0; k < Person::players.size(); k++) {
566 if (Person::players[k]->numwaypoints > 1) {
567 glBegin(GL_LINE_LOOP);
568 for (int i = 0; i < Person::players[k]->numwaypoints; i++) {
569 glVertex3f(Person::players[k]->waypoints[i].x, Person::players[k]->waypoints[i].y + .5, Person::players[k]->waypoints[i].z);
576 if (numpathpoints > 1) {
577 glColor4f(0, 1, 0, 1);
578 for (unsigned k = 0; int(k) < numpathpoints; k++) {
579 if (numpathpointconnect[k]) {
580 for (int i = 0; i < numpathpointconnect[k]; i++) {
581 glBegin(GL_LINE_LOOP);
582 glVertex3f(pathpoint[k].x, pathpoint[k].y + .5, pathpoint[k].z);
583 glVertex3f(pathpoint[pathpointconnect[k][i]].x, pathpoint[pathpointconnect[k][i]].y + .5, pathpoint[pathpointconnect[k][i]].z);
588 glColor4f(1, 1, 1, 1);
591 glVertex3f(pathpoint[pathpointselected].x, pathpoint[pathpointselected].y + .5, pathpoint[pathpointselected].z);
598 glEnable(GL_TEXTURE_2D);
599 glColor4f(.5, .5, .5, 1);
602 if (bonus > 0 && bonustime < 1 && !winfreeze && indialogue == -1/*bonustime<4*/) {
603 const char *bonus_name;
604 if (bonus < bonus_count)
605 bonus_name = bonus_names[bonus];
607 bonus_name = "Excellent!"; // When does this happen?
609 glColor4f(0, 0, 0, 1 - bonustime);
610 text->glPrintOutline(1024 / 2 - 10 * strlen(bonus_name) - 4, 768 / 16 - 4 + 768 * 4 / 5, bonus_name, 1, 2.5, 1024, 768);
611 glColor4f(1, 0, 0, 1 - bonustime);
612 text->glPrint(1024 / 2 - 10 * strlen(bonus_name), 768 / 16 + 768 * 4 / 5, bonus_name, 1, 2, 1024, 768);
614 sprintf (string, "%d", (int)bonusvalue);
615 glColor4f(0, 0, 0, 1 - bonustime);
616 text->glPrintOutline(1024 / 2 - 10 * strlen(string) - 4, 768 / 16 - 4 - 20 + 768 * 4 / 5, string, 1, 2.5 * .8, 1024, 768);
617 glColor4f(1, 0, 0, 1 - bonustime);
618 text->glPrint(1024 / 2 - 10 * strlen(string), 768 / 16 - 20 + 768 * 4 / 5, string, 1, 2 * .8, 1024, 768);
619 glColor4f(.5, .5, .5, 1);
622 if (tutoriallevel == 1) {
623 tutorialopac = tutorialmaxtime - tutorialstagetime;
624 if (tutorialopac > 1)
626 if (tutorialopac < 0)
629 sprintf (string, " ");
630 sprintf (string2, " ");
631 sprintf (string3, " ");
632 if (tutorialstage == 0) {
633 sprintf (string, " ");
634 sprintf (string2, " ");
635 sprintf (string3, " ");
637 if (tutorialstage == 1) {
638 sprintf (string, "Welcome to the Lugaru training level!");
639 sprintf (string2, " ");
640 sprintf (string3, " ");
642 if (tutorialstage == 2) {
643 sprintf (string, "BASIC MOVEMENT:");
644 sprintf (string2, " ");
645 sprintf (string3, " ");
647 if (tutorialstage == 3) {
648 sprintf (string, "You can move the mouse to rotate the camera.");
649 sprintf (string2, " ");
650 sprintf (string3, " ");
652 if (tutorialstage == 4) {
653 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));
654 sprintf (string2, "All movement is relative to the camera.");
655 sprintf (string3, " ");
657 if (tutorialstage == 5) {
658 sprintf (string, "Please press %s to jump.", Input::keyToChar(jumpkey));
659 sprintf (string2, "You can hold it longer to jump higher.");
660 sprintf (string3, " ");
662 if (tutorialstage == 6) {
663 sprintf (string, "You can press %s to crouch.", Input::keyToChar(crouchkey));
664 sprintf (string2, "You can jump higher from a crouching position.");
665 sprintf (string3, " ");
667 if (tutorialstage == 7) {
668 sprintf (string, "While running, you can press %s to roll.", Input::keyToChar(crouchkey));
669 sprintf (string2, " ");
670 sprintf (string3, " ");
672 if (tutorialstage == 8) {
673 sprintf (string, "While crouching, you can sneak around silently");
674 sprintf (string2, "using the movement keys.");
675 sprintf (string3, " ");
677 if (tutorialstage == 9) {
678 sprintf (string, "Release the crouch key while sneaking and hold the movement keys");
679 sprintf (string2, "to run animal-style.");
680 sprintf (string3, " ");
682 if (tutorialstage == 10) {
683 sprintf (string, "ADVANCED MOVEMENT:");
684 sprintf (string2, " ");
685 sprintf (string3, " ");
687 if (tutorialstage == 11) {
688 sprintf (string, "When you jump at a wall, you can hold %s again", Input::keyToChar(jumpkey));
689 sprintf (string2, "during impact to perform a walljump.");
690 sprintf (string3, "Be sure to use the movement keys to press against the wall");
692 if (tutorialstage == 12) {
693 sprintf (string, "While in the air, you can press crouch to flip.");
694 sprintf (string2, "Walljumps and flips confuse enemies and give you more control.");
695 sprintf (string3, " ");
697 if (tutorialstage == 13) {
698 sprintf (string, "BASIC COMBAT:");
699 sprintf (string2, " ");
700 sprintf (string3, " ");
702 if (tutorialstage == 14) {
703 sprintf (string, "There is now an imaginary enemy");
704 sprintf (string2, "in the middle of the training area.");
705 sprintf (string3, " ");
707 if (tutorialstage == 15) {
708 if (attackkey == MOUSEBUTTON1)
709 sprintf (string, "Click to attack when you are near an enemy.");
711 sprintf (string, "Press %s to attack when you are near an enemy.", Input::keyToChar(attackkey));
712 sprintf (string2, "You can punch by standing still near an enemy and attacking.");
713 sprintf (string3, " ");
715 if (tutorialstage == 16) {
716 sprintf (string, "If you are close, you will perform a weak punch.");
717 sprintf (string2, "The weak punch is excellent for starting attack combinations.");
718 sprintf (string3, " ");
720 if (tutorialstage == 17) {
721 sprintf (string, "Attacking while running results in a spin kick.");
722 sprintf (string2, "This is one of your most powerful ground attacks.");
723 sprintf (string3, " ");
725 if (tutorialstage == 18) {
726 sprintf (string, "Sweep the enemy's legs out by attacking while crouched.");
727 sprintf (string2, "This is a very fast attack, and easy to follow up.");
728 sprintf (string3, " ");
730 if (tutorialstage == 19) {
731 sprintf (string, "When an enemy is on the ground, you can deal some extra");
732 sprintf (string2, "damage by running up and drop-kicking him.");
733 sprintf (string3, "(Try knocking them down with a sweep first)");
735 if (tutorialstage == 20) {
736 sprintf (string, "Your most powerful individual attack is the rabbit kick.");
737 if (attackkey == MOUSEBUTTON1)
738 sprintf (string2, "Run at the enemy while holding the mouse button, and press");
740 sprintf (string2, "Run at the enemy while holding %s, and press", Input::keyToChar(attackkey));
741 sprintf (string3, "the jump key (%s) to attack.", Input::keyToChar(jumpkey));
743 if (tutorialstage == 21) {
744 sprintf (string, "This attack is devastating if timed correctly.");
745 sprintf (string2, "Even if timed incorrectly, it will knock the enemy over.");
747 sprintf (string3, "Try rabbit-kicking the imaginary enemy again.");
749 sprintf (string3, "Try rabbit-kicking the imaginary enemy.");
751 if (tutorialstage == 22) {
752 sprintf (string, "If you sneak behind an enemy unnoticed, you can kill");
753 sprintf (string2, "him instantly. Move close behind this enemy");
754 sprintf (string3, "and attack.");
756 if (tutorialstage == 23) {
757 sprintf (string, "Another important attack is the wall kick. When an enemy");
758 sprintf (string2, "is near a wall, perform a walljump nearby and hold");
759 sprintf (string3, "the attack key during impact with the wall.");
761 if (tutorialstage == 24) {
762 sprintf (string, "You can tackle enemies by running at them animal-style");
763 if (attackkey == MOUSEBUTTON1)
764 sprintf (string2, "and pressing jump (%s) or attack(mouse button).", Input::keyToChar(jumpkey));
766 sprintf (string2, "and pressing jump (%s) or attack(%s).", Input::keyToChar(jumpkey), Input::keyToChar(attackkey));
767 sprintf (string3, "This is especially useful when they are running away.");
769 if (tutorialstage == 25) {
770 sprintf (string, "Dodge by pressing back and attack. Dodging is essential");
771 sprintf (string2, "against enemies with swords or other long weapons.");
772 sprintf (string3, " ");
774 if (tutorialstage == 26) {
775 sprintf (string, "REVERSALS AND COUNTER-REVERSALS");
776 sprintf (string2, " ");
777 sprintf (string3, " ");
779 if (tutorialstage == 27) {
780 sprintf (string, "The enemy can now reverse your attacks.");
781 sprintf (string2, " ");
782 sprintf (string3, " ");
784 if (tutorialstage == 28) {
785 sprintf (string, "If you attack, you will notice that the enemy now sometimes");
786 sprintf (string2, "catches your attack and uses it against you. Hold");
787 sprintf (string3, "crouch (%s) after attacking to escape from reversals.", Input::keyToChar(crouchkey));
789 if (tutorialstage == 29) {
790 sprintf (string, "Try escaping from two more reversals in a row.");
791 sprintf (string2, " ");
792 sprintf (string3, " ");
794 if (tutorialstage == 30) {
795 sprintf (string, "Good!");
796 sprintf (string2, " ");
797 sprintf (string3, " ");
799 if (tutorialstage == 31) {
800 sprintf (string, "To reverse an attack, you must tap crouch (%s) during the", Input::keyToChar(crouchkey));
801 sprintf (string2, "enemy's attack. You must also be close to the enemy;");
802 sprintf (string3, "this is especially important against armed opponents.");
804 if (tutorialstage == 32) {
805 sprintf (string, "The enemy can attack in %d seconds.", (int)(tutorialmaxtime - tutorialstagetime));
806 sprintf (string2, "This imaginary opponents attacks will be highlighted");
807 sprintf (string3, "to make this easier.");
809 if (tutorialstage == 33) {
810 sprintf (string, "Reverse three enemy attacks!");
811 sprintf (string2, " ");
812 sprintf (string3, " ");
814 if (tutorialstage == 34) {
815 sprintf (string, "Reverse two more enemy attacks!");
816 sprintf (string2, " ");
817 sprintf (string3, " ");
819 if (tutorialstage == 35) {
820 sprintf (string, "Reverse one more enemy attack!");
821 sprintf (string2, " ");
822 sprintf (string3, " ");
824 if (tutorialstage == 36) {
825 sprintf (string, "Excellent!");
826 sprintf (string2, " ");
827 sprintf (string3, " ");
829 if (tutorialstage == 37) {
830 sprintf (string, "Now spar with the enemy for %d more seconds.", (int)(tutorialmaxtime - tutorialstagetime));
831 sprintf (string2, "Damage dealt: %d", (int)damagedealt);
832 sprintf (string3, "Damage taken: %d.", (int)damagetaken);
834 if (tutorialstage == 38) {
835 sprintf (string, "WEAPONS:");
836 sprintf (string2, " ");
837 sprintf (string3, " ");
839 if (tutorialstage == 39) {
840 sprintf (string, "There is now an imaginary knife");
841 sprintf (string2, "in the center of the training area.");
842 sprintf (string3, " ");
844 if (tutorialstage == 40) {
845 sprintf (string, "Stand, roll or handspring over the knife");
846 sprintf (string2, "while pressing %s to pick it up.", Input::keyToChar(throwkey));
847 sprintf (string3, "You can crouch and press the same key to drop it again.");
849 if (tutorialstage == 41) {
850 sprintf (string, "You can equip and unequip weapons using the %s key.", Input::keyToChar(drawkey));
851 sprintf (string2, "Sometimes it is best to keep them unequipped to");
852 sprintf (string3, "prevent enemies from taking them. ");
854 if (tutorialstage == 42) {
855 sprintf (string, "The knife is the smallest weapon and the least encumbering.");
856 sprintf (string2, "You can equip or unequip it while standing, crouching,");
857 sprintf (string3, "running or flipping.");
859 if (tutorialstage == 43) {
860 sprintf (string, "You perform weapon attacks the same way as unarmed attacks,");
861 sprintf (string2, "but sharp weapons cause permanent damage, instead of the");
862 sprintf (string3, "temporary trauma from blunt weapons, fists and feet.");
864 if (tutorialstage == 44) {
865 sprintf (string, "The enemy now has your knife!");
866 sprintf (string2, "Please reverse two of his knife attacks.");
867 sprintf (string3, " ");
869 if (tutorialstage == 45) {
870 sprintf (string, "Please reverse one more of his knife attacks.");
871 sprintf (string2, " ");
872 sprintf (string3, " ");
874 if (tutorialstage == 46) {
875 sprintf (string, "Now he has a sword!");
876 sprintf (string2, "The sword has longer reach than your arms, so you");
877 sprintf (string3, "must move close to reverse the sword slash.");
879 if (tutorialstage == 47) {
880 sprintf (string, "Long weapons like the sword and staff are also useful for defense;");
881 sprintf (string2, "you can parry enemy weapon attacks by pressing the attack key");
882 sprintf (string3, "at the right time. Please try parrying the enemy's attacks!");
884 if (tutorialstage == 48) {
885 sprintf (string, "The staff is like the sword, but has two main attacks.");
886 sprintf (string2, "The standing smash is fast and effective, and the running");
887 sprintf (string3, "spin smash is slower and more powerful.");
889 if (tutorialstage == 49) {
890 sprintf (string, "When facing an enemy, you can throw the knife with %s.", Input::keyToChar(throwkey));
891 sprintf (string2, "It is possible to throw the knife while flipping,");
892 sprintf (string3, "but it is very inaccurate.");
894 if (tutorialstage == 50) {
895 sprintf (string, "You now know everything you can learn from training.");
896 sprintf (string2, "Everything else you must learn from experience!");
897 sprintf (string3, " ");
899 if (tutorialstage == 51) {
900 sprintf (string, "Walk out of the training area to return to the main menu.");
901 sprintf (string2, " ");
902 sprintf (string3, " ");
905 glColor4f(0, 0, 0, tutorialopac);
906 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);
907 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);
908 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);
909 glColor4f(1, 1, 1, tutorialopac);
910 text->glPrint(screenwidth / 2 - 7.6 * strlen(string)*screenwidth / 1024, screenheight / 16 + screenheight * 4 / 5, string, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight);
911 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);
912 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);
914 sprintf (string, "Press 'tab' to skip to the next item.");
915 sprintf (string2, "Press escape at any time to");
916 sprintf (string3, "pause or exit the tutorial.");
918 glColor4f(0, 0, 0, 1);
919 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);
920 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);
921 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);
922 glColor4f(0.5, 0.5, 0.5, 1);
923 text->glPrint(screenwidth / 2 - 7.6 * strlen(string)*screenwidth / 1024 * .8, 0 + screenheight * 1 / 10, string, 1, 1.5 * screenwidth / 1024 * .8, screenwidth, screenheight);
924 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);
925 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);
929 if (numhotspots && (bonustime >= 1 || bonus <= 0 || bonustime < 0) && !tutoriallevel) {
930 float closestdist = -1;
932 int closest = currenthotspot;
933 for (int i = 0; i < numhotspots; i++) {
934 distance = distsq(&Person::players[0]->coords, &hotspot[i]);
935 if (closestdist == -1 || distance < closestdist) {
936 if (distsq(&Person::players[0]->coords, &hotspot[i]) < hotspotsize[i] && ((hotspottype[i] <= 10 && hotspottype[i] >= 0) || (hotspottype[i] <= 40 && hotspottype[i] >= 20))) {
937 closestdist = distance;
943 currenthotspot = closest;
944 if (currenthotspot != -1) {
945 if (hotspottype[closest] <= 10) {
946 if (distsq(&Person::players[0]->coords, &hotspot[closest]) < hotspotsize[closest])
947 tutorialstagetime = 0;
949 tutorialopac = tutorialmaxtime - tutorialstagetime;
950 if (tutorialopac > 1)
952 if (tutorialopac < 0)
955 sprintf (string, "%s", hotspottext[closest]);
962 if (string[i] == '\n' || string[i] > 'z' || string[i] < ' ' || string[i] == '\0') {
963 glColor4f(0, 0, 0, tutorialopac);
964 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);
965 glColor4f(1, 1, 1, tutorialopac);
966 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);
969 if (string[i] == '\0')
976 } else if (hotspottype[closest] >= 20 && dialoguegonethrough[hotspottype[closest] - 20] == 0) {
977 whichdialogue = hotspottype[closest] - 20;
978 for (int j = 0; j < numdialogueboxes[whichdialogue]; j++) {
979 Person::players[participantfocus[whichdialogue][j]]->coords = participantlocation[whichdialogue][participantfocus[whichdialogue][j]];
980 Person::players[participantfocus[whichdialogue][j]]->yaw = participantyaw[whichdialogue][participantfocus[whichdialogue][j]];
981 Person::players[participantfocus[whichdialogue][j]]->targetyaw = participantyaw[whichdialogue][participantfocus[whichdialogue][j]];
982 Person::players[participantfocus[whichdialogue][j]]->velocity = 0;
983 Person::players[participantfocus[whichdialogue][j]]->animTarget = Person::players[participantfocus[whichdialogue][j]]->getIdle();
984 Person::players[participantfocus[whichdialogue][j]]->frameTarget = 0;
988 dialoguegonethrough[whichdialogue]++;
989 if (dialogueboxsound[whichdialogue][indialogue] != 0) {
991 if (dialogueboxsound[whichdialogue][indialogue] == 1) whichsoundplay = rabbitchitter;
992 if (dialogueboxsound[whichdialogue][indialogue] == 2) whichsoundplay = rabbitchitter2;
993 if (dialogueboxsound[whichdialogue][indialogue] == 3) whichsoundplay = rabbitpainsound;
994 if (dialogueboxsound[whichdialogue][indialogue] == 4) whichsoundplay = rabbitpain1sound;
995 if (dialogueboxsound[whichdialogue][indialogue] == 5) whichsoundplay = rabbitattacksound;
996 if (dialogueboxsound[whichdialogue][indialogue] == 6) whichsoundplay = rabbitattack2sound;
997 if (dialogueboxsound[whichdialogue][indialogue] == 7) whichsoundplay = rabbitattack3sound;
998 if (dialogueboxsound[whichdialogue][indialogue] == 8) whichsoundplay = rabbitattack4sound;
999 if (dialogueboxsound[whichdialogue][indialogue] == 9) whichsoundplay = growlsound;
1000 if (dialogueboxsound[whichdialogue][indialogue] == 10) whichsoundplay = growl2sound;
1001 if (dialogueboxsound[whichdialogue][indialogue] == 11) whichsoundplay = snarlsound;
1002 if (dialogueboxsound[whichdialogue][indialogue] == 12) whichsoundplay = snarl2sound;
1003 if (dialogueboxsound[whichdialogue][indialogue] == 13) whichsoundplay = barksound;
1004 if (dialogueboxsound[whichdialogue][indialogue] == 14) whichsoundplay = bark2sound;
1005 if (dialogueboxsound[whichdialogue][indialogue] == 15) whichsoundplay = bark3sound;
1006 if (dialogueboxsound[whichdialogue][indialogue] == 16) whichsoundplay = barkgrowlsound;
1007 if (dialogueboxsound[whichdialogue][indialogue] == -1) whichsoundplay = fireendsound;
1008 if (dialogueboxsound[whichdialogue][indialogue] == -2) whichsoundplay = firestartsound;
1009 if (dialogueboxsound[whichdialogue][indialogue] == -3) whichsoundplay = consolesuccesssound;
1010 if (dialogueboxsound[whichdialogue][indialogue] == -4) whichsoundplay = consolefailsound;
1011 emit_sound_at(whichsoundplay, Person::players[participantfocus[whichdialogue][indialogue]]->coords);
1017 if (indialogue != -1 && !mainmenu) {
1018 glDisable(GL_DEPTH_TEST);
1019 glDisable(GL_CULL_FACE);
1020 glDisable(GL_LIGHTING);
1021 glDisable(GL_TEXTURE_2D);
1023 glMatrixMode(GL_PROJECTION);
1026 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1027 glMatrixMode(GL_MODELVIEW);
1030 if (dialogueboxlocation[whichdialogue][indialogue] == 1)
1031 glTranslatef(0, screenheight * 3 / 4, 0);
1032 glScalef(screenwidth, screenheight / 4, 1);
1033 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1036 glColor4f(dialogueboxcolor[whichdialogue][indialogue][0], dialogueboxcolor[whichdialogue][indialogue][1], dialogueboxcolor[whichdialogue][indialogue][2], 0.7);
1038 glVertex3f(0, 0, 0.0f);
1039 glVertex3f(1, 0, 0.0f);
1040 glVertex3f(1, 1, 0.0f);
1041 glVertex3f(0, 1, 0.0f);
1043 glMatrixMode(GL_PROJECTION);
1045 glMatrixMode(GL_MODELVIEW);
1047 glEnable(GL_DEPTH_TEST);
1048 glEnable(GL_CULL_FACE);
1049 glDisable(GL_BLEND);
1051 glEnable(GL_TEXTURE_2D);
1058 startx = screenwidth * 1 / 5;
1059 if (dialogueboxlocation[whichdialogue][indialogue] == 1)
1060 starty = screenheight / 16 + screenheight * 4 / 5;
1061 if (dialogueboxlocation[whichdialogue][indialogue] == 2)
1062 starty = screenheight * 1 / 5 - screenheight / 16;
1067 for (int i = 0; i < 264; i++) {
1071 for (int i = 0; i < (int)strlen(dialoguename[whichdialogue][indialogue]); i++) {
1072 tempname[tempnum] = dialoguename[whichdialogue][indialogue][i];
1074 if (dialoguename[whichdialogue][indialogue][i] == '#' || dialoguename[whichdialogue][indialogue][i] == '\0')
1079 tempname[tempnum] = '\0';
1082 sprintf (string, "%s: ", tempname);
1084 if (dialogueboxcolor[whichdialogue][indialogue][0] + dialogueboxcolor[whichdialogue][indialogue][1] + dialogueboxcolor[whichdialogue][indialogue][2] < 1.5) {
1085 glColor4f(0, 0, 0, tutorialopac);
1086 text->glPrintOutline(startx - 2 * 7.6 * strlen(string)*screenwidth / 1024 - 4, starty - 4, string, 1, 1.5 * 1.25 * screenwidth / 1024, screenwidth, screenheight);
1087 glColor4f(0.7, 0.7, 0.7, tutorialopac);
1088 text->glPrint(startx - 2 * 7.6 * strlen(string)*screenwidth / 1024, starty, string, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight);
1090 glColor4f(0, 0, 0, tutorialopac);
1091 text->glPrintOutline(startx - 2 * 7.6 * strlen(string)*screenwidth / 1024 - 4, starty - 4, string, 1, 1.5 * 1.25 * screenwidth / 1024, screenwidth, screenheight);
1095 for (int i = 0; i < (int)strlen(dialoguetext[whichdialogue][indialogue]) + 1; i++) {
1096 tempname[tempnum] = dialoguetext[whichdialogue][indialogue][i];
1097 if (dialoguetext[whichdialogue][indialogue][i] != '#')
1101 sprintf (string, "%s", tempname);
1108 if (string[i] == '\n' || string[i] > 'z' || string[i] < ' ' || string[i] == '\0') {
1109 if (dialogueboxcolor[whichdialogue][indialogue][0] + dialogueboxcolor[whichdialogue][indialogue][1] + dialogueboxcolor[whichdialogue][indialogue][2] < 1.5) {
1110 glColor4f(0, 0, 0, tutorialopac);
1111 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);
1112 glColor4f(1, 1, 1, tutorialopac);
1113 text->glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/, starty - 20 * screenwidth / 1024 * line, string, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight, lastline, i);
1115 glColor4f(0, 0, 0, tutorialopac);
1116 text->glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/, starty - 20 * screenwidth / 1024 * line, string, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight, lastline, i);
1120 if (string[i] == '\0')
1129 if (!tutoriallevel && !winfreeze && indialogue == -1 && !mainmenu) {
1132 sprintf (string, "Score: %d", (int)accountactive->getCampaignScore());
1134 sprintf (string, "Score: %d", (int)accountactive->getCampaignScore() + (int)bonustotal);
1137 sprintf (string, "Score: %d", (int)bonustotal);
1138 glColor4f(0, 0, 0, 1);
1139 text->glPrintOutline(1024 / 40 - 4, 768 / 16 - 4 + 768 * 14 / 16, string, 1, 1.5 * 1.25, 1024, 768);
1140 glColor4f(1, 0, 0, 1);
1141 text->glPrint(1024 / 40, 768 / 16 + 768 * 14 / 16, string, 1, 1.5, 1024, 768);
1142 if (showdamagebar) {
1143 glDisable(GL_DEPTH_TEST);
1144 glDisable(GL_CULL_FACE);
1145 glDisable(GL_LIGHTING);
1146 glDisable(GL_TEXTURE_2D);
1148 glMatrixMode(GL_PROJECTION);
1151 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1152 glMatrixMode(GL_MODELVIEW);
1155 glTranslatef(15, screenheight * 17.5 / 20, 0);
1156 glScalef(screenwidth / 3 + 20, screenheight / 20, 1);
1157 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1159 glColor4f(0.0, 0.4, 0.0, 0.7);
1160 float bar = ((float)Person::players[0]->damage) / Person::players[0]->damagetolerance;
1162 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
1163 glVertex3f(1, 0, 0.0f);
1164 glVertex3f(1, 1, 0.0f);
1165 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
1167 glColor4f(0.1, 0.0, 0.0, 1);
1168 bar = ((float)Person::players[0]->bloodloss) / Person::players[0]->damagetolerance;
1170 glVertex3f(0, 0, 0.0f);
1171 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
1172 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
1173 glVertex3f(0, 1, 0.0f);
1175 glColor4f(0.4, 0.0, 0.0, 0.7);
1176 bar = ((float)Person::players[0]->damage) / Person::players[0]->damagetolerance;
1178 glVertex3f(0, 0, 0.0f);
1179 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
1180 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
1181 glVertex3f(0, 1, 0.0f);
1183 glColor4f(0.4, 0.0, 0.0, 0.7);
1184 bar = ((float)Person::players[0]->permanentdamage) / Person::players[0]->damagetolerance;
1186 glVertex3f(0, 0, 0.0f);
1187 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
1188 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
1189 glVertex3f(0, 1, 0.0f);
1191 glColor4f(0.4, 0.0, 0.0, 0.7);
1192 bar = ((float)Person::players[0]->superpermanentdamage) / Person::players[0]->damagetolerance;
1194 glVertex3f(0, 0, 0.0f);
1195 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
1196 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
1197 glVertex3f(0, 1, 0.0f);
1199 glColor4f(0.0, 0.0, 0.0, 0.7);
1201 glBegin(GL_LINE_STRIP);
1202 glVertex3f(0, 0, 0.0f);
1203 glVertex3f(1, 0, 0.0f);
1204 glVertex3f(1, 1, 0.0f);
1205 glVertex3f(0, 1, 0.0f);
1206 glVertex3f(0, 0, 0.0f);
1209 glMatrixMode(GL_PROJECTION);
1211 glMatrixMode(GL_MODELVIEW);
1213 glEnable(GL_DEPTH_TEST);
1214 glEnable(GL_CULL_FACE);
1215 glDisable(GL_BLEND);
1217 glEnable(GL_TEXTURE_2D);
1219 // writing the numbers :
1220 sprintf (string, "Damages : %d/%d (%d)", (int)(Person::players[0]->damage), (int)(Person::players[0]->damagetolerance), (int)(Person::players[0]->bloodloss));
1221 glColor4f(0, 0, 0, 1);
1222 text->glPrintOutline(1024 / 40 - 4, 768 / 16 - 4 + 768 * 14 / 16 - 40, string, 1, 1.5 * 1.25, 1024, 768);
1223 glColor4f(1, 0, 0, 1);
1224 text->glPrint(1024 / 40, 768 / 16 + 768 * 14 / 16 - 40, string, 1, 1.5, 1024, 768);
1228 glColor4f(.5, .5, .5, 1);
1231 if ((texttoggle || editorenabled) && debugmode && !mainmenu) {
1232 sprintf (string, "The framespersecond is %d.", (int)(fps));
1233 text->glPrint(10, 30, string, 0, .8, 1024, 768);
1236 sprintf (string, "Map editor enabled.");
1238 sprintf (string, "Map editor disabled.");
1239 text->glPrint(10, 60, string, 0, .8, 1024, 768);
1240 if (editorenabled) {
1241 sprintf (string, "Object size: %f", editorsize);
1242 text->glPrint(10, 75, string, 0, .8, 1024, 768);
1244 sprintf (string, "Object yaw: %f", editoryaw);
1246 sprintf (string, "Object yaw: Random");
1247 text->glPrint(10, 90, string, 0, .8, 1024, 768);
1248 if (editorpitch >= 0)
1249 sprintf (string, "Object pitch: %f", editorpitch);
1251 sprintf (string, "Object pitch: Random");
1252 text->glPrint(10, 105, string, 0, .8, 1024, 768);
1253 sprintf (string, "Object type: %d", editortype);
1254 text->glPrint(10, 120, string, 0, .8, 1024, 768);
1255 switch (editortype) {
1257 sprintf (string, "(box)");
1260 sprintf (string, "(tree)");
1263 sprintf (string, "(wall)");
1266 sprintf (string, "(weird)");
1269 sprintf (string, "(spike)");
1272 sprintf (string, "(rock)");
1275 sprintf (string, "(bush)");
1278 sprintf (string, "(tunnel)");
1281 sprintf (string, "(chimney)");
1284 sprintf (string, "(platform)");
1287 sprintf (string, "(cool)");
1290 sprintf (string, "(fire)");
1293 text->glPrint(130, 120, string, 0, .8, 1024, 768);
1295 sprintf (string, "Numplayers: %lu", Person::players.size());
1296 text->glPrint(10, 155, string, 0, .8, 1024, 768);
1297 sprintf (string, "Player %d: numwaypoints: %d", (int(Person::players.size()) - 1), Person::players.back()->numwaypoints);
1298 text->glPrint(10, 140, string, 0, .8, 1024, 768);
1300 sprintf (string, "Difficulty: %d", difficulty);
1301 text->glPrint(10, 240, string, 0, .8, 1024, 768);
1306 if (drawmode == glowmode) {
1307 glDisable(GL_DEPTH_TEST);
1308 glDisable(GL_CULL_FACE);
1309 glDisable(GL_LIGHTING);
1310 glDisable(GL_TEXTURE_2D);
1312 glMatrixMode(GL_PROJECTION);
1315 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1316 glMatrixMode(GL_MODELVIEW);
1319 glScalef(screenwidth, screenheight, 1);
1320 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1322 glColor4f(0, 0, 0, .5);
1324 glVertex3f(0, 0, 0.0f);
1325 glVertex3f(256, 0, 0.0f);
1326 glVertex3f(256, 256, 0.0f);
1327 glVertex3f(0, 256, 0.0f);
1329 glMatrixMode(GL_PROJECTION);
1331 glMatrixMode(GL_MODELVIEW);
1333 glEnable(GL_DEPTH_TEST);
1334 glEnable(GL_CULL_FACE);
1335 glDisable(GL_BLEND);
1339 if ((((blackout && damageeffects) || (Person::players[0]->bloodloss > 0 && damageeffects && Person::players[0]->blooddimamount > 0) || Person::players[0]->dead) && !cameramode) || console) {
1340 glDisable(GL_DEPTH_TEST);
1341 glDisable(GL_CULL_FACE);
1342 glDisable(GL_LIGHTING);
1343 glDisable(GL_TEXTURE_2D);
1345 glMatrixMode(GL_PROJECTION);
1348 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1349 glMatrixMode(GL_MODELVIEW);
1352 glScalef(screenwidth, screenheight, 1);
1353 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1355 if (Person::players[0]->dead)
1356 blackout += multiplier * 3;
1357 if (Person::players[0]->dead == 1)
1359 if (Person::players[0]->dead == 2 && blackout > .6)
1361 glColor4f(0, 0, 0, blackout);
1362 if (!Person::players[0]->dead) {
1363 if ((Person::players[0]->bloodloss / Person::players[0]->damagetolerance * (sin(woozy) / 4 + .5))*.3 < .3) {
1364 glColor4f(0, 0, 0, Person::players[0]->blooddimamount * Person::players[0]->bloodloss / Person::players[0]->damagetolerance * (sin(woozy) / 4 + .5)*.3);
1365 blackout = Person::players[0]->blooddimamount * Person::players[0]->bloodloss / Person::players[0]->damagetolerance * (sin(woozy) / 4 + .5) * .3;
1367 glColor4f(0, 0, 0, Person::players[0]->blooddimamount * .3);
1368 blackout = Person::players[0]->blooddimamount * .3;
1372 glColor4f(.7, 0, 0, .2);
1374 glVertex3f(0, 0, 0.0f);
1375 glVertex3f(256, 0, 0.0f);
1376 glVertex3f(256, 256, 0.0f);
1377 glVertex3f(0, 256, 0.0f);
1379 glMatrixMode(GL_PROJECTION);
1381 glMatrixMode(GL_MODELVIEW);
1383 glEnable(GL_DEPTH_TEST);
1384 glEnable(GL_CULL_FACE);
1385 glDisable(GL_BLEND);
1389 if (flashamount > 0 && damageeffects) {
1390 if (flashamount > 1)
1392 if (flashdelay <= 0)
1393 flashamount -= multiplier;
1395 if (flashamount < 0)
1397 glDisable(GL_DEPTH_TEST);
1398 glDisable(GL_CULL_FACE);
1399 glDisable(GL_LIGHTING);
1401 glMatrixMode(GL_PROJECTION);
1404 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1405 glMatrixMode(GL_MODELVIEW);
1408 glScalef(screenwidth, screenheight, 1);
1409 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1411 glColor4f(flashr, flashg, flashb, flashamount);
1413 glVertex3f(0, 0, 0.0f);
1414 glVertex3f(256, 0, 0.0f);
1415 glVertex3f(256, 256, 0.0f);
1416 glVertex3f(0, 256, 0.0f);
1418 glMatrixMode(GL_PROJECTION);
1420 glMatrixMode(GL_MODELVIEW);
1422 glEnable(GL_DEPTH_TEST);
1423 glEnable(GL_CULL_FACE);
1424 glDisable(GL_BLEND);
1430 glEnable(GL_TEXTURE_2D);
1431 glColor4f(1, 1, 1, 1);
1432 for (unsigned i = 1; i < 15; i++)
1433 if (displaytime[i] < 4)
1434 for (unsigned j = 0; j < displaytext[i].size(); j++) {
1435 glColor4f(1, 1, 1, 4 - displaytime[i]);
1436 sprintf (string, "%c", displaytext[i][j]);
1437 text->glPrint(30 + j * 10, 30 + i * 20 + (screenheight - 330), string, 0, 1, screenwidth, screenheight);
1441 if (difficulty < 2 && indialogue == -1) { // minimap
1442 float mapviewdist = 20000;
1444 glDisable(GL_DEPTH_TEST);
1445 glColor3f (1.0, 1.0, 1.0); // no coloring
1447 glEnable(GL_TEXTURE_2D);
1448 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1449 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1450 glDisable(GL_DEPTH_TEST);
1451 glDisable(GL_CULL_FACE);
1452 glDisable(GL_LIGHTING);
1454 glMatrixMode(GL_PROJECTION);
1457 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1458 glMatrixMode(GL_MODELVIEW);
1461 glScalef((float)screenwidth / 2, (float)screenwidth / 2, 1);
1462 glTranslatef(1.75, .25, 0);
1463 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1465 glColor4f(1, 1, 1, 1);
1471 int numliveplayers = 0;
1473 for (unsigned i = 0; i < Person::players.size(); i++) {
1474 if (!Person::players[i]->dead)
1480 for (int i = 0; i < objects.numobjects; i++) {
1481 if (objects.type[i] == treetrunktype || objects.type[i] == boxtype) {
1482 center += objects.position[i];
1486 for (unsigned i = 0; i < Person::players.size(); i++) {
1487 if (!Person::players[i]->dead)
1488 center += Person::players[i]->coords;
1490 center /= numadd + numliveplayers;
1492 center = Person::players[0]->coords;
1494 float maxdistance = 0;
1496 //~ int whichclosest;
1497 for (int i = 0; i < objects.numobjects; i++) {
1498 tempdist = distsq(¢er, &objects.position[i]);
1499 if (tempdist > maxdistance) {
1501 maxdistance = tempdist;
1504 for (unsigned i = 0; i < Person::players.size(); i++) {
1505 if (!Person::players[i]->dead) {
1506 tempdist = distsq(¢er, &Person::players[i]->coords);
1507 if (tempdist > maxdistance) {
1509 maxdistance = tempdist;
1515 glScalef(.25 / radius * 256 * terrain.scale * .4, .25 / radius * 256 * terrain.scale * .4, 1);
1517 glScalef(1 / (1 / radius * 256 * terrain.scale * .4), 1 / (1 / radius * 256 * terrain.scale * .4), 1);
1519 glRotatef(Person::players[0]->lookyaw * -1 + 180, 0, 0, 1);
1520 glTranslatef(-(center.x / terrain.scale / 256 * -2 + 1), (center.z / terrain.scale / 256 * -2 + 1), 0);
1521 for (int i = 0; i < objects.numobjects; i++) {
1522 if (objects.type[i] == treetrunktype) {
1523 distcheck = distsq(&Person::players[0]->coords, &objects.position[i]);
1524 if (distcheck < mapviewdist) {
1525 Mapcircletexture.bind();
1526 glColor4f(0, .3, 0, opac * (1 - distcheck / mapviewdist));
1528 glTranslatef(objects.position[i].x / terrain.scale / 256 * -2 + 1, objects.position[i].z / terrain.scale / 256 * 2 - 1, 0);
1529 glRotatef(objects.yaw[i], 0, 0, 1);
1530 glScalef(.003, .003, .003);
1533 glVertex3f(-1, -1, 0.0f);
1535 glVertex3f(1, -1, 0.0f);
1537 glVertex3f(1, 1, 0.0f);
1539 glVertex3f(-1, 1, 0.0f);
1544 if (objects.type[i] == boxtype) {
1545 distcheck = distsq(&Person::players[0]->coords, &objects.position[i]);
1546 if (distcheck < mapviewdist) {
1547 Mapboxtexture.bind();
1548 glColor4f(.4, .4, .4, opac * (1 - distcheck / mapviewdist));
1550 glTranslatef(objects.position[i].x / terrain.scale / 256 * -2 + 1, objects.position[i].z / terrain.scale / 256 * 2 - 1, 0);
1551 glRotatef(objects.yaw[i], 0, 0, 1);
1552 glScalef(.01 * objects.scale[i], .01 * objects.scale[i], .01 * objects.scale[i]);
1555 glVertex3f(-1, -1, 0.0f);
1557 glVertex3f(1, -1, 0.0f);
1559 glVertex3f(1, 1, 0.0f);
1561 glVertex3f(-1, 1, 0.0f);
1567 if (editorenabled) {
1568 Mapcircletexture.bind();
1569 for (int i = 0; i < numboundaries; i++) {
1570 glColor4f(0, 0, 0, opac / 3);
1572 glTranslatef(boundary[i].x / terrain.scale / 256 * -2 + 1, boundary[i].z / terrain.scale / 256 * 2 - 1, 0);
1573 glScalef(.002, .002, .002);
1576 glVertex3f(-1, -1, 0.0f);
1578 glVertex3f(1, -1, 0.0f);
1580 glVertex3f(1, 1, 0.0f);
1582 glVertex3f(-1, 1, 0.0f);
1587 for (unsigned i = 0; i < Person::players.size(); i++) {
1588 distcheck = distsq(&Person::players[0]->coords, &Person::players[i]->coords);
1589 if (distcheck < mapviewdist) {
1591 Maparrowtexture.bind();
1593 glColor4f(1, 1, 1, opac);
1594 else if (Person::players[i]->dead == 2 || Person::players[i]->howactive > typesleeping)
1595 glColor4f(0, 0, 0, opac * (1 - distcheck / mapviewdist));
1596 else if (Person::players[i]->dead)
1597 glColor4f(.3, .3, .3, opac * (1 - distcheck / mapviewdist));
1598 else if (Person::players[i]->aitype == attacktypecutoff)
1599 glColor4f(1, 0, 0, opac * (1 - distcheck / mapviewdist));
1600 else if (Person::players[i]->aitype == passivetype)
1601 glColor4f(0, 1, 0, opac * (1 - distcheck / mapviewdist));
1603 glColor4f(1, 1, 0, 1);
1604 glTranslatef(Person::players[i]->coords.x / terrain.scale / 256 * -2 + 1, Person::players[i]->coords.z / terrain.scale / 256 * 2 - 1, 0);
1605 glRotatef(Person::players[i]->yaw + 180, 0, 0, 1);
1606 glScalef(.005, .005, .005);
1609 glVertex3f(-1, -1, 0.0f);
1611 glVertex3f(1, -1, 0.0f);
1613 glVertex3f(1, 1, 0.0f);
1615 glVertex3f(-1, 1, 0.0f);
1621 glDisable(GL_TEXTURE_2D);
1622 glMatrixMode(GL_PROJECTION);
1624 glMatrixMode(GL_MODELVIEW);
1626 glEnable(GL_DEPTH_TEST);
1627 glEnable(GL_CULL_FACE);
1628 glDisable(GL_BLEND);
1632 if (loading && !stealthloading && (!campaign || Person::players[0]->dead)) {
1633 glDisable(GL_DEPTH_TEST);
1634 glDisable(GL_CULL_FACE);
1635 glDisable(GL_LIGHTING);
1636 glDisable(GL_TEXTURE_2D);
1638 glMatrixMode(GL_PROJECTION);
1641 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1642 glMatrixMode(GL_MODELVIEW);
1645 glScalef(screenwidth, screenheight, 1);
1646 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1648 glColor4f(0, 0, 0, .7);
1650 glVertex3f(0, 0, 0.0f);
1651 glVertex3f(256, 0, 0.0f);
1652 glVertex3f(256, 256, 0.0f);
1653 glVertex3f(0, 256, 0.0f);
1655 glMatrixMode(GL_PROJECTION);
1657 glMatrixMode(GL_MODELVIEW);
1659 glEnable(GL_DEPTH_TEST);
1660 glEnable(GL_CULL_FACE);
1661 glDisable(GL_BLEND);
1665 glDisable(GL_DEPTH_TEST);
1666 glColor3f (1.0, 1.0, 1.0); // no coloring
1668 glEnable(GL_TEXTURE_2D);
1673 glEnable(GL_TEXTURE_2D);
1674 glColor4f(1, 1, 1, 1);
1675 sprintf (string, "Loading...");
1676 text->glPrint(1024 / 2 - 90, 768 / 2, string, 1, 2, 1024, 768);
1679 drawmode = normalmode;
1682 if (winfreeze && !campaign) {
1683 glDisable(GL_DEPTH_TEST);
1684 glDisable(GL_CULL_FACE);
1685 glDisable(GL_LIGHTING);
1686 glDisable(GL_TEXTURE_2D);
1688 glMatrixMode(GL_PROJECTION);
1691 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1692 glMatrixMode(GL_MODELVIEW);
1695 glScalef(screenwidth, screenheight, 1);
1696 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1698 glColor4f(0, 0, 0, .4);
1700 glVertex3f(0, 0, 0.0f);
1701 glVertex3f(256, 0, 0.0f);
1702 glVertex3f(256, 256, 0.0f);
1703 glVertex3f(0, 256, 0.0f);
1705 glMatrixMode(GL_PROJECTION);
1707 glMatrixMode(GL_MODELVIEW);
1709 glEnable(GL_DEPTH_TEST);
1710 glEnable(GL_CULL_FACE);
1711 glDisable(GL_BLEND);
1715 glDisable(GL_DEPTH_TEST);
1716 glColor3f (1.0, 1.0, 1.0); // no coloring
1718 glEnable(GL_TEXTURE_2D);
1720 //Win Screen Won Victory
1722 glEnable(GL_TEXTURE_2D);
1723 glColor4f(1, 1, 1, 1);
1724 sprintf (string, "Level Cleared!");
1725 text->glPrintOutlined(1024 / 2 - strlen(string) * 10, 768 * 7 / 8, string, 1, 2, 1024, 768);
1727 sprintf (string, "Score: %d", (int)(bonustotal - startbonustotal));
1728 text->glPrintOutlined(1024 / 30, 768 * 6 / 8, string, 1, 2, 1024, 768);
1731 sprintf (string, "Press Escape or Space to continue");
1733 sprintf (string, "Press Escape to return to menu or Space to continue");
1734 text->glPrintOutlined(640 / 2 - strlen(string) * 5, 480 * 1 / 16, string, 1, 1, 640, 480);
1738 for (int i = 0; i < 255; i++)
1740 sprintf (temp, "Time: %d:", (int)(((int)leveltime - (int)(leveltime) % 60) / 60));
1741 strcat(string, temp);
1742 if ((int)(leveltime) % 60 < 10)
1743 strcat(string, "0");
1744 sprintf (temp, "%d", (int)(leveltime) % 60);
1745 strcat(string, temp);
1746 text->glPrintOutlined(1024 / 30, 768 * 6 / 8 - 40, string, 1, 2, 1024, 768);
1749 int awards[award_count];
1750 int numawards = award_awards(awards);
1752 for (int i = 0; i < numawards && i < 6; i++)
1753 text->glPrintOutlined(1024 / 30, 768 * 6 / 8 - 90 - 40 * i, award_names[awards[i]], 1, 2, 1024, 768);
1756 if (drawmode != normalmode) {
1757 glEnable(GL_TEXTURE_2D);
1759 if (!drawtoggle || drawmode != realmotionblurmode || (drawtoggle == 2 || change == 1)) {
1760 if (screentexture) {
1762 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
1763 GLfloat subtractColor[4] = { 0.5, 0.5, 0.5, 0.0 };
1764 glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, subtractColor);
1765 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE);
1766 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_CONSTANT_EXT);
1767 glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 2.0f);
1769 glBindTexture( GL_TEXTURE_2D, screentexture);
1770 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1773 if ((drawtoggle || change == 1) && drawmode == realmotionblurmode) {
1774 if (screentexture2) {
1775 glBindTexture( GL_TEXTURE_2D, screentexture2);
1776 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1778 if (!screentexture2) {
1779 glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
1781 glGenTextures( 1, &screentexture2 );
1782 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
1784 glEnable(GL_TEXTURE_2D);
1785 glBindTexture( GL_TEXTURE_2D, screentexture2);
1786 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
1787 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
1789 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
1794 glClear(GL_DEPTH_BUFFER_BIT);
1795 Game::ReSizeGLScene(90, .1f);
1796 glViewport(0, 0, screenwidth, screenheight);
1798 if (drawmode != normalmode) {
1799 glDisable(GL_DEPTH_TEST);
1800 if (drawmode == motionblurmode) {
1801 glDrawBuffer(GL_FRONT);
1802 glReadBuffer(GL_BACK);
1804 glColor3f (1.0, 1.0, 1.0); // no coloring
1806 glEnable(GL_TEXTURE_2D);
1807 glBindTexture( GL_TEXTURE_2D, screentexture);
1808 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1809 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1810 glDisable(GL_DEPTH_TEST);
1811 glDisable(GL_CULL_FACE);
1812 glDisable(GL_LIGHTING);
1814 glMatrixMode(GL_PROJECTION);
1817 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1818 glMatrixMode(GL_MODELVIEW);
1821 glScalef((float)screenwidth / 2, (float)screenheight / 2, 1);
1822 glTranslatef(1, 1, 0);
1823 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1825 if (drawmode == motionblurmode) {
1826 if (motionbluramount < .2)
1827 motionbluramount = .2;
1828 glColor4f(1, 1, 1, motionbluramount);
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);
1842 if (drawmode == realmotionblurmode) {
1843 glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
1844 glClear(GL_COLOR_BUFFER_BIT);
1845 glBlendFunc(GL_SRC_ALPHA, GL_ONE);
1846 glBindTexture( GL_TEXTURE_2D, screentexture);
1847 glColor4f(1, 1, 1, .5);
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);
1860 glBindTexture( GL_TEXTURE_2D, screentexture2);
1861 glColor4f(1, 1, 1, .5);
1865 glVertex3f(-1, -1, 0.0f);
1866 glTexCoord2f(texcoordwidth, 0);
1867 glVertex3f(1, -1, 0.0f);
1868 glTexCoord2f(texcoordwidth, texcoordheight);
1869 glVertex3f(1, 1, 0.0f);
1870 glTexCoord2f(0, texcoordheight);
1871 glVertex3f(-1, 1, 0.0f);
1874 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1876 if (drawmode == doublevisionmode) {
1877 static float crosseyedness;
1878 crosseyedness = abs(Person::players[0]->damage - Person::players[0]->superpermanentdamage - (Person::players[0]->damagetolerance - Person::players[0]->superpermanentdamage) * 1 / 2) / 30;
1879 if (crosseyedness > 1)
1881 if (crosseyedness < 0)
1883 glColor4f(1, 1, 1, 1);
1884 glDisable(GL_BLEND);
1889 glVertex3f(-1, -1, 0.0f);
1890 glTexCoord2f(texcoordwidth, 0);
1891 glVertex3f(1, -1, 0.0f);
1892 glTexCoord2f(texcoordwidth, texcoordheight);
1893 glVertex3f(1, 1, 0.0f);
1894 glTexCoord2f(0, texcoordheight);
1895 glVertex3f(-1, 1, 0.0f);
1898 if (crosseyedness) {
1899 glColor4f(1, 1, 1, .5);
1902 glTranslatef(.015 * crosseyedness, 0, 0);
1906 glVertex3f(-1, -1, 0.0f);
1907 glTexCoord2f(texcoordwidth, 0);
1908 glVertex3f(1, -1, 0.0f);
1909 glTexCoord2f(texcoordwidth, texcoordheight);
1910 glVertex3f(1, 1, 0.0f);
1911 glTexCoord2f(0, texcoordheight);
1912 glVertex3f(-1, 1, 0.0f);
1917 if (drawmode == glowmode) {
1918 glColor4f(.5, .5, .5, .5);
1920 glBlendFunc(GL_SRC_ALPHA, GL_ONE);
1922 glTranslatef(.01, 0, 0);
1925 glVertex3f(-1, -1, 0.0f);
1926 glTexCoord2f(texcoordwidth, 0);
1927 glVertex3f(1, -1, 0.0f);
1928 glTexCoord2f(texcoordwidth, texcoordheight);
1929 glVertex3f(1, 1, 0.0f);
1930 glTexCoord2f(0, texcoordheight);
1931 glVertex3f(-1, 1, 0.0f);
1935 glTranslatef(-.01, 0, 0);
1938 glVertex3f(-1, -1, 0.0f);
1939 glTexCoord2f(texcoordwidth, 0);
1940 glVertex3f(1, -1, 0.0f);
1941 glTexCoord2f(texcoordwidth, texcoordheight);
1942 glVertex3f(1, 1, 0.0f);
1943 glTexCoord2f(0, texcoordheight);
1944 glVertex3f(-1, 1, 0.0f);
1948 glTranslatef(.0, .01, 0);
1951 glVertex3f(-1, -1, 0.0f);
1952 glTexCoord2f(texcoordwidth, 0);
1953 glVertex3f(1, -1, 0.0f);
1954 glTexCoord2f(texcoordwidth, texcoordheight);
1955 glVertex3f(1, 1, 0.0f);
1956 glTexCoord2f(0, texcoordheight);
1957 glVertex3f(-1, 1, 0.0f);
1961 glTranslatef(0, -.01, 0);
1964 glVertex3f(-1, -1, 0.0f);
1965 glTexCoord2f(texcoordwidth, 0);
1966 glVertex3f(1, -1, 0.0f);
1967 glTexCoord2f(texcoordwidth, texcoordheight);
1968 glVertex3f(1, 1, 0.0f);
1969 glTexCoord2f(0, texcoordheight);
1970 glVertex3f(-1, 1, 0.0f);
1974 if (drawmode == radialzoommode) {
1975 for (int i = 0; i < 3; i++) {
1976 glColor4f(1, 1, 1, 1 / ((float)i + 1));
1978 glScalef(1 + (float)i * .01, 1 + (float)i * .01, 1);
1981 glVertex3f(-1, -1, 0.0f);
1982 glTexCoord2f(texcoordwidth, 0);
1983 glVertex3f(1, -1, 0.0f);
1984 glTexCoord2f(texcoordwidth, texcoordheight);
1985 glVertex3f(1, 1, 0.0f);
1986 glTexCoord2f(0, texcoordheight);
1987 glVertex3f(-1, 1, 0.0f);
1992 glDisable(GL_TEXTURE_2D);
1993 glMatrixMode(GL_PROJECTION);
1995 glMatrixMode(GL_MODELVIEW);
1997 glEnable(GL_DEPTH_TEST);
1998 glEnable(GL_CULL_FACE);
1999 glDisable(GL_BLEND);
2004 glEnable(GL_TEXTURE_2D);
2005 glColor4f(1, 1, 1, 1);
2007 if (consoleselected >= 60)
2008 offset = consoleselected - 60;
2009 sprintf (string, " ]");
2010 text->glPrint(10, 30, string, 0, 1, 1024, 768);
2012 sprintf (string, "_");
2013 text->glPrint(30 + (float)(consoleselected) * 10 - offset * 10, 30, string, 0, 1, 1024, 768);
2015 for (unsigned i = 0; i < 15; i++)
2016 for (unsigned j = 0; j < consoletext[i].size(); j++) {
2017 glColor4f(1, 1, 1, 1 - (float)(i) / 16);
2018 sprintf (string, "%c", consoletext[i][j]);
2019 text->glPrint(30 + j * 10 - offset * 10, 30 + i * 20, string, 0, 1, 1024, 768);
2024 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted)) {
2025 multiplier = tempmult;
2032 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted)) {
2033 tempmult = multiplier;
2037 if ( side == stereoRight || side == stereoCenter ) {
2038 if (drawmode != motionblurmode || mainmenu) {
2043 glDrawBuffer(GL_BACK);
2044 glReadBuffer(GL_BACK);
2048 if (drawtoggle == 2)
2051 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted)) {
2052 multiplier = tempmult;
2054 //Jordan fixed your warning!
2060 // !!! FIXME: hack: clamp framerate in menu so text input works correctly on fast systems.
2063 glDrawBuffer(GL_BACK);
2064 glReadBuffer(GL_BACK);
2065 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
2066 Game::ReSizeGLScene(90, .1f);
2068 //draw menu background
2069 glClear(GL_DEPTH_BUFFER_BIT);
2070 glEnable(GL_ALPHA_TEST);
2071 glAlphaFunc(GL_GREATER, 0.001f);
2072 glEnable(GL_TEXTURE_2D);
2073 glDisable(GL_DEPTH_TEST);
2074 glDisable(GL_CULL_FACE);
2075 glDisable(GL_LIGHTING);
2077 glMatrixMode(GL_PROJECTION);
2080 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
2081 glMatrixMode(GL_MODELVIEW);
2084 glTranslatef(screenwidth / 2, screenheight / 2, 0);
2086 glScalef((float)screenwidth / 2, (float)screenheight / 2, 1);
2087 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
2088 glDisable(GL_BLEND);
2089 glColor4f(0, 0, 0, 1.0);
2090 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2091 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2092 glDisable(GL_TEXTURE_2D);
2094 glVertex3f(-1, -1, 0);
2095 glVertex3f(+1, -1, 0);
2096 glVertex3f(+1, +1, 0);
2097 glVertex3f(-1, +1, 0);
2100 glColor4f(0.4, 0.4, 0.4, 1.0);
2101 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2102 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2103 glEnable(GL_TEXTURE_2D);
2104 Game::Mainmenuitems[4].bind();
2107 glVertex3f(-1, -1, 0);
2109 glVertex3f(+1, -1, 0);
2111 glVertex3f(+1, +1, 0);
2113 glVertex3f(-1, +1, 0);
2117 glMatrixMode(GL_PROJECTION);
2119 glMatrixMode(GL_MODELVIEW);
2123 glMatrixMode(GL_PROJECTION);
2126 glOrtho(0, 640, 0, 480, -100, 100);
2127 glMatrixMode(GL_MODELVIEW);
2130 glEnable(GL_TEXTURE_2D);
2135 glMatrixMode(GL_PROJECTION);
2137 glMatrixMode(GL_MODELVIEW);
2140 glMatrixMode(GL_PROJECTION);
2143 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
2144 glMatrixMode(GL_MODELVIEW);
2147 glTranslatef(screenwidth / 2, screenheight / 2, 0);
2149 glScalef((float)screenwidth / 2, (float)screenheight / 2, 1);
2150 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
2152 glEnable(GL_TEXTURE_2D);
2153 glColor4f(1, 1, 1, 1);
2154 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2155 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2157 if (!Game::waiting) { // hide the cursor while waiting for a key
2159 glTranslatef(Game::mousecoordh - screenwidth / 2, Game::mousecoordv * -1 + screenheight / 2, 0);
2160 glScalef((float)screenwidth / 64, (float)screenwidth / 64, 1);
2161 glTranslatef(1, -1, 0);
2162 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
2163 glColor4f(1, 1, 1, 1);
2164 Game::cursortexture.bind();
2168 glVertex3f(-1, -1, 0.0f);
2170 glVertex3f(1, -1, 0.0f);
2172 glVertex3f(1, 1, 0.0f);
2174 glVertex3f(-1, 1, 0.0f);
2180 glMatrixMode(GL_PROJECTION);
2185 if (flashamount > 0) {
2186 if (flashamount > 1)
2188 if (flashdelay <= 0)
2189 flashamount -= multiplier;
2191 if (flashamount < 0)
2193 glDisable(GL_DEPTH_TEST);
2194 glDisable(GL_CULL_FACE);
2195 glDisable(GL_LIGHTING);
2196 glDisable(GL_TEXTURE_2D);
2198 glMatrixMode(GL_PROJECTION);
2201 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
2202 glMatrixMode(GL_MODELVIEW);
2205 glScalef(screenwidth, screenheight, 1);
2206 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
2208 glColor4f(flashr, flashg, flashb, flashamount);
2210 glVertex3f(0, 0, 0.0f);
2211 glVertex3f(256, 0, 0.0f);
2212 glVertex3f(256, 256, 0.0f);
2213 glVertex3f(0, 256, 0.0f);
2215 glMatrixMode(GL_PROJECTION);
2217 glMatrixMode(GL_MODELVIEW);
2219 glEnable(GL_DEPTH_TEST);
2220 glEnable(GL_CULL_FACE);
2221 glDisable(GL_BLEND);