2 Copyright (C) 2003, 2010 - Wolfire Games
4 This file is part of Lugaru.
6 Lugaru is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 Lugaru is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
21 #include "openal_wrapper.h"
27 extern int environment;
28 extern float texscale;
30 extern Terrain terrain;
31 //extern Sprites sprites;
32 extern float multiplier;
34 extern float viewdistance;
35 extern float fadestart;
36 extern float screenwidth, screenheight;
37 extern int kTextureSize;
38 extern FRUSTUM frustum;
40 extern Objects objects;
42 extern float usermousesensitivity;
44 extern float camerashake;
46 extern float slomodelay;
47 extern bool ismotionblur;
49 extern float blackout;
50 extern bool damageeffects;
52 extern bool texttoggle;
53 extern float blurness;
54 extern float targetblurness;
55 extern float playerdist;
56 extern bool cellophane;
58 extern float flashamount, flashr, flashg, flashb;
59 extern int flashdelay;
61 extern float motionbluramount;
63 extern bool alwaysblur;
65 extern bool tilt2weird;
66 extern bool tiltweird;
68 extern bool proportionweird;
69 extern bool vertexweird[6];
70 extern bool velocityblur;
71 extern bool debugmode;
73 extern int bloodtoggle;
74 extern int difficulty;
77 //extern int texdetail;
78 extern float texdetail;
79 extern bool musictoggle;
80 extern int tutoriallevel;
81 extern float smoketex;
82 extern float tutorialstagetime;
83 extern float tutorialmaxtime;
84 extern int tutorialstage;
85 extern bool againbonus;
86 extern float damagedealt;
87 extern bool invertmouse;
89 extern int numhotspots;
90 extern int killhotspot;
91 extern XYZ hotspot[40];
92 extern int hotspottype[40];
93 extern float hotspotsize[40];
94 extern char hotspottext[40][256];
95 extern int currenthotspot;;
98 extern bool winfreeze;
100 extern float menupulse;
102 extern bool gamestart;
104 extern bool gamestarted;
106 extern bool showdamagebar;
111 int numboundaries = 0;
118 normalmode, motionblurmode, radialzoommode,
119 realmotionblurmode, doublevisionmode, glowmode,
122 void Game::flash() // shouldn't be that way, these should be attributes and Person class should not change rendering.
133 /*********************> DrawGLScene() <*****/
134 int Game::DrawGLScene(StereoSide side)
136 static float texcoordwidth, texcoordheight;
137 static float texviewwidth, texviewheight;
139 static XYZ checkpoint;
140 static float tempmult;
142 static char string[256] = "";
143 static char string2[256] = "";
144 static char string3[256] = "";
145 static int drawmode = 0;
147 if ( stereomode == stereoAnaglyph ) {
150 glColorMask( 0.0, 1.0, 1.0, 1.0 );
153 glColorMask( 1.0, 0.0, 0.0, 1.0 );
159 glColorMask( 1.0, 1.0, 1.0, 1.0 );
161 if ( stereomode == stereoHorizontalInterlaced || stereomode == stereoVerticalInterlaced ) {
162 glStencilFunc(side == stereoLeft ? GL_NOTEQUAL : GL_EQUAL, 0x01, 0x01);
166 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted)) {
167 tempmult = multiplier;
173 numboundaries = mapradius * 2;
174 if (numboundaries > 360)
176 for (int i = 0; i < numboundaries; i++) {
179 boundary[i] = mapcenter + DoRotation(boundary[i] * mapradius, 0, i * (360 / ((float)(numboundaries))), 0);
188 int olddrawmode = drawmode;
189 if (ismotionblur && !loading) {
190 if ((findLengthfast(&Person::players[0]->velocity) > 200) && velocityblur && !cameramode) {
191 drawmode = motionblurmode;
192 motionbluramount = 200 / (findLengthfast(&Person::players[0]->velocity));
195 if (Person::players[0]->damage - Person::players[0]->superpermanentdamage > (Person::players[0]->damagetolerance - Person::players[0]->superpermanentdamage) * 1 / 2 && damageeffects && !cameramode) {
196 drawmode = doublevisionmode;
201 if (slomo && !loading) {
203 drawmode = motionblurmode;
204 motionbluramount = .2;
205 slomodelay -= multiplier;
211 if ((!changed && !slomo) || loading) {
212 drawmode = normalmode;
213 if (ismotionblur && (/*fps>100||*/alwaysblur)) {
214 if (olddrawmode != realmotionblurmode)
218 drawmode = realmotionblurmode;
219 } else if (olddrawmode == realmotionblurmode)
225 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted))
226 drawmode = normalmode;
227 if ((freeze || winfreeze) && ismotionblur && !mainmenu)
228 drawmode = radialzoommode;
230 if (winfreeze || mainmenu)
231 drawmode = normalmode;
234 drawtoggle = 1 - drawtoggle;
236 if (!texcoordwidth) {
237 texviewwidth = kTextureSize;
238 if (texviewwidth > screenwidth)
239 texviewwidth = screenwidth;
240 texviewheight = kTextureSize;
241 if (texviewheight > screenheight)
242 texviewheight = screenheight;
244 texcoordwidth = screenwidth / kTextureSize;
245 texcoordheight = screenheight / kTextureSize;
246 if (texcoordwidth > 1)
248 if (texcoordheight > 1)
252 glDrawBuffer(GL_BACK);
253 glReadBuffer(GL_BACK);
255 static XYZ terrainlight;
256 static float distance;
257 if (drawmode == normalmode)
258 Game::ReSizeGLScene(90, .1f);
259 if (drawmode != normalmode)
260 glViewport(0, 0, texviewwidth, texviewheight);
261 glDepthFunc(GL_LEQUAL);
263 glAlphaFunc(GL_GREATER, 0.0001f);
264 glEnable(GL_ALPHA_TEST);
265 glClearColor(0.25f, 0.25f, 0.25f, 1.0f);
266 glClear(GL_DEPTH_BUFFER_BIT);
268 glMatrixMode (GL_MODELVIEW);
269 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
272 // Move the camera for the current eye's point of view.
273 // Reverse the movement if we're reversing stereo
274 glTranslatef((stereoseparation / 2) * side * (stereoreverse ? -1 : 1), 0, 0);
277 if (!cameramode && !freeze && !winfreeze) {
279 glRotatef(float(Random() % 100) / 10 * camerashake/*+(woozy*woozy)/10*/, 0, 0, 1);
281 glRotatef(pitch + sin(woozy / 2) * (Person::players[0]->damage / Person::players[0]->damagetolerance) * 5, 1, 0, 0);
282 glRotatef(yaw + sin(woozy) * (Person::players[0]->damage / Person::players[0]->damagetolerance) * 5, 0, 1, 0);
284 if (cameramode || freeze || winfreeze) {
285 glRotatef(pitch, 1, 0, 0);
286 glRotatef(yaw, 0, 1, 0);
289 if (environment == desertenvironment) {
290 glRotatef((float)(abs(Random() % 100)) / 3000 - 1, 1, 0, 0);
291 glRotatef((float)(abs(Random() % 100)) / 3000 - 1, 0, 1, 0);
293 SetUpLight(&light, 0);
296 //heat blur effect in desert
297 if (abs(blurness - targetblurness) < multiplier * 10 || abs(blurness - targetblurness) > 2) {
298 blurness = targetblurness;
299 targetblurness = (float)(abs(Random() % 100)) / 40;
301 if (blurness < targetblurness)
302 blurness += multiplier * 5;
304 blurness -= multiplier * 5;
306 if (environment == desertenvironment && detail == 2)
307 glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, blurness + .4 );
308 if (environment == desertenvironment) {
309 glRotatef((float)(abs(Random() % 100)) / 1000, 1, 0, 0);
310 glRotatef((float)(abs(Random() % 100)) / 1000, 0, 1, 0);
313 glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0);
315 glTranslatef(-viewer.x, -viewer.y, -viewer.z);
316 frustum.GetFrustum();
318 //make shadow decals on terrain and objects
320 static float size, opacity, rotation;
322 for (unsigned k = 0; k < Person::players.size(); k++) {
323 if (!Person::players[k]->skeleton.free && Person::players[k]->playerdetail && Person::players[k]->howactive < typesleeping)
324 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)
325 for (int i = 0; i < Person::players[k]->skeleton.num_joints; i++) {
326 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) {
327 point = DoRotation(Person::players[k]->skeleton.joints[i].position, 0, Person::players[k]->yaw, 0) * Person::players[k]->scale + Person::players[k]->coords;
329 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;
330 if (k != 0 && tutoriallevel == 1) {
331 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;
333 terrain.MakeDecal(shadowdecal, point, size, opacity, rotation);
334 for (l = 0; l < terrain.patchobjectnum[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz]; l++) {
335 int j = terrain.patchobjects[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz][l];
336 if (objects.position[j].y < Person::players[k]->coords.y || objects.type[j] == tunneltype || objects.type[j] == weirdtype) {
337 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);
340 if (k != 0 && tutoriallevel == 1) {
341 opacity = .2 + .2 * sin(smoketex * 6 + i);
343 objects.model[j].MakeDecal(shadowdecal, &point, &size, &opacity, &rotation);
348 if ((Person::players[k]->skeleton.free || Person::players[k]->howactive >= typesleeping) && Person::players[k]->playerdetail)
349 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)
350 for (int i = 0; i < Person::players[k]->skeleton.num_joints; i++) {
351 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) {
352 if (Person::players[k]->skeleton.free)
353 point = Person::players[k]->skeleton.joints[i].position * Person::players[k]->scale + Person::players[k]->coords;
355 point = DoRotation(Person::players[k]->skeleton.joints[i].position, 0, Person::players[k]->yaw, 0) * Person::players[k]->scale + Person::players[k]->coords;
357 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;
358 if (k != 0 && tutoriallevel == 1) {
359 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;
361 terrain.MakeDecal(shadowdecal, point, size, opacity * .7, rotation);
362 for (l = 0; l < terrain.patchobjectnum[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz]; l++) {
363 int j = terrain.patchobjects[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz][l];
364 if (objects.position[j].y < Person::players[k]->coords.y || objects.type[j] == tunneltype || objects.type[j] == weirdtype) {
365 if (Person::players[k]->skeleton.free)
366 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);
368 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);
371 if (k != 0 && tutoriallevel == 1) {
372 opacity = .2 + .2 * sin(smoketex * 6 + i);
374 objects.model[j].MakeDecal(shadowdecal, &point, &size, &opacity, &rotation);
380 if (!Person::players[k]->playerdetail)
381 if (frustum.SphereInFrustum(Person::players[k]->coords.x, Person::players[k]->coords.y, Person::players[k]->coords.z, Person::players[k]->scale * 5)) {
382 point = Person::players[k]->coords;
384 opacity = .4 - (Person::players[k]->coords.y - terrain.getHeight(Person::players[k]->coords.x, Person::players[k]->coords.z)) / 5;
385 terrain.MakeDecal(shadowdecal, point, size, opacity * .7, rotation);
386 for (l = 0; l < terrain.patchobjectnum[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz]; l++) {
387 int j = terrain.patchobjects[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz][l];
388 point = DoRotation(Person::players[k]->coords - objects.position[j], 0, -objects.yaw[j], 0);
391 objects.model[j].MakeDecal(shadowdecal, &point, &size, &opacity, &rotation);
397 glEnable(GL_TEXTURE_2D);
399 glEnable(GL_DEPTH_TEST);
400 glEnable(GL_CULL_FACE);
402 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
403 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
404 terraintexture.bind();
406 terraintexture2.bind();
409 terrain.drawdecals();
412 glEnable(GL_CULL_FACE);
413 glEnable(GL_LIGHTING);
415 glEnable(GL_TEXTURE_2D);
418 glEnable(GL_COLOR_MATERIAL);
433 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
434 glEnable(GL_CULL_FACE);
435 glCullFace(GL_FRONT);
437 for (unsigned k = 0; k < Person::players.size(); k++) {
438 if (k == 0 || tutoriallevel != 1) {
440 glEnable(GL_LIGHTING);
441 terrainlight = terrain.getLighting(Person::players[k]->coords.x, Person::players[k]->coords.z);
442 distance = distsq(&viewer, &Person::players[k]->coords);
443 distance = (viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance;
444 glColor4f(terrainlight.x, terrainlight.y, terrainlight.z, distance);
447 if (distance >= .5) {
448 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;
451 if (Person::players[k]->occluded != 0)
452 i = checkcollide(viewer, checkpoint, Person::players[k]->lastoccluded);
454 i = checkcollide(viewer, checkpoint);
456 Person::players[k]->occluded += 1;
457 Person::players[k]->lastoccluded = i;
459 Person::players[k]->occluded = 0;
461 if (Person::players[k]->occluded < 25)
462 Person::players[k]->DrawSkeleton();
468 if (!cameramode && musictype == stream_fighttheme)
469 playerdist = distsqflat(&Person::players[0]->coords, &viewer);
474 glEnable(GL_TEXTURE_2D);
480 if (frustum.SphereInFrustum(realhawkcoords.x + hawk.boundingspherecenter.x, realhawkcoords.y + hawk.boundingspherecenter.y, realhawkcoords.z + hawk.boundingspherecenter.z, 2)) {
481 glAlphaFunc(GL_GREATER, 0.0001f);
483 glDisable(GL_CULL_FACE);
484 glDisable(GL_LIGHTING);
486 glTranslatef(hawkcoords.x, hawkcoords.y, hawkcoords.z);
487 glRotatef(hawkyaw, 0, 1, 0);
488 glTranslatef(25, 0, 0);
489 distance = distsq(&viewer, &realhawkcoords) * 1.2;
490 glColor4f(light.color[0], light.color[1], light.color[2], (viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance);
491 if ((viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance > 1)
492 glColor4f(light.color[0], light.color[1], light.color[2], 1);
493 if ((viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance > 0)
494 hawk.drawdifftex(hawktexture);
498 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
499 glEnable(GL_CULL_FACE);
500 glCullFace(GL_FRONT);
502 for (unsigned k = 0; k < Person::players.size(); k++) {
503 if (!(k == 0 || tutoriallevel != 1)) {
505 glEnable(GL_LIGHTING);
506 terrainlight = terrain.getLighting(Person::players[k]->coords.x, Person::players[k]->coords.z);
507 distance = distsq(&viewer, &Person::players[k]->coords);
508 distance = (viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance;
509 glColor4f(terrainlight.x, terrainlight.y, terrainlight.z, distance);
512 if (distance >= .5) {
513 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;
516 if (Person::players[k]->occluded != 0)
517 i = checkcollide(viewer, checkpoint, Person::players[k]->lastoccluded);
519 i = checkcollide(viewer, checkpoint);
521 Person::players[k]->occluded += 1;
522 Person::players[k]->lastoccluded = i;
524 Person::players[k]->occluded = 0;
526 if (Person::players[k]->occluded < 25)
527 Person::players[k]->DrawSkeleton();
533 glEnable(GL_TEXTURE_2D);
538 glDisable(GL_COLOR_MATERIAL);
540 glDisable(GL_LIGHTING);
541 glDisable(GL_TEXTURE_2D);
547 //waypoints, pathpoints in editor
550 glDisable(GL_LIGHTING);
551 glDisable(GL_TEXTURE_2D);
552 glDisable(GL_COLOR_MATERIAL);
553 glColor4f(1, 1, 0, 1);
555 for (unsigned k = 0; k < Person::players.size(); k++) {
556 if (Person::players[k]->numwaypoints > 1) {
557 glBegin(GL_LINE_LOOP);
558 for (int i = 0; i < Person::players[k]->numwaypoints; i++) {
559 glVertex3f(Person::players[k]->waypoints[i].x, Person::players[k]->waypoints[i].y + .5, Person::players[k]->waypoints[i].z);
566 if (numpathpoints > 1) {
567 glColor4f(0, 1, 0, 1);
568 for (unsigned k = 0; int(k) < numpathpoints; k++) {
569 if (numpathpointconnect[k]) {
570 for (int i = 0; i < numpathpointconnect[k]; i++) {
571 glBegin(GL_LINE_LOOP);
572 glVertex3f(pathpoint[k].x, pathpoint[k].y + .5, pathpoint[k].z);
573 glVertex3f(pathpoint[pathpointconnect[k][i]].x, pathpoint[pathpointconnect[k][i]].y + .5, pathpoint[pathpointconnect[k][i]].z);
578 glColor4f(1, 1, 1, 1);
581 glVertex3f(pathpoint[pathpointselected].x, pathpoint[pathpointselected].y + .5, pathpoint[pathpointselected].z);
588 glEnable(GL_TEXTURE_2D);
589 glColor4f(.5, .5, .5, 1);
592 if (bonus > 0 && bonustime < 1 && !winfreeze && indialogue == -1/*bonustime<4*/) {
593 const char *bonus_name;
594 if (bonus < bonus_count)
595 bonus_name = bonus_names[bonus];
597 bonus_name = "Excellent!"; // When does this happen?
599 glColor4f(0, 0, 0, 1 - bonustime);
600 text->glPrintOutline(1024 / 2 - 10 * strlen(bonus_name) - 4, 768 / 16 - 4 + 768 * 4 / 5, bonus_name, 1, 2.5, 1024, 768);
601 glColor4f(1, 0, 0, 1 - bonustime);
602 text->glPrint(1024 / 2 - 10 * strlen(bonus_name), 768 / 16 + 768 * 4 / 5, bonus_name, 1, 2, 1024, 768);
604 sprintf (string, "%d", (int)bonusvalue);
605 glColor4f(0, 0, 0, 1 - bonustime);
606 text->glPrintOutline(1024 / 2 - 10 * strlen(string) - 4, 768 / 16 - 4 - 20 + 768 * 4 / 5, string, 1, 2.5 * .8, 1024, 768);
607 glColor4f(1, 0, 0, 1 - bonustime);
608 text->glPrint(1024 / 2 - 10 * strlen(string), 768 / 16 - 20 + 768 * 4 / 5, string, 1, 2 * .8, 1024, 768);
609 glColor4f(.5, .5, .5, 1);
612 if (tutoriallevel == 1) {
613 tutorialopac = tutorialmaxtime - tutorialstagetime;
614 if (tutorialopac > 1)
616 if (tutorialopac < 0)
619 sprintf (string, " ");
620 sprintf (string2, " ");
621 sprintf (string3, " ");
622 if (tutorialstage == 0) {
623 sprintf (string, " ");
624 sprintf (string2, " ");
625 sprintf (string3, " ");
627 if (tutorialstage == 1) {
628 sprintf (string, "Welcome to the Lugaru training level!");
629 sprintf (string2, " ");
630 sprintf (string3, " ");
632 if (tutorialstage == 2) {
633 sprintf (string, "BASIC MOVEMENT:");
634 sprintf (string2, " ");
635 sprintf (string3, " ");
637 if (tutorialstage == 3) {
638 sprintf (string, "You can move the mouse to rotate the camera.");
639 sprintf (string2, " ");
640 sprintf (string3, " ");
642 if (tutorialstage == 4) {
643 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));
644 sprintf (string2, "All movement is relative to the camera.");
645 sprintf (string3, " ");
647 if (tutorialstage == 5) {
648 sprintf (string, "Please press %s to jump.", Input::keyToChar(jumpkey));
649 sprintf (string2, "You can hold it longer to jump higher.");
650 sprintf (string3, " ");
652 if (tutorialstage == 6) {
653 sprintf (string, "You can press %s to crouch.", Input::keyToChar(crouchkey));
654 sprintf (string2, "You can jump higher from a crouching position.");
655 sprintf (string3, " ");
657 if (tutorialstage == 7) {
658 sprintf (string, "While running, you can press %s to roll.", Input::keyToChar(crouchkey));
659 sprintf (string2, " ");
660 sprintf (string3, " ");
662 if (tutorialstage == 8) {
663 sprintf (string, "While crouching, you can sneak around silently");
664 sprintf (string2, "using the movement keys.");
665 sprintf (string3, " ");
667 if (tutorialstage == 9) {
668 sprintf (string, "Release the crouch key while sneaking and hold the movement keys");
669 sprintf (string2, "to run animal-style.");
670 sprintf (string3, " ");
672 if (tutorialstage == 10) {
673 sprintf (string, "ADVANCED MOVEMENT:");
674 sprintf (string2, " ");
675 sprintf (string3, " ");
677 if (tutorialstage == 11) {
678 sprintf (string, "When you jump at a wall, you can hold %s again", Input::keyToChar(jumpkey));
679 sprintf (string2, "during impact to perform a walljump.");
680 sprintf (string3, "Be sure to use the movement keys to press against the wall");
682 if (tutorialstage == 12) {
683 sprintf (string, "While in the air, you can press crouch to flip.");
684 sprintf (string2, "Walljumps and flips confuse enemies and give you more control.");
685 sprintf (string3, " ");
687 if (tutorialstage == 13) {
688 sprintf (string, "BASIC COMBAT:");
689 sprintf (string2, " ");
690 sprintf (string3, " ");
692 if (tutorialstage == 14) {
693 sprintf (string, "There is now an imaginary enemy");
694 sprintf (string2, "in the middle of the training area.");
695 sprintf (string3, " ");
697 if (tutorialstage == 15) {
698 if (attackkey == MOUSEBUTTON1)
699 sprintf (string, "Click to attack when you are near an enemy.");
701 sprintf (string, "Press %s to attack when you are near an enemy.", Input::keyToChar(attackkey));
702 sprintf (string2, "You can punch by standing still near an enemy and attacking.");
703 sprintf (string3, " ");
705 if (tutorialstage == 16) {
706 sprintf (string, "If you are close, you will perform a weak punch.");
707 sprintf (string2, "The weak punch is excellent for starting attack combinations.");
708 sprintf (string3, " ");
710 if (tutorialstage == 17) {
711 sprintf (string, "Attacking while running results in a spin kick.");
712 sprintf (string2, "This is one of your most powerful ground attacks.");
713 sprintf (string3, " ");
715 if (tutorialstage == 18) {
716 sprintf (string, "Sweep the enemy's legs out by attacking while crouched.");
717 sprintf (string2, "This is a very fast attack, and easy to follow up.");
718 sprintf (string3, " ");
720 if (tutorialstage == 19) {
721 sprintf (string, "When an enemy is on the ground, you can deal some extra");
722 sprintf (string2, "damage by running up and drop-kicking him.");
723 sprintf (string3, "(Try knocking them down with a sweep first)");
725 if (tutorialstage == 20) {
726 sprintf (string, "Your most powerful individual attack is the rabbit kick.");
727 if (attackkey == MOUSEBUTTON1)
728 sprintf (string2, "Run at the enemy while holding the mouse button, and press");
730 sprintf (string2, "Run at the enemy while holding %s, and press", Input::keyToChar(attackkey));
731 sprintf (string3, "the jump key (%s) to attack.", Input::keyToChar(jumpkey));
733 if (tutorialstage == 21) {
734 sprintf (string, "This attack is devastating if timed correctly.");
735 sprintf (string2, "Even if timed incorrectly, it will knock the enemy over.");
737 sprintf (string3, "Try rabbit-kicking the imaginary enemy again.");
739 sprintf (string3, "Try rabbit-kicking the imaginary enemy.");
741 if (tutorialstage == 22) {
742 sprintf (string, "If you sneak behind an enemy unnoticed, you can kill");
743 sprintf (string2, "him instantly. Move close behind this enemy");
744 sprintf (string3, "and attack.");
746 if (tutorialstage == 23) {
747 sprintf (string, "Another important attack is the wall kick. When an enemy");
748 sprintf (string2, "is near a wall, perform a walljump nearby and hold");
749 sprintf (string3, "the attack key during impact with the wall.");
751 if (tutorialstage == 24) {
752 sprintf (string, "You can tackle enemies by running at them animal-style");
753 if (attackkey == MOUSEBUTTON1)
754 sprintf (string2, "and pressing jump (%s) or attack(mouse button).", Input::keyToChar(jumpkey));
756 sprintf (string2, "and pressing jump (%s) or attack(%s).", Input::keyToChar(jumpkey), Input::keyToChar(attackkey));
757 sprintf (string3, "This is especially useful when they are running away.");
759 if (tutorialstage == 25) {
760 sprintf (string, "Dodge by pressing back and attack. Dodging is essential");
761 sprintf (string2, "against enemies with swords or other long weapons.");
762 sprintf (string3, " ");
764 if (tutorialstage == 26) {
765 sprintf (string, "REVERSALS AND COUNTER-REVERSALS");
766 sprintf (string2, " ");
767 sprintf (string3, " ");
769 if (tutorialstage == 27) {
770 sprintf (string, "The enemy can now reverse your attacks.");
771 sprintf (string2, " ");
772 sprintf (string3, " ");
774 if (tutorialstage == 28) {
775 sprintf (string, "If you attack, you will notice that the enemy now sometimes");
776 sprintf (string2, "catches your attack and uses it against you. Hold");
777 sprintf (string3, "crouch (%s) after attacking to escape from reversals.", Input::keyToChar(crouchkey));
779 if (tutorialstage == 29) {
780 sprintf (string, "Try escaping from two more reversals in a row.");
781 sprintf (string2, " ");
782 sprintf (string3, " ");
784 if (tutorialstage == 30) {
785 sprintf (string, "Good!");
786 sprintf (string2, " ");
787 sprintf (string3, " ");
789 if (tutorialstage == 31) {
790 sprintf (string, "To reverse an attack, you must tap crouch (%s) during the", Input::keyToChar(crouchkey));
791 sprintf (string2, "enemy's attack. You must also be close to the enemy;");
792 sprintf (string3, "this is especially important against armed opponents.");
794 if (tutorialstage == 32) {
795 sprintf (string, "The enemy can attack in %d seconds.", (int)(tutorialmaxtime - tutorialstagetime));
796 sprintf (string2, "This imaginary opponents attacks will be highlighted");
797 sprintf (string3, "to make this easier.");
799 if (tutorialstage == 33) {
800 sprintf (string, "Reverse three enemy attacks!");
801 sprintf (string2, " ");
802 sprintf (string3, " ");
804 if (tutorialstage == 34) {
805 sprintf (string, "Reverse two more enemy attacks!");
806 sprintf (string2, " ");
807 sprintf (string3, " ");
809 if (tutorialstage == 35) {
810 sprintf (string, "Reverse one more enemy attack!");
811 sprintf (string2, " ");
812 sprintf (string3, " ");
814 if (tutorialstage == 36) {
815 sprintf (string, "Excellent!");
816 sprintf (string2, " ");
817 sprintf (string3, " ");
819 if (tutorialstage == 37) {
820 sprintf (string, "Now spar with the enemy for %d more seconds.", (int)(tutorialmaxtime - tutorialstagetime));
821 sprintf (string2, "Damage dealt: %d", (int)damagedealt);
822 sprintf (string3, "Damage taken: %d.", (int)damagetaken);
824 if (tutorialstage == 38) {
825 sprintf (string, "WEAPONS:");
826 sprintf (string2, " ");
827 sprintf (string3, " ");
829 if (tutorialstage == 39) {
830 sprintf (string, "There is now an imaginary knife");
831 sprintf (string2, "in the center of the training area.");
832 sprintf (string3, " ");
834 if (tutorialstage == 40) {
835 sprintf (string, "Stand, roll or handspring over the knife");
836 sprintf (string2, "while pressing %s to pick it up.", Input::keyToChar(throwkey));
837 sprintf (string3, "You can crouch and press the same key to drop it again.");
839 if (tutorialstage == 41) {
840 sprintf (string, "You can equip and unequip weapons using the %s key.", Input::keyToChar(drawkey));
841 sprintf (string2, "Sometimes it is best to keep them unequipped to");
842 sprintf (string3, "prevent enemies from taking them. ");
844 if (tutorialstage == 42) {
845 sprintf (string, "The knife is the smallest weapon and the least encumbering.");
846 sprintf (string2, "You can equip or unequip it while standing, crouching,");
847 sprintf (string3, "running or flipping.");
849 if (tutorialstage == 43) {
850 sprintf (string, "You perform weapon attacks the same way as unarmed attacks,");
851 sprintf (string2, "but sharp weapons cause permanent damage, instead of the");
852 sprintf (string3, "temporary trauma from blunt weapons, fists and feet.");
854 if (tutorialstage == 44) {
855 sprintf (string, "The enemy now has your knife!");
856 sprintf (string2, "Please reverse two of his knife attacks.");
857 sprintf (string3, " ");
859 if (tutorialstage == 45) {
860 sprintf (string, "Please reverse one more of his knife attacks.");
861 sprintf (string2, " ");
862 sprintf (string3, " ");
864 if (tutorialstage == 46) {
865 sprintf (string, "Now he has a sword!");
866 sprintf (string2, "The sword has longer reach than your arms, so you");
867 sprintf (string3, "must move close to reverse the sword slash.");
869 if (tutorialstage == 47) {
870 sprintf (string, "Long weapons like the sword and staff are also useful for defense;");
871 sprintf (string2, "you can parry enemy weapon attacks by pressing the attack key");
872 sprintf (string3, "at the right time. Please try parrying the enemy's attacks!");
874 if (tutorialstage == 48) {
875 sprintf (string, "The staff is like the sword, but has two main attacks.");
876 sprintf (string2, "The standing smash is fast and effective, and the running");
877 sprintf (string3, "spin smash is slower and more powerful.");
879 if (tutorialstage == 49) {
880 sprintf (string, "When facing an enemy, you can throw the knife with %s.", Input::keyToChar(throwkey));
881 sprintf (string2, "It is possible to throw the knife while flipping,");
882 sprintf (string3, "but it is very inaccurate.");
884 if (tutorialstage == 50) {
885 sprintf (string, "You now know everything you can learn from training.");
886 sprintf (string2, "Everything else you must learn from experience!");
887 sprintf (string3, " ");
889 if (tutorialstage == 51) {
890 sprintf (string, "Walk out of the training area to return to the main menu.");
891 sprintf (string2, " ");
892 sprintf (string3, " ");
895 glColor4f(0, 0, 0, tutorialopac);
896 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);
897 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);
898 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);
899 glColor4f(1, 1, 1, tutorialopac);
900 text->glPrint(screenwidth / 2 - 7.6 * strlen(string)*screenwidth / 1024, screenheight / 16 + screenheight * 4 / 5, string, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight);
901 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);
902 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);
904 sprintf (string, "Press 'tab' to skip to the next item.");
905 sprintf (string2, "Press escape at any time to");
906 sprintf (string3, "pause or exit the tutorial.");
908 glColor4f(0, 0, 0, 1);
909 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);
910 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);
911 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);
912 glColor4f(0.5, 0.5, 0.5, 1);
913 text->glPrint(screenwidth / 2 - 7.6 * strlen(string)*screenwidth / 1024 * .8, 0 + screenheight * 1 / 10, string, 1, 1.5 * screenwidth / 1024 * .8, screenwidth, screenheight);
914 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);
915 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);
919 if (numhotspots && (bonustime >= 1 || bonus <= 0 || bonustime < 0) && !tutoriallevel) {
920 float closestdist = -1;
922 int closest = currenthotspot;
923 for (int i = 0; i < numhotspots; i++) {
924 distance = distsq(&Person::players[0]->coords, &hotspot[i]);
925 if (closestdist == -1 || distance < closestdist) {
926 if (distsq(&Person::players[0]->coords, &hotspot[i]) < hotspotsize[i] && ((hotspottype[i] <= 10 && hotspottype[i] >= 0) || (hotspottype[i] <= 40 && hotspottype[i] >= 20))) {
927 closestdist = distance;
933 currenthotspot = closest;
934 if (currenthotspot != -1) {
935 if (hotspottype[closest] <= 10) {
936 if (distsq(&Person::players[0]->coords, &hotspot[closest]) < hotspotsize[closest])
937 tutorialstagetime = 0;
939 tutorialopac = tutorialmaxtime - tutorialstagetime;
940 if (tutorialopac > 1)
942 if (tutorialopac < 0)
945 sprintf (string, "%s", hotspottext[closest]);
952 if (string[i] == '\n' || string[i] > 'z' || string[i] < ' ' || string[i] == '\0') {
953 glColor4f(0, 0, 0, tutorialopac);
954 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);
955 glColor4f(1, 1, 1, tutorialopac);
956 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);
959 if (string[i] == '\0')
966 } else if (hotspottype[closest] >= 20 && dialoguegonethrough[hotspottype[closest] - 20] == 0) {
967 whichdialogue = hotspottype[closest] - 20;
968 for (int j = 0; j < numdialogueboxes[whichdialogue]; j++) {
969 Person::players[participantfocus[whichdialogue][j]]->coords = participantlocation[whichdialogue][participantfocus[whichdialogue][j]];
970 Person::players[participantfocus[whichdialogue][j]]->yaw = participantyaw[whichdialogue][participantfocus[whichdialogue][j]];
971 Person::players[participantfocus[whichdialogue][j]]->targetyaw = participantyaw[whichdialogue][participantfocus[whichdialogue][j]];
972 Person::players[participantfocus[whichdialogue][j]]->velocity = 0;
973 Person::players[participantfocus[whichdialogue][j]]->animTarget = Person::players[participantfocus[whichdialogue][j]]->getIdle();
974 Person::players[participantfocus[whichdialogue][j]]->frameTarget = 0;
978 dialoguegonethrough[whichdialogue]++;
979 if (dialogueboxsound[whichdialogue][indialogue] != 0) {
981 if (dialogueboxsound[whichdialogue][indialogue] == 1) whichsoundplay = rabbitchitter;
982 if (dialogueboxsound[whichdialogue][indialogue] == 2) whichsoundplay = rabbitchitter2;
983 if (dialogueboxsound[whichdialogue][indialogue] == 3) whichsoundplay = rabbitpainsound;
984 if (dialogueboxsound[whichdialogue][indialogue] == 4) whichsoundplay = rabbitpain1sound;
985 if (dialogueboxsound[whichdialogue][indialogue] == 5) whichsoundplay = rabbitattacksound;
986 if (dialogueboxsound[whichdialogue][indialogue] == 6) whichsoundplay = rabbitattack2sound;
987 if (dialogueboxsound[whichdialogue][indialogue] == 7) whichsoundplay = rabbitattack3sound;
988 if (dialogueboxsound[whichdialogue][indialogue] == 8) whichsoundplay = rabbitattack4sound;
989 if (dialogueboxsound[whichdialogue][indialogue] == 9) whichsoundplay = growlsound;
990 if (dialogueboxsound[whichdialogue][indialogue] == 10) whichsoundplay = growl2sound;
991 if (dialogueboxsound[whichdialogue][indialogue] == 11) whichsoundplay = snarlsound;
992 if (dialogueboxsound[whichdialogue][indialogue] == 12) whichsoundplay = snarl2sound;
993 if (dialogueboxsound[whichdialogue][indialogue] == 13) whichsoundplay = barksound;
994 if (dialogueboxsound[whichdialogue][indialogue] == 14) whichsoundplay = bark2sound;
995 if (dialogueboxsound[whichdialogue][indialogue] == 15) whichsoundplay = bark3sound;
996 if (dialogueboxsound[whichdialogue][indialogue] == 16) whichsoundplay = barkgrowlsound;
997 if (dialogueboxsound[whichdialogue][indialogue] == -1) whichsoundplay = fireendsound;
998 if (dialogueboxsound[whichdialogue][indialogue] == -2) whichsoundplay = firestartsound;
999 if (dialogueboxsound[whichdialogue][indialogue] == -3) whichsoundplay = consolesuccesssound;
1000 if (dialogueboxsound[whichdialogue][indialogue] == -4) whichsoundplay = consolefailsound;
1001 emit_sound_at(whichsoundplay, Person::players[participantfocus[whichdialogue][indialogue]]->coords);
1007 if (indialogue != -1 && !mainmenu) {
1008 glDisable(GL_DEPTH_TEST);
1009 glDisable(GL_CULL_FACE);
1010 glDisable(GL_LIGHTING);
1011 glDisable(GL_TEXTURE_2D);
1013 glMatrixMode(GL_PROJECTION);
1016 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1017 glMatrixMode(GL_MODELVIEW);
1020 if (dialogueboxlocation[whichdialogue][indialogue] == 1)
1021 glTranslatef(0, screenheight * 3 / 4, 0);
1022 glScalef(screenwidth, screenheight / 4, 1);
1023 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1026 glColor4f(dialogueboxcolor[whichdialogue][indialogue][0], dialogueboxcolor[whichdialogue][indialogue][1], dialogueboxcolor[whichdialogue][indialogue][2], 0.7);
1028 glVertex3f(0, 0, 0.0f);
1029 glVertex3f(1, 0, 0.0f);
1030 glVertex3f(1, 1, 0.0f);
1031 glVertex3f(0, 1, 0.0f);
1033 glMatrixMode(GL_PROJECTION);
1035 glMatrixMode(GL_MODELVIEW);
1037 glEnable(GL_DEPTH_TEST);
1038 glEnable(GL_CULL_FACE);
1039 glDisable(GL_BLEND);
1041 glEnable(GL_TEXTURE_2D);
1048 startx = screenwidth * 1 / 5;
1049 if (dialogueboxlocation[whichdialogue][indialogue] == 1)
1050 starty = screenheight / 16 + screenheight * 4 / 5;
1051 if (dialogueboxlocation[whichdialogue][indialogue] == 2)
1052 starty = screenheight * 1 / 5 - screenheight / 16;
1057 for (int i = 0; i < 264; i++) {
1061 for (int i = 0; i < (int)strlen(dialoguename[whichdialogue][indialogue]); i++) {
1062 tempname[tempnum] = dialoguename[whichdialogue][indialogue][i];
1064 if (dialoguename[whichdialogue][indialogue][i] == '#' || dialoguename[whichdialogue][indialogue][i] == '\0')
1069 tempname[tempnum] = '\0';
1072 sprintf (string, "%s: ", tempname);
1074 if (dialogueboxcolor[whichdialogue][indialogue][0] + dialogueboxcolor[whichdialogue][indialogue][1] + dialogueboxcolor[whichdialogue][indialogue][2] < 1.5) {
1075 glColor4f(0, 0, 0, tutorialopac);
1076 text->glPrintOutline(startx - 2 * 7.6 * strlen(string)*screenwidth / 1024 - 4, starty - 4, string, 1, 1.5 * 1.25 * screenwidth / 1024, screenwidth, screenheight);
1077 glColor4f(0.7, 0.7, 0.7, tutorialopac);
1078 text->glPrint(startx - 2 * 7.6 * strlen(string)*screenwidth / 1024, starty, string, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight);
1080 glColor4f(0, 0, 0, tutorialopac);
1081 text->glPrintOutline(startx - 2 * 7.6 * strlen(string)*screenwidth / 1024 - 4, starty - 4, string, 1, 1.5 * 1.25 * screenwidth / 1024, screenwidth, screenheight);
1085 for (int i = 0; i < (int)strlen(dialoguetext[whichdialogue][indialogue]) + 1; i++) {
1086 tempname[tempnum] = dialoguetext[whichdialogue][indialogue][i];
1087 if (dialoguetext[whichdialogue][indialogue][i] != '#')
1091 sprintf (string, "%s", tempname);
1098 if (string[i] == '\n' || string[i] > 'z' || string[i] < ' ' || string[i] == '\0') {
1099 if (dialogueboxcolor[whichdialogue][indialogue][0] + dialogueboxcolor[whichdialogue][indialogue][1] + dialogueboxcolor[whichdialogue][indialogue][2] < 1.5) {
1100 glColor4f(0, 0, 0, tutorialopac);
1101 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);
1102 glColor4f(1, 1, 1, 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);
1105 glColor4f(0, 0, 0, tutorialopac);
1106 text->glPrint(startx/*-7.6*(i-lastline)*screenwidth/1024*/, starty - 20 * screenwidth / 1024 * line, string, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight, lastline, i);
1110 if (string[i] == '\0')
1119 if (!tutoriallevel && !winfreeze && indialogue == -1 && !mainmenu) {
1122 sprintf (string, "Score: %d", (int)accountactive->getCampaignScore());
1124 sprintf (string, "Score: %d", (int)accountactive->getCampaignScore() + (int)bonustotal);
1127 sprintf (string, "Score: %d", (int)bonustotal);
1128 glColor4f(0, 0, 0, 1);
1129 text->glPrintOutline(1024 / 40 - 4, 768 / 16 - 4 + 768 * 14 / 16, string, 1, 1.5 * 1.25, 1024, 768);
1130 glColor4f(1, 0, 0, 1);
1131 text->glPrint(1024 / 40, 768 / 16 + 768 * 14 / 16, string, 1, 1.5, 1024, 768);
1132 if (showdamagebar) {
1133 glDisable(GL_DEPTH_TEST);
1134 glDisable(GL_CULL_FACE);
1135 glDisable(GL_LIGHTING);
1136 glDisable(GL_TEXTURE_2D);
1138 glMatrixMode(GL_PROJECTION);
1141 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1142 glMatrixMode(GL_MODELVIEW);
1145 glTranslatef(15, screenheight * 17.5 / 20, 0);
1146 glScalef(screenwidth / 3 + 20, screenheight / 20, 1);
1147 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1149 glColor4f(0.0, 0.4, 0.0, 0.7);
1150 float bar = ((float)Person::players[0]->damage) / Person::players[0]->damagetolerance;
1152 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
1153 glVertex3f(1, 0, 0.0f);
1154 glVertex3f(1, 1, 0.0f);
1155 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
1157 glColor4f(0.1, 0.0, 0.0, 1);
1158 bar = ((float)Person::players[0]->bloodloss) / Person::players[0]->damagetolerance;
1160 glVertex3f(0, 0, 0.0f);
1161 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
1162 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
1163 glVertex3f(0, 1, 0.0f);
1165 glColor4f(0.4, 0.0, 0.0, 0.7);
1166 bar = ((float)Person::players[0]->damage) / Person::players[0]->damagetolerance;
1168 glVertex3f(0, 0, 0.0f);
1169 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
1170 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
1171 glVertex3f(0, 1, 0.0f);
1173 glColor4f(0.4, 0.0, 0.0, 0.7);
1174 bar = ((float)Person::players[0]->permanentdamage) / Person::players[0]->damagetolerance;
1176 glVertex3f(0, 0, 0.0f);
1177 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
1178 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
1179 glVertex3f(0, 1, 0.0f);
1181 glColor4f(0.4, 0.0, 0.0, 0.7);
1182 bar = ((float)Person::players[0]->superpermanentdamage) / Person::players[0]->damagetolerance;
1184 glVertex3f(0, 0, 0.0f);
1185 glVertex3f((bar < 1 ? bar : 1), 0, 0.0f);
1186 glVertex3f((bar < 1 ? bar : 1), 1, 0.0f);
1187 glVertex3f(0, 1, 0.0f);
1189 glColor4f(0.0, 0.0, 0.0, 0.7);
1191 glBegin(GL_LINE_STRIP);
1192 glVertex3f(0, 0, 0.0f);
1193 glVertex3f(1, 0, 0.0f);
1194 glVertex3f(1, 1, 0.0f);
1195 glVertex3f(0, 1, 0.0f);
1196 glVertex3f(0, 0, 0.0f);
1199 glMatrixMode(GL_PROJECTION);
1201 glMatrixMode(GL_MODELVIEW);
1203 glEnable(GL_DEPTH_TEST);
1204 glEnable(GL_CULL_FACE);
1205 glDisable(GL_BLEND);
1207 glEnable(GL_TEXTURE_2D);
1209 // writing the numbers :
1210 sprintf (string, "Damages : %d/%d (%d)", (int)(Person::players[0]->damage), (int)(Person::players[0]->damagetolerance), (int)(Person::players[0]->bloodloss));
1211 glColor4f(0, 0, 0, 1);
1212 text->glPrintOutline(1024 / 40 - 4, 768 / 16 - 4 + 768 * 14 / 16 - 40, string, 1, 1.5 * 1.25, 1024, 768);
1213 glColor4f(1, 0, 0, 1);
1214 text->glPrint(1024 / 40, 768 / 16 + 768 * 14 / 16 - 40, string, 1, 1.5, 1024, 768);
1218 glColor4f(.5, .5, .5, 1);
1221 if ((texttoggle || editorenabled) && debugmode && !mainmenu) {
1222 sprintf (string, "The framespersecond is %d.", (int)(fps));
1223 text->glPrint(10, 30, string, 0, .8, 1024, 768);
1226 sprintf (string, "Map editor enabled.");
1228 sprintf (string, "Map editor disabled.");
1229 text->glPrint(10, 60, string, 0, .8, 1024, 768);
1230 if (editorenabled) {
1231 sprintf (string, "Object size: %f", editorsize);
1232 text->glPrint(10, 75, string, 0, .8, 1024, 768);
1234 sprintf (string, "Object yaw: %f", editoryaw);
1236 sprintf (string, "Object yaw: Random");
1237 text->glPrint(10, 90, string, 0, .8, 1024, 768);
1238 if (editorpitch >= 0)
1239 sprintf (string, "Object pitch: %f", editorpitch);
1241 sprintf (string, "Object pitch: Random");
1242 text->glPrint(10, 105, string, 0, .8, 1024, 768);
1243 sprintf (string, "Object type: %d", editortype);
1244 text->glPrint(10, 120, string, 0, .8, 1024, 768);
1245 switch (editortype) {
1247 sprintf (string, "(box)");
1250 sprintf (string, "(tree)");
1253 sprintf (string, "(wall)");
1256 sprintf (string, "(weird)");
1259 sprintf (string, "(spike)");
1262 sprintf (string, "(rock)");
1265 sprintf (string, "(bush)");
1268 sprintf (string, "(tunnel)");
1271 sprintf (string, "(chimney)");
1274 sprintf (string, "(platform)");
1277 sprintf (string, "(cool)");
1280 sprintf (string, "(fire)");
1283 text->glPrint(130, 120, string, 0, .8, 1024, 768);
1285 sprintf (string, "Numplayers: %lu", Person::players.size());
1286 text->glPrint(10, 155, string, 0, .8, 1024, 768);
1287 sprintf (string, "Player %d: numwaypoints: %d", (int(Person::players.size()) - 1), Person::players.back()->numwaypoints);
1288 text->glPrint(10, 140, string, 0, .8, 1024, 768);
1290 sprintf (string, "Difficulty: %d", difficulty);
1291 text->glPrint(10, 240, string, 0, .8, 1024, 768);
1296 if (drawmode == glowmode) {
1297 glDisable(GL_DEPTH_TEST);
1298 glDisable(GL_CULL_FACE);
1299 glDisable(GL_LIGHTING);
1300 glDisable(GL_TEXTURE_2D);
1302 glMatrixMode(GL_PROJECTION);
1305 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1306 glMatrixMode(GL_MODELVIEW);
1309 glScalef(screenwidth, screenheight, 1);
1310 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1312 glColor4f(0, 0, 0, .5);
1314 glVertex3f(0, 0, 0.0f);
1315 glVertex3f(256, 0, 0.0f);
1316 glVertex3f(256, 256, 0.0f);
1317 glVertex3f(0, 256, 0.0f);
1319 glMatrixMode(GL_PROJECTION);
1321 glMatrixMode(GL_MODELVIEW);
1323 glEnable(GL_DEPTH_TEST);
1324 glEnable(GL_CULL_FACE);
1325 glDisable(GL_BLEND);
1329 if ((((blackout && damageeffects) || (Person::players[0]->bloodloss > 0 && damageeffects && Person::players[0]->blooddimamount > 0) || Person::players[0]->dead) && !cameramode) || console) {
1330 glDisable(GL_DEPTH_TEST);
1331 glDisable(GL_CULL_FACE);
1332 glDisable(GL_LIGHTING);
1333 glDisable(GL_TEXTURE_2D);
1335 glMatrixMode(GL_PROJECTION);
1338 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1339 glMatrixMode(GL_MODELVIEW);
1342 glScalef(screenwidth, screenheight, 1);
1343 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1345 if (Person::players[0]->dead)
1346 blackout += multiplier * 3;
1347 if (Person::players[0]->dead == 1)
1349 if (Person::players[0]->dead == 2 && blackout > .6)
1351 glColor4f(0, 0, 0, blackout);
1352 if (!Person::players[0]->dead) {
1353 if ((Person::players[0]->bloodloss / Person::players[0]->damagetolerance * (sin(woozy) / 4 + .5))*.3 < .3) {
1354 glColor4f(0, 0, 0, Person::players[0]->blooddimamount * Person::players[0]->bloodloss / Person::players[0]->damagetolerance * (sin(woozy) / 4 + .5)*.3);
1355 blackout = Person::players[0]->blooddimamount * Person::players[0]->bloodloss / Person::players[0]->damagetolerance * (sin(woozy) / 4 + .5) * .3;
1357 glColor4f(0, 0, 0, Person::players[0]->blooddimamount * .3);
1358 blackout = Person::players[0]->blooddimamount * .3;
1362 glColor4f(.7, 0, 0, .2);
1364 glVertex3f(0, 0, 0.0f);
1365 glVertex3f(256, 0, 0.0f);
1366 glVertex3f(256, 256, 0.0f);
1367 glVertex3f(0, 256, 0.0f);
1369 glMatrixMode(GL_PROJECTION);
1371 glMatrixMode(GL_MODELVIEW);
1373 glEnable(GL_DEPTH_TEST);
1374 glEnable(GL_CULL_FACE);
1375 glDisable(GL_BLEND);
1379 if (flashamount > 0 && damageeffects) {
1380 if (flashamount > 1)
1382 if (flashdelay <= 0)
1383 flashamount -= multiplier;
1385 if (flashamount < 0)
1387 glDisable(GL_DEPTH_TEST);
1388 glDisable(GL_CULL_FACE);
1389 glDisable(GL_LIGHTING);
1391 glMatrixMode(GL_PROJECTION);
1394 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1395 glMatrixMode(GL_MODELVIEW);
1398 glScalef(screenwidth, screenheight, 1);
1399 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1401 glColor4f(flashr, flashg, flashb, flashamount);
1403 glVertex3f(0, 0, 0.0f);
1404 glVertex3f(256, 0, 0.0f);
1405 glVertex3f(256, 256, 0.0f);
1406 glVertex3f(0, 256, 0.0f);
1408 glMatrixMode(GL_PROJECTION);
1410 glMatrixMode(GL_MODELVIEW);
1412 glEnable(GL_DEPTH_TEST);
1413 glEnable(GL_CULL_FACE);
1414 glDisable(GL_BLEND);
1420 glEnable(GL_TEXTURE_2D);
1421 glColor4f(1, 1, 1, 1);
1422 for (unsigned i = 1; i < 15; i++)
1423 if (displaytime[i] < 4)
1424 for (unsigned j = 0; j < displaytext[i].size(); j++) {
1425 glColor4f(1, 1, 1, 4 - displaytime[i]);
1426 sprintf (string, "%c", displaytext[i][j]);
1427 text->glPrint(30 + j * 10, 30 + i * 20 + (screenheight - 330), string, 0, 1, screenwidth, screenheight);
1431 if (difficulty < 2 && indialogue == -1) { // minimap
1432 float mapviewdist = 20000;
1434 glDisable(GL_DEPTH_TEST);
1435 glColor3f (1.0, 1.0, 1.0); // no coloring
1437 glEnable(GL_TEXTURE_2D);
1438 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1439 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1440 glDisable(GL_DEPTH_TEST);
1441 glDisable(GL_CULL_FACE);
1442 glDisable(GL_LIGHTING);
1444 glMatrixMode(GL_PROJECTION);
1447 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1448 glMatrixMode(GL_MODELVIEW);
1451 glScalef((float)screenwidth / 2, (float)screenwidth / 2, 1);
1452 glTranslatef(1.75, .25, 0);
1453 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1455 glColor4f(1, 1, 1, 1);
1461 int numliveplayers = 0;
1463 for (unsigned i = 0; i < Person::players.size(); i++) {
1464 if (!Person::players[i]->dead)
1470 for (int i = 0; i < objects.numobjects; i++) {
1471 if (objects.type[i] == treetrunktype || objects.type[i] == boxtype) {
1472 center += objects.position[i];
1476 for (unsigned i = 0; i < Person::players.size(); i++) {
1477 if (!Person::players[i]->dead)
1478 center += Person::players[i]->coords;
1480 center /= numadd + numliveplayers;
1482 center = Person::players[0]->coords;
1484 float maxdistance = 0;
1486 //~ int whichclosest;
1487 for (int i = 0; i < objects.numobjects; i++) {
1488 tempdist = distsq(¢er, &objects.position[i]);
1489 if (tempdist > maxdistance) {
1491 maxdistance = tempdist;
1494 for (unsigned i = 0; i < Person::players.size(); i++) {
1495 if (!Person::players[i]->dead) {
1496 tempdist = distsq(¢er, &Person::players[i]->coords);
1497 if (tempdist > maxdistance) {
1499 maxdistance = tempdist;
1505 glScalef(.25 / radius * 256 * terrain.scale * .4, .25 / radius * 256 * terrain.scale * .4, 1);
1507 glScalef(1 / (1 / radius * 256 * terrain.scale * .4), 1 / (1 / radius * 256 * terrain.scale * .4), 1);
1509 glRotatef(Person::players[0]->lookyaw * -1 + 180, 0, 0, 1);
1510 glTranslatef(-(center.x / terrain.scale / 256 * -2 + 1), (center.z / terrain.scale / 256 * -2 + 1), 0);
1511 for (int i = 0; i < objects.numobjects; i++) {
1512 if (objects.type[i] == treetrunktype) {
1513 distcheck = distsq(&Person::players[0]->coords, &objects.position[i]);
1514 if (distcheck < mapviewdist) {
1515 Mapcircletexture.bind();
1516 glColor4f(0, .3, 0, opac * (1 - distcheck / mapviewdist));
1518 glTranslatef(objects.position[i].x / terrain.scale / 256 * -2 + 1, objects.position[i].z / terrain.scale / 256 * 2 - 1, 0);
1519 glRotatef(objects.yaw[i], 0, 0, 1);
1520 glScalef(.003, .003, .003);
1523 glVertex3f(-1, -1, 0.0f);
1525 glVertex3f(1, -1, 0.0f);
1527 glVertex3f(1, 1, 0.0f);
1529 glVertex3f(-1, 1, 0.0f);
1534 if (objects.type[i] == boxtype) {
1535 distcheck = distsq(&Person::players[0]->coords, &objects.position[i]);
1536 if (distcheck < mapviewdist) {
1537 Mapboxtexture.bind();
1538 glColor4f(.4, .4, .4, opac * (1 - distcheck / mapviewdist));
1540 glTranslatef(objects.position[i].x / terrain.scale / 256 * -2 + 1, objects.position[i].z / terrain.scale / 256 * 2 - 1, 0);
1541 glRotatef(objects.yaw[i], 0, 0, 1);
1542 glScalef(.01 * objects.scale[i], .01 * objects.scale[i], .01 * objects.scale[i]);
1545 glVertex3f(-1, -1, 0.0f);
1547 glVertex3f(1, -1, 0.0f);
1549 glVertex3f(1, 1, 0.0f);
1551 glVertex3f(-1, 1, 0.0f);
1557 if (editorenabled) {
1558 Mapcircletexture.bind();
1559 for (int i = 0; i < numboundaries; i++) {
1560 glColor4f(0, 0, 0, opac / 3);
1562 glTranslatef(boundary[i].x / terrain.scale / 256 * -2 + 1, boundary[i].z / terrain.scale / 256 * 2 - 1, 0);
1563 glScalef(.002, .002, .002);
1566 glVertex3f(-1, -1, 0.0f);
1568 glVertex3f(1, -1, 0.0f);
1570 glVertex3f(1, 1, 0.0f);
1572 glVertex3f(-1, 1, 0.0f);
1577 for (unsigned i = 0; i < Person::players.size(); i++) {
1578 distcheck = distsq(&Person::players[0]->coords, &Person::players[i]->coords);
1579 if (distcheck < mapviewdist) {
1581 Maparrowtexture.bind();
1583 glColor4f(1, 1, 1, opac);
1584 else if (Person::players[i]->dead == 2 || Person::players[i]->howactive > typesleeping)
1585 glColor4f(0, 0, 0, opac * (1 - distcheck / mapviewdist));
1586 else if (Person::players[i]->dead)
1587 glColor4f(.3, .3, .3, opac * (1 - distcheck / mapviewdist));
1588 else if (Person::players[i]->aitype == attacktypecutoff)
1589 glColor4f(1, 0, 0, opac * (1 - distcheck / mapviewdist));
1590 else if (Person::players[i]->aitype == passivetype)
1591 glColor4f(0, 1, 0, opac * (1 - distcheck / mapviewdist));
1593 glColor4f(1, 1, 0, 1);
1594 glTranslatef(Person::players[i]->coords.x / terrain.scale / 256 * -2 + 1, Person::players[i]->coords.z / terrain.scale / 256 * 2 - 1, 0);
1595 glRotatef(Person::players[i]->yaw + 180, 0, 0, 1);
1596 glScalef(.005, .005, .005);
1599 glVertex3f(-1, -1, 0.0f);
1601 glVertex3f(1, -1, 0.0f);
1603 glVertex3f(1, 1, 0.0f);
1605 glVertex3f(-1, 1, 0.0f);
1611 glDisable(GL_TEXTURE_2D);
1612 glMatrixMode(GL_PROJECTION);
1614 glMatrixMode(GL_MODELVIEW);
1616 glEnable(GL_DEPTH_TEST);
1617 glEnable(GL_CULL_FACE);
1618 glDisable(GL_BLEND);
1622 if (loading && !stealthloading && (!campaign || Person::players[0]->dead)) {
1623 glDisable(GL_DEPTH_TEST);
1624 glDisable(GL_CULL_FACE);
1625 glDisable(GL_LIGHTING);
1626 glDisable(GL_TEXTURE_2D);
1628 glMatrixMode(GL_PROJECTION);
1631 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1632 glMatrixMode(GL_MODELVIEW);
1635 glScalef(screenwidth, screenheight, 1);
1636 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1638 glColor4f(0, 0, 0, .7);
1640 glVertex3f(0, 0, 0.0f);
1641 glVertex3f(256, 0, 0.0f);
1642 glVertex3f(256, 256, 0.0f);
1643 glVertex3f(0, 256, 0.0f);
1645 glMatrixMode(GL_PROJECTION);
1647 glMatrixMode(GL_MODELVIEW);
1649 glEnable(GL_DEPTH_TEST);
1650 glEnable(GL_CULL_FACE);
1651 glDisable(GL_BLEND);
1655 glDisable(GL_DEPTH_TEST);
1656 glColor3f (1.0, 1.0, 1.0); // no coloring
1658 glEnable(GL_TEXTURE_2D);
1663 glEnable(GL_TEXTURE_2D);
1664 glColor4f(1, 1, 1, 1);
1665 sprintf (string, "Loading...");
1666 text->glPrint(1024 / 2 - 90, 768 / 2, string, 1, 2, 1024, 768);
1669 drawmode = normalmode;
1672 if (winfreeze && !campaign) {
1673 glDisable(GL_DEPTH_TEST);
1674 glDisable(GL_CULL_FACE);
1675 glDisable(GL_LIGHTING);
1676 glDisable(GL_TEXTURE_2D);
1678 glMatrixMode(GL_PROJECTION);
1681 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1682 glMatrixMode(GL_MODELVIEW);
1685 glScalef(screenwidth, screenheight, 1);
1686 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1688 glColor4f(0, 0, 0, .4);
1690 glVertex3f(0, 0, 0.0f);
1691 glVertex3f(256, 0, 0.0f);
1692 glVertex3f(256, 256, 0.0f);
1693 glVertex3f(0, 256, 0.0f);
1695 glMatrixMode(GL_PROJECTION);
1697 glMatrixMode(GL_MODELVIEW);
1699 glEnable(GL_DEPTH_TEST);
1700 glEnable(GL_CULL_FACE);
1701 glDisable(GL_BLEND);
1705 glDisable(GL_DEPTH_TEST);
1706 glColor3f (1.0, 1.0, 1.0); // no coloring
1708 glEnable(GL_TEXTURE_2D);
1710 //Win Screen Won Victory
1712 glEnable(GL_TEXTURE_2D);
1713 glColor4f(1, 1, 1, 1);
1714 sprintf (string, "Level Cleared!");
1715 text->glPrintOutlined(1024 / 2 - strlen(string) * 10, 768 * 7 / 8, string, 1, 2, 1024, 768);
1717 sprintf (string, "Score: %d", (int)(bonustotal - startbonustotal));
1718 text->glPrintOutlined(1024 / 30, 768 * 6 / 8, string, 1, 2, 1024, 768);
1721 sprintf (string, "Press Escape or Space to continue");
1723 sprintf (string, "Press Escape to return to menu or Space to continue");
1724 text->glPrintOutlined(640 / 2 - strlen(string) * 5, 480 * 1 / 16, string, 1, 1, 640, 480);
1728 for (int i = 0; i < 255; i++)
1730 sprintf (temp, "Time: %d:", (int)(((int)leveltime - (int)(leveltime) % 60) / 60));
1731 strcat(string, temp);
1732 if ((int)(leveltime) % 60 < 10)
1733 strcat(string, "0");
1734 sprintf (temp, "%d", (int)(leveltime) % 60);
1735 strcat(string, temp);
1736 text->glPrintOutlined(1024 / 30, 768 * 6 / 8 - 40, string, 1, 2, 1024, 768);
1739 int awards[award_count];
1740 int numawards = award_awards(awards);
1742 for (int i = 0; i < numawards && i < 6; i++)
1743 text->glPrintOutlined(1024 / 30, 768 * 6 / 8 - 90 - 40 * i, award_names[awards[i]], 1, 2, 1024, 768);
1746 if (drawmode != normalmode) {
1747 glEnable(GL_TEXTURE_2D);
1749 if (!drawtoggle || drawmode != realmotionblurmode || (drawtoggle == 2 || change == 1)) {
1750 if (screentexture) {
1752 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
1753 GLfloat subtractColor[4] = { 0.5, 0.5, 0.5, 0.0 };
1754 glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, subtractColor);
1755 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE);
1756 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_CONSTANT_EXT);
1757 glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 2.0f);
1759 glBindTexture( GL_TEXTURE_2D, screentexture);
1760 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1763 if ((drawtoggle || change == 1) && drawmode == realmotionblurmode) {
1764 if (screentexture2) {
1765 glBindTexture( GL_TEXTURE_2D, screentexture2);
1766 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
1768 if (!screentexture2) {
1769 glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
1771 glGenTextures( 1, &screentexture2 );
1772 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
1774 glEnable(GL_TEXTURE_2D);
1775 glBindTexture( GL_TEXTURE_2D, screentexture2);
1776 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
1777 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
1779 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
1784 glClear(GL_DEPTH_BUFFER_BIT);
1785 Game::ReSizeGLScene(90, .1f);
1786 glViewport(0, 0, screenwidth, screenheight);
1788 if (drawmode != normalmode) {
1789 glDisable(GL_DEPTH_TEST);
1790 if (drawmode == motionblurmode) {
1791 glDrawBuffer(GL_FRONT);
1792 glReadBuffer(GL_BACK);
1794 glColor3f (1.0, 1.0, 1.0); // no coloring
1796 glEnable(GL_TEXTURE_2D);
1797 glBindTexture( GL_TEXTURE_2D, screentexture);
1798 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
1799 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
1800 glDisable(GL_DEPTH_TEST);
1801 glDisable(GL_CULL_FACE);
1802 glDisable(GL_LIGHTING);
1804 glMatrixMode(GL_PROJECTION);
1807 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
1808 glMatrixMode(GL_MODELVIEW);
1811 glScalef((float)screenwidth / 2, (float)screenheight / 2, 1);
1812 glTranslatef(1, 1, 0);
1813 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1815 if (drawmode == motionblurmode) {
1816 if (motionbluramount < .2)
1817 motionbluramount = .2;
1818 glColor4f(1, 1, 1, motionbluramount);
1822 glVertex3f(-1, -1, 0.0f);
1823 glTexCoord2f(texcoordwidth, 0);
1824 glVertex3f(1, -1, 0.0f);
1825 glTexCoord2f(texcoordwidth, texcoordheight);
1826 glVertex3f(1, 1, 0.0f);
1827 glTexCoord2f(0, texcoordheight);
1828 glVertex3f(-1, 1, 0.0f);
1832 if (drawmode == realmotionblurmode) {
1833 glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
1834 glClear(GL_COLOR_BUFFER_BIT);
1835 glBlendFunc(GL_SRC_ALPHA, GL_ONE);
1836 glBindTexture( GL_TEXTURE_2D, screentexture);
1837 glColor4f(1, 1, 1, .5);
1841 glVertex3f(-1, -1, 0.0f);
1842 glTexCoord2f(texcoordwidth, 0);
1843 glVertex3f(1, -1, 0.0f);
1844 glTexCoord2f(texcoordwidth, texcoordheight);
1845 glVertex3f(1, 1, 0.0f);
1846 glTexCoord2f(0, texcoordheight);
1847 glVertex3f(-1, 1, 0.0f);
1850 glBindTexture( GL_TEXTURE_2D, screentexture2);
1851 glColor4f(1, 1, 1, .5);
1855 glVertex3f(-1, -1, 0.0f);
1856 glTexCoord2f(texcoordwidth, 0);
1857 glVertex3f(1, -1, 0.0f);
1858 glTexCoord2f(texcoordwidth, texcoordheight);
1859 glVertex3f(1, 1, 0.0f);
1860 glTexCoord2f(0, texcoordheight);
1861 glVertex3f(-1, 1, 0.0f);
1864 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1866 if (drawmode == doublevisionmode) {
1867 static float crosseyedness;
1868 crosseyedness = abs(Person::players[0]->damage - Person::players[0]->superpermanentdamage - (Person::players[0]->damagetolerance - Person::players[0]->superpermanentdamage) * 1 / 2) / 30;
1869 if (crosseyedness > 1)
1871 if (crosseyedness < 0)
1873 glColor4f(1, 1, 1, 1);
1874 glDisable(GL_BLEND);
1879 glVertex3f(-1, -1, 0.0f);
1880 glTexCoord2f(texcoordwidth, 0);
1881 glVertex3f(1, -1, 0.0f);
1882 glTexCoord2f(texcoordwidth, texcoordheight);
1883 glVertex3f(1, 1, 0.0f);
1884 glTexCoord2f(0, texcoordheight);
1885 glVertex3f(-1, 1, 0.0f);
1888 if (crosseyedness) {
1889 glColor4f(1, 1, 1, .5);
1892 glTranslatef(.015 * crosseyedness, 0, 0);
1896 glVertex3f(-1, -1, 0.0f);
1897 glTexCoord2f(texcoordwidth, 0);
1898 glVertex3f(1, -1, 0.0f);
1899 glTexCoord2f(texcoordwidth, texcoordheight);
1900 glVertex3f(1, 1, 0.0f);
1901 glTexCoord2f(0, texcoordheight);
1902 glVertex3f(-1, 1, 0.0f);
1907 if (drawmode == glowmode) {
1908 glColor4f(.5, .5, .5, .5);
1910 glBlendFunc(GL_SRC_ALPHA, GL_ONE);
1912 glTranslatef(.01, 0, 0);
1915 glVertex3f(-1, -1, 0.0f);
1916 glTexCoord2f(texcoordwidth, 0);
1917 glVertex3f(1, -1, 0.0f);
1918 glTexCoord2f(texcoordwidth, texcoordheight);
1919 glVertex3f(1, 1, 0.0f);
1920 glTexCoord2f(0, texcoordheight);
1921 glVertex3f(-1, 1, 0.0f);
1925 glTranslatef(-.01, 0, 0);
1928 glVertex3f(-1, -1, 0.0f);
1929 glTexCoord2f(texcoordwidth, 0);
1930 glVertex3f(1, -1, 0.0f);
1931 glTexCoord2f(texcoordwidth, texcoordheight);
1932 glVertex3f(1, 1, 0.0f);
1933 glTexCoord2f(0, texcoordheight);
1934 glVertex3f(-1, 1, 0.0f);
1938 glTranslatef(.0, .01, 0);
1941 glVertex3f(-1, -1, 0.0f);
1942 glTexCoord2f(texcoordwidth, 0);
1943 glVertex3f(1, -1, 0.0f);
1944 glTexCoord2f(texcoordwidth, texcoordheight);
1945 glVertex3f(1, 1, 0.0f);
1946 glTexCoord2f(0, texcoordheight);
1947 glVertex3f(-1, 1, 0.0f);
1951 glTranslatef(0, -.01, 0);
1954 glVertex3f(-1, -1, 0.0f);
1955 glTexCoord2f(texcoordwidth, 0);
1956 glVertex3f(1, -1, 0.0f);
1957 glTexCoord2f(texcoordwidth, texcoordheight);
1958 glVertex3f(1, 1, 0.0f);
1959 glTexCoord2f(0, texcoordheight);
1960 glVertex3f(-1, 1, 0.0f);
1964 if (drawmode == radialzoommode) {
1965 for (int i = 0; i < 3; i++) {
1966 glColor4f(1, 1, 1, 1 / ((float)i + 1));
1968 glScalef(1 + (float)i * .01, 1 + (float)i * .01, 1);
1971 glVertex3f(-1, -1, 0.0f);
1972 glTexCoord2f(texcoordwidth, 0);
1973 glVertex3f(1, -1, 0.0f);
1974 glTexCoord2f(texcoordwidth, texcoordheight);
1975 glVertex3f(1, 1, 0.0f);
1976 glTexCoord2f(0, texcoordheight);
1977 glVertex3f(-1, 1, 0.0f);
1982 glDisable(GL_TEXTURE_2D);
1983 glMatrixMode(GL_PROJECTION);
1985 glMatrixMode(GL_MODELVIEW);
1987 glEnable(GL_DEPTH_TEST);
1988 glEnable(GL_CULL_FACE);
1989 glDisable(GL_BLEND);
1994 glEnable(GL_TEXTURE_2D);
1995 glColor4f(1, 1, 1, 1);
1997 if (consoleselected >= 60)
1998 offset = consoleselected - 60;
1999 sprintf (string, " ]");
2000 text->glPrint(10, 30, string, 0, 1, 1024, 768);
2002 sprintf (string, "_");
2003 text->glPrint(30 + (float)(consoleselected) * 10 - offset * 10, 30, string, 0, 1, 1024, 768);
2005 for (unsigned i = 0; i < 15; i++)
2006 for (unsigned j = 0; j < consoletext[i].size(); j++) {
2007 glColor4f(1, 1, 1, 1 - (float)(i) / 16);
2008 sprintf (string, "%c", consoletext[i][j]);
2009 text->glPrint(30 + j * 10 - offset * 10, 30 + i * 20, string, 0, 1, 1024, 768);
2014 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted)) {
2015 multiplier = tempmult;
2022 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted)) {
2023 tempmult = multiplier;
2027 if ( side == stereoRight || side == stereoCenter ) {
2028 if (drawmode != motionblurmode || mainmenu) {
2033 glDrawBuffer(GL_BACK);
2034 glReadBuffer(GL_BACK);
2038 if (drawtoggle == 2)
2041 if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted)) {
2042 multiplier = tempmult;
2044 //Jordan fixed your warning!
2050 // !!! FIXME: hack: clamp framerate in menu so text input works correctly on fast systems.
2053 glDrawBuffer(GL_BACK);
2054 glReadBuffer(GL_BACK);
2055 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
2056 Game::ReSizeGLScene(90, .1f);
2058 //draw menu background
2059 glClear(GL_DEPTH_BUFFER_BIT);
2060 glEnable(GL_ALPHA_TEST);
2061 glAlphaFunc(GL_GREATER, 0.001f);
2062 glEnable(GL_TEXTURE_2D);
2063 glDisable(GL_DEPTH_TEST);
2064 glDisable(GL_CULL_FACE);
2065 glDisable(GL_LIGHTING);
2067 glMatrixMode(GL_PROJECTION);
2070 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
2071 glMatrixMode(GL_MODELVIEW);
2074 glTranslatef(screenwidth / 2, screenheight / 2, 0);
2076 glScalef((float)screenwidth / 2, (float)screenheight / 2, 1);
2077 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
2078 glDisable(GL_BLEND);
2079 glColor4f(0, 0, 0, 1.0);
2080 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2081 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2082 glDisable(GL_TEXTURE_2D);
2084 glVertex3f(-1, -1, 0);
2085 glVertex3f(+1, -1, 0);
2086 glVertex3f(+1, +1, 0);
2087 glVertex3f(-1, +1, 0);
2090 glColor4f(0.4, 0.4, 0.4, 1.0);
2091 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2092 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2093 glEnable(GL_TEXTURE_2D);
2094 Game::Mainmenuitems[4].bind();
2097 glVertex3f(-1, -1, 0);
2099 glVertex3f(+1, -1, 0);
2101 glVertex3f(+1, +1, 0);
2103 glVertex3f(-1, +1, 0);
2107 glMatrixMode(GL_PROJECTION);
2109 glMatrixMode(GL_MODELVIEW);
2113 glMatrixMode(GL_PROJECTION);
2116 glOrtho(0, 640, 0, 480, -100, 100);
2117 glMatrixMode(GL_MODELVIEW);
2120 glEnable(GL_TEXTURE_2D);
2125 glMatrixMode(GL_PROJECTION);
2127 glMatrixMode(GL_MODELVIEW);
2130 glMatrixMode(GL_PROJECTION);
2133 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
2134 glMatrixMode(GL_MODELVIEW);
2137 glTranslatef(screenwidth / 2, screenheight / 2, 0);
2139 glScalef((float)screenwidth / 2, (float)screenheight / 2, 1);
2140 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
2142 glEnable(GL_TEXTURE_2D);
2143 glColor4f(1, 1, 1, 1);
2144 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2145 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
2147 if (!Game::waiting) { // hide the cursor while waiting for a key
2149 glTranslatef(Game::mousecoordh - screenwidth / 2, Game::mousecoordv * -1 + screenheight / 2, 0);
2150 glScalef((float)screenwidth / 64, (float)screenwidth / 64, 1);
2151 glTranslatef(1, -1, 0);
2152 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
2153 glColor4f(1, 1, 1, 1);
2154 Game::cursortexture.bind();
2158 glVertex3f(-1, -1, 0.0f);
2160 glVertex3f(1, -1, 0.0f);
2162 glVertex3f(1, 1, 0.0f);
2164 glVertex3f(-1, 1, 0.0f);
2170 glMatrixMode(GL_PROJECTION);
2175 if (flashamount > 0) {
2176 if (flashamount > 1)
2178 if (flashdelay <= 0)
2179 flashamount -= multiplier;
2181 if (flashamount < 0)
2183 glDisable(GL_DEPTH_TEST);
2184 glDisable(GL_CULL_FACE);
2185 glDisable(GL_LIGHTING);
2186 glDisable(GL_TEXTURE_2D);
2188 glMatrixMode(GL_PROJECTION);
2191 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
2192 glMatrixMode(GL_MODELVIEW);
2195 glScalef(screenwidth, screenheight, 1);
2196 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
2198 glColor4f(flashr, flashg, flashb, flashamount);
2200 glVertex3f(0, 0, 0.0f);
2201 glVertex3f(256, 0, 0.0f);
2202 glVertex3f(256, 256, 0.0f);
2203 glVertex3f(0, 256, 0.0f);
2205 glMatrixMode(GL_PROJECTION);
2207 glMatrixMode(GL_MODELVIEW);
2209 glEnable(GL_DEPTH_TEST);
2210 glEnable(GL_CULL_FACE);
2211 glDisable(GL_BLEND);