comparison demos/rpg/scripts/actors/player.py @ 518:e4cd18a179af

Added the PlayerActionListener. Added the ability to load NPCs from the settings file (this may be temporary). The idea of putting the NPCs in the settings file is to allow for custom attributes to be added without modification to the editor.
author prock@33b003aa-7bff-0310-803a-e67f0ece8222
date Wed, 26 May 2010 21:29:46 +0000
parents d70fc46c8aa5
children 14f777be6b94
comparison
equal deleted inserted replaced
517:c3a026cdd91b 518:e4cd18a179af
26 26
27 import sys, os, re, math, random, shutil 27 import sys, os, re, math, random, shutil
28 28
29 from fife import fife 29 from fife import fife
30 from scripts.actors.baseactor import Actor, ActorStates 30 from scripts.actors.baseactor import Actor, ActorStates
31 from scripts.objects.baseobject import ObjectActionListener, BaseGameObject
32
33 class PlayerActionListener(ObjectActionListener):
34 def __init__(self, gamecontroller, obj):
35 super(PlayerActionListener, self).__init__(gamecontroller, obj)
36
37 def onInstanceActionFinished(self, instance, action):
38 if action.getId() == 'walk':
39 print "player done walking"
40 #self._object.completeAction()
31 41
32 class Player(Actor): 42 class Player(Actor):
33 def __init__(self, gamecontroller, playermodelname): 43 def __init__(self, gamecontroller, playermodelname):
34 super(Player, self).__init__(gamecontroller, playermodelname, "player", True) 44 super(Player, self).__init__(gamecontroller, playermodelname, "player", True)
35 self._playermodelname = playermodelname 45 self._playermodelname = playermodelname
46
47 self._playeractionlistener = PlayerActionListener(self._gamecontroller, self)