Beispiel #1
0
    def __init__(self,
                 scene,
                 width,
                 height,
                 segments=3,
                 fill=True,
                 x=0,
                 y=0,
                 layer=0,
                 colours=[]):
        # type: (Scene, int, int, int, bool, int, int, int, list[str]) -> None
        GameObject.__init__(self, scene=scene)
        points = []
        x += scene.window.width / 2
        y += scene.window.height / 2

        for i in range(segments):
            angle = math.radians(float(i) / segments * 360)

            _x = width * math.cos(angle) + x
            _y = height * math.sin(angle) + y

            points.append(_x)
            points.append(_y)

        Polygon.__init__(self,
                         scene,
                         fill,
                         segments,
                         x,
                         y,
                         layer,
                         points,
                         colours=colours)
Beispiel #2
0
 def __init__(self, scene, image, scale=1, layer=0):
     # type: (Scene, pyglet.image.AbstractImage) -> None
     GameObject.__init__(self, scene)
     self.layer = layer
     pyglet.sprite.Sprite.__init__(self, img=image, batch=scene.batch, group=scene.layers[self.layer])
     self.scene = scene
     self.image = image
     self.scale = scale
Beispiel #3
0
    def __init__(self, scene, widget, x=0, y=0):
        GameObject.__init__(self, scene, -1)
        self.widget = widget
        self.widget.id = Globals.WIDGETS
        Globals.WIDGETS += 1

        Dialog.__init__(self, content=GridLayout(content=[
            [self.widget]
        ]),
            window=Globals.WINDOW, batch=scene.batch, group=scene.layers[-1], offset=(x, y), theme=felyne_dark)
