← All Docs

Particle System Documentation

Particle System Documentation Source Code

Particles Methods

b8.Particles.add(particle)

Adds a new particle to the system.

Each particle is an object with properties:

  • x, y: position,
  • vx, vy: velocity (pixels per second, default=0),
  • life: remaining life time (seconds, default=1),
  • size: square size (pixels, default=1),
  • color: fill color (a b8 palette id, default=15).
  • gravity: gravity (pixels per second, default=0).

Parameters

  • particle (object): The particle object to add.

b8.Particles.clearAll()

Clears all particles from the system.

b8.Particles.createExplosion(x, y, count, props)

Adds an explosion of particles to the system.

The explosion is created at the x, y position with a number of particles.

The optional properties include:

  • size: The size of the particles (in pixels, default=1).
  • color: The color of the particles (a b8 palette id, default=fgColor).
  • life: The life of the particles (in seconds, default=2).
  • speed: The speed of the particles (in pixels per second, default=25).
  • gravity: The gravity of the particles (in pixels per second, default=0).

Parameters

  • x (number): The x position of the explosion.
  • y (number): The y position of the explosion.
  • count (number): The number of particles to add.
  • props (object): The properties of the explosion.

b8.Particles.getParticles()

Returns the particles array.

This is useful for debugging or if you want to manipulate the particles directly.

Returns

  • (array): The particles array.

b8.Particles.render()

Renders all particles as squares.

This should be called in your render method. This is not called automatically which allows you to control the draw order.

b8.Particles.setParticles(particles)

Sets the particles array.

Can be used with Particles.getParticles to manipulate the particles directly.

Parameters

  • particles (array): The particles array.

b8.Particles.update(dt)

Updates all particles.

If you are using b8 scenes or the b8 game loop (doframe) then this is called automatically and you don’t need to call it manually.

Parameters

  • dt (number): Delta time to update particle movement.

More BeepMini Docs

Actors Documentation

App Intro Documentation

Async Documentation

Cart API

Core Functions

ECS (Entity Component System) Documentation

Game Math Documentation

Game State

Input Documentation

Inventory API

Joystick Documentation

Menu Documentation

Music Documentation

Particle System Documentation

Passcodes Documentation

Public API

Random Numbers Documentation

SFX Documentation

Scene Documentation

Text Renderer

Textmode

Tilemap Documentation

Utilities Documentation