Mercurial > fife-parpg
comparison demos/rio_de_hola/scripts/world.py @ 422:9d94f4676d17
Moved the management of cameras into the Map class. The View class no longer exists since it now serves no purpose. The engine class itself holds the renderers and these get passed to each map that is loaded and then passed to each camera on each map. This change makes it possible for multiple maps to be loaded at the same time with the same camera id without a name clash. fixes[t:342]
author | vtchill@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Fri, 12 Feb 2010 06:34:50 +0000 |
parents | 70697641fca3 |
children | 4f2752d45458 |
comparison
equal
deleted
inserted
replaced
421:293e812316c0 | 422:9d94f4676d17 |
---|---|
73 def __init__(self, engine): | 73 def __init__(self, engine): |
74 super(World, self).__init__(engine, regMouse=True, regKeys=True) | 74 super(World, self).__init__(engine, regMouse=True, regKeys=True) |
75 self.engine = engine | 75 self.engine = engine |
76 self.eventmanager = engine.getEventManager() | 76 self.eventmanager = engine.getEventManager() |
77 self.model = engine.getModel() | 77 self.model = engine.getModel() |
78 self.view = self.engine.getView() | |
79 self.filename = '' | 78 self.filename = '' |
80 self.pump_ctr = 0 # for testing purposis | 79 self.pump_ctr = 0 # for testing purposis |
81 self.ctrldown = False | 80 self.ctrldown = False |
82 self.instancemenu = None | 81 self.instancemenu = None |
83 self.instance_to_agent = {} | 82 self.instance_to_agent = {} |
197 """ | 196 """ |
198 camera_prefix = self.filename.rpartition('.')[0] # Remove file extension | 197 camera_prefix = self.filename.rpartition('.')[0] # Remove file extension |
199 camera_prefix = camera_prefix.rpartition('/')[2] # Remove path | 198 camera_prefix = camera_prefix.rpartition('/')[2] # Remove path |
200 camera_prefix += '_' | 199 camera_prefix += '_' |
201 | 200 |
202 for cam in self.view.getCameras(): | 201 for cam in self.map.getCameras(): |
203 camera_id = cam.getId().replace(camera_prefix, '') | 202 camera_id = cam.getId().replace(camera_prefix, '') |
204 self.cameras[camera_id] = cam | 203 self.cameras[camera_id] = cam |
204 cam.resetRenderers() | |
205 | 205 |
206 self.cameras['main'].attach(self.hero.agent) | 206 self.cameras['main'].attach(self.hero.agent) |
207 | 207 |
208 self.view.resetRenderers() | |
209 # Floating text renderers currntly only support one font. | 208 # Floating text renderers currntly only support one font. |
210 # ... so we set that up. | 209 # ... so we set that up. |
211 # You'll se that for our demo we use a image font, so we have to specify the font glyphs | 210 # You'll se that for our demo we use a image font, so we have to specify the font glyphs |
212 # for that one. | 211 # for that one. |
213 renderer = fife.FloatingTextRenderer.getInstance(self.cameras['main']) | 212 renderer = fife.FloatingTextRenderer.getInstance(self.cameras['main']) |
272 elif keystr == 's': | 271 elif keystr == 's': |
273 c = self.cameras['small'] | 272 c = self.cameras['small'] |
274 c.setEnabled(not c.isEnabled()) | 273 c.setEnabled(not c.isEnabled()) |
275 elif keystr == 'r': | 274 elif keystr == 'r': |
276 self.model.deleteMaps() | 275 self.model.deleteMaps() |
277 self.view.clearCameras() | |
278 self.load(self.filename) | 276 self.load(self.filename) |
279 elif keystr == 'o': | 277 elif keystr == 'o': |
280 self.target_rotation = (self.target_rotation + 90) % 360 | 278 self.target_rotation = (self.target_rotation + 90) % 360 |
281 elif keyval in (fife.Key.LEFT_CONTROL, fife.Key.RIGHT_CONTROL): | 279 elif keyval in (fife.Key.LEFT_CONTROL, fife.Key.RIGHT_CONTROL): |
282 self.ctrldown = True | 280 self.ctrldown = True |