Beispiel #1
0
    def set_origin_relative_y(self, y: float):
        if not 0 <= y <= 1:
            error = "Value should be between 0 and 1, got {}".format(y)
            Logger.log_error(error)
            raise AttributeError(error)

        self.origin.y = self.size.height * y
Beispiel #2
0
    def set_origin_relative_x(self, x: float):
        if not 0 <= x <= 1:
            error = "Value should be between 0 and 1, got {}".format(x)
            Logger.log_error(error)
            raise AttributeError(error)

        self.origin.x = self.size.width * x
Beispiel #3
0
 def time_flow_coefficient(self, coefficient: float) -> None:
     """By default it's 1 (without slowdown)"""
     if coefficient < 0:
         Logger.log_error("Time flow coefficient can't be less than zero")
         raise AttributeError(
             "Time flow coefficient can't be less than zero")
     self.time_flow_coeff = coefficient
     self.update_time = 1 / self.frame_rate * coefficient
Beispiel #4
0
    def remove_child(self, child: "Entity"):
        if child.parent is not self:
            error = "The object {} is not a child of the {}".format(
                child, self)
            Logger.log_error(error)
            raise AttributeError(error)

        self.children.remove(child)
Beispiel #5
0
    def set_origin_absolute_y(self, y: float):
        if not 0 <= y <= self.size.width:
            error = "Value should be between 0 and 1 {}, got {}".format(
                self.size.height, y)
            Logger.log_error(error)
            raise AttributeError(error)

        self.origin.y = y
Beispiel #6
0
    def set_origin_absolute_x(self, x: float):
        if not 0 <= x <= self.size.width:
            error = "Value should be between 0 and 1 {}, got {}".format(
                self.size.width, x)
            Logger.log_error(error)
            raise AttributeError(error)

        self.origin.x = x
Beispiel #7
0
    def stop(self):
        if not self.is_running:
            Logger.log_error("You can't stop disabled engine")
            raise Exception("You can't stop disabled engine")

        self.window.shutdown()

        self.is_running = False
        Logger.log_info("Application has just been stopped")
Beispiel #8
0
	def remove_component(self, component: BaseComponent) -> None:
		if component.attached_obj is not self:
			error = "The component {} is not a component of the {}".format(component, self)
			Logger.log_error(error)
			raise AttributeError(error)

		self.components.remove(component)
		component.attached_obj = None
		self.dispatch_event("on_component_removed", ComponentsChanged(component))
Beispiel #9
0
	def add_component(self, component: BaseComponent) -> None:
		if self.is_component(component):
			error = "Component of the same type already exists"
			Logger.log_error(error)
			raise AttributeError(error)

		component.attached_obj = self
		self.components.add(component)
		self.dispatch_event("on_component_added", ComponentsChanged(component))
Beispiel #10
0
	def attach_render_component(self, render_component: SpriteRenderer):
		if self.is_exist(render_component):
			Logger.log_error(
				"Component with the same component id{} and attached object{} already exists".format(
					render_component.id, render_component.attached_obj))
			raise AttributeError(
				"Component with the same component id{} and attached object{} already exists".format(
					render_component.id, render_component.attached_obj))

		self.components.add(render_component)
Beispiel #11
0
    def add_child(self, child: Entity):
        if self.is_child(child):
            Logger.log_error(
                "The object {} is already a child of the {}".format(
                    child, self))
            raise Exception(
                "The object {} is already a child of the {}".format(
                    child, self))

        child.parent = self
        self.children.add(child)
Beispiel #12
0
    def __init__(self,
                 width: float,
                 height: float,
                 name: str,
                 tag: str = "None") -> None:
        """Creates scene which is used to set environments and objects.

		origin (float): define origin coordinates
			can be seated in percentages using set_origin_percentages function
			starting fr om the left upper corner by default (0, 0)
		"""
        super(Scene, self).__init__(name, tag)

        self.add_component(Canvas(width, height, "Scene"))
        # TODO create camera

        Logger.log_info("New scene has just been created")
Beispiel #13
0
	def error_callback(self, error_id, description):
		Logger.log_error("[GLFW] Error id:{}:{}", format(error_id, description))
Beispiel #14
0
	def shutdown(self):
		glfw.terminate()
		Logger.log_info("Shutdown window")
Beispiel #15
0
	def __init__(self, width: float, height: float, title: str):

		super(OpenGLWindow, self).__init__(width, height, title)

		self.window = None
		Logger.log_info("Create window width:{} height:{} title:{}".format(width, height, title))
Beispiel #16
0
    def test_log(self):
        FileLogger.set_default_file(self.this_folder + r"default-logger1.txt")
        LoggingSystem.log_info("Info")
        LoggingSystem.log_error("Error")
        LoggingSystem.log_warning("Warning with long text")
        LoggingSystem.log_succeeded("Critical error")

        FileLogger.add_log_file("first",
                                self.this_folder + r"first-logger1.txt")
        file = FileLogger.get_file_path("first")

        LoggingSystem.log_info("Info", file)
        LoggingSystem.log_warning("Warning with long text", file)
        LoggingSystem.log_succeeded("Critical error", file)
        LoggingSystem.log_error("Error", file)
        LoggingSystem.log_warning("Warning with long text", file)
        LoggingSystem.log_succeeded("Critical error", file)

        FileLogger.add_log_file("second",
                                self.this_folder + r"second-logger1.txt")
        file = FileLogger.get_file_path("second")

        LoggingSystem.log_info("Info", file)
        LoggingSystem.log_error("Error", file)
        LoggingSystem.log_warning("Warning with long text", file)
        LoggingSystem.log_warning("Warning with long text", file)
        LoggingSystem.log_succeeded("Critical error", file)
        LoggingSystem.log_succeeded("Critical error", file)
Beispiel #17
0
 def init_logging_system(self):
     FileLogger.set_default_file("logs.txt")
     # FileLogger.activate()
     ConsoleLogger.activate()
     Logger.activate()
Beispiel #18
0
 def on_event(self, event: Event):
     Logger.log_info(str(event))