GameMaker's particle systems as its runtime runs them: systems that hold particles,
particle types that say how each particle starts, moves, changes and draws, and
emitters that set particles loose over a region. The functions are the game code's
part_system_*, part_type_*, part_emitter_* and part_particles_create, each
taking and giving the world; random draws come from the world's generator
(Cauldron2D.GameMaker.Random), in the runtime's order.
{world, system} = PartSystems.system_create(world)
{world, dust} = PartSystems.type_create(world)
world = PartSystems.type_sprite(world, dust, sprite, true, false, false)
{world, emitter} = PartSystems.emitter_create(world, system)
world =
world
|> PartSystems.emitter_region(system, emitter, {x - 4, x + 4, y, y}, :rectangle, :linear)
|> PartSystems.emitter_burst(system, emitter, dust, 1)A particle starts with a speed, direction, angle, size and life drawn from its type's
ranges, its type's first colour and alpha, and, for a type with a random start frame,
a frame drawn from 0–9999. system_update/2 then, for every particle:
- ages it a step; one whose life is up dies, setting loose its type's death particles where it was, and every living one sets loose its step particles
- adds the type's speed increment (never below 0), direction increment and angle increment, turns its motion by the type's gravity, and moves it by its speed and direction, each shaken by its wiggle
- adds the size increment (never below 0), sets its colour, and fades its alpha along the type's three alphas, the second at half its life
and then lets every emitter with a stream burst. A wiggle is a triangle wave from −1 to 1 times the type's wiggle amount, whose phase is the particle's age plus a multiple of a number from 0–99999 drawn when it was made.
items/2 gives a system's particles as draw list items in its draw order; a system
drawn automatically is drawn by Cauldron2D.GameMaker.Draw at its depth, and one
updated automatically is updated with each step.
Summary
Functions
Every automatically drawn system's particles as draw list items, at the system's depth.
number particles of type type set loose over emitter emitter's region; a
negative number sets one loose by a 1 in |number| chance (part_emitter_burst).
A new emitter of system system; {world, emitter} (part_emitter_create).
The world without emitter emitter of system system (part_emitter_destroy).
Emitter emitter's region {xmin, xmax, ymin, ymax}, its shape and how particles
spread over it (part_emitter_region).
System system's particles as draw list items, in its draw order (part_system_drawit).
number particles of type type set loose at {x, y} (part_particles_create).
The world with every automatically updated system one step on.
System system drawn by itself, or only through items/2 (part_system_automatic_draw).
System system updated by itself each step, or only by system_update/2 (part_system_automatic_update).
A new particle system; {world, system} (part_system_create).
System system drawn at depth (part_system_depth).
The world without system system and its particles (part_system_destroy).
Whether system system exists (part_system_exists).
The world with system system one step on (part_system_update).
Type type's alpha, the same all its life (part_type_alpha1).
Type type's alpha at its start, half its life and its end (part_type_alpha3).
Type type drawn added to what is under it, or over it (part_type_blend).
Type type coloured colour {r, g, b} (part_type_colour1).
Type type coloured from hue, saturation and value each drawn from its range when a
particle is made, 0–255 (part_type_colour_hsv).
A new particle type with GameMaker's defaults; {world, type} (part_type_create).
number particles of type death set loose where a particle of type dies (part_type_death).
The world without particle type type (part_type_destroy).
Type type's direction range, increment a step and wiggle, in degrees (part_type_direction).
Type type's gravity: amount a step towards direction (part_type_gravity).
Type type's life, from low to high steps (part_type_life).
Type type's angle range, increment a step and wiggle, and whether the angle is
added to the direction of motion (part_type_orientation).
Type type's scale {x, y} (part_type_scale).
Type type's size range, increment a step and wiggle (part_type_size).
Type type's speed range, increment a step and wiggle (part_type_speed).
Type type drawn as sprite sprite: animated through its frames, stretched so its
frames span the particle's life, starting on a random frame (part_type_sprite).
number particles of type step set loose each step from each particle of type (part_type_step).
Types
Functions
@spec automatic_items(Cauldron2D.GameMaker.World.t()) :: [map()]
Every automatically drawn system's particles as draw list items, at the system's depth.
@spec emitter_burst( Cauldron2D.GameMaker.World.t(), non_neg_integer(), non_neg_integer(), non_neg_integer(), integer() ) :: Cauldron2D.GameMaker.World.t()
number particles of type type set loose over emitter emitter's region; a
negative number sets one loose by a 1 in |number| chance (part_emitter_burst).
@spec emitter_create(Cauldron2D.GameMaker.World.t(), non_neg_integer()) :: {Cauldron2D.GameMaker.World.t(), non_neg_integer()}
A new emitter of system system; {world, emitter} (part_emitter_create).
@spec emitter_destroy( Cauldron2D.GameMaker.World.t(), non_neg_integer(), non_neg_integer() ) :: Cauldron2D.GameMaker.World.t()
The world without emitter emitter of system system (part_emitter_destroy).
@spec emitter_region( Cauldron2D.GameMaker.World.t(), non_neg_integer(), non_neg_integer(), {number(), number(), number(), number()}, shape(), distribution() ) :: Cauldron2D.GameMaker.World.t()
Emitter emitter's region {xmin, xmax, ymin, ymax}, its shape and how particles
spread over it (part_emitter_region).
@spec items(Cauldron2D.GameMaker.World.t(), non_neg_integer()) :: [map()]
System system's particles as draw list items, in its draw order (part_system_drawit).
@spec particles_create( Cauldron2D.GameMaker.World.t(), non_neg_integer(), {number(), number()}, non_neg_integer(), integer() ) :: Cauldron2D.GameMaker.World.t()
number particles of type type set loose at {x, y} (part_particles_create).
@spec step(Cauldron2D.GameMaker.World.t()) :: Cauldron2D.GameMaker.World.t()
The world with every automatically updated system one step on.
@spec system_automatic_draw( Cauldron2D.GameMaker.World.t(), non_neg_integer(), boolean() ) :: Cauldron2D.GameMaker.World.t()
System system drawn by itself, or only through items/2 (part_system_automatic_draw).
@spec system_automatic_update( Cauldron2D.GameMaker.World.t(), non_neg_integer(), boolean() ) :: Cauldron2D.GameMaker.World.t()
System system updated by itself each step, or only by system_update/2 (part_system_automatic_update).
@spec system_create(Cauldron2D.GameMaker.World.t()) :: {Cauldron2D.GameMaker.World.t(), non_neg_integer()}
A new particle system; {world, system} (part_system_create).
@spec system_depth(Cauldron2D.GameMaker.World.t(), non_neg_integer(), number()) :: Cauldron2D.GameMaker.World.t()
System system drawn at depth (part_system_depth).
@spec system_destroy(Cauldron2D.GameMaker.World.t(), non_neg_integer()) :: Cauldron2D.GameMaker.World.t()
The world without system system and its particles (part_system_destroy).
@spec system_exists?(Cauldron2D.GameMaker.World.t(), non_neg_integer()) :: boolean()
Whether system system exists (part_system_exists).
@spec system_update(Cauldron2D.GameMaker.World.t(), non_neg_integer()) :: Cauldron2D.GameMaker.World.t()
The world with system system one step on (part_system_update).
@spec type_alpha1(Cauldron2D.GameMaker.World.t(), non_neg_integer(), number()) :: Cauldron2D.GameMaker.World.t()
Type type's alpha, the same all its life (part_type_alpha1).
@spec type_alpha3( Cauldron2D.GameMaker.World.t(), non_neg_integer(), number(), number(), number() ) :: Cauldron2D.GameMaker.World.t()
Type type's alpha at its start, half its life and its end (part_type_alpha3).
@spec type_blend(Cauldron2D.GameMaker.World.t(), non_neg_integer(), boolean()) :: Cauldron2D.GameMaker.World.t()
Type type drawn added to what is under it, or over it (part_type_blend).
@spec type_colour1( Cauldron2D.GameMaker.World.t(), non_neg_integer(), {byte(), byte(), byte()} ) :: Cauldron2D.GameMaker.World.t()
Type type coloured colour {r, g, b} (part_type_colour1).
@spec type_colour_hsv( Cauldron2D.GameMaker.World.t(), non_neg_integer(), {number(), number()}, {number(), number()}, {number(), number()} ) :: Cauldron2D.GameMaker.World.t()
Type type coloured from hue, saturation and value each drawn from its range when a
particle is made, 0–255 (part_type_colour_hsv).
@spec type_create(Cauldron2D.GameMaker.World.t()) :: {Cauldron2D.GameMaker.World.t(), non_neg_integer()}
A new particle type with GameMaker's defaults; {world, type} (part_type_create).
@spec type_death( Cauldron2D.GameMaker.World.t(), non_neg_integer(), integer(), non_neg_integer() ) :: Cauldron2D.GameMaker.World.t()
number particles of type death set loose where a particle of type dies (part_type_death).
@spec type_destroy(Cauldron2D.GameMaker.World.t(), non_neg_integer()) :: Cauldron2D.GameMaker.World.t()
The world without particle type type (part_type_destroy).
@spec type_direction( Cauldron2D.GameMaker.World.t(), non_neg_integer(), number(), number(), number(), number() ) :: Cauldron2D.GameMaker.World.t()
Type type's direction range, increment a step and wiggle, in degrees (part_type_direction).
@spec type_gravity( Cauldron2D.GameMaker.World.t(), non_neg_integer(), number(), number() ) :: Cauldron2D.GameMaker.World.t()
Type type's gravity: amount a step towards direction (part_type_gravity).
@spec type_life(Cauldron2D.GameMaker.World.t(), non_neg_integer(), number(), number()) :: Cauldron2D.GameMaker.World.t()
Type type's life, from low to high steps (part_type_life).
@spec type_orientation( Cauldron2D.GameMaker.World.t(), non_neg_integer(), number(), number(), number(), number(), boolean() ) :: Cauldron2D.GameMaker.World.t()
Type type's angle range, increment a step and wiggle, and whether the angle is
added to the direction of motion (part_type_orientation).
@spec type_scale( Cauldron2D.GameMaker.World.t(), non_neg_integer(), number(), number() ) :: Cauldron2D.GameMaker.World.t()
Type type's scale {x, y} (part_type_scale).
@spec type_size( Cauldron2D.GameMaker.World.t(), non_neg_integer(), number(), number(), number(), number() ) :: Cauldron2D.GameMaker.World.t()
Type type's size range, increment a step and wiggle (part_type_size).
@spec type_speed( Cauldron2D.GameMaker.World.t(), non_neg_integer(), number(), number(), number(), number() ) :: Cauldron2D.GameMaker.World.t()
Type type's speed range, increment a step and wiggle (part_type_speed).
@spec type_sprite( Cauldron2D.GameMaker.World.t(), non_neg_integer(), integer(), boolean(), boolean(), boolean() ) :: Cauldron2D.GameMaker.World.t()
Type type drawn as sprite sprite: animated through its frames, stretched so its
frames span the particle's life, starting on a random frame (part_type_sprite).
@spec type_step( Cauldron2D.GameMaker.World.t(), non_neg_integer(), integer(), non_neg_integer() ) :: Cauldron2D.GameMaker.World.t()
number particles of type step set loose each step from each particle of type (part_type_step).