Particles scattering

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
Fenrir
Party member
Posts: 222
Joined: Wed Nov 27, 2013 9:44 am
Contact:

Particles scattering

Post by Fenrir »

Hi guys,

We're currently working on smoke grenades for the game, and we're using particles for it, it's really nice but we have a question. We want to control particles scaterring to not let them go through walls or pilars for instance, like in this image:

Image

We want the particules to stay in the area we've computed (the white limits), is there any way to do it?

Thanks!
User avatar
micha
Inner party member
Posts: 1083
Joined: Wed Sep 26, 2012 5:13 pm

Re: Particles scattering

Post by micha »

You would need to get the position of each particle and then apply collision detection on it. In LÖVE's particleSystem, I don't see any method for getting the particle positions. So you would have to implement an own particle system.
User avatar
Fenrir
Party member
Posts: 222
Joined: Wed Nov 27, 2013 9:44 am
Contact:

Re: Particles scattering

Post by Fenrir »

Thanks, I was a bit afraid of this answer... :)

What I'm also considering is to render the particles into a canvas and apply it in my final scene with a mask cropping what I don't want, but I'm afraid it'll be quite strange on the edges, maybe by applying a gradient it'll be acceptable.

But before going this route I wanted to be sure that there's no other solution, so d'ont hesitate if you have any idea!
szensk
Party member
Posts: 155
Joined: Sat Jan 19, 2013 3:57 am

Re: Particles scattering

Post by szensk »

I have an idea, but I've never done it. You can apply a shader to a particle system. You could draw the area you computed to a texture and multiply it with the particles. Then any particles out side of the computed area would simply be not-visible, yes?
User avatar
Azhukar
Party member
Posts: 478
Joined: Fri Oct 26, 2012 11:54 am

Re: Particles scattering

Post by Azhukar »

Take a look at stencils. http://www.love2d.org/wiki/love.graphics.setStencil

You can use a stencil the shape of your area and then draw your particle system, I'm not sure whether a gradient would work as a stencil to smooth the edges.
Post Reply

Who is online

Users browsing this forum: No registered users and 64 guests