Beispiel #1
0
            gravity(p, other)


# Loop
run = True
while run:
    clock.tick(60)
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            run = False
        elif event.type == pygame.MOUSEBUTTONDOWN:
            if curr_planet is None:
                pos = pygame.mouse.get_pos()
                curr_planet = Planet(Vector2(pos), Vector2(0, 0), 0.1)
                if pygame.mouse.get_pressed()[2]:
                    curr_planet.UNMOVABLE = True

        elif event.type == pygame.MOUSEBUTTONUP:
            if curr_planet is not None:
                planets.append(curr_planet)
                curr_planet = None
        elif event.type == pygame.MOUSEMOTION:
            if curr_planet is not None:
                m_pos = pygame.mouse.get_pos()
                p_pos = curr_planet.get_pos()
                curr_planet.set_vel(scale(subtract(m_pos, p_pos),
                                          ARROW_FACTOR))
        elif event.type == pygame.KEYDOWN:
            if event.key == pygame.K_UP:
                GRAVITY_COEFFICIENT = GRAVITY_COEFFICIENT + 0.1 if GRAVITY_COEFFICIENT + 0.1 < 3 else 3
            elif event.key == pygame.K_DOWN: