pass # already created in constructor def _pump(self): if self.listener.quit: self.breakRequested = True self.world.save('maps/savefile.xml') else: self.world.pump() def main(): app = IslandDemo() app.run() if __name__ == '__main__': if TDS.readSetting("ProfilingOn", type='bool'): import hotshot, hotshot.stats print "Starting profiler" prof = hotshot.Profile("fife.prof") prof.runcall(main) prof.close() print "analysing profiling results" stats = hotshot.stats.load("fife.prof") stats.strip_dirs() stats.sort_stats('time', 'calls') stats.print_stats(20) else: if TDS.readSetting("UsePsyco", type='bool'): # Import Psyco if available try: import psyco
from agent import Agent import fife from settings import Setting TDS = Setting() _STATE_NONE, _STATE_IDLE, _STATE_RUN, _STATE_FOLLOW = 0, 1, 2, 3 GIRL_SPEED = 3 * float(TDS.readSetting("TestAgentSpeed")) class Girl(Agent): def __init__(self, model, agentName, layer, uniqInMap=True): super(Girl, self).__init__(model, agentName, layer, uniqInMap) self.state = _STATE_NONE self.waypoints = ((67, 80), (75, 44)) self.waypoint_counter = 0 self.hero = self.layer.getInstance('PC') def onInstanceActionFinished(self, instance, action): if self.state in (_STATE_RUN, _STATE_FOLLOW): self.idle() else: if self.waypoint_counter % 3: self.waypoint_counter += 1 self.follow_hero() else: self.run(self.getNextWaypoint()) def getNextWaypoint(self): self.waypoint_counter += 1 l = fife.Location(self.layer) l.setLayerCoordinates(fife.ModelCoordinate(*self.waypoints[self.waypoint_counter % len(self.waypoints)]))