${SRCDIR}/Random.c
${SRCDIR}/Skeleton.cpp
${SRCDIR}/Skybox.cpp
- ${SRCDIR}/Sprites.cpp
+ ${SRCDIR}/Sprite.cpp
${SRCDIR}/Terrain.cpp
${SRCDIR}/Text.cpp
${SRCDIR}/TGALoader.cpp
${SRCDIR}/Random.h
${SRCDIR}/Skeleton.h
${SRCDIR}/Skybox.h
- ${SRCDIR}/Sprites.h
+ ${SRCDIR}/Sprite.h
${SRCDIR}/TGALoader.h
${SRCDIR}/Terrain.h
${SRCDIR}/Text.h
(pt->game->*(pt->method))();
}
}
+
+void Game::DrawGL() {
+ if ( stereomode == stereoNone ) {
+ DrawGLScene(stereoCenter);
+ } else {
+ DrawGLScene(stereoLeft);
+ DrawGLScene(stereoRight);
+ }
+}
#include "Lights.h"
#include "Person.h"
#include "Constants.h"
-#include "Sprites.h"
+#include "Sprite.h"
//#include <agl.h>
#include "Text.h"
#include "Objects.h"
unsigned short crouchkey,jumpkey,forwardkey,chatkey,backkey,leftkey,rightkey,drawkey,throwkey,attackkey;
bool oldattackkey;
- long long MD5_string (char *string);
static void LoadTexture(const char *fileName, GLuint *textureid,int mipmap, bool hasalpha);
static void LoadTextureSave(const char *fileName, GLuint *textureid,int mipmap,GLubyte *array, int *skinsize);
void LoadSave(const char *fileName, GLuint *textureid,bool mipmap,GLubyte *array, int *skinsize);
void FadeLoadingScreen(float howmuch);
void Dispose();
int DrawGLScene(StereoSide side);
+ void DrawGL();
void Tick();
void TickOnce();
void TickOnceAfter();
static __forceinline void swap_gl_buffers(void)
{
-
SDL_GL_SwapBuffers();
-
}
-#ifdef __GNUC__
-#define LONGLONGCONST(x) (x##ll)
-#else
-#define LONGLONGCONST(x) (x)
-#endif
-
extern "C" { void UndefinedSymbolToExposeStubbedCode(void); }
//#define STUBBED(x) UndefinedSymbolToExposeStubbedCode();
#define STUBBED(x) { static bool seen = false; if (!seen) { seen = true; fprintf(stderr, "STUBBED: %s at %s:%d\n", x, __FILE__, __LINE__); } }
extern float texscale;
extern Light light;
extern Terrain terrain;
-extern Sprites sprites;
+//extern Sprites sprites;
extern float multiplier;
extern float sps;
extern float viewdistance;
flashdelay=1;
}
/*********************> DrawGLScene() <*****/
-long long Game::MD5_string (char *string){
- char temp[256]="";
- char temp2[256]="";
- long long num=90814;
-
- sprintf (temp, "%s",string);
-
- int i=0;
- while (i<256&&temp[i]!='\0'){
- if(temp[i]%3==0)num+=temp[i]*124;
- else if(temp[i]%3==1)num-=temp[i]*temp[i];
- else num*=temp[i];
- i++;
- }
-
- num=longlongabs(num);
- if(num==0)num+=1452;
-
- while(num<LONGLONGCONST(5000000000000000)){
- num*=1.85421521;
- }
-
- while(num>LONGLONGCONST(9900000000000000)){
- num/=1.235421521;
- }
-
- return num;
-
- //return 1111111111111111;
-}
-
int Game::DrawGLScene(StereoSide side)
{
static float texcoordwidth,texcoordheight;
if(winfreeze||mainmenu)drawmode=normalmode;
- //drawmode=glowmode;
+#if PLATFORM_MACOSX
if(drawmode==glowmode){
RGBColor color2;
color2.red=0;
color2.green=0;
color2.blue=0;
-#if PLATFORM_MACOSX
DSpContext_FadeGamma(NULL,200,&color2);
-#endif
}
+#endif
if(drawtoggle!=2)drawtoggle=1-drawtoggle;
glDrawBuffer(GL_BACK);
glReadBuffer(GL_BACK);
- /*if(environment==desertenvironment)glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, (float)(abs(Random()%100))/50 );
- else glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0);
- */
if(abs(blurness-targetblurness)<multiplier*10||abs(blurness-targetblurness)>2){
blurness=targetblurness;
targetblurness=(float)(abs(Random()%100))/40;
}
- if(blurness<targetblurness)blurness+=multiplier*5;
- if(blurness>targetblurness)blurness-=multiplier*5;
+ if(blurness<targetblurness)
+ blurness+=multiplier*5;
+ else
+ blurness-=multiplier*5;
//glFinish();
static XYZ terrainlight;
static float distance;
- //if(drawmode==normalmode)ReSizeGLScene(90,.1);
if(drawmode==normalmode)ReSizeGLScene(90,.1f);
if(drawmode!=normalmode)glViewport(0,0,texviewwidth,texviewheight);
glDepthFunc(GL_LEQUAL);
glRotatef(rotation+sin(woozy)*(player[0].damage/player[0].damagetolerance)*5,0,1,0);
}
if(cameramode||freeze||winfreeze){
- //glRotatef(float(Random()%100)/10*camerashake/*+(woozy*woozy)/10*/,0,0,1);
glRotatef(rotation2,1,0,0);
glRotatef(rotation,0,1,0);
}
if(environment==desertenvironment){
glRotatef((float)(abs(Random()%100))/3000-1,1,0,0);
glRotatef((float)(abs(Random()%100))/3000-1,0,1,0);
- //glRotatef(blurness/40-1,1,0,0);
- //glRotatef(blurness/40-1,0,1,0);
}
SetUpLight(&light,0);
glPushMatrix();
opacity=.2+.2*sin(smoketex*6+i)-player[k].skeleton.joints[i].position.y*player[k].scale/5-(player[k].coords.y-terrain.getHeight(player[k].coords.x,player[k].coords.z))/10;
}
terrain.MakeDecal(shadowdecal,point,size,opacity,rotation);
- if(terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz])
- for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
- j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
- if(objects.position[j].y<player[k].coords.y||objects.type[j]==tunneltype||objects.type[j]==weirdtype){
- point=DoRotation(DoRotation(player[k].skeleton.joints[i].position,0,player[k].rotation,0)*player[k].scale+player[k].coords-objects.position[j],0,-objects.rotation[j],0);
- size=.4f;
- opacity=.4f;
- if(k!=0&&tutoriallevel==1){
- opacity=.2+.2*sin(smoketex*6+i);
- }
- objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
+ for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
+ j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
+ if(objects.position[j].y<player[k].coords.y||objects.type[j]==tunneltype||objects.type[j]==weirdtype){
+ point=DoRotation(DoRotation(player[k].skeleton.joints[i].position,0,player[k].rotation,0)*player[k].scale+player[k].coords-objects.position[j],0,-objects.rotation[j],0);
+ size=.4f;
+ opacity=.4f;
+ if(k!=0&&tutoriallevel==1){
+ opacity=.2+.2*sin(smoketex*6+i);
}
+ objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
}
+ }
}
}
if((player[k].skeleton.free||player[k].howactive>=typesleeping)&&player[k].playerdetail)
opacity=.2+.2*sin(smoketex*6+i)-player[k].skeleton.joints[i].position.y*player[k].scale/5-(player[k].coords.y-terrain.getHeight(player[k].coords.x,player[k].coords.z))/10;
}
terrain.MakeDecal(shadowdecal,point,size,opacity*.7,rotation);
- if(terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz])
- for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
- j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
- if(objects.position[j].y<player[k].coords.y||objects.type[j]==tunneltype||objects.type[j]==weirdtype){
- if(player[k].skeleton.free)point=DoRotation(player[k].skeleton.joints[i].position*player[k].scale+player[k].coords-objects.position[j],0,-objects.rotation[j],0);
- else point=DoRotation(DoRotation(player[k].skeleton.joints[i].position,0,player[k].rotation,0)*player[k].scale+player[k].coords-objects.position[j],0,-objects.rotation[j],0);
- size=.4f;
- opacity=.4f;
- if(k!=0&&tutoriallevel==1){
- opacity=.2+.2*sin(smoketex*6+i);
- }
- objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
+ for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
+ j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
+ if(objects.position[j].y<player[k].coords.y||objects.type[j]==tunneltype||objects.type[j]==weirdtype){
+ if(player[k].skeleton.free)point=DoRotation(player[k].skeleton.joints[i].position*player[k].scale+player[k].coords-objects.position[j],0,-objects.rotation[j],0);
+ else point=DoRotation(DoRotation(player[k].skeleton.joints[i].position,0,player[k].rotation,0)*player[k].scale+player[k].coords-objects.position[j],0,-objects.rotation[j],0);
+ size=.4f;
+ opacity=.4f;
+ if(k!=0&&tutoriallevel==1){
+ opacity=.2+.2*sin(smoketex*6+i);
}
+ objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
}
+ }
}
}
size=.7;
opacity=.4-(player[k].coords.y-terrain.getHeight(player[k].coords.x,player[k].coords.z))/5;
terrain.MakeDecal(shadowdecal,point,size,opacity*.7,rotation);
- if(terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz])
- for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
- j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
- point=DoRotation(player[k].coords-objects.position[j],0,-objects.rotation[j],0);
- size=.7;
- opacity=.4f;
- objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
- }
+ for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
+ j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
+ point=DoRotation(player[k].coords-objects.position[j],0,-objects.rotation[j],0);
+ size=.7;
+ opacity=.4f;
+ objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
+ }
}
}
}
}
}
- //}
glPushMatrix();
glEnable(GL_TEXTURE_2D);
glDepthMask(0);
- sprites.Draw();
+ Sprite::Draw();
if(editorenabled){
glEnable(GL_BLEND);
sprintf (string, "%s", hotspottext[closest]);
- int lastline;
- int line=0;
- bool done=0;
- lastline=0;
+ int lastline = 0;
+ int line = 0;
+ bool done = false;
i=0;
while(!done){
if(string[i]=='\n'||string[i]>'z'||string[i]<' '||string[i]=='\0'){
if(dialogueboxlocation[whichdialogue][indialogue]==1)starty=screenheight/16+screenheight*4/5;
if(dialogueboxlocation[whichdialogue][indialogue]==2)starty=screenheight*1/5-screenheight/16;
-// char tempname[64];
char tempname[264];
bool goodchar;
int tempnum=0;
-// for(i=0;i<64;i++){
for(i=0;i<264;i++){
tempname[i]='\0';
}
tempname[tempnum]=dialoguename[whichdialogue][indialogue][i];
goodchar=1;
if(dialoguename[whichdialogue][indialogue][i]=='#'||dialoguename[whichdialogue][indialogue][i]=='\0')goodchar=0;
- //if(tempnum>2)if(tempname[tempnum-2]=='e'&&tempname[tempnum-1]=='r')goodchar=0;
- //if(tempnum>2)if(tempname[tempnum]=='r'&&tempname[0]=='a')goodchar=0;
- if(goodchar)tempnum++;
- else tempname[tempnum]='\0';
+ if(goodchar)
+ tempnum++;
+ else
+ tempname[tempnum]='\0';
}
sprintf (string, "%s: ", tempname);
{
glColor4f(0,0,0,tutorialopac);
text.glPrintOutline(startx-2*7.6*strlen(string)*screenwidth/1024-4,starty-4,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight);
-
}
tempnum=0;
if(dialoguetext[whichdialogue][indialogue][i]!='#')tempnum++;
}
-
sprintf (string, "%s", tempname);
-
- int lastline;
- int line=0;
- bool done=0;
- lastline=0;
+ int lastline = 0;
+ int line = 0;
+ bool done = false;
i=0;
while(!done){
if(string[i]=='\n'||string[i]>'z'||string[i]<' '||string[i]=='\0'){
if(!tutoriallevel&&!winfreeze&&indialogue==-1&&!mainmenu){
if(campaign){
- if(!scoreadded)sprintf (string, "Score: %d", (int)accountactive->getCampaignScore()+(int)bonustotal);//(int)bonustotal);
- if(scoreadded)sprintf (string, "Score: %d", (int)accountactive->getCampaignScore());//(int)bonustotal);
+ if(scoreadded)
+ sprintf (string, "Score: %d", (int)accountactive->getCampaignScore());
+ else
+ sprintf (string, "Score: %d", (int)accountactive->getCampaignScore()+(int)bonustotal);
}
if(!campaign)sprintf (string, "Score: %d", (int)bonustotal);
glColor4f(0,0,0,1);
text.glPrint(10,260,string,0,.8,1024,768);
- if(editorenabled)sprintf (string, "Map editor enabled.");
- if(!editorenabled)sprintf (string, "Map editor Disabled.");
+ if(editorenabled)
+ sprintf (string, "Map editor enabled.");
+ else
+ sprintf (string, "Map editor disabled.");
text.glPrint(10,60,string,0,.8,1024,768);
if(editorenabled){
sprintf (string, "Object size: %f",editorsize);
text.glPrint(10,105,string,0,.8,1024,768);
sprintf (string, "Object type: %d",editortype);
text.glPrint(10,120,string,0,.8,1024,768);
- if(editortype==boxtype)sprintf (string, "(box)");
- if(editortype==treetrunktype)sprintf (string, "(tree)");
- if(editortype==walltype)sprintf (string, "(wall)");
- if(editortype==weirdtype)sprintf (string, "(weird)");
- if(editortype==spiketype)sprintf (string, "(spike)");
- if(editortype==rocktype)sprintf (string, "(rock)");
- if(editortype==bushtype)sprintf (string, "(bush)");
- if(editortype==tunneltype)sprintf (string, "(tunnel)");
- if(editortype==chimneytype)sprintf (string, "(chimney)");
- if(editortype==platformtype)sprintf (string, "(platform)");
- if(editortype==cooltype)sprintf (string, "(cool)");
- if(editortype==firetype)sprintf (string, "(fire)");
+ switch(editortype) {
+ case boxtype:
+ sprintf (string, "(box)");
+ break;
+ case treetrunktype:
+ sprintf (string, "(tree)");
+ break;
+ case walltype:
+ sprintf (string, "(wall)");
+ break;
+ case weirdtype:
+ sprintf (string, "(weird)");
+ break;
+ case spiketype:
+ sprintf (string, "(spike)");
+ break;
+ case rocktype:
+ sprintf (string, "(rock)");
+ break;
+ case bushtype:
+ sprintf (string, "(bush)");
+ break;
+ case tunneltype:
+ sprintf (string, "(tunnel)");
+ break;
+ case chimneytype:
+ sprintf (string, "(chimney)");
+ break;
+ case platformtype:
+ sprintf (string, "(platform)");
+ break;
+ case cooltype:
+ sprintf (string, "(cool)");
+ break;
+ case firetype:
+ sprintf (string, "(fire)");
+ break;
+ }
text.glPrint(130,120,string,0,.8,1024,768);
sprintf (string, "Numplayers: %d",numplayers);
sprintf (string, "Player %d: numwaypoints: %d",numplayers,player[numplayers-1].numwaypoints);
text.glPrint(10,140,string,0,.8,1024,768);
}
- /*sprintf (string, "Coords are: %f %f %f",player[0].coords.x,player[0].coords.y,player[0].coords.z);
- text.glPrint(10,200,string,0,.8,1024,768);*/
sprintf (string, "Difficulty: %d",difficulty);
text.glPrint(10,240,string,0,.8,1024,768);
- /*
- sprintf (string, "lasthotspot: %d",hotspottype[numhotspots-1]);
- text.glPrint(10,240,string,0,.8,1024,768);
- sprintf (string, "killhotspot: %d",killhotspot);
- text.glPrint(10,220,string,0,.8,1024,768);
- sprintf (string, "winhotspot: %d",winhotspot);
- text.glPrint(10,200,string,0,.8,1024,768);*/
}
}
}
if(minimap&&indialogue==-1){
- float mapviewdist;
- mapviewdist=20000;
+ float mapviewdist = 20000;
glDisable(GL_DEPTH_TEST);
glColor3f (1.0, 1.0, 1.0); // no coloring
glEnable(GL_BLEND);
glColor4f(1,1,1,1);
glPushMatrix();
- float opac;
- opac=.7;
+ float opac = .7;
XYZ center;
float radius;
float distcheck;
- center=0;
int numliveplayers=0;
+ center = 0;
for(i=0;i<numplayers;i++){
- if(!player[i].dead)numliveplayers++;
+ if(!player[i].dead) numliveplayers++;
}
- int numadd;
- numadd=0;
+ int numadd = 0;
for(i=0;i<objects.numobjects;i++){
if(objects.type[i]==treetrunktype||objects.type[i]==boxtype){
glTexCoord2f(0,1);
glVertex3f(-1, 1, 0.0f);
glEnd();
- /*glBegin(GL_TRIANGLES);
- glTexCoord2f(0,0);
- glVertex3f(-1, -1, 0.0f);
- glTexCoord2f(1,0);
- glVertex3f(1, -1, 0.0f);
- glTexCoord2f(1,1);
- glVertex3f(0, 1, 0.0f);
- glEnd();*/
glPopMatrix();
}
}
- /*glBegin(GL_QUADS);
- glTexCoord2f(0,0);
- glVertex3f(-1, -1, 0.0f);
- glTexCoord2f(1,0);
- glVertex3f(1, -1, 0.0f);
- glTexCoord2f(1,1);
- glVertex3f(1, 1, 0.0f);
- glTexCoord2f(0,1);
- glVertex3f(-1, 1, 0.0f);
- glEnd();*/
glPopMatrix();
glDisable(GL_TEXTURE_2D);
glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
glDepthMask(1);
}
- /*if(loading){
- loading=2;
- drawmode=normalmode;
- }*/
-
-
if(loading&&!stealthloading&&(!campaign||player[0].dead)){
glDisable(GL_DEPTH_TEST); // Disables Depth Testing
glDisable(GL_CULL_FACE);
glColor3f (1.0, 1.0, 1.0); // no coloring
glEnable(GL_TEXTURE_2D);
- /*glBindTexture( GL_TEXTURE_2D, logotexture);
- glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
- glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
- glDisable(GL_DEPTH_TEST); // Disables Depth Testing
- glDisable(GL_CULL_FACE);
- glDisable(GL_LIGHTING);
- glDepthMask(0);
- glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
- glPushMatrix(); // Store The Projection Matrix
- glLoadIdentity(); // Reset The Projection Matrix
- glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
- glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
- glPushMatrix(); // Store The Modelview Matrix
- glLoadIdentity(); // Reset The Modelview Matrix
- glScalef((float)screenwidth/2,(float)screenwidth/2,1);
- glTranslatef(1.8,1.25,0);
- glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
- glEnable(GL_BLEND);
- glColor4f(1,1,1,1);
- glPushMatrix();
- glScalef(.25,.25,.25);
- glBegin(GL_QUADS);
- glTexCoord2f(0,0);
- glVertex3f(-1, -1, 0.0f);
- glTexCoord2f(1,0);
- glVertex3f(1, -1, 0.0f);
- glTexCoord2f(1,1);
- glVertex3f(1, 1, 0.0f);
- glTexCoord2f(0,1);
- glVertex3f(-1, 1, 0.0f);
- glEnd();
- glPopMatrix();
- glDisable(GL_TEXTURE_2D);
- glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
- glPopMatrix(); // Restore The Old Projection Matrix
- glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
- glPopMatrix(); // Restore The Old Projection Matrix
- glEnable(GL_DEPTH_TEST); // Enables Depth Testing
- glEnable(GL_CULL_FACE);
- glDisable(GL_BLEND);
- glDepthMask(1);*/
//Awards
- int numawards;
+ int numawards = 0;
int awards[30];
- numawards=0;
if(damagetaken==0&&player[0].bloodloss==0){
awards[numawards]=awardflawless;
numawards++;
}
- bool alldead;
+ bool alldead = true;
+ for(i=1;i<numplayers;i++){
+ if(player[i].dead!=2)alldead=0;
+ }
+ if(alldead){
+ awards[numawards]=awardalldead;
+ numawards++;
+ }
alldead=1;
- if(numplayers>1)
- for(i=1;i<numplayers;i++){
- if(player[i].dead!=2)alldead=0;
- }
- if(alldead){
- awards[numawards]=awardalldead;
- numawards++;
- }
- alldead=1;
- if(numplayers>1)
- for(i=1;i<numplayers;i++){
- if(player[i].dead!=1)alldead=0;
- }
- if(alldead){
- awards[numawards]=awardnodead;
- numawards++;
- }
- if(numresponded==0&&!numthrowkill){
- awards[numawards]=awardstealth;
- numawards++;
- }
- if(numattacks==numstaffattack&&numattacks>0){
- awards[numawards]=awardbojutsu;
- numawards++;
- }
- if(numattacks==numswordattack&&numattacks>0){
- awards[numawards]=awardswordsman;
- numawards++;
- }
- if(numattacks==numknifeattack&&numattacks>0){
- awards[numawards]=awardknifefighter;
- numawards++;
- }
- if(numattacks==numunarmedattack&&numthrowkill==0&&weapons.numweapons>0){
- awards[numawards]=awardkungfu;
- numawards++;
- }
- if(numescaped>0){
- awards[numawards]=awardevasion;
- numawards++;
- }
- if(numflipfail==0&&numflipped+numwallflipped*2>20){
- awards[numawards]=awardacrobat;
- numawards++;
- }
- if(numthrowkill==numplayers-1){
- awards[numawards]=awardlongrange;
- numawards++;
- }
- alldead=1;
- if(numplayers>1)
- for(i=1;i<numplayers;i++){
- if(player[i].dead!=2)alldead=0;
- }
- if(numafterkill>0&&alldead){
- awards[numawards]=awardbrutal;
- numawards++;
- }
- if(numreversals>((float)numattacks)*.8&&numreversals>3){
- awards[numawards]=awardaikido;
- numawards++;
- }
- if(maxalarmed==1&&numplayers>2){
- awards[numawards]=awardstrategy;
- numawards++;
- }
- if(numflipfail>3){
- awards[numawards]=awardklutz;
- numawards++;
- }
+ for(i=1;i<numplayers;i++){
+ if(player[i].dead!=1)alldead=0;
+ }
+ if(alldead){
+ awards[numawards]=awardnodead;
+ numawards++;
+ }
+ if(numresponded==0&&!numthrowkill){
+ awards[numawards]=awardstealth;
+ numawards++;
+ }
+ if(numattacks==numstaffattack&&numattacks>0){
+ awards[numawards]=awardbojutsu;
+ numawards++;
+ }
+ if(numattacks==numswordattack&&numattacks>0){
+ awards[numawards]=awardswordsman;
+ numawards++;
+ }
+ if(numattacks==numknifeattack&&numattacks>0){
+ awards[numawards]=awardknifefighter;
+ numawards++;
+ }
+ if(numattacks==numunarmedattack&&numthrowkill==0&&weapons.numweapons>0){
+ awards[numawards]=awardkungfu;
+ numawards++;
+ }
+ if(numescaped>0){
+ awards[numawards]=awardevasion;
+ numawards++;
+ }
+ if(numflipfail==0&&numflipped+numwallflipped*2>20){
+ awards[numawards]=awardacrobat;
+ numawards++;
+ }
+ if(numthrowkill==numplayers-1){
+ awards[numawards]=awardlongrange;
+ numawards++;
+ }
+ alldead=1;
+ for(i=1;i<numplayers;i++){
+ if(player[i].dead!=2)alldead=0;
+ }
+ if(numafterkill>0&&alldead){
+ awards[numawards]=awardbrutal;
+ numawards++;
+ }
+ if(numreversals>((float)numattacks)*.8&&numreversals>3){
+ awards[numawards]=awardaikido;
+ numawards++;
+ }
+ if(maxalarmed==1&&numplayers>2){
+ awards[numawards]=awardstrategy;
+ numawards++;
+ }
+ if(numflipfail>3){
+ awards[numawards]=awardklutz;
+ numawards++;
+ }
+
+ //Win Screen Won Victory
+
+ glEnable(GL_TEXTURE_2D);
+ glColor4f(1,1,1,1);
+ sprintf (string, "Level Cleared!");
+ text.glPrintOutlined(1024/2-strlen(string)*10,768*7/8,string,1,2,1024,768);
+ sprintf (string, "Score: %d",(int)(bonustotal-startbonustotal));
+ text.glPrintOutlined(1024/30,768*6/8,string,1,2,1024,768);
- //Win Screen Won Victory
+ if(campaign)
+ sprintf (string, "Press Escape or Space to continue");
+ else
+ sprintf (string, "Press Escape to return to menu or Space to continue");
+ text.glPrintOutlined(640/2-strlen(string)*5,480*1/16,string,1,1,640,480);
- glEnable(GL_TEXTURE_2D);
- glColor4f(1,1,1,1);
- sprintf (string, "Level Cleared!");
- text.glPrintOutlined(1024/2-strlen(string)*10,768*7/8,string,1,2,1024,768);
-
- sprintf (string, "Score: %d",(int)(bonustotal-startbonustotal));
- text.glPrintOutlined(1024/30,768*6/8,string,1,2,1024,768);
-
- if(!campaign)sprintf (string, "Press Escape to return to menu or Space to continue");
- if(campaign)sprintf (string, "Press Escape or Space to continue");
- text.glPrintOutlined(640/2-strlen(string)*5,480*1/16,string,1,1,640,480);
-
- char temp[255];
-
- for(i=0;i<255;i++)string[i]='\0';
- sprintf (temp, "Time: %d:",(int)(((int)leveltime-(int)(leveltime)%60)/60));
- strcat(string,temp);
- if((int)(leveltime)%60<10)strcat(string,"0");
- sprintf (temp, "%d",(int)(leveltime)%60);
- strcat(string,temp);
- text.glPrintOutlined(1024/30,768*6/8-40,string,1,2,1024,768);
-
- for(i=0;i<numawards;i++){
- if(i<6){
- if(awards[i]==awardklutz)sprintf (string, "Suicidal");
- if(awards[i]==awardflawless)sprintf (string, "Flawless!");
- if(awards[i]==awardalldead)sprintf (string, "Take no prisoners");
- if(awards[i]==awardnodead)sprintf (string, "Merciful");
- if(awards[i]==awardstealth)sprintf (string, "One with the shadows!");
- if(awards[i]==awardswordsman)sprintf (string, "Swordsman");
- if(awards[i]==awardkungfu)sprintf (string, "Unarmed!");
- if(awards[i]==awardknifefighter)sprintf (string, "Knife fighter");
- if(awards[i]==awardcoward)sprintf (string, "Coward");
- if(awards[i]==awardevasion)sprintf (string, "Escape artist");
- if(awards[i]==awardacrobat)sprintf (string, "Gymnast");
- if(awards[i]==awardlongrange)sprintf (string, "Blade slinger");
- if(awards[i]==awardbrutal)sprintf (string, "Brutal");
- if(awards[i]==awardhyper)sprintf (string, "Hyper");
- if(awards[i]==awardaikido)sprintf (string, "Aikido master!");
- if(awards[i]==awardrambo)sprintf (string, "Rambo");
- if(awards[i]==awardfast)sprintf (string, "Fast");
- if(awards[i]==awardrealfast)sprintf (string, "Real fast");
- if(awards[i]==awarddamnfast)sprintf (string, "Damn fast");
- if(awards[i]==awardstrategy)sprintf (string, "Divide and conquer");
- if(awards[i]==awardbojutsu)sprintf (string, "Bojutsu");
- text.glPrintOutlined(1024/30,768*6/8-90-40*i,string,1,2,1024,768);
- }
- }
+ char temp[255];
- //drawmode=normalmode;
+ for(i=0;i<255;i++)string[i]='\0';
+ sprintf (temp, "Time: %d:",(int)(((int)leveltime-(int)(leveltime)%60)/60));
+ strcat(string,temp);
+ if((int)(leveltime)%60<10)strcat(string,"0");
+ sprintf (temp, "%d",(int)(leveltime)%60);
+ strcat(string,temp);
+ text.glPrintOutlined(1024/30,768*6/8-40,string,1,2,1024,768);
+
+ for(i=0;i<numawards;i++){
+ if(i<6){
+ if(awards[i]==awardklutz)sprintf (string, "Suicidal");
+ if(awards[i]==awardflawless)sprintf (string, "Flawless!");
+ if(awards[i]==awardalldead)sprintf (string, "Take no prisoners");
+ if(awards[i]==awardnodead)sprintf (string, "Merciful");
+ if(awards[i]==awardstealth)sprintf (string, "One with the shadows!");
+ if(awards[i]==awardswordsman)sprintf (string, "Swordsman");
+ if(awards[i]==awardkungfu)sprintf (string, "Unarmed!");
+ if(awards[i]==awardknifefighter)sprintf (string, "Knife fighter");
+ if(awards[i]==awardcoward)sprintf (string, "Coward");
+ if(awards[i]==awardevasion)sprintf (string, "Escape artist");
+ if(awards[i]==awardacrobat)sprintf (string, "Gymnast");
+ if(awards[i]==awardlongrange)sprintf (string, "Blade slinger");
+ if(awards[i]==awardbrutal)sprintf (string, "Brutal");
+ if(awards[i]==awardhyper)sprintf (string, "Hyper");
+ if(awards[i]==awardaikido)sprintf (string, "Aikido master!");
+ if(awards[i]==awardrambo)sprintf (string, "Rambo");
+ if(awards[i]==awardfast)sprintf (string, "Fast");
+ if(awards[i]==awardrealfast)sprintf (string, "Real fast");
+ if(awards[i]==awarddamnfast)sprintf (string, "Damn fast");
+ if(awards[i]==awardstrategy)sprintf (string, "Divide and conquer");
+ if(awards[i]==awardbojutsu)sprintf (string, "Bojutsu");
+ text.glPrintOutlined(1024/30,768*6/8-90-40*i,string,1,2,1024,768);
+ }
+ }
}
if(drawmode!=normalmode){
if(drawmode==motionblurmode){
glDrawBuffer(GL_FRONT);
glReadBuffer(GL_BACK);
- //myassert(glGetError() == GL_NO_ERROR);
- //glFlush();
}
glColor3f (1.0, 1.0, 1.0); // no coloring
if(console){
glEnable(GL_TEXTURE_2D);
glColor4f(1,1,1,1);
- if(console){
- int offset;
- offset=0;
- if(consoleselected>=60)offset=consoleselected-60;
- sprintf (string, " ]");
- text.glPrint(10,30,string,0,1,1024,768);
- if(consoleblink){
- sprintf (string, "_");
- text.glPrint(30+(float)(consoleselected)*10-offset*10,30,string,0,1,1024,768);
- }
- for(i=0;i<15;i++){
- for(j=0;j<consolechars[i];j++){
- glColor4f(1,1,1,1-(float)(i)/16);
- if(j<consolechars[i]){
- sprintf (string, "%c",consoletext[i][j]);
- text.glPrint(30+j*10-offset*10,30+i*20,string,0,1,1024,768);
- }
+ int offset = 0;
+ if(consoleselected>=60)
+ offset=consoleselected-60;
+ sprintf (string, " ]");
+ text.glPrint(10,30,string,0,1,1024,768);
+ if(consoleblink){
+ sprintf (string, "_");
+ text.glPrint(30+(float)(consoleselected)*10-offset*10,30,string,0,1,1024,768);
+ }
+ for(i=0;i<15;i++){
+ for(j=0;j<consolechars[i];j++){
+ glColor4f(1,1,1,1-(float)(i)/16);
+ if(j<consolechars[i]){
+ sprintf (string, "%c",consoletext[i][j]);
+ text.glPrint(30+j*10-offset*10,30+i*20,string,0,1,1024,768);
}
}
}
if(mainmenu==1){
LoadTexture(":Data:Textures:Newgame.png",&Mainmenuitems[1],0,0);
LoadTexture(":Data:Textures:Quit.png",&Mainmenuitems[3],0,0);
- /*if(oldmainmenu==1||oldmainmenu==0){
- LoadTexture(":Data:Textures:World.png",&Mainmenuitems[7],0,0);
- LoadTexture(":Data:Textures:Options.png",&Mainmenuitems[2],0,0);
- LoadTexture(":Data:Textures:Lugaru.png",&Mainmenuitems[0],0,0);
- loaddistrib=0;
- }*/
}
if(mainmenu==2){
LoadTexture(":Data:Textures:Resume.png",&Mainmenuitems[1],0,0);
LoadTexture(":Data:Textures:Endgame.png",&Mainmenuitems[3],0,0);
- /*if(oldmainmenu==2||oldmainmenu==0){
- LoadTexture(":Data:Textures:World.png",&Mainmenuitems[7],0,0);
- LoadTexture(":Data:Textures:Options.png",&Mainmenuitems[2],0,0);
- LoadTexture(":Data:Textures:Lugaru.png",&Mainmenuitems[0],0,0);
- loaddistrib=0;
- }*/
}
}
if(lastcheck>.5||oldmainmenu!=mainmenu){
if(mainmenu==5){
ifstream ipstream(ConvertFileName(":Data:Campaigns:main.txt"));
- //campaignnumlevels=0;
- //accountactive->getCampaignChoicesMade()=0;
ipstream.ignore(256,':');
ipstream >> campaignnumlevels;
for(i=0;i<campaignnumlevels;i++){
ipstream >> campaignchoosenext[i];
ipstream.ignore(256,':');
ipstream >> campaignnumnext[i];
- if(campaignnumnext[i])
- for(j=0;j<campaignnumnext[i];j++){
- ipstream.ignore(256,':');
- ipstream >> campaignnextlevel[i][j];
- campaignnextlevel[i][j]-=1;
- }
+ for(j=0;j<campaignnumnext[i];j++){
ipstream.ignore(256,':');
- ipstream >> campaignlocationx[i];
- //campaignlocationx[i]-=30;
- ipstream.ignore(256,':');
- ipstream >> campaignlocationy[i];
- //campaignlocationy[i]+=30;
+ ipstream >> campaignnextlevel[i][j];
+ campaignnextlevel[i][j]-=1;
+ }
+ ipstream.ignore(256,':');
+ ipstream >> campaignlocationx[i];
+ ipstream.ignore(256,':');
+ ipstream >> campaignlocationy[i];
}
ipstream.close();
levelorder[0]=0;
levelvisible[0]=1;
- if(accountactive->getCampaignChoicesMade())
- for(i=0;i<accountactive->getCampaignChoicesMade();i++){
- levelorder[i+1]=campaignnextlevel[levelorder[i]][accountactive->getCampaignChoice(i)];
- levelvisible[levelorder[i+1]]=1;
- }
- int whichlevelstart;
- whichlevelstart=accountactive->getCampaignChoicesMade()-1;
- if(whichlevelstart<0){
- accountactive->setCampaignScore(0);
- accountactive->resetFasttime();
- campaignchoicenum=1;
- campaignchoicewhich[0]=0;
- }
- else
- {
- campaignchoicenum=campaignnumnext[levelorder[whichlevelstart]];
- if(campaignchoicenum==0){
- //if(accountactive->getCampaignFasttime()==0||accountcampaigntime[accountactive]<accountactive->getCampaignFasttime())accountactive->getCampaignFasttime()=accountcampaigntime[accountactive];
- }
- if(campaignchoicenum)
- for(i=0;i<campaignchoicenum;i++){
- campaignchoicewhich[i]=campaignnextlevel[levelorder[whichlevelstart]][i];
- levelvisible[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
- levelhighlight[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
- }
+ for(i=0;i<accountactive->getCampaignChoicesMade();i++){
+ levelorder[i+1]=campaignnextlevel[levelorder[i]][accountactive->getCampaignChoice(i)];
+ levelvisible[levelorder[i+1]]=1;
+ }
+ int whichlevelstart = accountactive->getCampaignChoicesMade()-1;
+ if(whichlevelstart<0){
+ accountactive->setCampaignScore(0);
+ accountactive->resetFasttime();
+ campaignchoicenum=1;
+ campaignchoicewhich[0]=0;
+ }
+ else
+ {
+ campaignchoicenum=campaignnumnext[levelorder[whichlevelstart]];
+ for(i=0;i<campaignchoicenum;i++){
+ campaignchoicewhich[i]=campaignnextlevel[levelorder[whichlevelstart]][i];
+ levelvisible[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
+ levelhighlight[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
}
- /*levelorder[0]=0;
- levelorder[1]=1;
- levelorder[2]=2;
- levelorder[3]=3;*/
+ }
}
}
if(mainmenu==5){
texdetail=temptexdetail;
- /*if(mainmenu!=0)*/oldmainmenu=mainmenu;
+ oldmainmenu=mainmenu;
if(mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==8||mainmenu==9||mainmenu==10||mainmenu==119||mainmenu==13||mainmenu==17||mainmenu==18){
glClear(GL_DEPTH_BUFFER_BIT);
}
}
- if(mainmenu==13){
- nummenuitems=2;
- char temp[255];
-
- sprintf (menustring[0], "Please enter your name:");
- startx[0]=50;
- starty[0]=250;
- endx[0]=startx[0]+strlen(menustring[0])*10;
- endy[0]=starty[0]+20;
- movex[0]=0;
- movey[0]=0;
-
- sprintf (menustring[1], "Please enter your name:");
- startx[1]=290;
- starty[1]=250;
- endx[1]=startx[1]+strlen(menustring[1])*10;
- endy[1]=starty[1]+20;
- movex[1]=0;
- movey[1]=0;
- }
if(mainmenu==1||mainmenu==2){
nummenuitems=7;
startx[0]=150;
}
}
- if(mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==8||mainmenu==9||mainmenu==10||mainmenu==11||mainmenu==13||mainmenu==17||mainmenu==18)
- for(i=0;i<nummenuitems;i++){
- if((mousecoordh/screenwidth*640)>startx[i]&&(mousecoordh/screenwidth*640)<endx[i]&&480-(mousecoordv/screenheight*480)>starty[i]&&480-(mousecoordv/screenheight*480)<endy[i]){
- if(mainmenu!=5)selected=i;
- if(mainmenu==5&&(i!=0&&i!=6))selected=i;
- if(mainmenu==9&&(i!=numchallengelevels+1))selected=i;
- if(mainmenu==11&&(i!=numchallengelevels+1))selected=i;
- }
+ if(mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==8||mainmenu==9||mainmenu==10||mainmenu==11||mainmenu==13||mainmenu==17||mainmenu==18)
+ for(i=0;i<nummenuitems;i++){
+ if((mousecoordh/screenwidth*640)>startx[i]&&(mousecoordh/screenwidth*640)<endx[i]&&480-(mousecoordv/screenheight*480)>starty[i]&&480-(mousecoordv/screenheight*480)<endy[i]){
+ if(mainmenu!=5)selected=i;
+ if(mainmenu==5&&(i!=0&&i!=6))selected=i;
+ if(mainmenu==9&&(i!=numchallengelevels+1))selected=i;
+ if(mainmenu==11&&(i!=numchallengelevels+1))selected=i;
}
+ }
- if(nummenuitems>0)
- for(i=0;i<nummenuitems;i++){
- if(selected==i)selectedlong[i]+=multiplier*5;
- if(selectedlong[i]>1)selectedlong[i]=1;
- if(selected!=i)selectedlong[i]-=multiplier*5;
- if(selectedlong[i]<0)selectedlong[i]=0;
- //if(i>=4)selectedlong[i]=.3;
- if(i>=4&&(mainmenu==1||mainmenu==2))selectedlong[i]=0;
- }
-
- if(nummenuitems>0)
- for(i=0;i<nummenuitems;i++){
- offsetx[i]=(startx[i]+endx[i])/2-(mousecoordh/screenwidth*640);
- offsety[i]=(starty[i]+endy[i])/2-(480-(mousecoordv/screenheight*480));
- offsetx[i]*=.06f;
- offsety[i]*=.06f;
- offsetx[i]=0;
- offsety[i]=0;
- if(i>=4&&(mainmenu==1||mainmenu==2)){
- offsetx[i]=(startx[i]+endx[i]+movex[i]*transition)/2-(640+190)/2;
- offsety[i]=(starty[i]+endy[i]+movey[i]*transition)/2-(336+150)/2;
- offsetx[i]*=.06f;
- offsety[i]*=.06f;
- }
- }
+ for(i=0;i<nummenuitems;i++){
+ if(selected==i) {
+ selectedlong[i]+=multiplier*5;
+ if(selectedlong[i]>1) selectedlong[i]=1;
+ } else {
+ selectedlong[i]-=multiplier*5;
+ if(selectedlong[i]<0) selectedlong[i]=0;
+ }
+ offsetx[i]=(startx[i]+endx[i])/2-(mousecoordh/screenwidth*640);
+ offsety[i]=(starty[i]+endy[i])/2-(480-(mousecoordv/screenheight*480));
+ offsetx[i]*=.06f;
+ offsety[i]*=.06f;
+ offsetx[i]=0;
+ offsety[i]=0;
+ if(i>=4&&(mainmenu==1||mainmenu==2)){
+ selectedlong[i]=0;
+ offsetx[i]=(startx[i]+endx[i]+movex[i]*transition)/2-(640+190)/2;
+ offsety[i]=(starty[i]+endy[i]+movey[i]*transition)/2-(336+150)/2;
+ offsetx[i]*=.06f;
+ offsety[i]*=.06f;
+ }
+ }
- if(mainmenu==1||mainmenu==2){
- glClear(GL_DEPTH_BUFFER_BIT);
- glEnable(GL_ALPHA_TEST);
- glAlphaFunc(GL_GREATER, 0.001f);
- glEnable(GL_TEXTURE_2D);
- glDisable(GL_DEPTH_TEST); // Disables Depth Testing
- glDisable(GL_CULL_FACE);
- glDisable(GL_LIGHTING);
- glDepthMask(0);
- glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
- glPushMatrix(); // Store The Projection Matrix
- glLoadIdentity(); // Reset The Projection Matrix
- glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
- glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
- glPushMatrix(); // Store The Modelview Matrix
- glLoadIdentity(); // Reset The Modelview Matrix
- glTranslatef(screenwidth/2,screenheight/2,0);
- glPushMatrix();
- glScalef((float)screenwidth/2,(float)screenheight/2,1);
- glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
- glDisable(GL_BLEND);
- glColor4f(0,0,0,1.0);
- glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
- glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
- glDisable(GL_TEXTURE_2D);
- glPushMatrix();
- //glScalef(.25,.25,.25);
- glBegin(GL_QUADS);
- glTexCoord2f(0,0);
- glVertex3f(-1, -1, 0.0f);
- glTexCoord2f(1,0);
- glVertex3f(1, -1, 0.0f);
- glTexCoord2f(1,1);
- glVertex3f(1, 1, 0.0f);
- glTexCoord2f(0,1);
- glVertex3f(-1, 1, 0.0f);
- glEnd();
- glPopMatrix();
- glEnable(GL_BLEND);
- glColor4f(0.4,0.4,0.4,1.0);
- glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
- glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
- glEnable(GL_TEXTURE_2D);
- glBindTexture( GL_TEXTURE_2D, Mainmenuitems[4]);
- glPushMatrix();
- //glScalef(.25,.25,.25);
- glBegin(GL_QUADS);
- glTexCoord2f(0,0);
- glVertex3f(-1, -1, 0.0f);
- glTexCoord2f(1,0);
- glVertex3f(1, -1, 0.0f);
- glTexCoord2f(1,1);
- glVertex3f(1, 1, 0.0f);
- glTexCoord2f(0,1);
- glVertex3f(-1, 1, 0.0f);
- glEnd();
- glPopMatrix();
- glPopMatrix();
- glPopMatrix();
- glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
- glPopMatrix();
+ if(mainmenu==1||mainmenu==2){
+ glClear(GL_DEPTH_BUFFER_BIT);
+ glEnable(GL_ALPHA_TEST);
+ glAlphaFunc(GL_GREATER, 0.001f);
+ glEnable(GL_TEXTURE_2D);
+ glDisable(GL_DEPTH_TEST); // Disables Depth Testing
+ glDisable(GL_CULL_FACE);
+ glDisable(GL_LIGHTING);
+ glDepthMask(0);
+ glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
+ glPushMatrix(); // Store The Projection Matrix
+ glLoadIdentity(); // Reset The Projection Matrix
+ glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
+ glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
+ glPushMatrix(); // Store The Modelview Matrix
+ glLoadIdentity(); // Reset The Modelview Matrix
+ glTranslatef(screenwidth/2,screenheight/2,0);
+ glPushMatrix();
+ glScalef((float)screenwidth/2,(float)screenheight/2,1);
+ glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
+ glDisable(GL_BLEND);
+ glColor4f(0,0,0,1.0);
+ glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
+ glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
+ glDisable(GL_TEXTURE_2D);
+ glPushMatrix();
+ //glScalef(.25,.25,.25);
+ glBegin(GL_QUADS);
+ glTexCoord2f(0,0);
+ glVertex3f(-1, -1, 0.0f);
+ glTexCoord2f(1,0);
+ glVertex3f(1, -1, 0.0f);
+ glTexCoord2f(1,1);
+ glVertex3f(1, 1, 0.0f);
+ glTexCoord2f(0,1);
+ glVertex3f(-1, 1, 0.0f);
+ glEnd();
+ glPopMatrix();
+ glEnable(GL_BLEND);
+ glColor4f(0.4,0.4,0.4,1.0);
+ glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
+ glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
+ glEnable(GL_TEXTURE_2D);
+ glBindTexture( GL_TEXTURE_2D, Mainmenuitems[4]);
+ glPushMatrix();
+ //glScalef(.25,.25,.25);
+ glBegin(GL_QUADS);
+ glTexCoord2f(0,0);
+ glVertex3f(-1, -1, 0.0f);
+ glTexCoord2f(1,0);
+ glVertex3f(1, -1, 0.0f);
+ glTexCoord2f(1,1);
+ glVertex3f(1, 1, 0.0f);
+ glTexCoord2f(0,1);
+ glVertex3f(-1, 1, 0.0f);
+ glEnd();
+ glPopMatrix();
+ glPopMatrix();
+ glPopMatrix();
+ glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
+ glPopMatrix();
- glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
- glPushMatrix(); // Store The Projection Matrix
- glLoadIdentity(); // Reset The Projection Matrix
- glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
- glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
- glPushMatrix(); // Store The Modelview Matrix
- glLoadIdentity(); // Reset The Modelview Matrix
- glPushMatrix();
- glDisable(GL_TEXTURE_2D);
- glColor4f(1,0,0,1);
- /*glPushMatrix();
- glBegin(GL_QUADS);
- glTexCoord2f(0,0);
- if(anim!=1)glVertex3f(190, 150, 0.0f);
- if(anim==1)glVertex3f(190+movex[4]*transition, 150, 0.0f);
- glTexCoord2f(1,0);
- glVertex3f(640, 150, 0.0f);
- glTexCoord2f(1,1);
- glVertex3f(640, 336, 0.0f);
- glTexCoord2f(0,1);
- if(anim!=1)glVertex3f(190, 336, 0.0f);
- if(anim==1)glVertex3f(190+movex[4]*transition, 336, 0.0f);
- glEnd();
- glPopMatrix();*/
- glPopMatrix();
- glPopMatrix();
- glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
- glPopMatrix();
- glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
+ glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
+ glPushMatrix(); // Store The Projection Matrix
+ glLoadIdentity(); // Reset The Projection Matrix
+ glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
+ glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
+ glPushMatrix(); // Store The Modelview Matrix
+ glLoadIdentity(); // Reset The Modelview Matrix
+ glPushMatrix();
+ glDisable(GL_TEXTURE_2D);
+ glColor4f(1,0,0,1);
+ glPopMatrix();
+ glPopMatrix();
+ glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
+ glPopMatrix();
+ glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
- }
+ }
- glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
- glPushMatrix(); // Store The Projection Matrix
- glLoadIdentity(); // Reset The Projection Matrix
- glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
+ glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
+ glPushMatrix(); // Store The Projection Matrix
+ glLoadIdentity(); // Reset The Projection Matrix
+ glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
+ glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
+ glPushMatrix(); // Store The Modelview Matrix
+ glLoadIdentity(); // Reset The Modelview Matrix
+ glEnable(GL_TEXTURE_2D);
+ for(j=0;j<nummenuitems;j++)
+ {
+ if(j<=3||(mainmenu!=1&&mainmenu!=2))
+ {
+ //glDisable(GL_BLEND);
+ glEnable(GL_ALPHA_TEST);
+ glEnable(GL_BLEND);
+ //glDisable(GL_ALPHA_TEST);
+ glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
+ if(mainmenu==1||mainmenu==2)
+ {
+ glColor4f(1,1,1,1);
+ glBlendFunc(GL_SRC_ALPHA,GL_ONE);
+ glBindTexture( GL_TEXTURE_2D, Mainmenuitems[j]);
+ glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
+ glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
+ glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
+ glPushMatrix();
+ glBegin(GL_QUADS);
+ glTexCoord2f(0,0);
+ glVertex3f(startx[j]+movex[j]*transition, starty[j]+movey[j]*transition, 0.0f);
+ glTexCoord2f(1,0);
+ glVertex3f(endx[j]+movex[j]*transition, starty[j]+movey[j]*transition, 0.0f);
+ glTexCoord2f(1,1);
+ glVertex3f(endx[j]+movex[j]*transition, endy[j]+movey[j]*transition, 0.0f);
+ glTexCoord2f(0,1);
+ glVertex3f(startx[j]+movex[j]*transition, endy[j]+movey[j]*transition, 0.0f);
+ glEnd();
+ glPopMatrix();
+ glEnable(GL_BLEND);
+ //glDisable(GL_ALPHA_TEST);
+ if(j<4)glBlendFunc(GL_SRC_ALPHA,GL_ONE);
+ for(i=0;i<10;i++)
+ {
+ if(1-((float)i)/10-(1-selectedlong[j])>0)
+ {
+ glColor4f(1,1,1,(1-((float)i)/10-(1-selectedlong[j]))*.25);
+ glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
+ glPushMatrix();
+ glBegin(GL_QUADS);
+ glTexCoord2f(0,0);
+ glVertex3f(startx[j]-((float)i)*1/2+offsetx[j]*((float)i)/2+movex[j]*transition, starty[j]-((float)i)*1/2+offsety[j]*((float)i)/2+movey[j]*transition, 0.0f);
+ glTexCoord2f(1,0);
+ glVertex3f(endx[j]+((float)i)*1/2+offsetx[j]*((float)i)/2+movex[j]*transition, starty[j]-((float)i)*1/2+offsety[j]*((float)i)/2+movey[j]*transition, 0.0f);
+ glTexCoord2f(1,1);
+ glVertex3f(endx[j]+((float)i)*1/2+offsetx[j]*((float)i)/2+movex[j]*transition, endy[j]+((float)i)*1/2+offsety[j]*((float)i)/2+movey[j]*transition, 0.0f);
+ glTexCoord2f(0,1);
+ glVertex3f(startx[j]-((float)i)*1/2+offsetx[j]*((float)i)/2+movex[j]*transition, endy[j]+((float)i)*1/2+offsety[j]*((float)i)/2+movey[j]*transition, 0.0f);
+ glEnd();
+ glPopMatrix();
+ }
+ }
+ }
+ if(mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==8||mainmenu==9||mainmenu==10||mainmenu==11||mainmenu==13||mainmenu==17||mainmenu==18)
+ {
+ if(mainmenu!=5||j<6)
+ {
+ glColor4f(1,0,0,1);
+ if(mainmenu==9&&j>accountactive->getProgress()&&j<numchallengelevels)glColor4f(0.5,0,0,1);
+ if(mainmenu==11&&j>accountactive->getProgress()&&j<numchallengelevels)glColor4f(0.5,0,0,1);
+ //if(1-((float)i)/10-(1-selectedlong[j])>0){
glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
- glPushMatrix(); // Store The Modelview Matrix
- glLoadIdentity(); // Reset The Modelview Matrix
- glEnable(GL_TEXTURE_2D);
- if(nummenuitems>0)
+ glPushMatrix();
+ if(mainmenu!=7||j!=0||!entername)
+ text.glPrint(startx[j],starty[j],menustring[j],0,1,640,480);
+ else
+ {
+ if(displayblink){
+ sprintf (string, "_");
+ text.glPrint(startx[j]+(float)(displayselected)*10,starty[j],string,0,1,640,480);
+ }
+ for(l=0;l<displaychars[0];l++){
+ sprintf (string, "%c",displaytext[0][l]);
+ text.glPrint(startx[j]+l*10,starty[j],string,0,1,640,480);
+ }
+ }
+ glPopMatrix();
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA,GL_ONE);
+ for(i=0;i<15;i++)
{
- for(j=0;j<nummenuitems;j++)
+ if(1-((float)i)/15-(1-selectedlong[j])>0)
{
- if(j<=3||(mainmenu!=1&&mainmenu!=2))
- {
- //glDisable(GL_BLEND);
- glEnable(GL_ALPHA_TEST);
- glEnable(GL_BLEND);
- //glDisable(GL_ALPHA_TEST);
- glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
- if(mainmenu==1||mainmenu==2)
+ glColor4f(1,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
+ if(mainmenu==9&&j>accountactive->getProgress()&&j<numchallengelevels)glColor4f(0.5,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
+ if(mainmenu==11&&j>accountactive->getProgress()&&j<numchallengelevels)glColor4f(0.5,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
+ if(mainmenu==3)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4-((/*1*/+((float)i)/70)*strlen(menustring[j]))*3,starty[j]+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
+ if(mainmenu==4)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4,starty[j]+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
+ if(mainmenu==5)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4,starty[j]+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
+ if(mainmenu==6)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4,starty[j]+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
+ if(mainmenu==7&&(j!=0||!entername)) text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4,starty[j]+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
+ if(mainmenu==8)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4,starty[j]+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
+ if(mainmenu==9)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4,starty[j]+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
+ if(mainmenu==11)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4,starty[j]+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
+ if(mainmenu==10)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4,starty[j]+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
+ if(mainmenu==17)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4,starty[j]+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
+ if(mainmenu==13&&j!=1)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4,starty[j]+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
+ if(mainmenu==18)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4,starty[j]+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
+ }
+ }
+ }
+ else
+ {
+ glClear(GL_DEPTH_BUFFER_BIT);
+ glEnable(GL_ALPHA_TEST);
+ glAlphaFunc(GL_GREATER, 0.001f);
+ glEnable(GL_TEXTURE_2D);
+ glDisable(GL_DEPTH_TEST); // Disables Depth Testing
+ glDisable(GL_CULL_FACE);
+ glDisable(GL_LIGHTING);
+ if(j==6)glColor4f(1,1,1,1);
+ else glColor4f(1,0,0,1);
+
+ glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
+ glPushMatrix(); // Store The Projection Matrix
+ glLoadIdentity(); // Reset The Projection Matrix
+ glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
+ glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
+ glPushMatrix(); // Store The Modelview Matrix
+ glLoadIdentity(); // Reset The Modelview Matrix
+ glPushMatrix();
+
+ //Draw world, draw map
+ glTranslatef(2,-5,0);
+
+ if(j>6&&j<nummenuitems-1)
+ {
+ XYZ linestart,lineend,offset;
+ XYZ fac;
+ float startsize;
+ float endsize;
+ linestart=0;
+ lineend=0;
+ offset=0;
+ //float linestartx,lineendx,linestarty,lineendy,offsetx,offsety;
+ linestart.x=(startx[j]+endx[j])/2;
+ linestart.y=(starty[j]+endy[j])/2;
+ if(j>=6+accountactive->getCampaignChoicesMade()){
+ linestart.x=(startx[6+accountactive->getCampaignChoicesMade()]+endx[6+accountactive->getCampaignChoicesMade()])/2;
+ linestart.y=(starty[6+accountactive->getCampaignChoicesMade()]+endy[6+accountactive->getCampaignChoicesMade()])/2;
+ }
+ lineend.x=(startx[j+1]+endx[j+1])/2;
+ lineend.y=(starty[j+1]+endy[j+1])/2;
+ offset=lineend-linestart;
+ fac=offset;
+ Normalise(&fac);
+ offset=DoRotation(offset,0,0,90);
+ Normalise(&offset);
+ glDisable(GL_TEXTURE_2D);
+
+ if(j<6+accountactive->getCampaignChoicesMade()){
+ glColor4f(0.5,0,0,1);
+ endsize=.5;
+ } else {
+ glColor4f(1,0,0,1);
+ endsize=1;
+ }
+ startsize=.5;
+
+ linestart+=fac*4*startsize;
+ lineend-=fac*4*endsize;
+
+ if(!(j>7+accountactive->getCampaignChoicesMade()+campaignchoicenum)){
+ glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
+ glPushMatrix();
+ glBegin(GL_QUADS);
+ glTexCoord2f(0,0);
+ glVertex3f(linestart.x-offset.x*startsize, linestart.y-offset.y*startsize, 0.0f);
+ glTexCoord2f(1,0);
+ glVertex3f(linestart.x+offset.x*startsize, linestart.y+offset.y*startsize, 0.0f);
+ glTexCoord2f(1,1);
+ glVertex3f(lineend.x+offset.x*endsize, lineend.y+offset.y*endsize, 0.0f);
+ glTexCoord2f(0,1);
+ glVertex3f(lineend.x-offset.x*endsize, lineend.y-offset.y*endsize, 0.0f);
+ glEnd();
+ glPopMatrix();
+ }
+ glEnable(GL_TEXTURE_2D);
+ }
+
+
+ if(j==6)glBindTexture( GL_TEXTURE_2D, Mainmenuitems[7]);
+ else glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
+ glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
+ glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
+ if(j-7<accountactive->getCampaignChoicesMade())glColor4f(0.5,0,0,1);
+ if(j-7>=accountactive->getCampaignChoicesMade())glColor4f(1,0,0,1);
+ if(j==6)glColor4f(1,1,1,1);
+ XYZ midpoint;
+ float itemsize;
+ itemsize=abs(startx[j]-endx[j])/2;
+ midpoint=0;
+ midpoint.x=(startx[j]+endx[j])/2;
+ midpoint.y=(starty[j]+endy[j])/2;
+ if(j>6&&(j-7<accountactive->getCampaignChoicesMade()))itemsize*=.5;
+ if(!(j-7>accountactive->getCampaignChoicesMade()+campaignchoicenum))
{
- glColor4f(1,1,1,1);
- glBlendFunc(GL_SRC_ALPHA,GL_ONE);
- glBindTexture( GL_TEXTURE_2D, Mainmenuitems[j]);
- glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
- glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
glPushMatrix();
glBegin(GL_QUADS);
glTexCoord2f(0,0);
- glVertex3f(startx[j]+movex[j]*transition, starty[j]+movey[j]*transition, 0.0f);
+ glVertex3f(midpoint.x-itemsize+movex[j]*transition, midpoint.y-itemsize+movey[j]*transition, 0.0f);
glTexCoord2f(1,0);
- glVertex3f(endx[j]+movex[j]*transition, starty[j]+movey[j]*transition, 0.0f);
+ glVertex3f(midpoint.x+itemsize+movex[j]*transition, midpoint.y-itemsize+movey[j]*transition, 0.0f);
glTexCoord2f(1,1);
- glVertex3f(endx[j]+movex[j]*transition, endy[j]+movey[j]*transition, 0.0f);
+ glVertex3f(midpoint.x+itemsize+movex[j]*transition, midpoint.y+itemsize+movey[j]*transition, 0.0f);
glTexCoord2f(0,1);
- glVertex3f(startx[j]+movex[j]*transition, endy[j]+movey[j]*transition, 0.0f);
+ glVertex3f(midpoint.x-itemsize+movex[j]*transition, midpoint.y+itemsize+movey[j]*transition, 0.0f);
glEnd();
glPopMatrix();
glEnable(GL_BLEND);
{
if(1-((float)i)/10-(1-selectedlong[j])>0)
{
- glColor4f(1,1,1,(1-((float)i)/10-(1-selectedlong[j]))*.25);
+ glColor4f(1,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
glPushMatrix();
glBegin(GL_QUADS);
glTexCoord2f(0,0);
- glVertex3f(startx[j]-((float)i)*1/2+offsetx[j]*((float)i)/2+movex[j]*transition, starty[j]-((float)i)*1/2+offsety[j]*((float)i)/2+movey[j]*transition, 0.0f);
+ glVertex3f(midpoint.x-itemsize-((float)i)*1/2+offsetx[j]*((float)i)/2+movex[j]*transition, midpoint.y-itemsize-((float)i)*1/2+offsety[j]*((float)i)/2+movey[j]*transition, 0.0f);
glTexCoord2f(1,0);
- glVertex3f(endx[j]+((float)i)*1/2+offsetx[j]*((float)i)/2+movex[j]*transition, starty[j]-((float)i)*1/2+offsety[j]*((float)i)/2+movey[j]*transition, 0.0f);
+ glVertex3f(midpoint.x+itemsize+((float)i)*1/2+offsetx[j]*((float)i)/2+movex[j]*transition, midpoint.y-itemsize-((float)i)*1/2+offsety[j]*((float)i)/2+movey[j]*transition, 0.0f);
glTexCoord2f(1,1);
- glVertex3f(endx[j]+((float)i)*1/2+offsetx[j]*((float)i)/2+movex[j]*transition, endy[j]+((float)i)*1/2+offsety[j]*((float)i)/2+movey[j]*transition, 0.0f);
+ glVertex3f(midpoint.x+itemsize+((float)i)*1/2+offsetx[j]*((float)i)/2+movex[j]*transition, midpoint.y+itemsize+((float)i)*1/2+offsety[j]*((float)i)/2+movey[j]*transition, 0.0f);
glTexCoord2f(0,1);
- glVertex3f(startx[j]-((float)i)*1/2+offsetx[j]*((float)i)/2+movex[j]*transition, endy[j]+((float)i)*1/2+offsety[j]*((float)i)/2+movey[j]*transition, 0.0f);
+ glVertex3f(midpoint.x-itemsize-((float)i)*1/2+offsetx[j]*((float)i)/2+movex[j]*transition, midpoint.y+itemsize+((float)i)*1/2+offsety[j]*((float)i)/2+movey[j]*transition, 0.0f);
glEnd();
glPopMatrix();
}
}
}
- if(mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==8||mainmenu==9||mainmenu==10||mainmenu==11||mainmenu==13||mainmenu==17||mainmenu==18)
- {
- if(mainmenu!=5||j<6)
- {
- glColor4f(1,0,0,1);
- if(mainmenu==9&&j>accountactive->getProgress()&&j<numchallengelevels)glColor4f(0.5,0,0,1);
- if(mainmenu==11&&j>accountactive->getProgress()&&j<numchallengelevels)glColor4f(0.5,0,0,1);
- //if(1-((float)i)/10-(1-selectedlong[j])>0){
- glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
- glPushMatrix();
- if(mainmenu!=7||j!=0||!entername)
- text.glPrint(startx[j],starty[j],menustring[j],0,1,640,480);
- else
- {
- if(displayblink){
- sprintf (string, "_");
- text.glPrint(startx[j]+(float)(displayselected)*10,starty[j],string,0,1,640,480);
- }
- for(l=0;l<displaychars[0];l++){
- sprintf (string, "%c",displaytext[0][l]);
- text.glPrint(startx[j]+l*10,starty[j],string,0,1,640,480);
- }
- }
- glPopMatrix();
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA,GL_ONE);
- for(i=0;i<15;i++)
- {
- if(1-((float)i)/15-(1-selectedlong[j])>0)
- {
- glColor4f(1,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
- if(mainmenu==9&&j>accountactive->getProgress()&&j<numchallengelevels)glColor4f(0.5,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
- if(mainmenu==11&&j>accountactive->getProgress()&&j<numchallengelevels)glColor4f(0.5,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
- if(mainmenu==3)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4-((/*1*/+((float)i)/70)*strlen(menustring[j]))*3,starty[j]/*-i*1/2*/+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
- if(mainmenu==4)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4/*-((((float)i)/70)*strlen(menustring[j]))*3*/,starty[j]/*-i*1/2*/+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
- if(mainmenu==5)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4/*-((((float)i)/70)*strlen(menustring[j]))*3*/,starty[j]/*-i*1/2*/+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
- if(mainmenu==6)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4/*-((((float)i)/70)*strlen(menustring[j]))*3*/,starty[j]/*-i*1/2*/+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
- if(mainmenu==7&&(j!=0||!entername)) text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4,starty[j]+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
- if(mainmenu==8)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4/*-((((float)i)/70)*strlen(menustring[j]))*3*/,starty[j]/*-i*1/2*/+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
- if(mainmenu==9)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4/*-((((float)i)/70)*strlen(menustring[j]))*3*/,starty[j]/*-i*1/2*/+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
- if(mainmenu==11)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4/*-((((float)i)/70)*strlen(menustring[j]))*3*/,starty[j]/*-i*1/2*/+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
- if(mainmenu==10)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4/*-((((float)i)/70)*strlen(menustring[j]))*3*/,starty[j]/*-i*1/2*/+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
- if(mainmenu==17)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4/*-((((float)i)/70)*strlen(menustring[j]))*3*/,starty[j]/*-i*1/2*/+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
- if(mainmenu==13&&j!=1)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4/*-((((float)i)/70)*strlen(menustring[j]))*3*/,starty[j]/*-i*1/2*/+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
- if(mainmenu==18)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4/*-((((float)i)/70)*strlen(menustring[j]))*3*/,starty[j]/*-i*1/2*/+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
- /*else{
- if(displayblink){
- sprintf (string, "_");
- text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4+(float)(displayselected)*10*(1+((float)i)/70),starty[j]+offsety[j]*((float)i)/4,string,0,1+((float)i)/70,640,480);
- }
- k=0;
- for(l=0;l<displaychars[k];l++){
- if(l<displaychars[k]){
- sprintf (string, "%c",displaytext[k][l]);
- text.glPrint(startx[j]-((float)k)+offsetx[j]*((float)k)/4+l*10*(1+((float)i)/70),starty[j]+offsety[j]*((float)i)/4,string,0,1+((float)i)/70,640,480);
- }
- }
- }*/
- }
- }
- }
- else
- {
- glClear(GL_DEPTH_BUFFER_BIT);
- glEnable(GL_ALPHA_TEST);
- glAlphaFunc(GL_GREATER, 0.001f);
- glEnable(GL_TEXTURE_2D);
- glDisable(GL_DEPTH_TEST); // Disables Depth Testing
- glDisable(GL_CULL_FACE);
- glDisable(GL_LIGHTING);
- if(j==6)glColor4f(1,1,1,1);
- else glColor4f(1,0,0,1);
-
- glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
- glPushMatrix(); // Store The Projection Matrix
- glLoadIdentity(); // Reset The Projection Matrix
- glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
- glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
- glPushMatrix(); // Store The Modelview Matrix
- glLoadIdentity(); // Reset The Modelview Matrix
- glPushMatrix();
-
- //Draw world, draw map
- glTranslatef(2,-5,0);
-
- if(j>6&&j<nummenuitems-1)
- {
- XYZ linestart,lineend,offset;
- XYZ fac;
- float startsize;
- float endsize;
- linestart=0;
- lineend=0;
- offset=0;
- //float linestartx,lineendx,linestarty,lineendy,offsetx,offsety;
- linestart.x=(startx[j]+endx[j])/2;
- linestart.y=(starty[j]+endy[j])/2;
- if(j>=6+accountactive->getCampaignChoicesMade()){
- linestart.x=(startx[6+accountactive->getCampaignChoicesMade()]+endx[6+accountactive->getCampaignChoicesMade()])/2;
- linestart.y=(starty[6+accountactive->getCampaignChoicesMade()]+endy[6+accountactive->getCampaignChoicesMade()])/2;
- }
- lineend.x=(startx[j+1]+endx[j+1])/2;
- lineend.y=(starty[j+1]+endy[j+1])/2;
- offset=lineend-linestart;
- fac=offset;
- Normalise(&fac);
- offset=DoRotation(offset,0,0,90);
- Normalise(&offset);
- glDisable(GL_TEXTURE_2D);
-
- if(j<6+accountactive->getCampaignChoicesMade()){
- glColor4f(0.5,0,0,1);
- startsize=.5;
- endsize=.5;
- }
- if(j>=6+accountactive->getCampaignChoicesMade()){
- glColor4f(1,0,0,1);
- endsize=1;
- startsize=.5;
- }
-
- linestart+=fac*4*startsize;
- lineend-=fac*4*endsize;
-
- if(!(j>7+accountactive->getCampaignChoicesMade()+campaignchoicenum)){
- glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
- glPushMatrix();
- glBegin(GL_QUADS);
- glTexCoord2f(0,0);
- glVertex3f(linestart.x-offset.x*startsize, linestart.y-offset.y*startsize, 0.0f);
- glTexCoord2f(1,0);
- glVertex3f(linestart.x+offset.x*startsize, linestart.y+offset.y*startsize, 0.0f);
- glTexCoord2f(1,1);
- glVertex3f(lineend.x+offset.x*endsize, lineend.y+offset.y*endsize, 0.0f);
- glTexCoord2f(0,1);
- glVertex3f(lineend.x-offset.x*endsize, lineend.y-offset.y*endsize, 0.0f);
- glEnd();
- glPopMatrix();
- }
- glEnable(GL_TEXTURE_2D);
- }
-
-
- if(j==6)glBindTexture( GL_TEXTURE_2D, Mainmenuitems[7]);
- else glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
- glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
- glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
- if(j-7<accountactive->getCampaignChoicesMade())glColor4f(0.5,0,0,1);
- if(j-7>=accountactive->getCampaignChoicesMade())glColor4f(1,0,0,1);
- if(j==6)glColor4f(1,1,1,1);
- XYZ midpoint;
- float itemsize;
- itemsize=abs(startx[j]-endx[j])/2;
- midpoint=0;
- midpoint.x=(startx[j]+endx[j])/2;
- midpoint.y=(starty[j]+endy[j])/2;
- if(j>6&&(j-7<accountactive->getCampaignChoicesMade()))itemsize*=.5;
- if(!(j-7>accountactive->getCampaignChoicesMade()+campaignchoicenum))
- {
- glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
- glPushMatrix();
- glBegin(GL_QUADS);
- glTexCoord2f(0,0);
- glVertex3f(midpoint.x-itemsize+movex[j]*transition, midpoint.y-itemsize+movey[j]*transition, 0.0f);
- glTexCoord2f(1,0);
- glVertex3f(midpoint.x+itemsize+movex[j]*transition, midpoint.y-itemsize+movey[j]*transition, 0.0f);
- glTexCoord2f(1,1);
- glVertex3f(midpoint.x+itemsize+movex[j]*transition, midpoint.y+itemsize+movey[j]*transition, 0.0f);
- glTexCoord2f(0,1);
- glVertex3f(midpoint.x-itemsize+movex[j]*transition, midpoint.y+itemsize+movey[j]*transition, 0.0f);
- glEnd();
- glPopMatrix();
- glEnable(GL_BLEND);
- //glDisable(GL_ALPHA_TEST);
- if(j<4)glBlendFunc(GL_SRC_ALPHA,GL_ONE);
- for(i=0;i<10;i++)
- {
- if(1-((float)i)/10-(1-selectedlong[j])>0)
- {
- glColor4f(1,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
- glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
- glPushMatrix();
- glBegin(GL_QUADS);
- glTexCoord2f(0,0);
- glVertex3f(midpoint.x-itemsize-((float)i)*1/2+offsetx[j]*((float)i)/2+movex[j]*transition, midpoint.y-itemsize-((float)i)*1/2+offsety[j]*((float)i)/2+movey[j]*transition, 0.0f);
- glTexCoord2f(1,0);
- glVertex3f(midpoint.x+itemsize+((float)i)*1/2+offsetx[j]*((float)i)/2+movex[j]*transition, midpoint.y-itemsize-((float)i)*1/2+offsety[j]*((float)i)/2+movey[j]*transition, 0.0f);
- glTexCoord2f(1,1);
- glVertex3f(midpoint.x+itemsize+((float)i)*1/2+offsetx[j]*((float)i)/2+movex[j]*transition, midpoint.y+itemsize+((float)i)*1/2+offsety[j]*((float)i)/2+movey[j]*transition, 0.0f);
- glTexCoord2f(0,1);
- glVertex3f(midpoint.x-itemsize-((float)i)*1/2+offsetx[j]*((float)i)/2+movex[j]*transition, midpoint.y+itemsize+((float)i)*1/2+offsety[j]*((float)i)/2+movey[j]*transition, 0.0f);
- glEnd();
- glPopMatrix();
- }
- }
- }
- glPopMatrix();
- glPopMatrix();
- glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
- glPopMatrix();
- glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
+ glPopMatrix();
+ glPopMatrix();
+ glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
+ glPopMatrix();
+ glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
- if(j-7>=accountactive->getCampaignChoicesMade()){
- //glColor4f(0,0,0,1);
- //text.glPrintOutline(startx[j]+10-1.5,starty[j]-4-1.5,menustring[j],0,0.6*1.25,640,480);
- //glColor4f(1,0,0,1);
- //text.glPrint(startx[j]+10,starty[j]-4,menustring[j],0,0.6,640,480);
- text.glPrintOutlined(0.9,0,0,startx[j]+10,starty[j]-4,menustring[j],0,0.6,640,480);
- glDisable(GL_DEPTH_TEST);
- }
- }
- }
- }
- }
+ if(j-7>=accountactive->getCampaignChoicesMade()){
+ text.glPrintOutlined(0.9,0,0,startx[j]+10,starty[j]-4,menustring[j],0,0.6,640,480);
+ glDisable(GL_DEPTH_TEST);
}
- glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
- glPopMatrix();
+ }
+ }
+ }
+ }
+ glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
+ glPopMatrix();
+ glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
+ glPopMatrix();
+
+ if(mainmenu==1||mainmenu==2)
+ if(transition<.1||transition>.9){
+ glClear(GL_DEPTH_BUFFER_BIT);
+ glEnable(GL_ALPHA_TEST);
+ glAlphaFunc(GL_GREATER, 0.001f);
+ glEnable(GL_TEXTURE_2D);
+ glDisable(GL_DEPTH_TEST); // Disables Depth Testing
+ glDisable(GL_CULL_FACE);
+ glDisable(GL_LIGHTING);
+ glDepthMask(0);
+ glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
+ glPushMatrix(); // Store The Projection Matrix
+ glLoadIdentity(); // Reset The Projection Matrix
+ glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
+ glPushMatrix(); // Store The Modelview Matrix
+ glLoadIdentity(); // Reset The Modelview Matrix
+ glPushMatrix();
+ glDisable(GL_TEXTURE_2D);
+ if(transition<.1)
+ glColor4f(1,0,0,1-(transition*10));
+ if(transition>.9)
+ glColor4f(1,0,0,1-((1-transition)*10));
+ glPopMatrix();
glPopMatrix();
+ glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
+ glPopMatrix();
+ }
- if(mainmenu==1||mainmenu==2)
- if(transition<.1||transition>.9){
- glClear(GL_DEPTH_BUFFER_BIT);
- glEnable(GL_ALPHA_TEST);
- glAlphaFunc(GL_GREATER, 0.001f);
- glEnable(GL_TEXTURE_2D);
- glDisable(GL_DEPTH_TEST); // Disables Depth Testing
- glDisable(GL_CULL_FACE);
- glDisable(GL_LIGHTING);
- glDepthMask(0);
- glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
- glPushMatrix(); // Store The Projection Matrix
- glLoadIdentity(); // Reset The Projection Matrix
- glOrtho(0,640,0,480,-100,100); // Set Up An Ortho Screen
- glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
- glPushMatrix(); // Store The Modelview Matrix
- glLoadIdentity(); // Reset The Modelview Matrix
- glPushMatrix();
- glDisable(GL_TEXTURE_2D);
- if(transition<.1)glColor4f(1,0,0,1-(transition*10));
- if(transition>.9)glColor4f(1,0,0,1-((1-transition)*10));
- /*glPushMatrix();
- glBegin(GL_QUADS);
- glTexCoord2f(0,0);
- glVertex3f(190, 150, 0.0f);
- glTexCoord2f(1,0);
- glVertex3f(640, 150, 0.0f);
- glTexCoord2f(1,1);
- glVertex3f(640, 336, 0.0f);
- glTexCoord2f(0,1);
- glVertex3f(190, 336, 0.0f);
- glEnd();
- glPopMatrix();*/
- glPopMatrix();
- glPopMatrix();
- glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
- glPopMatrix();
- }
-
- glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
- glPushMatrix(); // Store The Projection Matrix
- glLoadIdentity(); // Reset The Projection Matrix
- glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
- glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
- glPushMatrix(); // Store The Modelview Matrix
- glLoadIdentity(); // Reset The Modelview Matrix
- glTranslatef(screenwidth/2,screenheight/2,0);
- glPushMatrix();
- glScalef((float)screenwidth/2,(float)screenheight/2,1);
- glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
- glEnable(GL_BLEND);
- glEnable(GL_TEXTURE_2D);
- glColor4f(1,1,1,1);
- glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
- glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
- glPopMatrix();
- if(!waiting) { // hide the cursor while waiting for a key
- glPushMatrix();
- glTranslatef(mousecoordh-screenwidth/2,mousecoordv*-1+screenheight/2,0);
- glScalef((float)screenwidth/64,(float)screenwidth/64,1);
- glTranslatef(1,-1,0);
- glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
- glColor4f(1,1,1,1);
- glBindTexture( GL_TEXTURE_2D, cursortexture);
- glPushMatrix();
- //glScalef(.25,.25,.25);
- glBegin(GL_QUADS);
- glTexCoord2f(0,0);
- glVertex3f(-1, -1, 0.0f);
- glTexCoord2f(1,0);
- glVertex3f(1, -1, 0.0f);
- glTexCoord2f(1,1);
- glVertex3f(1, 1, 0.0f);
- glTexCoord2f(0,1);
- glVertex3f(-1, 1, 0.0f);
- glEnd();
- glPopMatrix();
- glPopMatrix();
- }
- glPopMatrix();
- glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
- glPopMatrix();
+ glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
+ glPushMatrix(); // Store The Projection Matrix
+ glLoadIdentity(); // Reset The Projection Matrix
+ glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
+ glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
+ glPushMatrix(); // Store The Modelview Matrix
+ glLoadIdentity(); // Reset The Modelview Matrix
+ glTranslatef(screenwidth/2,screenheight/2,0);
+ glPushMatrix();
+ glScalef((float)screenwidth/2,(float)screenheight/2,1);
+ glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
+ glEnable(GL_BLEND);
+ glEnable(GL_TEXTURE_2D);
+ glColor4f(1,1,1,1);
+ glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
+ glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
+ glPopMatrix();
+ if(!waiting) { // hide the cursor while waiting for a key
+ glPushMatrix();
+ glTranslatef(mousecoordh-screenwidth/2,mousecoordv*-1+screenheight/2,0);
+ glScalef((float)screenwidth/64,(float)screenwidth/64,1);
+ glTranslatef(1,-1,0);
+ glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
+ glColor4f(1,1,1,1);
+ glBindTexture( GL_TEXTURE_2D, cursortexture);
+ glPushMatrix();
+ //glScalef(.25,.25,.25);
+ glBegin(GL_QUADS);
+ glTexCoord2f(0,0);
+ glVertex3f(-1, -1, 0.0f);
+ glTexCoord2f(1,0);
+ glVertex3f(1, -1, 0.0f);
+ glTexCoord2f(1,1);
+ glVertex3f(1, 1, 0.0f);
+ glTexCoord2f(0,1);
+ glVertex3f(-1, 1, 0.0f);
+ glEnd();
+ glPopMatrix();
+ glPopMatrix();
+ }
+ glPopMatrix();
+ glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
+ glPopMatrix();
- if(flashamount>0)
- {
- //printf("Flash amount: %f, delay %i\n", flashamount, flashdelay);
- if(flashamount>1)flashamount=1;
- if(flashdelay<=0)flashamount-=multiplier;
- flashdelay--;
- if(flashamount<0)flashamount=0;
- glDisable(GL_DEPTH_TEST); // Disables Depth Testing
- glDisable(GL_CULL_FACE);
- glDisable(GL_LIGHTING);
- glDisable(GL_TEXTURE_2D);
- glDepthMask(0);
- glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
- glPushMatrix(); // Store The Projection Matrix
- glLoadIdentity(); // Reset The Projection Matrix
- glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
- glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
- glPushMatrix(); // Store The Modelview Matrix
- glLoadIdentity(); // Reset The Modelview Matrix
- glScalef(screenwidth,screenheight,1);
- glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
- glEnable(GL_BLEND);
- glColor4f(flashr,flashg,flashb,flashamount);
- glBegin(GL_QUADS);
- glVertex3f(0, 0, 0.0f);
- glVertex3f(256, 0, 0.0f);
- glVertex3f(256, 256, 0.0f);
- glVertex3f(0, 256, 0.0f);
- glEnd();
- glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
- glPopMatrix(); // Restore The Old Projection Matrix
- glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
- glPopMatrix(); // Restore The Old Projection Matrix
- glEnable(GL_DEPTH_TEST); // Enables Depth Testing
- glEnable(GL_CULL_FACE);
- glDisable(GL_BLEND);
- glDepthMask(1);
- }
+ if(flashamount>0)
+ {
+ //printf("Flash amount: %f, delay %i\n", flashamount, flashdelay);
+ if(flashamount>1)flashamount=1;
+ if(flashdelay<=0)flashamount-=multiplier;
+ flashdelay--;
+ if(flashamount<0)flashamount=0;
+ glDisable(GL_DEPTH_TEST); // Disables Depth Testing
+ glDisable(GL_CULL_FACE);
+ glDisable(GL_LIGHTING);
+ glDisable(GL_TEXTURE_2D);
+ glDepthMask(0);
+ glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
+ glPushMatrix(); // Store The Projection Matrix
+ glLoadIdentity(); // Reset The Projection Matrix
+ glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
+ glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
+ glPushMatrix(); // Store The Modelview Matrix
+ glLoadIdentity(); // Reset The Modelview Matrix
+ glScalef(screenwidth,screenheight,1);
+ glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
+ glEnable(GL_BLEND);
+ glColor4f(flashr,flashg,flashb,flashamount);
+ glBegin(GL_QUADS);
+ glVertex3f(0, 0, 0.0f);
+ glVertex3f(256, 0, 0.0f);
+ glVertex3f(256, 256, 0.0f);
+ glVertex3f(0, 256, 0.0f);
+ glEnd();
+ glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
+ glPopMatrix(); // Restore The Old Projection Matrix
+ glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
+ glPopMatrix(); // Restore The Old Projection Matrix
+ glEnable(GL_DEPTH_TEST); // Enables Depth Testing
+ glEnable(GL_CULL_FACE);
+ glDisable(GL_BLEND);
+ glDepthMask(1);
+ }
}
if(freeze||winfreeze||(mainmenu&&gameon)||(!gameon&&gamestarted)||(!gameon&&gamestarted)){
extern OPENAL_SAMPLE *samp[100];
extern int channels[100];
extern Terrain terrain;
-extern Sprites sprites;
+//extern Sprites sprites;
extern int kTextureSize;
extern float texdetail;
extern float realtexdetail;
glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
- if(!*textureid)glGenTextures( 1, textureid );
+ if(!*textureid)
+ glGenTextures( 1, textureid );
glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
glBindTexture( GL_TEXTURE_2D, *textureid);
if(trilinear)if(mipmap)glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
if(!trilinear)if(mipmap)glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST );
if(!mipmap)glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
-
- //glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texture.sizeX, texture.sizeY, 0,
- // GL_BGRA_EXT, GL_UNSIGNED_INT_8_8_8_8_REV, texture.data);
-
- //gluBuild2DMipmaps( GL_TEXTURE_2D, type, texture.sizeX, texture.sizeY, GL_BGRA_EXT, GL_UNSIGNED_INT_8_8_8_8_REV, texture.data );
-
+
gluBuild2DMipmaps( GL_TEXTURE_2D, type, texture.sizeX, texture.sizeY, type, GL_UNSIGNED_BYTE, texture.data );
-
-// textures.insert(std::make_pair(fname, *textureid));
}
-// else
-// {
-// *textureid = it->second;
-// }
}
void Game::LoadTextureSave(const char *fileName, GLuint *textureid,int mipmap,GLubyte *array, int *skinsize)
LoadTexture(":Data:Textures:bodyprint.png",&terrain.bodyprinttexture,0,1);
- /*LoadTexture(":Data:Textures:cloud.png",&sprites.cloudtexture,1);
+ /*LoadTexture(":Data:Textures:cloud.png",&Sprite::cloudtexture,1);
- LoadTexture(":Data:Textures:cloudimpact.png",&sprites.cloudimpacttexture,1);
+ LoadTexture(":Data:Textures:cloudimpact.png",&Sprite::cloudimpacttexture,1);
- LoadTexture(":Data:Textures:bloodparticle.png",&sprites.bloodtexture,1);
+ LoadTexture(":Data:Textures:bloodparticle.png",&Sprite::bloodtexture,1);
- LoadTexture(":Data:Textures:snowflake.png",&sprites.snowflaketexture,1);
+ LoadTexture(":Data:Textures:snowflake.png",&Sprite::snowflaketexture,1);
- LoadTexture(":Data:Textures:flame.png",&sprites.flametexture,1);
+ LoadTexture(":Data:Textures:flame.png",&Sprite::flametexture,1);
- LoadTexture(":Data:Textures:smoke.png",&sprites.smoketexture,1);
+ LoadTexture(":Data:Textures:smoke.png",&Sprite::smoketexture,1);
//texdetail=temptexdetail;
- LoadTexture(":Data:Textures:shine.png",&sprites.shinetexture,1);*/
+ LoadTexture(":Data:Textures:shine.png",&Sprite::shinetexture,1);*/
//LoadTexture(":Data:Textures:box.jpg",&objects.boxtextureptr,1,0);
- LoadTexture(":Data:Textures:cloud.png",&sprites.cloudtexture,1,1);
- LoadTexture(":Data:Textures:cloudimpact.png",&sprites.cloudimpacttexture,1,1);
- LoadTexture(":Data:Textures:bloodparticle.png",&sprites.bloodtexture,1,1);
- LoadTexture(":Data:Textures:snowflake.png",&sprites.snowflaketexture,1,1);
- LoadTexture(":Data:Textures:flame.png",&sprites.flametexture,1,1);
- LoadTexture(":Data:Textures:bloodflame.png",&sprites.bloodflametexture,1,1);
- LoadTexture(":Data:Textures:smoke.png",&sprites.smoketexture,1,1);
- LoadTexture(":Data:Textures:shine.png",&sprites.shinetexture,1,0);
- LoadTexture(":Data:Textures:splinter.png",&sprites.splintertexture,1,1);
- LoadTexture(":Data:Textures:leaf.png",&sprites.leaftexture,1,1);
- LoadTexture(":Data:Textures:tooth.png",&sprites.toothtexture,1,1);
+ LoadTexture(":Data:Textures:cloud.png",&Sprite::cloudtexture,1,1);
+ LoadTexture(":Data:Textures:cloudimpact.png",&Sprite::cloudimpacttexture,1,1);
+ LoadTexture(":Data:Textures:bloodparticle.png",&Sprite::bloodtexture,1,1);
+ LoadTexture(":Data:Textures:snowflake.png",&Sprite::snowflaketexture,1,1);
+ LoadTexture(":Data:Textures:flame.png",&Sprite::flametexture,1,1);
+ LoadTexture(":Data:Textures:bloodflame.png",&Sprite::bloodflametexture,1,1);
+ LoadTexture(":Data:Textures:smoke.png",&Sprite::smoketexture,1,1);
+ LoadTexture(":Data:Textures:shine.png",&Sprite::shinetexture,1,0);
+ LoadTexture(":Data:Textures:splinter.png",&Sprite::splintertexture,1,1);
+ LoadTexture(":Data:Textures:leaf.png",&Sprite::leaftexture,1,1);
+ LoadTexture(":Data:Textures:tooth.png",&Sprite::toothtexture,1,1);
rotation=0;
rotation2=0;
extern Terrain terrain;
extern OPENAL_SAMPLE *samp[100];
extern int channels[100];
-extern Sprites sprites;
extern int kTextureSize;
extern float screenwidth,screenheight;
extern float gravity;
}
/********************> Tick() <*****/
-extern void ScreenShot(const char * fname);
+extern bool save_image(const char * fname);
void Screenshot (void)
{
char temp[1024];
#else
mkdir("Screenshots", S_IRWXU);
#endif
-
- ScreenShot(temp);
+
+ save_image(temp);
}
whichlevel=which;
}
-/*char * Game::MD5_string (unsigned char *string){
-char temp[50];
-char temp2[100];
-
-strcpy(temp2,(const char *)string);
-strcat((char *)temp2,(const char *)"Lugaru");
-sprintf (temp, "%d",strlen((char *)temp2));
-strcat((char *)temp2,temp);
-
-MD5 context;
-unsigned int len = strlen ( (char *)temp2);
-
-context.update ((unsigned char *)temp2, len);
-context.finalize ();
-
-return context.hex_digest();
-}*/
-
-
-
void Game::Loadlevel(char *name){
int i,j,k,l,m;
static int oldlevel;
if(!stealthloading)
{
terrain.numdecals=0;
- sprites.numsprites=0;
+ Sprite::deleteSprites();
for(i=0;i<objects.numobjects;i++)
{
objects.model[i].numdecals=0;
hotspotsprite=DoRotation(hotspotsprite,0,0,Random()%360);
hotspotsprite=DoRotation(hotspotsprite,0,Random()%360,0);
hotspotsprite+=hotspot[i];
- sprites.MakeSprite(breathsprite, hotspotsprite, hotspotsprite*0, 1,0.5,0, 7, 0.4);
+ Sprite::MakeSprite(breathsprite, hotspotsprite, hotspotsprite*0, 1,0.5,0, 7, 0.4);
hotspotvisual[i]+=0.1/hotspotsize[i]/hotspotsize[i]/hotspotsize[i];
}
}
if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2;
if(!player[1].skeleton.free)temp=DoRotation(DoRotation(DoRotation(player[1].skeleton.joints[i].position,0,0,player[1].tilt),player[1].tilt2,0,0),0,player[1].rotation,0)*player[1].scale+player[1].coords;
if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords;
- sprites.MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
+ Sprite::MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
}
}
if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2;
if(!player[1].skeleton.free)temp=DoRotation(DoRotation(DoRotation(player[1].skeleton.joints[i].position,0,0,player[1].tilt),player[1].tilt2,0,0),0,player[1].rotation,0)*player[1].scale+player[1].coords;
if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords;
- sprites.MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
+ Sprite::MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
}
}
footpoint.y+=((float)abs(Random()%1200))/100-6;
footpoint.x+=((float)abs(Random()%1200))/100-6;
footpoint.z+=((float)abs(Random()%1200))/100-6;
- sprites.MakeSprite(snowsprite, footpoint,footvel, 1,1,1, .1, 1);
+ Sprite::MakeSprite(snowsprite, footpoint,footvel, 1,1,1, .1, 1);
}
}
for(k=0;k<numplayers;k++){
flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
headspurtdirection=player[closest].skeleton.joints[player[closest].skeleton.jointlabels[head]].position-player[closest].skeleton.joints[player[closest].skeleton.jointlabels[neck]].position;
Normalise(&headspurtdirection);
- sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, .6, 1);
+ Sprite::MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, .6, 1);
flatvelocity2+=headspurtdirection*8;
- sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2/2, 1,1,1, .16, 1);
+ Sprite::MakeSprite(bloodsprite, flatfacing2,flatvelocity2/2, 1,1,1, .16, 1);
}
- sprites.MakeSprite(cloudsprite, flatfacing2,flatvelocity2*0, .6,0,0, 1, .5);
+ Sprite::MakeSprite(cloudsprite, flatfacing2,flatvelocity2*0, .6,0,0, 1, .5);
float gLoc[3];
float vel[3];
flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
- sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, 3, 1);
- sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2, 1,1,1, .3, 1);
- sprites.MakeSprite(cloudsprite, flatfacing2,flatvelocity2*0, .6,0,0, 1, .5);
+ Sprite::MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, 3, 1);
+ Sprite::MakeSprite(bloodsprite, flatfacing2,flatvelocity2, 1,1,1, .3, 1);
+ Sprite::MakeSprite(cloudsprite, flatfacing2,flatvelocity2*0, .6,0,0, 1, .5);
}
for(i=0;i<player[closest].skeleton.num_joints; i++){
flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
- sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, 3, 1);
- sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2, 1,1,1, .4, 1);
+ Sprite::MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, 3, 1);
+ Sprite::MakeSprite(bloodsprite, flatfacing2,flatvelocity2, 1,1,1, .4, 1);
}
for(i=0;i<player[closest].skeleton.num_joints; i++){
flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
- sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2*2, 1,1,1, 3, 1);
- sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2*2, 1,1,1, .4, 1);
+ Sprite::MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2*2, 1,1,1, 3, 1);
+ Sprite::MakeSprite(bloodsprite, flatfacing2,flatvelocity2*2, 1,1,1, .4, 1);
}
for(i=0;i<player[closest].skeleton.num_joints; i++){
flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
- sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2*2, 1,1,1, 3, 1);
- sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2*2, 1,1,1, .4, 1);
+ Sprite::MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2*2, 1,1,1, 3, 1);
+ Sprite::MakeSprite(bloodsprite, flatfacing2,flatvelocity2*2, 1,1,1, .4, 1);
}
XYZ temppos;
else player[i].targetrotation-=90;
}
}
- /*if(findDistancefast(&player[i].coords,&weapons.position[player[i].ally])<3){
- if(abs(Random()%6)){
- player[i].crouchkeydown=1;
- if(!findDistancefast(&player[i].coords,&weapons.position[player[i].ally])<1){
- if(player[i].isRun()){
- player[i].targetframe=0;
- player[i].target=0;
- player[i].targetanimation=sneakanim;
- }
- }
- else player[i].forwardkeydown=0;
- }
- else player[i].crouchkeydown=0;
- }
- else player[i].crouchkeydown=0;*/
}
player[i].leftkeydown=0;
footpoint=weapons.position[k];
if(player[i].victim->weaponstuck!=-1){
if(player[i].victim->weaponids[player[i].victim->weaponstuck]==k){
- if(bloodtoggle)sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3);
+ if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3);
weapons.bloody[k]=2;
weapons.blooddrip[k]=5;
player[i].victim->weaponstuck=-1;
objects.DoStuff();
- if(numenvsounds!=0)
- for(j=numenvsounds-1;j>=0;j--){
- envsoundlife[j]-=multiplier;
- if(envsoundlife[j]<0){
- numenvsounds--;
- envsoundlife[j]=envsoundlife[numenvsounds];
- envsound[j]=envsound[numenvsounds];
- }
+ for(j=numenvsounds-1;j>=0;j--){
+ envsoundlife[j]-=multiplier;
+ if(envsoundlife[j]<0){
+ numenvsounds--;
+ envsoundlife[j]=envsoundlife[numenvsounds];
+ envsound[j]=envsound[numenvsounds];
}
- if(!slomo)OPENAL_SetFrequency(OPENAL_ALL, 22050);
- if(slomo)OPENAL_SetFrequency(OPENAL_ALL, slomofreq);
-
- if(tutoriallevel==1){
- XYZ temp;
- XYZ temp2;
- XYZ temp3;
- XYZ oldtemp;
- XYZ oldtemp2;
- temp.x=1011;
- temp.y=84;
- temp.z=491;
- temp2.x=1025;
- temp2.y=75;
- temp2.z=447;
- temp3.x=1038;
- temp3.y=76;
- temp3.z=453;
- oldtemp=temp;
- oldtemp2=temp2;
- if(tutorialstage>=51)
+ }
+ if(slomo) OPENAL_SetFrequency(OPENAL_ALL, slomofreq);
+ else OPENAL_SetFrequency(OPENAL_ALL, 22050);
+
+ if(tutoriallevel==1){
+ XYZ temp;
+ XYZ temp2;
+ XYZ temp3;
+ XYZ oldtemp;
+ XYZ oldtemp2;
+ temp.x=1011;
+ temp.y=84;
+ temp.z=491;
+ temp2.x=1025;
+ temp2.y=75;
+ temp2.z=447;
+ temp3.x=1038;
+ temp3.y=76;
+ temp3.z=453;
+ oldtemp=temp;
+ oldtemp2=temp2;
+ if(tutorialstage>=51)
+ if(findDistancefast(&temp,&player[0].coords)>=findDistancefast(&temp,&temp2)-1||findDistancefast(&temp3,&player[0].coords)<4){
+ OPENAL_StopSound(OPENAL_ALL); // hack...OpenAL renderer isn't stopping music after tutorial goes to level menu...
+ OPENAL_SetFrequency(OPENAL_ALL, 0.001);
+
+ PlayStreamEx( stream_music3, strm[stream_music3], NULL, true);
+ OPENAL_SetPaused(channels[stream_music3], false);
+ OPENAL_SetVolume(channels[stream_music3], 256);
+
+ gameon=0;
+ mainmenu=5;
+
+ fireSound();
+
+ flash();
+ }
+ if(tutorialstage<51)
if(findDistancefast(&temp,&player[0].coords)>=findDistancefast(&temp,&temp2)-1||findDistancefast(&temp3,&player[0].coords)<4){
- OPENAL_StopSound(OPENAL_ALL); // hack...OpenAL renderer isn't stopping music after tutorial goes to level menu...
- OPENAL_SetFrequency(OPENAL_ALL, 0.001);
-
- PlayStreamEx( stream_music3, strm[stream_music3], NULL, true);
- OPENAL_SetPaused(channels[stream_music3], false);
- OPENAL_SetVolume(channels[stream_music3], 256);
-
- gameon=0;
- mainmenu=5;
-
- float gLoc[3]={0,0,0};
- float vel[3]={0,0,0};
- OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
+ float gLoc[3];
+ float vel[3];
+ gLoc[0]=player[0].coords.x;
+ gLoc[1]=player[0].coords.y;
+ gLoc[2]=player[0].coords.z;
+ vel[0]=0;
+ vel[1]=0;
+ vel[2]=0;
PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
OPENAL_SetVolume(channels[fireendsound], 256);
OPENAL_SetPaused(channels[fireendsound], false);
- OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
+
+ player[0].coords=(oldtemp+oldtemp2)/2;
flash();
}
- if(tutorialstage<51)
- if(findDistancefast(&temp,&player[0].coords)>=findDistancefast(&temp,&temp2)-1||findDistancefast(&temp3,&player[0].coords)<4){
+ if(tutorialstage>=14&&tutorialstage<50)
+ if(findDistancefast(&temp,&player[1].coords)>=findDistancefast(&temp,&temp2)-1||findDistancefast(&temp3,&player[1].coords)<4){
float gLoc[3];
float vel[3];
- gLoc[0]=player[0].coords.x;
- gLoc[1]=player[0].coords.y;
- gLoc[2]=player[0].coords.z;
+ gLoc[0]=player[1].coords.x;
+ gLoc[1]=player[1].coords.y;
+ gLoc[2]=player[1].coords.z;
vel[0]=0;
vel[1]=0;
vel[2]=0;
OPENAL_SetVolume(channels[fireendsound], 256);
OPENAL_SetPaused(channels[fireendsound], false);
- player[0].coords=(oldtemp+oldtemp2)/2;
-
- flash();
- }
- if(tutorialstage>=14&&tutorialstage<50)
- if(findDistancefast(&temp,&player[1].coords)>=findDistancefast(&temp,&temp2)-1||findDistancefast(&temp3,&player[1].coords)<4){
- float gLoc[3];
- float vel[3];
- gLoc[0]=player[1].coords.x;
- gLoc[1]=player[1].coords.y;
- gLoc[2]=player[1].coords.z;
- vel[0]=0;
- vel[1]=0;
- vel[2]=0;
- PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
- OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
- OPENAL_SetVolume(channels[fireendsound], 256);
- OPENAL_SetPaused(channels[fireendsound], false);
-
- for(int i=0;i<player[1].skeleton.num_joints;i++){
- if(Random()%2==0){
- if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2;
- if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2;
- if(!player[1].skeleton.free)temp=DoRotation(DoRotation(DoRotation(player[1].skeleton.joints[i].position,0,0,player[1].tilt),player[1].tilt2,0,0),0,player[1].rotation,0)*player[1].scale+player[1].coords;
- if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords;
- sprites.MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
- }
+ for(int i=0;i<player[1].skeleton.num_joints;i++){
+ if(Random()%2==0){
+ if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2;
+ if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2;
+ if(!player[1].skeleton.free)temp=DoRotation(DoRotation(DoRotation(player[1].skeleton.joints[i].position,0,0,player[1].tilt),player[1].tilt2,0,0),0,player[1].rotation,0)*player[1].scale+player[1].coords;
+ if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords;
+ Sprite::MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
}
+ }
- player[1].coords=(oldtemp+oldtemp2)/2;
- for(int i=0;i<player[1].skeleton.num_joints;i++){
- player[1].skeleton.joints[i].velocity=0;
- if(Random()%2==0){
- if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2;
- if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2;
- if(!player[1].skeleton.free)temp=DoRotation(DoRotation(DoRotation(player[1].skeleton.joints[i].position,0,0,player[1].tilt),player[1].tilt2,0,0),0,player[1].rotation,0)*player[1].scale+player[1].coords;
- if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords;
- sprites.MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
- }
+ player[1].coords=(oldtemp+oldtemp2)/2;
+ for(int i=0;i<player[1].skeleton.num_joints;i++){
+ player[1].skeleton.joints[i].velocity=0;
+ if(Random()%2==0){
+ if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2;
+ if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2;
+ if(!player[1].skeleton.free)temp=DoRotation(DoRotation(DoRotation(player[1].skeleton.joints[i].position,0,0,player[1].tilt),player[1].tilt2,0,0),0,player[1].rotation,0)*player[1].scale+player[1].coords;
+ if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords;
+ Sprite::MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
}
}
- }
+ }
+ }
- //3d sound
- static float gLoc[3];
- gLoc[0]=viewer.x;
- gLoc[1]=viewer.y;
- gLoc[2]=viewer.z;
- static float vel[3];
- vel[0]=(viewer.x-oldviewer.x)/multiplier;
- vel[1]=(viewer.y-oldviewer.y)/multiplier;
- vel[2]=(viewer.z-oldviewer.z)/multiplier;
+ //3d sound
+ static float gLoc[3];
+ gLoc[0]=viewer.x;
+ gLoc[1]=viewer.y;
+ gLoc[2]=viewer.z;
+ static float vel[3];
+ vel[0]=(viewer.x-oldviewer.x)/multiplier;
+ vel[1]=(viewer.y-oldviewer.y)/multiplier;
+ vel[2]=(viewer.z-oldviewer.z)/multiplier;
- //Set orientation with forward and up vectors
- static XYZ upvector;
- upvector=0;
- upvector.z=-1;
+ //Set orientation with forward and up vectors
+ static XYZ upvector;
+ upvector=0;
+ upvector.z=-1;
- upvector=DoRotation(upvector,-rotation2+90,0,0);
- upvector=DoRotation(upvector,0,0-rotation,0);
+ upvector=DoRotation(upvector,-rotation2+90,0,0);
+ upvector=DoRotation(upvector,0,0-rotation,0);
- facing=0;
- facing.z=-1;
+ facing=0;
+ facing.z=-1;
- facing=DoRotation(facing,-rotation2,0,0);
- facing=DoRotation(facing,0,0-rotation,0);
+ facing=DoRotation(facing,-rotation2,0,0);
+ facing=DoRotation(facing,0,0-rotation,0);
- static float ori[6];
- ori[0] = -facing.x;
- ori[1] = facing.y;
- ori[2] = -facing.z;
- ori[3] = -upvector.x;
- ori[4] = upvector.y;
- ori[5] = -upvector.z;
+ static float ori[6];
+ ori[0] = -facing.x;
+ ori[1] = facing.y;
+ ori[2] = -facing.z;
+ ori[3] = -upvector.x;
+ ori[4] = upvector.y;
+ ori[5] = -upvector.z;
- OPENAL_3D_Listener_SetAttributes(&gLoc[0], &vel[0], ori[0], ori[1], ori[2], ori[3], ori[4], ori[5]);
- OPENAL_Update();
+ OPENAL_3D_Listener_SetAttributes(&gLoc[0], &vel[0], ori[0], ori[1], ori[2], ori[3], ori[4], ori[5]);
+ OPENAL_Update();
- oldviewer=viewer;
+ oldviewer=viewer;
}
}
}
void Game::TickOnce(){
- if(!mainmenu)
- if(directing||indialogue==-1){
+ if(mainmenu)
+ rotation+=multiplier*5;
+ else
+ if(directing||indialogue==-1) {
rotation+=deltah*.7;
if(!invertmouse)rotation2+=deltav*.7;
if(invertmouse)rotation2-=deltav*.7;
if(rotation2>90)rotation2=90;
if(rotation2<-70)rotation2=-70;
}
- if(mainmenu)rotation+=multiplier*5;
}
void Game::TickOnceAfter(){
PlayStreamEx( stream_music3, strm[stream_music3], NULL, true);
OPENAL_SetPaused(channels[stream_music3], false);
}
- }
-
- if(!musictoggle){
- OPENAL_SetPaused(channels[music1], true);
- OPENAL_SetPaused(channels[stream_music2], true);
- OPENAL_SetPaused(channels[stream_music3], true);
-
- for(i=0;i<4;i++){
- oldmusicvolume[i]=0;
- musicvolume[i]=0;
- }
- }
-
- if(musictoggle){
if(musicvolume[0]<=0&&oldmusicvolume[0]>0){
OPENAL_SetPaused(channels[music1], true);
}
for(i=0;i<3;i++){
oldmusicvolume[i]=musicvolume[i];
}
+ } else {
+ OPENAL_SetPaused(channels[music1], true);
+ OPENAL_SetPaused(channels[stream_music2], true);
+ OPENAL_SetPaused(channels[stream_music3], true);
+
+ for(i=0;i<4;i++){
+ oldmusicvolume[i]=0;
+ musicvolume[i]=0;
+ }
}
killhotspot=2;
- if(numhotspots)
- for(i=0;i<numhotspots;i++){
- if(hotspottype[i]>10&&hotspottype[i]<20){
- if(player[hotspottype[i]-10].dead==0){
- killhotspot=0;
- }
- else if(killhotspot==2)
- killhotspot=1;
+ for(i=0;i<numhotspots;i++){
+ if(hotspottype[i]>10&&hotspottype[i]<20){
+ if(player[hotspottype[i]-10].dead==0){
+ killhotspot=0;
}
+ else if(killhotspot==2)
+ killhotspot=1;
}
- if(killhotspot==2)killhotspot=0;
+ }
+ if(killhotspot==2)killhotspot=0;
- winhotspot=0;
- if(numhotspots)
- for(i=0;i<numhotspots;i++){
- if(hotspottype[i]==-1){
- if(findDistancefast(&player[0].coords,&hotspot[i])<hotspotsize[i])
- winhotspot=1;
- }
- }
+ winhotspot=0;
+ for(i=0;i<numhotspots;i++){
+ if(hotspottype[i]==-1){
+ if(findDistancefast(&player[0].coords,&hotspot[i])<hotspotsize[i])
+ winhotspot=1;
+ }
+ }
- int numalarmed=0;
- if(numplayers>1)
- for(i=1;i<numplayers;i++){
- if(!player[i].dead&&player[i].aitype==attacktypecutoff&&player[i].surprised<=0)numalarmed++;
- }
- if(numalarmed>maxalarmed)maxalarmed=numalarmed;
+ int numalarmed=0;
+ for(i=1;i<numplayers;i++){
+ if(!player[i].dead&&player[i].aitype==attacktypecutoff&&player[i].surprised<=0)numalarmed++;
+ }
+ if(numalarmed>maxalarmed)maxalarmed=numalarmed;
- if(changedelay<=0&&!loading&&!editorenabled&&gameon&&!tutoriallevel&&changedelay!=-999&&!won){
- if(player[0].dead&&changedelay<=0){
- changedelay=1;
- targetlevel=whichlevel;
- }
- alldead=1;
- if(numplayers>1)
- for(i=1;i<numplayers;i++){
- if(!player[i].dead&&player[i].howactive<typedead1)alldead=0;
- }
+ if(changedelay<=0&&!loading&&!editorenabled&&gameon&&!tutoriallevel&&changedelay!=-999&&!won){
+ if(player[0].dead&&changedelay<=0){
+ changedelay=1;
+ targetlevel=whichlevel;
+ }
+ alldead=1;
+ for(i=1;i<numplayers;i++){
+ if(!player[i].dead&&player[i].howactive<typedead1)alldead=0;
+ }
- if(alldead&&!player[0].dead&&maptype==mapkilleveryone){
- changedelay=1;
- targetlevel=whichlevel+1;
- if(targetlevel>numchallengelevels-1)targetlevel=0;
- }
- if(winhotspot||windialogue){
- changedelay=0.1;
- targetlevel=whichlevel+1;
- if(targetlevel>numchallengelevels-1)targetlevel=0;
- }
+ if(alldead&&!player[0].dead&&maptype==mapkilleveryone){
+ changedelay=1;
+ targetlevel=whichlevel+1;
+ if(targetlevel>numchallengelevels-1)targetlevel=0;
+ }
+ if(winhotspot||windialogue){
+ changedelay=0.1;
+ targetlevel=whichlevel+1;
+ if(targetlevel>numchallengelevels-1)targetlevel=0;
+ }
- if(killhotspot){
- changedelay=1;
- targetlevel=whichlevel+1;
- if(targetlevel>numchallengelevels-1)targetlevel=0;
- }
+ if(killhotspot){
+ changedelay=1;
+ targetlevel=whichlevel+1;
+ if(targetlevel>numchallengelevels-1)targetlevel=0;
+ }
- if(changedelay>0&&!player[0].dead&&!won){
- //high scores, awards, win
- if(campaign){
- won=1;
- accountactive->winCampaignLevel(whichchoice, bonustotal, leveltime);
- /*accountcampaignchoices[accountactive][accountactive->getCampaignChoicesMade()]=whichchoice;
- accountactive->getCampaignChoicesMade()++;
- accountcampaignscore[accountactive]+=bonustotal;
- accountcampaigntime[accountactive]+=leveltime;
- if(accountcampaignscore[accountactive]>accountcampaignhighscore[accountactive])
- accountcampaignhighscore[accountactive]=accountcampaignscore[accountactive];*/
- scoreadded=1;
- }
- else
- {
- won=1;
- accountactive->winLevel(whichlevel,bonustotal-startbonustotal,leveltime);
- }
- }
- }
+ if(changedelay>0&&!player[0].dead&&!won){
+ //high scores, awards, win
+ if(campaign){
+ accountactive->winCampaignLevel(whichchoice, bonustotal, leveltime);
+ scoreadded=1;
+ }
+ else
+ {
+ accountactive->winLevel(whichlevel,bonustotal-startbonustotal,leveltime);
+ }
+ won=1;
+ }
+ }
- if(!winfreeze){
+ if(!winfreeze){
- if(leveltime<1){
- loading=0;
- changedelay=.1;
- alldead=0;
- winhotspot=0;
- killhotspot=0;
- }
+ if(leveltime<1){
+ loading=0;
+ changedelay=.1;
+ alldead=0;
+ winhotspot=0;
+ killhotspot=0;
+ }
- if(!editorenabled&&gameon&&!mainmenu){
- if(changedelay!=-999)changedelay-=multiplier/7;
- if(player[0].dead)targetlevel=whichlevel;
- if(loading==2&&!campaign){
- flash();
+ if(!editorenabled&&gameon&&!mainmenu){
+ if(changedelay!=-999)changedelay-=multiplier/7;
+ if(player[0].dead)targetlevel=whichlevel;
+ if(loading==2&&!campaign){
+ flash();
- fireSound(firestartsound);
+ fireSound(firestartsound);
- if(!player[0].dead&&targetlevel!=whichlevel){
- startbonustotal=bonustotal;
- }
- if(!player[0].dead)Loadlevel(targetlevel);
- if(player[0].dead)Loadlevel(whichlevel);
+ if(!player[0].dead&&targetlevel!=whichlevel){
+ startbonustotal=bonustotal;
+ }
+ if(player[0].dead) Loadlevel(whichlevel);
+ else Loadlevel(targetlevel);
- fireSound();
+ fireSound();
- loading=3;
- }
- if(loading==2&&targetlevel==whichlevel){
- flash();
- loadtime=0;
+ loading=3;
+ }
+ if(loading==2&&targetlevel==whichlevel){
+ flash();
+ loadtime=0;
- float gLoc[3]={0,0,0};
- float vel[3]={0,0,0};
- fireSound(firestartsound);
+ fireSound(firestartsound);
- for(i=0;i<255;i++){
- mapname[i]='\0';
- }
- mapname[0]=':';
- mapname[1]='D';
- mapname[2]='a';
- mapname[3]='t';
- mapname[4]='a';
- mapname[5]=':';
- mapname[6]='M';
- mapname[7]='a';
- mapname[8]='p';
- mapname[9]='s';
- mapname[10]=':';
- strcat(mapname,campaignmapname[levelorder[accountactive->getCampaignChoicesMade()]]);//[campaignchoicewhich[whichchoice]]);
- Loadlevel(mapname);
-
- fireSound();
-
- loading=3;
- }
- if(changedelay<=-999&&whichlevel!=-2&&!loading&&(player[0].dead||(alldead&&maptype==mapkilleveryone)||(winhotspot)||(killhotspot))&&!winfreeze)loading=1;
- if((player[0].dead||(alldead&&maptype==mapkilleveryone)||(winhotspot)||(windialogue)||(killhotspot))&&changedelay<=0){
- {
- if(whichlevel!=-2&&!loading&&!player[0].dead){
- winfreeze=1;
- changedelay=-999;
- }
- if(player[0].dead)loading=1;
- }
- }
- }
+ for(i=0;i<255;i++){
+ mapname[i]='\0';
+ }
+ mapname[0]=':';
+ mapname[1]='D';
+ mapname[2]='a';
+ mapname[3]='t';
+ mapname[4]='a';
+ mapname[5]=':';
+ mapname[6]='M';
+ mapname[7]='a';
+ mapname[8]='p';
+ mapname[9]='s';
+ mapname[10]=':';
+ strcat(mapname,campaignmapname[levelorder[accountactive->getCampaignChoicesMade()]]);//[campaignchoicewhich[whichchoice]]);
+ Loadlevel(mapname);
- if(campaign)
- if(mainmenu==0&&winfreeze&&(campaignchoosenext[campaignchoicewhich[whichchoice]])==1){
- if(campaignnumnext[campaignchoicewhich[whichchoice]]==0){
- endgame=1;
- }
- }
- else if(mainmenu==0&&winfreeze){
- if(campaignchoosenext[campaignchoicewhich[whichchoice]]==2)
- stealthloading=1;
- else stealthloading=0;
+ fireSound();
- if(!stealthloading){
- float gLoc[3]={0,0,0};
- float vel[3]={0,0,0};
- fireSound(firestartsound);
+ loading=3;
+ }
+ if(changedelay<=-999&&whichlevel!=-2&&!loading&&(player[0].dead||(alldead&&maptype==mapkilleveryone)||(winhotspot)||(killhotspot))&&!winfreeze)loading=1;
+ if((player[0].dead||(alldead&&maptype==mapkilleveryone)||(winhotspot)||(windialogue)||(killhotspot))&&changedelay<=0){
+ {
+ if(whichlevel!=-2&&!loading&&!player[0].dead){
+ winfreeze=1;
+ changedelay=-999;
+ }
+ if(player[0].dead)loading=1;
+ }
+ }
+ }
- flash();
- }
+ if(campaign)
+ if(mainmenu==0&&winfreeze&&(campaignchoosenext[campaignchoicewhich[whichchoice]])==1){
+ if(campaignnumnext[campaignchoicewhich[whichchoice]]==0){
+ endgame=1;
+ }
+ }
+ else if(mainmenu==0&&winfreeze){
+ if(campaignchoosenext[campaignchoicewhich[whichchoice]]==2)
+ stealthloading=1;
+ else stealthloading=0;
- startbonustotal=0;
-
- ifstream ipstream(ConvertFileName(":Data:Campaigns:main.txt"));
- ipstream.ignore(256,':');
- ipstream >> campaignnumlevels;
- for(i=0;i<campaignnumlevels;i++){
- ipstream.ignore(256,':');
- ipstream.ignore(256,':');
- ipstream.ignore(256,' ');
- ipstream >> campaignmapname[i];
- ipstream.ignore(256,':');
- ipstream >> campaigndescription[i];
- for(j=0;j<256;j++){
- if(campaigndescription[i][j]=='_')campaigndescription[i][j]=' ';
- }
- ipstream.ignore(256,':');
- ipstream >> campaignchoosenext[i];
- ipstream.ignore(256,':');
- ipstream >> campaignnumnext[i];
- if(campaignnumnext[i])
- for(j=0;j<campaignnumnext[i];j++){
- ipstream.ignore(256,':');
- ipstream >> campaignnextlevel[i][j];
- campaignnextlevel[i][j]-=1;
- }
- ipstream.ignore(256,':');
- ipstream >> campaignlocationx[i];
- ipstream.ignore(256,':');
- ipstream >> campaignlocationy[i];
- }
- ipstream.close();
+ if(!stealthloading){
+ float gLoc[3]={0,0,0};
+ float vel[3]={0,0,0};
+ fireSound(firestartsound);
- for(i=0;i<campaignnumlevels;i++){
- levelvisible[i]=0;
- levelhighlight[i]=0;
- }
+ flash();
+ }
+ startbonustotal=0;
+
+ ifstream ipstream(ConvertFileName(":Data:Campaigns:main.txt"));
+ ipstream.ignore(256,':');
+ ipstream >> campaignnumlevels;
+ for(i=0;i<campaignnumlevels;i++){
+ ipstream.ignore(256,':');
+ ipstream.ignore(256,':');
+ ipstream.ignore(256,' ');
+ ipstream >> campaignmapname[i];
+ ipstream.ignore(256,':');
+ ipstream >> campaigndescription[i];
+ for(j=0;j<256;j++){
+ if(campaigndescription[i][j]=='_')campaigndescription[i][j]=' ';
+ }
+ ipstream.ignore(256,':');
+ ipstream >> campaignchoosenext[i];
+ ipstream.ignore(256,':');
+ ipstream >> campaignnumnext[i];
+ for(j=0;j<campaignnumnext[i];j++){
+ ipstream.ignore(256,':');
+ ipstream >> campaignnextlevel[i][j];
+ campaignnextlevel[i][j]-=1;
+ }
+ ipstream.ignore(256,':');
+ ipstream >> campaignlocationx[i];
+ ipstream.ignore(256,':');
+ ipstream >> campaignlocationy[i];
+ }
+ ipstream.close();
- for(i=0;i<campaignnumlevels;i++){
- levelvisible[i]=0;
- levelhighlight[i]=0;
- }
+ for(i=0;i<campaignnumlevels;i++){
+ levelvisible[i]=0;
+ levelhighlight[i]=0;
+ }
- levelorder[0]=0;
- levelvisible[0]=1;
- if(accountactive->getCampaignChoicesMade())
- for(i=0;i<accountactive->getCampaignChoicesMade();i++){
- levelorder[i+1]=campaignnextlevel[levelorder[i]][accountactive->getCampaignChoice(i)];
- levelvisible[levelorder[i+1]]=1;
- }
- int whichlevelstart;
- whichlevelstart=accountactive->getCampaignChoicesMade()-1;
- if(whichlevelstart<0){
- campaignchoicenum=1;
- campaignchoicewhich[0]=0;
- }
- else
- {
- campaignchoicenum=campaignnumnext[levelorder[whichlevelstart]];
- if(campaignchoicenum)
- for(i=0;i<campaignchoicenum;i++){
- campaignchoicewhich[i]=campaignnextlevel[levelorder[whichlevelstart]][i];
- levelvisible[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
- levelhighlight[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
- }
- }
- loading=2;
- loadtime=0;
- targetlevel=7;
- //if(firstload)TickOnceAfter();
- if(!firstload)LoadStuff();
- //else {
- for(i=0;i<255;i++){
- mapname[i]='\0';
- }
- mapname[0]=':';
- mapname[1]='D';
- mapname[2]='a';
- mapname[3]='t';
- mapname[4]='a';
- mapname[5]=':';
- mapname[6]='M';
- mapname[7]='a';
- mapname[8]='p';
- mapname[9]='s';
- mapname[10]=':';
-
- strcat(mapname,campaignmapname[campaignchoicewhich[0]]);
- whichchoice=0;
- visibleloading=1;
- stillloading=1;
- Loadlevel(mapname);
- campaign=1;
- mainmenu=0;
- gameon=1;
- OPENAL_SetPaused(channels[stream_music3], true);
-
- stealthloading=0;
- }
+ for(i=0;i<campaignnumlevels;i++){
+ levelvisible[i]=0;
+ levelhighlight[i]=0;
+ }
- if(loading==3)loading=0;
+ levelorder[0]=0;
+ levelvisible[0]=1;
+ for(i=0;i<accountactive->getCampaignChoicesMade();i++){
+ levelorder[i+1]=campaignnextlevel[levelorder[i]][accountactive->getCampaignChoice(i)];
+ levelvisible[levelorder[i+1]]=1;
+ }
+ int whichlevelstart;
+ whichlevelstart=accountactive->getCampaignChoicesMade()-1;
+ if(whichlevelstart<0){
+ campaignchoicenum=1;
+ campaignchoicewhich[0]=0;
+ }
+ else
+ {
+ campaignchoicenum=campaignnumnext[levelorder[whichlevelstart]];
+ for(i=0;i<campaignchoicenum;i++){
+ campaignchoicewhich[i]=campaignnextlevel[levelorder[whichlevelstart]][i];
+ levelvisible[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
+ levelhighlight[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
+ }
+ }
+ loading=2;
+ loadtime=0;
+ targetlevel=7;
+ //if(firstload)TickOnceAfter();
+ if(!firstload)LoadStuff();
+ //else {
+ for(i=0;i<255;i++){
+ mapname[i]='\0';
}
+ mapname[0]=':';
+ mapname[1]='D';
+ mapname[2]='a';
+ mapname[3]='t';
+ mapname[4]='a';
+ mapname[5]=':';
+ mapname[6]='M';
+ mapname[7]='a';
+ mapname[8]='p';
+ mapname[9]='s';
+ mapname[10]=':';
+
+ strcat(mapname,campaignmapname[campaignchoicewhich[0]]);
+ whichchoice=0;
+ visibleloading=1;
+ stillloading=1;
+ Loadlevel(mapname);
+ campaign=1;
+ mainmenu=0;
+ gameon=1;
+ OPENAL_SetPaused(channels[stream_music3], true);
+
+ stealthloading=0;
+ }
+
+ if(loading==3)loading=0;
+
+ }
- oldmusictype=musictype;
+ oldmusictype=musictype;
}
facing=0;
#include "Lights.h"
#include "Skeleton.h"
#include "Terrain.h"
-#include "Sprites.h"
+#include "Sprite.h"
#include "Frustum.h"
#include "Objects.h"
#include "Weapons.h"
Skeleton testskeleton;
int numsounds = 0;
Terrain terrain;
-Sprites sprites;
float sps = 0;
SDL_Surface *sdlscreen;
+++ /dev/null
-/*
-Copyright (C) 2003, 2010 - Wolfire Games
-
-This file is part of Lugaru.
-
-Lugaru is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-
-See the GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-/*
- * Copyright (c) 1999-2002 Apple Computer, Inc. All rights reserved.
- *
- * @APPLE_LICENSE_HEADER_START@
- *
- * Portions Copyright (c) 1999-2002 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
- *
- * The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
- * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
- * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
- *
- * @APPLE_LICENSE_HEADER_END@
- *
- * Modified: $Date: 2002/04/27 20:52:48 $
- * Revision: $Id: LinkedList.h,v 1.3 2002/04/27 20:52:48 lane Exp $
- */
-
-
-/*
- File: LinkedList.h
-
- Contains:
-
-*/
-
-#ifndef __LINKEDLIST__
-#define __LINKEDLIST__
-
-
-//we cant just use "macintosh_build" - the mac macho_build is designated as "posix_build" but may
-//include open transport in some cases
-#ifndef __OPENTRANSPORT__
-//#if (!macintosh_build)
-
-#include <stddef.h> //for OTGetLinkObject replacement
-
-#include "OPUtils.h" //for true/false
-
-#if (windows_build)
-
-// ECF 010928 win32 syncronization routines for safe critical sections. We can't simply use TryEnterCriticalSection()
-// to return a true/false value because it's not available in win95 and 98
-class OSCriticalSection
-{
- public:
- NMBoolean locked;
- OSCriticalSection() {locked = false; InitializeCriticalSection(&theCriticalSection);}
- ~OSCriticalSection() {DeleteCriticalSection(&theCriticalSection);}
- NMBoolean acquire() { if (locked == true) return false; //dont have to wait in this case
- EnterCriticalSection(&theCriticalSection);
- if (locked) {LeaveCriticalSection(&theCriticalSection); return false;}
- else {locked = true; LeaveCriticalSection(&theCriticalSection); return true;}}
- void release() { EnterCriticalSection(&theCriticalSection);
- locked = false; LeaveCriticalSection(&theCriticalSection);}
-
- CRITICAL_SECTION theCriticalSection;
-};
-#endif //windows_build
-
-#if (posix_build)
-#include <pthread.h>
-class OSCriticalSection
-{
- public:
- OSCriticalSection() {pthread_mutex_init(&theMutex,NULL);}
- ~OSCriticalSection() {pthread_mutex_destroy(&theMutex);}
- NMBoolean acquire() { int error = pthread_mutex_trylock(&theMutex);
- if (error) return false; else return true;}
- void release() { pthread_mutex_unlock(&theMutex);}
-
- pthread_mutex_t theMutex;
-};
-
-#endif //(posix_build)
-
-/* -------------------------------------------------------------------------
- ** OTLIFO
- **
- ** These are functions to implement a LIFO list that is interrupt-safe.
- ** The only function which is not is OTReverseList. Normally, you create
- ** a LIFO list, populate it at interrupt time, and then use OTLIFOStealList
- ** to atomically remove the list, and OTReverseList to flip the list so that
- ** it is a FIFO list, which tends to be more useful.
- ------------------------------------------------------------------------- */
-
- class OTLink;
- class OTLIFO;
-
- class OTLink
- {
- public:
- OTLink* fNext;
- void Init()
- { fNext = NULL; }
- };
-
- class OTLIFO
- {
- public:
- OSCriticalSection theLock;
- OTLink* fHead;
-
- void Init()
- { fHead = NULL; }
-
- void Enqueue(OTLink* link)
- {
- while (true) {if (theLock.acquire()) break;}
- link->fNext = fHead;
- fHead = link;
- theLock.release();
- }
-
-
- OTLink* Dequeue()
- {
- while (true) {if (theLock.acquire()) break;}
- OTLink *origHead = fHead;
- fHead = fHead->fNext;
- theLock.release();
- return origHead;
- }
-
-
- OTLink* StealList()
- {
- while (true) {if (theLock.acquire()) break;}
- OTLink *origHead = fHead;
- fHead = NULL;
- theLock.release();
- return origHead;
- }
-
-
- NMBoolean IsEmpty()
- {
- return fHead == NULL;
- }
- };
-
-/* -------------------------------------------------------------------------
- ** OTList
- **
- ** An OTList is a non-interrupt-safe list, but has more features than the
- ** OTLIFO list. It is a standard singly-linked list.
- ------------------------------------------------------------------------- */
-
- typedef struct OTList OTList;
-
- typedef NMBoolean (*OTListSearchProcPtr)(const void* ref, OTLink* linkToCheck);
- //
- // Remove the last link from the list
- //
- extern OTLink* OTRemoveLast(OTList* pList);
- //
- // Return the first link from the list
- //
- extern OTLink* OTGetFirst(OTList* pList);
- //
- // Return the last link from the list
- //
- extern OTLink* OTGetLast(OTList* pList);
- //
- // Return true if the link is present in the list
- //
- extern NMBoolean OTIsInList(OTList* pList, OTLink* link);
- //
- // Find a link in the list which matches the search criteria
- // established by the search proc and the refPtr. This is done
- // by calling the search proc, passing it the refPtr and each
- // link in the list, until the search proc returns true.
- // NULL is returned if the search proc never returned true.
- //
- extern OTLink* OTFindLink(OTList* pList, OTListSearchProcPtr proc, const void* refPtr);
- //
- // Remove the specified link from the list, returning true if it was found
- //
- extern NMBoolean OTRemoveLink(OTList*, OTLink*);
- //
- // Similar to OTFindLink, but it also removes it from the list.
- //
- extern OTLink* OTFindAndRemoveLink(OTList* pList, OTListSearchProcPtr proc, const void* refPtr);
- //
- // Return the "index"th link in the list
- //
- extern OTLink* OTGetIndexedLink(OTList* pList, size_t index);
-
- struct OTList
- {
- OTLink* fHead;
-
- void Init()
- { fHead = NULL; }
-
- NMBoolean IsEmpty()
- { return fHead == NULL; }
-
- void AddFirst(OTLink* link)
- {
- link->fNext = fHead;
- fHead = link;
- }
-
- void AddLast(OTLink* link)
- {
- if (fHead == NULL)
- fHead = link->fNext;
- else
- {
- OTLink *current = fHead;
-
- while (current->fNext != NULL)
- current = current->fNext;
-
- current->fNext = link;
- }
-
-
- link->fNext = fHead;
- fHead = link;
- }
-
-
- OTLink* GetFirst()
- { return OTGetFirst(this); }
-
- OTLink* GetLast()
- { return OTGetLast(this); }
-
- OTLink* RemoveFirst()
- {
- OTLink *origHead = fHead;
- fHead = fHead->fNext;
- return origHead;
- }
-
- OTLink* RemoveLast()
- { return OTRemoveLast(this); }
-
- NMBoolean IsInList(OTLink* link)
- { return OTIsInList(this, link); }
-
- OTLink* FindLink(OTListSearchProcPtr proc, const void* ref)
- { return OTFindLink(this, proc, ref); }
-
- NMBoolean RemoveLink(OTLink* link)
- { return OTRemoveLink(this, link); }
-
- OTLink* RemoveLink(OTListSearchProcPtr proc, const void* ref)
- { return OTFindAndRemoveLink(this, proc, ref); }
-
- OTLink* GetIndexedLink(size_t index)
- { return OTGetIndexedLink(this, index); }
- };
-
-
-//FIXME!! this is a recursive function and will crash and burn on large lists
-static OTLink* OTReverseList(OTLink *headRef)
-{
- OTLink *first;
- OTLink *rest;
-
- if (headRef == NULL) return NULL;
-
- first = headRef;
- rest = (OTLink *) first->fNext;
-
- if (rest == NULL) return headRef;
-
- rest = OTReverseList(rest);
-
- first->fNext->fNext = first;
- first->fNext = NULL;
-
- return rest;
-}
-
-
- #define OTGetLinkObject(link, struc, field) \
- ((struc*)((char*)(link) - offsetof(struc, field)))
-
-#endif //!macintosh_build
-#endif /* __LINKEDLIST__ */
-
-
char* ConvertFileName( const char* orgfilename, const char *mode = "rb" );
#define fopen( a, b) fopen(ConvertFileName(a, b), b)
-/*
-inline float abs( float f)
-{
-if (f < 0)
-return -f;
-return f;
-}
-inline double abs( double f)
-{
-if (f < 0)
-return -f;
-return f;
-}
-*/
-__forceinline long long longlongabs( long long f)
-{
- if (f < 0)
- return -f;
- return f;
-}
#endif
#endif
extern float windvar;
extern float playerdist;
extern bool skyboxtexture;
-extern Sprites sprites;
//Functions
XYZ spawnpoint;
for(int i=0;i<numobjects;i++){
/*if(type[i]==firetype){
- sprites.MakeSprite(weaponshinesprite, position[i],position[i]*0, 1,1,1, 5, 1);
+ Sprite::MakeSprite(weaponshinesprite, position[i],position[i]*0, 1,1,1, 5, 1);
}*/
if(type[i]==firetype)onfire[i]=1;
spawnpoint.z=0;
spawnpoint=DoRotation(spawnpoint,0,Random()%360,0);
spawnpoint+=position[i];
- sprites.MakeSprite(flamesprite, spawnpoint,spawnpoint*0, 1,1,1, (.6+(float)abs(Random()%100)/200-.25)*5*scale[i], 1);
+ Sprite::MakeSprite(flamesprite, spawnpoint,spawnpoint*0, 1,1,1, (.6+(float)abs(Random()%100)/200-.25)*5*scale[i], 1);
}
if(type[i]==treeleavestype){
spawnpoint.x=((float)(Random()%100))/80*scale[i];
spawnpoint.z=0;
spawnpoint=DoRotation(spawnpoint,0,Random()%360,0);
spawnpoint+=position[i];
- sprites.MakeSprite(flamesprite, spawnpoint,spawnpoint*0, 1,1,1, (.6+(float)abs(Random()%100)/200-.25)*6, 1);
+ Sprite::MakeSprite(flamesprite, spawnpoint,spawnpoint*0, 1,1,1, (.6+(float)abs(Random()%100)/200-.25)*6, 1);
}
}
#include "Lights.h"
#include "Models.h"
#include "Terrain.h"
-#include "Sprites.h"
+#include "Sprite.h"
#include <vector>
//
// Model Structures
static bool load_image(const char * fname, TGAImageRec & tex);
static bool load_png(const char * fname, TGAImageRec & tex);
static bool load_jpg(const char * fname, TGAImageRec & tex);
-static bool save_image(const char * fname);
+bool save_image(const char * fname);
static bool save_png(const char * fname);
extern float realmultiplier;
extern int slomo;
extern bool cellophane;
-// MODIFIED GWC
-//extern int terraindetail;
-//extern int texdetail;
extern float terraindetail;
extern float texdetail;
using namespace std;
-
-
SDL_Rect **resolutions = NULL;
static SDL_Rect rect_1024_768 = { 0, 0, 1024, 768 };
static SDL_Rect rect_800_600 = { 0, 0, 800, 600 };
NULL
};
-
-
-unsigned int resolutionDepths[8][2] = {0};
-
-int closestResolution(int width, int height);
-int resolutionID(int width, int height);
-
-void ReportError (char * strError);
-
void DrawGL(Game & game);
-void CreateGLWindow (void);
Boolean SetUp (Game & game);
void DoUpdate (Game & game);
-void DoEvent (void);
void CleanUp (void);
-
// statics/globals (internal only) ------------------------------------------
-#ifndef WIN32
-typedef struct tagPOINT {
- int x;
- int y;
-} POINT, *PPOINT;
-#endif
-
-
#ifdef _MSC_VER
#pragma warning(push)
// no-op.
}
-
-
-void sdlGetCursorPos(POINT *pt)
-{
- SDL_GetMouseState(&(pt->x), &(pt->y));
-}
-#define GetCursorPos(x) sdlGetCursorPos(x)
-#define SetCursorPos(x, y) SDL_WarpMouse(x, y)
-#define ScreenToClient(x, pt)
-#define ClientToScreen(x, pt)
#ifdef MessageBox
#undef MessageBox
#endif
#define MessageBox(hwnd,text,title,flags) STUBBED("msgbox")
-
-Point delta;
-
-static bool g_button, fullscreen = true;
-
-
// Menu defs
-enum
-{
- kFileQuit = 1
-};
-
-enum
-{
- kForegroundSleep = 10,
- kBackgroundSleep = 10000
-};
-
int kContextWidth;
int kContextHeight;
-const RGBColor rgbBlack = { 0x0000, 0x0000, 0x0000 };
-
-GLuint gFontList;
-char gcstrMode [256] = "";
-
-UInt32 gSleepTime = kForegroundSleep;
-Boolean gDone = false, gfFrontProcess = true;
+Boolean gDone = false;
Game * pgame = 0;
return false;
}
-
-// --------------------------------------------------------------------------
-
-void ReportError (char * strError)
-{
-#ifdef _MSC_VER // !!! FIXME. --ryan.
- throw std::exception( strError);
-#endif
-
- /* char errMsgCStr [256];
- Str255 strErr;
-
- sprintf (errMsgCStr, "%s", strError);
-
- // out as debug string
- CToPStr (strErr, errMsgCStr);
- DebugStr (strErr);
- */
-}
-
//-----------------------------------------------------------------------------------------------------------------------
// OpenGL Drawing
-void DrawGL (Game & game)
-{
- if ( stereomode == stereoNone ) {
- game.DrawGLScene(stereoCenter);
- } else {
- game.DrawGLScene(stereoLeft);
- game.DrawGLScene(stereoRight);
- }
-}
-
static void sdlEventProc(const SDL_Event &e, Game &game)
{
- int val;
- SDLMod mod;
-
switch(e.type)
{
case SDL_MOUSEMOTION:
num_channels = 0;
}
*/
- DrawGL (game);
+ game.DrawGL();
}
// --------------------------------------------------------------------------
{
LOGFUNC;
-// game.Dispose();
-
-
-
-
SDL_Quit();
#define GL_FUNC(ret,fn,params,call,rt) p##fn = NULL;
#include "glstubs.h"
LOGFUNC;
- //memset( &g_theKeys, 0, sizeof( KeyMap));
-
- //initSDLKeyTable();
-
try
{
bool regnow = false;
- // --------------------------------------------------------------------------
+// --------------------------------------------------------------------------
- extern int channels[100];
- extern OPENAL_SAMPLE * samp[100];
- extern OPENAL_STREAM * strm[20];
+extern int channels[100];
+extern OPENAL_SAMPLE * samp[100];
+extern OPENAL_STREAM * strm[20];
- extern "C" void PlaySoundEx(int chan, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused)
+extern "C" void PlaySoundEx(int chan, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused)
+{
+ const OPENAL_SAMPLE * currSample = OPENAL_GetCurrentSample(channels[chan]);
+ if (currSample && currSample == samp[chan])
{
- const OPENAL_SAMPLE * currSample = OPENAL_GetCurrentSample(channels[chan]);
- if (currSample && currSample == samp[chan])
+ if (OPENAL_GetPaused(channels[chan]))
+ {
+ OPENAL_StopSound(channels[chan]);
+ channels[chan] = OPENAL_FREE;
+ }
+ else if (OPENAL_IsPlaying(channels[chan]))
{
- if (OPENAL_GetPaused(channels[chan]))
+ int loop_mode = OPENAL_GetLoopMode(channels[chan]);
+ if (loop_mode & OPENAL_LOOP_OFF)
{
- OPENAL_StopSound(channels[chan]);
channels[chan] = OPENAL_FREE;
}
- else if (OPENAL_IsPlaying(channels[chan]))
- {
- int loop_mode = OPENAL_GetLoopMode(channels[chan]);
- if (loop_mode & OPENAL_LOOP_OFF)
- {
- channels[chan] = OPENAL_FREE;
- }
- }
- }
- else
- {
- channels[chan] = OPENAL_FREE;
}
+ }
+ else
+ {
+ channels[chan] = OPENAL_FREE;
+ }
- channels[chan] = OPENAL_PlaySoundEx(channels[chan], sptr, dsp, startpaused);
- if (channels[chan] < 0)
- {
- channels[chan] = OPENAL_PlaySoundEx(OPENAL_FREE, sptr, dsp, startpaused);
- }
+ channels[chan] = OPENAL_PlaySoundEx(channels[chan], sptr, dsp, startpaused);
+ if (channels[chan] < 0)
+ {
+ channels[chan] = OPENAL_PlaySoundEx(OPENAL_FREE, sptr, dsp, startpaused);
}
+}
- extern "C" void PlayStreamEx(int chan, OPENAL_STREAM *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused)
+extern "C" void PlayStreamEx(int chan, OPENAL_STREAM *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused)
+{
+ const OPENAL_SAMPLE * currSample = OPENAL_GetCurrentSample(channels[chan]);
+ if (currSample && currSample == OPENAL_Stream_GetSample(sptr))
{
- const OPENAL_SAMPLE * currSample = OPENAL_GetCurrentSample(channels[chan]);
- if (currSample && currSample == OPENAL_Stream_GetSample(sptr))
- {
- OPENAL_StopSound(channels[chan]);
- OPENAL_Stream_Stop(sptr);
- }
- else
- {
+ OPENAL_StopSound(channels[chan]);
OPENAL_Stream_Stop(sptr);
- channels[chan] = OPENAL_FREE;
- }
-
- channels[chan] = OPENAL_Stream_PlayEx(channels[chan], sptr, dsp, startpaused);
- if (channels[chan] < 0)
- {
- channels[chan] = OPENAL_Stream_PlayEx(OPENAL_FREE, sptr, dsp, startpaused);
- }
}
-
-
- bool LoadImage(const char * fname, TGAImageRec & tex)
+ else
{
- if ( tex.data == NULL )
- return false;
- else
- return load_image(fname, tex);
+ OPENAL_Stream_Stop(sptr);
+ channels[chan] = OPENAL_FREE;
}
- void ScreenShot(const char * fname)
+ channels[chan] = OPENAL_Stream_PlayEx(channels[chan], sptr, dsp, startpaused);
+ if (channels[chan] < 0)
{
- save_image(fname);
+ channels[chan] = OPENAL_Stream_PlayEx(OPENAL_FREE, sptr, dsp, startpaused);
}
+}
+
+
+bool LoadImage(const char * fname, TGAImageRec & tex)
+{
+ if ( tex.data == NULL )
+ return false;
+ else
+ return load_image(fname, tex);
+}
+
+void ScreenShot(const char * fname)
+{
+
+}
}
-static bool save_image(const char *file_name)
+bool save_image(const char *file_name)
{
const char *ptr = strrchr((char *)file_name, '.');
if (ptr)
extern Terrain terrain;
extern float gravity;
extern int environment;
-extern Sprites sprites;
extern int detail;
extern FRUSTUM frustum;
extern XYZ viewer;
if(skeleton.free)flatvelocity=skeleton.joints[howmany].velocity;
if(!skeleton.free)flatfacing=DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
if(skeleton.free)flatfacing=skeleton.joints[howmany].position*scale+coords;
- sprites.MakeSprite(flamesprite, flatfacing,flatvelocity, 1,1,1, 2, 1);
+ Sprite::MakeSprite(flamesprite, flatfacing,flatvelocity, 1,1,1, 2, 1);
}
onfiredelay=0.5;
if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
if(skeleton.free){
- sprites.MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
- sprites.MakeSprite(bloodflamesprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .3, 1);
+ Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
+ Sprite::MakeSprite(bloodflamesprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .3, 1);
}
if(!skeleton.free){
- sprites.MakeSprite(bloodsprite, DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .05, 1);
- sprites.MakeSprite(bloodflamesprite, DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .3, 1);
+ Sprite::MakeSprite(bloodsprite, DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .05, 1);
+ Sprite::MakeSprite(bloodflamesprite, DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .3, 1);
}
}
if(Random()%2==0)
for(int i=0;i<3;i++){
if(Random()%2!=0){
bloodvel=0;
- if(!skeleton.free){
+ if(skeleton.free) {
+ bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
+ bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
+ } else {
bloodvel.z=10;
bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
+ bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
}
- if(skeleton.free){
- bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
- }
- if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
- if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
bloodvel*=.2;
if(skeleton.free){
- sprites.MakeSprite(splintersprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
- sprites.special[sprites.numsprites-1]=3;
- }
- if(!skeleton.free){
- sprites.MakeSprite(splintersprite, DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .05, 1);
- sprites.special[sprites.numsprites-1]=3;
+ Sprite::MakeSprite(splintersprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
+ } else {
+ Sprite::MakeSprite(splintersprite, DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .05, 1);
}
+ Sprite::setLastSpriteSpecial(3);
}
}
}
bleedxint=abs(Random()%512);
bleedyint=abs(Random()%512);
}
- if(creature==wolftype)
- while(wolfbloodText[bleedxint*512*3+bleedyint*3+0]>which+4||wolfbloodText[bleedxint*512*3+bleedyint*3+0]<which-4||bleedxint<10||bleedyint<10||bleedxint>500||bleedyint>500){
- bleedxint=abs(Random()%512);
- bleedyint=abs(Random()%512);
- }
- bleedy=bleedxint;
- bleedx=bleedyint;
- bleedy/=realtexdetail;
- bleedx/=realtexdetail;
- direction=abs(Random()%2)*2-1;
+ if(creature==wolftype)
+ while(wolfbloodText[bleedxint*512*3+bleedyint*3+0]>which+4||wolfbloodText[bleedxint*512*3+bleedyint*3+0]<which-4||bleedxint<10||bleedyint<10||bleedxint>500||bleedyint>500){
+ bleedxint=abs(Random()%512);
+ bleedyint=abs(Random()%512);
+ }
+ bleedy=bleedxint;
+ bleedx=bleedyint;
+ bleedy/=realtexdetail;
+ bleedx/=realtexdetail;
+ direction=abs(Random()%2)*2-1;
}
}
if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
if(skeleton.free){
- sprites.MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
- sprites.MakeSprite(bloodflamesprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .3, 1);
+ Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
+ Sprite::MakeSprite(bloodflamesprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .3, 1);
}
if(!skeleton.free){
- sprites.MakeSprite(bloodsprite, DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .05, 1);
- sprites.MakeSprite(bloodflamesprite, DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .3, 1);
+ Sprite::MakeSprite(bloodsprite, DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .05, 1);
+ Sprite::MakeSprite(bloodflamesprite, DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .3, 1);
}
}
}
if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
if(skeleton.free){
- sprites.MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
- sprites.MakeSprite(bloodflamesprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .3, 1);
+ Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
+ Sprite::MakeSprite(bloodflamesprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .3, 1);
}
if(!skeleton.free){
- sprites.MakeSprite(bloodsprite, DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .05, 1);
- sprites.MakeSprite(bloodflamesprite, DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .3, 1);
+ Sprite::MakeSprite(bloodsprite, DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .05, 1);
+ Sprite::MakeSprite(bloodflamesprite, DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .3, 1);
}
}
}
flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
- sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, 3, 1);
- sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2, 1,1,1, .4, 1);
- sprites.MakeSprite(cloudsprite, flatfacing2,flatvelocity2*0, .6,0,0, 1, .5);
+ Sprite::MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, 3, 1);
+ Sprite::MakeSprite(bloodsprite, flatfacing2,flatvelocity2, 1,1,1, .4, 1);
+ Sprite::MakeSprite(cloudsprite, flatfacing2,flatvelocity2*0, .6,0,0, 1, .5);
}
float gLoc[3];
if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
//footpoint.y=coords.y;
- if(findDistancefast(&footpoint,&viewer))sprites.MakeSprite(cloudsprite, footpoint,footvel, 1,1,1, .5, .2*opacity);
+ if(findDistancefast(&footpoint,&viewer))Sprite::MakeSprite(cloudsprite, footpoint,footvel, 1,1,1, .5, .2*opacity);
}
else if(environment==snowyenvironment&&onterrain&&terrain.getOpacity(coords.x,coords.z)<.2){
footvel=velocity/5;
if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
footpoint.y=terrain.getHeight(footpoint.x,footpoint.z);
terrainlight=terrain.getLighting(footpoint.x,footpoint.z);
- if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)sprites.MakeSprite(cloudsprite, footpoint,footvel*.6, terrainlight.x,terrainlight.y,terrainlight.z, .5, .7*opacity);
+ if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)Sprite::MakeSprite(cloudsprite, footpoint,footvel*.6, terrainlight.x,terrainlight.y,terrainlight.z, .5, .7*opacity);
if(opacity>=1||detail==2)if(detail==2)if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)terrain.MakeDecal(footprintdecal,footpoint,.2,1*opacity,rotation);
}
else if(environment==grassyenvironment&&onterrain&&terrain.getOpacity(coords.x,coords.z)<.2){
if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
footpoint.y=terrain.getHeight(footpoint.x,footpoint.z);
terrainlight=terrain.getLighting(footpoint.x,footpoint.z);
- if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)sprites.MakeSprite(cloudsprite, footpoint,footvel*.6, terrainlight.x*90/255,terrainlight.y*70/255,terrainlight.z*8/255, .5, .5*opacity);
+ if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)Sprite::MakeSprite(cloudsprite, footpoint,footvel*.6, terrainlight.x*90/255,terrainlight.y*70/255,terrainlight.z*8/255, .5, .5*opacity);
}
else if(environment==desertenvironment&&onterrain&&terrain.getOpacity(coords.x,coords.z)<.2){
footvel=velocity/5;
if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
footpoint.y=terrain.getHeight(footpoint.x,footpoint.z);
terrainlight=terrain.getLighting(footpoint.x,footpoint.z);
- if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)sprites.MakeSprite(cloudsprite, footpoint,footvel*.6, terrainlight.x*190/255,terrainlight.y*170/255,terrainlight.z*108/255, .5, .7*opacity);
+ if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)Sprite::MakeSprite(cloudsprite, footpoint,footvel*.6, terrainlight.x*190/255,terrainlight.y*170/255,terrainlight.z*108/255, .5, .7*opacity);
if(opacity>=1||detail==2)if(detail==2)if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)terrain.MakeDecal(footprintdecal,footpoint,.2,.25*opacity,rotation);
}
else if(isLanding()||targetanimation==jumpupanim||isLandhard())
if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
//footpoint.y=coords.y;
- if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)sprites.MakeSprite(cloudsprite, footpoint,footvel*.6, 1,1,1, .5, .2*opacity);
+ if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)Sprite::MakeSprite(cloudsprite, footpoint,footvel*.6, 1,1,1, .5, .2*opacity);
}
}
footvel=0;
footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[whichlabel]].position,0,rotation,0)*scale+coords;
- sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,1,1, .9, .3);
+ Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,1,1, .9, .3);
}
footpoint=weapons.position[i];
if(victim->weaponstuck!=-1){
if(victim->weaponids[victim->weaponstuck]==i){
- if(bloodtoggle)sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3);
+ if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3);
weapons.bloody[i]=2;
weapons.blooddrip[i]=5;
victim->weaponstuck=-1;
relative.y=10;
Normalise(&relative);
//victim->Puff(abdomen);
- if(bloodtoggle)sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3);
+ if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3);
if(victim->bloodloss<victim->damagetolerance){
victim->bloodloss+=1000;
footpoint=DoRotation((victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].position+victim->skeleton.joints[victim->skeleton.jointlabels[neck]].position)/2,0,victim->rotation,0)*victim->scale+victim->coords;
}
if(tutoriallevel!=1){
- if(bloodtoggle)sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .6, .3);
+ if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .6, .3);
footvel=DoRotation(facing,0,90,0)*.8;
//footvel.y-=.3;
- sprites.MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
- sprites.MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
- sprites.MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .2, 1);
- sprites.MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .2, 1);
+ Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
+ Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
+ Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .2, 1);
+ Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .2, 1);
}
if(tutoriallevel==1){
- sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,1,1, .6, .3);
+ Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,1,1, .6, .3);
}
victim->DoDamage(damagemult*0);
}
if(!skeleton.free){
footpoint=DoRotation((victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].position+victim->skeleton.joints[victim->skeleton.jointlabels[neck]].position)/2,0,victim->rotation,0)*victim->scale+victim->coords;
}
- if(bloodtoggle)sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
+ if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
footvel=DoRotation(facing,0,90,0)*.8;
footvel.y-=.3;
- sprites.MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
- sprites.MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
- sprites.MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
- sprites.MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
+ Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
+ Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
+ Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
+ Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
}
}
else {
bloodvel.z=20;
bloodvel.y=5;
bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
- sprites.MakeSprite(bloodsprite, DoRotation(skeleton.joints[skeleton.jointlabels[neck]].position,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .05, 1);
+ Sprite::MakeSprite(bloodsprite, DoRotation(skeleton.joints[skeleton.jointlabels[neck]].position,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .05, 1);
*/
XYZ footvel,footpoint;
footvel=0;
footpoint=weapons.tippoint[weaponids[0]];
- if(bloodtoggle)sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
+ if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]]);
- sprites.MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
- sprites.MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
- sprites.MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
- sprites.MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
+ Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
+ Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
+ Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
+ Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
victim->DoBloodBig(200,195);
if(id==0){
bonus=tracheotomy;
XYZ footvel,footpoint;
footvel=0;
footpoint=weapons.tippoint[weaponids[0]];
- if(bloodtoggle)sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
+ if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]])*-1;
- sprites.MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
- sprites.MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
- sprites.MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .2, 1);
- sprites.MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .2, 1);
+ Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
+ Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
+ Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .2, 1);
+ Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .2, 1);
}
victim->bloodloss+=10000;
XYZ footvel,footpoint;
footvel=0;
footpoint=weapons.tippoint[weaponids[0]];
- if(bloodtoggle)sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
+ if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]])*-1;
- sprites.MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
- sprites.MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
- sprites.MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
- sprites.MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
+ Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
+ Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
+ Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
+ Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
}
}
XYZ footvel,footpoint;
footvel=0;
footpoint=(weapons.tippoint[weaponids[0]]+weapons.position[weaponids[0]])/2;
- if(bloodtoggle)sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
+ if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]]);
- sprites.MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
- sprites.MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
- sprites.MakeSprite(bloodflamesprite, footpoint,DoRotation(footvel*5,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .3, 1);
- sprites.MakeSprite(bloodflamesprite, footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .3, 1);
+ Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
+ Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
+ Sprite::MakeSprite(bloodflamesprite, footpoint,DoRotation(footvel*5,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .3, 1);
+ Sprite::MakeSprite(bloodflamesprite, footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .3, 1);
victim->DoBloodBig(200,180);
victim->DoBloodBig(200,215);
victim->bloodloss+=10000;
XYZ footvel,footpoint;
footvel=0;
footpoint=weapons.tippoint[weaponids[0]];
- if(bloodtoggle)sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
+ if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]])*-1;
- sprites.MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
- sprites.MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
- sprites.MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
- sprites.MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
+ Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
+ Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
+ Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
+ Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
}
}
if(skeleton.free)flatvelocity=skeleton.joints[howmany].velocity*scale/2;
if(!skeleton.free)flatfacing=DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
if(skeleton.free)flatfacing=skeleton.joints[howmany].position*scale+coords;
- sprites.MakeSprite(flamesprite, flatfacing,flatvelocity, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
+ Sprite::MakeSprite(flamesprite, flatfacing,flatvelocity, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
}
while(flamedelay<0&&!onfire&&tutoriallevel==1&&id!=0){
if(skeleton.free)flatvelocity=skeleton.joints[howmany].velocity*scale/2;
if(!skeleton.free)flatfacing=DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
if(skeleton.free)flatfacing=skeleton.joints[howmany].position*scale+coords;
- sprites.MakeSprite(breathsprite, flatfacing,flatvelocity, 1,1,1, .6+(float)abs(Random()%100)/200-.25, .3);
+ Sprite::MakeSprite(breathsprite, flatfacing,flatvelocity, 1,1,1, .6+(float)abs(Random()%100)/200-.25, .3);
}
if(bleeding>0){
}
if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/40,rotation+((float)(Random()%100))/40,0)*scale;
if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/40,((float)(Random()%100))/40,0)*scale;
- if(skeleton.free)sprites.MakeSprite(bloodsprite, (skeleton.joints[skeleton.jointlabels[neck]].position+(skeleton.joints[skeleton.jointlabels[neck]].position-skeleton.joints[skeleton.jointlabels[head]].position)/5)*scale+coords,bloodvel, 1,1,1, .05, .9);
- if(!skeleton.free)sprites.MakeSprite(bloodsprite, DoRotation(skeleton.joints[skeleton.jointlabels[neck]].position+(skeleton.joints[skeleton.jointlabels[neck]].position-skeleton.joints[skeleton.jointlabels[head]].position)/5,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .05, .9);
+ if(skeleton.free)Sprite::MakeSprite(bloodsprite, (skeleton.joints[skeleton.jointlabels[neck]].position+(skeleton.joints[skeleton.jointlabels[neck]].position-skeleton.joints[skeleton.jointlabels[head]].position)/5)*scale+coords,bloodvel, 1,1,1, .05, .9);
+ if(!skeleton.free)Sprite::MakeSprite(bloodsprite, DoRotation(skeleton.joints[skeleton.jointlabels[neck]].position+(skeleton.joints[skeleton.jointlabels[neck]].position-skeleton.joints[skeleton.jointlabels[head]].position)/5,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .05, .9);
neckspurtparticledelay=.05;
}
if(neckspurtdelay<0){
bloodvel=0;
if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[abdomen]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
- if(skeleton.free)sprites.MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[abdomen]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
- if(!skeleton.free)sprites.MakeSprite(bloodsprite, DoRotation((skeleton.joints[skeleton.jointlabels[abdomen]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .05, 1);
+ if(skeleton.free)Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[abdomen]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
+ if(!skeleton.free)Sprite::MakeSprite(bloodsprite, DoRotation((skeleton.joints[skeleton.jointlabels[abdomen]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .05, 1);
}
}
/*if(id==0){
if(!skeleton.free)footpoint=DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,rotation,0)*scale+coords;
if(skeleton.free)footpoint=((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2)*scale+coords;
if(targetanimation==sleepanim)footvel=DoRotation(footvel,0,90,0);
- sprites.MakeSprite(breathsprite, footpoint+footvel*.2,footvel*.4, 1,1,1, .4, .3);
+ Sprite::MakeSprite(breathsprite, footpoint+footvel*.2,footvel*.4, 1,1,1, .4, .3);
}
}
pos.x+=float(abs(Random()%100)-50)/200;
pos.y+=float(abs(Random()%100)-50)/200;
pos.z+=float(abs(Random()%100)-50)/200;
- sprites.MakeSprite(splintersprite, pos,tempvel*.5+velocity*float(abs(Random()%100))/100, 165/255+float(abs(Random()%100)-50)/400,0,0, .2+float(abs(Random()%100)-50)/1300, 1);
- sprites.special[sprites.numsprites-1]=1;
+ Sprite::MakeSprite(splintersprite, pos,tempvel*.5+velocity*float(abs(Random()%100))/100, 165/255+float(abs(Random()%100)-50)/400,0,0, .2+float(abs(Random()%100)-50)/1300, 1);
+ Sprite::setLastSpriteSpecial(1);
}
howmany=findLength(&velocity)*4;
if(detail==2)
pos.x+=float(abs(Random()%100)-50)/200;
pos.y+=float(abs(Random()%100)-50)/200;
pos.z+=float(abs(Random()%100)-50)/200;
- sprites.MakeSprite(splintersprite, pos,tempvel*.3+velocity*float(abs(Random()%100))/100/2, 1,1,1, .1, 1);
- sprites.special[sprites.numsprites-1]=2;
+ Sprite::MakeSprite(splintersprite, pos,tempvel*.3+velocity*float(abs(Random()%100))/100/2, 1,1,1, .1, 1);
+ Sprite::setLastSpriteSpecial(2);
}
}
objects.rotx[i]+=velocity.x*multiplier*6;
pos.x+=float(abs(Random()%100)-50)/150;
pos.y+=float(abs(Random()%100)-50)/150;
pos.z+=float(abs(Random()%100)-50)/150;
- sprites.MakeSprite(splintersprite, pos,tempvel*.5+velocity*float(abs(Random()%100))/100, 165/255+float(abs(Random()%100)-50)/400,0,0, .2+float(abs(Random()%100)-50)/1300, 1);
- sprites.special[sprites.numsprites-1]=1;
+ Sprite::MakeSprite(splintersprite, pos,tempvel*.5+velocity*float(abs(Random()%100))/100, 165/255+float(abs(Random()%100)-50)/400,0,0, .2+float(abs(Random()%100)-50)/1300, 1);
+ Sprite::setLastSpriteSpecial(1);
}
howmany=findLength(&velocity)*4;
if(detail==2)
pos.x+=float(abs(Random()%100)-50)/150;
pos.y+=float(abs(Random()%100)-50)/150;
pos.z+=float(abs(Random()%100)-50)/150;
- sprites.MakeSprite(splintersprite, pos,tempvel*.3+velocity*float(abs(Random()%100))/100/2, 1,1,1, .1, 1);
- sprites.special[sprites.numsprites-1]=2;
+ Sprite::MakeSprite(splintersprite, pos,tempvel*.3+velocity*float(abs(Random()%100))/100/2, 1,1,1, .1, 1);
+ Sprite::setLastSpriteSpecial(2);
}
}
objects.messedwith[i]=.5;
}
if(playerdetail){
if(!showpoints){
- if((tutoriallevel&&id!=0))skeleton.drawmodel.drawdifftex(sprites.cloudimpacttexture);
+ if((tutoriallevel&&id!=0))skeleton.drawmodel.drawdifftex(Sprite::cloudimpacttexture);
else skeleton.drawmodel.draw();
}
}
if(!playerdetail){
- if((tutoriallevel&&id!=0))skeleton.drawmodellow.drawdifftex(sprites.cloudimpacttexture);
+ if((tutoriallevel&&id!=0))skeleton.drawmodellow.drawdifftex(Sprite::cloudimpacttexture);
else skeleton.drawmodellow.drawdifftex(skeleton.drawmodel.textureptr);
}
glTranslatef(smoketex*.6,0,0);
if(playerdetail){
if(!showpoints){
- if((tutoriallevel&&id!=0))skeleton.drawmodel.drawdifftex(sprites.cloudimpacttexture);
+ if((tutoriallevel&&id!=0))skeleton.drawmodel.drawdifftex(Sprite::cloudimpacttexture);
else skeleton.drawmodel.draw();
}
}
if(!playerdetail){
- if((tutoriallevel&&id!=0))skeleton.drawmodellow.drawdifftex(sprites.cloudimpacttexture);
+ if((tutoriallevel&&id!=0))skeleton.drawmodellow.drawdifftex(Sprite::cloudimpacttexture);
else skeleton.drawmodellow.drawdifftex(skeleton.drawmodel.textureptr);
}
}
#include "Models.h"
#include "Constants.h"
#include "Terrain.h"
-#include "Sprites.h"
+#include "Sprite.h"
#include <cmath>
#include "Weapons.h"
+++ /dev/null
-/*
-Copyright (C) 2003, 2010 - Wolfire Games
-
-This file is part of Lugaru.
-
-Lugaru is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-
-See the GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-// Pointer.h: interface for the Pointer class.
-//
-//////////////////////////////////////////////////////////////////////
-
-#ifndef _POINTER_H
-#define _POINTER_H
-
-template <class T>
-class Pointer
-{
-private:
- void Destroy()
- {
- p = NULL;
- GC::Collect();
- }
-
-public:
- T* p;
-
- Pointer( T* p_ = NULL ) : p( p_ )
- {
- }
-
- ~Pointer()
- {
- GC::SetTotalBytesAllocated( GC::GetTotalBytesAllocated() - sizeof( *p ) );
-
- p->~T(); // Explicitely call the destructor
-
- Destroy();
-
- }
-
- Pointer& operator = ( Pointer<T>& p_ )
- {
- return operator = ( ( T* ) p_);
- }
-
- Pointer& operator = ( T* p_ )
- {
- Destroy();
- p = p_;
- return *this;
- }
-
- operator T*()
- {
- return p;
- }
-
- T& operator*()
- {
- return *p;
- }
-
- T* operator->()
- {
- return p;
- }
-
-// For automatic type conversion during new call
- operator void**()
- {
- return ( void** ) & p;
- }
-};
-
-
-#endif
-
printf("Loading config\n");
while(!ipstream.eof()) {
ipstream.getline( setting, sizeof(setting) );
+ printf("setting : %s\n",setting);
// skip blank lines
// assume lines starting with spaces are all blank
extern OPENAL_SAMPLE *samp[100];
extern int channels[100];
extern Objects objects;
-extern Sprites sprites;
extern int environment;
extern float terraindetail;
extern float camerashake;
}
if(findLengthfast(&bounceness)>4000&&breaking){
objects.model[k].MakeDecal(breakdecal,DoRotation(temp-objects.position[k],0,-objects.rotation[k],0),.4,.5,Random()%360);
- sprites.MakeSprite(cloudsprite, headpos*(*scale)+*coords,joints[jointlabels[head]].velocity*.06, 1,1,1, 4, .2);
+ Sprite::MakeSprite(cloudsprite, headpos*(*scale)+*coords,joints[jointlabels[head]].velocity*.06, 1,1,1, 4, .2);
breaking=0;
camerashake+=.6;
joints[jointlabels[head]].locked=1;
//joints[jointlabels[head]].velocity*=3;
}
- if(findLengthfast(&bounceness)>500)sprites.MakeSprite(cloudsprite, headpos*(*scale)+*coords,joints[jointlabels[head]].velocity*.06, 1,1,1, .5, .2);
+ if(findLengthfast(&bounceness)>500)Sprite::MakeSprite(cloudsprite, headpos*(*scale)+*coords,joints[jointlabels[head]].velocity*.06, 1,1,1, .5, .2);
joints[jointlabels[head]].position=(temp-*coords)/(*scale)+(startheadpos-headpos)+terrainnormal*.005;
if(longdead>100)broken=1;
}
if(tutoriallevel!=1||id==0)
if(findLengthfast(&bounceness)>8000&&breaking){
objects.model[k].MakeDecal(breakdecal,DoRotation(temp-objects.position[k],0,-objects.rotation[k],0),.4,.5,Random()%360);
- sprites.MakeSprite(cloudsprite, joints[i].position*(*scale)+*coords,joints[i].velocity*.06, 1,1,1, 4, .2);
- //sprites.MakeSprite(cloudsprite, joints[i].position*(*scale)+*coords,joints[i].velocity*.06, 1,1,1, 1, .2);
+ Sprite::MakeSprite(cloudsprite, joints[i].position*(*scale)+*coords,joints[i].velocity*.06, 1,1,1, 4, .2);
+ //Sprite::MakeSprite(cloudsprite, joints[i].position*(*scale)+*coords,joints[i].velocity*.06, 1,1,1, 1, .2);
breaking=0;
camerashake+=.6;
if(environment==snowyenvironment&&findLengthfast(&bounceness)>500&&terrain.getOpacity(joints[i].position.x*(*scale)+coords->x,joints[i].position.z*(*scale)+coords->z)<.2){
terrainlight=terrain.getLighting(joints[i].position.x*(*scale)+coords->x,joints[i].position.z*(*scale)+coords->z);
- sprites.MakeSprite(cloudsprite, joints[i].position*(*scale)+*coords,joints[i].velocity*.06, terrainlight.x,terrainlight.y,terrainlight.z, .5, .7);
+ Sprite::MakeSprite(cloudsprite, joints[i].position*(*scale)+*coords,joints[i].velocity*.06, terrainlight.x,terrainlight.y,terrainlight.z, .5, .7);
if(detail==2)terrain.MakeDecal(bodyprintdecal, joints[i].position*(*scale)+*coords,.4,.4,0);
}
else if(environment==desertenvironment&&findLengthfast(&bounceness)>500&&terrain.getOpacity(joints[i].position.x*(*scale)+coords->x,joints[i].position.z*(*scale)+coords->z)<.2){
terrainlight=terrain.getLighting(joints[i].position.x*(*scale)+coords->x,joints[i].position.z*(*scale)+coords->z);
- sprites.MakeSprite(cloudsprite, joints[i].position*(*scale)+*coords,joints[i].velocity*.06, terrainlight.x*190/255,terrainlight.y*170/255,terrainlight.z*108/255, .5, .7);
+ Sprite::MakeSprite(cloudsprite, joints[i].position*(*scale)+*coords,joints[i].velocity*.06, terrainlight.x*190/255,terrainlight.y*170/255,terrainlight.z*108/255, .5, .7);
}
else if(environment==grassyenvironment&&findLengthfast(&bounceness)>500&&terrain.getOpacity(joints[i].position.x*(*scale)+coords->x,joints[i].position.z*(*scale)+coords->z)<.2){
terrainlight=terrain.getLighting(joints[i].position.x*(*scale)+coords->x,joints[i].position.z*(*scale)+coords->z);
- sprites.MakeSprite(cloudsprite, joints[i].position*(*scale)+*coords,joints[i].velocity*.06, terrainlight.x*90/255,terrainlight.y*70/255,terrainlight.z*8/255, .5, .5);
+ Sprite::MakeSprite(cloudsprite, joints[i].position*(*scale)+*coords,joints[i].velocity*.06, terrainlight.x*90/255,terrainlight.y*70/255,terrainlight.z*8/255, .5, .5);
}
- else if(findLengthfast(&bounceness)>500)sprites.MakeSprite(cloudsprite, joints[i].position*(*scale)+*coords,joints[i].velocity*.06, terrainlight.x,terrainlight.y,terrainlight.z, .5, .2);
+ else if(findLengthfast(&bounceness)>500)Sprite::MakeSprite(cloudsprite, joints[i].position*(*scale)+*coords,joints[i].velocity*.06, terrainlight.x,terrainlight.y,terrainlight.z, .5, .2);
joints[i].position.y=(terrain.getHeight(joints[i].position.x*(*scale)+coords->x,joints[i].position.z*(*scale)+coords->z)+groundlevel-coords->y)/(*scale);
if(tutoriallevel!=1||id==0)
if(findLengthfast(&bounceness)>4000&&breaking){
objects.model[k].MakeDecal(breakdecal,DoRotation(temp-objects.position[k],0,-objects.rotation[k],0),.4,.5,Random()%360);
- sprites.MakeSprite(cloudsprite, joints[i].position*(*scale)+*coords,joints[i].velocity*.06, 1,1,1, 4, .2);
+ Sprite::MakeSprite(cloudsprite, joints[i].position*(*scale)+*coords,joints[i].velocity*.06, 1,1,1, 4, .2);
breaking=0;
camerashake+=.6;
pos.x+=float(abs(Random()%100)-50)/100*objects.scale[k]*5;
pos.y+=float(abs(Random()%100)-50)/100*objects.scale[k]*15;
pos.z+=float(abs(Random()%100)-50)/100*objects.scale[k]*5;
- sprites.MakeSprite(splintersprite, pos,tempvel*.5, 165/255+float(abs(Random()%100)-50)/400,0,0, .2+float(abs(Random()%100)-50)/1300, 1);
- sprites.special[sprites.numsprites-1]=1;
+ Sprite::MakeSprite(splintersprite, pos,tempvel*.5, 165/255+float(abs(Random()%100)-50)/400,0,0, .2+float(abs(Random()%100)-50)/1300, 1);
+ Sprite::special[Sprite::numsprites-1]=1;
}*/
objects.rotx[k]+=joints[i].velocity.x*multiplier*.4;
objects.roty[k]+=joints[i].velocity.z*multiplier*.4;
joints[i].locked=1;
//joints[i].velocity*=3;
}
- if(findLengthfast(&bounceness)>500)sprites.MakeSprite(cloudsprite, joints[i].position*(*scale)+*coords,joints[i].velocity*.06, 1,1,1, .5, .2);
+ if(findLengthfast(&bounceness)>500)Sprite::MakeSprite(cloudsprite, joints[i].position*(*scale)+*coords,joints[i].velocity*.06, 1,1,1, .5, .2);
joints[i].position=(temp-*coords)/(*scale)+terrainnormal*.005;
if(longdead>100)broken=1;
}
#include "gamegl.h"
#include "Quaternions.h"
#include "Objects.h"
-#include "Sprites.h"
+#include "Sprite.h"
#include "binio.h"
#define neutral 0
--- /dev/null
+/*
+Copyright (C) 2003, 2010 - Wolfire Games
+
+This file is part of Lugaru.
+
+Lugaru is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "Sprite.h"
+#include "Person.h"
+extern XYZ viewer;
+extern float viewdistance;
+extern float fadestart;
+extern int environment;
+extern float texscale;
+extern Light light;
+extern float multiplier;
+extern float gravity;
+extern Terrain terrain;
+extern Objects objects;
+extern int detail;
+extern XYZ viewerfacing;
+extern float terraindetail;
+extern int bloodtoggle;
+extern XYZ windvector;
+extern int numplayers;
+extern Person player[maxplayers];
+
+// init statics
+GLuint Sprite::cloudtexture = 0;
+GLuint Sprite::cloudimpacttexture = 0;
+GLuint Sprite::bloodtexture = 0;
+GLuint Sprite::flametexture = 0;
+GLuint Sprite::bloodflametexture = 0;
+GLuint Sprite::smoketexture = 0;
+GLuint Sprite::snowflaketexture = 0;
+GLuint Sprite::shinetexture = 0;
+GLuint Sprite::splintertexture = 0;
+GLuint Sprite::leaftexture = 0;
+GLuint Sprite::toothtexture = 0;
+
+float Sprite::checkdelay = 0;
+
+vector<Sprite*> Sprite::sprites = vector<Sprite*>();
+
+//Functions
+void Sprite::Draw()
+{
+ int i,j,k;
+ static float M[16];
+ static XYZ point;
+ static float distancemult;
+ static int lasttype;
+ static int lastspecial;
+ static int whichpatchx,whichpatchz;
+ static XYZ start,end,colpoint;
+ static bool check;
+ static bool blend;
+ static float tempmult;
+ static XYZ difference;
+ static float lightcolor[3];
+ static float viewdistsquared=viewdistance*viewdistance;
+ static XYZ tempviewer;
+
+ tempviewer=viewer+viewerfacing*6;
+ check=0;
+
+ lightcolor[0]=light.color[0]*.5+light.ambient[0];
+ lightcolor[1]=light.color[1]*.5+light.ambient[1];
+ lightcolor[2]=light.color[2]*.5+light.ambient[2];
+
+ checkdelay-=multiplier*10;
+
+ if(checkdelay<=0){
+ check=1;
+ checkdelay=1;
+ }
+
+ lasttype=-1;
+ lastspecial=-1;
+ glEnable(GL_BLEND);
+ glDisable(GL_LIGHTING);
+ glDisable(GL_CULL_FACE);
+ glEnable(GL_TEXTURE_2D);
+ blend = 1;
+ glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
+ glDepthMask(0);
+ glAlphaFunc(GL_GREATER, 0.0001);
+ for(i=0;i<sprites.size();i++){
+ if(lasttype!=sprites[i]->type) {
+ switch(sprites[i]->type) {
+ case cloudsprite:
+ glBindTexture( GL_TEXTURE_2D, cloudtexture);
+ if(!blend){
+ blend=1;
+ glAlphaFunc(GL_GREATER, 0.0001);
+ glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
+ }
+ break;
+ case cloudimpactsprite:
+ glBindTexture( GL_TEXTURE_2D, cloudimpacttexture);
+ if(!blend){
+ blend=1;
+ glAlphaFunc(GL_GREATER, 0.0001);
+ glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
+ }
+ break;
+ case breathsprite:
+ glBindTexture( GL_TEXTURE_2D, cloudimpacttexture);
+ if(!blend){
+ blend=1;
+ glAlphaFunc(GL_GREATER, 0.0001);
+ glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
+ }
+ break;
+ case smoketype:
+ glBindTexture( GL_TEXTURE_2D, smoketexture);
+ if(!blend){
+ blend=1;
+ glAlphaFunc(GL_GREATER, 0.0001);
+ glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
+ }
+ break;
+ case bloodsprite:
+ glBindTexture( GL_TEXTURE_2D, bloodtexture);
+ if(!blend){
+ blend=1;
+ glAlphaFunc(GL_GREATER, 0.0001);
+ glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
+ }
+ break;
+ case splintersprite :
+ if(lastspecial!=sprites[i]->special) {
+ if(sprites[i]->special==0)glBindTexture( GL_TEXTURE_2D, splintertexture);
+ if(sprites[i]->special==1)glBindTexture( GL_TEXTURE_2D, leaftexture);
+ if(sprites[i]->special==2)glBindTexture( GL_TEXTURE_2D, snowflaketexture);
+ if(sprites[i]->special==3)glBindTexture( GL_TEXTURE_2D, toothtexture);
+ if(!blend){
+ blend=1;
+ glAlphaFunc(GL_GREATER, 0.0001);
+ glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
+ }
+ }
+ break;
+ case snowsprite:
+ glBindTexture( GL_TEXTURE_2D, snowflaketexture);
+ if(!blend){
+ blend=1;
+ glAlphaFunc(GL_GREATER, 0.0001);
+ glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
+ }
+ break;
+ case weaponshinesprite:
+ glBindTexture( GL_TEXTURE_2D, shinetexture);
+ if(blend){
+ blend=0;
+ glAlphaFunc(GL_GREATER, 0.001);
+ glBlendFunc(GL_SRC_ALPHA,GL_ONE);
+ }
+ break;
+ case flamesprite:
+ case weaponflamesprite:
+ glBindTexture( GL_TEXTURE_2D, flametexture);
+ if(blend||lasttype==bloodflamesprite){
+ blend=0;
+ glAlphaFunc(GL_GREATER, 0.3);
+ glBlendFunc(GL_SRC_ALPHA,GL_ONE);
+ }
+ break;
+ case bloodflamesprite:
+ glBindTexture( GL_TEXTURE_2D, bloodflametexture);
+ if(blend){
+ blend=0;
+ glAlphaFunc(GL_GREATER, 0.3);
+ glBlendFunc(GL_ONE,GL_ZERO);
+ }
+ break;
+ }
+ }
+ if(sprites[i]->type==snowsprite)
+ distancemult=(144-(findDistancefast(&tempviewer,&sprites[i]->position)-(144*fadestart))*(1/(1-fadestart)))/144;
+ else
+ distancemult=(viewdistsquared-(findDistancefast(&viewer,&sprites[i]->position)-(viewdistsquared*fadestart))*(1/(1-fadestart)))/viewdistsquared;
+ if(sprites[i]->type==flamesprite){
+ if(distancemult>=1) glColor4f(sprites[i]->color[0],sprites[i]->color[1],sprites[i]->color[2],sprites[i]->opacity);
+ else glColor4f(sprites[i]->color[0],sprites[i]->color[1],sprites[i]->color[2],sprites[i]->opacity*distancemult);
+ } else {
+ if(distancemult>=1) glColor4f(sprites[i]->color[0]*lightcolor[0],sprites[i]->color[1]*lightcolor[1],sprites[i]->color[2]*lightcolor[2],sprites[i]->opacity);
+ else glColor4f(sprites[i]->color[0]*lightcolor[0],sprites[i]->color[1]*lightcolor[1],sprites[i]->color[2]*lightcolor[2],sprites[i]->opacity*distancemult);
+ }
+ lasttype=sprites[i]->type;
+ lastspecial=sprites[i]->special;
+ glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
+ glPushMatrix();
+ glTranslatef(sprites[i]->position.x,sprites[i]->position.y,sprites[i]->position.z);
+ if((sprites[i]->type==flamesprite||sprites[i]->type==weaponflamesprite||sprites[i]->type==weaponshinesprite)){
+ difference=viewer-sprites[i]->position;
+ Normalise(&difference);
+ glTranslatef(difference.x*sprites[i]->size/4, difference.y*sprites[i]->size/4, difference.z*sprites[i]->size/4);
+ }
+ if(sprites[i]->type==snowsprite){
+ glRotatef(sprites[i]->rotation*.2,0,.3,1);
+ glTranslatef(1,0,0);
+ }
+ glGetFloatv(GL_MODELVIEW_MATRIX,M);
+ point.x=M[12];
+ point.y=M[13];
+ point.z=M[14];
+ glLoadIdentity();
+ glTranslatef(point.x, point.y, point.z);
+
+ glRotatef(sprites[i]->rotation,0,0,1);
+
+ if((sprites[i]->type==flamesprite||sprites[i]->type==weaponflamesprite||sprites[i]->type==weaponshinesprite||sprites[i]->type==bloodflamesprite)){
+ if(sprites[i]->alivetime<.14)glScalef(sprites[i]->alivetime/.14,sprites[i]->alivetime/.14,sprites[i]->alivetime/.14);
+ }
+ if(sprites[i]->type==smoketype||sprites[i]->type==snowsprite||sprites[i]->type==weaponshinesprite||sprites[i]->type==breathsprite){
+ if(sprites[i]->alivetime<.3){
+ if(distancemult>=1)glColor4f(sprites[i]->color[0]*lightcolor[0],sprites[i]->color[1]*lightcolor[1],sprites[i]->color[2]*lightcolor[2],sprites[i]->opacity*sprites[i]->alivetime/.3);
+ if(distancemult<1)glColor4f(sprites[i]->color[0]*lightcolor[0],sprites[i]->color[1]*lightcolor[1],sprites[i]->color[2]*lightcolor[2],sprites[i]->opacity*distancemult*sprites[i]->alivetime/.3);
+ }
+ }
+ if(sprites[i]->type==splintersprite&&sprites[i]->special>0&&sprites[i]->special!=3){
+ if(sprites[i]->alivetime<.2){
+ if(distancemult>=1) glColor4f(sprites[i]->color[0]*lightcolor[0],sprites[i]->color[1]*lightcolor[1],sprites[i]->color[2]*lightcolor[2],sprites[i]->alivetime/.2);
+ else glColor4f(sprites[i]->color[0]*lightcolor[0],sprites[i]->color[1]*lightcolor[1],sprites[i]->color[2]*lightcolor[2],distancemult*sprites[i]->alivetime/.2);
+ }
+ else {
+ if(distancemult>=1) glColor4f(sprites[i]->color[0]*lightcolor[0],sprites[i]->color[1]*lightcolor[1],sprites[i]->color[2]*lightcolor[2],1);
+ else glColor4f(sprites[i]->color[0]*lightcolor[0],sprites[i]->color[1]*lightcolor[1],sprites[i]->color[2]*lightcolor[2],1);
+ }
+ }
+ if(sprites[i]->type==splintersprite&&(sprites[i]->special==0||sprites[i]->special==3)){
+ if(distancemult>=1) glColor4f(sprites[i]->color[0]*lightcolor[0],sprites[i]->color[1]*lightcolor[1],sprites[i]->color[2]*lightcolor[2],1);
+ else glColor4f(sprites[i]->color[0]*lightcolor[0],sprites[i]->color[1]*lightcolor[1],sprites[i]->color[2]*lightcolor[2],1);
+ }
+
+ glBegin(GL_TRIANGLES);
+ glTexCoord2f(1.0f, 1.0f); glVertex3f( .5*sprites[i]->size, .5*sprites[i]->size, 0.0f);
+ glTexCoord2f(0.0f, 1.0f); glVertex3f(-.5*sprites[i]->size, .5*sprites[i]->size, 0.0f);
+ glTexCoord2f(1.0f, 0.0f); glVertex3f( .5*sprites[i]->size,-.5*sprites[i]->size, 0.0f);
+ glTexCoord2f(0.0f, 0.0f); glVertex3f(-.5*sprites[i]->size,-.5*sprites[i]->size, 0.0f);
+ glTexCoord2f(1.0f, 0.0f); glVertex3f( .5*sprites[i]->size, -.5*sprites[i]->size, 0.0f);
+ glTexCoord2f(0.0f, 1.0f); glVertex3f(-.5*sprites[i]->size, .5*sprites[i]->size, 0.0f);
+ glEnd();
+ glPopMatrix();
+ }
+ tempmult=multiplier;
+ for(i=sprites.size()-1;i>=0;i--){
+ multiplier=tempmult;
+ if(sprites[i]->type!=snowsprite) {
+ sprites[i]->position+=sprites[i]->velocity*multiplier;
+ sprites[i]->velocity+=windvector*multiplier;
+ }
+ if(sprites[i]->type==flamesprite||sprites[i]->type==smoketype)sprites[i]->position+=windvector*multiplier/2;
+ if((sprites[i]->type==flamesprite||sprites[i]->type==weaponflamesprite||sprites[i]->type==weaponshinesprite||sprites[i]->type==bloodflamesprite))
+ multiplier*=sprites[i]->speed*.7;
+ sprites[i]->alivetime+=multiplier;
+
+ if(sprites[i]->type==cloudsprite||sprites[i]->type==cloudimpactsprite){
+ sprites[i]->opacity-=multiplier/2;
+ sprites[i]->size+=multiplier/2;
+ sprites[i]->velocity.y+=gravity*multiplier*.25;
+ }
+ if(sprites[i]->type==breathsprite){
+ sprites[i]->opacity-=multiplier/2;
+ sprites[i]->size+=multiplier/2;
+ if(findLength(&sprites[i]->velocity)<=multiplier)sprites[i]->velocity=0;
+ else{
+ XYZ slowdown;
+ slowdown=sprites[i]->velocity*-1;
+ Normalise(&slowdown);
+ slowdown*=multiplier;
+ sprites[i]->velocity+=slowdown;
+ }
+ }
+ if(sprites[i]->type==snowsprite){
+ sprites[i]->size-=multiplier/120;
+ sprites[i]->rotation+=multiplier*360;
+ sprites[i]->position.y-=multiplier;
+ sprites[i]->position+=windvector*multiplier;
+ if(sprites[i]->position.y<tempviewer.y-6)sprites[i]->position.y+=12;
+ if(sprites[i]->position.y>tempviewer.y+6)sprites[i]->position.y-=12;
+ if(sprites[i]->position.z<tempviewer.z-6)sprites[i]->position.z+=12;
+ if(sprites[i]->position.z>tempviewer.z+6)sprites[i]->position.z-=12;
+ if(sprites[i]->position.x<tempviewer.x-6)sprites[i]->position.x+=12;
+ if(sprites[i]->position.x>tempviewer.x+6)sprites[i]->position.x-=12;
+ }
+ if(sprites[i]->type==bloodsprite){
+ bool spritehit=0;
+ sprites[i]->rotation+=multiplier*100;
+ sprites[i]->velocity.y+=gravity*multiplier;
+ if(check){
+ XYZ where,startpoint,endpoint,movepoint,footpoint;
+ float rotationpoint;
+ int whichtri;
+
+ for(j=0;j<numplayers;j++){
+ if(!spritehit&&player[j].dead&&sprites[i]->alivetime>.1){
+ where=sprites[i]->oldposition;
+ where-=player[j].coords;
+ if(!player[j].skeleton.free)where=DoRotation(where,0,-player[j].rotation,0);
+ startpoint=where;
+ where=sprites[i]->position;
+ where-=player[j].coords;
+ if(!player[j].skeleton.free)where=DoRotation(where,0,-player[j].rotation,0);
+ endpoint=where;
+
+ movepoint=0;
+ rotationpoint=0;
+ whichtri=player[j].skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &footpoint, &movepoint, &rotationpoint);
+ if(whichtri!=-1){
+ spritehit=1;
+ player[j].DoBloodBigWhere(0,160,sprites[i]->oldposition);
+ DeleteSprite(i);
+ }
+ }
+ }
+
+ whichpatchx=sprites[i]->position.x/(terrain.size/subdivision*terrain.scale*terraindetail);
+ whichpatchz=sprites[i]->position.z/(terrain.size/subdivision*terrain.scale*terraindetail);
+ if(whichpatchx>0&&whichpatchz>0&&whichpatchx<subdivision&&whichpatchz<subdivision)
+ if(terrain.patchobjectnum[whichpatchx][whichpatchz]){
+ if(!spritehit)
+ for(j=0;j<terrain.patchobjectnum[whichpatchx][whichpatchz];j++){
+ k=terrain.patchobjects[whichpatchx][whichpatchz][j];
+ start=sprites[i]->oldposition;
+ end=sprites[i]->position;
+ if(!spritehit)
+ if(objects.model[k].LineCheck(&start,&end,&colpoint,&objects.position[k],&objects.rotation[k])!=-1){
+ if(detail==2||(detail==1&&abs(Random()%4)==0)||(detail==0&&abs(Random()%8)==0))objects.model[k].MakeDecal(blooddecalfast,DoRotation(colpoint-objects.position[k],0,-objects.rotation[k],0),sprites[i]->size*1.6/*+abs((float)(Random()%100))/2400*/,.5,Random()%360);
+ DeleteSprite(i);
+ spritehit=1;
+ }
+ }
+ }
+ if(!spritehit)
+ if(sprites[i]->position.y<terrain.getHeight(sprites[i]->position.x,sprites[i]->position.z)){
+ terrain.MakeDecal(blooddecalfast,sprites[i]->position,sprites[i]->size*1.6/*+abs((float)(Random()%100))/2400*/,.6,Random()%360);
+ DeleteSprite(i);
+ }
+ }
+ }
+ if(sprites[i]->type==splintersprite){
+ sprites[i]->rotation+=sprites[i]->rotatespeed*multiplier;
+ sprites[i]->opacity-=multiplier/2;
+ if(sprites[i]->special==0||sprites[i]->special==2||sprites[i]->special==3)sprites[i]->velocity.y+=gravity*multiplier;
+ if(sprites[i]->special==1)sprites[i]->velocity.y+=gravity*multiplier*.5;
+ }
+ if(sprites[i]->type==flamesprite||sprites[i]->type==weaponflamesprite||sprites[i]->type==weaponshinesprite||sprites[i]->type==bloodflamesprite){
+ sprites[i]->rotation+=multiplier*sprites[i]->rotatespeed;
+ sprites[i]->opacity-=multiplier*5/4;
+ if(sprites[i]->type!=weaponshinesprite&&sprites[i]->type!=bloodflamesprite)
+ if(sprites[i]->opacity<.5&&sprites[i]->opacity+multiplier*5/4>=.5&&(abs(Random()%4)==0||(sprites[i]->initialsize>2&&Random()%2==0)))
+ MakeSprite(smoketype, sprites[i]->position,sprites[i]->velocity, .9,.9,.6, sprites[i]->size*1.2, .4);
+ if(sprites[i]->alivetime>.14&&(sprites[i]->type==flamesprite)){
+ sprites[i]->velocity=0;
+ sprites[i]->velocity.y=1.5;
+ }
+ }
+ if(sprites[i]->type==smoketype){
+ sprites[i]->opacity-=multiplier/3/sprites[i]->initialsize;
+ sprites[i]->color[0]-=multiplier;
+ sprites[i]->color[1]-=multiplier;
+ sprites[i]->color[2]-=multiplier;
+ if(sprites[i]->color[0]<.6)sprites[i]->color[0]=.6;
+ if(sprites[i]->color[1]<.6)sprites[i]->color[1]=.6;
+ if(sprites[i]->color[2]<.6)sprites[i]->color[2]=.6;
+ sprites[i]->size+=multiplier;
+ sprites[i]->velocity=0;
+ sprites[i]->velocity.y=1.5;
+ sprites[i]->rotation+=multiplier*sprites[i]->rotatespeed/5;
+ }
+ if(sprites[i]->opacity<=0||sprites[i]->size<=0)DeleteSprite(i);
+ }
+ if(check)
+ for(i=sprites.size()-1;i>=0;i--){
+ sprites[i]->oldposition=sprites[i]->position;
+ }
+ glAlphaFunc(GL_GREATER, 0.0001);
+ glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
+}
+
+void Sprite::DeleteSprite(int i)
+{
+ sprites.erase(sprites.begin()+i);
+}
+
+void Sprite::MakeSprite(int atype, XYZ where, XYZ avelocity, float red, float green, float blue, float asize, float aopacity){
+ if(sprites.size()<max_sprites-1){
+ sprites.push_back(new Sprite());
+ if((atype!=bloodsprite&&atype!=bloodflamesprite)||bloodtoggle){
+ sprites.back()->special=0;
+ sprites.back()->type=atype;
+ sprites.back()->position=where;
+ sprites.back()->oldposition=where;
+ sprites.back()->velocity=avelocity;
+ sprites.back()->alivetime=0;
+ sprites.back()->opacity=aopacity;
+ sprites.back()->size=asize;
+ sprites.back()->initialsize=asize;
+ sprites.back()->color[0]=red;
+ sprites.back()->color[1]=green;
+ sprites.back()->color[2]=blue;
+ sprites.back()->rotatespeed=abs(Random()%720)-360;
+ sprites.back()->speed=float(abs(Random()%100))/200+1.5;
+ }
+ }
+}
+
+Sprite::Sprite()
+{
+ oldposition = 0;
+ position = 0;
+ velocity = 0;
+ size = 0;
+ initialsize = 0;
+ type = 0;
+ special = 0;
+ memset(color,0,sizeof(color));
+ opacity = 0;
+ rotation = 0;
+ alivetime = 0;
+ speed = 0;
+ rotatespeed = 0;
+}
+
+void Sprite::clearTextures()
+{
+ if (toothtexture) glDeleteTextures( 1, &toothtexture );
+ if (cloudtexture) glDeleteTextures( 1, &cloudtexture );
+ if (cloudimpacttexture) glDeleteTextures( 1, &cloudimpacttexture );
+ if (bloodtexture) glDeleteTextures( 1, &bloodtexture );
+ if (flametexture) glDeleteTextures( 1, &flametexture );
+ if (bloodflametexture) glDeleteTextures( 1, &bloodflametexture );
+ if (smoketexture) glDeleteTextures( 1, &smoketexture );
+ if (snowflaketexture) glDeleteTextures( 1, &snowflaketexture );
+ if (shinetexture) glDeleteTextures( 1, &shinetexture );
+ if (splintertexture) glDeleteTextures( 1, &splintertexture );
+ if (leaftexture) glDeleteTextures( 1, &leaftexture );
+}
+
--- /dev/null
+/*
+Copyright (C) 2003, 2010 - Wolfire Games
+
+This file is part of Lugaru.
+
+Lugaru is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#ifndef _SPRITE_H_
+#define _SPRITE_H_
+
+#include "Quaternions.h"
+#include "gamegl.h"
+#include "TGALoader.h"
+#include "Quaternions.h"
+#include "Frustum.h"
+#include "Lights.h"
+#include "Terrain.h"
+#include "Objects.h"
+
+#include <vector>
+
+#define max_sprites 20000
+
+enum {
+ cloudsprite = 0,
+ bloodsprite,
+ flamesprite,
+ smoketype,
+ weaponflamesprite,
+ cloudimpactsprite,
+ snowsprite,
+ weaponshinesprite,
+ bloodflamesprite,
+ breathsprite,
+ splintersprite,
+ spritenumber
+};
+
+class Sprite{
+ private:
+ XYZ oldposition;
+ XYZ position;
+ XYZ velocity;
+ float size;
+ float initialsize;
+ int type;
+ int special;
+ float color[3];
+ float opacity;
+ float rotation;
+ float alivetime;
+ float speed;
+ float rotatespeed;
+
+ static float checkdelay;
+
+ static vector<Sprite*> sprites;
+
+ public:
+ static void DeleteSprite(int which);
+ static void MakeSprite(int atype, XYZ where, XYZ avelocity, float red, float green, float blue, float asize, float aopacity);
+ static void Draw();
+ static void deleteSprites() {
+ sprites.clear();
+ }
+ static void setLastSpriteSpecial(int s) {
+ sprites.back()->special = s;
+ }
+ static void setLastSpriteSpeed(int s) {
+ sprites.back()->speed = s;
+ }
+ static void setLastSpriteAlivetime(float al) {
+ sprites.back()->alivetime = al;
+ }
+ static void clearTextures();
+
+ static GLuint cloudtexture;
+ static GLuint bloodtexture;
+ static GLuint flametexture;
+ static GLuint smoketexture;
+
+ static GLuint cloudimpacttexture;
+ static GLuint snowflaketexture;
+ static GLuint shinetexture;
+ static GLuint bloodflametexture;
+
+ static GLuint splintertexture;
+
+ static GLuint leaftexture;
+ static GLuint toothtexture;
+
+ Sprite();
+ ~Sprite();
+};
+
+#endif
+++ /dev/null
-/*
-Copyright (C) 2003, 2010 - Wolfire Games
-
-This file is part of Lugaru.
-
-Lugaru is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-
-See the GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-#include "Sprites.h"
-#include "Person.h"
-extern XYZ viewer;
-extern float viewdistance;
-extern float fadestart;
-extern int environment;
-extern float texscale;
-extern Light light;
-extern float multiplier;
-extern float gravity;
-extern Terrain terrain;
-extern Objects objects;
-extern int detail;
-extern XYZ viewerfacing;
-extern float terraindetail;
-extern int bloodtoggle;
-extern XYZ windvector;
-extern int numplayers;
-extern Person player[maxplayers];
-//Functions
-
-void Sprites::Draw()
-{
- static int i,j,k;
- static float M[16];
- static XYZ point;
- static float distancemult;
- static int lasttype;
- static int lastspecial;
- static int whichpatchx,whichpatchz;
- static XYZ start,end,colpoint;
- static bool check;
- static bool blend;
- static float tempmult;
- static XYZ difference;
- static float lightcolor[3];
- static float viewdistsquared=viewdistance*viewdistance;
- static XYZ tempviewer;
-
- tempviewer=viewer+viewerfacing*6;
- check=0;
-
- lightcolor[0]=light.color[0]*.5+light.ambient[0];
- lightcolor[1]=light.color[1]*.5+light.ambient[1];
- lightcolor[2]=light.color[2]*.5+light.ambient[2];
-
- checkdelay-=multiplier*10;
-
- if(checkdelay<=0){
- check=1;
- checkdelay=1;
- }
-
- lasttype=-1;
- lastspecial=-1;
- glEnable(GL_BLEND);
- glDisable(GL_LIGHTING);
- glDisable(GL_CULL_FACE);
- glEnable(GL_TEXTURE_2D);
- blend = 1;
- glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
- glDepthMask(0);
- glAlphaFunc(GL_GREATER, 0.0001);
- for(i=0;i<numsprites;i++){
- if(type[i]==cloudsprite&&lasttype!=type[i]){
- glBindTexture( GL_TEXTURE_2D, cloudtexture);
- if(!blend){
- blend=1;
- glAlphaFunc(GL_GREATER, 0.0001);
- glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
- }
- }
- if(type[i]==cloudimpactsprite&&lasttype!=type[i]){
- glBindTexture( GL_TEXTURE_2D, cloudimpacttexture);
- if(!blend){
- blend=1;
- glAlphaFunc(GL_GREATER, 0.0001);
- glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
- }
- }
- if(type[i]==breathsprite&&lasttype!=type[i]){
- glBindTexture( GL_TEXTURE_2D, cloudimpacttexture);
- if(!blend){
- blend=1;
- glAlphaFunc(GL_GREATER, 0.0001);
- glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
- }
- }
- if(type[i]==smoketype&&lasttype!=type[i]){
- glBindTexture( GL_TEXTURE_2D, smoketexture);
- if(!blend){
- blend=1;
- glAlphaFunc(GL_GREATER, 0.0001);
- glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
- }
- }
- if(type[i]==bloodsprite&&lasttype!=type[i]){
- glBindTexture( GL_TEXTURE_2D, bloodtexture);
- if(!blend){
- blend=1;
- glAlphaFunc(GL_GREATER, 0.0001);
- glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
- }
- }
- if(type[i]==splintersprite&&(lasttype!=type[i]||lastspecial!=special[i])){
- if(special[i]==0)glBindTexture( GL_TEXTURE_2D, splintertexture);
- if(special[i]==1)glBindTexture( GL_TEXTURE_2D, leaftexture);
- if(special[i]==2)glBindTexture( GL_TEXTURE_2D, snowflaketexture);
- if(special[i]==3)glBindTexture( GL_TEXTURE_2D, toothtexture);
- if(!blend){
- blend=1;
- glAlphaFunc(GL_GREATER, 0.0001);
- glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
- }
- }
- if(type[i]==snowsprite&&lasttype!=type[i]){
- glBindTexture( GL_TEXTURE_2D, snowflaketexture);
- if(!blend){
- blend=1;
- glAlphaFunc(GL_GREATER, 0.0001);
- glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
- }
- }
- if(type[i]==weaponshinesprite&&lasttype!=type[i]){
- glBindTexture( GL_TEXTURE_2D, shinetexture);
- if(blend){
- blend=0;
- glAlphaFunc(GL_GREATER, 0.001);
- glBlendFunc(GL_SRC_ALPHA,GL_ONE);
- }
- }
- if((type[i]==flamesprite||type[i]==weaponflamesprite)&&lasttype!=type[i]){
- glBindTexture( GL_TEXTURE_2D, flametexture);
- if(blend||lasttype==bloodflamesprite){
- blend=0;
- glAlphaFunc(GL_GREATER, 0.3);
- glBlendFunc(GL_SRC_ALPHA,GL_ONE);
- }
- }
- if((type[i]==bloodflamesprite)&&lasttype!=type[i]){
- glBindTexture( GL_TEXTURE_2D, bloodflametexture);
- if(blend){
- blend=0;
- glAlphaFunc(GL_GREATER, 0.3);
- glBlendFunc(GL_ONE,GL_ZERO);
- //glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
- }
- }
- if(type[i]!=snowsprite)distancemult=(viewdistsquared-(findDistancefast(&viewer,&position[i])-(viewdistsquared*fadestart))*(1/(1-fadestart)))/viewdistsquared;
- if(type[i]==snowsprite)distancemult=(144-(findDistancefast(&tempviewer,&position[i])-(144*fadestart))*(1/(1-fadestart)))/144;
- if(type[i]!=flamesprite){
- if(distancemult>=1)glColor4f(color[i][0]*lightcolor[0],color[i][1]*lightcolor[1],color[i][2]*lightcolor[2],opacity[i]);
- if(distancemult<1)glColor4f(color[i][0]*lightcolor[0],color[i][1]*lightcolor[1],color[i][2]*lightcolor[2],opacity[i]*distancemult);
- }
- if(type[i]==flamesprite){
- if(distancemult>=1)glColor4f(color[i][0],color[i][1],color[i][2],opacity[i]);
- if(distancemult<1)glColor4f(color[i][0],color[i][1],color[i][2],opacity[i]*distancemult);
- }
- lasttype=type[i];
- lastspecial=special[i];
- glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
- glPushMatrix();
- glTranslatef(position[i].x,position[i].y,position[i].z);
- if((type[i]==flamesprite||type[i]==weaponflamesprite||type[i]==weaponshinesprite)){
- difference=viewer-position[i];
- Normalise(&difference);
- glTranslatef(difference.x*size[i]/4, difference.y*size[i]/4, difference.z*size[i]/4);
- }
- if(type[i]==snowsprite){
- glRotatef(rotation[i]*.2,0,.3,1);
- glTranslatef(1,0,0);
- }
- glGetFloatv(GL_MODELVIEW_MATRIX,M);
- point.x=M[12];
- point.y=M[13];
- point.z=M[14];
- glLoadIdentity();
- glTranslatef(point.x, point.y, point.z);
-
- glRotatef(rotation[i],0,0,1);
-
- if((type[i]==flamesprite||type[i]==weaponflamesprite||type[i]==weaponshinesprite||type[i]==bloodflamesprite)){
- if(alivetime[i]<.14)glScalef(alivetime[i]/.14,alivetime[i]/.14,alivetime[i]/.14);
- }
- if(type[i]==smoketype||type[i]==snowsprite||type[i]==weaponshinesprite||type[i]==breathsprite){
- if(alivetime[i]<.3){
- if(distancemult>=1)glColor4f(color[i][0]*lightcolor[0],color[i][1]*lightcolor[1],color[i][2]*lightcolor[2],opacity[i]*alivetime[i]/.3);
- if(distancemult<1)glColor4f(color[i][0]*lightcolor[0],color[i][1]*lightcolor[1],color[i][2]*lightcolor[2],opacity[i]*distancemult*alivetime[i]/.3);
- }
- }
- if(type[i]==splintersprite&&special[i]>0&&special[i]!=3){
- if(alivetime[i]<.2){
- if(distancemult>=1)glColor4f(color[i][0]*lightcolor[0],color[i][1]*lightcolor[1],color[i][2]*lightcolor[2],alivetime[i]/.2);
- if(distancemult<1)glColor4f(color[i][0]*lightcolor[0],color[i][1]*lightcolor[1],color[i][2]*lightcolor[2],distancemult*alivetime[i]/.2);
- }
- else{
- if(distancemult>=1)glColor4f(color[i][0]*lightcolor[0],color[i][1]*lightcolor[1],color[i][2]*lightcolor[2],1);
- if(distancemult<1)glColor4f(color[i][0]*lightcolor[0],color[i][1]*lightcolor[1],color[i][2]*lightcolor[2],1);
- }
- }
- if(type[i]==splintersprite&&(special[i]==0||special[i]==3)){
- if(distancemult>=1)glColor4f(color[i][0]*lightcolor[0],color[i][1]*lightcolor[1],color[i][2]*lightcolor[2],1);
- if(distancemult<1)glColor4f(color[i][0]*lightcolor[0],color[i][1]*lightcolor[1],color[i][2]*lightcolor[2],1);
- }
- /*
- if(type[i]==snowsprite){
- glRotatef(rotation[i],0,0,1);
- glTranslatef(1,0,0);
- }*/
-
- glBegin(GL_TRIANGLES);
- glTexCoord2f(1.0f, 1.0f); glVertex3f( .5*size[i], .5*size[i], 0.0f);
- glTexCoord2f(0.0f, 1.0f); glVertex3f(-.5*size[i], .5*size[i], 0.0f);
- glTexCoord2f(1.0f, 0.0f); glVertex3f( .5*size[i],-.5*size[i], 0.0f);
- glTexCoord2f(0.0f, 0.0f); glVertex3f(-.5*size[i],-.5*size[i], 0.0f);
- glTexCoord2f(1.0f, 0.0f); glVertex3f( .5*size[i], -.5*size[i], 0.0f);
- glTexCoord2f(0.0f, 1.0f); glVertex3f(-.5*size[i], .5*size[i], 0.0f);
- glEnd();
- glPopMatrix();
- }
- tempmult=multiplier;
- for(i=numsprites-1;i>=0;i--){
- multiplier=tempmult;
- if(type[i]!=snowsprite)position[i]+=velocity[i]*multiplier;
- if(type[i]!=snowsprite)velocity[i]+=windvector*multiplier;
- if(type[i]==flamesprite||type[i]==smoketype)position[i]+=windvector*multiplier/2;
- if((type[i]==flamesprite||type[i]==weaponflamesprite||type[i]==weaponshinesprite||type[i]==bloodflamesprite))multiplier*=speed[i]*.7;
- alivetime[i]+=multiplier;
-
- if(type[i]==cloudsprite||type[i]==cloudimpactsprite){
- opacity[i]-=multiplier/2;
- size[i]+=multiplier/2;
- velocity[i].y+=gravity*multiplier*.25;
- }
- if(type[i]==breathsprite){
- opacity[i]-=multiplier/2;
- size[i]+=multiplier/2;
- if(findLength(&velocity[i])<=multiplier)velocity[i]=0;
- else{
- XYZ slowdown;
- slowdown=velocity[i]*-1;
- Normalise(&slowdown);
- slowdown*=multiplier;
- velocity[i]+=slowdown;
- }
- }
- if(type[i]==snowsprite){
- size[i]-=multiplier/120;
- rotation[i]+=multiplier*360;
- position[i].y-=multiplier;
- position[i]+=windvector*multiplier;
- if(position[i].y<tempviewer.y-6)position[i].y+=12;
- if(position[i].y>tempviewer.y+6)position[i].y-=12;
- if(position[i].z<tempviewer.z-6)position[i].z+=12;
- if(position[i].z>tempviewer.z+6)position[i].z-=12;
- if(position[i].x<tempviewer.x-6)position[i].x+=12;
- if(position[i].x>tempviewer.x+6)position[i].x-=12;
- }
- if(type[i]==bloodsprite){
- bool spritehit=0;
- rotation[i]+=multiplier*100;
- velocity[i].y+=gravity*multiplier;
- if(check){
- XYZ where,startpoint,endpoint,movepoint,footpoint;
- float rotationpoint;
- int whichtri;
-
- for(j=0;j<numplayers;j++){
- if(!spritehit&&player[j].dead&&alivetime[i]>.1){
- where=oldposition[i];
- where-=player[j].coords;
- if(!player[j].skeleton.free)where=DoRotation(where,0,-player[j].rotation,0);
- startpoint=where;
- where=position[i];
- where-=player[j].coords;
- if(!player[j].skeleton.free)where=DoRotation(where,0,-player[j].rotation,0);
- endpoint=where;
-
- movepoint=0;
- rotationpoint=0;
- whichtri=player[j].skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &footpoint, &movepoint, &rotationpoint);
- if(whichtri!=-1){
- spritehit=1;
- player[j].DoBloodBigWhere(0,160,oldposition[i]);
- DeleteSprite(i);
- }
- }
- }
-
- whichpatchx=position[i].x/(terrain.size/subdivision*terrain.scale*terraindetail);
- whichpatchz=position[i].z/(terrain.size/subdivision*terrain.scale*terraindetail);
- if(whichpatchx>0&&whichpatchz>0&&whichpatchx<subdivision&&whichpatchz<subdivision)
- if(terrain.patchobjectnum[whichpatchx][whichpatchz]){
- if(!spritehit)
- for(j=0;j<terrain.patchobjectnum[whichpatchx][whichpatchz];j++){
- k=terrain.patchobjects[whichpatchx][whichpatchz][j];
- start=oldposition[i];
- end=position[i];
- if(!spritehit)
- if(objects.model[k].LineCheck(&start,&end,&colpoint,&objects.position[k],&objects.rotation[k])!=-1){
- if(detail==2||(detail==1&&abs(Random()%4)==0)||(detail==0&&abs(Random()%8)==0))objects.model[k].MakeDecal(blooddecalfast,DoRotation(colpoint-objects.position[k],0,-objects.rotation[k],0),size[i]*1.6/*+abs((float)(Random()%100))/2400*/,.5,Random()%360);
- DeleteSprite(i);
- spritehit=1;
- }
- }
- }
- if(!spritehit)
- if(position[i].y<terrain.getHeight(position[i].x,position[i].z)){
- terrain.MakeDecal(blooddecalfast,position[i],size[i]*1.6/*+abs((float)(Random()%100))/2400*/,.6,Random()%360);
- DeleteSprite(i);
- }
- }
- }
- if(type[i]==splintersprite){
- rotation[i]+=rotatespeed[i]*multiplier;
- opacity[i]-=multiplier/2;
- if(special[i]==0||special[i]==2||special[i]==3)velocity[i].y+=gravity*multiplier;
- if(special[i]==1)velocity[i].y+=gravity*multiplier*.5;
- }
- if(type[i]==flamesprite||type[i]==weaponflamesprite||type[i]==weaponshinesprite||type[i]==bloodflamesprite){
- rotation[i]+=multiplier*rotatespeed[i];
- opacity[i]-=multiplier*5/4;
- if(type[i]!=weaponshinesprite&&type[i]!=bloodflamesprite)
- if(opacity[i]<.5&&opacity[i]+multiplier*5/4>=.5&&(abs(Random()%4)==0||(initialsize[i]>2&&Random()%2==0)))MakeSprite(smoketype, position[i],velocity[i], .9,.9,.6, size[i]*1.2, .4);
- if(alivetime[i]>.14&&(type[i]==flamesprite)){
- velocity[i]=0;
- velocity[i].y=1.5;
- }
- }
- /*if(type[i]==smoketype){
- opacity[i]-=multiplier/3/initialsize[i];
- size[i]+=multiplier;
- velocity[i]=0;
- velocity[i].y=1.5;
- rotation[i]+=multiplier*rotatespeed[i]/5;
- }*/
- if(type[i]==smoketype){
- opacity[i]-=multiplier/3/initialsize[i];
- color[i][0]-=multiplier;
- color[i][1]-=multiplier;
- color[i][2]-=multiplier;
- if(color[i][0]<.6)color[i][0]=.6;
- if(color[i][1]<.6)color[i][1]=.6;
- if(color[i][2]<.6)color[i][2]=.6;
- size[i]+=multiplier;
- velocity[i]=0;
- velocity[i].y=1.5;
- rotation[i]+=multiplier*rotatespeed[i]/5;
- }
- if(opacity[i]<=0||size[i]<=0)DeleteSprite(i);
- }
- if(check)
- for(i=numsprites-1;i>=0;i--){
- oldposition[i]=position[i];
- }
- glAlphaFunc(GL_GREATER, 0.0001);
- glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
-}
-
-void Sprites::DeleteSprite(int which)
-{
- type[which]=type[numsprites-1];
- rotation[which]=rotation[numsprites-1];
- alivetime[which]=alivetime[numsprites-1];
- opacity[which]=opacity[numsprites-1];
- position[which]=position[numsprites-1];
- velocity[which]=velocity[numsprites-1];
- size[which]=size[numsprites-1];
- speed[which]=speed[numsprites-1];
- special[which]=special[numsprites-1];
- color[which][0]=color[numsprites-1][0];
- color[which][1]=color[numsprites-1][1];
- color[which][2]=color[numsprites-1][2];
- numsprites--;
-}
-
-void Sprites::MakeSprite(int atype, XYZ where, XYZ avelocity, float red, float green, float blue, float asize, float aopacity){
- if(numsprites<max_sprites-1){
- if((atype!=bloodsprite&&atype!=bloodflamesprite)||bloodtoggle){
- special[numsprites]=0;
- type[numsprites]=atype;
- position[numsprites]=where;
- oldposition[numsprites]=where;
- velocity[numsprites]=avelocity;
- alivetime[numsprites]=0;
- opacity[numsprites]=aopacity;
- size[numsprites]=asize;
- initialsize[numsprites]=asize;
- color[numsprites][0]=red;
- color[numsprites][1]=green;
- color[numsprites][2]=blue;
- rotatespeed[numsprites]=abs(Random()%720)-360;
- speed[numsprites]=float(abs(Random()%100))/200+1.5;
- }
- numsprites++;
- }
-}
-
-Sprites::Sprites()
-{
- cloudtexture = 0;
- cloudimpacttexture = 0;
- bloodtexture = 0;
- flametexture = 0;
- bloodflametexture = 0;
- smoketexture = 0;
- snowflaketexture = 0;
- shinetexture = 0;
- splintertexture = 0;
- leaftexture = 0;
- toothtexture = 0;
-
- memset(oldposition, 0, sizeof(oldposition));
- memset(position, 0, sizeof(position));
- memset(velocity, 0, sizeof(velocity));
- memset(size, 0, sizeof(size));
- memset(initialsize, 0, sizeof(initialsize));
- memset(type, 0, sizeof(type));
- memset(special, 0, sizeof(special));
- memset(color, 0, sizeof(color));
- memset(opacity, 0, sizeof(opacity));
- memset(rotation, 0, sizeof(rotation));
- memset(alivetime, 0, sizeof(alivetime));
- memset(speed, 0, sizeof(speed));
- memset(rotatespeed, 0, sizeof(rotatespeed));
-
- checkdelay = 0;
- numsprites = 0;
-}
-Sprites::~Sprites()
-{
- if (toothtexture) glDeleteTextures( 1, &toothtexture );
- if (cloudtexture) glDeleteTextures( 1, &cloudtexture );
- if (cloudimpacttexture) glDeleteTextures( 1, &cloudimpacttexture );
- if (bloodtexture) glDeleteTextures( 1, &bloodtexture );
- if (flametexture) glDeleteTextures( 1, &flametexture );
- if (bloodflametexture) glDeleteTextures( 1, &bloodflametexture );
- if (smoketexture) glDeleteTextures( 1, &smoketexture );
- if (snowflaketexture) glDeleteTextures( 1, &snowflaketexture );
- if (shinetexture) glDeleteTextures( 1, &shinetexture );
- if (splintertexture) glDeleteTextures( 1, &splintertexture );
- if (leaftexture) glDeleteTextures( 1, &leaftexture );
-}
-
+++ /dev/null
-/*
-Copyright (C) 2003, 2010 - Wolfire Games
-
-This file is part of Lugaru.
-
-Lugaru is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-
-See the GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-#ifndef _SPRITES_H_
-#define _SPRITES_H_
-
-#include "Quaternions.h"
-#include "gamegl.h"
-#include "TGALoader.h"
-#include "Quaternions.h"
-#include "Frustum.h"
-#include "Lights.h"
-#include "Terrain.h"
-#include "Objects.h"
-//
-// Model Structures
-//
-
-#define max_sprites 20000
-
-#define cloudsprite 0
-#define bloodsprite 1
-#define flamesprite 2
-#define smoketype 3
-#define weaponflamesprite 4
-#define cloudimpactsprite 5
-#define snowsprite 6
-#define weaponshinesprite 7
-#define bloodflamesprite 8
-#define breathsprite 9
-#define splintersprite 10
-
-class Sprites{
-public:
- GLuint cloudtexture;
- GLuint cloudimpacttexture;
- GLuint bloodtexture;
- GLuint flametexture;
- GLuint bloodflametexture;
- GLuint smoketexture;
- GLuint snowflaketexture;
- GLuint shinetexture;
- GLuint splintertexture;
- GLuint leaftexture;
- GLuint toothtexture;
-
- XYZ oldposition[max_sprites];
- XYZ position[max_sprites];
- XYZ velocity[max_sprites];
- float size[max_sprites];
- float initialsize[max_sprites];
- int type[max_sprites];
- int special[max_sprites];
- float color[max_sprites][3];
- float opacity[max_sprites];
- float rotation[max_sprites];
- float alivetime[max_sprites];
- float speed[max_sprites];
- float rotatespeed[max_sprites];
- float checkdelay;
- int numsprites;
-
- void DeleteSprite(int which);
- void MakeSprite(int atype, XYZ where, XYZ avelocity, float red, float green, float blue, float asize, float aopacity);
- void Draw();
-
- Sprites();
- ~Sprites();
-};
-
-#endif
/********************> LoadTGA() <*****/
bool upload_image(const unsigned char* filePath, bool hasalpha)
{
- if(visibleloading){
+ if(visibleloading) {
loadscreencolor=1;
pgame->LoadingScreen();
}
extern Terrain terrain;
extern float gravity;
extern int environment;
-extern Sprites sprites;
extern int detail;
extern FRUSTUM frustum;
extern XYZ viewer;
tempvel.y=float(abs(Random()%100)-50)/20;
tempvel.z=float(abs(Random()%100)-50)/20;
tempvel+=speed;
- sprites.MakeSprite(splintersprite, position[i]+(tippoint[i]-position[i])*((float)j-8)/32,tempvel*.5, 115/255,73/255,12/255, .1, 1);
+ Sprite::MakeSprite(splintersprite, position[i]+(tippoint[i]-position[i])*((float)j-8)/32,tempvel*.5, 115/255,73/255,12/255, .1, 1);
}
int tempowner;
tempowner=owner[i];
bloody[i]=0;
- sprites.MakeSprite(cloudimpactsprite, position[i],velocity[i], 1,1,1, .8, .3);
+ Sprite::MakeSprite(cloudimpactsprite, position[i],velocity[i], 1,1,1, .8, .3);
}
else {
physics[i]=1;
player[j].skeleton.joints[player[j].skeleton.jointlabels[rightshoulder]].velocity+=velocity[i]*2;
player[j].skeleton.joints[player[j].skeleton.jointlabels[leftshoulder]].velocity+=velocity[i]*2;
//player[j].Puff(abdomen);
- if(bloodtoggle&&tutoriallevel!=1)sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3);
- if(tutoriallevel==1)sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,1,1, .8, .3);
+ if(bloodtoggle&&tutoriallevel!=1)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3);
+ if(tutoriallevel==1)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,1,1, .8, .3);
footvel=tippoint[i]-position[i];
Normalise(&footvel);
- if(bloodtoggle&&tutoriallevel!=1)sprites.MakeSprite(bloodflamesprite, footpoint,footvel*-1, 1,0,0, .6, 1);
+ if(bloodtoggle&&tutoriallevel!=1)Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*-1, 1,0,0, .6, 1);
if(tutoriallevel!=1){
if(player[j].weaponstuckwhere==0)player[j].DoBloodBig(2,205);
XYZ terrainlight;
terrainlight=terrain.getLighting(position[i].x,position[i].z);
if(environment==snowyenvironment){
- if(findDistancefast(&position[i],&viewer)<viewdistance*viewdistance/4)sprites.MakeSprite(cloudsprite, position[i],velocity[i], terrainlight.x,terrainlight.y,terrainlight.z, .5, .7);
+ if(findDistancefast(&position[i],&viewer)<viewdistance*viewdistance/4)Sprite::MakeSprite(cloudsprite, position[i],velocity[i], terrainlight.x,terrainlight.y,terrainlight.z, .5, .7);
}
else if(environment==grassyenvironment){
- if(findDistancefast(&position[i],&viewer)<viewdistance*viewdistance/4)sprites.MakeSprite(cloudsprite, position[i],velocity[i], terrainlight.x*90/255,terrainlight.y*70/255,terrainlight.z*8/255, .5, .5);
+ if(findDistancefast(&position[i],&viewer)<viewdistance*viewdistance/4)Sprite::MakeSprite(cloudsprite, position[i],velocity[i], terrainlight.x*90/255,terrainlight.y*70/255,terrainlight.z*8/255, .5, .5);
}
else if(environment==desertenvironment){
- if(findDistancefast(&position[i],&viewer)<viewdistance*viewdistance/4)sprites.MakeSprite(cloudsprite, position[i],velocity[i], terrainlight.x*190/255,terrainlight.y*170/255,terrainlight.z*108/255, .5, .7);
+ if(findDistancefast(&position[i],&viewer)<viewdistance*viewdistance/4)Sprite::MakeSprite(cloudsprite, position[i],velocity[i], terrainlight.x*190/255,terrainlight.y*170/255,terrainlight.z*108/255, .5, .7);
}
bloody[i]=0;
XYZ terrainlight;
terrainlight=terrain.getLighting(position[i].x,position[i].z);
if(environment==snowyenvironment){
- if(findDistancefast(&position[i],&viewer)<viewdistance*viewdistance/4)sprites.MakeSprite(cloudsprite, position[i],velocity[i], terrainlight.x,terrainlight.y,terrainlight.z, .5, .7);
+ if(findDistancefast(&position[i],&viewer)<viewdistance*viewdistance/4)Sprite::MakeSprite(cloudsprite, position[i],velocity[i], terrainlight.x,terrainlight.y,terrainlight.z, .5, .7);
}
else if(environment==grassyenvironment){
- if(findDistancefast(&position[i],&viewer)<viewdistance*viewdistance/4)sprites.MakeSprite(cloudsprite, position[i],velocity[i], terrainlight.x*90/255,terrainlight.y*70/255,terrainlight.z*8/255, .5, .5);
+ if(findDistancefast(&position[i],&viewer)<viewdistance*viewdistance/4)Sprite::MakeSprite(cloudsprite, position[i],velocity[i], terrainlight.x*90/255,terrainlight.y*70/255,terrainlight.z*8/255, .5, .5);
}
else if(environment==desertenvironment){
- if(findDistancefast(&position[i],&viewer)<viewdistance*viewdistance/4)sprites.MakeSprite(cloudsprite, position[i],velocity[i], terrainlight.x*190/255,terrainlight.y*170/255,terrainlight.z*108/255, .5, .7);
+ if(findDistancefast(&position[i],&viewer)<viewdistance*viewdistance/4)Sprite::MakeSprite(cloudsprite, position[i],velocity[i], terrainlight.x*190/255,terrainlight.y*170/255,terrainlight.z*108/255, .5, .7);
}
}
}
XYZ terrainlight;
terrainlight=terrain.getLighting(tippoint[i].x,tippoint[i].z);
if(environment==snowyenvironment){
- if(findDistancefast(&tippoint[i],&viewer)<viewdistance*viewdistance/4)sprites.MakeSprite(cloudsprite, tippoint[i],tipvelocity[i], terrainlight.x,terrainlight.y,terrainlight.z, .5, .7);
+ if(findDistancefast(&tippoint[i],&viewer)<viewdistance*viewdistance/4)Sprite::MakeSprite(cloudsprite, tippoint[i],tipvelocity[i], terrainlight.x,terrainlight.y,terrainlight.z, .5, .7);
}
else if(environment==grassyenvironment){
- if(findDistancefast(&tippoint[i],&viewer)<viewdistance*viewdistance/4)sprites.MakeSprite(cloudsprite, tippoint[i],tipvelocity[i], terrainlight.x*90/255,terrainlight.y*70/255,terrainlight.z*8/255, .5, .5);
+ if(findDistancefast(&tippoint[i],&viewer)<viewdistance*viewdistance/4)Sprite::MakeSprite(cloudsprite, tippoint[i],tipvelocity[i], terrainlight.x*90/255,terrainlight.y*70/255,terrainlight.z*8/255, .5, .5);
}
else if(environment==desertenvironment){
- if(findDistancefast(&tippoint[i],&viewer)<viewdistance*viewdistance/4)sprites.MakeSprite(cloudsprite, tippoint[i],tipvelocity[i], terrainlight.x*190/255,terrainlight.y*170/255,terrainlight.z*108/255, .5, .7);
+ if(findDistancefast(&tippoint[i],&viewer)<viewdistance*viewdistance/4)Sprite::MakeSprite(cloudsprite, tippoint[i],tipvelocity[i], terrainlight.x*190/255,terrainlight.y*170/255,terrainlight.z*108/255, .5, .7);
}
}
}
bloodloc.y-=.05;
if(bloodtoggle){
bloodvel=0;
- sprites.MakeSprite(bloodsprite, bloodloc,bloodvel, 1,1,1, .03, 1);
+ Sprite::MakeSprite(bloodsprite, bloodloc,bloodvel, 1,1,1, .03, 1);
}
}
}
normalrot.y=1;
}
}
- sprites.MakeSprite(weaponflamesprite, position[i]+tippoint[i]*(((float)abs(Random()%100))/600+.05),normalrot, 1,1,1, (.6+(float)abs(Random()%100)/200-.25)*1/3, 1);
- sprites.speed[sprites.numsprites-1]=4;
- sprites.alivetime[sprites.numsprites-1]=.3;
+ Sprite::MakeSprite(weaponflamesprite, position[i]+tippoint[i]*(((float)abs(Random()%100))/600+.05),normalrot, 1,1,1, (.6+(float)abs(Random()%100)/200-.25)*1/3, 1);
+ Sprite::setLastSpriteSpeed(4);
+ Sprite::setLastSpriteAlivetime(.3);
}
}
if(Random()%50==0&&findDistancefast(&position[i],&viewer)>80){
XYZ shinepoint;
shinepoint=position[i]+(tippoint[i]-position[i])*(((float)abs(Random()%100))/100);
- sprites.MakeSprite(weaponshinesprite, shinepoint,normalrot, 1,1,1, (.1+(float)abs(Random()%100)/200-.25)*1/3*fast_sqrt(findDistance(&shinepoint,&viewer)), 1);
- sprites.speed[sprites.numsprites-1]=4;
- sprites.alivetime[sprites.numsprites-1]=.3;
+ Sprite::MakeSprite(weaponshinesprite, shinepoint,normalrot, 1,1,1, (.1+(float)abs(Random()%100)/200-.25)*1/3*fast_sqrt(findDistance(&shinepoint,&viewer)), 1);
+ Sprite::setLastSpriteSpeed(4);
+ Sprite::setLastSpriteAlivetime(.3);
}
}
}
XYZ nothingpoint;
nothingpoint=0;
shinepoint=position[i];
- sprites.MakeSprite(weaponshinesprite, shinepoint,nothingpoint, 1,1,1,multiplier*2, 1);
- sprites.speed[sprites.numsprites-1]=4;
- sprites.alivetime[sprites.numsprites-1]=.3;
+ Sprite::MakeSprite(weaponshinesprite, shinepoint,nothingpoint, 1,1,1,multiplier*2, 1);
+ Sprite::speed[Sprite::numsprites-1]=4;
+ Sprite::alivetime[Sprite::numsprites-1]=.3;
shinepoint=tippoint[i];
- sprites.MakeSprite(weaponshinesprite, shinepoint,nothingpoint, 1,1,1,multiplier*2, 1);
- sprites.speed[sprites.numsprites-1]=4;
- sprites.alivetime[sprites.numsprites-1]=.3;*/
+ Sprite::MakeSprite(weaponshinesprite, shinepoint,nothingpoint, 1,1,1,multiplier*2, 1);
+ Sprite::speed[Sprite::numsprites-1]=4;
+ Sprite::alivetime[Sprite::numsprites-1]=.3;*/
}
}
return 0;
#include "Models.h"
#include "Constants.h"
#include "Terrain.h"
-#include "Sprites.h"
+#include "Sprite.h"
#include "Person.h"
#include <cmath>
void CopyCStringToPascal( const char* src, unsigned char dst[256])
{
int len = strlen( src);
- dst[ 0] = len;
+ dst[0] = len;
memcpy( dst + 1, src, len);
}
void CopyPascalStringToC( const unsigned char* src, char* dst)
{
- int len = src[ 0];
+ int len = src[0];
memcpy( dst, src + 1, len);
- dst[ len] = 0;
+ dst[len] = 0;
}
typedef bool Boolean;
-
struct Point
{
short v;
char* ConvertFileName( const char* orgfilename, const char* junk);
-#define fopen( a, b) fopen( ConvertFileName( a), b);
+#define fopen(a, b) fopen(ConvertFileName(a), b);
-inline float abs( float f)
+inline float abs(float f)
{
if (f < 0)
return -f;
return f;
}
-inline double abs( double f)
+inline double abs(double f)
{
if (f < 0)
return -f;
#include "GL/glext.h"
#include "MacCompatibility.h"
-#if !PLATFORM_MACOSX
-struct RGBColor
-{
- unsigned short red;
- unsigned short green;
- unsigned short blue;
-};
-typedef struct RGBColor RGBColor;
-typedef RGBColor * RGBColorPtr;
-#endif
-
using namespace std;
/* !!! FIXME: until we replace logger better. --ryan. */
+++ /dev/null
-/*
-Copyright (C) 2003, 2010 - Wolfire Games
-
-This file is part of Lugaru.
-
-Lugaru is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-
-See the GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-/*
- * Copyright (c) 2002 Lane Roathe. All rights reserved.
- * Developed in cooperation with Freeverse, Inc.
- *
- * @APPLE_LICENSE_HEADER_START@
- *
- * Portions Copyright (c) 1999-2002 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
- *
- * The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
- * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
- * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
- *
- * @APPLE_LICENSE_HEADER_END@
- *
- * Modified: $Date: 2002/04/27 21:42:01 $
- * Revision: $Id: nsp_network.c,v 1.1 2002/04/27 21:42:01 lane Exp $
- */
-
-/* NOTES:
-
- - This example is designed so that all networking code is in this one file. The purpose is to make
- it easier for a programmer to study the basic use of OpenPlay's NetSprocket API and not to
- demonstrate good programming style or OOP practices.
-
- - This file is not game independent (hey, that's what OpenPlay is about!), it simply helped me keep
- the example use of NetSprocket's more managable ... I hope :)
-
- - I wanted the host (ie, server) to also be a player, and found it was pretty easy to do; I simply
- made sure that I tracked whether I was a server or client (see the _server variable in main.h) and
- then when sending all players a message I had to modify the "to" portion of the header and
- resend it to the host. This means the host is sending itself messages, which works great.
-
-*/
-
-/* ----------------------------------------------------------- Includes */
-
-#include <ctype.h>
-#include <stdio.h>
-#include <time.h>
-#include <string.h>
-#include <stdlib.h>
-
-#include "main.h"
-
-#include "network.h"
-
-/* ----------------------------------------------------------- Macro definitions */
-
-enum
-{
- kMessageType_Question = 256,
- kMessageType_Answer,
-
- kMessageType_Information
-};
-
-#define kPlayerType 1234 /* just defines a way to allow/reject players of different types */
-
-
-/* ----------------------------------------------------------- Type definitions */
-
-/* Questions are sent out in message packets from server to players */
-
-/* NOTE Message string is ZERO terminated! */
-/* This allows us to strcpy, strcmp, etc. on raw packet data */
-/* Meaning packet size = sizeof(packet_t) + strlen(string) */
-
-typedef struct
-{
- NSpMessageHeader header;
-
- char str[1]; /* message (question, info, etc) string */
-
-}MessagePacket_t, *MessagePacketPtr;
-
-/* Answers are sent from the players to the server in this packet */
-
-typedef struct
-{
- NSpMessageHeader header;
-
- char answer; /* finally, the answer */
-
-}AnswerPacket_t, *AnswerPacketPtr;
-
-/* ----------------------------------------------------------- Local Variables */
-
-/* name of this version of the app*/
-char *GameNameStr = "OpenPlay NSp API Example 1";
-
-/* Local vars used to handle our interaction with OpenPlay's NetSprockets API */
-
-static NSpGameReference _gameReference = NULL; /* general game info */
-static NSpProtocolListReference _protocolListRef = NULL; /* list of protocols we've started up */
-
-static NMBoolean _approved; /* after requesting to join a new game, this tracks whether or not we were approved */
-static NMBoolean _response; /* true if we get a response following a request to join a new game (else we time out */
-
-/*--------------------------------------------------------------------------------*/
-/*--------------------------------------------------------------------------------*/
-#if __MWERKS__
- #pragma mark -
- #pragma mark È Local Routines
- #pragma mark -
-#endif
-
-
-/*--------------------------------------------------------------------------------*/
-/*--------------------------------------------------------------------------------*/
-#if __MWERKS__
- #pragma mark -
- #pragma mark È Global Routines
- #pragma mark -
-#endif
-
-unsigned char *GameC2PStr
-(
- char *s, /* source C string */
- unsigned char *d /* destination buffer for Pascal string */
-)
-{
- int c = 0;
-
- if( s && d ) /* make sure we got got inputs */
- {
- while( *s )
- d[++c] = (unsigned char)*s++; /* no blockmove, copy & get length in one shot */
- }
- *d = (unsigned char)c;
-
- return( d );
-}
-
-char *GameP2CStr
-(
- unsigned char *s, /* source Pascal string */
- char *d /* buffer to hold converted C string */
-)
-{
- if( s && d )
- {
- memcpy( d, s+1, *s ); /* pretty simple */
- d[*s] = 0;
- }
- return( d );
-}
-
-/* ================================================================================
- Handle all of the network messages that are sent to this application
-
- EXIT: 0 == no error, else error code
-*/
-
-void NetworkHandleMessage( void )
-{
- NSpMessageHeader *mhp;
- char str[256]; /* buffer for converted PStrings */
-
- /* Ask NetSprocket to give us a message if any are waiting */
-
- mhp = NSpMessage_Get( _gameReference );
- if( mhp )
- {
- /* Print out the type of message received */
-
- switch(mhp -> what)
- {
-
-/* --- Handle NetSprocket's generic messages */
-
- case kNSpJoinApproved:
- printf( "Approved!\n\n", str );
- fflush(stdout);
- _response = true;
- _approved = true; /* tell our waiting loop that we were approved */
-#if __USE_SIOUX__
- {
- NMErr err;
-
- err = NSpGame_GetInfo( _gameReference, &gameInfo );
- if( !err )
- SIOUXSetTitle( gameInfo.name );
- }
-#endif
- break;
-
- case kNSpJoinDenied:
- GameP2CStr( ((NSpJoinDeniedMessage *)mhp)->reason, str );
- printf( "Denied!\n Reason: %s\n\n", str );
- fflush(stdout);
- //GameOver();
-
- _response = true;
- _approved = false; /* tell our waiting loop we were denied */
- break;
-
- case kNSpError:
- printf( "*** ERROR *** (reported value: %d)\n\n", ((NSpErrorMessage *)mhp)->error );
- fflush(stdout);
-
- _response = true;
- _approved = false;
- break;
-
- case kNSpGameTerminated:
- printf( "--- Host Terminated Game ---\n\n" );
- fflush(stdout);
- //GameOver();
-
- _response = true;
- _approved = false;
- break;
-
- case kNSpPlayerJoined:
- {
- NSpGameInfo gameInfo;
- char gamename[256];
- NMErr err;
-
- err = NSpGame_GetInfo( _gameReference, &gameInfo );
- if( !err )
- GameP2CStr( gameInfo.name, gamename );
- else
- strcpy( gamename, "ERRROR" );
-
- GameP2CStr( ((NSpPlayerJoinedMessage *)mhp)->playerInfo.name, str );
- printf( "===> Player %s joined game '%s', %d players now!\n\n",
- str, gamename, ((NSpPlayerJoinedMessage *)mhp)->playerCount );
- fflush(stdout);
-
- /* Lets go ahead and re-send the current question, as the new guy deserves a shot at it too */
- /*if( GameIsHost() )
- {
- //QuestionPtr theQuestion = GameGetCurrentQuestion();
- //if (theQuestion)
- // NetworkSendQuestion(theQuestion->question);
- }*/
- }
- break;
-
- case kNSpPlayerLeft:
- GameP2CStr( ((NSpPlayerLeftMessage *)mhp)->playerName, str );
- printf( "===> Player, %s, Left game, leaving %d players!\n\n",
- str, ((NSpPlayerLeftMessage *)mhp)->playerCount );
- fflush(stdout);
- break;
-
- case kNSpHostChanged:
- printf( "===> ??? Host changed to player ID %d\n\n",
- ((NSpHostChangedMessage *)mhp)->newHost );
- fflush(stdout);
- break;
-
- case kNSpGroupCreated:
- printf( "===> Player #%d created a new Group, ID %d\n\n",
- ((NSpCreateGroupMessage *)mhp)->requestingPlayer, ((NSpCreateGroupMessage *)mhp)->groupID );
- fflush(stdout);
- break;
-
- case kNSpGroupDeleted:
- printf( "===> Player #%d deleted group #%d\n\n",
- ((NSpDeleteGroupMessage *)mhp)->requestingPlayer, ((NSpDeleteGroupMessage *)mhp)->groupID );
- fflush(stdout);
- break;
-
- case kNSpPlayerAddedToGroup:
- printf( "===> Player %d was added to group %d\n\n",
- ((NSpAddPlayerToGroupMessage *)mhp)->player, ((NSpAddPlayerToGroupMessage *)mhp)->group );
- fflush(stdout);
- break;
-
- case kNSpPlayerRemovedFromGroup:
- printf( "===> Player %d was removed from group %d\n\n",
- ((NSpRemovePlayerFromGroupMessage *)mhp)->player, ((NSpRemovePlayerFromGroupMessage *)mhp)->group );
- fflush(stdout);
- break;
-
- case kNSpPlayerTypeChanged:
- printf( "===> Player %d changed to a new type, %d\n\n",
- ((NSpPlayerTypeChangedMessage *)mhp)->player, ((NSpPlayerTypeChangedMessage *)mhp)->newType );
- break;
-
-
-/* --- Handle our game specific messages */
-
-
- /* Got a message, see if it is correct or not and let everyone know the results */
-
- case kMessageType_Answer:
- {
- NSpPlayerInfoPtr pip;
- char cname[kNSpStr32Len];
- NMErr err;
-
- err = NSpPlayer_GetInfo( _gameReference, mhp->from, &pip );
- if( !err )
- {
- GameP2CStr( pip->name, cname );
-
- NSpPlayer_ReleaseInfo( _gameReference, pip );
- }
- else
- strcpy( cname, "UNKOWN -- error!" );
-
- //sprintf( str, "Player #%d, %s, answered with '%c', which is %s", mhp->from, cname, ((AnswerPacketPtr)mhp)->answer,
- //GameCheckAnswer( ((AnswerPacketPtr)mhp)->answer ) ? "Correct!" : "WRONG!" );
-
- NetworkSendInformation( str );
- }
- break;
-
- /* allow game to do any special processing needed when a question arrives */
-
- case kMessageType_Question:
- //GameDisplayQuestion( ((MessagePacketPtr)mhp)->str );
- break;
-
- /* pretty simple, just display the info message */
-
- case kMessageType_Information:
- printf( "%s\n\n", ((MessagePacketPtr)mhp)->str );
- fflush(stdout);
- break;
-
- default:
- break;
- }
-
- /* Once done with it, release the message */
-
- NSpMessage_Release( _gameReference, mhp );
- }
-}
-
-/* ================================================================================
- Return the # of players in the current game
-
- EXIT: none
-*/
-
-NMUInt32 NetworkGetPlayerCount( void )
-{
- NSpGameInfo gameInfo;
- NMErr err;
-
- err = NSpGame_GetInfo( _gameReference, &gameInfo ); /* player count is in the game info record */
- if( !err )
- {
- return( gameInfo.currentPlayers );
- }
-
- return( 0 );
-}
-
-/* ================================================================================
- Send an answer to the server
-
- EXIT: none
-*/
-
-NMErr NetworkSendAnswer
-(
- char answer /* the answer to send (just a char!) */
-)
-{
- AnswerPacket_t answerPacket;
- NMErr err;
-
- /* init the NetSprocket portion of the packet */
-
- NSpClearMessageHeader( &answerPacket.header );
-
- answerPacket.header.what = kMessageType_Answer;
- answerPacket.header.to = kNSpHostOnly;
- answerPacket.header.messageLen = sizeof(answerPacket);
-
- /* fill in the data section */
-
- answerPacket.answer = answer;
-
- /* tell NetSprocket to send the message */
-
- err = NSpMessage_Send( _gameReference, &answerPacket.header, kNSpSendFlag_Registered );
- if( err )
- {
- printf( "*** ERROR *** Unable to send answer packet, error # %d\n\n", err );
- fflush(stdout);
- }
-
- return( err );
-}
-
-/* ================================================================================
- Send a message to all players
-
- EXIT: none
-*/
-
-NMErr NetworkSendPlayerMessage
-(
- const char *message, /* ptr to message string to send */
- NMUInt32 messageType /* type of message (question, info, etc. */
-)
-{
- MessagePacketPtr qpp;
- unsigned long messageLen, size;
- NMErr err;
-
- /* sanity checks */
-
- if( !message )
- return( kNSpInvalidParameterErr );
-
- /* get size of message string & total size of network packet */
-
- messageLen = strlen( message );
- size = sizeof(MessagePacket_t) + messageLen + 1; /* header + num_chars + terminator */
-
- /* allocate the memory for the packet */
-
- qpp = (MessagePacketPtr)malloc( size );
- if( !qpp )
- {
- printf( " *** ERROR *** Unable to allocate message buffer!\n\n" );
- fflush(stdout);
- return( kNSpMemAllocationErr );
- }
-
- /* init the NetSprocket portion of the packet */
-
- NSpClearMessageHeader( &qpp->header );
-
- qpp->header.what = (NMSInt32)messageType;
- qpp->header.to = kNSpAllPlayers;
- qpp->header.messageLen = size;
-
- /* fill in the data section */
-
- strcpy( qpp->str, message );
-
- /* tell NetSprocket to send the message */
-
- err = NSpMessage_Send( _gameReference, &qpp->header, kNSpSendFlag_Registered );
- if( !err )
- {
- qpp->header.to = kNSpHostOnly; /* allow host to play as well! */
-
- err = NSpMessage_Send( _gameReference, &qpp->header, kNSpSendFlag_Registered );
- }
-
- if( err )
- {
- printf( "*** ERROR *** Unable to send message packet, error # %d\n\n", err );
- fflush(stdout);
- }
-
- /* clean up after ourselves! */
-
- free( qpp );
-
- return( err );
-}
-
-/* ================================================================================
- Send a question to all players
-
- EXIT: none
-*/
-
-NMErr NetworkSendQuestion
-(
- const char *question /* ptr to question string to send */
-)
-{
- return( NetworkSendPlayerMessage( question, kMessageType_Question ) );
-}
-
-/* ================================================================================
- Send information to all players
-
- EXIT: none
-*/
-
-NMErr NetworkSendInformation
-(
- const char *message /* ptr to information string to send */
-)
-{
- return( NetworkSendPlayerMessage( message, kMessageType_Information ) );
-}
-
-#if __MWERKS__
- #pragma mark -
-#endif
-
-/* ================================================================================
- Initialize server networking
-
- EXIT: 0 == no error, else error code
-*/
-
-NMErr NetworkStartServer
-(
- NMUInt16 port, /* port clients will connect on */
- NMUInt32 maxPlayers, /* max # of players to allow into game */
- const unsigned char *gameName, /* name of game (displayed to clients on connect) */
- const unsigned char *playerName /* name of player on server computer */
-)
-{
- NSpProtocolReference protocolRef;
- NMErr err;
-
- /* Create a new protocol list to store our IP protocol reference in */
-
- err = NSpProtocolList_New( NULL, &_protocolListRef );
- if( !err )
- {
- /* Create a protocol reference for our IP connection, on our specified port w/default maxRTT and throughput */
-
- protocolRef = NSpProtocol_CreateIP( port, 0, 0 );
- if( protocolRef )
- {
- /* We got a good reference, append it to the list we created earlier */
-
- err = NSpProtocolList_Append( _protocolListRef, protocolRef );
- if( !err )
- {
- /* We got a protocol and it's in our reference list, now we can create the game
- to host, using the parms sent in and defaulting rest of the "unused" hosting parms */
-
- err = NSpGame_Host( &_gameReference, _protocolListRef, maxPlayers, gameName,
- "\pPassword", playerName, kPlayerType, kNSpClientServer, 0 );
- }
- }
- else
- err = kNSpInvalidProtocolRefErr; /* assign somewhat meaningful error on failure to create protocol reference */
- }
-
- return( err );
-}
-
-
-/* ================================================================================
- Shutdown the networking, release resources, etc.
-
- EXIT: 0 == no error, else error code
-*/
-
-NMErr NetworkStartClient
-(
- char *ipAddr, /* IP address (or domain name) to look for server (host) on */
- char *port, /* Port to talk to server via */
- const unsigned char *playerName /* name of player wanting to join */
-)
-{
- NSpAddressReference addRef;
- NMErr err;
-
- /* Given our input strings, create an OpenPlay address reference for talking to server */
-
- addRef = NSpCreateIPAddressReference( ipAddr, port );
- if( addRef )
- {
- printf( "\nAttempting to join game..." );
- fflush(stdout);
-
- /* Now, look for a server on the IP/Port given and see if we can connect */
-
- err = NSpGame_Join( &_gameReference, addRef, playerName, "\pPassword", kPlayerType, NULL, 0, 0 );
- if( !err )
- {
- NMUInt32 startTime, currentTime;
- time_t seconds;
-
- printf( "connected!\n\nWaiting for approval to join game (press 'q' to quit)..." );
- fflush(stdout);
-
- time(&seconds);
- startTime = seconds;
-
- _response = _approved = false;
-
- /* We connected, now we have to wait for the server to approve our join request */
-
- while( !_response )
- {
- /* Check for a time out in connecting to server */
- /* this is before the event handler so that we are not approved, but time out anyway (small chance, but...) */
-
- time(&seconds);
- currentTime = seconds;
-
- if( (currentTime - startTime > 60) && (!_response) )
- {
- printf( "ERROR: Connection timed out!\n\n" );
- fflush(stdout);
-
- _response = true;
- _approved = false;
- }
-
- /* Handle system messages and allow user to quit via 'q' */
- /* This also gets and handles network messages, like accept/deny */
-
- //GameHandleEvents();
- }
-
- /* if we were not approved, we must dispose of the game object here */
-
- if( !_approved )
- {
- err = NSpGame_Dispose( _gameReference, kNSpGameFlag_ForceTerminateGame );
- _gameReference = NULL;
- }
- else /* let the user know that they were accepted to the game */
- {
- NSpGameInfo gameInfo;
- char str[256];
-
- err = NSpGame_GetInfo( _gameReference, &gameInfo );
- if( !err )
- {
- GameP2CStr( gameInfo.name, str );
-
- printf( " Welcome to the game '%s', with %d players\n\n", str, (int)gameInfo.currentPlayers );
- fflush(stdout);
- }
- }
- }
- }
- else
- err = kNMParameterErr;
-
- return( err );
-}
-
-
-#if __MWERKS__
- #pragma mark -
-#endif
-
-/* ================================================================================
- Shutdown the networking, release resources, etc.
-
- EXIT: 0 == no error, else error code
-*/
-
-NMErr NetworkShutdown( void )
-{
- NMUInt32 refCount;
- NMErr err = kNMNoError;
-
- /* if we have a game object (we should!) dispose if it now */
-
- if( _gameReference )
- err = NSpGame_Dispose( _gameReference, kNSpGameFlag_ForceTerminateGame );
-
- /* dispose of our protocol references & the list containing them */
-
- if( _protocolListRef )
- {
- NSpProtocolReference pRef;
-
- refCount = NSpProtocolList_GetCount( _protocolListRef ); /* get number of protocols */
-
- while( refCount-- && !err )
- {
- pRef = NSpProtocolList_GetIndexedRef( _protocolListRef, refCount ); /* get currect reference */
-
- err = NSpProtocolList_RemoveIndexed( _protocolListRef, refCount ); /* then remove it from the list */
-
- /* now, we can dispose of the reference safely */
- NSpProtocol_Dispose( pRef ); /* this should have an NMErr return, but has a void return... */
- }
-
- /* once all of the protocols are disposed, we can dispose of the containing reference list */
- NSpProtocolList_Dispose( _protocolListRef );
- }
-
-
- /* Make sure we can't use old values */
-
- _protocolListRef = NULL;
- _gameReference = NULL;
-
- return( err );
-}
-
-/* ================================================================================
- Startup the networking system (NetSprockets in this case)
-
- EXIT: 0 == no error, else error code
-*/
-
-NMErr NetworkStartup( void )
-{
- NMErr err;
-
- /* First, make sure that NetSprockets is available (we weak linked to OpenPlayStubLib) */
-
- if( NULL == NSpInitialize ) /*|| NULL == ProtocolAcceptConnection )*/
- return( errModuleNotFound );
-
- /* Initialize NetSprockets, 0 == use defaults & NSe1 stands for "NetSprocket Example 1"
- It is an identifier for games of our type on the network */
-
- err = NSpInitialize( 0, 0, 0, 'NSe1', 0 );
-
- return( err );
-}
char *fname = (char *) alloca(strlen(_fname) + 16);
strcpy(fname, _fname);
char *ptr = strchr(fname, '.');
- if (ptr) *ptr = NULL;
+ if (ptr) *ptr = '\0';
strcat(fname, ".ogg");
// just in case...