def __init__(self, transform=Transform(), scene=None, active=False): """ Parameters ---------- transform | A Capsian Transform Component | Transform scene | A Capsian Scene Object | Scene2D/Scene3D/OverlayScene active | Weather the entity is active or not | bool """ super().__init__(transform=transform, scene=scene, active=active) x = transform.size[0] / 2 y = transform.size[1] / 2 z = transform.size[2] / 2 self.currentX = x self.currentY = y self.vertex_list = pyglet.graphics.vertex_list(4, ('v3f', [ 0, 0, 0, transform.size[0], 0, 0, transform.size[0], transform.size[1], 0, 0, transform.size[1], 0 ]), ('t3f', [0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0])) scene.objects2D.append(self) scene.drawable.append(self)
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 """ super().__init__(font=font, font_size=font_size, transform=transform, text="", scene=scene, color=color, *args, **kwargs) self.text_pointer = text scene.dynamic_hud.append(self) engine.default_clock.Schedule.call_with_interval( self.update_text, 1 / 10)
def __init__(self, transform=Transform(), amount=4, duration=240, scene=None): """ Parameters ---------- transform | A Capsian Transform Object | Transform amount | The amount of particles to be generated | int duration | The duration of the effect | int scene | The Capsian Scene of which the particles are part of | Scene3D """ super().__init__( transform, scene, False ) self.dead = 0 self.quads = list() self.amount = int(amount) self.duration = float(duration) self.create( amount, self.components.transform.position, self.components.transform.size )
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 """ super().__init__(font=font, font_size=font_size, transform=transform, text=text, scene=scene, color=color, *args, **kwargs) self.scene.dynamic_gui.append(self)
def __init__(self, transform=Transform(), fov=90, far=5000, near=0.05): """ Parameters ---------- transform | A Capsian transform component | Transform fov | The field of view | int < 180 far | The furthest point in view | float near | The nearest point in view | float """ super().__init__(transform, active=True) # Direction vectors self.dx = 0 self.dy = 0 self.dz = 0 self.rotY = 0 self.rotX = 0 self.mouse_dx = 0 self.mouse_dy = 0 # Rendering self.fov = fov self.far = int(far) self.near = float(near) self.scenes = [] self.hud_scenes = []
def __init__(self, transform=Transform(), scene=None, material=None): """ Parameters ---------- transform | A Capsian Transform Component | Transform scene | A Capsian Scene Object | Scene3D material | A Capsian Material Object | Material """ super().__init__(scene=scene, transform=transform) self.texture = material.texture self._add_block(transform.x, transform.y, transform.z)
def __init__(self, transform=Transform(), scene=None, texture=None): """ Parameters ---------- transform | A Capsian Tansfom Component | Transfom scene | A Capsian Scene of which the sprite is part of | Scene3D texture | A texture | texture """ t = TexturedSquare(transform, scene, texture) self.texture = texture.get_texture() scene.dynamic_hud.append(t)
def create(self, quantity: int, pos: list, size: list) -> None: from Capsian import Transform for _ in range(quantity): x = pos[0] + random.uniform(-size[0] * 2, size[2] * 2) y = pos[1] + random.uniform(-size[0], size[2] / 2) z = pos[2] + random.uniform(size[0] * 2, size[2] * 2) p = RotatingSquare(Transform(x, y, z, size[0], size[1], size[2]), self.scene, False) self.quads.append(p) engine.default_clock.Schedule.call_every_tick(self.check) engine.default_clock.Schedule.call_with_interval(self.destroy, 1)
def __init__(self, scene): """ Parameters ---------- scene | The scene of which the object is part of | OverlayScene """ from Capsian.components.transform import Transform from Capsian.GUI.label import Label3D from Capsian.world.format import Color self.scene = scene self.label = Label3D(font="Calibri", font_size=48, transform=Transform(0, 0, 0, None, None), text=self.get_pyglet_fps, color=Color(255, 255, 255).rgba, scene=scene)
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)
def __init__(self, transform=Transform(), scene=None, texture=None): self.texture = texture.get_texture() super().__init__(transform, scene, False)
def __init__(self, transform=Transform(), scene=None, active=False): """ Parameters ---------- transform | A Capsian Transform Component | Transform scene | A Capsian Scene Object | Scene2D/Scene3D/OverlayScene active | Weather the entity is active or not | bool """ from datetime import datetime from Capsian.values import CPSN_STANDARD_SCENE class Components(list): transform = None character_controller = None key_listener = None mouse_listener = None def __init__(self, spr: Entity): self.spr = spr def add(self, component: Component) -> None: from datetime import datetime component._init(self.spr) self.append(component) self.spr.on_component_added(component, datetime.now()) setattr(self, repr(component), component) component.on_ready(datetime.now()) self.components = Components(self) self.active = active self.components.add(transform) self.next_pos = [ [transform.x + 1, transform.y, transform.z ], [transform.x - 1, transform.y, transform.z ], [transform.x, transform.y, transform.z + 1], [transform.x, transform.y, transform.z - 1], [transform.x, transform.y + 1, transform.z ], [transform.x, transform.y - 1, transform.z ], ] if not isinstance(scene, CPSN_STANDARD_SCENE): self.scene = None return if scene == None: from Capsian.video.scene import PlaceholderScene self.scene = PlaceholderScene() return self.scene = scene if active: scene.stack.append(self) self.on_create(datetime.now())