Пример #1
0
void C4Stat::Reset()
{
	iStartCalled = 0;

	tTimeSum = 0;
	iCount = 0;

	ResetPart();
}
Пример #2
0
int Fire::RenderParticles(VECTOR_CLASS* rminu,VECTOR_CLASS* rpluu,float processParts)
{
	VECTOR_CLASS startDiff=Vector(0,0,0);
	if(start)
		 startDiff = *start-lastStart;
	glDepthMask(GL_FALSE);
	int numRendered=0;
	//glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
	SetTexture1(game.Textures[PARTICLE]);
	glBegin(GL_QUADS);
	VECTOR_CLASS dl,dr,tr,tl;
	VECTOR_CLASS currPos;
	unsigned long currTick=GetTickCount();
	float difference=0;
	int suck=0;

	if(!processParts)
		lifeStart+=(currTick-LastTick);
	float globalFade=1-(float)(GetTickCount()-lifeStart)/(float)life;

	for(int a=0;a<numParticles;a++)
	{
		if(particles[a].state&STATE_ON)
		{
			if(processParts)
			{
				difference=(float)(currTick-particles[a].StartTick);
				if(difference>=particles[a].life)
				{
					ResetPart(a,0);
					continue;
				}
				if(particles[a].life)
					difference/=particles[a].life;
				particles[a].a=(unsigned char)(255-(unsigned char)(difference*255));
				particles[a].size=size*(1-difference);
				particles[a].pos+=particles[a].vel*g_speed;

				particles[a].counter+=0.05f*g_speed;
			}
			else		// Account for the paused time
				particles[a].StartTick+=(currTick-LastTick);

			particles[a].pos+=startDiff;
			currPos=particles[a].pos;

			numRendered++;
			glColor4ub((unsigned char)(particles[a].r*fadeIn),
						(unsigned char)(particles[a].g*fadeIn),
						(unsigned char)(particles[a].b*fadeIn),
						(unsigned char)(particles[a].a*fadeIn*globalFade));

			float x=particles[a].pos.x+sinf(particles[a].counter)*10;

			glTexCoord2f(1,0);	glVertex3f( x+particles[a].size, particles[a].pos.y+particles[a].size,10);
			glTexCoord2f(0,0);	glVertex3f( x-particles[a].size, particles[a].pos.y+particles[a].size,10);
			glTexCoord2f(0,1);	glVertex3f( x-particles[a].size, particles[a].pos.y-particles[a].size,10);
			glTexCoord2f(1,1);	glVertex3f( x+particles[a].size, particles[a].pos.y-particles[a].size,10);
		}
	}
	glEnd();
	LastTick=currTick;
	glDepthMask(GL_TRUE);

	if(start)	lastStart=*start;
	return numRendered;
}