Пример #1
0
 def _concrete_map(self, raw_map):
     stone_wall_tile_factory = TileFactory('stone_wall')
     grass_floor_tile_factory = TileFactory('grass_floor')
     
     # Fill all with wall
     rectangle = geometry.Rectangle(geometry.get_point(0, 0), w=self.WIDTH, h=self.HEIGHT)
     raw_map = self._fill_rectangle(raw_map, rectangle, stone_wall_tile_factory)
     
     # Fill middle with floor
     rectangle = geometry.Rectangle(geometry.get_point(1, 1), w=self.WIDTH - 2, h=self.HEIGHT - 2)
     raw_map = self._fill_rectangle(raw_map, rectangle, grass_floor_tile_factory)
     
     return raw_map
Пример #2
0
    def move_towards(self, turn_summary, param, active=False):
        ''' For moving map objects around. A move by a Thing does not
            count as a turn (only Actors can take a turn).

                active: set to 'False' if movement is forced
                            (push, recoil, etc.) , which is always the
                            default case for Thing objects
            
            Returns TurnSummary, with blocking Tile or Thing in
            'TurnSummary.blocked_by'.
            
        '''
        target_x, target_y = get_vector(param)
        target_xy = get_point(self.xy.x + target_x, self.xy.y + target_y)

        # Check for blocking Tile or Thing
        turn_summary.blocked_by = self.proxy.blocked_by_tile(target_xy) \
        or self.proxy.blocked_by_obj(target_xy)

        # Blocked moves        
        if turn_summary.blocked_by:
            if active:
                # Nothing happens in this class
                pass
            else:
                # Crashbang!
                # TODO: collision damage
                pass

        # Successful move            
        else:
            self.xy = target_xy

        return turn_summary
Пример #3
0
 def spawn_at_random(self, obj):
     success = False
     
     while not success:
         x = rnd.get_int(0, self.WIDTH - 1)
         y = rnd.get_int(0, self.HEIGHT - 1) 
         success = self.spawn_at(obj, geometry.get_point(x, y))
     
     return success
Пример #4
0
 def _create_spawn_points(self, raw_map):
     _xy_list = list()
     
     for _n in xrange(self._number_of_spawn_points):
         xy = None
         while not xy:
             x = rnd.get_int(1, self.WIDTH) - 1
             y = rnd.get_int(1, self.WIDTH) - 1
             if not raw_map[x][y].blocks:
                 raw_map[x][y].update_col(color.get_color(color.PURPLE, 2))
                 xy = geometry.get_point(x, y)
         _xy_list.append(xy)
     
     return tuple(_xy_list)