FadeDelay for longer-lasting particles

stable-5.2
Tobias Zwick 2009-07-15 15:41:03 +02:00
parent 1bb6778403
commit 10e6174b1f
4 changed files with 20 additions and 8 deletions

View File

@ -137,7 +137,12 @@
<row>
<col>AlphaFade</col>
<col>Integer</col>
<col>0 bis 40. Ausfaden pro Frame. Wenn das Partikel vollends ausgefadet ist, verschwindet es.</col>
<col>0 bis 40. Ausfaden pro FadeDelay. Wenn das Partikel vollends ausgefadet ist, verschwindet es.</col>
</row>
<row>
<col>FadeDelay</col>
<col>Integer</col>
<col>Default ist 1.</col>
</row>
<row>
<col>Parallaxity</col>

View File

@ -73,7 +73,8 @@ class C4ParticleDefCore
int32_t VertexY; // y-offset of vertex; 100 is object height
int32_t Additive; // whether particle should be drawn additively
int32_t Attach; // whether the particle moves relatively to the target
int32_t AlphaFade; // fadeout in each frame
int32_t AlphaFade; // fadeout in each* frame
int32_t FadeDelay; // *each = well, can be redefined here. Standard is 1
int32_t Parallaxity [2]; // parallaxity
StdStrBuf InitFn; // proc to be used for initialization

View File

@ -58,6 +58,7 @@ void C4ParticleDefCore::CompileFunc(StdCompiler * pComp)
pComp->Value(mkNamingAdapt(VertexY, "VertexY", 0));
pComp->Value(mkNamingAdapt(Additive, "Additive", 0));
pComp->Value(mkNamingAdapt(AlphaFade, "AlphaFade", 0));
pComp->Value(mkNamingAdapt(FadeDelay, "FadeDelay", 0));
pComp->Value(mkNamingAdapt(mkArrayAdaptDM(Parallaxity,100),"Parallaxity"));
pComp->Value(mkNamingAdapt(Attach, "Attach", 0));
}
@ -74,7 +75,8 @@ C4ParticleDefCore::C4ParticleDefCore():
VertexCount(0),VertexY(0),
Additive(0),
Attach(0),
AlphaFade(0)
AlphaFade(0),
FadeDelay(0)
{
GfxFace.Default();
Parallaxity[0] = Parallaxity[1] = 100;
@ -703,11 +705,14 @@ bool fxStdExec(C4Particle *pPrt, C4Object *pTarget)
if (iFade < 0) if (Game.FrameCounter % -iFade == 0) iFade = 1; else iFade = 0;
if (iFade)
{
DWORD dwClr=pPrt->b;
int32_t iAlpha=dwClr>>24;
iAlpha+=pPrt->pDef->AlphaFade;
if (iAlpha>=0xff) return false;
pPrt->b=(dwClr&0xffffff) | (iAlpha<<24);
if(pPrt->pDef->FadeDelay == 0 || Game.FrameCounter % pPrt->pDef->FadeDelay == 0)
{
DWORD dwClr=pPrt->b;
int32_t iAlpha=dwClr>>24;
iAlpha+=pPrt->pDef->AlphaFade;
if (iAlpha>=0xff) return false;
pPrt->b=(dwClr&0xffffff) | (iAlpha<<24);
}
}
// if delay is given, advance lifetime
if (pPrt->pDef->Delay)

View File

@ -8,3 +8,4 @@ Face=0,0,64,64,-32,-32
Delay=0
Repeats=1
AlphaFade=1
FadeDelay=3