Skip to content

error on "arcade.examples.shapes" #1045

@ayukoid

Description

@ayukoid

Bug Report

Actual behavior:

Traceback (most recent call last):
  File "E:\programming\Python38-32\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "E:\programming\Python38-32\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "E:\programming\Python38-32\lib\site-packages\arcade\examples\shapes.py", line 144, in <module>
    main()
  File "E:\programming\Python38-32\lib\site-packages\arcade\examples\shapes.py", line 139, in main
    MyGame()
  File "E:\programming\Python38-32\lib\site-packages\arcade\examples\shapes.py", line 77, in __init__
    super().__init__(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE)
  File "E:\programming\Python38-32\lib\site-packages\arcade\application.py", line 122, in __init__
    super().__init__(width=width, height=height, caption=title,
  File "E:\programming\Python38-32\lib\site-packages\pyglet\window\win32\__init__.py", line 130, in __init__
    super(Win32Window, self).__init__(*args, **kwargs)
  File "E:\programming\Python38-32\lib\site-packages\pyglet\window\__init__.py", line 609, in __init__
    self._create_projection()
  File "E:\programming\Python38-32\lib\site-packages\pyglet\window\__init__.py", line 613, in _create_projection
    self.ubo = self._default_program.uniform_blocks['WindowBlock'].create_ubo()
KeyError: 'WindowBlock'

Expected behavior:

The example arcade.examples.shapes to run

Steps to reproduce/example code:

import arcade
import random

# Set up the constants
SCREEN_WIDTH = 800
SCREEN_HEIGHT = 600
SCREEN_TITLE = "Shapes!"

NUMBER_OF_SHAPES = 500


class Shape:
    """ Generic base shape class """
    def __init__(self, x, y, width, height, angle, delta_x, delta_y,
                 delta_angle, color):
        self.x = x
        self.y = y
        self.width = width
        self.height = height
        self.angle = angle
        self.delta_x = delta_x
        self.delta_y = delta_y
        self.delta_angle = delta_angle
        self.color = color

    def move(self):
        self.x += self.delta_x
        self.y += self.delta_y
        self.angle += self.delta_angle
        if self.x < 0 and self.delta_x < 0:
            self.delta_x *= -1
        if self.y < 0 and self.delta_y < 0:
            self.delta_y *= -1
        if self.x > SCREEN_WIDTH and self.delta_x > 0:
            self.delta_x *= -1
        if self.y > SCREEN_HEIGHT and self.delta_y > 0:
            self.delta_y *= -1


class Ellipse(Shape):

    def draw(self):
        arcade.draw_ellipse_filled(self.x, self.y, self.width, self.height,
                                   self.color, self.angle)


class Rectangle(Shape):

    def draw(self):
        arcade.draw_rectangle_filled(self.x, self.y, self.width, self.height,
                                     self.color, self.angle)


class Line(Shape):

    def draw(self):
        arcade.draw_line(self.x, self.y,
                         self.x + self.width, self.y + self.height,
                         self.color, 2)


class MyGame(arcade.Window):
    """ Main application class. """

    def __init__(self):
        # Call the parent __init__
        super().__init__(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE)

        # Create a shape list
        self.shape_list = []

        for i in range(NUMBER_OF_SHAPES):

            # Random spot
            x = random.randrange(0, SCREEN_WIDTH)
            y = random.randrange(0, SCREEN_HEIGHT)

            # Random size
            width = random.randrange(15, 40)
            height = random.randrange(15, 40)

            # Random angle
            angle = random.randrange(0, 360)

            # Random movement
            d_x = random.randrange(-3, 4)
            d_y = random.randrange(-3, 4)
            d_angle = random.randrange(-3, 4)

            # Random color
            red = random.randrange(256)
            green = random.randrange(256)
            blue = random.randrange(256)
            alpha = random.randrange(256)

            # Random line, ellipse, or rect
            shape_type = random.randrange(3)

            if shape_type == 0:
                shape = Rectangle(x, y, width, height, angle, d_x, d_y,
                                  d_angle, (red, green, blue, alpha))
            elif shape_type == 1:
                shape = Ellipse(x, y, width, height, angle, d_x, d_y,
                                d_angle, (red, green, blue, alpha))
            else:
                shape = Line(x, y, width, height, angle, d_x, d_y,
                             d_angle, (red, green, blue, alpha))

            # Add this new shape to the list
            self.shape_list.append(shape)

    def on_update(self, dt):
        """ Move everything """
        for shape in self.shape_list:
            shape.move()

    def on_draw(self):
        """ Render the screen. """

        # Clear teh screen
        arcade.start_render()

        # Draw the shapes
        for shape in self.shape_list:
            shape.draw()


def main():
    MyGame()
    arcade.run()


if __name__ == "__main__":
    main()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions