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.
Get particle positions?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Get particle positions?
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.
Otherwise, please provide a .love-file or at least a screenshot, so we know what's going on.
Re: Get particle positions?
Here's an image of what's going on:
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
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
- Jasoco
- Inner party member
- Posts: 3726
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: Get particle positions?
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.
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?
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 playerJasoco wrote:Snip
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 )
Nevertheless, thanks for help everyone
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot] and 1 guest