Exemple #1
0
delta_time = 0
frame_start_time = 0
#endregion

rope = Rope(x=size[0] / 2, y=10, length=500, resolution=50)

mouse_collider = Collider(0, 0)
mouse_collider.size = 50

while True:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit()
            quit()
    frame_start_time = time()
    screen.fill(0)

    mpos = Vec(pygame.mouse.get_pos())
    mouse_collider.pos.linear_interpolate(mpos, t=delta_time)

    pygame.draw.circle(screen, [10, 10, 10], mouse_collider.pos.get(),
                       mouse_collider.size)

    rope.update([mouse_collider], delta_time=delta_time)
    rope.draw(screen)

    pygame.display.update()
    clock.tick(fps)
    delta_time = time() - frame_start_time
    pygame.display.set_caption(f'Framerate: {int(clock.get_fps())}')
Exemple #2
0
    B = 0  #random.randint(1,255)
    G = 0  #random.randint(1,255)

    if len(paint_points) > 1:
        pygame.draw.aalines(win, (R, G, B), False, paint_points)

    ### USE THIS DRAW OPTION IF YOUR COMPUTER IS REALLY SLOW!! (insead of the draw option above)
    '''
    for point in paint_points:
        pygame.draw.circle(win, (255,0,0), point, 1)
    '''

    line_1.show(win)
    line_2.show(win)
    swing(line_1, line_2)
    line_1.update()
    line_2.update(line_1)

    paint_points.append(line_2.point2)

    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            run = False
        if event.type == pygame.MOUSEBUTTONUP:
            g = 2
            r1 = random.randint(50, 200)
            r2 = random.randint(50, 200)
            a1 = math.pi / random.randint(1, 5)
            a2 = math.pi / random.randint(1, 5)
            m1 = random.randint(10, 40)
            m2 = random.randint(10, 40)