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
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; either version 2
9 of the License, or (at your option) any later version.
11 This program 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.
15 See the GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 #include "openal_wrapper.h"
29 extern int environment;
30 extern float texscale;
32 extern Terrain terrain;
33 //extern Sprites sprites;
34 extern float multiplier;
36 extern float viewdistance;
37 extern float fadestart;
38 extern float screenwidth, screenheight;
39 extern int kTextureSize;
40 extern FRUSTUM frustum;
42 extern Objects objects;
44 extern float usermousesensitivity;
46 extern float camerashake;
48 extern float slomodelay;
49 extern bool ismotionblur;
51 extern float blackout;
52 extern bool damageeffects;
54 extern bool texttoggle;
55 extern float blurness;
56 extern float targetblurness;
57 extern float playerdist;
58 extern bool cellophane;
60 extern float flashamount, flashr, flashg, flashb;
61 extern int flashdelay;
63 extern float motionbluramount;
65 extern bool alwaysblur;
67 extern bool tilt2weird;
68 extern bool tiltweird;
70 extern bool proportionweird;
71 extern bool vertexweird[6];
72 extern bool velocityblur;
73 extern bool debugmode;
75 extern int bloodtoggle;
76 extern int difficulty;
79 //extern int texdetail;
80 extern float texdetail;
81 extern bool musictoggle;
82 extern int tutoriallevel;
83 extern float smoketex;
84 extern float tutorialstagetime;
85 extern float tutorialmaxtime;
86 extern int tutorialstage;
87 extern bool againbonus;
88 extern float damagedealt;
89 extern bool invertmouse;
91 extern int numhotspots;
92 extern int killhotspot;
93 extern XYZ hotspot[40];
94 extern int hotspottype[40];
95 extern float hotspotsize[40];
96 extern char hotspottext[40][256];
97 extern int currenthotspot;;
100 extern bool winfreeze;
102 extern float menupulse;
104 extern bool gamestart;
106 extern bool gamestarted;
108 extern bool showdamagebar;
113 int numboundaries = 0;
120 normalmode, motionblurmode, radialzoommode,
121 realmotionblurmode, doublevisionmode, glowmode,
124 void Game::flash() // shouldn't be that way, these should be attributes and Person class should not change rendering.
135 /*********************> DrawGLScene() <*****/
136 int Game::DrawGLScene(StereoSide side)
138 static float texcoordwidth, texcoordheight;
139 static float texviewwidth, texviewheight;
140 static int i, j, k, l;
141 //~ static GLubyte color;
142 static XYZ checkpoint;
143 static float tempmult;
145 static char string[256] = "";
146 static char string2[256] = "";
147 static char string3[256] = "";
148 static int drawmode = 0;
150 if ( stereomode == stereoAnaglyph ) {
153 glColorMask( 0.0, 1.0, 1.0, 1.0 );
156 glColorMask( 1.0, 0.0, 0.0, 1.0 );
162 glColorMask( 1.0, 1.0, 1.0, 1.0 );
164 if ( stereomode == stereoHorizontalInterlaced || stereomode == stereoVerticalInterlaced ) {
165 glStencilFunc(side == stereoLeft ? GL_NOTEQUAL : GL_EQUAL, 0x01, 0x01);
169 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted)) {
170 tempmult = multiplier;
176 numboundaries = mapradius * 2;
177 if (numboundaries > 360)
179 for (i = 0; i < numboundaries; i++) {
182 boundary[i] = mapcenter + DoRotation(boundary[i] * mapradius, 0, i * (360 / ((float)(numboundaries))), 0);
191 int olddrawmode = drawmode;
192 if (ismotionblur && !loading) {
193 if ((findLengthfast(&Person::players[0]->velocity) > 200) && velocityblur && !cameramode) {
194 drawmode = motionblurmode;
195 motionbluramount = 200 / (findLengthfast(&Person::players[0]->velocity));
198 if (Person::players[0]->damage - Person::players[0]->superpermanentdamage > (Person::players[0]->damagetolerance - Person::players[0]->superpermanentdamage) * 1 / 2 && damageeffects && !cameramode) {
199 drawmode = doublevisionmode;
204 if (slomo && !loading) {
206 drawmode = motionblurmode;
207 motionbluramount = .2;
208 slomodelay -= multiplier;
214 if ((!changed && !slomo) || loading) {
215 drawmode = normalmode;
216 if (ismotionblur && (/*fps>100||*/alwaysblur)) {
217 if (olddrawmode != realmotionblurmode)
221 drawmode = realmotionblurmode;
222 } else if (olddrawmode == realmotionblurmode)
228 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted))
229 drawmode = normalmode;
230 if ((freeze || winfreeze) && ismotionblur && !mainmenu)
231 drawmode = radialzoommode;
233 if (winfreeze || mainmenu)
234 drawmode = normalmode;
237 if (drawmode == glowmode) {
242 DSpContext_FadeGamma(NULL, 200, &color2);
247 drawtoggle = 1 - drawtoggle;
249 if (!texcoordwidth) {
250 texviewwidth = kTextureSize;
251 if (texviewwidth > screenwidth)
252 texviewwidth = screenwidth;
253 texviewheight = kTextureSize;
254 if (texviewheight > screenheight)
255 texviewheight = screenheight;
257 texcoordwidth = screenwidth / kTextureSize;
258 texcoordheight = screenheight / kTextureSize;
259 if (texcoordwidth > 1)
261 if (texcoordheight > 1)
265 glDrawBuffer(GL_BACK);
266 glReadBuffer(GL_BACK);
269 static XYZ terrainlight;
270 static float distance;
271 if (drawmode == normalmode)
272 Game::ReSizeGLScene(90, .1f);
273 if (drawmode != normalmode)
274 glViewport(0, 0, texviewwidth, texviewheight);
275 glDepthFunc(GL_LEQUAL);
277 glAlphaFunc(GL_GREATER, 0.0001f);
278 glEnable(GL_ALPHA_TEST);
279 glClearColor(0.25f, 0.25f, 0.25f, 1.0f);
280 glClear(GL_DEPTH_BUFFER_BIT);
282 glMatrixMode (GL_MODELVIEW);
283 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
286 // Move the camera for the current eye's point of view.
287 // Reverse the movement if we're reversing stereo
288 glTranslatef((stereoseparation / 2) * side * (stereoreverse ? -1 : 1), 0, 0);
291 if (!cameramode && !freeze && !winfreeze) {
293 glRotatef(float(Random() % 100) / 10 * camerashake/*+(woozy*woozy)/10*/, 0, 0, 1);
295 glRotatef(pitch + sin(woozy / 2) * (Person::players[0]->damage / Person::players[0]->damagetolerance) * 5, 1, 0, 0);
296 glRotatef(yaw + sin(woozy) * (Person::players[0]->damage / Person::players[0]->damagetolerance) * 5, 0, 1, 0);
298 if (cameramode || freeze || winfreeze) {
299 glRotatef(pitch, 1, 0, 0);
300 glRotatef(yaw, 0, 1, 0);
303 if (environment == desertenvironment) {
304 glRotatef((float)(abs(Random() % 100)) / 3000 - 1, 1, 0, 0);
305 glRotatef((float)(abs(Random() % 100)) / 3000 - 1, 0, 1, 0);
307 SetUpLight(&light, 0);
310 //heat blur effect in desert
311 if (abs(blurness - targetblurness) < multiplier * 10 || abs(blurness - targetblurness) > 2) {
312 blurness = targetblurness;
313 targetblurness = (float)(abs(Random() % 100)) / 40;
315 if (blurness < targetblurness)
316 blurness += multiplier * 5;
318 blurness -= multiplier * 5;
320 if (environment == desertenvironment && detail == 2)
321 glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, blurness + .4 );
322 if (environment == desertenvironment) {
323 glRotatef((float)(abs(Random() % 100)) / 1000, 1, 0, 0);
324 glRotatef((float)(abs(Random() % 100)) / 1000, 0, 1, 0);
327 glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0);
329 glTranslatef(-viewer.x, -viewer.y, -viewer.z);
330 frustum.GetFrustum();
332 //make shadow decals on terrain and objects
334 static float size, opacity, rotation;
336 for (k = 0; k < Person::players.size(); k++) {
337 if (!Person::players[k]->skeleton.free && Person::players[k]->playerdetail && Person::players[k]->howactive < typesleeping)
338 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)
339 for (i = 0; i < Person::players[k]->skeleton.num_joints; i++) {
340 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) {
341 point = DoRotation(Person::players[k]->skeleton.joints[i].position, 0, Person::players[k]->yaw, 0) * Person::players[k]->scale + Person::players[k]->coords;
343 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;
344 if (k != 0 && tutoriallevel == 1) {
345 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;
347 terrain.MakeDecal(shadowdecal, point, size, opacity, rotation);
348 for (l = 0; l < terrain.patchobjectnum[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz]; l++) {
349 j = terrain.patchobjects[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz][l];
350 if (objects.position[j].y < Person::players[k]->coords.y || objects.type[j] == tunneltype || objects.type[j] == weirdtype) {
351 point = DoRotation(DoRotation(Person::players[k]->skeleton.joints[i].position, 0, Person::players[k]->yaw, 0) * Person::players[k]->scale + Person::players[k]->coords - objects.position[j], 0, -objects.yaw[j], 0);
354 if (k != 0 && tutoriallevel == 1) {
355 opacity = .2 + .2 * sin(smoketex * 6 + i);
357 objects.model[j].MakeDecal(shadowdecal, &point, &size, &opacity, &rotation);
362 if ((Person::players[k]->skeleton.free || Person::players[k]->howactive >= typesleeping) && Person::players[k]->playerdetail)
363 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)
364 for (i = 0; i < Person::players[k]->skeleton.num_joints; i++) {
365 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) {
366 if (Person::players[k]->skeleton.free)
367 point = Person::players[k]->skeleton.joints[i].position * Person::players[k]->scale + Person::players[k]->coords;
369 point = DoRotation(Person::players[k]->skeleton.joints[i].position, 0, Person::players[k]->yaw, 0) * Person::players[k]->scale + Person::players[k]->coords;
371 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;
372 if (k != 0 && tutoriallevel == 1) {
373 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;
375 terrain.MakeDecal(shadowdecal, point, size, opacity * .7, rotation);
376 for (l = 0; l < terrain.patchobjectnum[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz]; l++) {
377 j = terrain.patchobjects[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz][l];
378 if (objects.position[j].y < Person::players[k]->coords.y || objects.type[j] == tunneltype || objects.type[j] == weirdtype) {
379 if (Person::players[k]->skeleton.free)
380 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);
382 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);
385 if (k != 0 && tutoriallevel == 1) {
386 opacity = .2 + .2 * sin(smoketex * 6 + i);
388 objects.model[j].MakeDecal(shadowdecal, &point, &size, &opacity, &rotation);
394 if (!Person::players[k]->playerdetail)
395 if (frustum.SphereInFrustum(Person::players[k]->coords.x, Person::players[k]->coords.y, Person::players[k]->coords.z, Person::players[k]->scale * 5)) {
396 point = Person::players[k]->coords;
398 opacity = .4 - (Person::players[k]->coords.y - terrain.getHeight(Person::players[k]->coords.x, Person::players[k]->coords.z)) / 5;
399 terrain.MakeDecal(shadowdecal, point, size, opacity * .7, rotation);
400 for (l = 0; l < terrain.patchobjectnum[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz]; l++) {
401 j = terrain.patchobjects[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz][l];
402 point = DoRotation(Person::players[k]->coords - objects.position[j], 0, -objects.yaw[j], 0);
405 objects.model[j].MakeDecal(shadowdecal, &point, &size, &opacity, &rotation);
411 glEnable(GL_TEXTURE_2D);
413 glEnable(GL_DEPTH_TEST);
414 glEnable(GL_CULL_FACE);
416 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
417 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
418 terraintexture.bind();
420 terraintexture2.bind();
422 //glBindTexture( GL_TEXTURE_2D, terraintexture3);
423 //glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
426 terrain.drawdecals();
429 glEnable(GL_CULL_FACE);
430 glEnable(GL_LIGHTING);
432 glEnable(GL_TEXTURE_2D);
435 glEnable(GL_COLOR_MATERIAL);
450 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
451 glEnable(GL_CULL_FACE);
452 glCullFace(GL_FRONT);
454 for (k = 0; k < Person::players.size(); k++) {
455 if (k == 0 || tutoriallevel != 1) {
457 glEnable(GL_LIGHTING);
458 terrainlight = terrain.getLighting(Person::players[k]->coords.x, Person::players[k]->coords.z);
459 distance = distsq(&viewer, &Person::players[k]->coords);
460 distance = (viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance;
461 glColor4f(terrainlight.x, terrainlight.y, terrainlight.z, distance);
464 if (distance >= .5) {
465 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;
467 if (!Person::players[k]->occluded == 0)
468 i = checkcollide(viewer, checkpoint, Person::players[k]->lastoccluded);
469 if (i == -1 || Person::players[k]->occluded == 0)
470 i = checkcollide(viewer, checkpoint);
472 Person::players[k]->occluded += 1;
473 Person::players[k]->lastoccluded = i;
475 Person::players[k]->occluded = 0;
477 if (Person::players[k]->occluded < 25)
478 Person::players[k]->DrawSkeleton();
484 if (!cameramode && musictype == stream_fighttheme)
485 playerdist = distsqflat(&Person::players[0]->coords, &viewer);
490 glEnable(GL_TEXTURE_2D);
496 if (frustum.SphereInFrustum(realhawkcoords.x + hawk.boundingspherecenter.x, realhawkcoords.y + hawk.boundingspherecenter.y, realhawkcoords.z + hawk.boundingspherecenter.z, 2)) {
497 glAlphaFunc(GL_GREATER, 0.0001f);
499 glDisable(GL_CULL_FACE);
500 glDisable(GL_LIGHTING);
502 glTranslatef(hawkcoords.x, hawkcoords.y, hawkcoords.z);
503 glRotatef(hawkyaw, 0, 1, 0);
504 glTranslatef(25, 0, 0);
505 distance = distsq(&viewer, &realhawkcoords) * 1.2;
506 glColor4f(light.color[0], light.color[1], light.color[2], (viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance);
507 if ((viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance > 1)
508 glColor4f(light.color[0], light.color[1], light.color[2], 1);
509 if ((viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance > 0)
510 hawk.drawdifftex(hawktexture);
514 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
515 glEnable(GL_CULL_FACE);
516 glCullFace(GL_FRONT);
518 for (k = 0; k < Person::players.size(); k++) {
519 if (!(k == 0 || tutoriallevel != 1)) {
521 glEnable(GL_LIGHTING);
522 terrainlight = terrain.getLighting(Person::players[k]->coords.x, Person::players[k]->coords.z);
523 distance = distsq(&viewer, &Person::players[k]->coords);
524 distance = (viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance;
525 glColor4f(terrainlight.x, terrainlight.y, terrainlight.z, distance);
528 if (distance >= .5) {
529 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;
531 if (!Person::players[k]->occluded == 0)
532 i = checkcollide(viewer, checkpoint, Person::players[k]->lastoccluded);
533 if (i == -1 || Person::players[k]->occluded == 0)
534 i = checkcollide(viewer, checkpoint);
536 Person::players[k]->occluded += 1;
537 Person::players[k]->lastoccluded = i;
539 Person::players[k]->occluded = 0;
541 if (Person::players[k]->occluded < 25)
542 Person::players[k]->DrawSkeleton();
548 glEnable(GL_TEXTURE_2D);
553 glDisable(GL_COLOR_MATERIAL);
555 glDisable(GL_LIGHTING);
556 glDisable(GL_TEXTURE_2D);
562 //waypoints, pathpoints in editor
565 glDisable(GL_LIGHTING);
566 glDisable(GL_TEXTURE_2D);
567 glDisable(GL_COLOR_MATERIAL);
568 glColor4f(1, 1, 0, 1);
570 for (k = 0; k < Person::players.size(); k++) {
571 if (Person::players[k]->numwaypoints > 1) {
572 glBegin(GL_LINE_LOOP);
573 for (i = 0; i < Person::players[k]->numwaypoints; i++) {
574 glVertex3f(Person::players[k]->waypoints[i].x, Person::players[k]->waypoints[i].y + .5, Person::players[k]->waypoints[i].z);
581 if (numpathpoints > 1) {
582 glColor4f(0, 1, 0, 1);
583 for (k = 0; k < numpathpoints; k++) {
584 if (numpathpointconnect[k]) {
585 for (i = 0; i < numpathpointconnect[k]; i++) {
586 glBegin(GL_LINE_LOOP);
587 glVertex3f(pathpoint[k].x, pathpoint[k].y + .5, pathpoint[k].z);
588 glVertex3f(pathpoint[pathpointconnect[k][i]].x, pathpoint[pathpointconnect[k][i]].y + .5, pathpoint[pathpointconnect[k][i]].z);
593 glColor4f(1, 1, 1, 1);
596 glVertex3f(pathpoint[pathpointselected].x, pathpoint[pathpointselected].y + .5, pathpoint[pathpointselected].z);
603 glEnable(GL_TEXTURE_2D);
604 glColor4f(.5, .5, .5, 1);
606 sprintf (string, " ", (int)(fps));
607 text->glPrint(10, 30, string, 0, .8, screenwidth, screenheight);
610 if (bonus > 0 && bonustime < 1 && !winfreeze && indialogue == -1/*bonustime<4*/) {
611 const char *bonus_name;
612 if (bonus < bonus_count)
613 bonus_name = bonus_names[bonus];
615 bonus_name = "Excellent!"; // When does this happen?
617 glColor4f(0, 0, 0, 1 - bonustime);
618 text->glPrintOutline(1024 / 2 - 10 * strlen(bonus_name) - 4, 768 / 16 - 4 + 768 * 4 / 5, bonus_name, 1, 2.5, 1024, 768);
619 glColor4f(1, 0, 0, 1 - bonustime);
620 text->glPrint(1024 / 2 - 10 * strlen(bonus_name), 768 / 16 + 768 * 4 / 5, bonus_name, 1, 2, 1024, 768);
622 sprintf (string, "%d", (int)bonusvalue);
623 glColor4f(0, 0, 0, 1 - bonustime);
624 text->glPrintOutline(1024 / 2 - 10 * strlen(string) - 4, 768 / 16 - 4 - 20 + 768 * 4 / 5, string, 1, 2.5 * .8, 1024, 768);
625 glColor4f(1, 0, 0, 1 - bonustime);
626 text->glPrint(1024 / 2 - 10 * strlen(string), 768 / 16 - 20 + 768 * 4 / 5, string, 1, 2 * .8, 1024, 768);
627 glColor4f(.5, .5, .5, 1);
630 if (tutoriallevel == 1) {
631 tutorialopac = tutorialmaxtime - tutorialstagetime;
632 if (tutorialopac > 1)
634 if (tutorialopac < 0)
637 sprintf (string, " ");
638 sprintf (string2, " ");
639 sprintf (string3, " ");
640 if (tutorialstage == 0) {
641 sprintf (string, " ");
642 sprintf (string2, " ");
643 sprintf (string3, " ");
645 if (tutorialstage == 1) {
646 sprintf (string, "Welcome to the Lugaru training level!");
647 sprintf (string2, " ");
648 sprintf (string3, " ");
650 if (tutorialstage == 2) {
651 sprintf (string, "BASIC MOVEMENT:");
652 sprintf (string2, " ");
653 sprintf (string3, " ");
655 if (tutorialstage == 3) {
656 sprintf (string, "You can move the mouse to rotate the camera.");
657 sprintf (string2, " ");
658 sprintf (string3, " ");
660 if (tutorialstage == 4) {
661 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));
662 sprintf (string2, "All movement is relative to the camera.");
663 sprintf (string3, " ");
665 if (tutorialstage == 5) {
666 sprintf (string, "Please press %s to jump.", Input::keyToChar(jumpkey));
667 sprintf (string2, "You can hold it longer to jump higher.");
668 sprintf (string3, " ");
670 if (tutorialstage == 6) {
671 sprintf (string, "You can press %s to crouch.", Input::keyToChar(crouchkey));
672 sprintf (string2, "You can jump higher from a crouching position.");
673 sprintf (string3, " ");
675 if (tutorialstage == 7) {
676 sprintf (string, "While running, you can press %s to roll.", Input::keyToChar(crouchkey));
677 sprintf (string2, " ");
678 sprintf (string3, " ");
680 if (tutorialstage == 8) {
681 sprintf (string, "While crouching, you can sneak around silently");
682 sprintf (string2, "using the movement keys.");
683 sprintf (string3, " ");
685 if (tutorialstage == 9) {
686 sprintf (string, "Release the crouch key while sneaking and hold the movement keys");
687 sprintf (string2, "to run animal-style.");
688 sprintf (string3, " ");
690 if (tutorialstage == 10) {
691 sprintf (string, "ADVANCED MOVEMENT:");
692 sprintf (string2, " ");
693 sprintf (string3, " ");
695 if (tutorialstage == 11) {
696 sprintf (string, "When you jump at a wall, you can hold %s again", Input::keyToChar(jumpkey));
697 sprintf (string2, "during impact to perform a walljump.");
698 sprintf (string3, "Be sure to use the movement keys to press against the wall");
700 if (tutorialstage == 12) {
701 sprintf (string, "While in the air, you can press crouch to flip.");
702 sprintf (string2, "Walljumps and flips confuse enemies and give you more control.");
703 sprintf (string3, " ");
705 if (tutorialstage == 13) {
706 sprintf (string, "BASIC COMBAT:");
707 sprintf (string2, " ");
708 sprintf (string3, " ");
710 if (tutorialstage == 14) {
711 sprintf (string, "There is now an imaginary enemy");
712 sprintf (string2, "in the middle of the training area.");
713 sprintf (string3, " ");
715 if (tutorialstage == 15) {
716 if (attackkey == MOUSEBUTTON1)
717 sprintf (string, "Click to attack when you are near an enemy.");
719 sprintf (string, "Press %s to attack when you are near an enemy.", Input::keyToChar(attackkey));
720 sprintf (string2, "You can punch by standing still near an enemy and attacking.");
721 sprintf (string3, " ");
723 if (tutorialstage == 16) {
724 sprintf (string, "If you are close, you will perform a weak punch.");
725 sprintf (string2, "The weak punch is excellent for starting attack combinations.");
726 sprintf (string3, " ");
728 if (tutorialstage == 17) {
729 sprintf (string, "Attacking while running results in a spin kick.");
730 sprintf (string2, "This is one of your most powerful ground attacks.");
731 sprintf (string3, " ");
733 if (tutorialstage == 18) {
734 sprintf (string, "Sweep the enemy's legs out by attacking while crouched.");
735 sprintf (string2, "This is a very fast attack, and easy to follow up.");
736 sprintf (string3, " ");
738 if (tutorialstage == 19) {
739 sprintf (string, "When an enemy is on the ground, you can deal some extra");
740 sprintf (string2, "damage by running up and drop-kicking him.");
741 sprintf (string3, "(Try knocking them down with a sweep first)");
743 if (tutorialstage == 20) {
744 sprintf (string, "Your most powerful individual attack is the rabbit kick.");
745 if (attackkey == MOUSEBUTTON1)
746 sprintf (string2, "Run at the enemy while holding the mouse button, and press");
748 sprintf (string2, "Run at the enemy while holding %s, and press", Input::keyToChar(attackkey));
749 sprintf (string3, "the jump key (%s) to attack.", Input::keyToChar(jumpkey));
751 if (tutorialstage == 21) {
752 sprintf (string, "This attack is devastating if timed correctly.");
753 sprintf (string2, "Even if timed incorrectly, it will knock the enemy over.");
755 sprintf (string3, "Try rabbit-kicking the imaginary enemy again.");
757 sprintf (string3, "Try rabbit-kicking the imaginary enemy.");
759 if (tutorialstage == 22) {
760 sprintf (string, "If you sneak behind an enemy unnoticed, you can kill");
761 sprintf (string2, "him instantly. Move close behind this enemy");
762 sprintf (string3, "and attack.");
764 if (tutorialstage == 23) {
765 sprintf (string, "Another important attack is the wall kick. When an enemy");
766 sprintf (string2, "is near a wall, perform a walljump nearby and hold");
767 sprintf (string3, "the attack key during impact with the wall.");
769 if (tutorialstage == 24) {
770 sprintf (string, "You can tackle enemies by running at them animal-style");
771 if (attackkey == MOUSEBUTTON1)
772 sprintf (string2, "and pressing jump (%s) or attack(mouse button).", Input::keyToChar(jumpkey));
774 sprintf (string2, "and pressing jump (%s) or attack(%s).", Input::keyToChar(jumpkey), Input::keyToChar(attackkey));
775 sprintf (string3, "This is especially useful when they are running away.");
777 if (tutorialstage == 25) {
778 sprintf (string, "Dodge by pressing back and attack. Dodging is essential");
779 sprintf (string2, "against enemies with swords or other long weapons.");
780 sprintf (string3, " ");
782 if (tutorialstage == 26) {
783 sprintf (string, "REVERSALS AND COUNTER-REVERSALS");
784 sprintf (string2, " ");
785 sprintf (string3, " ");
787 if (tutorialstage == 27) {
788 sprintf (string, "The enemy can now reverse your attacks.");
789 sprintf (string2, " ");
790 sprintf (string3, " ");
792 if (tutorialstage == 28) {
793 sprintf (string, "If you attack, you will notice that the enemy now sometimes");
794 sprintf (string2, "catches your attack and uses it against you. Hold");
795 sprintf (string3, "crouch (%s) after attacking to escape from reversals.", Input::keyToChar(crouchkey));
797 if (tutorialstage == 29) {
798 sprintf (string, "Try escaping from two more reversals in a row.");
799 sprintf (string2, " ");
800 sprintf (string3, " ");
802 if (tutorialstage == 30) {
803 sprintf (string, "Good!");
804 sprintf (string2, " ");
805 sprintf (string3, " ");
807 if (tutorialstage == 31) {
808 sprintf (string, "To reverse an attack, you must tap crouch (%s) during the", Input::keyToChar(crouchkey));
809 sprintf (string2, "enemy's attack. You must also be close to the enemy;");
810 sprintf (string3, "this is especially important against armed opponents.");
812 if (tutorialstage == 32) {
813 sprintf (string, "The enemy can attack in %d seconds.", (int)(tutorialmaxtime - tutorialstagetime));
814 sprintf (string2, "This imaginary opponents attacks will be highlighted");
815 sprintf (string3, "to make this easier.");
817 if (tutorialstage == 33) {
818 sprintf (string, "Reverse three enemy attacks!");
819 sprintf (string2, " ");
820 sprintf (string3, " ");
822 if (tutorialstage == 34) {
823 sprintf (string, "Reverse two more enemy attacks!");
824 sprintf (string2, " ");
825 sprintf (string3, " ");
827 if (tutorialstage == 35) {
828 sprintf (string, "Reverse one more enemy attack!");
829 sprintf (string2, " ");
830 sprintf (string3, " ");
832 if (tutorialstage == 36) {
833 sprintf (string, "Excellent!");
834 sprintf (string2, " ");
835 sprintf (string3, " ");
837 if (tutorialstage == 37) {
838 sprintf (string, "Now spar with the enemy for %d more seconds.", (int)(tutorialmaxtime - tutorialstagetime));
839 sprintf (string2, "Damage dealt: %d", (int)damagedealt);
840 sprintf (string3, "Damage taken: %d.", (int)damagetaken);
842 if (tutorialstage == 38) {
843 sprintf (string, "WEAPONS:");
844 sprintf (string2, " ");
845 sprintf (string3, " ");
847 if (tutorialstage == 39) {
848 sprintf (string, "There is now an imaginary knife");
849 sprintf (string2, "in the center of the training area.");
850 sprintf (string3, " ");
852 if (tutorialstage == 40) {
853 sprintf (string, "Stand, roll or handspring over the knife");
854 sprintf (string2, "while pressing %s to pick it up.", Input::keyToChar(throwkey));
855 sprintf (string3, "You can crouch and press the same key to drop it again.");
857 if (tutorialstage == 41) {
858 sprintf (string, "You can equip and unequip weapons using the %s key.", Input::keyToChar(drawkey));
859 sprintf (string2, "Sometimes it is best to keep them unequipped to");
860 sprintf (string3, "prevent enemies from taking them. ");
862 if (tutorialstage == 42) {
863 sprintf (string, "The knife is the smallest weapon and the least encumbering.");
864 sprintf (string2, "You can equip or unequip it while standing, crouching,");
865 sprintf (string3, "running or flipping.");
867 if (tutorialstage == 43) {
868 sprintf (string, "You perform weapon attacks the same way as unarmed attacks,");
869 sprintf (string2, "but sharp weapons cause permanent damage, instead of the");
870 sprintf (string3, "temporary trauma from blunt weapons, fists and feet.");
872 if (tutorialstage == 44) {
873 sprintf (string, "The enemy now has your knife!");
874 sprintf (string2, "Please reverse two of his knife attacks.");
875 sprintf (string3, " ");
877 if (tutorialstage == 45) {
878 sprintf (string, "Please reverse one more of his knife attacks.");
879 sprintf (string2, " ");
880 sprintf (string3, " ");
882 if (tutorialstage == 46) {
883 sprintf (string, "Now he has a sword!");
884 sprintf (string2, "The sword has longer reach than your arms, so you");
885 sprintf (string3, "must move close to reverse the sword slash.");
887 if (tutorialstage == 47) {
888 sprintf (string, "Long weapons like the sword and staff are also useful for defense;");
889 sprintf (string2, "you can parry enemy weapon attacks by pressing the attack key");
890 sprintf (string3, "at the right time. Please try parrying the enemy's attacks!");
892 if (tutorialstage == 48) {
893 sprintf (string, "The staff is like the sword, but has two main attacks.");
894 sprintf (string2, "The standing smash is fast and effective, and the running");
895 sprintf (string3, "spin smash is slower and more powerful.");
897 if (tutorialstage == 49) {
898 sprintf (string, "When facing an enemy, you can throw the knife with %s.", Input::keyToChar(throwkey));
899 sprintf (string2, "It is possible to throw the knife while flipping,");
900 sprintf (string3, "but it is very inaccurate.");
902 if (tutorialstage == 50) {
903 sprintf (string, "You now know everything you can learn from training.");
904 sprintf (string2, "Everything else you must learn from experience!");
905 sprintf (string3, " ");
907 if (tutorialstage == 51) {
908 sprintf (string, "Walk out of the training area to return to the main menu.");
909 sprintf (string2, " ");
910 sprintf (string3, " ");
913 glColor4f(0, 0, 0, tutorialopac);
914 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);
915 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);
916 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);
917 glColor4f(1, 1, 1, tutorialopac);
918 text->glPrint(screenwidth / 2 - 7.6 * strlen(string)*screenwidth / 1024, screenheight / 16 + screenheight * 4 / 5, string, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight);
919 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);
920 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);
922 sprintf (string, "Press 'tab' to skip to the next item.");
923 sprintf (string2, "Press escape at any time to");
924 sprintf (string3, "pause or exit the tutorial.");
926 glColor4f(0, 0, 0, 1);
927 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);
928 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);
929 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);
930 glColor4f(0.5, 0.5, 0.5, 1);
931 text->glPrint(screenwidth / 2 - 7.6 * strlen(string)*screenwidth / 1024 * .8, 0 + screenheight * 1 / 10, string, 1, 1.5 * screenwidth / 1024 * .8, screenwidth, screenheight);
932 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);
933 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);
937 if (numhotspots && (bonustime >= 1 || bonus <= 0 || bonustime < 0) && !tutoriallevel) {
939 float closestdist = -1;
941 closest = currenthotspot;
942 for (i = 0; i < numhotspots; i++) {
943 distance = distsq(&Person::players[0]->coords, &hotspot[i]);
944 if (closestdist == -1 || distance < closestdist) {
945 if (distsq(&Person::players[0]->coords, &hotspot[i]) < hotspotsize[i] && ((hotspottype[i] <= 10 && hotspottype[i] >= 0) || (hotspottype[i] <= 40 && hotspottype[i] >= 20))) {
946 closestdist = distance;
952 currenthotspot = closest;
953 if (currenthotspot != -1) {
954 if (hotspottype[closest] <= 10) {
955 if (distsq(&Person::players[0]->coords, &hotspot[closest]) < hotspotsize[closest])
956 tutorialstagetime = 0;
958 tutorialopac = tutorialmaxtime - tutorialstagetime;
959 if (tutorialopac > 1)
961 if (tutorialopac < 0)
964 sprintf (string, "%s", hotspottext[closest]);
971 if (string[i] == '\n' || string[i] > 'z' || string[i] < ' ' || string[i] == '\0') {
972 glColor4f(0, 0, 0, tutorialopac);
973 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);
974 glColor4f(1, 1, 1, tutorialopac);
975 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);
978 if (string[i] == '\0')
985 } else if (hotspottype[closest] >= 20 && dialoguegonethrough[hotspottype[closest] - 20] == 0) {
986 whichdialogue = hotspottype[closest] - 20;
987 for (j = 0; j < numdialogueboxes[whichdialogue]; j++) {
988 Person::players[participantfocus[whichdialogue][j]]->coords = participantlocation[whichdialogue][participantfocus[whichdialogue][j]];
989 Person::players[participantfocus[whichdialogue][j]]->yaw = participantyaw[whichdialogue][participantfocus[whichdialogue][j]];
990 Person::players[participantfocus[whichdialogue][j]]->targetyaw = participantyaw[whichdialogue][participantfocus[whichdialogue][j]];
991 Person::players[participantfocus[whichdialogue][j]]->velocity = 0;
992 Person::players[participantfocus[whichdialogue][j]]->animTarget = Person::players[participantfocus[whichdialogue][j]]->getIdle();
993 Person::players[participantfocus[whichdialogue][j]]->frameTarget = 0;
997 dialoguegonethrough[whichdialogue]++;
998 if (dialogueboxsound[whichdialogue][indialogue] != 0) {
1000 if (dialogueboxsound[whichdialogue][indialogue] == 1) whichsoundplay = rabbitchitter;
1001 if (dialogueboxsound[whichdialogue][indialogue] == 2) whichsoundplay = rabbitchitter2;
1002 if (dialogueboxsound[whichdialogue][indialogue] == 3) whichsoundplay = rabbitpainsound;
1003 if (dialogueboxsound[whichdialogue][indialogue] == 4) whichsoundplay = rabbitpain1sound;
1004 if (dialogueboxsound[whichdialogue][indialogue] == 5) whichsoundplay = rabbitattacksound;
1005 if (dialogueboxsound[whichdialogue][indialogue] == 6) whichsoundplay = rabbitattack2sound;
1006 if (dialogueboxsound[whichdialogue][indialogue] == 7) whichsoundplay = rabbitattack3sound;
1007 if (dialogueboxsound[whichdialogue][indialogue] == 8) whichsoundplay = rabbitattack4sound;
1008 if (dialogueboxsound[whichdialogue][indialogue] == 9) whichsoundplay = growlsound;
1009 if (dialogueboxsound[whichdialogue][indialogue] == 10) whichsoundplay = growl2sound;
1010 if (dialogueboxsound[whichdialogue][indialogue] == 11) whichsoundplay = snarlsound;
1011 if (dialogueboxsound[whichdialogue][indialogue] == 12) whichsoundplay = snarl2sound;
1012 if (dialogueboxsound[whichdialogue][indialogue] == 13) whichsoundplay = barksound;
1013 if (dialogueboxsound[whichdialogue][indialogue] == 14) whichsoundplay = bark2sound;
1014 if (dialogueboxsound[whichdialogue][indialogue] == 15) whichsoundplay = bark3sound;
1015 if (dialogueboxsound[whichdialogue][indialogue] == 16) whichsoundplay = barkgrowlsound;
1016 if (dialogueboxsound[whichdialogue][indialogue] == -1) whichsoundplay = fireendsound;
1017 if (dialogueboxsound[whichdialogue][indialogue] == -2) whichsoundplay = firestartsound;
1018 if (dialogueboxsound[whichdialogue][indialogue] == -3) whichsoundplay = consolesuccesssound;
1019 if (dialogueboxsound[whichdialogue][indialogue] == -4) whichsoundplay = consolefailsound;
1020 emit_sound_at(whichsoundplay, Person::players[participantfocus[whichdialogue][indialogue]]->coords);
1026 if (indialogue != -1 && !mainmenu) {
1027 glDisable(GL_DEPTH_TEST);
1028 glDisable(GL_CULL_FACE);
1029 glDisable(GL_LIGHTING);
1030 glDisable(GL_TEXTURE_2D);
1032 glMatrixMode(GL_PROJECTION);
1035 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1036 glMatrixMode(GL_MODELVIEW);
1039 if (dialogueboxlocation[whichdialogue][indialogue] == 1)
1040 glTranslatef(0, screenheight * 3 / 4, 0);
1041 glScalef(screenwidth, screenheight / 4, 1);
1042 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1045 glColor4f(dialogueboxcolor[whichdialogue][indialogue][0], dialogueboxcolor[whichdialogue][indialogue][1], dialogueboxcolor[whichdialogue][indialogue][2], 0.7);
1047 glVertex3f(0, 0, 0.0f);
1048 glVertex3f(1, 0, 0.0f);
1049 glVertex3f(1, 1, 0.0f);
1050 glVertex3f(0, 1, 0.0f);
1052 glMatrixMode(GL_PROJECTION);
1054 glMatrixMode(GL_MODELVIEW);
1056 glEnable(GL_DEPTH_TEST);
1057 glEnable(GL_CULL_FACE);
1058 glDisable(GL_BLEND);
1060 glEnable(GL_TEXTURE_2D);
1067 startx = screenwidth * 1 / 5;
1068 if (dialogueboxlocation[whichdialogue][indialogue] == 1)
1069 starty = screenheight / 16 + screenheight * 4 / 5;
1070 if (dialogueboxlocation[whichdialogue][indialogue] == 2)
1071 starty = screenheight * 1 / 5 - screenheight / 16;
1076 for (i = 0; i < 264; i++) {
1080 for (i = 0; i < (int)strlen(dialoguename[whichdialogue][indialogue]); i++) {
1081 tempname[tempnum] = dialoguename[whichdialogue][indialogue][i];
1083 if (dialoguename[whichdialogue][indialogue][i] == '#' || dialoguename[whichdialogue][indialogue][i] == '\0')
1088 tempname[tempnum] = '\0';
1091 sprintf (string, "%s: ", tempname);
1093 if (dialogueboxcolor[whichdialogue][indialogue][0] + dialogueboxcolor[whichdialogue][indialogue][1] + dialogueboxcolor[whichdialogue][indialogue][2] < 1.5) {
1094 glColor4f(0, 0, 0, tutorialopac);
1095 text->glPrintOutline(startx - 2 * 7.6 * strlen(string)*screenwidth / 1024 - 4, starty - 4, string, 1, 1.5 * 1.25 * screenwidth / 1024, screenwidth, screenheight);
1096 glColor4f(0.7, 0.7, 0.7, tutorialopac);
1097 text->glPrint(startx - 2 * 7.6 * strlen(string)*screenwidth / 1024, starty, string, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight);
1099 glColor4f(0, 0, 0, tutorialopac);
1100 text->glPrintOutline(startx - 2 * 7.6 * strlen(string)*screenwidth / 1024 - 4, starty - 4, string, 1, 1.5 * 1.25 * screenwidth / 1024, screenwidth, screenheight);
1104 for (i = 0; i < (int)strlen(dialoguetext[whichdialogue][indialogue]) + 1; i++) {
1105 tempname[tempnum] = dialoguetext[whichdialogue][indialogue][i];
1106 if (dialoguetext[whichdialogue][indialogue][i] != '#')
1110 sprintf (string, "%s", tempname);
1117 if (string[i] == '\n' || string[i] > 'z' || string[i] < ' ' || string[i] == '\0') {
1118 if (dialogueboxcolor[whichdialogue][indialogue][0] + dialogueboxcolor[whichdialogue][indialogue][1] + dialogueboxcolor[whichdialogue][indialogue][2] < 1.5) {
1119 glColor4f(0, 0, 0, tutorialopac);
1120 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);
1121 glColor4f(1, 1, 1, tutorialopac);
1122 text->glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/, starty - 20 * screenwidth / 1024 * line, string, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight, lastline, i);
1124 glColor4f(0, 0, 0, tutorialopac);
1125 text->glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/, starty - 20 * screenwidth / 1024 * line, string, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight, lastline, i);
1129 if (string[i] == '\0')
1138 if (!tutoriallevel && !winfreeze && indialogue == -1 && !mainmenu) {
1141 sprintf (string, "Score: %d", (int)accountactive->getCampaignScore());
1143 sprintf (string, "Score: %d", (int)accountactive->getCampaignScore() + (int)bonustotal);
1146 sprintf (string, "Score: %d", (int)bonustotal);
1147 glColor4f(0, 0, 0, 1);
1148 text->glPrintOutline(1024 / 40 - 4, 768 / 16 - 4 + 768 * 14 / 16, string, 1, 1.5 * 1.25, 1024, 768);
1149 glColor4f(1, 0, 0, 1);
1150 text->glPrint(1024 / 40, 768 / 16 + 768 * 14 / 16, string, 1, 1.5, 1024, 768);
1151 if (showdamagebar) {
1152 glDisable(GL_DEPTH_TEST);
1153 glDisable(GL_CULL_FACE);
1154 glDisable(GL_LIGHTING);
1155 glDisable(GL_TEXTURE_2D);
1157 glMatrixMode(GL_PROJECTION);
1160 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1161 glMatrixMode(GL_MODELVIEW);
1164 glTranslatef(15, screenheight * 17.5 / 20, 0);
1165 glScalef(screenwidth / 3 + 20, screenheight / 20, 1);
1166 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1168 glColor4f(0.0, 0.4, 0.0, 0.7);
1169 float bar = ((float)Person::players[0]->damage) / Person::players[0]->damagetolerance;
1171 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
1172 glVertex3f(1, 0, 0.0f);
1173 glVertex3f(1, 1, 0.0f);
1174 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
1176 glColor4f(0.1, 0.0, 0.0, 1);
1177 bar = ((float)Person::players[0]->bloodloss) / Person::players[0]->damagetolerance;
1179 glVertex3f(0, 0, 0.0f);
1180 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
1181 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
1182 glVertex3f(0, 1, 0.0f);
1184 glColor4f(0.4, 0.0, 0.0, 0.7);
1185 bar = ((float)Person::players[0]->damage) / Person::players[0]->damagetolerance;
1187 glVertex3f(0, 0, 0.0f);
1188 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
1189 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
1190 glVertex3f(0, 1, 0.0f);
1192 glColor4f(0.4, 0.0, 0.0, 0.7);
1193 bar = ((float)Person::players[0]->permanentdamage) / Person::players[0]->damagetolerance;
1195 glVertex3f(0, 0, 0.0f);
1196 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
1197 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
1198 glVertex3f(0, 1, 0.0f);
1200 glColor4f(0.4, 0.0, 0.0, 0.7);
1201 bar = ((float)Person::players[0]->superpermanentdamage) / Person::players[0]->damagetolerance;
1203 glVertex3f(0, 0, 0.0f);
1204 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
1205 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
1206 glVertex3f(0, 1, 0.0f);
1208 glColor4f(0.0, 0.0, 0.0, 0.7);
1210 glBegin(GL_LINE_STRIP);
1211 glVertex3f(0, 0, 0.0f);
1212 glVertex3f(1, 0, 0.0f);
1213 glVertex3f(1, 1, 0.0f);
1214 glVertex3f(0, 1, 0.0f);
1215 glVertex3f(0, 0, 0.0f);
1218 glMatrixMode(GL_PROJECTION);
1220 glMatrixMode(GL_MODELVIEW);
1222 glEnable(GL_DEPTH_TEST);
1223 glEnable(GL_CULL_FACE);
1224 glDisable(GL_BLEND);
1226 glEnable(GL_TEXTURE_2D);
1228 // writing the numbers :
1229 sprintf (string, "Damages : %d/%d (%d)", (int)(Person::players[0]->damage), (int)(Person::players[0]->damagetolerance), (int)(Person::players[0]->bloodloss));
1230 glColor4f(0, 0, 0, 1);
1231 text->glPrintOutline(1024 / 40 - 4, 768 / 16 - 4 + 768 * 14 / 16 - 40, string, 1, 1.5 * 1.25, 1024, 768);
1232 glColor4f(1, 0, 0, 1);
1233 text->glPrint(1024 / 40, 768 / 16 + 768 * 14 / 16 - 40, string, 1, 1.5, 1024, 768);
1237 glColor4f(.5, .5, .5, 1);
1240 if ((texttoggle || editorenabled) && debugmode && !mainmenu) {
1241 sprintf (string, "The framespersecond is %d.", (int)(fps));
1242 text->glPrint(10, 30, string, 0, .8, 1024, 768);
1245 sprintf (string, "Map editor enabled.");
1247 sprintf (string, "Map editor disabled.");
1248 text->glPrint(10, 60, string, 0, .8, 1024, 768);
1249 if (editorenabled) {
1250 sprintf (string, "Object size: %f", editorsize);
1251 text->glPrint(10, 75, string, 0, .8, 1024, 768);
1253 sprintf (string, "Object yaw: %f", editoryaw);
1255 sprintf (string, "Object yaw: Random");
1256 text->glPrint(10, 90, string, 0, .8, 1024, 768);
1257 if (editorpitch >= 0)
1258 sprintf (string, "Object pitch: %f", editorpitch);
1260 sprintf (string, "Object pitch: Random");
1261 text->glPrint(10, 105, string, 0, .8, 1024, 768);
1262 sprintf (string, "Object type: %d", editortype);
1263 text->glPrint(10, 120, string, 0, .8, 1024, 768);
1264 switch (editortype) {
1266 sprintf (string, "(box)");
1269 sprintf (string, "(tree)");
1272 sprintf (string, "(wall)");
1275 sprintf (string, "(weird)");
1278 sprintf (string, "(spike)");
1281 sprintf (string, "(rock)");
1284 sprintf (string, "(bush)");
1287 sprintf (string, "(tunnel)");
1290 sprintf (string, "(chimney)");
1293 sprintf (string, "(platform)");
1296 sprintf (string, "(cool)");
1299 sprintf (string, "(fire)");
1302 text->glPrint(130, 120, string, 0, .8, 1024, 768);
1304 sprintf (string, "Numplayers: %d", Person::players.size());
1305 text->glPrint(10, 155, string, 0, .8, 1024, 768);
1306 sprintf (string, "Player %d: numwaypoints: %d", Person::players.size()-1, Person::players.back()->numwaypoints);
1307 text->glPrint(10, 140, string, 0, .8, 1024, 768);
1309 sprintf (string, "Difficulty: %d", difficulty);
1310 text->glPrint(10, 240, string, 0, .8, 1024, 768);
1315 if (drawmode == glowmode) {
1316 glDisable(GL_DEPTH_TEST);
1317 glDisable(GL_CULL_FACE);
1318 glDisable(GL_LIGHTING);
1319 glDisable(GL_TEXTURE_2D);
1321 glMatrixMode(GL_PROJECTION);
1324 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1325 glMatrixMode(GL_MODELVIEW);
1328 glScalef(screenwidth, screenheight, 1);
1329 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1331 glColor4f(0, 0, 0, .5);
1333 glVertex3f(0, 0, 0.0f);
1334 glVertex3f(256, 0, 0.0f);
1335 glVertex3f(256, 256, 0.0f);
1336 glVertex3f(0, 256, 0.0f);
1338 glMatrixMode(GL_PROJECTION);
1340 glMatrixMode(GL_MODELVIEW);
1342 glEnable(GL_DEPTH_TEST);
1343 glEnable(GL_CULL_FACE);
1344 glDisable(GL_BLEND);
1348 if ((((blackout && damageeffects) || (Person::players[0]->bloodloss > 0 && damageeffects && Person::players[0]->blooddimamount > 0) || Person::players[0]->dead) && !cameramode) || console) {
1349 glDisable(GL_DEPTH_TEST);
1350 glDisable(GL_CULL_FACE);
1351 glDisable(GL_LIGHTING);
1352 glDisable(GL_TEXTURE_2D);
1354 glMatrixMode(GL_PROJECTION);
1357 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1358 glMatrixMode(GL_MODELVIEW);
1361 glScalef(screenwidth, screenheight, 1);
1362 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1364 if (Person::players[0]->dead)
1365 blackout += multiplier * 3;
1366 if (Person::players[0]->dead == 1)
1368 if (Person::players[0]->dead == 2 && blackout > .6)
1370 glColor4f(0, 0, 0, blackout);
1371 if (!Person::players[0]->dead) {
1372 if ((Person::players[0]->bloodloss / Person::players[0]->damagetolerance * (sin(woozy) / 4 + .5))*.3 < .3) {
1373 glColor4f(0, 0, 0, Person::players[0]->blooddimamount * Person::players[0]->bloodloss / Person::players[0]->damagetolerance * (sin(woozy) / 4 + .5)*.3);
1374 blackout = Person::players[0]->blooddimamount * Person::players[0]->bloodloss / Person::players[0]->damagetolerance * (sin(woozy) / 4 + .5) * .3;
1376 glColor4f(0, 0, 0, Person::players[0]->blooddimamount * .3);
1377 blackout = Person::players[0]->blooddimamount * .3;
1381 glColor4f(.7, 0, 0, .2);
1383 glVertex3f(0, 0, 0.0f);
1384 glVertex3f(256, 0, 0.0f);
1385 glVertex3f(256, 256, 0.0f);
1386 glVertex3f(0, 256, 0.0f);
1388 glMatrixMode(GL_PROJECTION);
1390 glMatrixMode(GL_MODELVIEW);
1392 glEnable(GL_DEPTH_TEST);
1393 glEnable(GL_CULL_FACE);
1394 glDisable(GL_BLEND);
1398 if (flashamount > 0 && damageeffects) {
1399 if (flashamount > 1)
1401 if (flashdelay <= 0)
1402 flashamount -= multiplier;
1404 if (flashamount < 0)
1406 glDisable(GL_DEPTH_TEST);
1407 glDisable(GL_CULL_FACE);
1408 glDisable(GL_LIGHTING);
1410 glMatrixMode(GL_PROJECTION);
1413 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1414 glMatrixMode(GL_MODELVIEW);
1417 glScalef(screenwidth, screenheight, 1);
1418 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1420 glColor4f(flashr, flashg, flashb, flashamount);
1422 glVertex3f(0, 0, 0.0f);
1423 glVertex3f(256, 0, 0.0f);
1424 glVertex3f(256, 256, 0.0f);
1425 glVertex3f(0, 256, 0.0f);
1427 glMatrixMode(GL_PROJECTION);
1429 glMatrixMode(GL_MODELVIEW);
1431 glEnable(GL_DEPTH_TEST);
1432 glEnable(GL_CULL_FACE);
1433 glDisable(GL_BLEND);
1439 glEnable(GL_TEXTURE_2D);
1440 glColor4f(1, 1, 1, 1);
1441 for (i = 1; i < 15; i++)
1442 if (displaytime[i] < 4)
1443 for (j = 0; j < displaytext[i].size(); j++) {
1444 glColor4f(1, 1, 1, 4 - displaytime[i]);
1445 sprintf (string, "%c", displaytext[i][j]);
1446 text->glPrint(30 + j * 10, 30 + i * 20 + (screenheight - 330), string, 0, 1, screenwidth, screenheight);
1450 if (difficulty < 2 && indialogue == -1) { // minimap
1451 float mapviewdist = 20000;
1453 glDisable(GL_DEPTH_TEST);
1454 glColor3f (1.0, 1.0, 1.0); // no coloring
1456 glEnable(GL_TEXTURE_2D);
1457 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1458 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1459 glDisable(GL_DEPTH_TEST);
1460 glDisable(GL_CULL_FACE);
1461 glDisable(GL_LIGHTING);
1463 glMatrixMode(GL_PROJECTION);
1466 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1467 glMatrixMode(GL_MODELVIEW);
1470 glScalef((float)screenwidth / 2, (float)screenwidth / 2, 1);
1471 glTranslatef(1.75, .25, 0);
1472 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1474 glColor4f(1, 1, 1, 1);
1480 int numliveplayers = 0;
1482 for (i = 0; i < Person::players.size(); i++) {
1483 if (!Person::players[i]->dead)
1489 for (i = 0; i < objects.numobjects; i++) {
1490 if (objects.type[i] == treetrunktype || objects.type[i] == boxtype) {
1491 center += objects.position[i];
1495 for (i = 0; i < Person::players.size(); i++) {
1496 if (!Person::players[i]->dead)
1497 center += Person::players[i]->coords;
1499 center /= numadd + numliveplayers;
1501 center = Person::players[0]->coords;
1503 float maxdistance = 0;
1505 //~ int whichclosest;
1506 for (i = 0; i < objects.numobjects; i++) {
1507 tempdist = distsq(¢er, &objects.position[i]);
1508 if (tempdist > maxdistance) {
1510 maxdistance = tempdist;
1513 for (i = 0; i < Person::players.size(); i++) {
1514 if (!Person::players[i]->dead) {
1515 tempdist = distsq(¢er, &Person::players[i]->coords);
1516 if (tempdist > maxdistance) {
1518 maxdistance = tempdist;
1522 radius = fast_sqrt(maxdistance);
1526 glScalef(.25 / radius * 256 * terrain.scale * .4, .25 / radius * 256 * terrain.scale * .4, 1);
1528 glScalef(1 / (1 / radius * 256 * terrain.scale * .4), 1 / (1 / radius * 256 * terrain.scale * .4), 1);
1530 glRotatef(Person::players[0]->lookyaw * -1 + 180, 0, 0, 1);
1531 glTranslatef(-(center.x / terrain.scale / 256 * -2 + 1), (center.z / terrain.scale / 256 * -2 + 1), 0);
1532 for (i = 0; i < objects.numobjects; i++) {
1533 if (objects.type[i] == treetrunktype) {
1534 distcheck = distsq(&Person::players[0]->coords, &objects.position[i]);
1535 if (distcheck < mapviewdist) {
1536 Mapcircletexture.bind();
1537 glColor4f(0, .3, 0, opac * (1 - distcheck / mapviewdist));
1539 glTranslatef(objects.position[i].x / terrain.scale / 256 * -2 + 1, objects.position[i].z / terrain.scale / 256 * 2 - 1, 0);
1540 glRotatef(objects.yaw[i], 0, 0, 1);
1541 glScalef(.003, .003, .003);
1544 glVertex3f(-1, -1, 0.0f);
1546 glVertex3f(1, -1, 0.0f);
1548 glVertex3f(1, 1, 0.0f);
1550 glVertex3f(-1, 1, 0.0f);
1555 if (objects.type[i] == boxtype) {
1556 distcheck = distsq(&Person::players[0]->coords, &objects.position[i]);
1557 if (distcheck < mapviewdist) {
1558 Mapboxtexture.bind();
1559 glColor4f(.4, .4, .4, opac * (1 - distcheck / mapviewdist));
1561 glTranslatef(objects.position[i].x / terrain.scale / 256 * -2 + 1, objects.position[i].z / terrain.scale / 256 * 2 - 1, 0);
1562 glRotatef(objects.yaw[i], 0, 0, 1);
1563 glScalef(.01 * objects.scale[i], .01 * objects.scale[i], .01 * objects.scale[i]);
1566 glVertex3f(-1, -1, 0.0f);
1568 glVertex3f(1, -1, 0.0f);
1570 glVertex3f(1, 1, 0.0f);
1572 glVertex3f(-1, 1, 0.0f);
1578 if (editorenabled) {
1579 Mapcircletexture.bind();
1580 for (i = 0; i < numboundaries; i++) {
1581 glColor4f(0, 0, 0, opac / 3);
1583 glTranslatef(boundary[i].x / terrain.scale / 256 * -2 + 1, boundary[i].z / terrain.scale / 256 * 2 - 1, 0);
1584 glScalef(.002, .002, .002);
1587 glVertex3f(-1, -1, 0.0f);
1589 glVertex3f(1, -1, 0.0f);
1591 glVertex3f(1, 1, 0.0f);
1593 glVertex3f(-1, 1, 0.0f);
1598 for (i = 0; i < Person::players.size(); i++) {
1599 distcheck = distsq(&Person::players[0]->coords, &Person::players[i]->coords);
1600 if (distcheck < mapviewdist) {
1602 Maparrowtexture.bind();
1604 glColor4f(1, 1, 1, opac);
1605 else if (Person::players[i]->dead == 2 || Person::players[i]->howactive > typesleeping)
1606 glColor4f(0, 0, 0, opac * (1 - distcheck / mapviewdist));
1607 else if (Person::players[i]->dead)
1608 glColor4f(.3, .3, .3, opac * (1 - distcheck / mapviewdist));
1609 else if (Person::players[i]->aitype == attacktypecutoff)
1610 glColor4f(1, 0, 0, opac * (1 - distcheck / mapviewdist));
1611 else if (Person::players[i]->aitype == passivetype)
1612 glColor4f(0, 1, 0, opac * (1 - distcheck / mapviewdist));
1614 glColor4f(1, 1, 0, 1);
1615 glTranslatef(Person::players[i]->coords.x / terrain.scale / 256 * -2 + 1, Person::players[i]->coords.z / terrain.scale / 256 * 2 - 1, 0);
1616 glRotatef(Person::players[i]->yaw + 180, 0, 0, 1);
1617 glScalef(.005, .005, .005);
1620 glVertex3f(-1, -1, 0.0f);
1622 glVertex3f(1, -1, 0.0f);
1624 glVertex3f(1, 1, 0.0f);
1626 glVertex3f(-1, 1, 0.0f);
1632 glDisable(GL_TEXTURE_2D);
1633 glMatrixMode(GL_PROJECTION);
1635 glMatrixMode(GL_MODELVIEW);
1637 glEnable(GL_DEPTH_TEST);
1638 glEnable(GL_CULL_FACE);
1639 glDisable(GL_BLEND);
1643 if (loading && !stealthloading && (!campaign || Person::players[0]->dead)) {
1644 glDisable(GL_DEPTH_TEST);
1645 glDisable(GL_CULL_FACE);
1646 glDisable(GL_LIGHTING);
1647 glDisable(GL_TEXTURE_2D);
1649 glMatrixMode(GL_PROJECTION);
1652 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1653 glMatrixMode(GL_MODELVIEW);
1656 glScalef(screenwidth, screenheight, 1);
1657 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1659 glColor4f(0, 0, 0, .7);
1661 glVertex3f(0, 0, 0.0f);
1662 glVertex3f(256, 0, 0.0f);
1663 glVertex3f(256, 256, 0.0f);
1664 glVertex3f(0, 256, 0.0f);
1666 glMatrixMode(GL_PROJECTION);
1668 glMatrixMode(GL_MODELVIEW);
1670 glEnable(GL_DEPTH_TEST);
1671 glEnable(GL_CULL_FACE);
1672 glDisable(GL_BLEND);
1676 glDisable(GL_DEPTH_TEST);
1677 glColor3f (1.0, 1.0, 1.0); // no coloring
1679 glEnable(GL_TEXTURE_2D);
1684 glEnable(GL_TEXTURE_2D);
1685 glColor4f(1, 1, 1, 1);
1686 sprintf (string, "Loading...");
1687 text->glPrint(1024 / 2 - 90, 768 / 2, string, 1, 2, 1024, 768);
1690 //if(ismotionblur)drawmode=motionblurmode;
1691 drawmode = normalmode;
1694 if (winfreeze && !campaign) {
1695 glDisable(GL_DEPTH_TEST);
1696 glDisable(GL_CULL_FACE);
1697 glDisable(GL_LIGHTING);
1698 glDisable(GL_TEXTURE_2D);
1700 glMatrixMode(GL_PROJECTION);
1703 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1704 glMatrixMode(GL_MODELVIEW);
1707 glScalef(screenwidth, screenheight, 1);
1708 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1710 glColor4f(0, 0, 0, .4);
1712 glVertex3f(0, 0, 0.0f);
1713 glVertex3f(256, 0, 0.0f);
1714 glVertex3f(256, 256, 0.0f);
1715 glVertex3f(0, 256, 0.0f);
1717 glMatrixMode(GL_PROJECTION);
1719 glMatrixMode(GL_MODELVIEW);
1721 glEnable(GL_DEPTH_TEST);
1722 glEnable(GL_CULL_FACE);
1723 glDisable(GL_BLEND);
1727 glDisable(GL_DEPTH_TEST);
1728 glColor3f (1.0, 1.0, 1.0); // no coloring
1730 glEnable(GL_TEXTURE_2D);
1732 //Win Screen Won Victory
1734 glEnable(GL_TEXTURE_2D);
1735 glColor4f(1, 1, 1, 1);
1736 sprintf (string, "Level Cleared!");
1737 text->glPrintOutlined(1024 / 2 - strlen(string) * 10, 768 * 7 / 8, string, 1, 2, 1024, 768);
1739 sprintf (string, "Score: %d", (int)(bonustotal - startbonustotal));
1740 text->glPrintOutlined(1024 / 30, 768 * 6 / 8, string, 1, 2, 1024, 768);
1743 sprintf (string, "Press Escape or Space to continue");
1745 sprintf (string, "Press Escape to return to menu or Space to continue");
1746 text->glPrintOutlined(640 / 2 - strlen(string) * 5, 480 * 1 / 16, string, 1, 1, 640, 480);
1750 for (i = 0; i < 255; i++)string[i] = '\0';
1751 sprintf (temp, "Time: %d:", (int)(((int)leveltime - (int)(leveltime) % 60) / 60));
1752 strcat(string, temp);
1753 if ((int)(leveltime) % 60 < 10)
1754 strcat(string, "0");
1755 sprintf (temp, "%d", (int)(leveltime) % 60);
1756 strcat(string, temp);
1757 text->glPrintOutlined(1024 / 30, 768 * 6 / 8 - 40, string, 1, 2, 1024, 768);
1760 int awards[award_count];
1761 int numawards = award_awards(awards);
1763 for (i = 0; i < numawards && i < 6; i++)
1764 text->glPrintOutlined(1024 / 30, 768 * 6 / 8 - 90 - 40 * i, award_names[awards[i]], 1, 2, 1024, 768);
1767 if (drawmode != normalmode) {
1768 glEnable(GL_TEXTURE_2D);
1770 if (!drawtoggle || drawmode != realmotionblurmode || (drawtoggle == 2 || change == 1)) {
1771 if (screentexture) {
1773 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
1774 GLfloat subtractColor[4] = { 0.5, 0.5, 0.5, 0.0 };
1775 glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, subtractColor);
1776 //glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_SUBTRACT);
1777 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE);
1778 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_CONSTANT_EXT);
1779 glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 2.0f);
1781 glBindTexture( GL_TEXTURE_2D, screentexture);
1782 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1785 if ((drawtoggle || change == 1) && drawmode == realmotionblurmode) {
1786 if (screentexture2) {
1787 glBindTexture( GL_TEXTURE_2D, screentexture2);
1788 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1790 if (!screentexture2) {
1791 glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
1793 glGenTextures( 1, &screentexture2 );
1794 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
1796 glEnable(GL_TEXTURE_2D);
1797 glBindTexture( GL_TEXTURE_2D, screentexture2);
1798 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
1799 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
1801 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
1807 glClear(GL_DEPTH_BUFFER_BIT);
1808 Game::ReSizeGLScene(90, .1f);
1809 glViewport(0, 0, screenwidth, screenheight);
1811 if (drawmode != normalmode) {
1812 glDisable(GL_DEPTH_TEST);
1813 if (drawmode == motionblurmode) {
1814 glDrawBuffer(GL_FRONT);
1815 glReadBuffer(GL_BACK);
1817 glColor3f (1.0, 1.0, 1.0); // no coloring
1819 glEnable(GL_TEXTURE_2D);
1820 glBindTexture( GL_TEXTURE_2D, screentexture);
1821 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1822 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1823 glDisable(GL_DEPTH_TEST);
1824 glDisable(GL_CULL_FACE);
1825 glDisable(GL_LIGHTING);
1827 glMatrixMode(GL_PROJECTION);
1830 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1831 glMatrixMode(GL_MODELVIEW);
1834 glScalef((float)screenwidth / 2, (float)screenheight / 2, 1);
1835 glTranslatef(1, 1, 0);
1836 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1838 if (drawmode == motionblurmode) {
1839 if (motionbluramount < .2)
1840 motionbluramount = .2;
1841 //glColor4f(1,1,1,fast_sqrt(multiplier)*2.9*motionbluramount);
1842 glColor4f(1, 1, 1, motionbluramount);
1846 glVertex3f(-1, -1, 0.0f);
1847 glTexCoord2f(texcoordwidth, 0);
1848 glVertex3f(1, -1, 0.0f);
1849 glTexCoord2f(texcoordwidth, texcoordheight);
1850 glVertex3f(1, 1, 0.0f);
1851 glTexCoord2f(0, texcoordheight);
1852 glVertex3f(-1, 1, 0.0f);
1856 if (drawmode == realmotionblurmode) {
1857 glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
1858 glClear(GL_COLOR_BUFFER_BIT);
1859 glBlendFunc(GL_SRC_ALPHA, GL_ONE);
1860 glBindTexture( GL_TEXTURE_2D, screentexture);
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 glBindTexture( GL_TEXTURE_2D, screentexture2);
1875 glColor4f(1, 1, 1, .5);
1879 glVertex3f(-1, -1, 0.0f);
1880 glTexCoord2f(texcoordwidth, 0);
1881 glVertex3f(1, -1, 0.0f);
1882 glTexCoord2f(texcoordwidth, texcoordheight);
1883 glVertex3f(1, 1, 0.0f);
1884 glTexCoord2f(0, texcoordheight);
1885 glVertex3f(-1, 1, 0.0f);
1888 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1890 if (drawmode == doublevisionmode) {
1891 static float crosseyedness;
1892 crosseyedness = abs(Person::players[0]->damage - Person::players[0]->superpermanentdamage - (Person::players[0]->damagetolerance - Person::players[0]->superpermanentdamage) * 1 / 2) / 30;
1893 if (crosseyedness > 1)
1895 if (crosseyedness < 0)
1897 glColor4f(1, 1, 1, 1);
1898 glDisable(GL_BLEND);
1903 glVertex3f(-1, -1, 0.0f);
1904 glTexCoord2f(texcoordwidth, 0);
1905 glVertex3f(1, -1, 0.0f);
1906 glTexCoord2f(texcoordwidth, texcoordheight);
1907 glVertex3f(1, 1, 0.0f);
1908 glTexCoord2f(0, texcoordheight);
1909 glVertex3f(-1, 1, 0.0f);
1912 if (crosseyedness) {
1913 glColor4f(1, 1, 1, .5);
1916 glTranslatef(.015 * crosseyedness, 0, 0);
1920 glVertex3f(-1, -1, 0.0f);
1921 glTexCoord2f(texcoordwidth, 0);
1922 glVertex3f(1, -1, 0.0f);
1923 glTexCoord2f(texcoordwidth, texcoordheight);
1924 glVertex3f(1, 1, 0.0f);
1925 glTexCoord2f(0, texcoordheight);
1926 glVertex3f(-1, 1, 0.0f);
1931 if (drawmode == glowmode) {
1932 glColor4f(.5, .5, .5, .5);
1934 glBlendFunc(GL_SRC_ALPHA, GL_ONE);
1936 glTranslatef(.01, 0, 0);
1939 glVertex3f(-1, -1, 0.0f);
1940 glTexCoord2f(texcoordwidth, 0);
1941 glVertex3f(1, -1, 0.0f);
1942 glTexCoord2f(texcoordwidth, texcoordheight);
1943 glVertex3f(1, 1, 0.0f);
1944 glTexCoord2f(0, texcoordheight);
1945 glVertex3f(-1, 1, 0.0f);
1949 glTranslatef(-.01, 0, 0);
1952 glVertex3f(-1, -1, 0.0f);
1953 glTexCoord2f(texcoordwidth, 0);
1954 glVertex3f(1, -1, 0.0f);
1955 glTexCoord2f(texcoordwidth, texcoordheight);
1956 glVertex3f(1, 1, 0.0f);
1957 glTexCoord2f(0, texcoordheight);
1958 glVertex3f(-1, 1, 0.0f);
1962 glTranslatef(.0, .01, 0);
1965 glVertex3f(-1, -1, 0.0f);
1966 glTexCoord2f(texcoordwidth, 0);
1967 glVertex3f(1, -1, 0.0f);
1968 glTexCoord2f(texcoordwidth, texcoordheight);
1969 glVertex3f(1, 1, 0.0f);
1970 glTexCoord2f(0, texcoordheight);
1971 glVertex3f(-1, 1, 0.0f);
1975 glTranslatef(0, -.01, 0);
1978 glVertex3f(-1, -1, 0.0f);
1979 glTexCoord2f(texcoordwidth, 0);
1980 glVertex3f(1, -1, 0.0f);
1981 glTexCoord2f(texcoordwidth, texcoordheight);
1982 glVertex3f(1, 1, 0.0f);
1983 glTexCoord2f(0, texcoordheight);
1984 glVertex3f(-1, 1, 0.0f);
1988 if (drawmode == radialzoommode) {
1989 for (i = 0; i < 3; i++) {
1990 //glRotatef((float)i*.1,0,0,1);
1991 glColor4f(1, 1, 1, 1 / ((float)i + 1));
1993 glScalef(1 + (float)i * .01, 1 + (float)i * .01, 1);
1996 glVertex3f(-1, -1, 0.0f);
1997 glTexCoord2f(texcoordwidth, 0);
1998 glVertex3f(1, -1, 0.0f);
1999 glTexCoord2f(texcoordwidth, texcoordheight);
2000 glVertex3f(1, 1, 0.0f);
2001 glTexCoord2f(0, texcoordheight);
2002 glVertex3f(-1, 1, 0.0f);
2007 glDisable(GL_TEXTURE_2D);
2008 glMatrixMode(GL_PROJECTION);
2010 glMatrixMode(GL_MODELVIEW);
2012 glEnable(GL_DEPTH_TEST);
2013 glEnable(GL_CULL_FACE);
2014 glDisable(GL_BLEND);
2019 glEnable(GL_TEXTURE_2D);
2020 glColor4f(1, 1, 1, 1);
2022 if (consoleselected >= 60)
2023 offset = consoleselected - 60;
2024 sprintf (string, " ]");
2025 text->glPrint(10, 30, string, 0, 1, 1024, 768);
2027 sprintf (string, "_");
2028 text->glPrint(30 + (float)(consoleselected) * 10 - offset * 10, 30, string, 0, 1, 1024, 768);
2030 for (i = 0; i < 15; i++)
2031 for (j = 0; j < consoletext[i].size(); j++) {
2032 glColor4f(1, 1, 1, 1 - (float)(i) / 16);
2033 sprintf (string, "%c", consoletext[i][j]);
2034 text->glPrint(30 + j * 10 - offset * 10, 30 + i * 20, string, 0, 1, 1024, 768);
2039 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted)) {
2040 multiplier = tempmult;
2047 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted)) {
2048 tempmult = multiplier;
2053 if ( side == stereoRight || side == stereoCenter ) {
2054 if (drawmode != motionblurmode || mainmenu) {
2059 //myassert(glGetError() == GL_NO_ERROR);
2060 glDrawBuffer(GL_BACK);
2061 glReadBuffer(GL_BACK);
2066 if (drawtoggle == 2)
2069 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted)) {
2070 multiplier = tempmult;
2072 //Jordan fixed your warning!
2078 // !!! FIXME: hack: clamp framerate in menu so text input works correctly on fast systems.
2081 glDrawBuffer(GL_BACK);
2082 glReadBuffer(GL_BACK);
2083 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
2084 Game::ReSizeGLScene(90, .1f);
2086 //draw menu background
2087 glClear(GL_DEPTH_BUFFER_BIT);
2088 glEnable(GL_ALPHA_TEST);
2089 glAlphaFunc(GL_GREATER, 0.001f);
2090 glEnable(GL_TEXTURE_2D);
2091 glDisable(GL_DEPTH_TEST);
2092 glDisable(GL_CULL_FACE);
2093 glDisable(GL_LIGHTING);
2095 glMatrixMode(GL_PROJECTION);
2098 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
2099 glMatrixMode(GL_MODELVIEW);
2102 glTranslatef(screenwidth / 2, screenheight / 2, 0);
2104 glScalef((float)screenwidth / 2, (float)screenheight / 2, 1);
2105 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
2106 glDisable(GL_BLEND);
2107 glColor4f(0, 0, 0, 1.0);
2108 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2109 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2110 glDisable(GL_TEXTURE_2D);
2112 glVertex3f(-1, -1, 0);
2113 glVertex3f(+1, -1, 0);
2114 glVertex3f(+1, +1, 0);
2115 glVertex3f(-1, +1, 0);
2118 glColor4f(0.4, 0.4, 0.4, 1.0);
2119 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2120 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2121 glEnable(GL_TEXTURE_2D);
2122 Game::Mainmenuitems[4].bind();
2125 glVertex3f(-1, -1, 0);
2127 glVertex3f(+1, -1, 0);
2129 glVertex3f(+1, +1, 0);
2131 glVertex3f(-1, +1, 0);
2135 glMatrixMode(GL_PROJECTION);
2137 glMatrixMode(GL_MODELVIEW);
2141 glMatrixMode(GL_PROJECTION);
2144 glOrtho(0, 640, 0, 480, -100, 100);
2145 glMatrixMode(GL_MODELVIEW);
2148 glEnable(GL_TEXTURE_2D);
2153 glMatrixMode(GL_PROJECTION);
2155 glMatrixMode(GL_MODELVIEW);
2158 glMatrixMode(GL_PROJECTION);
2161 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
2162 glMatrixMode(GL_MODELVIEW);
2165 glTranslatef(screenwidth / 2, screenheight / 2, 0);
2167 glScalef((float)screenwidth / 2, (float)screenheight / 2, 1);
2168 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
2170 glEnable(GL_TEXTURE_2D);
2171 glColor4f(1, 1, 1, 1);
2172 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2173 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2175 if (!Game::waiting) { // hide the cursor while waiting for a key
2177 glTranslatef(Game::mousecoordh - screenwidth / 2, Game::mousecoordv * -1 + screenheight / 2, 0);
2178 glScalef((float)screenwidth / 64, (float)screenwidth / 64, 1);
2179 glTranslatef(1, -1, 0);
2180 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
2181 glColor4f(1, 1, 1, 1);
2182 Game::cursortexture.bind();
2184 //glScalef(.25,.25,.25);
2187 glVertex3f(-1, -1, 0.0f);
2189 glVertex3f(1, -1, 0.0f);
2191 glVertex3f(1, 1, 0.0f);
2193 glVertex3f(-1, 1, 0.0f);
2199 glMatrixMode(GL_PROJECTION);
2204 if (flashamount > 0) {
2205 if (flashamount > 1)
2207 if (flashdelay <= 0)
2208 flashamount -= multiplier;
2210 if (flashamount < 0)
2212 glDisable(GL_DEPTH_TEST);
2213 glDisable(GL_CULL_FACE);
2214 glDisable(GL_LIGHTING);
2215 glDisable(GL_TEXTURE_2D);
2217 glMatrixMode(GL_PROJECTION);
2220 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
2221 glMatrixMode(GL_MODELVIEW);
2224 glScalef(screenwidth, screenheight, 1);
2225 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
2227 glColor4f(flashr, flashg, flashb, flashamount);
2229 glVertex3f(0, 0, 0.0f);
2230 glVertex3f(256, 0, 0.0f);
2231 glVertex3f(256, 256, 0.0f);
2232 glVertex3f(0, 256, 0.0f);
2234 glMatrixMode(GL_PROJECTION);
2236 glMatrixMode(GL_MODELVIEW);
2238 glEnable(GL_DEPTH_TEST);
2239 glEnable(GL_CULL_FACE);
2240 glDisable(GL_BLEND);