Changeset 133


Ignore:
Timestamp:
06/13/09 15:09:26 (10 years ago)
Author:
meggie_parpg
Message:
  • Added a target position to Door objects so that the PC will start on that

position.

  • Removed the tele_tile class and made tiles into doors. In the future, we'll

want to make them on the Ground layer instead of the Object Layer.

  • Changed some things in the map_objects files.
Location:
trunk/PARPG
Files:
1 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/PARPG/maps/map2_objects.xml

    r128 r133  
    1010    <!-- Object blocking is set in the objects own xml file --> 
    1111    <object display="True" gfx="crate" xpos="1.0" ypos="1.0" id="crate03" 
    12             carry="0" contain="1" text="Yet another crate!"></object> 
     12        carry="0" contain="1" text="Yet another crate!"></object> 
     13    <!-- There can be a number of doors, which serve as transition triggers --> 
     14    <door display="True" gfx="grass-a" xpos="-14" ypos="-17" 
     15          id="tt01" carry="0" contain="0" text="Start Map" map="map" 
     16          txpos="-14" typos="10"></door> 
    1317</objects> 
    1418 
  • trunk/PARPG/maps/map_objects.xml

    r130 r133  
    2222    <!-- There can be a number of doors, which serve as transition triggers --> 
    2323    <door display="True" gfx="shanty-door" xpos="-2.0" ypos="6.0" 
    24           id="sh-door" carry="0" contain="0" text="Door" map="map2"></door> 
    25     <!-- There can be any number of 'teleport tiles', or tiles that move the 
    26          PC around (perhaps the map name could be stored here) --> 
    27     <tele_tile target="map2" xpos="-14" ypos="10" txpos="-14" typos="-17"> 
    28         </tele_tile> 
     24        id="sh-door" carry="0" contain="0" text="Door" map="map2" 
     25        txpos="-5" typos="-5"></door> 
     26    <door display="True" gfx="snow02" xpos="-14" ypos="10" 
     27          id="tt01" carry="0" contain="0" text="New Map" map="map2" 
     28          txpos="-14" typos="-17"></door> 
    2929</objects> 
    3030 
  • trunk/PARPG/scripts/engine.py

    r132 r133  
    2020from agents.npc import NPC 
    2121from objects import GameObject 
    22 from tele_tiles import TeleTile 
    2322from objLoader import LocalXMLParser 
    2423 
     
    3736    """A MapDoor is an item that when clicked transports the player to 
    3837       another map""" 
    39     def __init__(self, name, new_map): 
     38    def __init__(self, name, new_map, targ_tup): 
    4039        self.id = name 
    4140        self.map = "maps/"+new_map+".xml" 
     41        # self.targ_coord: a (int, int) which stores the intended location  
     42        # of the PC on the new map 
     43        self.targ_coords = targ_tup 
    4244 
    4345class Engine: 
     
    5456        self.objects = [] 
    5557        self.doors = [] 
    56         self.tele_tiles = [] 
     58        self.PC_targLoc = None 
    5759 
    5860    def reset(self): 
    5961        """Clears the data on a map reload so we don't have objects/npcs from 
    60            other maps hanging around. Right now I'm clearing the PC, but we'll 
    61            have to evaluate that when we get more details on how the stepping  
    62            on tiles works.""" 
     62           other maps hanging around.""" 
    6363        self.PC = None 
    6464        self.npcs = [] 
    6565        self.objects = [] 
    6666        self.doors = [] 
    67         self.tele_tiles = [] 
    6867 
    6968    def loadObjects(self, filename): 
     
    8988        self.addNPCs(cur_handler.npcs) 
    9089        self.addObjects(cur_handler.objects) 
    91         self.addTeleTiles(cur_handler.tele_tiles) 
    9290        self.addDoors(cur_handler.doors) 
    9391        objects_file.close() 
     
    9694    def addPC(self,pc): 
    9795        """Add the PC to the world""" 
    98         self.view.addObject(float(pc[0]), float(pc[1]),"PC","PC") 
     96        if self.PC_targLoc: 
     97            self.view.addObject(float(self.PC_targLoc[0]), \ 
     98                    float(self.PC_targLoc[1]), "PC", "PC") 
     99            self.PC_targLoc = None 
     100        else: 
     101            self.view.addObject(float(pc[0]), float(pc[1]),"PC","PC") 
    99102        self.PC = Hero("PC", self.view.agent_layer) 
    100103        # ensure the PC starts on a default action 
     
    122125            self.npcs[-1].start() 
    123126 
    124     def addTeleTiles(self, tiles): 
    125         """Add all of the teleportation tiles we found into this class""" 
    126         # we want to use the ground layer for now 
    127         layer = self.view.map.getLayer('GroundLayer') 
    128         for i in tiles: 
    129             self.tele_tiles.append(TeleTile(i[0], i[1], i[2], layer)) 
    130  
    131127    def addDoors(self, doors): 
    132128        """Add all the doors to the map as well 
    133129           As an object they have already been added""" 
    134130        for i in doors: 
    135             self.doors.append(MapDoor(i[0], i[1])) 
     131            self.doors.append(MapDoor(i[0], i[1], i[2])) 
    136132 
    137133    def objectActive(self, ident): 
     
    164160            if(obj_id == i.id): 
    165161                # load the new map 
     162                self.PC_targLoc = i.targ_coords 
    166163                self.loadMap(str(i.map)) 
    167164                return None 
     
    185182        self.view.load(map_file) 
    186183        # then we update FIFE with the PC, NPC and object details 
    187         self.reset()         
     184        self.reset() 
    188185        self.loadObjects(map_file[:-4]+"_objects.xml") 
    189  
    190     def checkTeleTiles(self, location): 
    191         """Iterates through the possible teleportation tiles to see if the  
    192             given location is a teleportation tile 
    193         @param location: a fife.Location to check against the tiles 
    194         @return: the TeleTile if a tile is matched or False""" 
    195         for tile in self.tele_tiles: 
    196             if tile.matchLocation(location): 
    197                 return tile 
    198         return False 
    199186 
    200187    def handleMouseClick(self,position): 
  • trunk/PARPG/scripts/objLoader.py

    r130 r133  
    2929        self.npcs = [] 
    3030        self.doors = [] 
    31         self.tele_tiles = [] 
    3231     
    3332    def getParser(self): 
     
    9998            try: 
    10099                new_map = attrs.getValue("map") 
    101             except(KeyError): 
    102                 sys.stderr.write("Error: Door has no map!\n") 
    103                 sys.exit(False) 
    104             # format is [id,map_name] 
    105             self.doors.append([self.objects[-1][4],new_map]) 
    106         elif(name == "tele_tile"): 
    107             try: 
    108                 target = attrs.getValue("target") 
    109                 xpos = attrs.getValue("xpos") 
    110                 ypos = attrs.getValue("ypos") 
    111100                txpos = attrs.getValue("txpos") 
    112101                typos = attrs.getValue("typos") 
    113102            except(KeyError): 
    114                 sys.stderr.write("Error: Data missing in \ 
    115                                   tele_tile definition\n") 
     103                sys.stderr.write("Error: Door has no map or no target!\n") 
    116104                sys.exit(False) 
    117             self.tele_tiles.append([target, tuple([int(xpos), int(ypos)]), \ 
    118                     tuple([int(txpos), int(typos)])]) 
    119  
     105            # format is [id,map_name,target coords on new map] 
     106            self.doors.append([self.objects[-1][4],new_map, \ 
     107                    tuple([txpos, typos])]) 
Note: See TracChangeset for help on using the changeset viewer.