Пример #1
0
    def ladder_below(self, rect):
        test_rect = Rect((rect.left, rect.top + 1), (rect.width, rect.height))
        colliding_ladders = list(
            filter((lambda ladder: test_rect.colliderect(ladder.rect)),
                   self.ladders.values()))

        return colliding_ladders[0] if len(colliding_ladders) > 0 else None
Пример #2
0
    def platform_right_adjacent(self, rect):
        test_rect = Rect((rect.right + 1, rect.top), (rect.width, rect.height))
        colliding_platforms = list(
            filter((lambda platform: test_rect.colliderect(platform.rect)),
                   self.platforms.values()))

        return colliding_platforms[0] if len(colliding_platforms) > 0 else None
Пример #3
0
    def platform_below(self, rect):
        test_rect = Rect((rect.left, rect.top + 1), (rect.width, rect.height))
        colliding_platforms = list(
            filter((lambda platform: test_rect.colliderect(platform.rect)),
                   self.platforms.values()))

        return colliding_platforms[0] if len(colliding_platforms) > 0 else None
Пример #4
0
    def get_entities_inside_region(self, rect: Rect):
        # return any entity, regardless of layer, that is intersecting with the given rect
        found = set()

        for layer in self.layers:
            for entity in self.layers[layer]:
                if rect.collidepoint(*entity.position) or rect.colliderect(
                        entity.rect):
                    found.add(entity)

        return list(found)