Particles, as GameMaker's part_particles_create makes them: pictures that code
sets loose, which move, animate and fade by themselves and are gone when their life
runs out. They are drawn with the room, at their depth, and cleared when a room is
entered.
world = Cauldron2D.GameMaker.Particles.create(world, %{
sprite: flame, position: {x, y}, velocity: {0.0, -0.4}, life: 14, frame_speed: 0.5
})A particle is a map:
:sprite— a sprite index;:framethe frame it starts on (default0) and:frame_speedframes a step (default0), wrapping. Or, in its place,:picture— any picture key of the draw list, such as:pixel, drawn from its top-left corner:position(required){x, y};:velocity{x, y}pixels a step (default still);:gravity{x, y}added to the velocity every step (default none):life(required) — the steps it lasts:alpha{from, to}, faded across its life (default{1.0, 1.0});:blend{r, g, b};:scale{x, y};:depth(default0)
Summary
Functions
The world with particle set loose.
The particles as draw list items, each naming {:sprite, sprite, frame} or its own picture.
The world with every particle one step on, and those whose life is over gone.
The particles for which pick is true, taken out of the world: {taken, world}. A
particle keeps any keys of its own it was created with, so pick can tell kinds
apart.
Types
@type particle() :: %{ :position => {number(), number()}, :life => pos_integer(), optional(atom()) => term() }
Functions
@spec create(Cauldron2D.GameMaker.World.t(), particle()) :: Cauldron2D.GameMaker.World.t()
The world with particle set loose.
@spec items(Cauldron2D.GameMaker.World.t()) :: [map()]
The particles as draw list items, each naming {:sprite, sprite, frame} or its own picture.
@spec step(Cauldron2D.GameMaker.World.t()) :: Cauldron2D.GameMaker.World.t()
The world with every particle one step on, and those whose life is over gone.
@spec take(Cauldron2D.GameMaker.World.t(), (particle() -> boolean())) :: {[particle()], Cauldron2D.GameMaker.World.t()}
The particles for which pick is true, taken out of the world: {taken, world}. A
particle keeps any keys of its own it was created with, so pick can tell kinds
apart.