예제 #1
0
 def teleport(self, tile_map):
     """Teleports the ghost between one of the tiles outside the tunnel, depending on the current tile position."""
     row = -2 if self.tile_index[1] == 29 else 28
     self.handle_tile_content(tile_map[(self.tile_index[0], row)], tile_map)
     self.prev_tile_index = self.tile_index
     self.tile_index = (self.tile_index[0], row)
     self.position = Vector2D(*settings.get_position(self.tile_index))
예제 #2
0
파일: main.py 프로젝트: Naxaes/pacman
def add_points(tile_map):
    energizer_tiles = [(6, 1), (6, 26), (26, 1), (26, 26)]
    energizer_pos = [
        settings.get_position(x, offset="topleft") for x in energizer_tiles
    ]
    empty_pos = list(itertools.product(range(12, 23),
                                       range(7, 21)))  # Square by the house.
    for tile in tile_map.tile.values():
        if settings.get_tile_index(tile.rect.topleft) in empty_pos:
            continue
        if tile.is_any_type(
                "path", "restricted") and 0 <= tile.rect.x < settings.WIDTH:
            if any(tile.rect.collidepoint(pos) for pos in energizer_pos):
                tile.content.add(Enegizer(tile.rect))
            else:
                tile.content.add(Point(tile.rect))
예제 #3
0
 def teleport(self):
     if self.tile_index[1] == -2:
         self.tile_index = (self.tile_index[0], 28)
     else:
         self.tile_index = (self.tile_index[0], -1)
     self.position = Vector2D(*settings.get_position(self.tile_index))