Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / 2DPhysics on particles

Author
Message
Henrik
6
Years of Service
User Offline
Joined: 17th Nov 2013
Location:
Posted: 17th Nov 2013 14:28
Hey,
I didnĀ“t find an answer to this question in this forum:
Is it possible to move all particles instead of the start zone?

If the charakter in my game moves he stays in the middle of the screen and the whole map under him moves. I designed a fire with particles which i want to place on the map and it also has to move across the screen while walking. If i change the x and y coordinates of the particles as i did with the spites, only the start zone moves and the particles which are already "send" don't.

I hope you can understand my problem, is there anyone who can help me?
Henrik
Latch
14
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 18th Nov 2013 00:10
Hello,

Depending on the particle generator (set of functions) that you are using, there may be an offset parameter which adjusts the position of the particles based on the position of the emitter.

The emitter is the point from where the particles start.

If there is no offset in the particle functions themselves, there has to be some mechanism (an array or other storage) that keeps track of where each particle is and what it's current life span is.

What you would need to do, is loop through all of the particles and offset their position by the new position of the start zone. For example, if you have moved the start position 4 pixels in the +X direction, then you have to add 4 to the current position of each particle.

Enjoy your day.
Henrik
6
Years of Service
User Offline
Joined: 17th Nov 2013
Location:
Posted: 25th Nov 2013 13:53
Thank you for the answer Latch,

The mechanism you are talking about is exactly what i am searching for.
My problem is that i am searching for it for more then two weeks.
Either it doesn't exist or i am just using the wrong keywords.

Is anyone out there who knows the name of this command?
Latch
14
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 29th Nov 2013 21:19
Are you using DarkBasic Classic or Pro?

What are you using to generate particles? If this is Classic, then particle generators are custom and depend on the functions that are used - what I mean is, a user like you or me wrote the code and the answers are in the code itself.

Enjoy your day.
LBFN
13
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 29th Nov 2013 22:32
@Henrik,

I assume you are using particle commands from within DBPro. I believe that all of the particles are generated from a common emitter position, so it will be difficult to remedy the problem you presented using the stock particle commands. I am not aware of how you can query/change an individual particles' position within the main particle object as I think DBP holds those values internally.

Because of the limitations imposed by particles I have never really used them. I find it just as easy to generate the code myself to make and manipulate them, and I can make it as flexible as I want.

I would suggest that you consider writing your own function to handle them. TheComet made some nice stuff regarding particles. Take a look here:

http://forum.thegamecreators.com/?m=forum_view&t=190374&b=1

So many games to code.....so little time.
Latch
14
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 29th Nov 2013 22:47 Edited at: 21st Dec 2013 02:09
@Henrik

I knocked together a very simple example of 2d particles. Basically, there are 2 functions that will control the position of the emitter.

If you click on the left button and move the mouse around, the emitter's position will follow the mouse and the particles will only reset their position after their life has ended. This gives the effect of waving a sparkler in the air.

If you click the RIGHT mouse button and move the mouse around, the emitter will move and all of the particles' positions will change based on that positional offset. I think this would be the effect you are describing.



Enjoy your day.

Login to post a reply

Server time is: 2020-08-12 03:00:36
Your offset time is: 2020-08-12 03:00:36