Changeset 178


Ignore:
Timestamp:
07/01/09 20:16:02 (10 years ago)
Author:
meggie_parpg
Message:

Added new objectLoader. Changed GameObject? constructor to take an xpos and a ypos instead of a tuple, which was necessary because of the way the dictionary unpacking works. Changed the default gfx in WoodenCrate? to make it so that the view can understand it. Added something to engine so that it will make the crate. Ugly hard-coding to get rid of later.

Location:
trunk/PARPG/scripts
Files:
1 added
3 edited

Legend:

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

    r177 r178  
    2424from gamestate import GameState 
    2525from gamedata import * 
     26from objectLoader import ObjectXMLParser 
    2627 
    2728# design note: 
     
    120121        # now open and read the XML file 
    121122        cur_handler = LocalXMLParser() 
     123        other_handler = ObjectXMLParser() 
    122124        parser = cur_handler.getParser() 
    123125        parser.setContentHandler(cur_handler) 
    124126        parser.parse(objects_file) 
     127        objects_file.seek(0) 
     128        other_handler.getObjects(objects_file) 
    125129        objects_file.close() 
    126130        # must have at least 1 PC 
     
    133137        self.addObjects(cur_handler.objects) 
    134138        self.addDoors(cur_handler.doors) 
     139        self.addGameObjs(other_handler.local_info) 
    135140        return True 
     141 
     142    def addGameObjs(self, objList): 
     143        """Add all found game objects to the world 
     144           @type objList: list 
     145           @param objList: a list of the objects found in the xml file 
     146           @return: None""" 
     147        for obj in objList: 
     148            print obj.X, obj.Y, obj.gfx['map'], obj.ID 
     149            self.view.addObject(obj.X, obj.Y, obj.gfx['map'], obj.ID) 
    136150 
    137151    def addPC(self,pc): 
  • trunk/PARPG/scripts/objects/base.py

    r175 r178  
    5454    This must be the first class (left to right) inherited by any game object. 
    5555    """ 
    56     def __init__ (self, ID, gfx = {}, coords = (0.0,0.0), map_id = None,  
     56    def __init__ (self, ID, gfx = {}, xpos = 0.0, ypos = 0.0, map_id = None,  
    5757                  blocking=True, name="Generic object", text="Item description", 
    5858                  **kwargs): 
     
    7575        self.ID = ID 
    7676        self.gfx = gfx 
    77         self.X, self.Y = float(coords[0]), float (coords[1]) 
     77        self.X = xpos 
     78        self.Y = ypos 
    7879        self.map_id = map_id 
    7980        self.blocking = True 
  • trunk/PARPG/scripts/objects/containers.py

    r176 r178  
    2424 
    2525class WoodenCrate (composed.ImmovableContainer): 
    26     def __init__ (self, ID, name = 'Wooden Crate', text = 'A battered down crate', 
    27                   gfx = {'map': 'objects/objects/crate/image.png'}, **kwargs): 
    28         super(WoodenCrate,self).__init__ (ID, name = name, gfx = gfx, text = text, **kwargs) 
     26    def __init__ (self, ID, name = 'Wooden Crate', \ 
     27            text = 'A battered down crate', gfx = {'map': 'crate'}, **kwargs): 
     28        super(WoodenCrate,self).__init__ (ID, name = name, gfx = gfx, \ 
     29                text = text, **kwargs) 
Note: See TracChangeset for help on using the changeset viewer.