2 Copyright (C) 2003, 2010 - Wolfire Games
3 Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
5 This file is part of Lugaru.
7 Lugaru is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 Lugaru is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
22 #include "openal_wrapper.h"
28 extern int environment;
29 extern float texscale;
31 extern Terrain terrain;
32 extern float multiplier;
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;
75 extern float texdetail;
76 extern bool musictoggle;
77 extern int tutoriallevel;
78 extern float smoketex;
79 extern float tutorialstagetime;
80 extern float tutorialmaxtime;
81 extern int tutorialstage;
82 extern bool againbonus;
83 extern float damagedealt;
84 extern bool invertmouse;
86 extern int numhotspots;
87 extern int killhotspot;
88 extern XYZ hotspot[40];
89 extern int hotspottype[40];
90 extern float hotspotsize[40];
91 extern char hotspottext[40][256];
92 extern int currenthotspot;;
95 extern bool winfreeze;
97 extern float menupulse;
99 extern bool gamestart;
101 extern bool gamestarted;
103 extern bool showdamagebar;
108 int numboundaries = 0;
115 normalmode, motionblurmode, radialzoommode,
116 realmotionblurmode, doublevisionmode, glowmode,
119 void Game::flash() // shouldn't be that way, these should be attributes and Person class should not change rendering.
130 /*********************> DrawGLScene() <*****/
131 int Game::DrawGLScene(StereoSide side)
133 static float texcoordwidth, texcoordheight;
134 static float texviewwidth, texviewheight;
136 static XYZ checkpoint;
137 static float tempmult;
139 static char string[256] = "";
140 static char string2[256] = "";
141 static char string3[256] = "";
142 static int drawmode = 0;
144 if ( stereomode == stereoAnaglyph ) {
147 glColorMask( 0.0, 1.0, 1.0, 1.0 );
150 glColorMask( 1.0, 0.0, 0.0, 1.0 );
156 glColorMask( 1.0, 1.0, 1.0, 1.0 );
158 if ( stereomode == stereoHorizontalInterlaced || stereomode == stereoVerticalInterlaced ) {
159 glStencilFunc(side == stereoLeft ? GL_NOTEQUAL : GL_EQUAL, 0x01, 0x01);
163 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted)) {
164 tempmult = multiplier;
170 numboundaries = mapradius * 2;
171 if (numboundaries > 360)
173 for (int i = 0; i < numboundaries; i++) {
176 boundary[i] = mapcenter + DoRotation(boundary[i] * mapradius, 0, i * (360 / ((float)(numboundaries))), 0);
185 int olddrawmode = drawmode;
186 if (ismotionblur && !loading) {
187 if ((findLengthfast(&Person::players[0]->velocity) > 200) && velocityblur && !cameramode) {
188 drawmode = motionblurmode;
189 motionbluramount = 200 / (findLengthfast(&Person::players[0]->velocity));
192 if (Person::players[0]->damage - Person::players[0]->superpermanentdamage > (Person::players[0]->damagetolerance - Person::players[0]->superpermanentdamage) * 1 / 2 && damageeffects && !cameramode) {
193 drawmode = doublevisionmode;
198 if (slomo && !loading) {
200 drawmode = motionblurmode;
201 motionbluramount = .2;
202 slomodelay -= multiplier;
208 if ((!changed && !slomo) || loading) {
209 drawmode = normalmode;
210 if (ismotionblur && (/*fps>100||*/alwaysblur)) {
211 if (olddrawmode != realmotionblurmode)
215 drawmode = realmotionblurmode;
216 } else if (olddrawmode == realmotionblurmode)
222 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted))
223 drawmode = normalmode;
224 if ((freeze || winfreeze) && ismotionblur && !mainmenu)
225 drawmode = radialzoommode;
227 if (winfreeze || mainmenu)
228 drawmode = normalmode;
231 drawtoggle = 1 - drawtoggle;
233 if (!texcoordwidth) {
234 texviewwidth = kTextureSize;
235 if (texviewwidth > screenwidth)
236 texviewwidth = screenwidth;
237 texviewheight = kTextureSize;
238 if (texviewheight > screenheight)
239 texviewheight = screenheight;
241 texcoordwidth = screenwidth / kTextureSize;
242 texcoordheight = screenheight / kTextureSize;
243 if (texcoordwidth > 1)
245 if (texcoordheight > 1)
249 glDrawBuffer(GL_BACK);
250 glReadBuffer(GL_BACK);
252 static XYZ terrainlight;
253 static float distance;
254 if (drawmode == normalmode)
255 Game::ReSizeGLScene(90, .1f);
256 if (drawmode != normalmode)
257 glViewport(0, 0, texviewwidth, texviewheight);
258 glDepthFunc(GL_LEQUAL);
260 glAlphaFunc(GL_GREATER, 0.0001f);
261 glEnable(GL_ALPHA_TEST);
262 glClearColor(0.25f, 0.25f, 0.25f, 1.0f);
263 glClear(GL_DEPTH_BUFFER_BIT);
265 glMatrixMode (GL_MODELVIEW);
266 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
269 // Move the camera for the current eye's point of view.
270 // Reverse the movement if we're reversing stereo
271 glTranslatef((stereoseparation / 2) * side * (stereoreverse ? -1 : 1), 0, 0);
274 if (!cameramode && !freeze && !winfreeze) {
276 glRotatef(float(Random() % 100) / 10 * camerashake/*+(woozy*woozy)/10*/, 0, 0, 1);
278 glRotatef(pitch + sin(woozy / 2) * (Person::players[0]->damage / Person::players[0]->damagetolerance) * 5, 1, 0, 0);
279 glRotatef(yaw + sin(woozy) * (Person::players[0]->damage / Person::players[0]->damagetolerance) * 5, 0, 1, 0);
281 if (cameramode || freeze || winfreeze) {
282 glRotatef(pitch, 1, 0, 0);
283 glRotatef(yaw, 0, 1, 0);
286 if (environment == desertenvironment) {
287 glRotatef((float)(abs(Random() % 100)) / 3000 - 1, 1, 0, 0);
288 glRotatef((float)(abs(Random() % 100)) / 3000 - 1, 0, 1, 0);
290 SetUpLight(&light, 0);
293 //heat blur effect in desert
294 if (abs(blurness - targetblurness) < multiplier * 10 || abs(blurness - targetblurness) > 2) {
295 blurness = targetblurness;
296 targetblurness = (float)(abs(Random() % 100)) / 40;
298 if (blurness < targetblurness)
299 blurness += multiplier * 5;
301 blurness -= multiplier * 5;
303 if (environment == desertenvironment && detail == 2)
304 glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, blurness + .4 );
305 if (environment == desertenvironment) {
306 glRotatef((float)(abs(Random() % 100)) / 1000, 1, 0, 0);
307 glRotatef((float)(abs(Random() % 100)) / 1000, 0, 1, 0);
310 glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0);
312 glTranslatef(-viewer.x, -viewer.y, -viewer.z);
313 frustum.GetFrustum();
315 //make shadow decals on terrain and objects
317 static float size, opacity, rotation;
319 for (unsigned k = 0; k < Person::players.size(); k++) {
320 if (!Person::players[k]->skeleton.free && Person::players[k]->playerdetail && Person::players[k]->howactive < typesleeping)
321 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)
322 for (int i = 0; i < Person::players[k]->skeleton.num_joints; i++) {
323 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) {
324 point = DoRotation(Person::players[k]->skeleton.joints[i].position, 0, Person::players[k]->yaw, 0) * Person::players[k]->scale + Person::players[k]->coords;
326 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;
327 if (k != 0 && tutoriallevel == 1) {
328 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;
330 terrain.MakeDecal(shadowdecal, point, size, opacity, rotation);
331 for (l = 0; l < terrain.patchobjectnum[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz]; l++) {
332 int j = terrain.patchobjects[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz][l];
333 if (objects.position[j].y < Person::players[k]->coords.y || objects.type[j] == tunneltype || objects.type[j] == weirdtype) {
334 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);
337 if (k != 0 && tutoriallevel == 1) {
338 opacity = .2 + .2 * sin(smoketex * 6 + i);
340 objects.model[j].MakeDecal(shadowdecal, &point, &size, &opacity, &rotation);
345 if ((Person::players[k]->skeleton.free || Person::players[k]->howactive >= typesleeping) && Person::players[k]->playerdetail)
346 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)
347 for (int i = 0; i < Person::players[k]->skeleton.num_joints; i++) {
348 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) {
349 if (Person::players[k]->skeleton.free)
350 point = Person::players[k]->skeleton.joints[i].position * Person::players[k]->scale + Person::players[k]->coords;
352 point = DoRotation(Person::players[k]->skeleton.joints[i].position, 0, Person::players[k]->yaw, 0) * Person::players[k]->scale + Person::players[k]->coords;
354 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;
355 if (k != 0 && tutoriallevel == 1) {
356 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;
358 terrain.MakeDecal(shadowdecal, point, size, opacity * .7, rotation);
359 for (l = 0; l < terrain.patchobjectnum[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz]; l++) {
360 int j = terrain.patchobjects[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz][l];
361 if (objects.position[j].y < Person::players[k]->coords.y || objects.type[j] == tunneltype || objects.type[j] == weirdtype) {
362 if (Person::players[k]->skeleton.free)
363 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);
365 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);
368 if (k != 0 && tutoriallevel == 1) {
369 opacity = .2 + .2 * sin(smoketex * 6 + i);
371 objects.model[j].MakeDecal(shadowdecal, &point, &size, &opacity, &rotation);
377 if (!Person::players[k]->playerdetail)
378 if (frustum.SphereInFrustum(Person::players[k]->coords.x, Person::players[k]->coords.y, Person::players[k]->coords.z, Person::players[k]->scale * 5)) {
379 point = Person::players[k]->coords;
381 opacity = .4 - (Person::players[k]->coords.y - terrain.getHeight(Person::players[k]->coords.x, Person::players[k]->coords.z)) / 5;
382 terrain.MakeDecal(shadowdecal, point, size, opacity * .7, rotation);
383 for (l = 0; l < terrain.patchobjectnum[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz]; l++) {
384 int j = terrain.patchobjects[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz][l];
385 point = DoRotation(Person::players[k]->coords - objects.position[j], 0, -objects.yaw[j], 0);
388 objects.model[j].MakeDecal(shadowdecal, &point, &size, &opacity, &rotation);
394 glEnable(GL_TEXTURE_2D);
396 glEnable(GL_DEPTH_TEST);
397 glEnable(GL_CULL_FACE);
399 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
400 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
401 terraintexture.bind();
403 terraintexture2.bind();
406 terrain.drawdecals();
409 glEnable(GL_CULL_FACE);
410 glEnable(GL_LIGHTING);
412 glEnable(GL_TEXTURE_2D);
415 glEnable(GL_COLOR_MATERIAL);
430 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
431 glEnable(GL_CULL_FACE);
432 glCullFace(GL_FRONT);
434 for (unsigned k = 0; k < Person::players.size(); k++) {
435 if (k == 0 || tutoriallevel != 1) {
437 glEnable(GL_LIGHTING);
438 terrainlight = terrain.getLighting(Person::players[k]->coords.x, Person::players[k]->coords.z);
439 distance = distsq(&viewer, &Person::players[k]->coords);
440 distance = (viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance;
441 glColor4f(terrainlight.x, terrainlight.y, terrainlight.z, distance);
444 if (distance >= .5) {
445 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;
448 if (Person::players[k]->occluded != 0)
449 i = checkcollide(viewer, checkpoint, Person::players[k]->lastoccluded);
451 i = checkcollide(viewer, checkpoint);
453 Person::players[k]->occluded += 1;
454 Person::players[k]->lastoccluded = i;
456 Person::players[k]->occluded = 0;
458 if (Person::players[k]->occluded < 25)
459 Person::players[k]->DrawSkeleton();
465 if (!cameramode && musictype == stream_fighttheme)
466 playerdist = distsqflat(&Person::players[0]->coords, &viewer);
471 glEnable(GL_TEXTURE_2D);
477 if (frustum.SphereInFrustum(realhawkcoords.x + hawk.boundingspherecenter.x, realhawkcoords.y + hawk.boundingspherecenter.y, realhawkcoords.z + hawk.boundingspherecenter.z, 2)) {
478 glAlphaFunc(GL_GREATER, 0.0001f);
480 glDisable(GL_CULL_FACE);
481 glDisable(GL_LIGHTING);
483 glTranslatef(hawkcoords.x, hawkcoords.y, hawkcoords.z);
484 glRotatef(hawkyaw, 0, 1, 0);
485 glTranslatef(25, 0, 0);
486 distance = distsq(&viewer, &realhawkcoords) * 1.2;
487 glColor4f(light.color[0], light.color[1], light.color[2], (viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance);
488 if ((viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance > 1)
489 glColor4f(light.color[0], light.color[1], light.color[2], 1);
490 if ((viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance > 0)
491 hawk.drawdifftex(hawktexture);
495 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
496 glEnable(GL_CULL_FACE);
497 glCullFace(GL_FRONT);
499 for (unsigned k = 0; k < Person::players.size(); k++) {
500 if (!(k == 0 || tutoriallevel != 1)) {
502 glEnable(GL_LIGHTING);
503 terrainlight = terrain.getLighting(Person::players[k]->coords.x, Person::players[k]->coords.z);
504 distance = distsq(&viewer, &Person::players[k]->coords);
505 distance = (viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance;
506 glColor4f(terrainlight.x, terrainlight.y, terrainlight.z, distance);
509 if (distance >= .5) {
510 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;
513 if (Person::players[k]->occluded != 0)
514 i = checkcollide(viewer, checkpoint, Person::players[k]->lastoccluded);
516 i = checkcollide(viewer, checkpoint);
518 Person::players[k]->occluded += 1;
519 Person::players[k]->lastoccluded = i;
521 Person::players[k]->occluded = 0;
523 if (Person::players[k]->occluded < 25)
524 Person::players[k]->DrawSkeleton();
530 glEnable(GL_TEXTURE_2D);
535 glDisable(GL_COLOR_MATERIAL);
537 glDisable(GL_LIGHTING);
538 glDisable(GL_TEXTURE_2D);
544 //waypoints, pathpoints in editor
547 glDisable(GL_LIGHTING);
548 glDisable(GL_TEXTURE_2D);
549 glDisable(GL_COLOR_MATERIAL);
550 glColor4f(1, 1, 0, 1);
552 for (unsigned k = 0; k < Person::players.size(); k++) {
553 if (Person::players[k]->numwaypoints > 1) {
554 glBegin(GL_LINE_LOOP);
555 for (int i = 0; i < Person::players[k]->numwaypoints; i++) {
556 glVertex3f(Person::players[k]->waypoints[i].x, Person::players[k]->waypoints[i].y + .5, Person::players[k]->waypoints[i].z);
563 if (numpathpoints > 1) {
564 glColor4f(0, 1, 0, 1);
565 for (unsigned k = 0; int(k) < numpathpoints; k++) {
566 if (numpathpointconnect[k]) {
567 for (int i = 0; i < numpathpointconnect[k]; i++) {
568 glBegin(GL_LINE_LOOP);
569 glVertex3f(pathpoint[k].x, pathpoint[k].y + .5, pathpoint[k].z);
570 glVertex3f(pathpoint[pathpointconnect[k][i]].x, pathpoint[pathpointconnect[k][i]].y + .5, pathpoint[pathpointconnect[k][i]].z);
575 glColor4f(1, 1, 1, 1);
578 glVertex3f(pathpoint[pathpointselected].x, pathpoint[pathpointselected].y + .5, pathpoint[pathpointselected].z);
585 glEnable(GL_TEXTURE_2D);
586 glColor4f(.5, .5, .5, 1);
589 if (bonus > 0 && bonustime < 1 && !winfreeze && indialogue == -1/*bonustime<4*/) {
590 const char *bonus_name;
591 if (bonus < bonus_count)
592 bonus_name = bonus_names[bonus];
594 bonus_name = "Excellent!"; // When does this happen?
596 glColor4f(0, 0, 0, 1 - bonustime);
597 text->glPrintOutline(1024 / 2 - 10 * strlen(bonus_name) - 4, 768 / 16 - 4 + 768 * 4 / 5, bonus_name, 1, 2.5, 1024, 768);
598 glColor4f(1, 0, 0, 1 - bonustime);
599 text->glPrint(1024 / 2 - 10 * strlen(bonus_name), 768 / 16 + 768 * 4 / 5, bonus_name, 1, 2, 1024, 768);
601 sprintf (string, "%d", (int)bonusvalue);
602 glColor4f(0, 0, 0, 1 - bonustime);
603 text->glPrintOutline(1024 / 2 - 10 * strlen(string) - 4, 768 / 16 - 4 - 20 + 768 * 4 / 5, string, 1, 2.5 * .8, 1024, 768);
604 glColor4f(1, 0, 0, 1 - bonustime);
605 text->glPrint(1024 / 2 - 10 * strlen(string), 768 / 16 - 20 + 768 * 4 / 5, string, 1, 2 * .8, 1024, 768);
606 glColor4f(.5, .5, .5, 1);
609 if (tutoriallevel == 1) {
610 tutorialopac = tutorialmaxtime - tutorialstagetime;
611 if (tutorialopac > 1)
613 if (tutorialopac < 0)
616 sprintf (string, " ");
617 sprintf (string2, " ");
618 sprintf (string3, " ");
619 if (tutorialstage == 0) {
620 sprintf (string, " ");
621 sprintf (string2, " ");
622 sprintf (string3, " ");
624 if (tutorialstage == 1) {
625 sprintf (string, "Welcome to the Lugaru training level!");
626 sprintf (string2, " ");
627 sprintf (string3, " ");
629 if (tutorialstage == 2) {
630 sprintf (string, "BASIC MOVEMENT:");
631 sprintf (string2, " ");
632 sprintf (string3, " ");
634 if (tutorialstage == 3) {
635 sprintf (string, "You can move the mouse to rotate the camera.");
636 sprintf (string2, " ");
637 sprintf (string3, " ");
639 if (tutorialstage == 4) {
640 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));
641 sprintf (string2, "All movement is relative to the camera.");
642 sprintf (string3, " ");
644 if (tutorialstage == 5) {
645 sprintf (string, "Please press %s to jump.", Input::keyToChar(jumpkey));
646 sprintf (string2, "You can hold it longer to jump higher.");
647 sprintf (string3, " ");
649 if (tutorialstage == 6) {
650 sprintf (string, "You can press %s to crouch.", Input::keyToChar(crouchkey));
651 sprintf (string2, "You can jump higher from a crouching position.");
652 sprintf (string3, " ");
654 if (tutorialstage == 7) {
655 sprintf (string, "While running, you can press %s to roll.", Input::keyToChar(crouchkey));
656 sprintf (string2, " ");
657 sprintf (string3, " ");
659 if (tutorialstage == 8) {
660 sprintf (string, "While crouching, you can sneak around silently");
661 sprintf (string2, "using the movement keys.");
662 sprintf (string3, " ");
664 if (tutorialstage == 9) {
665 sprintf (string, "Release the crouch key while sneaking and hold the movement keys");
666 sprintf (string2, "to run animal-style.");
667 sprintf (string3, " ");
669 if (tutorialstage == 10) {
670 sprintf (string, "ADVANCED MOVEMENT:");
671 sprintf (string2, " ");
672 sprintf (string3, " ");
674 if (tutorialstage == 11) {
675 sprintf (string, "When you jump at a wall, you can hold %s again", Input::keyToChar(jumpkey));
676 sprintf (string2, "during impact to perform a walljump.");
677 sprintf (string3, "Be sure to use the movement keys to press against the wall");
679 if (tutorialstage == 12) {
680 sprintf (string, "While in the air, you can press crouch to flip.");
681 sprintf (string2, "Walljumps and flips confuse enemies and give you more control.");
682 sprintf (string3, " ");
684 if (tutorialstage == 13) {
685 sprintf (string, "BASIC COMBAT:");
686 sprintf (string2, " ");
687 sprintf (string3, " ");
689 if (tutorialstage == 14) {
690 sprintf (string, "There is now an imaginary enemy");
691 sprintf (string2, "in the middle of the training area.");
692 sprintf (string3, " ");
694 if (tutorialstage == 15) {
695 if (attackkey == MOUSEBUTTON1)
696 sprintf (string, "Click to attack when you are near an enemy.");
698 sprintf (string, "Press %s to attack when you are near an enemy.", Input::keyToChar(attackkey));
699 sprintf (string2, "You can punch by standing still near an enemy and attacking.");
700 sprintf (string3, " ");
702 if (tutorialstage == 16) {
703 sprintf (string, "If you are close, you will perform a weak punch.");
704 sprintf (string2, "The weak punch is excellent for starting attack combinations.");
705 sprintf (string3, " ");
707 if (tutorialstage == 17) {
708 sprintf (string, "Attacking while running results in a spin kick.");
709 sprintf (string2, "This is one of your most powerful ground attacks.");
710 sprintf (string3, " ");
712 if (tutorialstage == 18) {
713 sprintf (string, "Sweep the enemy's legs out by attacking while crouched.");
714 sprintf (string2, "This is a very fast attack, and easy to follow up.");
715 sprintf (string3, " ");
717 if (tutorialstage == 19) {
718 sprintf (string, "When an enemy is on the ground, you can deal some extra");
719 sprintf (string2, "damage by running up and drop-kicking him.");
720 sprintf (string3, "(Try knocking them down with a sweep first)");
722 if (tutorialstage == 20) {
723 sprintf (string, "Your most powerful individual attack is the rabbit kick.");
724 if (attackkey == MOUSEBUTTON1)
725 sprintf (string2, "Run at the enemy while holding the mouse button, and press");
727 sprintf (string2, "Run at the enemy while holding %s, and press", Input::keyToChar(attackkey));
728 sprintf (string3, "the jump key (%s) to attack.", Input::keyToChar(jumpkey));
730 if (tutorialstage == 21) {
731 sprintf (string, "This attack is devastating if timed correctly.");
732 sprintf (string2, "Even if timed incorrectly, it will knock the enemy over.");
734 sprintf (string3, "Try rabbit-kicking the imaginary enemy again.");
736 sprintf (string3, "Try rabbit-kicking the imaginary enemy.");
738 if (tutorialstage == 22) {
739 sprintf (string, "If you sneak behind an enemy unnoticed, you can kill");
740 sprintf (string2, "him instantly. Move close behind this enemy");
741 sprintf (string3, "and attack.");
743 if (tutorialstage == 23) {
744 sprintf (string, "Another important attack is the wall kick. When an enemy");
745 sprintf (string2, "is near a wall, perform a walljump nearby and hold");
746 sprintf (string3, "the attack key during impact with the wall.");
748 if (tutorialstage == 24) {
749 sprintf (string, "You can tackle enemies by running at them animal-style");
750 if (attackkey == MOUSEBUTTON1)
751 sprintf (string2, "and pressing jump (%s) or attack(mouse button).", Input::keyToChar(jumpkey));
753 sprintf (string2, "and pressing jump (%s) or attack(%s).", Input::keyToChar(jumpkey), Input::keyToChar(attackkey));
754 sprintf (string3, "This is especially useful when they are running away.");
756 if (tutorialstage == 25) {
757 sprintf (string, "Dodge by pressing back and attack. Dodging is essential");
758 sprintf (string2, "against enemies with swords or other long weapons.");
759 sprintf (string3, " ");
761 if (tutorialstage == 26) {
762 sprintf (string, "REVERSALS AND COUNTER-REVERSALS");
763 sprintf (string2, " ");
764 sprintf (string3, " ");
766 if (tutorialstage == 27) {
767 sprintf (string, "The enemy can now reverse your attacks.");
768 sprintf (string2, " ");
769 sprintf (string3, " ");
771 if (tutorialstage == 28) {
772 sprintf (string, "If you attack, you will notice that the enemy now sometimes");
773 sprintf (string2, "catches your attack and uses it against you. Hold");
774 sprintf (string3, "crouch (%s) after attacking to escape from reversals.", Input::keyToChar(crouchkey));
776 if (tutorialstage == 29) {
777 sprintf (string, "Try escaping from two more reversals in a row.");
778 sprintf (string2, " ");
779 sprintf (string3, " ");
781 if (tutorialstage == 30) {
782 sprintf (string, "Good!");
783 sprintf (string2, " ");
784 sprintf (string3, " ");
786 if (tutorialstage == 31) {
787 sprintf (string, "To reverse an attack, you must tap crouch (%s) during the", Input::keyToChar(crouchkey));
788 sprintf (string2, "enemy's attack. You must also be close to the enemy;");
789 sprintf (string3, "this is especially important against armed opponents.");
791 if (tutorialstage == 32) {
792 sprintf (string, "The enemy can attack in %d seconds.", (int)(tutorialmaxtime - tutorialstagetime));
793 sprintf (string2, "This imaginary opponents attacks will be highlighted");
794 sprintf (string3, "to make this easier.");
796 if (tutorialstage == 33) {
797 sprintf (string, "Reverse three enemy attacks!");
798 sprintf (string2, " ");
799 sprintf (string3, " ");
801 if (tutorialstage == 34) {
802 sprintf (string, "Reverse two more enemy attacks!");
803 sprintf (string2, " ");
804 sprintf (string3, " ");
806 if (tutorialstage == 35) {
807 sprintf (string, "Reverse one more enemy attack!");
808 sprintf (string2, " ");
809 sprintf (string3, " ");
811 if (tutorialstage == 36) {
812 sprintf (string, "Excellent!");
813 sprintf (string2, " ");
814 sprintf (string3, " ");
816 if (tutorialstage == 37) {
817 sprintf (string, "Now spar with the enemy for %d more seconds.", (int)(tutorialmaxtime - tutorialstagetime));
818 sprintf (string2, "Damage dealt: %d", (int)damagedealt);
819 sprintf (string3, "Damage taken: %d.", (int)damagetaken);
821 if (tutorialstage == 38) {
822 sprintf (string, "WEAPONS:");
823 sprintf (string2, " ");
824 sprintf (string3, " ");
826 if (tutorialstage == 39) {
827 sprintf (string, "There is now an imaginary knife");
828 sprintf (string2, "in the center of the training area.");
829 sprintf (string3, " ");
831 if (tutorialstage == 40) {
832 sprintf (string, "Stand, roll or handspring over the knife");
833 sprintf (string2, "while pressing %s to pick it up.", Input::keyToChar(throwkey));
834 sprintf (string3, "You can crouch and press the same key to drop it again.");
836 if (tutorialstage == 41) {
837 sprintf (string, "You can equip and unequip weapons using the %s key.", Input::keyToChar(drawkey));
838 sprintf (string2, "Sometimes it is best to keep them unequipped to");
839 sprintf (string3, "prevent enemies from taking them. ");
841 if (tutorialstage == 42) {
842 sprintf (string, "The knife is the smallest weapon and the least encumbering.");
843 sprintf (string2, "You can equip or unequip it while standing, crouching,");
844 sprintf (string3, "running or flipping.");
846 if (tutorialstage == 43) {
847 sprintf (string, "You perform weapon attacks the same way as unarmed attacks,");
848 sprintf (string2, "but sharp weapons cause permanent damage, instead of the");
849 sprintf (string3, "temporary trauma from blunt weapons, fists and feet.");
851 if (tutorialstage == 44) {
852 sprintf (string, "The enemy now has your knife!");
853 sprintf (string2, "Please reverse two of his knife attacks.");
854 sprintf (string3, " ");
856 if (tutorialstage == 45) {
857 sprintf (string, "Please reverse one more of his knife attacks.");
858 sprintf (string2, " ");
859 sprintf (string3, " ");
861 if (tutorialstage == 46) {
862 sprintf (string, "Now he has a sword!");
863 sprintf (string2, "The sword has longer reach than your arms, so you");
864 sprintf (string3, "must move close to reverse the sword slash.");
866 if (tutorialstage == 47) {
867 sprintf (string, "Long weapons like the sword and staff are also useful for defense;");
868 sprintf (string2, "you can parry enemy weapon attacks by pressing the attack key");
869 sprintf (string3, "at the right time. Please try parrying the enemy's attacks!");
871 if (tutorialstage == 48) {
872 sprintf (string, "The staff is like the sword, but has two main attacks.");
873 sprintf (string2, "The standing smash is fast and effective, and the running");
874 sprintf (string3, "spin smash is slower and more powerful.");
876 if (tutorialstage == 49) {
877 sprintf (string, "When facing an enemy, you can throw the knife with %s.", Input::keyToChar(throwkey));
878 sprintf (string2, "It is possible to throw the knife while flipping,");
879 sprintf (string3, "but it is very inaccurate.");
881 if (tutorialstage == 50) {
882 sprintf (string, "You now know everything you can learn from training.");
883 sprintf (string2, "Everything else you must learn from experience!");
884 sprintf (string3, " ");
886 if (tutorialstage == 51) {
887 sprintf (string, "Walk out of the training area to return to the main menu.");
888 sprintf (string2, " ");
889 sprintf (string3, " ");
892 glColor4f(0, 0, 0, tutorialopac);
893 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);
894 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);
895 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);
896 glColor4f(1, 1, 1, tutorialopac);
897 text->glPrint(screenwidth / 2 - 7.6 * strlen(string)*screenwidth / 1024, screenheight / 16 + screenheight * 4 / 5, string, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight);
898 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);
899 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);
901 sprintf (string, "Press 'tab' to skip to the next item.");
902 sprintf (string2, "Press escape at any time to");
903 sprintf (string3, "pause or exit the tutorial.");
905 glColor4f(0, 0, 0, 1);
906 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);
907 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);
908 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);
909 glColor4f(0.5, 0.5, 0.5, 1);
910 text->glPrint(screenwidth / 2 - 7.6 * strlen(string)*screenwidth / 1024 * .8, 0 + screenheight * 1 / 10, string, 1, 1.5 * screenwidth / 1024 * .8, screenwidth, screenheight);
911 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);
912 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);
916 if (numhotspots && (bonustime >= 1 || bonus <= 0 || bonustime < 0) && !tutoriallevel) {
917 float closestdist = -1;
919 int closest = currenthotspot;
920 for (int i = 0; i < numhotspots; i++) {
921 distance = distsq(&Person::players[0]->coords, &hotspot[i]);
922 if (closestdist == -1 || distance < closestdist) {
923 if (distsq(&Person::players[0]->coords, &hotspot[i]) < hotspotsize[i] && ((hotspottype[i] <= 10 && hotspottype[i] >= 0) || (hotspottype[i] <= 40 && hotspottype[i] >= 20))) {
924 closestdist = distance;
930 currenthotspot = closest;
931 if (currenthotspot != -1) {
932 if (hotspottype[closest] <= 10) {
933 if (distsq(&Person::players[0]->coords, &hotspot[closest]) < hotspotsize[closest])
934 tutorialstagetime = 0;
936 tutorialopac = tutorialmaxtime - tutorialstagetime;
937 if (tutorialopac > 1)
939 if (tutorialopac < 0)
942 sprintf (string, "%s", hotspottext[closest]);
949 if (string[i] == '\n' || string[i] > 'z' || string[i] < ' ' || string[i] == '\0') {
950 glColor4f(0, 0, 0, tutorialopac);
951 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);
952 glColor4f(1, 1, 1, tutorialopac);
953 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);
956 if (string[i] == '\0')
963 } else if (hotspottype[closest] >= 20 && dialoguegonethrough[hotspottype[closest] - 20] == 0) {
964 whichdialogue = hotspottype[closest] - 20;
965 for (int j = 0; j < numdialogueboxes[whichdialogue]; j++) {
966 Person::players[participantfocus[whichdialogue][j]]->coords = participantlocation[whichdialogue][participantfocus[whichdialogue][j]];
967 Person::players[participantfocus[whichdialogue][j]]->yaw = participantyaw[whichdialogue][participantfocus[whichdialogue][j]];
968 Person::players[participantfocus[whichdialogue][j]]->targetyaw = participantyaw[whichdialogue][participantfocus[whichdialogue][j]];
969 Person::players[participantfocus[whichdialogue][j]]->velocity = 0;
970 Person::players[participantfocus[whichdialogue][j]]->animTarget = Person::players[participantfocus[whichdialogue][j]]->getIdle();
971 Person::players[participantfocus[whichdialogue][j]]->frameTarget = 0;
975 dialoguegonethrough[whichdialogue]++;
976 if (dialogueboxsound[whichdialogue][indialogue] != 0) {
978 if (dialogueboxsound[whichdialogue][indialogue] == 1) whichsoundplay = rabbitchitter;
979 if (dialogueboxsound[whichdialogue][indialogue] == 2) whichsoundplay = rabbitchitter2;
980 if (dialogueboxsound[whichdialogue][indialogue] == 3) whichsoundplay = rabbitpainsound;
981 if (dialogueboxsound[whichdialogue][indialogue] == 4) whichsoundplay = rabbitpain1sound;
982 if (dialogueboxsound[whichdialogue][indialogue] == 5) whichsoundplay = rabbitattacksound;
983 if (dialogueboxsound[whichdialogue][indialogue] == 6) whichsoundplay = rabbitattack2sound;
984 if (dialogueboxsound[whichdialogue][indialogue] == 7) whichsoundplay = rabbitattack3sound;
985 if (dialogueboxsound[whichdialogue][indialogue] == 8) whichsoundplay = rabbitattack4sound;
986 if (dialogueboxsound[whichdialogue][indialogue] == 9) whichsoundplay = growlsound;
987 if (dialogueboxsound[whichdialogue][indialogue] == 10) whichsoundplay = growl2sound;
988 if (dialogueboxsound[whichdialogue][indialogue] == 11) whichsoundplay = snarlsound;
989 if (dialogueboxsound[whichdialogue][indialogue] == 12) whichsoundplay = snarl2sound;
990 if (dialogueboxsound[whichdialogue][indialogue] == 13) whichsoundplay = barksound;
991 if (dialogueboxsound[whichdialogue][indialogue] == 14) whichsoundplay = bark2sound;
992 if (dialogueboxsound[whichdialogue][indialogue] == 15) whichsoundplay = bark3sound;
993 if (dialogueboxsound[whichdialogue][indialogue] == 16) whichsoundplay = barkgrowlsound;
994 if (dialogueboxsound[whichdialogue][indialogue] == -1) whichsoundplay = fireendsound;
995 if (dialogueboxsound[whichdialogue][indialogue] == -2) whichsoundplay = firestartsound;
996 if (dialogueboxsound[whichdialogue][indialogue] == -3) whichsoundplay = consolesuccesssound;
997 if (dialogueboxsound[whichdialogue][indialogue] == -4) whichsoundplay = consolefailsound;
998 emit_sound_at(whichsoundplay, Person::players[participantfocus[whichdialogue][indialogue]]->coords);
1004 if (indialogue != -1 && !mainmenu) {
1005 glDisable(GL_DEPTH_TEST);
1006 glDisable(GL_CULL_FACE);
1007 glDisable(GL_LIGHTING);
1008 glDisable(GL_TEXTURE_2D);
1010 glMatrixMode(GL_PROJECTION);
1013 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1014 glMatrixMode(GL_MODELVIEW);
1017 if (dialogueboxlocation[whichdialogue][indialogue] == 1)
1018 glTranslatef(0, screenheight * 3 / 4, 0);
1019 glScalef(screenwidth, screenheight / 4, 1);
1020 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1023 glColor4f(dialogueboxcolor[whichdialogue][indialogue][0], dialogueboxcolor[whichdialogue][indialogue][1], dialogueboxcolor[whichdialogue][indialogue][2], 0.7);
1025 glVertex3f(0, 0, 0.0f);
1026 glVertex3f(1, 0, 0.0f);
1027 glVertex3f(1, 1, 0.0f);
1028 glVertex3f(0, 1, 0.0f);
1030 glMatrixMode(GL_PROJECTION);
1032 glMatrixMode(GL_MODELVIEW);
1034 glEnable(GL_DEPTH_TEST);
1035 glEnable(GL_CULL_FACE);
1036 glDisable(GL_BLEND);
1038 glEnable(GL_TEXTURE_2D);
1045 startx = screenwidth * 1 / 5;
1046 if (dialogueboxlocation[whichdialogue][indialogue] == 1)
1047 starty = screenheight / 16 + screenheight * 4 / 5;
1048 if (dialogueboxlocation[whichdialogue][indialogue] == 2)
1049 starty = screenheight * 1 / 5 - screenheight / 16;
1054 for (int i = 0; i < 264; i++) {
1058 for (int i = 0; i < (int)strlen(dialoguename[whichdialogue][indialogue]); i++) {
1059 tempname[tempnum] = dialoguename[whichdialogue][indialogue][i];
1061 if (dialoguename[whichdialogue][indialogue][i] == '#' || dialoguename[whichdialogue][indialogue][i] == '\0')
1066 tempname[tempnum] = '\0';
1069 sprintf (string, "%s: ", tempname);
1071 if (dialogueboxcolor[whichdialogue][indialogue][0] + dialogueboxcolor[whichdialogue][indialogue][1] + dialogueboxcolor[whichdialogue][indialogue][2] < 1.5) {
1072 glColor4f(0, 0, 0, tutorialopac);
1073 text->glPrintOutline(startx - 2 * 7.6 * strlen(string)*screenwidth / 1024 - 4, starty - 4, string, 1, 1.5 * 1.25 * screenwidth / 1024, screenwidth, screenheight);
1074 glColor4f(0.7, 0.7, 0.7, tutorialopac);
1075 text->glPrint(startx - 2 * 7.6 * strlen(string)*screenwidth / 1024, starty, string, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight);
1077 glColor4f(0, 0, 0, tutorialopac);
1078 text->glPrintOutline(startx - 2 * 7.6 * strlen(string)*screenwidth / 1024 - 4, starty - 4, string, 1, 1.5 * 1.25 * screenwidth / 1024, screenwidth, screenheight);
1082 for (int i = 0; i < (int)strlen(dialoguetext[whichdialogue][indialogue]) + 1; i++) {
1083 tempname[tempnum] = dialoguetext[whichdialogue][indialogue][i];
1084 if (dialoguetext[whichdialogue][indialogue][i] != '#')
1088 sprintf (string, "%s", tempname);
1095 if (string[i] == '\n' || string[i] > 'z' || string[i] < ' ' || string[i] == '\0') {
1096 if (dialogueboxcolor[whichdialogue][indialogue][0] + dialogueboxcolor[whichdialogue][indialogue][1] + dialogueboxcolor[whichdialogue][indialogue][2] < 1.5) {
1097 glColor4f(0, 0, 0, tutorialopac);
1098 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);
1099 glColor4f(1, 1, 1, tutorialopac);
1100 text->glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/, starty - 20 * screenwidth / 1024 * line, string, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight, lastline, i);
1102 glColor4f(0, 0, 0, tutorialopac);
1103 text->glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/, starty - 20 * screenwidth / 1024 * line, string, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight, lastline, i);
1107 if (string[i] == '\0')
1116 if (!tutoriallevel && !winfreeze && indialogue == -1 && !mainmenu) {
1119 sprintf (string, "Score: %d", (int)accountactive->getCampaignScore());
1121 sprintf (string, "Score: %d", (int)accountactive->getCampaignScore() + (int)bonustotal);
1124 sprintf (string, "Score: %d", (int)bonustotal);
1125 glColor4f(0, 0, 0, 1);
1126 text->glPrintOutline(1024 / 40 - 4, 768 / 16 - 4 + 768 * 14 / 16, string, 1, 1.5 * 1.25, 1024, 768);
1127 glColor4f(1, 0, 0, 1);
1128 text->glPrint(1024 / 40, 768 / 16 + 768 * 14 / 16, string, 1, 1.5, 1024, 768);
1129 if (showdamagebar) {
1130 glDisable(GL_DEPTH_TEST);
1131 glDisable(GL_CULL_FACE);
1132 glDisable(GL_LIGHTING);
1133 glDisable(GL_TEXTURE_2D);
1135 glMatrixMode(GL_PROJECTION);
1138 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1139 glMatrixMode(GL_MODELVIEW);
1142 glTranslatef(15, screenheight * 17.5 / 20, 0);
1143 glScalef(screenwidth / 3 + 20, screenheight / 20, 1);
1144 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1146 glColor4f(0.0, 0.4, 0.0, 0.7);
1147 float bar = ((float)Person::players[0]->damage) / Person::players[0]->damagetolerance;
1149 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
1150 glVertex3f(1, 0, 0.0f);
1151 glVertex3f(1, 1, 0.0f);
1152 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
1154 glColor4f(0.1, 0.0, 0.0, 1);
1155 bar = ((float)Person::players[0]->bloodloss) / Person::players[0]->damagetolerance;
1157 glVertex3f(0, 0, 0.0f);
1158 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
1159 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
1160 glVertex3f(0, 1, 0.0f);
1162 glColor4f(0.4, 0.0, 0.0, 0.7);
1163 bar = ((float)Person::players[0]->damage) / Person::players[0]->damagetolerance;
1165 glVertex3f(0, 0, 0.0f);
1166 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
1167 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
1168 glVertex3f(0, 1, 0.0f);
1170 glColor4f(0.4, 0.0, 0.0, 0.7);
1171 bar = ((float)Person::players[0]->permanentdamage) / Person::players[0]->damagetolerance;
1173 glVertex3f(0, 0, 0.0f);
1174 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
1175 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
1176 glVertex3f(0, 1, 0.0f);
1178 glColor4f(0.4, 0.0, 0.0, 0.7);
1179 bar = ((float)Person::players[0]->superpermanentdamage) / Person::players[0]->damagetolerance;
1181 glVertex3f(0, 0, 0.0f);
1182 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
1183 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
1184 glVertex3f(0, 1, 0.0f);
1186 glColor4f(0.0, 0.0, 0.0, 0.7);
1188 glBegin(GL_LINE_STRIP);
1189 glVertex3f(0, 0, 0.0f);
1190 glVertex3f(1, 0, 0.0f);
1191 glVertex3f(1, 1, 0.0f);
1192 glVertex3f(0, 1, 0.0f);
1193 glVertex3f(0, 0, 0.0f);
1196 glMatrixMode(GL_PROJECTION);
1198 glMatrixMode(GL_MODELVIEW);
1200 glEnable(GL_DEPTH_TEST);
1201 glEnable(GL_CULL_FACE);
1202 glDisable(GL_BLEND);
1204 glEnable(GL_TEXTURE_2D);
1206 // writing the numbers :
1207 sprintf (string, "Damages : %d/%d (%d)", (int)(Person::players[0]->damage), (int)(Person::players[0]->damagetolerance), (int)(Person::players[0]->bloodloss));
1208 glColor4f(0, 0, 0, 1);
1209 text->glPrintOutline(1024 / 40 - 4, 768 / 16 - 4 + 768 * 14 / 16 - 40, string, 1, 1.5 * 1.25, 1024, 768);
1210 glColor4f(1, 0, 0, 1);
1211 text->glPrint(1024 / 40, 768 / 16 + 768 * 14 / 16 - 40, string, 1, 1.5, 1024, 768);
1215 glColor4f(.5, .5, .5, 1);
1218 if ((texttoggle || editorenabled) && debugmode && !mainmenu) {
1219 sprintf (string, "The framespersecond is %d.", (int)(fps));
1220 text->glPrint(10, 30, string, 0, .8, 1024, 768);
1223 sprintf (string, "Map editor enabled.");
1225 sprintf (string, "Map editor disabled.");
1226 text->glPrint(10, 60, string, 0, .8, 1024, 768);
1227 if (editorenabled) {
1228 sprintf (string, "Object size: %f", editorsize);
1229 text->glPrint(10, 75, string, 0, .8, 1024, 768);
1231 sprintf (string, "Object yaw: %f", editoryaw);
1233 sprintf (string, "Object yaw: Random");
1234 text->glPrint(10, 90, string, 0, .8, 1024, 768);
1235 if (editorpitch >= 0)
1236 sprintf (string, "Object pitch: %f", editorpitch);
1238 sprintf (string, "Object pitch: Random");
1239 text->glPrint(10, 105, string, 0, .8, 1024, 768);
1240 sprintf (string, "Object type: %d", editortype);
1241 text->glPrint(10, 120, string, 0, .8, 1024, 768);
1242 switch (editortype) {
1244 sprintf (string, "(box)");
1247 sprintf (string, "(tree)");
1250 sprintf (string, "(wall)");
1253 sprintf (string, "(weird)");
1256 sprintf (string, "(spike)");
1259 sprintf (string, "(rock)");
1262 sprintf (string, "(bush)");
1265 sprintf (string, "(tunnel)");
1268 sprintf (string, "(chimney)");
1271 sprintf (string, "(platform)");
1274 sprintf (string, "(cool)");
1277 sprintf (string, "(fire)");
1280 text->glPrint(130, 120, string, 0, .8, 1024, 768);
1282 sprintf (string, "Numplayers: %lu", Person::players.size());
1283 text->glPrint(10, 155, string, 0, .8, 1024, 768);
1284 sprintf (string, "Player %d: numwaypoints: %d", (int(Person::players.size()) - 1), Person::players.back()->numwaypoints);
1285 text->glPrint(10, 140, string, 0, .8, 1024, 768);
1287 sprintf (string, "Difficulty: %d", difficulty);
1288 text->glPrint(10, 240, string, 0, .8, 1024, 768);
1293 if (drawmode == glowmode) {
1294 glDisable(GL_DEPTH_TEST);
1295 glDisable(GL_CULL_FACE);
1296 glDisable(GL_LIGHTING);
1297 glDisable(GL_TEXTURE_2D);
1299 glMatrixMode(GL_PROJECTION);
1302 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1303 glMatrixMode(GL_MODELVIEW);
1306 glScalef(screenwidth, screenheight, 1);
1307 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1309 glColor4f(0, 0, 0, .5);
1311 glVertex3f(0, 0, 0.0f);
1312 glVertex3f(256, 0, 0.0f);
1313 glVertex3f(256, 256, 0.0f);
1314 glVertex3f(0, 256, 0.0f);
1316 glMatrixMode(GL_PROJECTION);
1318 glMatrixMode(GL_MODELVIEW);
1320 glEnable(GL_DEPTH_TEST);
1321 glEnable(GL_CULL_FACE);
1322 glDisable(GL_BLEND);
1326 if ((((blackout && damageeffects) || (Person::players[0]->bloodloss > 0 && damageeffects && Person::players[0]->blooddimamount > 0) || Person::players[0]->dead) && !cameramode) || console) {
1327 glDisable(GL_DEPTH_TEST);
1328 glDisable(GL_CULL_FACE);
1329 glDisable(GL_LIGHTING);
1330 glDisable(GL_TEXTURE_2D);
1332 glMatrixMode(GL_PROJECTION);
1335 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1336 glMatrixMode(GL_MODELVIEW);
1339 glScalef(screenwidth, screenheight, 1);
1340 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1342 if (Person::players[0]->dead)
1343 blackout += multiplier * 3;
1344 if (Person::players[0]->dead == 1)
1346 if (Person::players[0]->dead == 2 && blackout > .6)
1348 glColor4f(0, 0, 0, blackout);
1349 if (!Person::players[0]->dead) {
1350 if ((Person::players[0]->bloodloss / Person::players[0]->damagetolerance * (sin(woozy) / 4 + .5))*.3 < .3) {
1351 glColor4f(0, 0, 0, Person::players[0]->blooddimamount * Person::players[0]->bloodloss / Person::players[0]->damagetolerance * (sin(woozy) / 4 + .5)*.3);
1352 blackout = Person::players[0]->blooddimamount * Person::players[0]->bloodloss / Person::players[0]->damagetolerance * (sin(woozy) / 4 + .5) * .3;
1354 glColor4f(0, 0, 0, Person::players[0]->blooddimamount * .3);
1355 blackout = Person::players[0]->blooddimamount * .3;
1359 glColor4f(.7, 0, 0, .2);
1361 glVertex3f(0, 0, 0.0f);
1362 glVertex3f(256, 0, 0.0f);
1363 glVertex3f(256, 256, 0.0f);
1364 glVertex3f(0, 256, 0.0f);
1366 glMatrixMode(GL_PROJECTION);
1368 glMatrixMode(GL_MODELVIEW);
1370 glEnable(GL_DEPTH_TEST);
1371 glEnable(GL_CULL_FACE);
1372 glDisable(GL_BLEND);
1376 if (flashamount > 0 && damageeffects) {
1377 if (flashamount > 1)
1379 if (flashdelay <= 0)
1380 flashamount -= multiplier;
1382 if (flashamount < 0)
1384 glDisable(GL_DEPTH_TEST);
1385 glDisable(GL_CULL_FACE);
1386 glDisable(GL_LIGHTING);
1388 glMatrixMode(GL_PROJECTION);
1391 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1392 glMatrixMode(GL_MODELVIEW);
1395 glScalef(screenwidth, screenheight, 1);
1396 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1398 glColor4f(flashr, flashg, flashb, flashamount);
1400 glVertex3f(0, 0, 0.0f);
1401 glVertex3f(256, 0, 0.0f);
1402 glVertex3f(256, 256, 0.0f);
1403 glVertex3f(0, 256, 0.0f);
1405 glMatrixMode(GL_PROJECTION);
1407 glMatrixMode(GL_MODELVIEW);
1409 glEnable(GL_DEPTH_TEST);
1410 glEnable(GL_CULL_FACE);
1411 glDisable(GL_BLEND);
1417 glEnable(GL_TEXTURE_2D);
1418 glColor4f(1, 1, 1, 1);
1419 for (unsigned i = 1; i < 15; i++)
1420 if (displaytime[i] < 4)
1421 for (unsigned j = 0; j < displaytext[i].size(); j++) {
1422 glColor4f(1, 1, 1, 4 - displaytime[i]);
1423 sprintf (string, "%c", displaytext[i][j]);
1424 text->glPrint(30 + j * 10, 30 + i * 20 + (screenheight - 330), string, 0, 1, screenwidth, screenheight);
1428 if (difficulty < 2 && indialogue == -1) { // minimap
1429 float mapviewdist = 20000;
1431 glDisable(GL_DEPTH_TEST);
1432 glColor3f (1.0, 1.0, 1.0); // no coloring
1434 glEnable(GL_TEXTURE_2D);
1435 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1436 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1437 glDisable(GL_DEPTH_TEST);
1438 glDisable(GL_CULL_FACE);
1439 glDisable(GL_LIGHTING);
1441 glMatrixMode(GL_PROJECTION);
1444 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1445 glMatrixMode(GL_MODELVIEW);
1448 glScalef((float)screenwidth / 2, (float)screenwidth / 2, 1);
1449 glTranslatef(1.75, .25, 0);
1450 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1452 glColor4f(1, 1, 1, 1);
1458 int numliveplayers = 0;
1460 for (unsigned i = 0; i < Person::players.size(); i++) {
1461 if (!Person::players[i]->dead)
1467 for (int i = 0; i < objects.numobjects; i++) {
1468 if (objects.type[i] == treetrunktype || objects.type[i] == boxtype) {
1469 center += objects.position[i];
1473 for (unsigned i = 0; i < Person::players.size(); i++) {
1474 if (!Person::players[i]->dead)
1475 center += Person::players[i]->coords;
1477 center /= numadd + numliveplayers;
1479 center = Person::players[0]->coords;
1481 float maxdistance = 0;
1483 for (int i = 0; i < objects.numobjects; i++) {
1484 tempdist = distsq(¢er, &objects.position[i]);
1485 if (tempdist > maxdistance) {
1486 maxdistance = tempdist;
1489 for (unsigned i = 0; i < Person::players.size(); i++) {
1490 if (!Person::players[i]->dead) {
1491 tempdist = distsq(¢er, &Person::players[i]->coords);
1492 if (tempdist > maxdistance) {
1493 maxdistance = tempdist;
1499 glScalef(.25 / radius * 256 * terrain.scale * .4, .25 / radius * 256 * terrain.scale * .4, 1);
1501 glScalef(1 / (1 / radius * 256 * terrain.scale * .4), 1 / (1 / radius * 256 * terrain.scale * .4), 1);
1503 glRotatef(Person::players[0]->lookyaw * -1 + 180, 0, 0, 1);
1504 glTranslatef(-(center.x / terrain.scale / 256 * -2 + 1), (center.z / terrain.scale / 256 * -2 + 1), 0);
1505 for (int i = 0; i < objects.numobjects; i++) {
1506 if (objects.type[i] == treetrunktype) {
1507 distcheck = distsq(&Person::players[0]->coords, &objects.position[i]);
1508 if (distcheck < mapviewdist) {
1509 Mapcircletexture.bind();
1510 glColor4f(0, .3, 0, opac * (1 - distcheck / mapviewdist));
1512 glTranslatef(objects.position[i].x / terrain.scale / 256 * -2 + 1, objects.position[i].z / terrain.scale / 256 * 2 - 1, 0);
1513 glRotatef(objects.yaw[i], 0, 0, 1);
1514 glScalef(.003, .003, .003);
1517 glVertex3f(-1, -1, 0.0f);
1519 glVertex3f(1, -1, 0.0f);
1521 glVertex3f(1, 1, 0.0f);
1523 glVertex3f(-1, 1, 0.0f);
1528 if (objects.type[i] == boxtype) {
1529 distcheck = distsq(&Person::players[0]->coords, &objects.position[i]);
1530 if (distcheck < mapviewdist) {
1531 Mapboxtexture.bind();
1532 glColor4f(.4, .4, .4, opac * (1 - distcheck / mapviewdist));
1534 glTranslatef(objects.position[i].x / terrain.scale / 256 * -2 + 1, objects.position[i].z / terrain.scale / 256 * 2 - 1, 0);
1535 glRotatef(objects.yaw[i], 0, 0, 1);
1536 glScalef(.01 * objects.scale[i], .01 * objects.scale[i], .01 * objects.scale[i]);
1539 glVertex3f(-1, -1, 0.0f);
1541 glVertex3f(1, -1, 0.0f);
1543 glVertex3f(1, 1, 0.0f);
1545 glVertex3f(-1, 1, 0.0f);
1551 if (editorenabled) {
1552 Mapcircletexture.bind();
1553 for (int i = 0; i < numboundaries; i++) {
1554 glColor4f(0, 0, 0, opac / 3);
1556 glTranslatef(boundary[i].x / terrain.scale / 256 * -2 + 1, boundary[i].z / terrain.scale / 256 * 2 - 1, 0);
1557 glScalef(.002, .002, .002);
1560 glVertex3f(-1, -1, 0.0f);
1562 glVertex3f(1, -1, 0.0f);
1564 glVertex3f(1, 1, 0.0f);
1566 glVertex3f(-1, 1, 0.0f);
1571 for (unsigned i = 0; i < Person::players.size(); i++) {
1572 distcheck = distsq(&Person::players[0]->coords, &Person::players[i]->coords);
1573 if (distcheck < mapviewdist) {
1575 Maparrowtexture.bind();
1577 glColor4f(1, 1, 1, opac);
1578 else if (Person::players[i]->dead == 2 || Person::players[i]->howactive > typesleeping)
1579 glColor4f(0, 0, 0, opac * (1 - distcheck / mapviewdist));
1580 else if (Person::players[i]->dead)
1581 glColor4f(.3, .3, .3, opac * (1 - distcheck / mapviewdist));
1582 else if (Person::players[i]->aitype == attacktypecutoff)
1583 glColor4f(1, 0, 0, opac * (1 - distcheck / mapviewdist));
1584 else if (Person::players[i]->aitype == passivetype)
1585 glColor4f(0, 1, 0, opac * (1 - distcheck / mapviewdist));
1587 glColor4f(1, 1, 0, 1);
1588 glTranslatef(Person::players[i]->coords.x / terrain.scale / 256 * -2 + 1, Person::players[i]->coords.z / terrain.scale / 256 * 2 - 1, 0);
1589 glRotatef(Person::players[i]->yaw + 180, 0, 0, 1);
1590 glScalef(.005, .005, .005);
1593 glVertex3f(-1, -1, 0.0f);
1595 glVertex3f(1, -1, 0.0f);
1597 glVertex3f(1, 1, 0.0f);
1599 glVertex3f(-1, 1, 0.0f);
1605 glDisable(GL_TEXTURE_2D);
1606 glMatrixMode(GL_PROJECTION);
1608 glMatrixMode(GL_MODELVIEW);
1610 glEnable(GL_DEPTH_TEST);
1611 glEnable(GL_CULL_FACE);
1612 glDisable(GL_BLEND);
1616 if (loading && !stealthloading && (!campaign || Person::players[0]->dead)) {
1617 glDisable(GL_DEPTH_TEST);
1618 glDisable(GL_CULL_FACE);
1619 glDisable(GL_LIGHTING);
1620 glDisable(GL_TEXTURE_2D);
1622 glMatrixMode(GL_PROJECTION);
1625 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1626 glMatrixMode(GL_MODELVIEW);
1629 glScalef(screenwidth, screenheight, 1);
1630 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1632 glColor4f(0, 0, 0, .7);
1634 glVertex3f(0, 0, 0.0f);
1635 glVertex3f(256, 0, 0.0f);
1636 glVertex3f(256, 256, 0.0f);
1637 glVertex3f(0, 256, 0.0f);
1639 glMatrixMode(GL_PROJECTION);
1641 glMatrixMode(GL_MODELVIEW);
1643 glEnable(GL_DEPTH_TEST);
1644 glEnable(GL_CULL_FACE);
1645 glDisable(GL_BLEND);
1649 glDisable(GL_DEPTH_TEST);
1650 glColor3f (1.0, 1.0, 1.0); // no coloring
1652 glEnable(GL_TEXTURE_2D);
1657 glEnable(GL_TEXTURE_2D);
1658 glColor4f(1, 1, 1, 1);
1659 sprintf (string, "Loading...");
1660 text->glPrint(1024 / 2 - 90, 768 / 2, string, 1, 2, 1024, 768);
1663 drawmode = normalmode;
1666 if (winfreeze && !campaign) {
1667 glDisable(GL_DEPTH_TEST);
1668 glDisable(GL_CULL_FACE);
1669 glDisable(GL_LIGHTING);
1670 glDisable(GL_TEXTURE_2D);
1672 glMatrixMode(GL_PROJECTION);
1675 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1676 glMatrixMode(GL_MODELVIEW);
1679 glScalef(screenwidth, screenheight, 1);
1680 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1682 glColor4f(0, 0, 0, .4);
1684 glVertex3f(0, 0, 0.0f);
1685 glVertex3f(256, 0, 0.0f);
1686 glVertex3f(256, 256, 0.0f);
1687 glVertex3f(0, 256, 0.0f);
1689 glMatrixMode(GL_PROJECTION);
1691 glMatrixMode(GL_MODELVIEW);
1693 glEnable(GL_DEPTH_TEST);
1694 glEnable(GL_CULL_FACE);
1695 glDisable(GL_BLEND);
1699 glDisable(GL_DEPTH_TEST);
1700 glColor3f (1.0, 1.0, 1.0); // no coloring
1702 glEnable(GL_TEXTURE_2D);
1704 //Win Screen Won Victory
1706 glEnable(GL_TEXTURE_2D);
1707 glColor4f(1, 1, 1, 1);
1708 sprintf (string, "Level Cleared!");
1709 text->glPrintOutlined(1024 / 2 - strlen(string) * 10, 768 * 7 / 8, string, 1, 2, 1024, 768);
1711 sprintf (string, "Score: %d", (int)(bonustotal - startbonustotal));
1712 text->glPrintOutlined(1024 / 30, 768 * 6 / 8, string, 1, 2, 1024, 768);
1715 sprintf (string, "Press Escape or Space to continue");
1717 sprintf (string, "Press Escape to return to menu or Space to continue");
1718 text->glPrintOutlined(640 / 2 - strlen(string) * 5, 480 * 1 / 16, string, 1, 1, 640, 480);
1722 for (int i = 0; i < 255; i++)
1724 sprintf (temp, "Time: %d:", (int)(((int)leveltime - (int)(leveltime) % 60) / 60));
1725 strcat(string, temp);
1726 if ((int)(leveltime) % 60 < 10)
1727 strcat(string, "0");
1728 sprintf (temp, "%d", (int)(leveltime) % 60);
1729 strcat(string, temp);
1730 text->glPrintOutlined(1024 / 30, 768 * 6 / 8 - 40, string, 1, 2, 1024, 768);
1733 int awards[award_count];
1734 int numawards = award_awards(awards);
1736 for (int i = 0; i < numawards && i < 6; i++)
1737 text->glPrintOutlined(1024 / 30, 768 * 6 / 8 - 90 - 40 * i, award_names[awards[i]], 1, 2, 1024, 768);
1740 if (drawmode != normalmode) {
1741 glEnable(GL_TEXTURE_2D);
1743 if (!drawtoggle || drawmode != realmotionblurmode || (drawtoggle == 2 || change == 1)) {
1744 if (screentexture) {
1746 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
1747 GLfloat subtractColor[4] = { 0.5, 0.5, 0.5, 0.0 };
1748 glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, subtractColor);
1749 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE);
1750 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_CONSTANT_EXT);
1751 glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 2.0f);
1753 glBindTexture( GL_TEXTURE_2D, screentexture);
1754 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1757 if ((drawtoggle || change == 1) && drawmode == realmotionblurmode) {
1758 if (screentexture2) {
1759 glBindTexture( GL_TEXTURE_2D, screentexture2);
1760 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1762 if (!screentexture2) {
1763 glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
1765 glGenTextures( 1, &screentexture2 );
1766 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
1768 glEnable(GL_TEXTURE_2D);
1769 glBindTexture( GL_TEXTURE_2D, screentexture2);
1770 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
1771 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
1773 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
1778 glClear(GL_DEPTH_BUFFER_BIT);
1779 Game::ReSizeGLScene(90, .1f);
1780 glViewport(0, 0, screenwidth, screenheight);
1782 if (drawmode != normalmode) {
1783 glDisable(GL_DEPTH_TEST);
1784 if (drawmode == motionblurmode) {
1785 glDrawBuffer(GL_FRONT);
1786 glReadBuffer(GL_BACK);
1788 glColor3f (1.0, 1.0, 1.0); // no coloring
1790 glEnable(GL_TEXTURE_2D);
1791 glBindTexture( GL_TEXTURE_2D, screentexture);
1792 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1793 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1794 glDisable(GL_DEPTH_TEST);
1795 glDisable(GL_CULL_FACE);
1796 glDisable(GL_LIGHTING);
1798 glMatrixMode(GL_PROJECTION);
1801 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1802 glMatrixMode(GL_MODELVIEW);
1805 glScalef((float)screenwidth / 2, (float)screenheight / 2, 1);
1806 glTranslatef(1, 1, 0);
1807 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1809 if (drawmode == motionblurmode) {
1810 if (motionbluramount < .2)
1811 motionbluramount = .2;
1812 glColor4f(1, 1, 1, motionbluramount);
1816 glVertex3f(-1, -1, 0.0f);
1817 glTexCoord2f(texcoordwidth, 0);
1818 glVertex3f(1, -1, 0.0f);
1819 glTexCoord2f(texcoordwidth, texcoordheight);
1820 glVertex3f(1, 1, 0.0f);
1821 glTexCoord2f(0, texcoordheight);
1822 glVertex3f(-1, 1, 0.0f);
1826 if (drawmode == realmotionblurmode) {
1827 glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
1828 glClear(GL_COLOR_BUFFER_BIT);
1829 glBlendFunc(GL_SRC_ALPHA, GL_ONE);
1830 glBindTexture( GL_TEXTURE_2D, screentexture);
1831 glColor4f(1, 1, 1, .5);
1835 glVertex3f(-1, -1, 0.0f);
1836 glTexCoord2f(texcoordwidth, 0);
1837 glVertex3f(1, -1, 0.0f);
1838 glTexCoord2f(texcoordwidth, texcoordheight);
1839 glVertex3f(1, 1, 0.0f);
1840 glTexCoord2f(0, texcoordheight);
1841 glVertex3f(-1, 1, 0.0f);
1844 glBindTexture( GL_TEXTURE_2D, screentexture2);
1845 glColor4f(1, 1, 1, .5);
1849 glVertex3f(-1, -1, 0.0f);
1850 glTexCoord2f(texcoordwidth, 0);
1851 glVertex3f(1, -1, 0.0f);
1852 glTexCoord2f(texcoordwidth, texcoordheight);
1853 glVertex3f(1, 1, 0.0f);
1854 glTexCoord2f(0, texcoordheight);
1855 glVertex3f(-1, 1, 0.0f);
1858 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1860 if (drawmode == doublevisionmode) {
1861 static float crosseyedness;
1862 crosseyedness = abs(Person::players[0]->damage - Person::players[0]->superpermanentdamage - (Person::players[0]->damagetolerance - Person::players[0]->superpermanentdamage) * 1 / 2) / 30;
1863 if (crosseyedness > 1)
1865 if (crosseyedness < 0)
1867 glColor4f(1, 1, 1, 1);
1868 glDisable(GL_BLEND);
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 if (crosseyedness) {
1883 glColor4f(1, 1, 1, .5);
1886 glTranslatef(.015 * crosseyedness, 0, 0);
1890 glVertex3f(-1, -1, 0.0f);
1891 glTexCoord2f(texcoordwidth, 0);
1892 glVertex3f(1, -1, 0.0f);
1893 glTexCoord2f(texcoordwidth, texcoordheight);
1894 glVertex3f(1, 1, 0.0f);
1895 glTexCoord2f(0, texcoordheight);
1896 glVertex3f(-1, 1, 0.0f);
1901 if (drawmode == glowmode) {
1902 glColor4f(.5, .5, .5, .5);
1904 glBlendFunc(GL_SRC_ALPHA, GL_ONE);
1906 glTranslatef(.01, 0, 0);
1909 glVertex3f(-1, -1, 0.0f);
1910 glTexCoord2f(texcoordwidth, 0);
1911 glVertex3f(1, -1, 0.0f);
1912 glTexCoord2f(texcoordwidth, texcoordheight);
1913 glVertex3f(1, 1, 0.0f);
1914 glTexCoord2f(0, texcoordheight);
1915 glVertex3f(-1, 1, 0.0f);
1919 glTranslatef(-.01, 0, 0);
1922 glVertex3f(-1, -1, 0.0f);
1923 glTexCoord2f(texcoordwidth, 0);
1924 glVertex3f(1, -1, 0.0f);
1925 glTexCoord2f(texcoordwidth, texcoordheight);
1926 glVertex3f(1, 1, 0.0f);
1927 glTexCoord2f(0, texcoordheight);
1928 glVertex3f(-1, 1, 0.0f);
1932 glTranslatef(.0, .01, 0);
1935 glVertex3f(-1, -1, 0.0f);
1936 glTexCoord2f(texcoordwidth, 0);
1937 glVertex3f(1, -1, 0.0f);
1938 glTexCoord2f(texcoordwidth, texcoordheight);
1939 glVertex3f(1, 1, 0.0f);
1940 glTexCoord2f(0, texcoordheight);
1941 glVertex3f(-1, 1, 0.0f);
1945 glTranslatef(0, -.01, 0);
1948 glVertex3f(-1, -1, 0.0f);
1949 glTexCoord2f(texcoordwidth, 0);
1950 glVertex3f(1, -1, 0.0f);
1951 glTexCoord2f(texcoordwidth, texcoordheight);
1952 glVertex3f(1, 1, 0.0f);
1953 glTexCoord2f(0, texcoordheight);
1954 glVertex3f(-1, 1, 0.0f);
1958 if (drawmode == radialzoommode) {
1959 for (int i = 0; i < 3; i++) {
1960 glColor4f(1, 1, 1, 1 / ((float)i + 1));
1962 glScalef(1 + (float)i * .01, 1 + (float)i * .01, 1);
1965 glVertex3f(-1, -1, 0.0f);
1966 glTexCoord2f(texcoordwidth, 0);
1967 glVertex3f(1, -1, 0.0f);
1968 glTexCoord2f(texcoordwidth, texcoordheight);
1969 glVertex3f(1, 1, 0.0f);
1970 glTexCoord2f(0, texcoordheight);
1971 glVertex3f(-1, 1, 0.0f);
1976 glDisable(GL_TEXTURE_2D);
1977 glMatrixMode(GL_PROJECTION);
1979 glMatrixMode(GL_MODELVIEW);
1981 glEnable(GL_DEPTH_TEST);
1982 glEnable(GL_CULL_FACE);
1983 glDisable(GL_BLEND);
1988 glEnable(GL_TEXTURE_2D);
1989 glColor4f(1, 1, 1, 1);
1991 if (consoleselected >= 60)
1992 offset = consoleselected - 60;
1993 sprintf (string, " ]");
1994 text->glPrint(10, 30, string, 0, 1, 1024, 768);
1996 sprintf (string, "_");
1997 text->glPrint(30 + (float)(consoleselected) * 10 - offset * 10, 30, string, 0, 1, 1024, 768);
1999 for (unsigned i = 0; i < 15; i++)
2000 for (unsigned j = 0; j < consoletext[i].size(); j++) {
2001 glColor4f(1, 1, 1, 1 - (float)(i) / 16);
2002 sprintf (string, "%c", consoletext[i][j]);
2003 text->glPrint(30 + j * 10 - offset * 10, 30 + i * 20, string, 0, 1, 1024, 768);
2008 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted)) {
2009 multiplier = tempmult;
2016 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted)) {
2017 tempmult = multiplier;
2021 if ( side == stereoRight || side == stereoCenter ) {
2022 if (drawmode != motionblurmode || mainmenu) {
2027 glDrawBuffer(GL_BACK);
2028 glReadBuffer(GL_BACK);
2032 if (drawtoggle == 2)
2035 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted)) {
2036 multiplier = tempmult;
2038 //Jordan fixed your warning!
2044 // !!! FIXME: hack: clamp framerate in menu so text input works correctly on fast systems.
2047 glDrawBuffer(GL_BACK);
2048 glReadBuffer(GL_BACK);
2049 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
2050 Game::ReSizeGLScene(90, .1f);
2052 //draw menu background
2053 glClear(GL_DEPTH_BUFFER_BIT);
2054 glEnable(GL_ALPHA_TEST);
2055 glAlphaFunc(GL_GREATER, 0.001f);
2056 glEnable(GL_TEXTURE_2D);
2057 glDisable(GL_DEPTH_TEST);
2058 glDisable(GL_CULL_FACE);
2059 glDisable(GL_LIGHTING);
2061 glMatrixMode(GL_PROJECTION);
2064 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
2065 glMatrixMode(GL_MODELVIEW);
2068 glTranslatef(screenwidth / 2, screenheight / 2, 0);
2070 glScalef((float)screenwidth / 2, (float)screenheight / 2, 1);
2071 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
2072 glDisable(GL_BLEND);
2073 glColor4f(0, 0, 0, 1.0);
2074 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2075 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2076 glDisable(GL_TEXTURE_2D);
2078 glVertex3f(-1, -1, 0);
2079 glVertex3f(+1, -1, 0);
2080 glVertex3f(+1, +1, 0);
2081 glVertex3f(-1, +1, 0);
2084 glColor4f(0.4, 0.4, 0.4, 1.0);
2085 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2086 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2087 glEnable(GL_TEXTURE_2D);
2088 Game::Mainmenuitems[4].bind();
2091 glVertex3f(-1, -1, 0);
2093 glVertex3f(+1, -1, 0);
2095 glVertex3f(+1, +1, 0);
2097 glVertex3f(-1, +1, 0);
2101 glMatrixMode(GL_PROJECTION);
2103 glMatrixMode(GL_MODELVIEW);
2107 glMatrixMode(GL_PROJECTION);
2110 glOrtho(0, 640, 0, 480, -100, 100);
2111 glMatrixMode(GL_MODELVIEW);
2114 glEnable(GL_TEXTURE_2D);
2119 glMatrixMode(GL_PROJECTION);
2121 glMatrixMode(GL_MODELVIEW);
2124 glMatrixMode(GL_PROJECTION);
2127 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
2128 glMatrixMode(GL_MODELVIEW);
2131 glTranslatef(screenwidth / 2, screenheight / 2, 0);
2133 glScalef((float)screenwidth / 2, (float)screenheight / 2, 1);
2134 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
2136 glEnable(GL_TEXTURE_2D);
2137 glColor4f(1, 1, 1, 1);
2138 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2139 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2141 if (!Game::waiting) { // hide the cursor while waiting for a key
2143 glTranslatef(Game::mousecoordh - screenwidth / 2, Game::mousecoordv * -1 + screenheight / 2, 0);
2144 glScalef((float)screenwidth / 64, (float)screenwidth / 64, 1);
2145 glTranslatef(1, -1, 0);
2146 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
2147 glColor4f(1, 1, 1, 1);
2148 Game::cursortexture.bind();
2152 glVertex3f(-1, -1, 0.0f);
2154 glVertex3f(1, -1, 0.0f);
2156 glVertex3f(1, 1, 0.0f);
2158 glVertex3f(-1, 1, 0.0f);
2164 glMatrixMode(GL_PROJECTION);
2169 if (flashamount > 0) {
2170 if (flashamount > 1)
2172 if (flashdelay <= 0)
2173 flashamount -= multiplier;
2175 if (flashamount < 0)
2177 glDisable(GL_DEPTH_TEST);
2178 glDisable(GL_CULL_FACE);
2179 glDisable(GL_LIGHTING);
2180 glDisable(GL_TEXTURE_2D);
2182 glMatrixMode(GL_PROJECTION);
2185 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
2186 glMatrixMode(GL_MODELVIEW);
2189 glScalef(screenwidth, screenheight, 1);
2190 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
2192 glColor4f(flashr, flashg, flashb, flashamount);
2194 glVertex3f(0, 0, 0.0f);
2195 glVertex3f(256, 0, 0.0f);
2196 glVertex3f(256, 256, 0.0f);
2197 glVertex3f(0, 256, 0.0f);
2199 glMatrixMode(GL_PROJECTION);
2201 glMatrixMode(GL_MODELVIEW);
2203 glEnable(GL_DEPTH_TEST);
2204 glEnable(GL_CULL_FACE);
2205 glDisable(GL_BLEND);