Beispiel #1
0
    def __init__(self, camera):
        from Capsian.values import CPSN_PERSPECTIVE_CAMERA

        super().__init__(camera)

        if not isinstance(camera, CPSN_PERSPECTIVE_CAMERA):
            Log.critical(f"{repr(camera)} is not a valid camera for Scene3D!")
            return
        
        if not self.enable():
            Log.error(f"Could not enable scene {self}")
Beispiel #2
0
    def __init__(self, camera):
        from Capsian.values import CPSN_ORTHOGRAPHIC_CAMERA
        
        super().__init__(camera)

        self.dynamic_gui = types.LimitedLenghtObjectArray(200.000, False)

        if not isinstance(camera, CPSN_ORTHOGRAPHIC_CAMERA):
            Log.critical(f"{repr(camera)} is not a valid camera for Scene2D!")
            return
        
        if not self.enable():
            Log.error(f"Could not enable scene {self}")
Beispiel #3
0
    def __init__(self, camera):
        from Capsian.values import CPSN_HUD_SCENE, CPSN_PERSPECTIVE_CAMERA

        super().__init__(camera)

        self.hud_batch   = pyglet.graphics.Batch()
        self.dynamic_hud = types.LimitedLenghtObjectArray(30.0000, False)

        if not isinstance(camera, CPSN_PERSPECTIVE_CAMERA):
            Log.critical(f"{repr(camera)} is not a valid camera for OverlayScene!")
            return
        
        if not self.enable():
            Log.error(f"Could not enable scene {self}")
Beispiel #4
0
    def set_viewport(self, camera) -> None:
        """
        Description
        -----------
            Sets the rendering viewport to the specified one

        Parameters
        ----------
            camera | The new viewport | PerspectiveCamera\OrthographicCamera
        """

        if not self.alive > 0:
            return

        if not hasattr(camera, "init"):
            Log.critical("The specified camera is not valid")
            return

        camera.init()
Beispiel #5
0
    def __init__(self, camera, fullscreen_key=key.F11, *args, **kwargs):
        """
        Parameters
        ----------
            camera         | A Capsian Camera Object                         | PerspectiveCamera\OrthographicCamera
            fullscreen_key | The key that will trigger fullscreen on and off

        Additional Parameters (From Pyglet)
        -----------------------------------
            width      | The width of the window                    | int
            height     | The height of the window                   | int
            vsync      | Weather VSync is on or off                 | bool
            resizable  | Weather the window is resizable or not     | bool
            fullscreen | Weather fullscreen is on by default or not | bool
        """

        # Create window
        super().__init__(*args,
                         **kwargs,
                         screen=pyglet.canvas.Display.get_default_screen(
                             pyglet.canvas.Display()))

        # Variable declaration
        self.mouse_lock = False
        self.fullscreen_key = fullscreen_key

        # Others
        self.lighting = False
        engine.main_window = self
        self.alive = 1

        # Looks
        self.move_to_center()

        # Checks weather the camera is compatible
        if not hasattr(camera, "init"):
            Log.critical("The specified camera is not valid")
            return

        self.view_port = camera
        camera.init()
Beispiel #6
0
    def __init__(self,
                 font: str,
                 font_size: float,
                 text: str,
                 color,
                 transform=Transform(),
                 scene=PlaceholderScene(),
                 *args,
                 **kwargs):
        """
        Parameters
        ----------
            font      | The font you want to use for the label          | str
            font-size | The font size you want to use                   | float
            text      | The text of the label                           | str
            color     | The color of the label                          | list [R, G, B, A]
            scene     | The Capsian Scene of which the label is part of | Scene2D
        """

        if not isinstance(scene, CPSN_HUD_SCENE):
            Log.critical(
                f"Invalid scene type for Static HUD Label. This object can only be used in a GUI scene (CPSN_HUD_SCENE)"
            )
            return

        self.scene = scene

        super().__init__(text=text,
                         font_name=font,
                         font_size=font_size,
                         bold=False,
                         italic=False,
                         x=transform.x,
                         y=transform.y,
                         width=transform.width,
                         height=transform.height,
                         color=color,
                         *args,
                         **kwargs)
Beispiel #7
0
 def on_ready(self, time) -> None:
     if not isinstance(self.parent, CPSN_PERSPECTIVE_CAMERA):
         Log.critical(
             "You are trying to add a CharacterController Component to an object that is not CPSN_PERSPECTIVE_CAMERA compatible"
         )
         return