2 Copyright (C) 2003, 2010 - Wolfire Games
4 This file is part of Lugaru.
6 Lugaru is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 Lugaru is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
21 #include "openal_wrapper.h"
27 extern int environment;
28 extern float texscale;
30 extern Terrain terrain;
31 //extern Sprites sprites;
32 extern float multiplier;
34 extern float viewdistance;
35 extern float fadestart;
36 extern float screenwidth, screenheight;
37 extern int kTextureSize;
38 extern FRUSTUM frustum;
40 extern Objects objects;
42 extern float usermousesensitivity;
43 extern float camerashake;
45 extern float slomodelay;
46 extern bool ismotionblur;
48 extern float blackout;
49 extern bool damageeffects;
51 extern bool texttoggle;
52 extern float blurness;
53 extern float targetblurness;
54 extern float playerdist;
55 extern bool cellophane;
57 extern float flashamount, flashr, flashg, flashb;
58 extern int flashdelay;
60 extern float motionbluramount;
62 extern bool alwaysblur;
64 extern bool tilt2weird;
65 extern bool tiltweird;
67 extern bool proportionweird;
68 extern bool vertexweird[6];
69 extern bool velocityblur;
70 extern bool debugmode;
72 extern int bloodtoggle;
73 extern int difficulty;
76 //extern int texdetail;
77 extern float texdetail;
78 extern bool musictoggle;
79 extern int tutoriallevel;
80 extern float smoketex;
81 extern float tutorialstagetime;
82 extern float tutorialmaxtime;
83 extern int tutorialstage;
84 extern bool againbonus;
85 extern float damagedealt;
86 extern bool invertmouse;
88 extern int numhotspots;
89 extern int killhotspot;
90 extern XYZ hotspot[40];
91 extern int hotspottype[40];
92 extern float hotspotsize[40];
93 extern char hotspottext[40][256];
94 extern int currenthotspot;;
97 extern bool winfreeze;
99 extern float menupulse;
101 extern bool gamestart;
103 extern bool gamestarted;
105 extern bool showdamagebar;
110 int numboundaries = 0;
117 normalmode, motionblurmode, radialzoommode,
118 realmotionblurmode, doublevisionmode, glowmode,
121 void Game::flash() // shouldn't be that way, these should be attributes and Person class should not change rendering.
132 /*********************> DrawGLScene() <*****/
133 int Game::DrawGLScene(StereoSide side)
135 static float texcoordwidth, texcoordheight;
136 static float texviewwidth, texviewheight;
138 static XYZ checkpoint;
139 static float tempmult;
141 static char string[256] = "";
142 static char string2[256] = "";
143 static char string3[256] = "";
144 static int drawmode = 0;
146 if ( stereomode == stereoAnaglyph ) {
149 glColorMask( 0.0, 1.0, 1.0, 1.0 );
152 glColorMask( 1.0, 0.0, 0.0, 1.0 );
158 glColorMask( 1.0, 1.0, 1.0, 1.0 );
160 if ( stereomode == stereoHorizontalInterlaced || stereomode == stereoVerticalInterlaced ) {
161 glStencilFunc(side == stereoLeft ? GL_NOTEQUAL : GL_EQUAL, 0x01, 0x01);
165 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted)) {
166 tempmult = multiplier;
172 numboundaries = mapradius * 2;
173 if (numboundaries > 360)
175 for (int i = 0; i < numboundaries; i++) {
178 boundary[i] = mapcenter + DoRotation(boundary[i] * mapradius, 0, i * (360 / ((float)(numboundaries))), 0);
187 int olddrawmode = drawmode;
188 if (ismotionblur && !loading) {
189 if ((findLengthfast(&Person::players[0]->velocity) > 200) && velocityblur && !cameramode) {
190 drawmode = motionblurmode;
191 motionbluramount = 200 / (findLengthfast(&Person::players[0]->velocity));
194 if (Person::players[0]->damage - Person::players[0]->superpermanentdamage > (Person::players[0]->damagetolerance - Person::players[0]->superpermanentdamage) * 1 / 2 && damageeffects && !cameramode) {
195 drawmode = doublevisionmode;
200 if (slomo && !loading) {
202 drawmode = motionblurmode;
203 motionbluramount = .2;
204 slomodelay -= multiplier;
210 if ((!changed && !slomo) || loading) {
211 drawmode = normalmode;
212 if (ismotionblur && (/*fps>100||*/alwaysblur)) {
213 if (olddrawmode != realmotionblurmode)
217 drawmode = realmotionblurmode;
218 } else if (olddrawmode == realmotionblurmode)
224 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted))
225 drawmode = normalmode;
226 if ((freeze || winfreeze) && ismotionblur && !mainmenu)
227 drawmode = radialzoommode;
229 if (winfreeze || mainmenu)
230 drawmode = normalmode;
233 drawtoggle = 1 - drawtoggle;
235 if (!texcoordwidth) {
236 texviewwidth = kTextureSize;
237 if (texviewwidth > screenwidth)
238 texviewwidth = screenwidth;
239 texviewheight = kTextureSize;
240 if (texviewheight > screenheight)
241 texviewheight = screenheight;
243 texcoordwidth = screenwidth / kTextureSize;
244 texcoordheight = screenheight / kTextureSize;
245 if (texcoordwidth > 1)
247 if (texcoordheight > 1)
251 glDrawBuffer(GL_BACK);
252 glReadBuffer(GL_BACK);
254 static XYZ terrainlight;
255 static float distance;
256 if (drawmode == normalmode)
257 Game::ReSizeGLScene(90, .1f);
258 if (drawmode != normalmode)
259 glViewport(0, 0, texviewwidth, texviewheight);
260 glDepthFunc(GL_LEQUAL);
262 glAlphaFunc(GL_GREATER, 0.0001f);
263 glEnable(GL_ALPHA_TEST);
264 glClearColor(0.25f, 0.25f, 0.25f, 1.0f);
265 glClear(GL_DEPTH_BUFFER_BIT);
267 glMatrixMode (GL_MODELVIEW);
268 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
271 // Move the camera for the current eye's point of view.
272 // Reverse the movement if we're reversing stereo
273 glTranslatef((stereoseparation / 2) * side * (stereoreverse ? -1 : 1), 0, 0);
276 if (!cameramode && !freeze && !winfreeze) {
278 glRotatef(float(Random() % 100) / 10 * camerashake/*+(woozy*woozy)/10*/, 0, 0, 1);
280 glRotatef(pitch + sin(woozy / 2) * (Person::players[0]->damage / Person::players[0]->damagetolerance) * 5, 1, 0, 0);
281 glRotatef(yaw + sin(woozy) * (Person::players[0]->damage / Person::players[0]->damagetolerance) * 5, 0, 1, 0);
283 if (cameramode || freeze || winfreeze) {
284 glRotatef(pitch, 1, 0, 0);
285 glRotatef(yaw, 0, 1, 0);
288 if (environment == desertenvironment) {
289 glRotatef((float)(abs(Random() % 100)) / 3000 - 1, 1, 0, 0);
290 glRotatef((float)(abs(Random() % 100)) / 3000 - 1, 0, 1, 0);
292 SetUpLight(&light, 0);
295 //heat blur effect in desert
296 if (abs(blurness - targetblurness) < multiplier * 10 || abs(blurness - targetblurness) > 2) {
297 blurness = targetblurness;
298 targetblurness = (float)(abs(Random() % 100)) / 40;
300 if (blurness < targetblurness)
301 blurness += multiplier * 5;
303 blurness -= multiplier * 5;
305 if (environment == desertenvironment && detail == 2)
306 glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, blurness + .4 );
307 if (environment == desertenvironment) {
308 glRotatef((float)(abs(Random() % 100)) / 1000, 1, 0, 0);
309 glRotatef((float)(abs(Random() % 100)) / 1000, 0, 1, 0);
312 glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0);
314 glTranslatef(-viewer.x, -viewer.y, -viewer.z);
315 frustum.GetFrustum();
317 //make shadow decals on terrain and objects
319 static float size, opacity, rotation;
321 for (unsigned k = 0; k < Person::players.size(); k++) {
322 if (!Person::players[k]->skeleton.free && Person::players[k]->playerdetail && Person::players[k]->howactive < typesleeping)
323 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)
324 for (int i = 0; i < Person::players[k]->skeleton.num_joints; i++) {
325 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) {
326 point = DoRotation(Person::players[k]->skeleton.joints[i].position, 0, Person::players[k]->yaw, 0) * Person::players[k]->scale + Person::players[k]->coords;
328 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;
329 if (k != 0 && tutoriallevel == 1) {
330 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;
332 terrain.MakeDecal(shadowdecal, point, size, opacity, rotation);
333 for (l = 0; l < terrain.patchobjectnum[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz]; l++) {
334 int j = terrain.patchobjects[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz][l];
335 if (objects.position[j].y < Person::players[k]->coords.y || objects.type[j] == tunneltype || objects.type[j] == weirdtype) {
336 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);
339 if (k != 0 && tutoriallevel == 1) {
340 opacity = .2 + .2 * sin(smoketex * 6 + i);
342 objects.model[j].MakeDecal(shadowdecal, &point, &size, &opacity, &rotation);
347 if ((Person::players[k]->skeleton.free || Person::players[k]->howactive >= typesleeping) && Person::players[k]->playerdetail)
348 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)
349 for (int i = 0; i < Person::players[k]->skeleton.num_joints; i++) {
350 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) {
351 if (Person::players[k]->skeleton.free)
352 point = Person::players[k]->skeleton.joints[i].position * Person::players[k]->scale + Person::players[k]->coords;
354 point = DoRotation(Person::players[k]->skeleton.joints[i].position, 0, Person::players[k]->yaw, 0) * Person::players[k]->scale + Person::players[k]->coords;
356 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;
357 if (k != 0 && tutoriallevel == 1) {
358 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;
360 terrain.MakeDecal(shadowdecal, point, size, opacity * .7, rotation);
361 for (l = 0; l < terrain.patchobjectnum[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz]; l++) {
362 int j = terrain.patchobjects[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz][l];
363 if (objects.position[j].y < Person::players[k]->coords.y || objects.type[j] == tunneltype || objects.type[j] == weirdtype) {
364 if (Person::players[k]->skeleton.free)
365 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);
367 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);
370 if (k != 0 && tutoriallevel == 1) {
371 opacity = .2 + .2 * sin(smoketex * 6 + i);
373 objects.model[j].MakeDecal(shadowdecal, &point, &size, &opacity, &rotation);
379 if (!Person::players[k]->playerdetail)
380 if (frustum.SphereInFrustum(Person::players[k]->coords.x, Person::players[k]->coords.y, Person::players[k]->coords.z, Person::players[k]->scale * 5)) {
381 point = Person::players[k]->coords;
383 opacity = .4 - (Person::players[k]->coords.y - terrain.getHeight(Person::players[k]->coords.x, Person::players[k]->coords.z)) / 5;
384 terrain.MakeDecal(shadowdecal, point, size, opacity * .7, rotation);
385 for (l = 0; l < terrain.patchobjectnum[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz]; l++) {
386 int j = terrain.patchobjects[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz][l];
387 point = DoRotation(Person::players[k]->coords - objects.position[j], 0, -objects.yaw[j], 0);
390 objects.model[j].MakeDecal(shadowdecal, &point, &size, &opacity, &rotation);
396 glEnable(GL_TEXTURE_2D);
398 glEnable(GL_DEPTH_TEST);
399 glEnable(GL_CULL_FACE);
401 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
402 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
403 terraintexture.bind();
405 terraintexture2.bind();
408 terrain.drawdecals();
411 glEnable(GL_CULL_FACE);
412 glEnable(GL_LIGHTING);
414 glEnable(GL_TEXTURE_2D);
417 glEnable(GL_COLOR_MATERIAL);
432 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
433 glEnable(GL_CULL_FACE);
434 glCullFace(GL_FRONT);
436 for (unsigned k = 0; k < Person::players.size(); k++) {
437 if (k == 0 || tutoriallevel != 1) {
439 glEnable(GL_LIGHTING);
440 terrainlight = terrain.getLighting(Person::players[k]->coords.x, Person::players[k]->coords.z);
441 distance = distsq(&viewer, &Person::players[k]->coords);
442 distance = (viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance;
443 glColor4f(terrainlight.x, terrainlight.y, terrainlight.z, distance);
446 if (distance >= .5) {
447 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;
450 if (Person::players[k]->occluded != 0)
451 i = checkcollide(viewer, checkpoint, Person::players[k]->lastoccluded);
453 i = checkcollide(viewer, checkpoint);
455 Person::players[k]->occluded += 1;
456 Person::players[k]->lastoccluded = i;
458 Person::players[k]->occluded = 0;
460 if (Person::players[k]->occluded < 25)
461 Person::players[k]->DrawSkeleton();
467 if (!cameramode && musictype == stream_fighttheme)
468 playerdist = distsqflat(&Person::players[0]->coords, &viewer);
473 glEnable(GL_TEXTURE_2D);
479 if (frustum.SphereInFrustum(realhawkcoords.x + hawk.boundingspherecenter.x, realhawkcoords.y + hawk.boundingspherecenter.y, realhawkcoords.z + hawk.boundingspherecenter.z, 2)) {
480 glAlphaFunc(GL_GREATER, 0.0001f);
482 glDisable(GL_CULL_FACE);
483 glDisable(GL_LIGHTING);
485 glTranslatef(hawkcoords.x, hawkcoords.y, hawkcoords.z);
486 glRotatef(hawkyaw, 0, 1, 0);
487 glTranslatef(25, 0, 0);
488 distance = distsq(&viewer, &realhawkcoords) * 1.2;
489 glColor4f(light.color[0], light.color[1], light.color[2], (viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance);
490 if ((viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance > 1)
491 glColor4f(light.color[0], light.color[1], light.color[2], 1);
492 if ((viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance > 0)
493 hawk.drawdifftex(hawktexture);
497 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
498 glEnable(GL_CULL_FACE);
499 glCullFace(GL_FRONT);
501 for (unsigned k = 0; k < Person::players.size(); k++) {
502 if (!(k == 0 || tutoriallevel != 1)) {
504 glEnable(GL_LIGHTING);
505 terrainlight = terrain.getLighting(Person::players[k]->coords.x, Person::players[k]->coords.z);
506 distance = distsq(&viewer, &Person::players[k]->coords);
507 distance = (viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance;
508 glColor4f(terrainlight.x, terrainlight.y, terrainlight.z, distance);
511 if (distance >= .5) {
512 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;
515 if (Person::players[k]->occluded != 0)
516 i = checkcollide(viewer, checkpoint, Person::players[k]->lastoccluded);
518 i = checkcollide(viewer, checkpoint);
520 Person::players[k]->occluded += 1;
521 Person::players[k]->lastoccluded = i;
523 Person::players[k]->occluded = 0;
525 if (Person::players[k]->occluded < 25)
526 Person::players[k]->DrawSkeleton();
532 glEnable(GL_TEXTURE_2D);
537 glDisable(GL_COLOR_MATERIAL);
539 glDisable(GL_LIGHTING);
540 glDisable(GL_TEXTURE_2D);
546 //waypoints, pathpoints in editor
549 glDisable(GL_LIGHTING);
550 glDisable(GL_TEXTURE_2D);
551 glDisable(GL_COLOR_MATERIAL);
552 glColor4f(1, 1, 0, 1);
554 for (unsigned k = 0; k < Person::players.size(); k++) {
555 if (Person::players[k]->numwaypoints > 1) {
556 glBegin(GL_LINE_LOOP);
557 for (int i = 0; i < Person::players[k]->numwaypoints; i++) {
558 glVertex3f(Person::players[k]->waypoints[i].x, Person::players[k]->waypoints[i].y + .5, Person::players[k]->waypoints[i].z);
565 if (numpathpoints > 1) {
566 glColor4f(0, 1, 0, 1);
567 for (unsigned k = 0; int(k) < numpathpoints; k++) {
568 if (numpathpointconnect[k]) {
569 for (int i = 0; i < numpathpointconnect[k]; i++) {
570 glBegin(GL_LINE_LOOP);
571 glVertex3f(pathpoint[k].x, pathpoint[k].y + .5, pathpoint[k].z);
572 glVertex3f(pathpoint[pathpointconnect[k][i]].x, pathpoint[pathpointconnect[k][i]].y + .5, pathpoint[pathpointconnect[k][i]].z);
577 glColor4f(1, 1, 1, 1);
580 glVertex3f(pathpoint[pathpointselected].x, pathpoint[pathpointselected].y + .5, pathpoint[pathpointselected].z);
587 glEnable(GL_TEXTURE_2D);
588 glColor4f(.5, .5, .5, 1);
591 if (bonus > 0 && bonustime < 1 && !winfreeze && indialogue == -1/*bonustime<4*/) {
592 const char *bonus_name;
593 if (bonus < bonus_count)
594 bonus_name = bonus_names[bonus];
596 bonus_name = "Excellent!"; // When does this happen?
598 glColor4f(0, 0, 0, 1 - bonustime);
599 text->glPrintOutline(1024 / 2 - 10 * strlen(bonus_name) - 4, 768 / 16 - 4 + 768 * 4 / 5, bonus_name, 1, 2.5, 1024, 768);
600 glColor4f(1, 0, 0, 1 - bonustime);
601 text->glPrint(1024 / 2 - 10 * strlen(bonus_name), 768 / 16 + 768 * 4 / 5, bonus_name, 1, 2, 1024, 768);
603 sprintf (string, "%d", (int)bonusvalue);
604 glColor4f(0, 0, 0, 1 - bonustime);
605 text->glPrintOutline(1024 / 2 - 10 * strlen(string) - 4, 768 / 16 - 4 - 20 + 768 * 4 / 5, string, 1, 2.5 * .8, 1024, 768);
606 glColor4f(1, 0, 0, 1 - bonustime);
607 text->glPrint(1024 / 2 - 10 * strlen(string), 768 / 16 - 20 + 768 * 4 / 5, string, 1, 2 * .8, 1024, 768);
608 glColor4f(.5, .5, .5, 1);
611 if (tutoriallevel == 1) {
612 tutorialopac = tutorialmaxtime - tutorialstagetime;
613 if (tutorialopac > 1)
615 if (tutorialopac < 0)
618 sprintf (string, " ");
619 sprintf (string2, " ");
620 sprintf (string3, " ");
621 if (tutorialstage == 0) {
622 sprintf (string, " ");
623 sprintf (string2, " ");
624 sprintf (string3, " ");
626 if (tutorialstage == 1) {
627 sprintf (string, "Welcome to the Lugaru training level!");
628 sprintf (string2, " ");
629 sprintf (string3, " ");
631 if (tutorialstage == 2) {
632 sprintf (string, "BASIC MOVEMENT:");
633 sprintf (string2, " ");
634 sprintf (string3, " ");
636 if (tutorialstage == 3) {
637 sprintf (string, "You can move the mouse to rotate the camera.");
638 sprintf (string2, " ");
639 sprintf (string3, " ");
641 if (tutorialstage == 4) {
642 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));
643 sprintf (string2, "All movement is relative to the camera.");
644 sprintf (string3, " ");
646 if (tutorialstage == 5) {
647 sprintf (string, "Please press %s to jump.", Input::keyToChar(jumpkey));
648 sprintf (string2, "You can hold it longer to jump higher.");
649 sprintf (string3, " ");
651 if (tutorialstage == 6) {
652 sprintf (string, "You can press %s to crouch.", Input::keyToChar(crouchkey));
653 sprintf (string2, "You can jump higher from a crouching position.");
654 sprintf (string3, " ");
656 if (tutorialstage == 7) {
657 sprintf (string, "While running, you can press %s to roll.", Input::keyToChar(crouchkey));
658 sprintf (string2, " ");
659 sprintf (string3, " ");
661 if (tutorialstage == 8) {
662 sprintf (string, "While crouching, you can sneak around silently");
663 sprintf (string2, "using the movement keys.");
664 sprintf (string3, " ");
666 if (tutorialstage == 9) {
667 sprintf (string, "Release the crouch key while sneaking and hold the movement keys");
668 sprintf (string2, "to run animal-style.");
669 sprintf (string3, " ");
671 if (tutorialstage == 10) {
672 sprintf (string, "ADVANCED MOVEMENT:");
673 sprintf (string2, " ");
674 sprintf (string3, " ");
676 if (tutorialstage == 11) {
677 sprintf (string, "When you jump at a wall, you can hold %s again", Input::keyToChar(jumpkey));
678 sprintf (string2, "during impact to perform a walljump.");
679 sprintf (string3, "Be sure to use the movement keys to press against the wall");
681 if (tutorialstage == 12) {
682 sprintf (string, "While in the air, you can press crouch to flip.");
683 sprintf (string2, "Walljumps and flips confuse enemies and give you more control.");
684 sprintf (string3, " ");
686 if (tutorialstage == 13) {
687 sprintf (string, "BASIC COMBAT:");
688 sprintf (string2, " ");
689 sprintf (string3, " ");
691 if (tutorialstage == 14) {
692 sprintf (string, "There is now an imaginary enemy");
693 sprintf (string2, "in the middle of the training area.");
694 sprintf (string3, " ");
696 if (tutorialstage == 15) {
697 if (attackkey == MOUSEBUTTON1)
698 sprintf (string, "Click to attack when you are near an enemy.");
700 sprintf (string, "Press %s to attack when you are near an enemy.", Input::keyToChar(attackkey));
701 sprintf (string2, "You can punch by standing still near an enemy and attacking.");
702 sprintf (string3, " ");
704 if (tutorialstage == 16) {
705 sprintf (string, "If you are close, you will perform a weak punch.");
706 sprintf (string2, "The weak punch is excellent for starting attack combinations.");
707 sprintf (string3, " ");
709 if (tutorialstage == 17) {
710 sprintf (string, "Attacking while running results in a spin kick.");
711 sprintf (string2, "This is one of your most powerful ground attacks.");
712 sprintf (string3, " ");
714 if (tutorialstage == 18) {
715 sprintf (string, "Sweep the enemy's legs out by attacking while crouched.");
716 sprintf (string2, "This is a very fast attack, and easy to follow up.");
717 sprintf (string3, " ");
719 if (tutorialstage == 19) {
720 sprintf (string, "When an enemy is on the ground, you can deal some extra");
721 sprintf (string2, "damage by running up and drop-kicking him.");
722 sprintf (string3, "(Try knocking them down with a sweep first)");
724 if (tutorialstage == 20) {
725 sprintf (string, "Your most powerful individual attack is the rabbit kick.");
726 if (attackkey == MOUSEBUTTON1)
727 sprintf (string2, "Run at the enemy while holding the mouse button, and press");
729 sprintf (string2, "Run at the enemy while holding %s, and press", Input::keyToChar(attackkey));
730 sprintf (string3, "the jump key (%s) to attack.", Input::keyToChar(jumpkey));
732 if (tutorialstage == 21) {
733 sprintf (string, "This attack is devastating if timed correctly.");
734 sprintf (string2, "Even if timed incorrectly, it will knock the enemy over.");
736 sprintf (string3, "Try rabbit-kicking the imaginary enemy again.");
738 sprintf (string3, "Try rabbit-kicking the imaginary enemy.");
740 if (tutorialstage == 22) {
741 sprintf (string, "If you sneak behind an enemy unnoticed, you can kill");
742 sprintf (string2, "him instantly. Move close behind this enemy");
743 sprintf (string3, "and attack.");
745 if (tutorialstage == 23) {
746 sprintf (string, "Another important attack is the wall kick. When an enemy");
747 sprintf (string2, "is near a wall, perform a walljump nearby and hold");
748 sprintf (string3, "the attack key during impact with the wall.");
750 if (tutorialstage == 24) {
751 sprintf (string, "You can tackle enemies by running at them animal-style");
752 if (attackkey == MOUSEBUTTON1)
753 sprintf (string2, "and pressing jump (%s) or attack(mouse button).", Input::keyToChar(jumpkey));
755 sprintf (string2, "and pressing jump (%s) or attack(%s).", Input::keyToChar(jumpkey), Input::keyToChar(attackkey));
756 sprintf (string3, "This is especially useful when they are running away.");
758 if (tutorialstage == 25) {
759 sprintf (string, "Dodge by pressing back and attack. Dodging is essential");
760 sprintf (string2, "against enemies with swords or other long weapons.");
761 sprintf (string3, " ");
763 if (tutorialstage == 26) {
764 sprintf (string, "REVERSALS AND COUNTER-REVERSALS");
765 sprintf (string2, " ");
766 sprintf (string3, " ");
768 if (tutorialstage == 27) {
769 sprintf (string, "The enemy can now reverse your attacks.");
770 sprintf (string2, " ");
771 sprintf (string3, " ");
773 if (tutorialstage == 28) {
774 sprintf (string, "If you attack, you will notice that the enemy now sometimes");
775 sprintf (string2, "catches your attack and uses it against you. Hold");
776 sprintf (string3, "crouch (%s) after attacking to escape from reversals.", Input::keyToChar(crouchkey));
778 if (tutorialstage == 29) {
779 sprintf (string, "Try escaping from two more reversals in a row.");
780 sprintf (string2, " ");
781 sprintf (string3, " ");
783 if (tutorialstage == 30) {
784 sprintf (string, "Good!");
785 sprintf (string2, " ");
786 sprintf (string3, " ");
788 if (tutorialstage == 31) {
789 sprintf (string, "To reverse an attack, you must tap crouch (%s) during the", Input::keyToChar(crouchkey));
790 sprintf (string2, "enemy's attack. You must also be close to the enemy;");
791 sprintf (string3, "this is especially important against armed opponents.");
793 if (tutorialstage == 32) {
794 sprintf (string, "The enemy can attack in %d seconds.", (int)(tutorialmaxtime - tutorialstagetime));
795 sprintf (string2, "This imaginary opponents attacks will be highlighted");
796 sprintf (string3, "to make this easier.");
798 if (tutorialstage == 33) {
799 sprintf (string, "Reverse three enemy attacks!");
800 sprintf (string2, " ");
801 sprintf (string3, " ");
803 if (tutorialstage == 34) {
804 sprintf (string, "Reverse two more enemy attacks!");
805 sprintf (string2, " ");
806 sprintf (string3, " ");
808 if (tutorialstage == 35) {
809 sprintf (string, "Reverse one more enemy attack!");
810 sprintf (string2, " ");
811 sprintf (string3, " ");
813 if (tutorialstage == 36) {
814 sprintf (string, "Excellent!");
815 sprintf (string2, " ");
816 sprintf (string3, " ");
818 if (tutorialstage == 37) {
819 sprintf (string, "Now spar with the enemy for %d more seconds.", (int)(tutorialmaxtime - tutorialstagetime));
820 sprintf (string2, "Damage dealt: %d", (int)damagedealt);
821 sprintf (string3, "Damage taken: %d.", (int)damagetaken);
823 if (tutorialstage == 38) {
824 sprintf (string, "WEAPONS:");
825 sprintf (string2, " ");
826 sprintf (string3, " ");
828 if (tutorialstage == 39) {
829 sprintf (string, "There is now an imaginary knife");
830 sprintf (string2, "in the center of the training area.");
831 sprintf (string3, " ");
833 if (tutorialstage == 40) {
834 sprintf (string, "Stand, roll or handspring over the knife");
835 sprintf (string2, "while pressing %s to pick it up.", Input::keyToChar(throwkey));
836 sprintf (string3, "You can crouch and press the same key to drop it again.");
838 if (tutorialstage == 41) {
839 sprintf (string, "You can equip and unequip weapons using the %s key.", Input::keyToChar(drawkey));
840 sprintf (string2, "Sometimes it is best to keep them unequipped to");
841 sprintf (string3, "prevent enemies from taking them. ");
843 if (tutorialstage == 42) {
844 sprintf (string, "The knife is the smallest weapon and the least encumbering.");
845 sprintf (string2, "You can equip or unequip it while standing, crouching,");
846 sprintf (string3, "running or flipping.");
848 if (tutorialstage == 43) {
849 sprintf (string, "You perform weapon attacks the same way as unarmed attacks,");
850 sprintf (string2, "but sharp weapons cause permanent damage, instead of the");
851 sprintf (string3, "temporary trauma from blunt weapons, fists and feet.");
853 if (tutorialstage == 44) {
854 sprintf (string, "The enemy now has your knife!");
855 sprintf (string2, "Please reverse two of his knife attacks.");
856 sprintf (string3, " ");
858 if (tutorialstage == 45) {
859 sprintf (string, "Please reverse one more of his knife attacks.");
860 sprintf (string2, " ");
861 sprintf (string3, " ");
863 if (tutorialstage == 46) {
864 sprintf (string, "Now he has a sword!");
865 sprintf (string2, "The sword has longer reach than your arms, so you");
866 sprintf (string3, "must move close to reverse the sword slash.");
868 if (tutorialstage == 47) {
869 sprintf (string, "Long weapons like the sword and staff are also useful for defense;");
870 sprintf (string2, "you can parry enemy weapon attacks by pressing the attack key");
871 sprintf (string3, "at the right time. Please try parrying the enemy's attacks!");
873 if (tutorialstage == 48) {
874 sprintf (string, "The staff is like the sword, but has two main attacks.");
875 sprintf (string2, "The standing smash is fast and effective, and the running");
876 sprintf (string3, "spin smash is slower and more powerful.");
878 if (tutorialstage == 49) {
879 sprintf (string, "When facing an enemy, you can throw the knife with %s.", Input::keyToChar(throwkey));
880 sprintf (string2, "It is possible to throw the knife while flipping,");
881 sprintf (string3, "but it is very inaccurate.");
883 if (tutorialstage == 50) {
884 sprintf (string, "You now know everything you can learn from training.");
885 sprintf (string2, "Everything else you must learn from experience!");
886 sprintf (string3, " ");
888 if (tutorialstage == 51) {
889 sprintf (string, "Walk out of the training area to return to the main menu.");
890 sprintf (string2, " ");
891 sprintf (string3, " ");
894 glColor4f(0, 0, 0, tutorialopac);
895 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);
896 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);
897 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);
898 glColor4f(1, 1, 1, tutorialopac);
899 text->glPrint(screenwidth / 2 - 7.6 * strlen(string)*screenwidth / 1024, screenheight / 16 + screenheight * 4 / 5, string, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight);
900 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);
901 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);
903 sprintf (string, "Press 'tab' to skip to the next item.");
904 sprintf (string2, "Press escape at any time to");
905 sprintf (string3, "pause or exit the tutorial.");
907 glColor4f(0, 0, 0, 1);
908 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);
909 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);
910 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);
911 glColor4f(0.5, 0.5, 0.5, 1);
912 text->glPrint(screenwidth / 2 - 7.6 * strlen(string)*screenwidth / 1024 * .8, 0 + screenheight * 1 / 10, string, 1, 1.5 * screenwidth / 1024 * .8, screenwidth, screenheight);
913 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);
914 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);
918 if (numhotspots && (bonustime >= 1 || bonus <= 0 || bonustime < 0) && !tutoriallevel) {
919 float closestdist = -1;
921 int closest = currenthotspot;
922 for (int i = 0; i < numhotspots; i++) {
923 distance = distsq(&Person::players[0]->coords, &hotspot[i]);
924 if (closestdist == -1 || distance < closestdist) {
925 if (distsq(&Person::players[0]->coords, &hotspot[i]) < hotspotsize[i] && ((hotspottype[i] <= 10 && hotspottype[i] >= 0) || (hotspottype[i] <= 40 && hotspottype[i] >= 20))) {
926 closestdist = distance;
932 currenthotspot = closest;
933 if (currenthotspot != -1) {
934 if (hotspottype[closest] <= 10) {
935 if (distsq(&Person::players[0]->coords, &hotspot[closest]) < hotspotsize[closest])
936 tutorialstagetime = 0;
938 tutorialopac = tutorialmaxtime - tutorialstagetime;
939 if (tutorialopac > 1)
941 if (tutorialopac < 0)
944 sprintf (string, "%s", hotspottext[closest]);
951 if (string[i] == '\n' || string[i] > 'z' || string[i] < ' ' || string[i] == '\0') {
952 glColor4f(0, 0, 0, tutorialopac);
953 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);
954 glColor4f(1, 1, 1, tutorialopac);
955 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);
958 if (string[i] == '\0')
965 } else if (hotspottype[closest] >= 20 && dialoguegonethrough[hotspottype[closest] - 20] == 0) {
966 whichdialogue = hotspottype[closest] - 20;
967 for (int j = 0; j < numdialogueboxes[whichdialogue]; j++) {
968 Person::players[participantfocus[whichdialogue][j]]->coords = participantlocation[whichdialogue][participantfocus[whichdialogue][j]];
969 Person::players[participantfocus[whichdialogue][j]]->yaw = participantyaw[whichdialogue][participantfocus[whichdialogue][j]];
970 Person::players[participantfocus[whichdialogue][j]]->targetyaw = participantyaw[whichdialogue][participantfocus[whichdialogue][j]];
971 Person::players[participantfocus[whichdialogue][j]]->velocity = 0;
972 Person::players[participantfocus[whichdialogue][j]]->animTarget = Person::players[participantfocus[whichdialogue][j]]->getIdle();
973 Person::players[participantfocus[whichdialogue][j]]->frameTarget = 0;
977 dialoguegonethrough[whichdialogue]++;
978 if (dialogueboxsound[whichdialogue][indialogue] != 0) {
980 if (dialogueboxsound[whichdialogue][indialogue] == 1) whichsoundplay = rabbitchitter;
981 if (dialogueboxsound[whichdialogue][indialogue] == 2) whichsoundplay = rabbitchitter2;
982 if (dialogueboxsound[whichdialogue][indialogue] == 3) whichsoundplay = rabbitpainsound;
983 if (dialogueboxsound[whichdialogue][indialogue] == 4) whichsoundplay = rabbitpain1sound;
984 if (dialogueboxsound[whichdialogue][indialogue] == 5) whichsoundplay = rabbitattacksound;
985 if (dialogueboxsound[whichdialogue][indialogue] == 6) whichsoundplay = rabbitattack2sound;
986 if (dialogueboxsound[whichdialogue][indialogue] == 7) whichsoundplay = rabbitattack3sound;
987 if (dialogueboxsound[whichdialogue][indialogue] == 8) whichsoundplay = rabbitattack4sound;
988 if (dialogueboxsound[whichdialogue][indialogue] == 9) whichsoundplay = growlsound;
989 if (dialogueboxsound[whichdialogue][indialogue] == 10) whichsoundplay = growl2sound;
990 if (dialogueboxsound[whichdialogue][indialogue] == 11) whichsoundplay = snarlsound;
991 if (dialogueboxsound[whichdialogue][indialogue] == 12) whichsoundplay = snarl2sound;
992 if (dialogueboxsound[whichdialogue][indialogue] == 13) whichsoundplay = barksound;
993 if (dialogueboxsound[whichdialogue][indialogue] == 14) whichsoundplay = bark2sound;
994 if (dialogueboxsound[whichdialogue][indialogue] == 15) whichsoundplay = bark3sound;
995 if (dialogueboxsound[whichdialogue][indialogue] == 16) whichsoundplay = barkgrowlsound;
996 if (dialogueboxsound[whichdialogue][indialogue] == -1) whichsoundplay = fireendsound;
997 if (dialogueboxsound[whichdialogue][indialogue] == -2) whichsoundplay = firestartsound;
998 if (dialogueboxsound[whichdialogue][indialogue] == -3) whichsoundplay = consolesuccesssound;
999 if (dialogueboxsound[whichdialogue][indialogue] == -4) whichsoundplay = consolefailsound;
1000 emit_sound_at(whichsoundplay, Person::players[participantfocus[whichdialogue][indialogue]]->coords);
1006 if (indialogue != -1 && !mainmenu) {
1007 glDisable(GL_DEPTH_TEST);
1008 glDisable(GL_CULL_FACE);
1009 glDisable(GL_LIGHTING);
1010 glDisable(GL_TEXTURE_2D);
1012 glMatrixMode(GL_PROJECTION);
1015 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1016 glMatrixMode(GL_MODELVIEW);
1019 if (dialogueboxlocation[whichdialogue][indialogue] == 1)
1020 glTranslatef(0, screenheight * 3 / 4, 0);
1021 glScalef(screenwidth, screenheight / 4, 1);
1022 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1025 glColor4f(dialogueboxcolor[whichdialogue][indialogue][0], dialogueboxcolor[whichdialogue][indialogue][1], dialogueboxcolor[whichdialogue][indialogue][2], 0.7);
1027 glVertex3f(0, 0, 0.0f);
1028 glVertex3f(1, 0, 0.0f);
1029 glVertex3f(1, 1, 0.0f);
1030 glVertex3f(0, 1, 0.0f);
1032 glMatrixMode(GL_PROJECTION);
1034 glMatrixMode(GL_MODELVIEW);
1036 glEnable(GL_DEPTH_TEST);
1037 glEnable(GL_CULL_FACE);
1038 glDisable(GL_BLEND);
1040 glEnable(GL_TEXTURE_2D);
1047 startx = screenwidth * 1 / 5;
1048 if (dialogueboxlocation[whichdialogue][indialogue] == 1)
1049 starty = screenheight / 16 + screenheight * 4 / 5;
1050 if (dialogueboxlocation[whichdialogue][indialogue] == 2)
1051 starty = screenheight * 1 / 5 - screenheight / 16;
1056 for (int i = 0; i < 264; i++) {
1060 for (int i = 0; i < (int)strlen(dialoguename[whichdialogue][indialogue]); i++) {
1061 tempname[tempnum] = dialoguename[whichdialogue][indialogue][i];
1063 if (dialoguename[whichdialogue][indialogue][i] == '#' || dialoguename[whichdialogue][indialogue][i] == '\0')
1068 tempname[tempnum] = '\0';
1071 sprintf (string, "%s: ", tempname);
1073 if (dialogueboxcolor[whichdialogue][indialogue][0] + dialogueboxcolor[whichdialogue][indialogue][1] + dialogueboxcolor[whichdialogue][indialogue][2] < 1.5) {
1074 glColor4f(0, 0, 0, tutorialopac);
1075 text->glPrintOutline(startx - 2 * 7.6 * strlen(string)*screenwidth / 1024 - 4, starty - 4, string, 1, 1.5 * 1.25 * screenwidth / 1024, screenwidth, screenheight);
1076 glColor4f(0.7, 0.7, 0.7, tutorialopac);
1077 text->glPrint(startx - 2 * 7.6 * strlen(string)*screenwidth / 1024, starty, string, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight);
1079 glColor4f(0, 0, 0, tutorialopac);
1080 text->glPrintOutline(startx - 2 * 7.6 * strlen(string)*screenwidth / 1024 - 4, starty - 4, string, 1, 1.5 * 1.25 * screenwidth / 1024, screenwidth, screenheight);
1084 for (int i = 0; i < (int)strlen(dialoguetext[whichdialogue][indialogue]) + 1; i++) {
1085 tempname[tempnum] = dialoguetext[whichdialogue][indialogue][i];
1086 if (dialoguetext[whichdialogue][indialogue][i] != '#')
1090 sprintf (string, "%s", tempname);
1097 if (string[i] == '\n' || string[i] > 'z' || string[i] < ' ' || string[i] == '\0') {
1098 if (dialogueboxcolor[whichdialogue][indialogue][0] + dialogueboxcolor[whichdialogue][indialogue][1] + dialogueboxcolor[whichdialogue][indialogue][2] < 1.5) {
1099 glColor4f(0, 0, 0, tutorialopac);
1100 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);
1101 glColor4f(1, 1, 1, tutorialopac);
1102 text->glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/, starty - 20 * screenwidth / 1024 * line, string, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight, lastline, i);
1104 glColor4f(0, 0, 0, tutorialopac);
1105 text->glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/, starty - 20 * screenwidth / 1024 * line, string, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight, lastline, i);
1109 if (string[i] == '\0')
1118 if (!tutoriallevel && !winfreeze && indialogue == -1 && !mainmenu) {
1121 sprintf (string, "Score: %d", (int)accountactive->getCampaignScore());
1123 sprintf (string, "Score: %d", (int)accountactive->getCampaignScore() + (int)bonustotal);
1126 sprintf (string, "Score: %d", (int)bonustotal);
1127 glColor4f(0, 0, 0, 1);
1128 text->glPrintOutline(1024 / 40 - 4, 768 / 16 - 4 + 768 * 14 / 16, string, 1, 1.5 * 1.25, 1024, 768);
1129 glColor4f(1, 0, 0, 1);
1130 text->glPrint(1024 / 40, 768 / 16 + 768 * 14 / 16, string, 1, 1.5, 1024, 768);
1131 if (showdamagebar) {
1132 glDisable(GL_DEPTH_TEST);
1133 glDisable(GL_CULL_FACE);
1134 glDisable(GL_LIGHTING);
1135 glDisable(GL_TEXTURE_2D);
1137 glMatrixMode(GL_PROJECTION);
1140 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1141 glMatrixMode(GL_MODELVIEW);
1144 glTranslatef(15, screenheight * 17.5 / 20, 0);
1145 glScalef(screenwidth / 3 + 20, screenheight / 20, 1);
1146 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1148 glColor4f(0.0, 0.4, 0.0, 0.7);
1149 float bar = ((float)Person::players[0]->damage) / Person::players[0]->damagetolerance;
1151 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
1152 glVertex3f(1, 0, 0.0f);
1153 glVertex3f(1, 1, 0.0f);
1154 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
1156 glColor4f(0.1, 0.0, 0.0, 1);
1157 bar = ((float)Person::players[0]->bloodloss) / Person::players[0]->damagetolerance;
1159 glVertex3f(0, 0, 0.0f);
1160 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
1161 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
1162 glVertex3f(0, 1, 0.0f);
1164 glColor4f(0.4, 0.0, 0.0, 0.7);
1165 bar = ((float)Person::players[0]->damage) / Person::players[0]->damagetolerance;
1167 glVertex3f(0, 0, 0.0f);
1168 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
1169 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
1170 glVertex3f(0, 1, 0.0f);
1172 glColor4f(0.4, 0.0, 0.0, 0.7);
1173 bar = ((float)Person::players[0]->permanentdamage) / Person::players[0]->damagetolerance;
1175 glVertex3f(0, 0, 0.0f);
1176 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
1177 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
1178 glVertex3f(0, 1, 0.0f);
1180 glColor4f(0.4, 0.0, 0.0, 0.7);
1181 bar = ((float)Person::players[0]->superpermanentdamage) / Person::players[0]->damagetolerance;
1183 glVertex3f(0, 0, 0.0f);
1184 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
1185 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
1186 glVertex3f(0, 1, 0.0f);
1188 glColor4f(0.0, 0.0, 0.0, 0.7);
1190 glBegin(GL_LINE_STRIP);
1191 glVertex3f(0, 0, 0.0f);
1192 glVertex3f(1, 0, 0.0f);
1193 glVertex3f(1, 1, 0.0f);
1194 glVertex3f(0, 1, 0.0f);
1195 glVertex3f(0, 0, 0.0f);
1198 glMatrixMode(GL_PROJECTION);
1200 glMatrixMode(GL_MODELVIEW);
1202 glEnable(GL_DEPTH_TEST);
1203 glEnable(GL_CULL_FACE);
1204 glDisable(GL_BLEND);
1206 glEnable(GL_TEXTURE_2D);
1208 // writing the numbers :
1209 sprintf (string, "Damages : %d/%d (%d)", (int)(Person::players[0]->damage), (int)(Person::players[0]->damagetolerance), (int)(Person::players[0]->bloodloss));
1210 glColor4f(0, 0, 0, 1);
1211 text->glPrintOutline(1024 / 40 - 4, 768 / 16 - 4 + 768 * 14 / 16 - 40, string, 1, 1.5 * 1.25, 1024, 768);
1212 glColor4f(1, 0, 0, 1);
1213 text->glPrint(1024 / 40, 768 / 16 + 768 * 14 / 16 - 40, string, 1, 1.5, 1024, 768);
1217 glColor4f(.5, .5, .5, 1);
1220 if ((texttoggle || editorenabled) && debugmode && !mainmenu) {
1221 sprintf (string, "The framespersecond is %d.", (int)(fps));
1222 text->glPrint(10, 30, string, 0, .8, 1024, 768);
1225 sprintf (string, "Map editor enabled.");
1227 sprintf (string, "Map editor disabled.");
1228 text->glPrint(10, 60, string, 0, .8, 1024, 768);
1229 if (editorenabled) {
1230 sprintf (string, "Object size: %f", editorsize);
1231 text->glPrint(10, 75, string, 0, .8, 1024, 768);
1233 sprintf (string, "Object yaw: %f", editoryaw);
1235 sprintf (string, "Object yaw: Random");
1236 text->glPrint(10, 90, string, 0, .8, 1024, 768);
1237 if (editorpitch >= 0)
1238 sprintf (string, "Object pitch: %f", editorpitch);
1240 sprintf (string, "Object pitch: Random");
1241 text->glPrint(10, 105, string, 0, .8, 1024, 768);
1242 sprintf (string, "Object type: %d", editortype);
1243 text->glPrint(10, 120, string, 0, .8, 1024, 768);
1244 switch (editortype) {
1246 sprintf (string, "(box)");
1249 sprintf (string, "(tree)");
1252 sprintf (string, "(wall)");
1255 sprintf (string, "(weird)");
1258 sprintf (string, "(spike)");
1261 sprintf (string, "(rock)");
1264 sprintf (string, "(bush)");
1267 sprintf (string, "(tunnel)");
1270 sprintf (string, "(chimney)");
1273 sprintf (string, "(platform)");
1276 sprintf (string, "(cool)");
1279 sprintf (string, "(fire)");
1282 text->glPrint(130, 120, string, 0, .8, 1024, 768);
1284 sprintf (string, "Numplayers: %lu", Person::players.size());
1285 text->glPrint(10, 155, string, 0, .8, 1024, 768);
1286 sprintf (string, "Player %d: numwaypoints: %d", (int(Person::players.size()) - 1), Person::players.back()->numwaypoints);
1287 text->glPrint(10, 140, string, 0, .8, 1024, 768);
1289 sprintf (string, "Difficulty: %d", difficulty);
1290 text->glPrint(10, 240, string, 0, .8, 1024, 768);
1295 if (drawmode == glowmode) {
1296 glDisable(GL_DEPTH_TEST);
1297 glDisable(GL_CULL_FACE);
1298 glDisable(GL_LIGHTING);
1299 glDisable(GL_TEXTURE_2D);
1301 glMatrixMode(GL_PROJECTION);
1304 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1305 glMatrixMode(GL_MODELVIEW);
1308 glScalef(screenwidth, screenheight, 1);
1309 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1311 glColor4f(0, 0, 0, .5);
1313 glVertex3f(0, 0, 0.0f);
1314 glVertex3f(256, 0, 0.0f);
1315 glVertex3f(256, 256, 0.0f);
1316 glVertex3f(0, 256, 0.0f);
1318 glMatrixMode(GL_PROJECTION);
1320 glMatrixMode(GL_MODELVIEW);
1322 glEnable(GL_DEPTH_TEST);
1323 glEnable(GL_CULL_FACE);
1324 glDisable(GL_BLEND);
1328 if ((((blackout && damageeffects) || (Person::players[0]->bloodloss > 0 && damageeffects && Person::players[0]->blooddimamount > 0) || Person::players[0]->dead) && !cameramode) || console) {
1329 glDisable(GL_DEPTH_TEST);
1330 glDisable(GL_CULL_FACE);
1331 glDisable(GL_LIGHTING);
1332 glDisable(GL_TEXTURE_2D);
1334 glMatrixMode(GL_PROJECTION);
1337 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1338 glMatrixMode(GL_MODELVIEW);
1341 glScalef(screenwidth, screenheight, 1);
1342 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1344 if (Person::players[0]->dead)
1345 blackout += multiplier * 3;
1346 if (Person::players[0]->dead == 1)
1348 if (Person::players[0]->dead == 2 && blackout > .6)
1350 glColor4f(0, 0, 0, blackout);
1351 if (!Person::players[0]->dead) {
1352 if ((Person::players[0]->bloodloss / Person::players[0]->damagetolerance * (sin(woozy) / 4 + .5))*.3 < .3) {
1353 glColor4f(0, 0, 0, Person::players[0]->blooddimamount * Person::players[0]->bloodloss / Person::players[0]->damagetolerance * (sin(woozy) / 4 + .5)*.3);
1354 blackout = Person::players[0]->blooddimamount * Person::players[0]->bloodloss / Person::players[0]->damagetolerance * (sin(woozy) / 4 + .5) * .3;
1356 glColor4f(0, 0, 0, Person::players[0]->blooddimamount * .3);
1357 blackout = Person::players[0]->blooddimamount * .3;
1361 glColor4f(.7, 0, 0, .2);
1363 glVertex3f(0, 0, 0.0f);
1364 glVertex3f(256, 0, 0.0f);
1365 glVertex3f(256, 256, 0.0f);
1366 glVertex3f(0, 256, 0.0f);
1368 glMatrixMode(GL_PROJECTION);
1370 glMatrixMode(GL_MODELVIEW);
1372 glEnable(GL_DEPTH_TEST);
1373 glEnable(GL_CULL_FACE);
1374 glDisable(GL_BLEND);
1378 if (flashamount > 0 && damageeffects) {
1379 if (flashamount > 1)
1381 if (flashdelay <= 0)
1382 flashamount -= multiplier;
1384 if (flashamount < 0)
1386 glDisable(GL_DEPTH_TEST);
1387 glDisable(GL_CULL_FACE);
1388 glDisable(GL_LIGHTING);
1390 glMatrixMode(GL_PROJECTION);
1393 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1394 glMatrixMode(GL_MODELVIEW);
1397 glScalef(screenwidth, screenheight, 1);
1398 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1400 glColor4f(flashr, flashg, flashb, flashamount);
1402 glVertex3f(0, 0, 0.0f);
1403 glVertex3f(256, 0, 0.0f);
1404 glVertex3f(256, 256, 0.0f);
1405 glVertex3f(0, 256, 0.0f);
1407 glMatrixMode(GL_PROJECTION);
1409 glMatrixMode(GL_MODELVIEW);
1411 glEnable(GL_DEPTH_TEST);
1412 glEnable(GL_CULL_FACE);
1413 glDisable(GL_BLEND);
1419 glEnable(GL_TEXTURE_2D);
1420 glColor4f(1, 1, 1, 1);
1421 for (unsigned i = 1; i < 15; i++)
1422 if (displaytime[i] < 4)
1423 for (unsigned j = 0; j < displaytext[i].size(); j++) {
1424 glColor4f(1, 1, 1, 4 - displaytime[i]);
1425 sprintf (string, "%c", displaytext[i][j]);
1426 text->glPrint(30 + j * 10, 30 + i * 20 + (screenheight - 330), string, 0, 1, screenwidth, screenheight);
1430 if (difficulty < 2 && indialogue == -1) { // minimap
1431 float mapviewdist = 20000;
1433 glDisable(GL_DEPTH_TEST);
1434 glColor3f (1.0, 1.0, 1.0); // no coloring
1436 glEnable(GL_TEXTURE_2D);
1437 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1438 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1439 glDisable(GL_DEPTH_TEST);
1440 glDisable(GL_CULL_FACE);
1441 glDisable(GL_LIGHTING);
1443 glMatrixMode(GL_PROJECTION);
1446 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1447 glMatrixMode(GL_MODELVIEW);
1450 glScalef((float)screenwidth / 2, (float)screenwidth / 2, 1);
1451 glTranslatef(1.75, .25, 0);
1452 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1454 glColor4f(1, 1, 1, 1);
1460 int numliveplayers = 0;
1462 for (unsigned i = 0; i < Person::players.size(); i++) {
1463 if (!Person::players[i]->dead)
1469 for (int i = 0; i < objects.numobjects; i++) {
1470 if (objects.type[i] == treetrunktype || objects.type[i] == boxtype) {
1471 center += objects.position[i];
1475 for (unsigned i = 0; i < Person::players.size(); i++) {
1476 if (!Person::players[i]->dead)
1477 center += Person::players[i]->coords;
1479 center /= numadd + numliveplayers;
1481 center = Person::players[0]->coords;
1483 float maxdistance = 0;
1485 //~ int whichclosest;
1486 for (int i = 0; i < objects.numobjects; i++) {
1487 tempdist = distsq(¢er, &objects.position[i]);
1488 if (tempdist > maxdistance) {
1490 maxdistance = tempdist;
1493 for (unsigned i = 0; i < Person::players.size(); i++) {
1494 if (!Person::players[i]->dead) {
1495 tempdist = distsq(¢er, &Person::players[i]->coords);
1496 if (tempdist > maxdistance) {
1498 maxdistance = tempdist;
1504 glScalef(.25 / radius * 256 * terrain.scale * .4, .25 / radius * 256 * terrain.scale * .4, 1);
1506 glScalef(1 / (1 / radius * 256 * terrain.scale * .4), 1 / (1 / radius * 256 * terrain.scale * .4), 1);
1508 glRotatef(Person::players[0]->lookyaw * -1 + 180, 0, 0, 1);
1509 glTranslatef(-(center.x / terrain.scale / 256 * -2 + 1), (center.z / terrain.scale / 256 * -2 + 1), 0);
1510 for (int i = 0; i < objects.numobjects; i++) {
1511 if (objects.type[i] == treetrunktype) {
1512 distcheck = distsq(&Person::players[0]->coords, &objects.position[i]);
1513 if (distcheck < mapviewdist) {
1514 Mapcircletexture.bind();
1515 glColor4f(0, .3, 0, opac * (1 - distcheck / mapviewdist));
1517 glTranslatef(objects.position[i].x / terrain.scale / 256 * -2 + 1, objects.position[i].z / terrain.scale / 256 * 2 - 1, 0);
1518 glRotatef(objects.yaw[i], 0, 0, 1);
1519 glScalef(.003, .003, .003);
1522 glVertex3f(-1, -1, 0.0f);
1524 glVertex3f(1, -1, 0.0f);
1526 glVertex3f(1, 1, 0.0f);
1528 glVertex3f(-1, 1, 0.0f);
1533 if (objects.type[i] == boxtype) {
1534 distcheck = distsq(&Person::players[0]->coords, &objects.position[i]);
1535 if (distcheck < mapviewdist) {
1536 Mapboxtexture.bind();
1537 glColor4f(.4, .4, .4, 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(.01 * objects.scale[i], .01 * objects.scale[i], .01 * objects.scale[i]);
1544 glVertex3f(-1, -1, 0.0f);
1546 glVertex3f(1, -1, 0.0f);
1548 glVertex3f(1, 1, 0.0f);
1550 glVertex3f(-1, 1, 0.0f);
1556 if (editorenabled) {
1557 Mapcircletexture.bind();
1558 for (int i = 0; i < numboundaries; i++) {
1559 glColor4f(0, 0, 0, opac / 3);
1561 glTranslatef(boundary[i].x / terrain.scale / 256 * -2 + 1, boundary[i].z / terrain.scale / 256 * 2 - 1, 0);
1562 glScalef(.002, .002, .002);
1565 glVertex3f(-1, -1, 0.0f);
1567 glVertex3f(1, -1, 0.0f);
1569 glVertex3f(1, 1, 0.0f);
1571 glVertex3f(-1, 1, 0.0f);
1576 for (unsigned i = 0; i < Person::players.size(); i++) {
1577 distcheck = distsq(&Person::players[0]->coords, &Person::players[i]->coords);
1578 if (distcheck < mapviewdist) {
1580 Maparrowtexture.bind();
1582 glColor4f(1, 1, 1, opac);
1583 else if (Person::players[i]->dead == 2 || Person::players[i]->howactive > typesleeping)
1584 glColor4f(0, 0, 0, opac * (1 - distcheck / mapviewdist));
1585 else if (Person::players[i]->dead)
1586 glColor4f(.3, .3, .3, opac * (1 - distcheck / mapviewdist));
1587 else if (Person::players[i]->aitype == attacktypecutoff)
1588 glColor4f(1, 0, 0, opac * (1 - distcheck / mapviewdist));
1589 else if (Person::players[i]->aitype == passivetype)
1590 glColor4f(0, 1, 0, opac * (1 - distcheck / mapviewdist));
1592 glColor4f(1, 1, 0, 1);
1593 glTranslatef(Person::players[i]->coords.x / terrain.scale / 256 * -2 + 1, Person::players[i]->coords.z / terrain.scale / 256 * 2 - 1, 0);
1594 glRotatef(Person::players[i]->yaw + 180, 0, 0, 1);
1595 glScalef(.005, .005, .005);
1598 glVertex3f(-1, -1, 0.0f);
1600 glVertex3f(1, -1, 0.0f);
1602 glVertex3f(1, 1, 0.0f);
1604 glVertex3f(-1, 1, 0.0f);
1610 glDisable(GL_TEXTURE_2D);
1611 glMatrixMode(GL_PROJECTION);
1613 glMatrixMode(GL_MODELVIEW);
1615 glEnable(GL_DEPTH_TEST);
1616 glEnable(GL_CULL_FACE);
1617 glDisable(GL_BLEND);
1621 if (loading && !stealthloading && (!campaign || Person::players[0]->dead)) {
1622 glDisable(GL_DEPTH_TEST);
1623 glDisable(GL_CULL_FACE);
1624 glDisable(GL_LIGHTING);
1625 glDisable(GL_TEXTURE_2D);
1627 glMatrixMode(GL_PROJECTION);
1630 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1631 glMatrixMode(GL_MODELVIEW);
1634 glScalef(screenwidth, screenheight, 1);
1635 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1637 glColor4f(0, 0, 0, .7);
1639 glVertex3f(0, 0, 0.0f);
1640 glVertex3f(256, 0, 0.0f);
1641 glVertex3f(256, 256, 0.0f);
1642 glVertex3f(0, 256, 0.0f);
1644 glMatrixMode(GL_PROJECTION);
1646 glMatrixMode(GL_MODELVIEW);
1648 glEnable(GL_DEPTH_TEST);
1649 glEnable(GL_CULL_FACE);
1650 glDisable(GL_BLEND);
1654 glDisable(GL_DEPTH_TEST);
1655 glColor3f (1.0, 1.0, 1.0); // no coloring
1657 glEnable(GL_TEXTURE_2D);
1662 glEnable(GL_TEXTURE_2D);
1663 glColor4f(1, 1, 1, 1);
1664 sprintf (string, "Loading...");
1665 text->glPrint(1024 / 2 - 90, 768 / 2, string, 1, 2, 1024, 768);
1668 drawmode = normalmode;
1671 if (winfreeze && !campaign) {
1672 glDisable(GL_DEPTH_TEST);
1673 glDisable(GL_CULL_FACE);
1674 glDisable(GL_LIGHTING);
1675 glDisable(GL_TEXTURE_2D);
1677 glMatrixMode(GL_PROJECTION);
1680 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1681 glMatrixMode(GL_MODELVIEW);
1684 glScalef(screenwidth, screenheight, 1);
1685 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1687 glColor4f(0, 0, 0, .4);
1689 glVertex3f(0, 0, 0.0f);
1690 glVertex3f(256, 0, 0.0f);
1691 glVertex3f(256, 256, 0.0f);
1692 glVertex3f(0, 256, 0.0f);
1694 glMatrixMode(GL_PROJECTION);
1696 glMatrixMode(GL_MODELVIEW);
1698 glEnable(GL_DEPTH_TEST);
1699 glEnable(GL_CULL_FACE);
1700 glDisable(GL_BLEND);
1704 glDisable(GL_DEPTH_TEST);
1705 glColor3f (1.0, 1.0, 1.0); // no coloring
1707 glEnable(GL_TEXTURE_2D);
1709 //Win Screen Won Victory
1711 glEnable(GL_TEXTURE_2D);
1712 glColor4f(1, 1, 1, 1);
1713 sprintf (string, "Level Cleared!");
1714 text->glPrintOutlined(1024 / 2 - strlen(string) * 10, 768 * 7 / 8, string, 1, 2, 1024, 768);
1716 sprintf (string, "Score: %d", (int)(bonustotal - startbonustotal));
1717 text->glPrintOutlined(1024 / 30, 768 * 6 / 8, string, 1, 2, 1024, 768);
1720 sprintf (string, "Press Escape or Space to continue");
1722 sprintf (string, "Press Escape to return to menu or Space to continue");
1723 text->glPrintOutlined(640 / 2 - strlen(string) * 5, 480 * 1 / 16, string, 1, 1, 640, 480);
1727 for (int i = 0; i < 255; i++)
1729 sprintf (temp, "Time: %d:", (int)(((int)leveltime - (int)(leveltime) % 60) / 60));
1730 strcat(string, temp);
1731 if ((int)(leveltime) % 60 < 10)
1732 strcat(string, "0");
1733 sprintf (temp, "%d", (int)(leveltime) % 60);
1734 strcat(string, temp);
1735 text->glPrintOutlined(1024 / 30, 768 * 6 / 8 - 40, string, 1, 2, 1024, 768);
1738 int awards[award_count];
1739 int numawards = award_awards(awards);
1741 for (int i = 0; i < numawards && i < 6; i++)
1742 text->glPrintOutlined(1024 / 30, 768 * 6 / 8 - 90 - 40 * i, award_names[awards[i]], 1, 2, 1024, 768);
1745 if (drawmode != normalmode) {
1746 glEnable(GL_TEXTURE_2D);
1748 if (!drawtoggle || drawmode != realmotionblurmode || (drawtoggle == 2 || change == 1)) {
1749 if (screentexture) {
1751 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
1752 GLfloat subtractColor[4] = { 0.5, 0.5, 0.5, 0.0 };
1753 glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, subtractColor);
1754 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE);
1755 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_CONSTANT_EXT);
1756 glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 2.0f);
1758 glBindTexture( GL_TEXTURE_2D, screentexture);
1759 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1762 if ((drawtoggle || change == 1) && drawmode == realmotionblurmode) {
1763 if (screentexture2) {
1764 glBindTexture( GL_TEXTURE_2D, screentexture2);
1765 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1767 if (!screentexture2) {
1768 glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
1770 glGenTextures( 1, &screentexture2 );
1771 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
1773 glEnable(GL_TEXTURE_2D);
1774 glBindTexture( GL_TEXTURE_2D, screentexture2);
1775 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
1776 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
1778 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
1783 glClear(GL_DEPTH_BUFFER_BIT);
1784 Game::ReSizeGLScene(90, .1f);
1785 glViewport(0, 0, screenwidth, screenheight);
1787 if (drawmode != normalmode) {
1788 glDisable(GL_DEPTH_TEST);
1789 if (drawmode == motionblurmode) {
1790 glDrawBuffer(GL_FRONT);
1791 glReadBuffer(GL_BACK);
1793 glColor3f (1.0, 1.0, 1.0); // no coloring
1795 glEnable(GL_TEXTURE_2D);
1796 glBindTexture( GL_TEXTURE_2D, screentexture);
1797 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1798 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1799 glDisable(GL_DEPTH_TEST);
1800 glDisable(GL_CULL_FACE);
1801 glDisable(GL_LIGHTING);
1803 glMatrixMode(GL_PROJECTION);
1806 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1807 glMatrixMode(GL_MODELVIEW);
1810 glScalef((float)screenwidth / 2, (float)screenheight / 2, 1);
1811 glTranslatef(1, 1, 0);
1812 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1814 if (drawmode == motionblurmode) {
1815 if (motionbluramount < .2)
1816 motionbluramount = .2;
1817 glColor4f(1, 1, 1, motionbluramount);
1821 glVertex3f(-1, -1, 0.0f);
1822 glTexCoord2f(texcoordwidth, 0);
1823 glVertex3f(1, -1, 0.0f);
1824 glTexCoord2f(texcoordwidth, texcoordheight);
1825 glVertex3f(1, 1, 0.0f);
1826 glTexCoord2f(0, texcoordheight);
1827 glVertex3f(-1, 1, 0.0f);
1831 if (drawmode == realmotionblurmode) {
1832 glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
1833 glClear(GL_COLOR_BUFFER_BIT);
1834 glBlendFunc(GL_SRC_ALPHA, GL_ONE);
1835 glBindTexture( GL_TEXTURE_2D, screentexture);
1836 glColor4f(1, 1, 1, .5);
1840 glVertex3f(-1, -1, 0.0f);
1841 glTexCoord2f(texcoordwidth, 0);
1842 glVertex3f(1, -1, 0.0f);
1843 glTexCoord2f(texcoordwidth, texcoordheight);
1844 glVertex3f(1, 1, 0.0f);
1845 glTexCoord2f(0, texcoordheight);
1846 glVertex3f(-1, 1, 0.0f);
1849 glBindTexture( GL_TEXTURE_2D, screentexture2);
1850 glColor4f(1, 1, 1, .5);
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);
1863 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1865 if (drawmode == doublevisionmode) {
1866 static float crosseyedness;
1867 crosseyedness = abs(Person::players[0]->damage - Person::players[0]->superpermanentdamage - (Person::players[0]->damagetolerance - Person::players[0]->superpermanentdamage) * 1 / 2) / 30;
1868 if (crosseyedness > 1)
1870 if (crosseyedness < 0)
1872 glColor4f(1, 1, 1, 1);
1873 glDisable(GL_BLEND);
1878 glVertex3f(-1, -1, 0.0f);
1879 glTexCoord2f(texcoordwidth, 0);
1880 glVertex3f(1, -1, 0.0f);
1881 glTexCoord2f(texcoordwidth, texcoordheight);
1882 glVertex3f(1, 1, 0.0f);
1883 glTexCoord2f(0, texcoordheight);
1884 glVertex3f(-1, 1, 0.0f);
1887 if (crosseyedness) {
1888 glColor4f(1, 1, 1, .5);
1891 glTranslatef(.015 * crosseyedness, 0, 0);
1895 glVertex3f(-1, -1, 0.0f);
1896 glTexCoord2f(texcoordwidth, 0);
1897 glVertex3f(1, -1, 0.0f);
1898 glTexCoord2f(texcoordwidth, texcoordheight);
1899 glVertex3f(1, 1, 0.0f);
1900 glTexCoord2f(0, texcoordheight);
1901 glVertex3f(-1, 1, 0.0f);
1906 if (drawmode == glowmode) {
1907 glColor4f(.5, .5, .5, .5);
1909 glBlendFunc(GL_SRC_ALPHA, GL_ONE);
1911 glTranslatef(.01, 0, 0);
1914 glVertex3f(-1, -1, 0.0f);
1915 glTexCoord2f(texcoordwidth, 0);
1916 glVertex3f(1, -1, 0.0f);
1917 glTexCoord2f(texcoordwidth, texcoordheight);
1918 glVertex3f(1, 1, 0.0f);
1919 glTexCoord2f(0, texcoordheight);
1920 glVertex3f(-1, 1, 0.0f);
1924 glTranslatef(-.01, 0, 0);
1927 glVertex3f(-1, -1, 0.0f);
1928 glTexCoord2f(texcoordwidth, 0);
1929 glVertex3f(1, -1, 0.0f);
1930 glTexCoord2f(texcoordwidth, texcoordheight);
1931 glVertex3f(1, 1, 0.0f);
1932 glTexCoord2f(0, texcoordheight);
1933 glVertex3f(-1, 1, 0.0f);
1937 glTranslatef(.0, .01, 0);
1940 glVertex3f(-1, -1, 0.0f);
1941 glTexCoord2f(texcoordwidth, 0);
1942 glVertex3f(1, -1, 0.0f);
1943 glTexCoord2f(texcoordwidth, texcoordheight);
1944 glVertex3f(1, 1, 0.0f);
1945 glTexCoord2f(0, texcoordheight);
1946 glVertex3f(-1, 1, 0.0f);
1950 glTranslatef(0, -.01, 0);
1953 glVertex3f(-1, -1, 0.0f);
1954 glTexCoord2f(texcoordwidth, 0);
1955 glVertex3f(1, -1, 0.0f);
1956 glTexCoord2f(texcoordwidth, texcoordheight);
1957 glVertex3f(1, 1, 0.0f);
1958 glTexCoord2f(0, texcoordheight);
1959 glVertex3f(-1, 1, 0.0f);
1963 if (drawmode == radialzoommode) {
1964 for (int i = 0; i < 3; i++) {
1965 glColor4f(1, 1, 1, 1 / ((float)i + 1));
1967 glScalef(1 + (float)i * .01, 1 + (float)i * .01, 1);
1970 glVertex3f(-1, -1, 0.0f);
1971 glTexCoord2f(texcoordwidth, 0);
1972 glVertex3f(1, -1, 0.0f);
1973 glTexCoord2f(texcoordwidth, texcoordheight);
1974 glVertex3f(1, 1, 0.0f);
1975 glTexCoord2f(0, texcoordheight);
1976 glVertex3f(-1, 1, 0.0f);
1981 glDisable(GL_TEXTURE_2D);
1982 glMatrixMode(GL_PROJECTION);
1984 glMatrixMode(GL_MODELVIEW);
1986 glEnable(GL_DEPTH_TEST);
1987 glEnable(GL_CULL_FACE);
1988 glDisable(GL_BLEND);
1993 glEnable(GL_TEXTURE_2D);
1994 glColor4f(1, 1, 1, 1);
1996 if (consoleselected >= 60)
1997 offset = consoleselected - 60;
1998 sprintf (string, " ]");
1999 text->glPrint(10, 30, string, 0, 1, 1024, 768);
2001 sprintf (string, "_");
2002 text->glPrint(30 + (float)(consoleselected) * 10 - offset * 10, 30, string, 0, 1, 1024, 768);
2004 for (unsigned i = 0; i < 15; i++)
2005 for (unsigned j = 0; j < consoletext[i].size(); j++) {
2006 glColor4f(1, 1, 1, 1 - (float)(i) / 16);
2007 sprintf (string, "%c", consoletext[i][j]);
2008 text->glPrint(30 + j * 10 - offset * 10, 30 + i * 20, string, 0, 1, 1024, 768);
2013 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted)) {
2014 multiplier = tempmult;
2021 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted)) {
2022 tempmult = multiplier;
2026 if ( side == stereoRight || side == stereoCenter ) {
2027 if (drawmode != motionblurmode || mainmenu) {
2032 glDrawBuffer(GL_BACK);
2033 glReadBuffer(GL_BACK);
2037 if (drawtoggle == 2)
2040 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted)) {
2041 multiplier = tempmult;
2043 //Jordan fixed your warning!
2049 // !!! FIXME: hack: clamp framerate in menu so text input works correctly on fast systems.
2052 glDrawBuffer(GL_BACK);
2053 glReadBuffer(GL_BACK);
2054 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
2055 Game::ReSizeGLScene(90, .1f);
2057 //draw menu background
2058 glClear(GL_DEPTH_BUFFER_BIT);
2059 glEnable(GL_ALPHA_TEST);
2060 glAlphaFunc(GL_GREATER, 0.001f);
2061 glEnable(GL_TEXTURE_2D);
2062 glDisable(GL_DEPTH_TEST);
2063 glDisable(GL_CULL_FACE);
2064 glDisable(GL_LIGHTING);
2066 glMatrixMode(GL_PROJECTION);
2069 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
2070 glMatrixMode(GL_MODELVIEW);
2073 glTranslatef(screenwidth / 2, screenheight / 2, 0);
2075 glScalef((float)screenwidth / 2, (float)screenheight / 2, 1);
2076 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
2077 glDisable(GL_BLEND);
2078 glColor4f(0, 0, 0, 1.0);
2079 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2080 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2081 glDisable(GL_TEXTURE_2D);
2083 glVertex3f(-1, -1, 0);
2084 glVertex3f(+1, -1, 0);
2085 glVertex3f(+1, +1, 0);
2086 glVertex3f(-1, +1, 0);
2089 glColor4f(0.4, 0.4, 0.4, 1.0);
2090 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2091 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2092 glEnable(GL_TEXTURE_2D);
2093 Game::Mainmenuitems[4].bind();
2096 glVertex3f(-1, -1, 0);
2098 glVertex3f(+1, -1, 0);
2100 glVertex3f(+1, +1, 0);
2102 glVertex3f(-1, +1, 0);
2106 glMatrixMode(GL_PROJECTION);
2108 glMatrixMode(GL_MODELVIEW);
2112 glMatrixMode(GL_PROJECTION);
2115 glOrtho(0, 640, 0, 480, -100, 100);
2116 glMatrixMode(GL_MODELVIEW);
2119 glEnable(GL_TEXTURE_2D);
2124 glMatrixMode(GL_PROJECTION);
2126 glMatrixMode(GL_MODELVIEW);
2129 glMatrixMode(GL_PROJECTION);
2132 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
2133 glMatrixMode(GL_MODELVIEW);
2136 glTranslatef(screenwidth / 2, screenheight / 2, 0);
2138 glScalef((float)screenwidth / 2, (float)screenheight / 2, 1);
2139 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
2141 glEnable(GL_TEXTURE_2D);
2142 glColor4f(1, 1, 1, 1);
2143 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2144 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2146 if (!Game::waiting) { // hide the cursor while waiting for a key
2148 glTranslatef(Game::mousecoordh - screenwidth / 2, Game::mousecoordv * -1 + screenheight / 2, 0);
2149 glScalef((float)screenwidth / 64, (float)screenwidth / 64, 1);
2150 glTranslatef(1, -1, 0);
2151 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
2152 glColor4f(1, 1, 1, 1);
2153 Game::cursortexture.bind();
2157 glVertex3f(-1, -1, 0.0f);
2159 glVertex3f(1, -1, 0.0f);
2161 glVertex3f(1, 1, 0.0f);
2163 glVertex3f(-1, 1, 0.0f);
2169 glMatrixMode(GL_PROJECTION);
2174 if (flashamount > 0) {
2175 if (flashamount > 1)
2177 if (flashdelay <= 0)
2178 flashamount -= multiplier;
2180 if (flashamount < 0)
2182 glDisable(GL_DEPTH_TEST);
2183 glDisable(GL_CULL_FACE);
2184 glDisable(GL_LIGHTING);
2185 glDisable(GL_TEXTURE_2D);
2187 glMatrixMode(GL_PROJECTION);
2190 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
2191 glMatrixMode(GL_MODELVIEW);
2194 glScalef(screenwidth, screenheight, 1);
2195 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
2197 glColor4f(flashr, flashg, flashb, flashamount);
2199 glVertex3f(0, 0, 0.0f);
2200 glVertex3f(256, 0, 0.0f);
2201 glVertex3f(256, 256, 0.0f);
2202 glVertex3f(0, 256, 0.0f);
2204 glMatrixMode(GL_PROJECTION);
2206 glMatrixMode(GL_MODELVIEW);
2208 glEnable(GL_DEPTH_TEST);
2209 glEnable(GL_CULL_FACE);
2210 glDisable(GL_BLEND);