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);
1442 sprintf (string, " ]");
1443 text->glPrint(10, 30 + screenheight - 330, string, 0, 1, screenwidth, screenheight);
1445 sprintf (string, "_");
1446 text->glPrint(30 + (float)(displayselected) * 10, 30 + (screenheight - 330), string, 0, 1, screenwidth, screenheight);
1449 for (i = 0; i < 15; i++)
1450 if ((i != 0 || chatting) && displaytime[i] < 4)
1451 for (j = 0; j < displaytext[i].size(); j++) {
1452 glColor4f(1, 1, 1, 4 - displaytime[i]);
1453 sprintf (string, "%c", displaytext[i][j]);
1454 text->glPrint(30 + j * 10, 30 + i * 20 + (screenheight - 330), string, 0, 1, screenwidth, screenheight);
1458 if (difficulty < 2 && indialogue == -1) { // minimap
1459 float mapviewdist = 20000;
1461 glDisable(GL_DEPTH_TEST);
1462 glColor3f (1.0, 1.0, 1.0); // no coloring
1464 glEnable(GL_TEXTURE_2D);
1465 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1466 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1467 glDisable(GL_DEPTH_TEST);
1468 glDisable(GL_CULL_FACE);
1469 glDisable(GL_LIGHTING);
1471 glMatrixMode(GL_PROJECTION);
1474 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1475 glMatrixMode(GL_MODELVIEW);
1478 glScalef((float)screenwidth / 2, (float)screenwidth / 2, 1);
1479 glTranslatef(1.75, .25, 0);
1480 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1482 glColor4f(1, 1, 1, 1);
1488 int numliveplayers = 0;
1490 for (i = 0; i < Person::players.size(); i++) {
1491 if (!Person::players[i]->dead)
1497 for (i = 0; i < objects.numobjects; i++) {
1498 if (objects.type[i] == treetrunktype || objects.type[i] == boxtype) {
1499 center += objects.position[i];
1503 for (i = 0; i < Person::players.size(); i++) {
1504 if (!Person::players[i]->dead)
1505 center += Person::players[i]->coords;
1507 center /= numadd + numliveplayers;
1509 center = Person::players[0]->coords;
1511 float maxdistance = 0;
1513 //~ int whichclosest;
1514 for (i = 0; i < objects.numobjects; i++) {
1515 tempdist = distsq(¢er, &objects.position[i]);
1516 if (tempdist > maxdistance) {
1518 maxdistance = tempdist;
1521 for (i = 0; i < Person::players.size(); i++) {
1522 if (!Person::players[i]->dead) {
1523 tempdist = distsq(¢er, &Person::players[i]->coords);
1524 if (tempdist > maxdistance) {
1526 maxdistance = tempdist;
1530 radius = fast_sqrt(maxdistance);
1534 glScalef(.25 / radius * 256 * terrain.scale * .4, .25 / radius * 256 * terrain.scale * .4, 1);
1536 glScalef(1 / (1 / radius * 256 * terrain.scale * .4), 1 / (1 / radius * 256 * terrain.scale * .4), 1);
1538 glRotatef(Person::players[0]->lookyaw * -1 + 180, 0, 0, 1);
1539 glTranslatef(-(center.x / terrain.scale / 256 * -2 + 1), (center.z / terrain.scale / 256 * -2 + 1), 0);
1540 for (i = 0; i < objects.numobjects; i++) {
1541 if (objects.type[i] == treetrunktype) {
1542 distcheck = distsq(&Person::players[0]->coords, &objects.position[i]);
1543 if (distcheck < mapviewdist) {
1544 Mapcircletexture.bind();
1545 glColor4f(0, .3, 0, opac * (1 - distcheck / mapviewdist));
1547 glTranslatef(objects.position[i].x / terrain.scale / 256 * -2 + 1, objects.position[i].z / terrain.scale / 256 * 2 - 1, 0);
1548 glRotatef(objects.yaw[i], 0, 0, 1);
1549 glScalef(.003, .003, .003);
1552 glVertex3f(-1, -1, 0.0f);
1554 glVertex3f(1, -1, 0.0f);
1556 glVertex3f(1, 1, 0.0f);
1558 glVertex3f(-1, 1, 0.0f);
1563 if (objects.type[i] == boxtype) {
1564 distcheck = distsq(&Person::players[0]->coords, &objects.position[i]);
1565 if (distcheck < mapviewdist) {
1566 Mapboxtexture.bind();
1567 glColor4f(.4, .4, .4, opac * (1 - distcheck / mapviewdist));
1569 glTranslatef(objects.position[i].x / terrain.scale / 256 * -2 + 1, objects.position[i].z / terrain.scale / 256 * 2 - 1, 0);
1570 glRotatef(objects.yaw[i], 0, 0, 1);
1571 glScalef(.01 * objects.scale[i], .01 * objects.scale[i], .01 * objects.scale[i]);
1574 glVertex3f(-1, -1, 0.0f);
1576 glVertex3f(1, -1, 0.0f);
1578 glVertex3f(1, 1, 0.0f);
1580 glVertex3f(-1, 1, 0.0f);
1586 if (editorenabled) {
1587 Mapcircletexture.bind();
1588 for (i = 0; i < numboundaries; i++) {
1589 glColor4f(0, 0, 0, opac / 3);
1591 glTranslatef(boundary[i].x / terrain.scale / 256 * -2 + 1, boundary[i].z / terrain.scale / 256 * 2 - 1, 0);
1592 glScalef(.002, .002, .002);
1595 glVertex3f(-1, -1, 0.0f);
1597 glVertex3f(1, -1, 0.0f);
1599 glVertex3f(1, 1, 0.0f);
1601 glVertex3f(-1, 1, 0.0f);
1606 for (i = 0; i < Person::players.size(); i++) {
1607 distcheck = distsq(&Person::players[0]->coords, &Person::players[i]->coords);
1608 if (distcheck < mapviewdist) {
1610 Maparrowtexture.bind();
1612 glColor4f(1, 1, 1, opac);
1613 else if (Person::players[i]->dead == 2 || Person::players[i]->howactive > typesleeping)
1614 glColor4f(0, 0, 0, opac * (1 - distcheck / mapviewdist));
1615 else if (Person::players[i]->dead)
1616 glColor4f(.3, .3, .3, opac * (1 - distcheck / mapviewdist));
1617 else if (Person::players[i]->aitype == attacktypecutoff)
1618 glColor4f(1, 0, 0, opac * (1 - distcheck / mapviewdist));
1619 else if (Person::players[i]->aitype == passivetype)
1620 glColor4f(0, 1, 0, opac * (1 - distcheck / mapviewdist));
1622 glColor4f(1, 1, 0, 1);
1623 glTranslatef(Person::players[i]->coords.x / terrain.scale / 256 * -2 + 1, Person::players[i]->coords.z / terrain.scale / 256 * 2 - 1, 0);
1624 glRotatef(Person::players[i]->yaw + 180, 0, 0, 1);
1625 glScalef(.005, .005, .005);
1628 glVertex3f(-1, -1, 0.0f);
1630 glVertex3f(1, -1, 0.0f);
1632 glVertex3f(1, 1, 0.0f);
1634 glVertex3f(-1, 1, 0.0f);
1640 glDisable(GL_TEXTURE_2D);
1641 glMatrixMode(GL_PROJECTION);
1643 glMatrixMode(GL_MODELVIEW);
1645 glEnable(GL_DEPTH_TEST);
1646 glEnable(GL_CULL_FACE);
1647 glDisable(GL_BLEND);
1651 if (loading && !stealthloading && (!campaign || Person::players[0]->dead)) {
1652 glDisable(GL_DEPTH_TEST);
1653 glDisable(GL_CULL_FACE);
1654 glDisable(GL_LIGHTING);
1655 glDisable(GL_TEXTURE_2D);
1657 glMatrixMode(GL_PROJECTION);
1660 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1661 glMatrixMode(GL_MODELVIEW);
1664 glScalef(screenwidth, screenheight, 1);
1665 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1667 glColor4f(0, 0, 0, .7);
1669 glVertex3f(0, 0, 0.0f);
1670 glVertex3f(256, 0, 0.0f);
1671 glVertex3f(256, 256, 0.0f);
1672 glVertex3f(0, 256, 0.0f);
1674 glMatrixMode(GL_PROJECTION);
1676 glMatrixMode(GL_MODELVIEW);
1678 glEnable(GL_DEPTH_TEST);
1679 glEnable(GL_CULL_FACE);
1680 glDisable(GL_BLEND);
1684 glDisable(GL_DEPTH_TEST);
1685 glColor3f (1.0, 1.0, 1.0); // no coloring
1687 glEnable(GL_TEXTURE_2D);
1692 glEnable(GL_TEXTURE_2D);
1693 glColor4f(1, 1, 1, 1);
1694 sprintf (string, "Loading...");
1695 text->glPrint(1024 / 2 - 90, 768 / 2, string, 1, 2, 1024, 768);
1698 //if(ismotionblur)drawmode=motionblurmode;
1699 drawmode = normalmode;
1702 if (winfreeze && !campaign) {
1703 glDisable(GL_DEPTH_TEST);
1704 glDisable(GL_CULL_FACE);
1705 glDisable(GL_LIGHTING);
1706 glDisable(GL_TEXTURE_2D);
1708 glMatrixMode(GL_PROJECTION);
1711 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1712 glMatrixMode(GL_MODELVIEW);
1715 glScalef(screenwidth, screenheight, 1);
1716 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1718 glColor4f(0, 0, 0, .4);
1720 glVertex3f(0, 0, 0.0f);
1721 glVertex3f(256, 0, 0.0f);
1722 glVertex3f(256, 256, 0.0f);
1723 glVertex3f(0, 256, 0.0f);
1725 glMatrixMode(GL_PROJECTION);
1727 glMatrixMode(GL_MODELVIEW);
1729 glEnable(GL_DEPTH_TEST);
1730 glEnable(GL_CULL_FACE);
1731 glDisable(GL_BLEND);
1735 glDisable(GL_DEPTH_TEST);
1736 glColor3f (1.0, 1.0, 1.0); // no coloring
1738 glEnable(GL_TEXTURE_2D);
1740 //Win Screen Won Victory
1742 glEnable(GL_TEXTURE_2D);
1743 glColor4f(1, 1, 1, 1);
1744 sprintf (string, "Level Cleared!");
1745 text->glPrintOutlined(1024 / 2 - strlen(string) * 10, 768 * 7 / 8, string, 1, 2, 1024, 768);
1747 sprintf (string, "Score: %d", (int)(bonustotal - startbonustotal));
1748 text->glPrintOutlined(1024 / 30, 768 * 6 / 8, string, 1, 2, 1024, 768);
1751 sprintf (string, "Press Escape or Space to continue");
1753 sprintf (string, "Press Escape to return to menu or Space to continue");
1754 text->glPrintOutlined(640 / 2 - strlen(string) * 5, 480 * 1 / 16, string, 1, 1, 640, 480);
1758 for (i = 0; i < 255; i++)string[i] = '\0';
1759 sprintf (temp, "Time: %d:", (int)(((int)leveltime - (int)(leveltime) % 60) / 60));
1760 strcat(string, temp);
1761 if ((int)(leveltime) % 60 < 10)
1762 strcat(string, "0");
1763 sprintf (temp, "%d", (int)(leveltime) % 60);
1764 strcat(string, temp);
1765 text->glPrintOutlined(1024 / 30, 768 * 6 / 8 - 40, string, 1, 2, 1024, 768);
1768 int awards[award_count];
1769 int numawards = award_awards(awards);
1771 for (i = 0; i < numawards && i < 6; i++)
1772 text->glPrintOutlined(1024 / 30, 768 * 6 / 8 - 90 - 40 * i, award_names[awards[i]], 1, 2, 1024, 768);
1775 if (drawmode != normalmode) {
1776 glEnable(GL_TEXTURE_2D);
1778 if (!drawtoggle || drawmode != realmotionblurmode || (drawtoggle == 2 || change == 1)) {
1779 if (screentexture) {
1781 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
1782 GLfloat subtractColor[4] = { 0.5, 0.5, 0.5, 0.0 };
1783 glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, subtractColor);
1784 //glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_SUBTRACT);
1785 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE);
1786 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_CONSTANT_EXT);
1787 glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 2.0f);
1789 glBindTexture( GL_TEXTURE_2D, screentexture);
1790 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1793 if ((drawtoggle || change == 1) && drawmode == realmotionblurmode) {
1794 if (screentexture2) {
1795 glBindTexture( GL_TEXTURE_2D, screentexture2);
1796 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1798 if (!screentexture2) {
1799 glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
1801 glGenTextures( 1, &screentexture2 );
1802 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
1804 glEnable(GL_TEXTURE_2D);
1805 glBindTexture( GL_TEXTURE_2D, screentexture2);
1806 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
1807 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
1809 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
1815 glClear(GL_DEPTH_BUFFER_BIT);
1816 Game::ReSizeGLScene(90, .1f);
1817 glViewport(0, 0, screenwidth, screenheight);
1819 if (drawmode != normalmode) {
1820 glDisable(GL_DEPTH_TEST);
1821 if (drawmode == motionblurmode) {
1822 glDrawBuffer(GL_FRONT);
1823 glReadBuffer(GL_BACK);
1825 glColor3f (1.0, 1.0, 1.0); // no coloring
1827 glEnable(GL_TEXTURE_2D);
1828 glBindTexture( GL_TEXTURE_2D, screentexture);
1829 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1830 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1831 glDisable(GL_DEPTH_TEST);
1832 glDisable(GL_CULL_FACE);
1833 glDisable(GL_LIGHTING);
1835 glMatrixMode(GL_PROJECTION);
1838 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1839 glMatrixMode(GL_MODELVIEW);
1842 glScalef((float)screenwidth / 2, (float)screenheight / 2, 1);
1843 glTranslatef(1, 1, 0);
1844 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1846 if (drawmode == motionblurmode) {
1847 if (motionbluramount < .2)
1848 motionbluramount = .2;
1849 //glColor4f(1,1,1,fast_sqrt(multiplier)*2.9*motionbluramount);
1850 glColor4f(1, 1, 1, motionbluramount);
1854 glVertex3f(-1, -1, 0.0f);
1855 glTexCoord2f(texcoordwidth, 0);
1856 glVertex3f(1, -1, 0.0f);
1857 glTexCoord2f(texcoordwidth, texcoordheight);
1858 glVertex3f(1, 1, 0.0f);
1859 glTexCoord2f(0, texcoordheight);
1860 glVertex3f(-1, 1, 0.0f);
1864 if (drawmode == realmotionblurmode) {
1865 glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
1866 glClear(GL_COLOR_BUFFER_BIT);
1867 glBlendFunc(GL_SRC_ALPHA, GL_ONE);
1868 glBindTexture( GL_TEXTURE_2D, screentexture);
1869 glColor4f(1, 1, 1, .5);
1873 glVertex3f(-1, -1, 0.0f);
1874 glTexCoord2f(texcoordwidth, 0);
1875 glVertex3f(1, -1, 0.0f);
1876 glTexCoord2f(texcoordwidth, texcoordheight);
1877 glVertex3f(1, 1, 0.0f);
1878 glTexCoord2f(0, texcoordheight);
1879 glVertex3f(-1, 1, 0.0f);
1882 glBindTexture( GL_TEXTURE_2D, screentexture2);
1883 glColor4f(1, 1, 1, .5);
1887 glVertex3f(-1, -1, 0.0f);
1888 glTexCoord2f(texcoordwidth, 0);
1889 glVertex3f(1, -1, 0.0f);
1890 glTexCoord2f(texcoordwidth, texcoordheight);
1891 glVertex3f(1, 1, 0.0f);
1892 glTexCoord2f(0, texcoordheight);
1893 glVertex3f(-1, 1, 0.0f);
1896 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1898 if (drawmode == doublevisionmode) {
1899 static float crosseyedness;
1900 crosseyedness = abs(Person::players[0]->damage - Person::players[0]->superpermanentdamage - (Person::players[0]->damagetolerance - Person::players[0]->superpermanentdamage) * 1 / 2) / 30;
1901 if (crosseyedness > 1)
1903 if (crosseyedness < 0)
1905 glColor4f(1, 1, 1, 1);
1906 glDisable(GL_BLEND);
1911 glVertex3f(-1, -1, 0.0f);
1912 glTexCoord2f(texcoordwidth, 0);
1913 glVertex3f(1, -1, 0.0f);
1914 glTexCoord2f(texcoordwidth, texcoordheight);
1915 glVertex3f(1, 1, 0.0f);
1916 glTexCoord2f(0, texcoordheight);
1917 glVertex3f(-1, 1, 0.0f);
1920 if (crosseyedness) {
1921 glColor4f(1, 1, 1, .5);
1924 glTranslatef(.015 * crosseyedness, 0, 0);
1928 glVertex3f(-1, -1, 0.0f);
1929 glTexCoord2f(texcoordwidth, 0);
1930 glVertex3f(1, -1, 0.0f);
1931 glTexCoord2f(texcoordwidth, texcoordheight);
1932 glVertex3f(1, 1, 0.0f);
1933 glTexCoord2f(0, texcoordheight);
1934 glVertex3f(-1, 1, 0.0f);
1939 if (drawmode == glowmode) {
1940 glColor4f(.5, .5, .5, .5);
1942 glBlendFunc(GL_SRC_ALPHA, GL_ONE);
1944 glTranslatef(.01, 0, 0);
1947 glVertex3f(-1, -1, 0.0f);
1948 glTexCoord2f(texcoordwidth, 0);
1949 glVertex3f(1, -1, 0.0f);
1950 glTexCoord2f(texcoordwidth, texcoordheight);
1951 glVertex3f(1, 1, 0.0f);
1952 glTexCoord2f(0, texcoordheight);
1953 glVertex3f(-1, 1, 0.0f);
1957 glTranslatef(-.01, 0, 0);
1960 glVertex3f(-1, -1, 0.0f);
1961 glTexCoord2f(texcoordwidth, 0);
1962 glVertex3f(1, -1, 0.0f);
1963 glTexCoord2f(texcoordwidth, texcoordheight);
1964 glVertex3f(1, 1, 0.0f);
1965 glTexCoord2f(0, texcoordheight);
1966 glVertex3f(-1, 1, 0.0f);
1970 glTranslatef(.0, .01, 0);
1973 glVertex3f(-1, -1, 0.0f);
1974 glTexCoord2f(texcoordwidth, 0);
1975 glVertex3f(1, -1, 0.0f);
1976 glTexCoord2f(texcoordwidth, texcoordheight);
1977 glVertex3f(1, 1, 0.0f);
1978 glTexCoord2f(0, texcoordheight);
1979 glVertex3f(-1, 1, 0.0f);
1983 glTranslatef(0, -.01, 0);
1986 glVertex3f(-1, -1, 0.0f);
1987 glTexCoord2f(texcoordwidth, 0);
1988 glVertex3f(1, -1, 0.0f);
1989 glTexCoord2f(texcoordwidth, texcoordheight);
1990 glVertex3f(1, 1, 0.0f);
1991 glTexCoord2f(0, texcoordheight);
1992 glVertex3f(-1, 1, 0.0f);
1996 if (drawmode == radialzoommode) {
1997 for (i = 0; i < 3; i++) {
1998 //glRotatef((float)i*.1,0,0,1);
1999 glColor4f(1, 1, 1, 1 / ((float)i + 1));
2001 glScalef(1 + (float)i * .01, 1 + (float)i * .01, 1);
2004 glVertex3f(-1, -1, 0.0f);
2005 glTexCoord2f(texcoordwidth, 0);
2006 glVertex3f(1, -1, 0.0f);
2007 glTexCoord2f(texcoordwidth, texcoordheight);
2008 glVertex3f(1, 1, 0.0f);
2009 glTexCoord2f(0, texcoordheight);
2010 glVertex3f(-1, 1, 0.0f);
2015 glDisable(GL_TEXTURE_2D);
2016 glMatrixMode(GL_PROJECTION);
2018 glMatrixMode(GL_MODELVIEW);
2020 glEnable(GL_DEPTH_TEST);
2021 glEnable(GL_CULL_FACE);
2022 glDisable(GL_BLEND);
2027 glEnable(GL_TEXTURE_2D);
2028 glColor4f(1, 1, 1, 1);
2030 if (consoleselected >= 60)
2031 offset = consoleselected - 60;
2032 sprintf (string, " ]");
2033 text->glPrint(10, 30, string, 0, 1, 1024, 768);
2035 sprintf (string, "_");
2036 text->glPrint(30 + (float)(consoleselected) * 10 - offset * 10, 30, string, 0, 1, 1024, 768);
2038 for (i = 0; i < 15; i++)
2039 for (j = 0; j < consoletext[i].size(); j++) {
2040 glColor4f(1, 1, 1, 1 - (float)(i) / 16);
2041 sprintf (string, "%c", consoletext[i][j]);
2042 text->glPrint(30 + j * 10 - offset * 10, 30 + i * 20, string, 0, 1, 1024, 768);
2047 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted)) {
2048 multiplier = tempmult;
2055 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted)) {
2056 tempmult = multiplier;
2061 if ( side == stereoRight || side == stereoCenter ) {
2062 if (drawmode != motionblurmode || mainmenu) {
2067 //myassert(glGetError() == GL_NO_ERROR);
2068 glDrawBuffer(GL_BACK);
2069 glReadBuffer(GL_BACK);
2074 if (drawtoggle == 2)
2077 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted)) {
2078 multiplier = tempmult;
2080 //Jordan fixed your warning!
2086 // !!! FIXME: hack: clamp framerate in menu so text input works correctly on fast systems.
2089 glDrawBuffer(GL_BACK);
2090 glReadBuffer(GL_BACK);
2091 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
2092 Game::ReSizeGLScene(90, .1f);
2094 //draw menu background
2095 glClear(GL_DEPTH_BUFFER_BIT);
2096 glEnable(GL_ALPHA_TEST);
2097 glAlphaFunc(GL_GREATER, 0.001f);
2098 glEnable(GL_TEXTURE_2D);
2099 glDisable(GL_DEPTH_TEST);
2100 glDisable(GL_CULL_FACE);
2101 glDisable(GL_LIGHTING);
2103 glMatrixMode(GL_PROJECTION);
2106 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
2107 glMatrixMode(GL_MODELVIEW);
2110 glTranslatef(screenwidth / 2, screenheight / 2, 0);
2112 glScalef((float)screenwidth / 2, (float)screenheight / 2, 1);
2113 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
2114 glDisable(GL_BLEND);
2115 glColor4f(0, 0, 0, 1.0);
2116 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2117 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2118 glDisable(GL_TEXTURE_2D);
2120 glVertex3f(-1, -1, 0);
2121 glVertex3f(+1, -1, 0);
2122 glVertex3f(+1, +1, 0);
2123 glVertex3f(-1, +1, 0);
2126 glColor4f(0.4, 0.4, 0.4, 1.0);
2127 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2128 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2129 glEnable(GL_TEXTURE_2D);
2130 Game::Mainmenuitems[4].bind();
2133 glVertex3f(-1, -1, 0);
2135 glVertex3f(+1, -1, 0);
2137 glVertex3f(+1, +1, 0);
2139 glVertex3f(-1, +1, 0);
2143 glMatrixMode(GL_PROJECTION);
2145 glMatrixMode(GL_MODELVIEW);
2149 glMatrixMode(GL_PROJECTION);
2152 glOrtho(0, 640, 0, 480, -100, 100);
2153 glMatrixMode(GL_MODELVIEW);
2156 glEnable(GL_TEXTURE_2D);
2161 glMatrixMode(GL_PROJECTION);
2163 glMatrixMode(GL_MODELVIEW);
2166 glMatrixMode(GL_PROJECTION);
2169 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
2170 glMatrixMode(GL_MODELVIEW);
2173 glTranslatef(screenwidth / 2, screenheight / 2, 0);
2175 glScalef((float)screenwidth / 2, (float)screenheight / 2, 1);
2176 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
2178 glEnable(GL_TEXTURE_2D);
2179 glColor4f(1, 1, 1, 1);
2180 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2181 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2183 if (!Game::waiting) { // hide the cursor while waiting for a key
2185 glTranslatef(Game::mousecoordh - screenwidth / 2, Game::mousecoordv * -1 + screenheight / 2, 0);
2186 glScalef((float)screenwidth / 64, (float)screenwidth / 64, 1);
2187 glTranslatef(1, -1, 0);
2188 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
2189 glColor4f(1, 1, 1, 1);
2190 Game::cursortexture.bind();
2192 //glScalef(.25,.25,.25);
2195 glVertex3f(-1, -1, 0.0f);
2197 glVertex3f(1, -1, 0.0f);
2199 glVertex3f(1, 1, 0.0f);
2201 glVertex3f(-1, 1, 0.0f);
2207 glMatrixMode(GL_PROJECTION);
2212 if (flashamount > 0) {
2213 if (flashamount > 1)
2215 if (flashdelay <= 0)
2216 flashamount -= multiplier;
2218 if (flashamount < 0)
2220 glDisable(GL_DEPTH_TEST);
2221 glDisable(GL_CULL_FACE);
2222 glDisable(GL_LIGHTING);
2223 glDisable(GL_TEXTURE_2D);
2225 glMatrixMode(GL_PROJECTION);
2228 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
2229 glMatrixMode(GL_MODELVIEW);
2232 glScalef(screenwidth, screenheight, 1);
2233 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
2235 glColor4f(flashr, flashg, flashb, flashamount);
2237 glVertex3f(0, 0, 0.0f);
2238 glVertex3f(256, 0, 0.0f);
2239 glVertex3f(256, 256, 0.0f);
2240 glVertex3f(0, 256, 0.0f);
2242 glMatrixMode(GL_PROJECTION);
2244 glMatrixMode(GL_MODELVIEW);
2246 glEnable(GL_DEPTH_TEST);
2247 glEnable(GL_CULL_FACE);
2248 glDisable(GL_BLEND);