Changeset 77 for trunk/PARPG/scripts
- Timestamp:
- 06/01/09 12:10:27 (11 years ago)
- Location:
- trunk/PARPG/scripts
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/PARPG/scripts/engine.py
r70 r77 132 132 def addPC(self,pc): 133 133 """Add the PC to the world""" 134 self.view.addObject(float(pc[0]), float(pc[1]),"PC" )134 self.view.addObject(float(pc[0]), float(pc[1]),"PC","PC") 135 135 self.PC = Hero("PC", self.view.agent_layer) 136 136 # ensure the PC starts on a default action … … 144 144 for i in objects: 145 145 if(i[0] == True): 146 self.view.addObject(float(i[1]), float(i[2]), i[3] )146 self.view.addObject(float(i[1]), float(i[2]), i[3], i[4]) 147 147 # now add it as an engine object 148 148 self.objects.append(GameObject(i)) … … 152 152 and into this class""" 153 153 for i in npcs: 154 self.view.addObject(float(i[0]), float(i[1]), i[2] )154 self.view.addObject(float(i[0]), float(i[1]), i[2], i[3]) 155 155 # now add as engine data 156 156 self.npcs.append(NPC(int(float(i[0])), int(float(i[1])), 157 157 i[3], i[4])) 158 158 159 def getObject String(self, xpos, ypos):160 """Get the objects description of itself"""159 def getObjectText(self, xpos, ypos): 160 """Get the objects id and description of itself""" 161 161 # cycle through all of the objects; do we have something there? 162 162 for i in self.objects: 163 163 if((xpos == i.xpos)and(ypos == i.ypos)): 164 164 # yes, we have a match, so return the text 165 return i. text165 return i.id, i.text 166 166 for i in self.npcs: 167 167 if((xpos == i.xpos)and(ypos == i.ypos)): 168 168 # yes, we have a match, so return the text 169 return i. text169 return i.id, i.text 170 170 # nothing, but return the empty string in case we print it 171 return "" 171 return "","" 172 172 173 173 def loadMap(self,map_file): -
trunk/PARPG/scripts/world.py
r76 r77 72 72 self.data = None 73 73 self.mouseCallback = None 74 self.obj_hash={} 74 75 75 76 self.hud = hud.Hud(self.engine, TDS) … … 125 126 self.cameras['main'].attach(agent) 126 127 127 def addObject(self, xpos, ypos, name):128 def addObject(self, xpos, ypos, gfx, name): 128 129 """Add an object or an NPC to the map 129 130 It makes no difference to fife which is which""" 130 131 obj = self.agent_layer.createInstance( 131 self.model.getObject(str( name), "PARPG"),132 fife.ExactModelCoordinate(xpos,ypos,0.0), str( name))132 self.model.getObject(str(gfx), "PARPG"), 133 fife.ExactModelCoordinate(xpos,ypos,0.0), str(gfx)) 133 134 obj.setRotation(0) 135 # save it for later use 136 self.obj_hash[name]=obj 134 137 fife.InstanceVisual.create(obj) 138 139 def displayObjectText(self, obj, text): 140 """Display on screen the text of the object over the object""" 141 # make sure that the object exists first 142 if obj in self.obj_hash: 143 # NOT WORKING! 144 #self.obj_hash[obj].say(text,3500) 145 print text 135 146 136 147 def displayInventory(self, callFromHud): … … 213 224 # the engine code should know.... 214 225 coords = self.getCoords(click).getLayerCoordinates() 215 obj = self.data.getObjectString(coords.x, coords.y)226 obj, text = self.data.getObjectText(coords.x, coords.y) 216 227 if(obj != ""): 217 print obj228 self.displayObjectText(obj, text) 218 229 219 230 def toggle_renderer (self, r_name):
Note: See TracChangeset
for help on using the changeset viewer.