Mercurial > parpg-source
annotate gamesceneview.py @ 17:7b31de1dc964
FifeManager no longer subclasses ApplicationBase
PARPGApplication stores an instance of tbe manager instead
author | KarstenBock@gmx.net |
---|---|
date | Wed, 03 Aug 2011 22:57:52 +0200 |
parents | 7a89ea5404b1 |
children | 98f26f7636d8 |
rev | line source |
---|---|
0
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
1 # This file is part of PARPG. |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
2 |
7a89ea5404b1
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 |
7a89ea5404b1
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 |
7a89ea5404b1
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 |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
6 # (at your option) any later version. |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
7 |
7a89ea5404b1
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, |
7a89ea5404b1
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 |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
11 # GNU General Public License for more details. |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
12 |
7a89ea5404b1
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 |
7a89ea5404b1
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/>. |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
15 |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
16 from sounds import SoundEngine |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
17 from viewbase import ViewBase |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
18 from fife import fife |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
19 |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
20 class GameSceneView(ViewBase): |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
21 """GameSceneView is responsible for drawing the scene""" |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
22 def __init__(self, engine, model): |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
23 """Constructor for GameSceneView |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
24 @param engine: A fife.Engine instance |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
25 @type engine: fife.Engine |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
26 @param model: a script.GameModel instance |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
27 @type model: script.GameModel |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
28 """ |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
29 super(GameSceneView, self).__init__(engine, model) |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
30 |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
31 # init the sound |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
32 self.sounds = SoundEngine(engine) |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
33 |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
34 self.hud = None |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
35 |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
36 # The current highlighted object |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
37 self.highlight_obj = None |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
38 |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
39 # faded objects in top layer |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
40 self.faded_objects = set() |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
41 |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
42 def displayObjectText(self, obj_id, text, time=1000): |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
43 """Display on screen the text of the object over the object. |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
44 @type obj_id: id of fife.instance |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
45 @param obj: id of object to draw over |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
46 @type text: String |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
47 @param text: text to display over object |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
48 @return: None""" |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
49 try: |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
50 if obj_id: |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
51 obj = self.model.active_map.agent_layer.getInstance(obj_id) |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
52 else: |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
53 obj = None |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
54 except RuntimeError as error: |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
55 if error.args[0].split(',')[0].strip() == "_[NotFound]_": |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
56 obj = None |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
57 else: |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
58 raise |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
59 if obj: |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
60 obj.say(str(text), time) |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
61 |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
62 def onWalk(self, click): |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
63 """Callback sample for the context menu.""" |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
64 self.hud.hideContainer() |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
65 self.model.game_state.player_character.run(click) |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
66 |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
67 def refreshTopLayerTransparencies(self): |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
68 """Fade or unfade TopLayer instances if the PlayerCharacter |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
69 is under them.""" |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
70 if not self.model.active_map: |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
71 return |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
72 |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
73 # get the PlayerCharacter's screen coordinates |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
74 camera = self.model.active_map.cameras[self.model.active_map.my_cam_id] |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
75 point = self.model.game_state.player_character.\ |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
76 behaviour.agent.getLocation() |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
77 scr_coords = camera.toScreenCoordinates(point.getMapCoordinates()) |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
78 |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
79 # find all instances on TopLayer that fall on those coordinates |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
80 instances = camera.getMatchingInstances(scr_coords, |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
81 self.model.active_map.top_layer) |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
82 instance_ids = [ instance.getId() for instance in instances ] |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
83 faded_objects = self.faded_objects |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
84 |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
85 # fade instances |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
86 for instance_id in instance_ids: |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
87 if instance_id not in faded_objects: |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
88 faded_objects.add(instance_id) |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
89 self.model.active_map.top_layer.getInstance(instance_id).\ |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
90 get2dGfxVisual().setTransparency(128) |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
91 |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
92 # unfade previously faded instances |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
93 for instance_id in faded_objects.copy(): |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
94 if instance_id not in instance_ids: |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
95 faded_objects.remove(instance_id) |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
96 self.model.active_map.top_layer.getInstance(instance_id).\ |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
97 get2dGfxVisual().setTransparency(0) |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
98 |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
99 |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
100 #def removeHighlight(self): |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
101 |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
102 |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
103 def highlightFrontObject(self, mouse_coords): |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
104 """Highlights the object that is at the |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
105 current mouse coordinates""" |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
106 if not self.model.active_map: |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
107 return |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
108 if mouse_coords: |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
109 front_obj = self.model.getObjectAtCoords(mouse_coords) |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
110 if front_obj != None: |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
111 if self.highlight_obj == None \ |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
112 or front_obj.getId() != \ |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
113 self.highlight_obj: |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
114 if self.model.game_state.hasObject(front_obj.getId()): |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
115 self.displayObjectText(self.highlight_obj, "") |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
116 self.model.active_map.outline_renderer.removeAllOutlines() |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
117 self.highlight_obj = front_obj.getId() |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
118 self.model.active_map.outline_renderer.addOutlined( |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
119 front_obj, |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
120 0, |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
121 137, 255, 2) |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
122 # get the text |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
123 item = self.model.objectActive(self.highlight_obj) |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
124 if item is not None: |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
125 self.displayObjectText(self.highlight_obj, |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
126 item.name) |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
127 else: |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
128 self.model.active_map.outline_renderer.removeAllOutlines() |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
129 self.highlight_obj = None |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
130 |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
131 |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
132 def moveCamera(self, direction): |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
133 """Move the camera in the given direction. |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
134 @type direction: list of two integers |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
135 @param direction: the two integers can be 1, -1, or 0 |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
136 @return: None """ |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
137 |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
138 if 'cameras' in dir(self.model.active_map): |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
139 cam = self.model.active_map.cameras[self.model.active_map.my_cam_id] |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
140 location = cam.getLocation() |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
141 position = location.getMapCoordinates() |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
142 |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
143 #how many pixls to move by each call |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
144 move_by = 1 |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
145 #create a new DoublePoint3D and add it to position DoublePoint3D |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
146 new_x, new_y = move_by * direction[0], move_by * direction[1] |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
147 |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
148 position_offset = fife.DoublePoint3D(int(new_x), int(new_y)) |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
149 position += position_offset |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
150 |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
151 #give location the new position |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
152 location.setMapCoordinates(position) |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
153 |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
154 #detach the camera from any objects |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
155 cam.detach() |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
156 #move the camera to the new location |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
157 cam.setLocation(location) |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
158 |
7a89ea5404b1
Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff
changeset
|
159 |