def draw_hit_box(self, color: Color = BLACK, line_thickness: float = 1):
        """
        Draw a sprite's hit-box.

        The 'hit box' drawing is cached, so if you change the color/line thickness
        later, it won't take.

        :param color: Color of box
        :param line_thickness: How thick the box should be
        """

        if self._hit_box_shape is None:

            # Adjust the hitbox
            point_list = []
            for point in self.hit_box:
                # Get a copy of the point
                point = [point[0], point[1]]

                # Scale the point
                if self.scale != 1:
                    point[0] *= self.scale
                    point[1] *= self.scale

                # Rotate the point
                if self.angle:
                    point = rotate_point(point[0], point[1], 0, 0, self.angle)

                point_list.append(point)

            shape = create_line_loop(point_list, color, line_thickness)
            self._hit_box_shape = ShapeElementList()
            self._hit_box_shape.append(shape)

        self._hit_box_shape.center_x = self.center_x
        self._hit_box_shape.center_y = self.center_y
        self._hit_box_shape.angle = self.angle
        self._hit_box_shape.draw()
Beispiel #2
0
    def __init__(self,
                 center_x,
                 center_y,
                 radius=80,
                 color=(220, 220, 220),
                 num_segments=-1):
        super().__init__()

        self.center_x = center_x
        self.center_y = center_y
        self.radius = radius

        point_list = [(self.radius * math.sin(a), self.radius * math.cos(a))
                      for a in np.linspace(0, 2 * math.pi, 10)]

        my_line_strip = arcade.create_line_loop(point_list,
                                                color=color,
                                                line_width=2)
        self.append(my_line_strip)

        self.center_x = SCREEN_WIDTH / 2
        self.center_y = SCREEN_HEIGHT / 2
        self.angle = 10