Beep8 logo

Particle System Documentation

Particle System Documentation Source Code

Particles Methods

beep8.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 beep8 palette id, default=15).
  • gravity: gravity (pixels per second, default=0).

Parameters

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

beep8.Particles.clearAll()

Clears all particles from the system.

beep8.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 beep8 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.

beep8.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.

beep8.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.

beep8.Particles.setParticles(particles)

Sets the particles array.

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

Parameters

  • particles (array): The particles array.

beep8.Particles.update(dt)

Updates all particles.

If you are using Beep8 scenes or the Beep8 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 Beep8 Docs

Actors Documentation

Async Documentation

Core Functions

Input Documentation

App Intro Documentation

Joystick Documentation

Menu Documentation

Music Documentation

Particle System Documentation

Passcodes Documentation

Public API

Random Numbers Documentation

Scene Documentation

SFX Documentation

Text Renderer

Tilemap Documentation

Utilities Documentation