#camera que acompanha o personagem
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 Pessonagem"""
        centro_alvo_x = retangulo_alvo.centerx
        centro_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)
    

