Skip to content

Getting Started

PossiblyAxolotl edited this page Feb 14, 2023 · 13 revisions

Setup

  1. Download the newest version of pdParticles from the code tab.

  2. Add pdParticles.lua to the same directory as your main.lua file.

  3. In your main.lua file add:

import "CoreLibs/graphics"

import "coreLibs/object"

import "pdParticles"

Making a Particle

To create a new particle create a variable using the ParticleCircle class. Also give it an x and y position somewhere on the screen

local p = ParticleCircle(200, 120)

You can modify all of the values with the functions detailed in the classes page.

to make all particles the same size use the setSize function with 1 argument:

p:setSize(1)

To make your particles vary in size, still use the setSize function but with 2 arguments to give it a range:

p:setSize(15, 25)

The particle mode decides whether the particle will disappear or stay until removed. By using the DECAY particle mode, particles will shrink rapidly until they disappear.

p:setMode(Particles.modes.DECAY)

Finally I will set the speed the particles move at. This one can also take in a range.

p:setSpeed(3, 7)

Now we can spawn our particle by typing

p:add(20)

to create 20 particles with those parameters and call

p:update()

every frame to update the particles. If you have multiple systems you can also call

Particles:update()

instead to update all of them.

This will create an effect that looks something like this:

playdate-20230131-144652

There is a lot more you can do with this library with things like ParticlePolys and ParticleImages so I hope you have fun messing with this

playdate-20230201-000033

(this video is taken from one of the example projects here!)

Clone this wiki locally