Beispiel #4
0
    def __init__(self, scene, width, height, fill=True, x=0, y=0, layer=0, colours=[]):
        # type: (Scene, int, int, bool, int, int, int, list[str]) -> None
        GameObject.__init__(self, scene=scene)
        x += scene.window.width / 2
        y += scene.window.height / 2

        points = [x, y + (height // 2),  # Bottom left
                  x + (width // 2), y,  # Bottom right
                  x + width, y + (height // 2),  # Top right
                  x + (width // 2), y + height]  # Top left
        Polygon.__init__(self, scene, fill, 4, x, y, layer, points, colours=colours)
Beispiel #5
0
 def __init__(self, scene, title, content, x=0, y=0):
     GameObject.__init__(self, scene, -1)
     KWindow.__init__(self,
                      title,
                      content,
                      window=Globals.WINDOW,
                      batch=scene.batch,
                      group=scene.layers[-1],
                      offset=(x, y),
                      theme=felyne_dark,
                      anchor=ANCHOR_TOP_LEFT)
Beispiel #6
0
 def __init__(self, scene, size, fill=True, x=0, y=0, layer=0, colours=[]):
     # type: (Scene, int, bool, int, int, int, list[str]) -> None
     GameObject.__init__(self, scene=scene)
     Rectangle.__init__(self,
                        scene,
                        size,
                        size,
                        fill,
                        x,
                        y,
                        layer,
                        colours=colours)
Beispiel #7
0
 def __init__(self, scene, text="", x=0, y=0, layer=0):
     # type: (Scene, str, int, int) -> None
     GameObject.__init__(self, scene=scene)
     self._layer = layer
     pyglet.text.Label.__init__(self,
                                text=text,
                                x=x,
                                y=y,
                                batch=scene.batch,
                                group=scene.layers[self._layer])
     self._scene = scene
     self._text = text
     self._x = x
     self._y = y
Beispiel #8
0
    def __init__(self,
                 scene,
                 width,
                 height,
                 expand,
                 expand_direction="out",
                 fill=True,
                 x=0,
                 y=0,
                 layer=0,
                 colours=[]):
        # type: (Scene, int, int, int, str, bool, int, int, int, list[str]) -> None
        GameObject.__init__(self, scene=scene)
        x += scene.window.width / 2
        y += scene.window.height / 2

        if expand_direction == "out":
            tl = x
            bl = x + width + expand
            tr = x + width
            br = x + expand
        elif expand_direction == "in":
            tl = x
            bl = x + width - expand
            tr = x + width
            br = x - expand

        points = [
            tl,
            y,  # Bottom left
            bl,
            y,  # Bottom right
            tr,
            y + height,  # Top right
            br,
            y + height
        ]  # Top left
        Polygon.__init__(self,
                         scene,
                         fill,
                         4,
                         x,
                         y,
                         layer,
                         points,
                         colours=colours)
Beispiel #9
0
    def __init__(self,
                 scene,
                 fill=True,
                 point_total=0,
                 x=0,
                 y=0,
                 layer=0,
                 points=[],
                 colours=[]):
        # type: (Scene, bool, int, int, int, int, list[int], list[str]) -> None
        GameObject.__init__(self, scene=scene)
        self.layer = layer
        self.scene = scene
        self.point_total = point_total
        self.points = points
        self.colours = self._colour_handler(colours)

        self.x_points = []
        self.y_points = []

        for i in range(0, len(self.points)):
            # If even
            if i & 1:
                self.y_points.append(self.points[i])

            else:
                self.x_points.append(self.points[i])

        self.size = (max(self.x_points) - min(self.x_points),
                     max(self.y_points) - min(self.y_points))
        self.center = (self.size[0] / 2, self.size[1] / 2)

        if fill:
            mode = pyglet.gl.GL_POLYGON
        else:
            mode = pyglet.gl.GL_LINE_LOOP

        self.batch = pyglet.graphics.Batch()
        self.shape = self.batch.add(point_total, mode, None,
                                    ('v2f', self.points),
                                    ('c3B', self.colours))
        self.scene.batch_list.append(self.batch)

        self.scene.object_list.append(self)
Beispiel #10
0
    def __init__(self, scene, width, height, skew, skew_direction="right", fill=True, x=0, y=0, layer=0, colours=[]):
        # type: (Scene, int, int, int, str, bool, int, int, int, list[str]) -> None
        GameObject.__init__(self, scene=scene)
        x += scene.window.width / 2
        y += scene.window.height / 2

        if skew_direction == "left":
            tl = x + skew
            bl = x + width + skew
            tr = x + width - skew
            br = x - skew
        elif skew_direction == "right":
            tl = x - skew
            bl = x + width - skew
            tr = x + width + skew
            br = x + skew

        points = [tl, y,  # Bottom left
                  bl, y,  # Bottom right
                  tr, y + height,  # Top right
                  br, y + height]  # Top left
        Polygon.__init__(self, scene, fill, 4, x, y, layer, points, colours=colours)
Beispiel #11
0
    def __init__(self,
                 scene,
                 width,
                 height,
                 tip_placement="center",
                 fill=True,
                 x=0,
                 y=0,
                 layer=0,
                 colours=[]):
        # type: (Scene, int, int, str, bool, int, int, int, list[str]) -> None
        GameObject.__init__(self, scene=scene)
        x += scene.window.width / 2
        y += scene.window.height / 2

        if tip_placement == "center":
            tip = (width // 2)
        elif tip_placement == "left":
            tip = 0
        elif tip_placement == "right":
            tip = width

        points = [
            x,
            y,  # Bottom left
            x + width,
            y,  # Bottom right
            x + tip,
            y + height
        ]  # Tip
        Polygon.__init__(self,
                         scene,
                         fill,
                         3,
                         x,
                         y,
                         layer,
                         points,
                         colours=colours)
Beispiel #12
0
 def __init__(self, scene, height, thickness=1, x=0, y=0, layer=0, colours=[]):
     # type: (Scene, int, int, int, int, int, list[str]) -> None
     GameObject.__init__(self, scene=scene)
     Rectangle.__init__(self, scene, thickness, height, True, x, y, layer, colours=colours)