diff options
Diffstat (limited to 'src/Sprites.cpp')
-rw-r--r-- | src/Sprites.cpp | 54 |
1 files changed, 25 insertions, 29 deletions
diff --git a/src/Sprites.cpp b/src/Sprites.cpp index 9bf307d..ef60a7d 100644 --- a/src/Sprites.cpp +++ b/src/Sprites.cpp @@ -35,7 +35,7 @@ int Sprites::MakeSprite(int atype, float abrightness, float acolor1, float acolo alivetime[howmanysprites]=0; owner[howmanysprites]=0; if(howmanysprites<maxsprites){howmanysprites++;} - + return 0; } @@ -56,7 +56,7 @@ int Sprites::MakeSprite(int atype, float abrightness, float acolor1, float acolo alivetime[howmanysprites]=0; owner[howmanysprites]=aowner; if(howmanysprites<maxsprites){howmanysprites++;} - + return 0; } @@ -76,10 +76,10 @@ int Sprites::DeleteSprite(int which){ rotation[which]=rotation[howmanysprites-1]; type[which]=type[howmanysprites-1]; type[howmanysprites-1]=0; - + if(howmanysprites>0){howmanysprites--;} } - + return 0; } @@ -118,7 +118,6 @@ void Sprites::LoadBulletTexture(char *fileName) bullettextureptr = loadTexture(fileName); } - void Sprites::DoStuff() { for(int i=0;i<howmanysprites;i++){ @@ -146,14 +145,14 @@ void Sprites::DoStuff() if(type[i]==bloodspritedown||type[i]==particlesspritedown){ velocity[i].y+=gravity*multiplier; } - + if(type[i]!=bulletinstant&&type[i]!=bullet)location[i]=location[i]+velocity[i]*multiplier; - + alivetime[i]+=multiplier; if(brightness[i]<=0)DeleteSprite(i); if(type[i]==snowsprite&&(location[i].y<-.1||environment!=snowy_environment))DeleteSprite(i); if(type[i]==rainsprite&&(location[i].y<-.1||environment!=rainy_environment))DeleteSprite(i); - + if(type[i]==snowsprite){ if(location[i].x<camera.position.x-precipitationhorz){location[i].x+=precipitationhorz*2;} if(location[i].z<camera.position.z-precipitationhorz){location[i].z+=precipitationhorz*2;} @@ -181,9 +180,9 @@ void Sprites::draw() float bulletsize; XYZ point; glAlphaFunc(GL_GREATER, 0.01); - + //glEnable(GL_POLYGON_OFFSET_FILL); - + glEnable(GL_BLEND); glDisable(GL_CULL_FACE); glEnable(GL_TEXTURE_2D); @@ -199,7 +198,7 @@ void Sprites::draw() if(type[i]==snowsprite){fog.ResetFog(); glBindTexture(GL_TEXTURE_2D, snowtextureptr);glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);} if(type[i]==rainsprite){fog.ResetFog(); glBindTexture(GL_TEXTURE_2D, raintextureptr);glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);} if(type[i]==bullet||type[i]==bulletinstant){fog.ResetFog(); glBindTexture(GL_TEXTURE_2D, bullettextureptr);glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);} - + glPushMatrix(); if(type[i]==muzzleflashsprite||type[i]==flashsprite||type[i]==smokesprite||type[i]==smokespritenoup||type[i]==snowsprite||type[i]==particlesspritedown||((type[i]==bloodspritenoup||type[i]==bloodspritedown)&&blood)){ glColor4f(color1[i]*fogcolorr*1.6,color2[i]*fogcolorg*1.6,color3[i]*fogcolorb*1.6,brightness[i]); @@ -214,7 +213,7 @@ void Sprites::draw() glLoadIdentity(); glTranslatef(point.x, point.y, point.z); glRotatef(rotation[i],0,0,1); - + glBegin(GL_TRIANGLES); glTexCoord2f(1.0f, 1.0f); glVertex3f( .3f*size[i], .3f*size[i], 0.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f(-.3f*size[i], .3f*size[i], 0.0f); @@ -223,23 +222,21 @@ void Sprites::draw() glTexCoord2f(1.0f, 0.0f); glVertex3f( .3f*size[i], -.3f*size[i], 0.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f(-.3f*size[i], .3f*size[i], 0.0f); glEnd(); - + } - + if(type[i]==rainsprite){ glColor4f(color1[i]*fogcolorr*1.6,color2[i]*fogcolorg*1.6,color3[i]*fogcolorb*1.6,brightness[i]); glTranslatef(location[i].x,location[i].y,location[i].z); glGetFloatv(GL_MODELVIEW_MATRIX,M); - for( int k=0; k<3; k+=2 ) + for( int k=0; k<3; k+=2 ) for( int j=0; j<3; j++ ) { if ( k==j ) M[k*4+j] = 1.0; else M[k*4+j] = 0.0; } - - - + glLoadMatrixf(M); glScalef(.2,abs(velocity[i].y)*multiplier,.2); glBegin(GL_TRIANGLES); @@ -251,7 +248,7 @@ void Sprites::draw() glTexCoord2f(0.0f, 1.0f); glVertex3f(-.3f*size[i], .3f*size[i], 0.0f); glEnd(); } - + if(type[i]==grenadesprite||type[i]==spoonsprite||type[i]==pinsprite){ glTranslatef(location[i].x,location[i].y+.2,location[i].z); glDisable(GL_BLEND); @@ -262,11 +259,11 @@ void Sprites::draw() glEnable(GL_COLOR_MATERIAL); glDepthMask(1); glRotatef(rotation[i],1,.6,.3); - + if(type[i]==grenadesprite)gunmodels[grenadebasemodel].draw(); if(type[i]==spoonsprite)gunmodels[grenadespoonmodel].draw(); if(type[i]==pinsprite)gunmodels[grenadepinmodel].draw(); - + glEnable(GL_BLEND); glDisable(GL_FOG); glDisable(GL_CULL_FACE); @@ -275,7 +272,7 @@ void Sprites::draw() glDisable(GL_COLOR_MATERIAL); glDepthMask(0); } - + if(type[i]==bullet||type[i]==bulletinstant){ bulletsize=size[i]; glPushMatrix(); @@ -296,15 +293,15 @@ void Sprites::draw() endProj.z=M[14]; glPopMatrix(); avgProj=(endProj+begProj)/2; - + dx = endProj.x - begProj.x; dy = endProj.y - begProj.y; oolen= 1/sqrt(dx*dx+dy*dy)*0.5; persp=0; persp.x=-dy*oolen; persp.y=dx*oolen; - + glColor4f(color1[i]*fogcolorr*1.6,color2[i]*fogcolorg*1.6,color3[i]*fogcolorb*1.6,brightness[i]); - + glPushMatrix(); glLoadIdentity(); glBegin(GL_TRIANGLES); @@ -316,15 +313,14 @@ void Sprites::draw() glTexCoord2f(1.0f, 1.0f); glVertex3f(endProj.x+persp.x*bulletsize/2, endProj.y+persp.y*bulletsize/2, endProj.z); glEnd(); glPopMatrix(); - glPopMatrix(); + glPopMatrix(); } glPopMatrix(); } - fog.ResetFog(); + fog.ResetFog(); glDepthMask(1); glDisable(GL_TEXTURE_2D); glEnable(GL_CULL_FACE); //glDisable(GL_POLYGON_OFFSET_FILL); - -} +} |