Ignore:
Timestamp:
08/28/09 15:05:39 (10 years ago)
Author:
Kaydeth_parpg
Message:

Ticket #72: Patch by Kaydeth. The separate objects file was merged back into the main map file that FIFE parses to load each Map. The Map, Engine, and World classes were all updated to allow game object creation to happen as the map file is loaded. loaders.py and xmlmap.py were copied from the FIFE code base and made local so that we can now customize how we pass the parsed map and object information to FIFE.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/game/scripts/map.py

    r262 r264  
    1717 
    1818import fife, time 
    19 from loaders import loadMapFile 
     19from local_loaders.loaders import loadMapFile 
    2020from scripts.common.eventlistenerbase import EventListenerBase 
    2121 
     
    2525class Map(fife.MapChangeListener): 
    2626    """Map class used to flag changes in the map""" 
    27     def __init__(self, engine): 
     27    def __init__(self, engine, data): 
    2828        # init mapchange listener 
    2929        fife.MapChangeListener.__init__(self) 
    3030        self.map = None 
    3131        self.engine = engine 
     32        self.data = data 
    3233         
    3334        # init map attributes 
     
    7273           @return: None""" 
    7374        self.reset() 
    74         self.map = loadMapFile(filename, self.engine) 
    75          
     75        self.map = loadMapFile(filename, self.engine, self.data) 
     76          
    7677        # there must be a PC object on the objects layer! 
    7778        self.agent_layer = self.map.getLayer('ObjectLayer') 
     
    100101    def addPC(self, agent): 
    101102        """Add the player character to the map 
    102            @type agent: Fife.instance 
    103            @param : The object to use as the PC sprite 
     103           @type agent: Fife.instance of PC 
    104104           @return: None""" 
    105105        # actually this is real easy, we just have to 
     
    107107        self.cameras['main'].attach(agent) 
    108108 
    109     def addObject(self, xpos, ypos, gfx, name): 
    110         """Add an object or an NPC to the map. 
    111            It makes no difference to fife which is which. 
    112            @type xpos: integer 
    113            @param xpos: x position of object 
    114            @type ypos: integer 
    115            @param ypos: y position of object 
    116            @type gfx: string 
    117            @param gfx: name of gfx image 
    118            @type name: string 
    119            @param name: name of object 
    120            @return: None""" 
    121         obj = self.agent_layer.createInstance( 
    122                 self.model.getObject(str(gfx), "PARPG"), 
    123                 fife.ExactModelCoordinate(float(xpos), float(ypos), 0.0), str(name)) 
    124         obj.setRotation(0) 
    125         fife.InstanceVisual.create(obj) 
     109    def addObject(self, name, obj): 
     110        """Add an object to this map0 
     111            Inputs: 
     112                name - ID of object 
     113                obj - FIFE instance of object 
     114            Return: 
     115                Nothing 
     116        """ 
    126117        # save it for later use 
    127118        self.obj_hash[name]=obj 
Note: See TracChangeset for help on using the changeset viewer.