Page 1 of 1

Get particle positions?

Posted: Wed Oct 31, 2012 4:42 pm
by RemiM
In my game I've created a fire using the ParticleSystem, however I want it so if the player touches the fire, then the player loses HP.
It seems the easiest way of doing this would be getting the particles position and matching them to the player positions. But I'm having trouble as of how to get the particle positions.

Re: Get particle positions?

Posted: Wed Oct 31, 2012 5:19 pm
by paranoiax
Wouldn't it be enough to get the emitter's position + some offset?
Otherwise, please provide a .love-file or at least a screenshot, so we know what's going on.

Re: Get particle positions?

Posted: Wed Oct 31, 2012 5:27 pm
by RemiM
Here's an image of what's going on: Image
I suppose the emitter position and some offset would be enough for a rough estimate, and probably enough accuracy for my small game. But if anyone knows a better way I could do it, I'd like to know :P

Re: Get particle positions?

Posted: Wed Oct 31, 2012 5:35 pm
by Robin
That's probably the way to go, yeah.

Re: Get particle positions?

Posted: Wed Oct 31, 2012 6:02 pm
by Jasoco
The only other way would be to write your own particle system where all your particles are just objects in a table. Not sure if it would be slower though. Does Löve's particle system utilize the system to accelerate all the looping it needs to do through every particle to move them every frame?

Writing your own would be trivial. You'd simply be creating a new particle object which would have its own X and Y and movement speeds and appearance and all the other data. You'd create a bunch of them on a delay and give them random information about speed, direction and scaling or color or image or whatever. It's basically how the system works now except that all the work is done for you and only requires a set of parameters and the update and draw calls.

But that's only if you really really need to check for collision with every single one as the built-in system doesn't return X and Y and other information for any particles. They're just for show and effect.

Re: Get particle positions?

Posted: Wed Oct 31, 2012 6:31 pm
by RemiM
Jasoco wrote:Snip
Yeah, I went with the easy/rough estimate way for now, it seems to be working good, unless you're 1 cm away from your screen and examining the fire and player :P

Maybe when I get more advanced with programming and game creation I will make my own particle system (This is my first game after all, and I have loads of plans for more games :D)

Nevertheless, thanks for help everyone