import pygame
"""Camera"""
class camera:
    def __init__(self, largura: int, altura: int, largura_janela:int):
        self.deslocamento_x = 0
        self.largura = largura
        self.altura = altura
        self.largura_janela = largura_janela
    def seguir(self, retangulo_alvo: pygame.Rect):
        """Centralizar a camera com o personagem"""
        centro_alvo_x = retangulo_alvo.centerx
        self.deslocamento_x = max(0, centro_alvo_x - self.largura_janela//2)
        desloc_maximo = max(0, self.largura - self.largura_janela)
        if self.deslocamento_x > desloc_maximo:
            self.deslocamento_x = desloc_maximo
    def aplicar(self, retangulo: pygame.Rect) -> pygame.Rect:
        return pygame.Rect-(retangulo.x - self.deslocamento_x, retangulo.y,
                            retangulo.width, retangulo. height)