PARTICLE EFFECTS

 

ParticleMovement

Set movement attributes of an emitter object.

Usage:

ParticleMovement emitter_object, speed#, gravity# [,acceleration#]

Example:

FrameLimit 40

img=LoadImage("Media\particle.bmp")

par=MakeEmitter(img,120) 'lifetime for 3 seconds

'speed 5, gravity 0.1

ParticleMovement par,5,0.1

'frequency 5, amount 4, chaos [-60 -> 60]

ParticleEmission par,5,4,60

'rotate the emitter to face upwards

RotateObject par,90

Repeat

    DrawScreen

Until EscapeKey()

 

ParticleAnimation

Particle animation is enabled through this command. Particles animate always so that the image strip ranges from zero to particle life end time. Thus, the animation is played only once, and its speed depends on the lifetime of the particles.

 

You must provide an animated image (LoadAnimImage). You must also specify the frame count of the image strip manually for ParticleAnimation. If you fail to provide the amount correctly, the program may crash.

Usage:

ParticleAnimation emitter_object, framecount

Example:

FrameLimit 40

'8 FRAMES!!!

img=LoadAnimImage("Media\animparticle.bmp",11,11,0,8)

par=MakeEmitter(img,80)

'speed 5, gravity 0.1

ParticleMovement par,5,0.1

'frequency 5, amount 4, chaos 10 degrees

ParticleEmission par,5,4,10

'animate particles, use 8 frames

ParticleAnimation par,8

RotateObject par,45

PositionObject par, -120, -50

Repeat

    DrawScreen

Until EscapeKey()

 

ParticleEmission

Particle emitters have a few aattributes that can be changed on-the-fly. This command tolerates the emission density, amount of emission per time and the spreading of emitted particles.

 

Density is the time in between two particles are emitted. The greater the value the lesser particles you get. The amount defines how many particles are emitted at time. Defaults to one. The spread value defines a sector in degrees that particles are directly emitted to. The value of 90 only makes particles to emit on the area of half circle, whereas 180 makes it go all over.

Usage:

ParticleEmission emitter_object, density, amount, spread

 

MakeEmitter

Creates a particle emitter object to world coordinates 0,0. Use particle emitters to enhance game graphics by creating smoke, sparks, fire or radiation of some sort. Paricles are objects that are needed a lot. Managing such vast amounts proofs slow, tanglented and requires unnecessary extra work. CoolBasic particle engine is super-optimized full-machine code implementation of functions that do all this automatically for you.

 

Particle emitters can be moved and turned the same way you'd do for any other object. You can destoy the emitter with the DeleteObject-command. You can also set a life for the emitter after which it's automatically destroyed. Even collision and picking is supported for the emitters.

 

You pass this function two parameters: an image (texture) and a life time. The life time is an integer that defines how many times the screen will be drawn before the particle (not the emitter) is destroyed. For example, if you set your game to run 40 fps (FrameLimit-command), you put 80 in order to let them live for 2 seconds.

 

Also check out the other particle commands.

Usage:

emitter_object = MakeEmitter (image_variable, lifetime)

Example:

FrameLimit 40

img=LoadImage("Media\particle.bmp")

par=MakeEmitter(img,120) 'lifetime for 3 seconds

Repeat

    DrawScreen

Forever