Exemple #1
0
    # if 'up' or 'down' is pressed increase or decrese size of pen
    if pythonGraph.key_pressed('up'):
        radius += 3
    if pythonGraph.key_pressed('down') and radius >= 3:
        radius -= 3


# configure graphics
config()

# animiation loop
while pythonGraph.window_not_closed():

    # draw the pallet
    draw_pallet()

    # get the coordinates of the mouse
    mouse_x = pythonGraph.get_mouse_x()
    mouse_y = pythonGraph.get_mouse_y()

    # draw circle or image on the canvas
    draw_on()

    # handle all key presses
    proc_keys()

    # check for click on color and change it
    pallet_click()

    # update window
    pythonGraph.update_window()
Exemple #2
0
# Setup tasks for window
pythonGraph.open_window(SCREEN_WIDTH, SCREEN_HEIGHT)
pythonGraph.set_window_title(SCREEN_TITLE)

# Animation Loop
while pythonGraph.window_not_closed():
    pythonGraph.clear_window(pythonGraph.colors.WHITE)

    for i in range(0, len(ball_x)):
        pythonGraph.draw_circle(ball_x[i], ball_y[i], ball_radius[i],
                                ball_color[i], True)

        ball_x[i] += ball_x_velocity[i]
        ball_y[i] += ball_y_velocity[i]

        if ball_x[i] < 0 or ball_x[i] > SCREEN_WIDTH:
            ball_x_velocity[i] *= -1
        if ball_y[i] < 0 or ball_y[i] > SCREEN_HEIGHT:
            ball_y_velocity[i] *= -1

    if pythonGraph.mouse_button_pressed(pythonGraph.mouse_buttons.LEFT):
        ball_x.append(pythonGraph.get_mouse_x())
        ball_y.append(pythonGraph.get_mouse_y())
        ball_x_velocity.append(random.randint(1, 10))
        ball_y_velocity.append(random.randint(1, 10))
        ball_radius.append(random.randint(10, 30))
        ball_color.append(pythonGraph.create_random_color())
        print("clicked")

    pythonGraph.update_window()