Partikelfunktionen

Indem man das in atypes.h definierte PARTICLE-Strukt benutzt, lassen sich DLL-Funktionen auch für Partikel verwenden. Sie können auf ähnliche Weise wie C-Skript-definierte Partikelfunktionen angewandt werden. Ein Pointer auf den Partikel ist das alleinige Argument für eine DLL-Partikelfunktion. Beispiel:

// example for a particle effect function
// start the particle effect by
// effect(DLLEffect_Explo,1000,my.x,NULL);

void Particle_Alphafade(PARTICLE *p)
{
// fade out, and kill the particle when it's totally translucent
	p->alpha -= v(time_step) * 4;
	if (p->alpha <= 0) p->lifespan = 0;
}

DLLFUNC void DLLEffect_Explo(PARTICLE *p)
{
// load a particle bmap - use 'static' for creating it only once
	static BMAP *bmap = bmap_create("blitz.tga");
	p->bmap = bmap;

// internal flags are already set, use |= for setting flags
	p->flags |= BEAM|MOVE|BRIGHT|TRANSLUCENT;
	
// some random start values for speed and alpha
	p->vel_x = random(_VAR(10)) - _VAR(5);
	p->vel_y = random(_VAR(10)) - _VAR(5);
	p->vel_z = random(_VAR(10)) - _VAR(5);
	p->alpha = _VAR(50) + random(_VAR(50));

// change the particle function
	p->event = (EVENT)Particle_Alphafade;
}

Beachten Sie, wie Sie ein Event direkt auf eine externe DLL-Funktion setzen können. Achten Sie jedoch darauf, dass die Zuweisung externer Funktionen nicht per game_save-Anweisung gespeichert wird. Dies ist für eine Partikelfunktion egal, wenn Sie aber einmal einer Entity oder einem Schlüsselevent eine externe Funktion zugewiesen haben, behalten Sie sie wie sie ist und ändern Sie sie danach nicht mehr.

► Aktuelle Version Online