Example #1
0
    def __init__(self, width, height):
        super().__init__(width, height)
        self.hit_sound = arcade.load_sound("sounds/rockHit2.ogg")
        self.object_list = arcade.SpriteList()
        self.time = 0
        arcade.set_background_color(arcade.color.DARK_SLATE_GRAY)

        self.player = arcade.PhysicsAABB("images/character.png", [390, 400],
                                         [79 / 2, 125 / 2], [0, 0], .7, 3, 0.4)
        self.object_list.append(self.player)

        create_circles(self.object_list, 300, 300, 5, 2)

        a = arcade.PhysicsCircle("images/meteorGrey_med1.png", [400, 150], 20,
                                 [0, 0], .8, 2, 0.1)
        self.object_list.append(a)
        a = arcade.PhysicsCircle("images/meteorGrey_med2.png", [370, 120], 20,
                                 [0, 0], .8, 2, 0.1)
        self.object_list.append(a)
        a = arcade.PhysicsCircle("images/meteorGrey_med1.png", [430, 120], 20,
                                 [0, 0], .8, 2, 0.1)
        self.object_list.append(a)
        a = arcade.PhysicsCircle("images/meteorGrey_med1.png", [400, 90], 20,
                                 [0, 0], .8, 2, 0.1)
        self.object_list.append(a)

        create_boxes(self.object_list, 150, 250, 2, 20)
        create_boxes(self.object_list, 450, 250, 2, 20)
        create_boxes(self.object_list, 190, 250, 13, 2)
        create_boxes(self.object_list, 190, 450, 13, 2)
        create_boxes(self.object_list, 190, 610, 13, 2)
Example #2
0
    def __init__(self, width, height):
        super().__init__(width, height)
        self.object_list = arcade.SpriteList()
        self.time = 0
        arcade.set_background_color(arcade.color.DARK_SLATE_GRAY)

        self.player = arcade.PhysicsCircle("images/pool_cue_ball.png", [390, 400], 15, [0, 0], 1, 1, BALL_DRAG)
        self.object_list.append(self.player)

        for row in range(5):
            for column in range(row + 1):
                x = 500 - row * 15 + column * 30
                y = 500 + row * 15 * 2
                ball = arcade.PhysicsCircle("images/pool_cue_ball.png", [x, y], 15, [0, 0], 1, 1, BALL_DRAG)
                self.object_list.append(ball)

        for x in range(200, 800, 40):
            wall = arcade.PhysicsAABB("images/boxCrate_double.png", [x, 700], [40, 40], [0, 0], 1, 100, BALL_DRAG)
            wall.static = True
            self.object_list.append(wall)

        for y in range(100, 700, 40):
            wall = arcade.PhysicsAABB("images/boxCrate_double.png", [200, y], [40, 40], [0, 0], 1, 100, BALL_DRAG)
            wall.static = True
            self.object_list.append(wall)

        for y in range(100, 700, 40):
            wall = arcade.PhysicsAABB("images/boxCrate_double.png", [760, y], [40, 40], [0, 0], 1, 100, BALL_DRAG)
            wall.static = True
            self.object_list.append(wall)

        for x in range(200, 800, 40):
            wall = arcade.PhysicsAABB("images/boxCrate_double.png", [x, 60], [40, 40], [0, 0], 1, 100, BALL_DRAG)
            wall.static = True
            self.object_list.append(wall)
Example #3
0
def create_circles(object_list, start_x, start_y, width, height):
    spacing = 20
    for x in range(start_x, start_x + width * spacing, spacing):
        for y in range(start_y, start_y + height * spacing, spacing):
            a = arcade.PhysicsCircle("images/coin_01.png", [x, y], 9, [0, 0],
                                     .1, 1, 0.15)
            object_list.append(a)
Example #4
0
    def on_key_press(self, key, modifiers):
        """
        Called whenever the mouse moves.
        """

        if key == arcade.key.LEFT:
            self.left_flipper_state = FLIPPER_UP

        elif key == arcade.key.RIGHT:
            self.right_flipper_state = FLIPPER_UP

        elif key == arcade.key.SPACE:
            x = 720
            y = 300
            ball = arcade.PhysicsCircle("images/pool_cue_ball.png", [x, y], 15,
                                        [0, +20], 1, .25, BALL_DRAG)
            self.sprite_list.append(ball)
Example #5
0
    def __init__(self, width, height):
        super().__init__(width, height)
        self.sprite_list = arcade.SpriteList()

        self.left_flipper_list = arcade.SpriteList()
        self.right_flipper_list = arcade.SpriteList()
        self.left_flipper_state = NO_FLIPPER
        self.right_flipper_state = NO_FLIPPER

        self.time = 0
        arcade.set_background_color(arcade.color.DARK_SLATE_GRAY)

        # Top wall
        for x in range(20, 800, 40):
            wall = arcade.PhysicsAABB("images/boxCrate_double.png", [x, 980],
                                      [40, 40], [0, 0], 1, 100, 0)
            wall.static = True
            self.sprite_list.append(wall)

        # Left wall
        for y in range(260, 980, 40):
            wall = arcade.PhysicsAABB("images/boxCrate_double.png", [20, y],
                                      [40, 40], [0, 0], 1, 100, 0)
            wall.static = True
            self.sprite_list.append(wall)

        # Right wall
        for y in range(260, 980, 40):
            wall = arcade.PhysicsAABB("images/boxCrate_double.png", [780, y],
                                      [40, 40], [0, 0], 1, 100, 0)
            wall.static = True
            self.sprite_list.append(wall)

        # Left bottom slope
        y = 260
        for x in range(40, 280, 10):
            y -= 5
            wall = arcade.PhysicsAABB("images/boxCrate_double.png", [x, y],
                                      [10, 10], [0, 0], 1, 100, 0)
            wall.static = True
            self.sprite_list.append(wall)

        # Right bottom slope
        y = 260
        for x in range(760, 520, -10):
            y -= 5
            wall = arcade.PhysicsAABB("images/boxCrate_double.png", [x, y],
                                      [10, 10], [0, 0], 1, 100, 0)
            wall.static = True
            self.sprite_list.append(wall)

        # Left flipper
        y = 135
        for x in range(280, 350, 10):
            wall = arcade.PhysicsAABB("images/boxCrate_double.png", [x, y],
                                      [10, 10], [0, 0], 1, 100, 0)
            wall.static = True
            self.sprite_list.append(wall)
            self.left_flipper_list.append(wall)
            y -= 5

        # Right flipper
        y = 135
        for x in range(520, 440, -10):
            wall = arcade.PhysicsAABB("images/boxCrate_double.png", [x, y],
                                      [10, 10], [0, 0], 1, 100, 0)
            wall.static = True
            self.sprite_list.append(wall)
            self.right_flipper_list.append(wall)
            y -= 5

        # Bumpers
        for row in range(2):
            for column in range(2):
                bumper = arcade.PhysicsCircle(
                    "images/bumper.png", [250 + 300 * column, 450 + 300 * row],
                    35, [0, 0], 1.5, 100, BALL_DRAG)
                bumper.static = True
                self.sprite_list.append(bumper)

        wall = arcade.PhysicsAABB("images/python_logo.png", [400, 600],
                                  [150, 150], [0, 0], 1, 100, 0)
        wall.static = True
        self.sprite_list.append(wall)