For complex things in GameMaker you would normally have an object and create instances of that object around the room. However, for graphics effects, this can be expensive as every instance comes with a "cost" in processing due to the variables it contains and the code it has in the different events. You can reduce this cost by turning to tilemap layers and asset layers for drawing your graphics needs but those are generally static and cannot be changed or moved around much. However, there is one other option for drawing fast yet versatile graphics effects in your games, and that is to use particles.
Particles are graphic resources that have certain properties which are defined within a particle system. These properties cannot be manipulated directly for individual particles, but are changed through the code that is used to define the individual particle and the system that it belongs to. They are very useful for creating beautiful and flashy effects (or subtle and discreet ones!) like explosions, decals, rain, snow, star fields and debris in a game without the CPU overhead that using instances has.
The basic setup for a particle system follows three steps, with the third step being optional depending on how you wish to create your particle effects within the room:
Although particles are an excellent tool for creating effects, they do come with certain restrictions and good practices which need to be followed unless you want your game to suffer from poor performance or even potentially crash:
The easiest way of creating particles in your game with GameMaker is to use the built-in effects mechanism. These effects are created using an internal particle system which is basically a very fast method for drawing graphical effects only and as such you do not have to worry about all the details (like memory management) when using these functions. You simply specify the type of effect, the position where it must be created, the size you want it to be and finally, its colour then let GameMaker do all the work.
TIP If you prefer a more visual approach to creating particles and don't need the extensive functionality that GML Code offers, you can also create a Particle System Asset using The Particle System Editor. Additionally, you can generate the GML Code for it using the editor's Copy GML to Clipboard .
The following functions exist for creating the built-in particle effects:
Even though these effects are limited in scope and customisation, they can still be used to create some simple, great effects with very little effort. For example by creating a small puff of grey smoke below a moving missile in each step, a pretty convincing smoke trail is created, so even when you are an expert in particles it pays to remember that these effects exist as they can still save you some time.
GameMaker also has a function to retrieve information on Particle System Assets created with The Particle System Editor:
However, the true potential of particles is in designing and creating your own effects using the powerful functions that the GameMaker Language supplies to you. You can find out more from each of the following sections: