On 21/07/13 05:26, Brandon Jumbeck wrote:
So just recently I jumped into Python and Pyglet since I have been looking for a language that can prototype much faster then my usual C++ and it seemed to fit my need perfectly. I am also quite new at game development in general so try not to be to hard on me ;p.

Anyways my question is about a little project I am working on (A little space shooter) and I have having trouble trying to figure out a good system to use for managing each objects state.

For example here is a snippet of code from my player class http://pastebin.com/cBBkmVwA . Notice the big if/elif/else combination I am using to update the player sprite based on keyboard input. This seems rather ugly to me and a lot of work to maintain (Specially since that code is only for basic movement of the sprite)... So I was wondering is there a better way to do this? Or is this the correct way to go about it?

I have been reading up on different state handling designs like FSM, HFSM and Behavior Tress but I couldn't really find any code examples of how they are implemented (I learn better by examining actual code).

So any help would be appreciated thank you.

I think the big 'if' statement is pretty standard practice although you seem to be repeating tests e.g.
if self.keyHandler[key.UP]:
# UP-RIGHT
if self.keyHandler[key.UP] and self.keyHandler[key.RIGHT]:
self.image = resources.playerForwardRight

you test self.keyHandler[key.UP] and then if it is set you do it again.

--
You received this message because you are subscribed to the Google Groups 
"pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to