annotate src/parpg/gamemap.py @ 170:371b17bc9113

Added ReplaceItemAction, to dialogueactions, which replaces a single item in the players inventory.
author KarstenBock@gmx.net
date Sun, 09 Oct 2011 14:39:02 +0200
parents ad75fa042b99
children 59c9ce2b8351
rev   line source
0
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
1 # This file is part of PARPG.
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
2
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
3 # PARPG is free software: you can redistribute it and/or modify
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
4 # it under the terms of the GNU General Public License as published by
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
5 # the Free Software Foundation, either version 3 of the License, or
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
6 # (at your option) any later version.
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
7
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
8 # PARPG is distributed in the hope that it will be useful,
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
11 # GNU General Public License for more details.
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
12
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
13 # You should have received a copy of the GNU General Public License
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
14 # along with PARPG. If not, see <http://www.gnu.org/licenses/>.
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
15
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
16 from fife import fife
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
17 from fife.extensions.loaders import loadMapFile
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
18
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
19 class GameMap(fife.MapChangeListener):
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
20 """Map class used to flag changes in the map"""
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
21 def __init__(self, engine, model):
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
22 # init mapchange listener
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
23 fife.MapChangeListener.__init__(self)
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
24 self.map = None
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
25 self.engine = engine
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
26 self.model = model
12
d60f1dab8469 Fixed resource path dependencies issue that caused PARPG to crash on start.
M. George Hansen <technopolitica@gmail.com>
parents: 0
diff changeset
27 self.settings = self.model.settings
0
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
28
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
29 # init map attributes
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
30 self.my_cam_id = None
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
31 self.cameras = {}
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
32 self.agent_layer = None
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
33 self.top_layer = None
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
34 self.fife_model = engine.getModel()
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
35 self.transitions = []
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
36 self.cur_cam2_x = 0
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
37 self.initial_cam2_x = 0
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
38 self.cam2_scrolling_right = True
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
39 self.target_rotation = 0
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
40 self.outline_renderer = None
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
41
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
42 def reset(self):
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
43 """Reset the model to default settings.
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
44 @return: None"""
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
45 # We have to delete the map in Fife.
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
46 if self.map:
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
47 self.model.deleteObjects()
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
48 self.model.deleteMap(self.map)
12
d60f1dab8469 Fixed resource path dependencies issue that caused PARPG to crash on start.
M. George Hansen <technopolitica@gmail.com>
parents: 0
diff changeset
49
0
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
50 self.transitions = []
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
51 self.map = None
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
52 self.agent_layer = None
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
53 self.top_layer = None
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
54 # We have to clear the cameras in the view as well, or we can't reuse
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
55 # camera names like 'main'
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
56 #self.view.clearCameras()
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
57 self.initial_cam2_x = 0
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
58 self.cam2_scrolling_right = True
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
59 #self.cameras = {}
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
60 self.cur_cam2_x = 0
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
61 self.target_rotation = 0
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
62 self.outline_renderer = None
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
63
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
64 def makeActive(self):
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
65 """Makes this map the active one.
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
66 @return: None"""
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
67 self.cameras[self.my_cam_id].setEnabled(True)
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
68
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
69 def load(self, filename):
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
70 """Load a map given the filename.
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
71 @type filename: String
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
72 @param filename: Name of map to load
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
73 @return: None"""
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
74 self.reset()
12
d60f1dab8469 Fixed resource path dependencies issue that caused PARPG to crash on start.
M. George Hansen <technopolitica@gmail.com>
parents: 0
diff changeset
75
0
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
76 self.map = loadMapFile(filename, self.engine)
12
d60f1dab8469 Fixed resource path dependencies issue that caused PARPG to crash on start.
M. George Hansen <technopolitica@gmail.com>
parents: 0
diff changeset
77
0
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
78 self.agent_layer = self.map.getLayer('ObjectLayer')
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
79 self.top_layer = self.map.getLayer('TopLayer')
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
80
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
81 # it's possible there's no transition layer
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
82 size = len('TransitionLayer')
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
83 for layer in self.map.getLayers():
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
84 # could be many layers, but hopefully no more than 3
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
85 if(layer.getId()[:size] == 'TransitionLayer'):
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
86 self.transitions.append(self.map.getLayer(layer.getId()))
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
87
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
88 """ Initialize the camera.
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
89 Note that if we have more than one camera in a map file
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
90 we will have to rework how self.my_cam_id works. To make sure
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
91 the proper camera is set as the 'main' camera.
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
92 At this point we also set the viewport to the current resolution."""
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
93 for cam in self.map.getCameras():
12
d60f1dab8469 Fixed resource path dependencies issue that caused PARPG to crash on start.
M. George Hansen <technopolitica@gmail.com>
parents: 0
diff changeset
94 width = self.settings.fife.ScreenWidth
d60f1dab8469 Fixed resource path dependencies issue that caused PARPG to crash on start.
M. George Hansen <technopolitica@gmail.com>
parents: 0
diff changeset
95 height = self.settings.fife.ScreenHeight
0
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
96 viewport = fife.Rect(0, 0, width, height)
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
97 cam.setViewPort(viewport)
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
98 self.my_cam_id = cam.getId()
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
99 self.cameras[self.my_cam_id] = cam
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
100 cam.resetRenderers()
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
101
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
102 self.target_rotation = self.cameras[self.my_cam_id].getRotation()
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
103
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
104 self.outline_renderer = fife.InstanceRenderer.\
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
105 getInstance(
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
106 self.cameras[
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
107 self.my_cam_id
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
108 ])
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
109
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
110 # set the render text
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
111 rend = fife.FloatingTextRenderer.getInstance(self.cameras[
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
112 self.my_cam_id
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
113 ])
12
d60f1dab8469 Fixed resource path dependencies issue that caused PARPG to crash on start.
M. George Hansen <technopolitica@gmail.com>
parents: 0
diff changeset
114 text = self.engine.getGuiManager().createFont('fonts/rpgfont.png',
d60f1dab8469 Fixed resource path dependencies issue that caused PARPG to crash on start.
M. George Hansen <technopolitica@gmail.com>
parents: 0
diff changeset
115 0,
d60f1dab8469 Fixed resource path dependencies issue that caused PARPG to crash on start.
M. George Hansen <technopolitica@gmail.com>
parents: 0
diff changeset
116 self.settings.fife.FontGlyphs)
d60f1dab8469 Fixed resource path dependencies issue that caused PARPG to crash on start.
M. George Hansen <technopolitica@gmail.com>
parents: 0
diff changeset
117
0
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
118 rend.changeDefaultFont(text)
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
119 rend.activateAllLayers(self.map)
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
120 rend.setEnabled(True)
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
121
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
122 # Activate the grid renderer on all layers
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
123 rend = self.cameras['map_camera'].getRenderer('GridRenderer')
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
124 rend.activateAllLayers(self.map)
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
125
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
126 # Activate the grid renderer on all layers
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
127 rend = fife.CoordinateRenderer.getInstance(self.cameras[
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
128 self.my_cam_id
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
129 ])
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
130 rend.setColor(0, 0, 0)
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
131 rend.addActiveLayer(self.map.getLayer("GroundLayer"))
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
132
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
133 # Make World aware that this is now the active map.
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
134 self.model.active_map = self
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
135
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
136 def addPC(self):
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
137 """Add the player character to the map
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
138 @return: None"""
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
139 # Update gamestate.player_character
69
ad75fa042b99 Changes to make PARPG "runable" with grease. (With the correct modified assets)
KarstenBock@gmx.net
parents: 12
diff changeset
140 self.model.game_state.getObjectById("PlayerCharacter").fifeagent.behaviour.onNewMap(self.agent_layer)
0
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
141 self.centerCameraOnPlayer()
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
142
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
143 def toggleRenderer(self, r_name):
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
144 """Enable or disable a renderer.
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
145 @return: None"""
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
146 renderer = self.cameras[self.my_cam_id].getRenderer(str(r_name))
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
147 renderer.setEnabled(not renderer.isEnabled())
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
148
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
149 def isPaused(self):
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
150 """Returns wheter the map is currentply paused or not"""
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
151 # Time multiplier is a float, never do equals on floats
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
152 return not self.map.getTimeMultiplier() >= 1.0
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
153
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
154 def pause(self, paused):
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
155 """ Pause/Unpause the game.
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
156 @return: nothing"""
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
157 if paused:
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
158 self.map.setTimeMultiplier(0.0)
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
159 if not paused and self.isPaused():
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
160 self.map.setTimeMultiplier(1.0)
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
161
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
162 def togglePause(self):
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
163 """ Toggle paused state.
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
164 @return: nothing"""
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
165 self.pause(not self.isPaused())
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
166
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
167 def centerCameraOnPlayer(self):
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
168 """Center the camera on the player"""
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
169 camera = self.cameras[self.my_cam_id]
69
ad75fa042b99 Changes to make PARPG "runable" with grease. (With the correct modified assets)
KarstenBock@gmx.net
parents: 12
diff changeset
170 player_agent = self.model.game_state.getObjectById("PlayerCharacter").fifeagent.behaviour.agent
0
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
171 camera.setLocation(player_agent.getLocation())