Jump to content
  • Advertisement
Sign in to follow this  
paic

Particle System and the Policy Design

This topic is 4522 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I'm trying to use the policy design pattern to create a customizable particle system, but I have a little conception problems. Let's say I want to create a particle system with a creationPolicy and an updatePolicy. For a simple creationPolicy which create a new particle every X seconds, I have no problems, I simply have a timer inside the policy class, and that's done. But now, let's say I want a creationPolicy which will create a new particle, but only if the total number of particle in the system is less than a certain value. The only solution I can see is that the creationPolicy should have a certain visibility of the host class ... but that would completely break the policy design, since a policy class shouldn't know anything about its host class (well, as far as I understood the concept) And even if that's fine, how do I let the policy have access to its host members without writing specific codes, and breaking the "extensability" of the policy design ? Thx in advance for any help / links / articles / etc. Edit: hmm, maybe this post should go into the General Programming forum, but I can't seem to be able to delete it :/ [Edited by - paic on March 29, 2006 6:38:55 AM]

Share this post


Link to post
Share on other sites
Advertisement
There's nothing that says the policies can't access information from the host, either through the host's natural interface or a proxy. If they couldn't, then it would defeat the purpose of the whole pattern (separating the algorithms from the host).

Quote:
Original post by paic
And even if that's fine, how do I let the policy have access to its host members without writing specific codes, and breaking the "extensability" of the policy design ?

Give the particle system an external interface that allows other objects such as your policies to access and control the system. Even if you update the particle system and change implementations, keep the interface consistent. This allows you to "program to an interface, not an implementation".

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!