FX

FX Module

The FX Module contains particles, for effects like sparks and dust.

Particles are added to a ParticleSystem. Every tick, call the particle system's update() to move the particles, and draw it with MDog.Draw.particleSystem(). Every particle has a life, which is how many ticks it lasts before it's removed.

Speeds are in pixels per tick.

const sparks = new MDog.FX.ParticleSystem();

function main() {
    if (MDog.Input.Mouse.getClick()) {
        for (let i = 0; i < 20; i++) {
            const vx = Math.random() * 2 - 1;
            const vy = Math.random() * -2;
            sparks.addParticle(new MDog.FX.ChunkParticle(
                MDog.Input.Mouse.getX(), MDog.Input.Mouse.getY(),
                60, "#ffcc00", vx, vy, {gy: 0.05}));
        }
    }

    sparks.update();

    MDog.Draw.clear();
    MDog.Draw.particleSystem(sparks);
}

The FX Module's classes can be accessed with new MDog.FX.ClassName().

ParticleSystem

Particles

There are three kinds of particles. They all have the same settings for gravity, layer, and tags.

Particle Methods

Every kind of particle has these methods.