Menu
Coding Projects -  blitz3d-2dparticles
Brief explanation of 2d Particle library in Blitzbasic

 
InitParticle
Initparticle initialized the particle library.
Advanced: It Creates an array with random values. This to speed up getting random values when drawing real time particles. It is quicker because instead of using the relatively slow rand function, a lookup in an array is done.
 
 
AddParticle
After Initparticle this one has to be called to add particles to the system. The more particles, the more acurate the system will be. Every time you add an effect, "free" particles are taken to create it. If no particles are free, it will "steal" "the oldest" particles objects allready in use.
But in short, more particles alocated with addparticle makes it possible to show more effects at the same time on the screen. However this will also increase CPU activity.
 
 
MoveParticles
 To move around all the particles, and itterate their new positions and internal states.
 
 
Showparticles
 To draw all the in-use particles, added with "UseParticle"
 
UseParticle
 Semantics: A Particle is taken in the system from all free pre-alocated particles. The particle is now "live". While it is alive, it will move, grow, and animate automatically, when you call move and show particles.
 
Syntax: Useparticle(x#,y#,dx#,dy#,tdx#,tdy#,longlivety#,col,scale,length,initiallength)
x,y: Initial x position of particle
dx,dy: Speed and direction of particle
tdx,tdy: Step between points in the particle tail.
longlivety: A Fadeaway factor for the particle. The closer to 1, the longer the particle will live
col: Can be one of the following constants
Const fb_white= 0
Const fb_blue= 1
Const fb_red= 2
Const fb_green= 3
Const fb_gray= 4
Const fb_yellow= 5
Const fb_purple= 6
Const fb_orange= 7
Const fb_cyan= 8
Const fb_white2= 9
Const fb_blue2= 10
Const fb_red2= 11
Const fb_green2= 12
Const fb_gray2= 13
Const fb_yellow2= 14
Const fb_purple2= 15
Const fb_orange2= 16
Const fb_cyan2= 17
scale: How width is the tale. The bigger the scale, the larger the tail "scatters".   Example: A very small tail-scale will produce a simple line (1 pixel width). A big tail scale will produce a tail wich has a width bigger then one. length: The maxlength of the tail. Initiallength: The initial length of the tail. (The tail will continue to grow with 1 tailstep untill it reaches maximum length)
 
 
 
Wrappers:
ParticleCreateHoldEffect and ParticleCreateMomentEffect
 
In the example there are two wrappers around the basic particle functionality. They can be used to create an effect that consist of many particles.
For example, an explosion, that consists of 100 particles. All appearing at the same point, but moving away from each other.
 
ParticleCreateMomentEffect Creates effects that are meant as a one off effect. Like different explosion types.
 
 
ParticleCreateHoldEffect Creates effects that are optimised to "hold" for a while. When you call this in a loop, particles keep being created in a certain way. The result is that a certain effect is created, such as smoke or a black hole.