Particle Effects Tutorial
Particle Effects are one of the most wellknown visual/special effect methodsused in GML, and in many otherlanguages as well. Particles are variousshapes (and sizes), with very littleinformation. This information includes
where they’re supposed to go, their
appearance, and more. With such littleinformation, particles take little CPUusage to calculate where and how todraw them on the screen. This is whyparticles are a great method to use if you want effects such as rain,explosions, smoke, fireworks, flames,and more. In the
, many engines are created onparticles alone (and sometimes withsome non-particle effects attached).Unfortunately, Particle Systems/effectscan take some time to get the hang of.They also take a lot of trial and error,and patience to get individual particletypes the way you want them.Inside a particle system are two types of elements.
, which are theparticles themselves
what they looklike, how they move, how they live/die,etc. Particle types are actually not a partof any system, and can be used by anysystem
however, for the sake of simplicity I like to think of particle typesas part of a system. The other type is
. Filters manipulate and changethe life of the particle as it is displayedon the screen. The most commonly usedfilter is an emitter. Emitters create theparticles in certain regions of a room.Other filters include attractors (whichdraw particles to a certain position withan amount of force), destroyers (whichdestroys particles that comewithin aregion in the room),deflectors (which bouncesparticles off an invisible force), andchangers (which change particles intoother types of particles when theycollide with an invisible region/force). Inthis tutorial, only the emitter filter willbe explained in detail.
Creating systems, filters,and types
A game can have as many systems,filters, and particle types as you like. Of course, the more you have, the morememory they take up. To create one of these, all you must do is use thefollowing functions:
//Create a System
//Create an emitter in the system'system0'
//Create an attractor in the system'system0'
//Create a destroyer in the system'system0'
//Create a changer in the system'system0'
//Create a particle type.
If you do not assign these functions to avariable, the system is still createdhowever you will not be able to access itbecause the unique ID of the system,filter, or type was not saved to anythingyou can refer to. Remember, if youcreate a second system and assign it to
the same ‘system0’ variable, the old
system will technically be lost and youwill not be able to do anything with thesystem.