annotate demos/rio_de_hola/scripts/agents/girl.py @ 583:47b49b9b0c0a

* Improved the floatingtextrenderer. Now you can set an alpha value for font, background quad and border. Splited quad and border into own commands. * Added a triangle function to backends and genericrenderer, also added the functions to set an alpha value for geometric figures.
author helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
date Sat, 07 Aug 2010 16:36:35 +0000
parents 3dff106b945b
children
rev   line source
395
70697641fca3 Adding the correct FIFE header to rio_de_hola and pychan_demo files.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 378
diff changeset
1 # -*- coding: utf-8 -*-
70697641fca3 Adding the correct FIFE header to rio_de_hola and pychan_demo files.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 378
diff changeset
2
70697641fca3 Adding the correct FIFE header to rio_de_hola and pychan_demo files.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 378
diff changeset
3 # ####################################################################
70697641fca3 Adding the correct FIFE header to rio_de_hola and pychan_demo files.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 378
diff changeset
4 # Copyright (C) 2005-2009 by the FIFE team
70697641fca3 Adding the correct FIFE header to rio_de_hola and pychan_demo files.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 378
diff changeset
5 # http://www.fifengine.de
70697641fca3 Adding the correct FIFE header to rio_de_hola and pychan_demo files.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 378
diff changeset
6 # This file is part of FIFE.
70697641fca3 Adding the correct FIFE header to rio_de_hola and pychan_demo files.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 378
diff changeset
7 #
70697641fca3 Adding the correct FIFE header to rio_de_hola and pychan_demo files.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 378
diff changeset
8 # FIFE is free software; you can redistribute it and/or
70697641fca3 Adding the correct FIFE header to rio_de_hola and pychan_demo files.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 378
diff changeset
9 # modify it under the terms of the GNU Lesser General Public
70697641fca3 Adding the correct FIFE header to rio_de_hola and pychan_demo files.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 378
diff changeset
10 # License as published by the Free Software Foundation; either
70697641fca3 Adding the correct FIFE header to rio_de_hola and pychan_demo files.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 378
diff changeset
11 # version 2.1 of the License, or (at your option) any later version.
70697641fca3 Adding the correct FIFE header to rio_de_hola and pychan_demo files.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 378
diff changeset
12 #
70697641fca3 Adding the correct FIFE header to rio_de_hola and pychan_demo files.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 378
diff changeset
13 # This library is distributed in the hope that it will be useful,
70697641fca3 Adding the correct FIFE header to rio_de_hola and pychan_demo files.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 378
diff changeset
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
70697641fca3 Adding the correct FIFE header to rio_de_hola and pychan_demo files.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 378
diff changeset
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
70697641fca3 Adding the correct FIFE header to rio_de_hola and pychan_demo files.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 378
diff changeset
16 # Lesser General Public License for more details.
70697641fca3 Adding the correct FIFE header to rio_de_hola and pychan_demo files.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 378
diff changeset
17 #
70697641fca3 Adding the correct FIFE header to rio_de_hola and pychan_demo files.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 378
diff changeset
18 # You should have received a copy of the GNU Lesser General Public
70697641fca3 Adding the correct FIFE header to rio_de_hola and pychan_demo files.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 378
diff changeset
19 # License along with this library; if not, write to the
70697641fca3 Adding the correct FIFE header to rio_de_hola and pychan_demo files.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 378
diff changeset
20 # Free Software Foundation, Inc.,
70697641fca3 Adding the correct FIFE header to rio_de_hola and pychan_demo files.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 378
diff changeset
21 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
70697641fca3 Adding the correct FIFE header to rio_de_hola and pychan_demo files.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 378
diff changeset
22 # ####################################################################
70697641fca3 Adding the correct FIFE header to rio_de_hola and pychan_demo files.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 378
diff changeset
23
378
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
24 from agent import Agent
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
25 from fife import fife
496
987307d12235 Added the fife_settings.py extension. This provides a small utility class for loading and saving settings along with a dialog box for setting screen resolution and other things.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 395
diff changeset
26 from fife.extensions.fife_settings import Setting
378
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
27
499
3dff106b945b Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 496
diff changeset
28 #TDS = Setting(app_name="rio_de_hola")
378
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
29
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
30 _STATE_NONE, _STATE_IDLE, _STATE_RUN, _STATE_FOLLOW = 0, 1, 2, 3
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
31
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
32 class Girl(Agent):
499
3dff106b945b Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 496
diff changeset
33 def __init__(self, settings, model, agentName, layer, uniqInMap=True):
3dff106b945b Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 496
diff changeset
34 super(Girl, self).__init__(settings, model, agentName, layer, uniqInMap)
378
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
35 self.state = _STATE_NONE
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
36 self.waypoints = ((67, 80), (75, 44))
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
37 self.waypoint_counter = 0
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
38 self.hero = self.layer.getInstance('PC')
499
3dff106b945b Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 496
diff changeset
39
3dff106b945b Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 496
diff changeset
40 self.GIRL_SPEED = 3 * float(self.settings.get("rio", "TestAgentSpeed"))
378
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
41
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
42 def onInstanceActionFinished(self, instance, action):
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
43 if self.state in (_STATE_RUN, _STATE_FOLLOW):
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
44 self.idle()
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
45 else:
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
46 if self.waypoint_counter % 3:
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
47 self.waypoint_counter += 1
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
48 self.follow_hero()
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
49 else:
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
50 self.run(self.getNextWaypoint())
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
51
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
52 def getNextWaypoint(self):
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
53 self.waypoint_counter += 1
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
54 l = fife.Location(self.layer)
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
55 l.setLayerCoordinates(fife.ModelCoordinate(*self.waypoints[self.waypoint_counter % len(self.waypoints)]))
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
56 return l
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
57
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
58 def start(self):
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
59 self.follow_hero()
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
60
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
61 def idle(self):
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
62 self.state = _STATE_IDLE
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
63 self.agent.act('stand', self.agent.getFacingLocation(), False)
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
64
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
65 def follow_hero(self):
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
66 self.state = _STATE_FOLLOW
499
3dff106b945b Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 496
diff changeset
67 self.agent.follow('run', self.hero, self.GIRL_SPEED)
378
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
68
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
69 def run(self, location):
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
70 self.state = _STATE_RUN
499
3dff106b945b Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 496
diff changeset
71 self.agent.move('run', location, self.GIRL_SPEED)