Beispiel #1
0
def draw_objects():
    breakout.clear_screen()

    # Draw the paddle, ball, and wall of bricks
    # TODO
    for brick in bricks:
        x = breakout.get_x(brick)
        y = breakout.get_y(brick)
        width = breakout.get_width(brick)
        height = breakout.get_height(brick)
        color = breakout.get_color(brick)
        breakout.draw_rectangle(x, y, width, height, color)
    x = breakout.get_x(paddle)
    y = breakout.get_y(paddle)
    width = breakout.get_width(paddle)
    height = breakout.get_height(paddle)
    color = breakout.get_color(paddle)
    breakout.draw_rectangle(x, y, width, height, color)

    x = breakout.get_x(ball)
    y = breakout.get_y(ball)
    radius = breakout.get_radius(ball)
    color = breakout.get_color(ball)
    breakout.draw_circle(x, y, radius, color)
    # Tell pygame to actually redraw everything (DON'T CHANGE)
    pygame.display.flip()
def draw_objects():
    # First wipe canvas clean
    breakout.clear_screen()
    # Draw the paddle, ball, and wall of bricks
    breakout.draw_rectangle(breakout.get_x(paddle), breakout.get_y(paddle), breakout.get_width(paddle), breakout.get_height(paddle), breakout.get_color(paddle))
    breakout.draw_circle(breakout.get_x(ball), breakout.get_y(ball), breakout.get_radius(ball), breakout.get_color(ball))
    for brick in bricks:
        breakout.draw_rectangle(breakout.get_x(brick), breakout.get_y(brick), breakout.get_width(brick), breakout.get_height(brick), breakout.get_color(brick))
    # Tell pygame to actually redraw everything
    pygame.display.flip()
def paddle_update_position(paddle):
    coordinates =  breakout.get_mouse_location()
    x = coordinates[0]
    breakout.set_x(paddle, breakout.clamp(x + breakout.get_x_velocity(paddle), 0, constants.SCREEN_WIDTH - breakout.get_width(paddle)))