from . import data

class Camera:
    def __init__(self):
        self.position = data.camera_position
        self.return_change : bool = False

    @staticmethod
    def set_screen_center(x : int, y : int):
        data.screen_center = {"x" : x, "y" : y}
        data.camera_position["x"] = x
        data.camera_position["y"] = y
    @staticmethod
    def get_screen_center(string : str = 1):
        return int(data.screen_center[string])
    
    @staticmethod
    def set_minimum(minimum : float):
        data.minimum = minimum

    def set_return_change(self, value : bool):
        self.return_change = value

    def move(self, x, y):
        self.position["x"] += x
        self.position["y"] += y
        if self.return_change:
            return self.position

    def set_position(self, x, y):
        self.position["x"] = x
        self.position["y"] = y
        if self.return_change:
            return self.position

    def get_position(self):
        return self.position



    def add_size(self, size):
        if data.camera_size + size <= data.minimum:
            return
        data.camera_size += size
        if self.return_change:
            return data.camera_size

    def set_size(self, size):
        data.camera_size = size
        if self.return_change:
            return data.camera_size

    def get_size(self):
        return data.camera_size




    def turn_left(self, angle):
        data.camera_d += angle
        if self.return_change:
            return data.camera_d

    def turn_right(self, angle):
        data.camera_d -= angle
        if self.return_change:
            return data.camera_d
    
    def set_direction(self, angle):
        data.camera_d = angle
        if self.return_change:
            return data.camera_d

    def get_direction(self):
        return data.camera_d
    

Camera = Camera()

__all__ = ["Camera"]