Ignore:
Timestamp:
05/11/09 07:54:38 (11 years ago)
Author:
maximinus_parpg
Message:

Objects now loaded from seperate XML file.
Cleaned up some small areas in various .py files
Added crate details.
Added some simple documentation in world.py
Removed some remaining RIO code that was not needed.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/PARPG/scripts/engine.py

    r54 r55  
    1717 
    1818# there should be NO references to FIFE here! 
    19 import fife 
    2019from xml.sax import make_parser 
    2120from xml.sax.handler import ContentHandler 
     
    2827# save us writing a bunch of new code. 
    2928# However, the objects and characters on a map are liable to change 
    30 # whilst the game is being changed, so when we change the map, we 
    31 # need to grab the objects and npc data EITHER from the engine state, 
    32 # or from another file if in their initial state 
     29# whilst the game is being run, so when we change the map, we need to 
     30# to grab the objects and npc data EITHER from the engine state, or grab 
     31# from another file if in their initial state 
    3332# This other file has the name AAA_objects.xml where AAA.xml is the name 
    3433# of the original mapfile. 
     
    4443     
    4544    def startElement(self,name,attrs): 
    46         """Called every time we meet a new element""" 
     45        """Called every time we meet a new element in the XML file""" 
    4746        # we are only looking for the 'layer' elements, the rest we ignore 
    4847        if(name=="PC"): 
     
    119118        return True 
    120119 
     120    def addObjects(self): 
     121        """Add all of the objects we found into the fife map""" 
     122        for i in self.objects: 
     123            self.view.addObject(float(i[0]),float(i[1]),i[2]) 
     124 
    121125    def loadMap(self,map_file): 
    122126        """Load a new map 
     
    128132        # finally, we update FIFE with the PC, NPC and object details 
    129133        self.view.addPC(self.pc[0],self.pc[1]) 
     134        self.addObjects() 
    130135 
Note: See TracChangeset for help on using the changeset viewer.