Ignore:
Timestamp:
06/13/09 07:43:28 (10 years ago)
Author:
maximinus_parpg
Message:

Added new functionality.
Right-click on a door to go to a new map.

File:
1 edited

Legend:

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

    r128 r130  
    3434# of the original mapfile. 
    3535 
     36class MapDoor: 
     37    """A MapDoor is an item that when clicked transports the player to 
     38       another map""" 
     39    def __init__(self, name, new_map): 
     40        self.id = name 
     41        self.map = "maps/"+new_map+".xml" 
     42 
    3643class Engine: 
    3744    """Engine holds the logic for the game 
     
    4653        self.npcs = [] 
    4754        self.objects = [] 
     55        self.doors = [] 
    4856        self.tele_tiles = [] 
    4957 
     
    8189        self.addObjects(cur_handler.objects) 
    8290        self.addTeleTiles(cur_handler.tele_tiles) 
     91        self.addDoors(cur_handler.doors) 
    8392        return True 
    8493 
     
    118127            self.tele_tiles.append(TeleTile(i[0], i[1], i[2], layer)) 
    119128 
     129    def addDoors(self, doors): 
     130        """Add all the doors to the map as well 
     131           As an object they have already been added""" 
     132        for i in doors: 
     133            self.doors.append(MapDoor(i[0], i[1])) 
     134 
    120135    def objectActive(self, ident): 
    121136        """Given the objects ID, pass back the object if it is active, 
     
    142157                # keep it simple for now 
    143158                actions.append(("Talk",None)) 
    144                 actions.append(("Attack",None)) 
     159                actions.append(("Attack",None))      
     160        # is it a door? 
     161        for i in self.doors: 
     162            if(obj_id == i.id): 
     163                # load the new map 
     164                self.loadMap(str(i.map)) 
    145165        # is it in our objects? 
    146166        for i in self.objects: 
Note: See TracChangeset for help on using the changeset viewer.