On 04/06/2009, at 1:42 PM, Steve Johnson wrote:
> I just added support for "behaviors," which modify game objects every
> frame. The current set of behaviors is very limited, just to
> demonstrate what is possible, but it makes my demo a little bit nicer.
> Instead of that weird orange creature, there is now a top-down view of
> a little guy with a gun who moves sort of FPS-style. Here is the code
> to create that guy:
>
> class Player(GameObject):
>    def __init__(self, x, y):
>        super(Player, self).__init__(
>            util.resourcevault.character, x=x, y=y,
>            behaviors = [
>                behavior.manual.FPS(
>                    self, keys={
>                        'left':key.A, 'right':key.D,
>                        'forward':key.W, 'backward':key.S
>                    }
>                )
>            ]
>        )

Pardon my comment but that code looks kinda nasty from the perspective  
of an outside potential user of your API :)

How about something a little nicer, taking a leaf from ORMs:

class Player(GameObject):
    fps = behavior.FPS(
       keys=dict(left=key.A, right=key.D, forward=key.W,  
backward=key.S),
    )

where behavior.FPS is something appropriate and then scrape the class  
for special attributes in the GameObject.__init__


     Richard


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pyglet-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/pyglet-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to