Mercurial > fife-parpg
comparison demos/rpg/scripts/actors/baseactor.py @ 516:d70fc46c8aa5
Added some placeholder graphics for the warrior. The player can now walk around the map.
author | prock@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Tue, 25 May 2010 21:41:59 +0000 |
parents | edf5c0cf52f3 |
children | c3a026cdd91b |
comparison
equal
deleted
inserted
replaced
515:520bd1621644 | 516:d70fc46c8aa5 |
---|---|
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 fife.extensions.loaders import loadMapFile | 30 from fife.extensions.loaders import loadMapFile |
31 | 31 |
32 ActorStates = {'IDLE':0, | |
33 'WALK':1, | |
34 'ATTACK':2} | |
35 | |
32 class Actor(object): | 36 class Actor(object): |
33 def __init__(self, gamecontroller, instancename, instanceid=None, createInstance=False): | 37 def __init__(self, gamecontroller, instancename, instanceid=None, createInstance=False): |
34 """ | 38 """ |
35 @param gamecontroller: A reference to the master game controller | 39 @param gamecontroller: A reference to the master game controller |
36 @param instancename: The name of the object to load. The object's XML file must | 40 @param instancename: The name of the object to load. The object's XML file must |
50 self._id = self._name | 54 self._id = self._name |
51 | 55 |
52 self._instance = None | 56 self._instance = None |
53 | 57 |
54 if createInstance: | 58 if createInstance: |
55 self._createFIFEInstance(self._name) | 59 self._createFIFEInstance() |
56 else: | 60 else: |
57 self._instance = self._gamecontroller.scene.layer.getInstance(self._id) | 61 self._instance = self._gamecontroller.scene.actorlayer.getInstance(self._id) |
58 self._instance.thisown = 0 | 62 self._instance.thisown = 0 |
63 | |
64 self._walkspeed = self._gamecontroller.settings.get("RPG", "DefaultActorWalkSpeed", 4.0) | |
65 self._state = ActorStates["IDLE"] | |
59 | 66 |
60 def destroy(self): | 67 def destroy(self): |
61 """ | 68 """ |
62 Deletes the FIFE instance from the actor layer on the map. | 69 Deletes the FIFE instance from the actor layer on the map. |
63 """ | 70 """ |
64 if self._instance : | 71 if self._instance : |
65 self._gamecontroller.scene.actorlayer.deleteInstance(self._instance) | 72 self._gamecontroller.scene.actorlayer.deleteInstance(self._instance) |
66 self._instance = None | 73 self._instance = None |
74 | |
75 def walk(self, location): | |
76 self._state = ActorStates["WALK"] | |
77 self._instance.move('walk', location, self._walkspeed) | |
67 | 78 |
68 def _createFIFEInstance(self): | 79 def _createFIFEInstance(self): |
69 """ | 80 """ |
70 Should not be called directly. Use the constructor! | 81 Should not be called directly. Use the constructor! |
71 """ | 82 """ |