Get particle positions?

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
RemiM
Prole
Posts: 8
Joined: Wed Oct 31, 2012 4:39 pm

Get particle positions?

Post 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.
User avatar
paranoiax
Prole
Posts: 40
Joined: Thu Aug 16, 2012 10:27 am

Re: Get particle positions?

Post 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.
RemiM
Prole
Posts: 8
Joined: Wed Oct 31, 2012 4:39 pm

Re: Get particle positions?

Post 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
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Get particle positions?

Post by Robin »

That's probably the way to go, yeah.
Help us help you: attach a .love.
User avatar
Jasoco
Inner party member
Posts: 3726
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Get particle positions?

Post 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.
RemiM
Prole
Posts: 8
Joined: Wed Oct 31, 2012 4:39 pm

Re: Get particle positions?

Post 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
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 5 guests