pdParticles - Playdate particle system

,

Hey! I was bored today so I decided to start making a Playdate particle system called pdParticles
playdate-20230131-145305
Currently it only suports drawing circles but I'm hoping to expand to rectangles, polygons, and images.
Just thought I should post it here since PD devs are the demographic for PD libraries

5 Likes

added other shapes
playdate-20230131-174818

2 Likes

Looks good so far. I'm interested to see how this evolves over time.

1 Like

added image particles
playdate-20230201-181257
giving it an imagetable makes each particle pick a random image from it
playdate-20230201-183243

1 Like

How fast is this running on device? Looks great.

There are some really quick and easy optimisations, by local aliasing the maths calls outside the loop & function and only using the alias inside the loop.

This reduces calls to the global math from many to one and is 30% faster.

local <const> random = math.random
for ...
    a = random(b,c)
end

I'd love to know your before/after figures.

3 Likes

ooh didn't know that helped, I don't have numbers right now but I can take some sometime soon

1 Like

You can have ~125 particles on screen and stay right at 30FPS.

I will open a PR that improves that by 16% to 145 if @PossiblyAxolotl doesn't mind!

3 Likes

Cool!

In my latest game I have 100 tiny rects as scrolling star field, plus between 25 and 100 additional particles based on current explosions, with some physics, running at 40fps. I'm using my own code for no reason other than I forgot this existed!

2 Likes

That’s cool with me!

1 Like