Game Development on a New Frontier RSS 2.0
 Tuesday, April 08, 2008
I've got the first attempt at a XNA state-machine driven particle system up and running, but it has some issues.  Taking a second look at the way I integrated the particles into the more generic state machine, I'm not happy with my implementation.

I think I'll keep the foundation of my state machine, but re-design the interface with the particle system.  Right now, I'm having some problems differentiating the different states of the independent particles because I built the "current" state into the state machine, rather than into the particles themselves.  Thus, when one particle changes states, they all change states.

This is an easy enough fix, but the way the particle system is tied to the state machine bothers me.  I think I'll use the core state machine as a foundation class (I think I designed it rather well as a generic state machine system), but I'll create an inherited class that implements the particle system specifically.  That part of my design wasn't so clean the first time around - that's what I get for trying to rush and get it done in one sitting!

One problem I ran into with the generic state machine is how to modify settings within the StateObject class that is passed into the StateMachine.  I ended up creating a Hashtable of attributes within the StateObject.  In the State object, an attribute can be set to change and is looked up by its identifier string.  It's a fairly expandable system (attributes can easily be created and modified at will), but I'm not 100% sure that I like it - there is some overhead with looking up into the Hashtable for existing attributes, as well as not providing very elegant ways to process that information.  Time will tell.  I may end up replacing it with a static system within the various inherited implementations of the StateMachine (the ParticleStateMachine, for instance, would know that the Particle objects have an "Age" attribute).  On the other hand, I may decide that I'm adding so much to the Particles that the Hashtable turns out to be handy!  We'll see.

Right now, the basic system looks like this:

StateMachine - Contains the different states, as well as system-wide settings (maximum particles to create, how often to create them, etc. - specific examples for the ParticleStateMachine).
State - Contains processing details about a specific state (changes attributes, performs if less than/greater than checks, tells the StateObject to switch to another state contained in the parent StateMachine, etc.).
StateObject - A generic interface into an object being passed through the StateMachine.  Each inherited implementation of the StateMachine will expand upon this as needed (i.e., the ParticleStateObject will contain an "Age" attribute as mentioned previously).

Knowing that I'm going to be changing the implementation, I'll hold off on posting code till I clean up the system a bit.  I wouldn't want just everyone to see my messy coding!  ;-)

Cheers!

Devan

Tuesday, April 08, 2008 6:49:29 PM (Pacific Standard Time, UTC-08:00)  #    Comments [0] -
XNA
Categories
 
 
 
 
 
 
Archive
<April 2008>
SunMonTueWedThuFriSat
303112345
6789101112
13141516171819
20212223242526
27282930123
45678910
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2009
Devan Stormont
Sign In
Statistics
Total Posts: 10
This Year: 0
This Month: 0
This Week: 0
Comments: 0
Themes
Pick a theme:
All Content © 2009, Devan Stormont
DasBlog theme 'Business' created by Christoph De Baene (delarou)