SparrowParticles is a very basic, generic attempt for particles.
sparrowParticles | SparrowParticles is a very basic, generic attempt for particles. |
Types | |
spParticle | Struct for one partcle. |
Macros | |
Events for the particle bunch update function | |
Functions | |
spParticleCreate | Creates a bunch of a fixed number of particles. |
spParticleUpdate | Updates all particles of the particles bunch and connected bunches. |
spParticleDraw | Draws all particles of the particles bunch and connected bunches. |
spParticleDelete | Deletes all particles of the particles bunch and connected bunches. |
spParticleFromSprite | This special function creates a particle bunch out of a sprite. |
PREFIX spParticleBunchPointer spParticleCreate( int count, int ( *feedback )( spParticleBunchPointer bunch, Sint32 action, Sint32 extra_data), spParticleBunchPointer * addBunch )
Creates a bunch of a fixed number of particles. In every update or draw step the feedback function will be called ONCE for all particles of the bunch (which is faster than doing this for every particle).
count | number of particles. It is not possible to add particles later, but to create a new particle bunch and add it to this bunch (see last parameter) |
feedback | a feedback function, which shall have the parameters spParticleBunchPointer bunch, Sint32 action and Sint32 extra_data. The bunch is the bunch returned by this function, action tells the feedback function, what to do (see also Events for the particle bunch update function) and extra_data gives some extra data for some actions, e.g. the time since the last frame in ms if the action is SP_PARTICLE_UPDATE. |
addBunch | if not NULL, this new created particle bunch will be added to the given bunch. Usefull to keep your particle bunches in meta particle bunches and to call spParticleUpdate, spParticleDraw and spParticleDelete just once. |
Pointer of spParticleBunch | pointer to the created particle bunch, but be carful! The data are unset! It is up to you to fill the bunch with positions, velocities, colours and other metadata (see also spParticle)! |
PREFIX void spParticleUpdate( spParticleBunchPointer * firstBunch, int steps )
Updates all particles of the particles bunch and connected bunches. It does this by calling the feedback function of the bunches with the action SP_PARTICLE_UPDATE!
firstBunch | the first bunch to update it’s particles |
steps | the time since the last frame to pass to the feedback function |
PREFIX void spParticleDelete( spParticleBunchPointer * firstBunch )
Deletes all particles of the particles bunch and connected bunches. Right before deleting, it calls the feedback function one last time with the action SP_PARTICLE_CLEAN_UP, which tells the feedback function clean up stuff if necessary.
firstBunch | the first bunch to update it’s particles |
PREFIX spParticleBunchPointer spParticleFromSprite( spSpritePointer sprite, int ( *feedback )( spParticleBunchPointer bunch, Sint32 action, Sint32 extra_data), spParticleBunchPointer * addBunch )
This special function creates a particle bunch out of a sprite. Useful for sprites, which shall explode. Every particle stand for a pixel of the sprite.
sprite | spSpritePointer to use |
feedback | feedback function for this bunch. See alo spParticleCreate. |
addBunch | optional meta bunch to add this bunch to. See also spParticleCreate. |
Pointer of spParticleBunch | pointer to the created particle bunch. But be careful! The positions and colours of the sprite are set, furthermore an “exploding” velocity, but keep in mind to scale this data to your system. ;) |
Creates a bunch of a fixed number of particles.
PREFIX spParticleBunchPointer spParticleCreate( int count, int ( *feedback )( spParticleBunchPointer bunch, Sint32 action, Sint32 extra_data), spParticleBunchPointer * addBunch )
Updates all particles of the particles bunch and connected bunches.
PREFIX void spParticleUpdate( spParticleBunchPointer * firstBunch, int steps )
Draws all particles of the particles bunch and connected bunches.
PREFIX void spParticleDraw( spParticleBunchPointer firstBunch )
Deletes all particles of the particles bunch and connected bunches.
PREFIX void spParticleDelete( spParticleBunchPointer * firstBunch )
This special function creates a particle bunch out of a sprite.
PREFIX spParticleBunchPointer spParticleFromSprite( spSpritePointer sprite, int ( *feedback )( spParticleBunchPointer bunch, Sint32 action, Sint32 extra_data), spParticleBunchPointer * addBunch )