Log In  

Cart #particletest-0 | 2023-08-21 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
17

Particle Effects

Sixteen different kind of particles based on same generation method. I get the idea of the main function and loop of the particles from Youtube video of "Particles in Pico-8 - The Ultimate Guide" from SpaceCat.

All functions work and genrate particle when "O" button is passed. The particles can be implemented to other carts by only copying the function into the code. So, everyone is free to use the particless as long as they refer to my work :D

P#133343 2023-08-21 07:05

4

This is so satisfying to play with! I really like the range of effects you've explored. Nice work on this!

I have a small suggestion for 2 of the effects, if you're open to that.

In Vacuum, if you didn't want the particles to collect along the X & Y axes, you could move them directly towards the center instead of moving X & Y separately.


change this:

if p.x<64 then p.x+=p.dx*2 end
if p.x>64 then p.x-=p.dx*2 end
if p.y<64 then p.y+=p.dy*2 end
if p.y>64 then p.y-=p.dy*2 end

to this:

--calulate direction to center
local dx,dy=64-p.x,64-p.y
--normalize (change length to 1)
local length=sqrt(dx*dx+dy*dy)
dx/=length
dy/=length
--move particle
p.x+=dx*p.dx
p.y+=dy*p.dy

In Fireworks, if you wanted round explosions instead of square, you could calculate dx & dy by starting with a random speed & angle.


change this:

add(frw,{x=64,y=48,
 rad=0,dx=rnd(2)-1,dy=rnd(2)-1,
 act=50,clr=10,grv=0.02})

to this:

local angle,speed=rnd(1),rnd(2)-1
local dx=speed*cos(angle)
local dy=speed*sin(angle)
add(frw,{x=64,y=48,
 rad=0,dx=dx,dy=dy,
 act=50,clr=10,grv=0.02})

P#133402 2023-08-22 16:48
1

@zovirl thanks for playing!

And also thanks for the feedbacks. For Vacuum i was trying to solve that problem and you gave a great simple solution.

For fireworks the round explosions are so much better :)

P#133426 2023-08-23 10:43
2

It looks good, I just started working with it and it amazes me how much stuff can be done on this platform.

P#133463 2023-08-24 13:00
1

@ijetanar yes, every cart has something in it for people to imagine new things!

P#133498 2023-08-25 09:15

[Please log in to post a comment]