|
|
@@ -12,6 +12,8 @@ pygame.display.set_caption("Patrick") |
|
|
|
running = True |
|
|
|
clock = pygame.time.Clock() |
|
|
|
|
|
|
|
data = [] |
|
|
|
|
|
|
|
|
|
|
|
def physics(): |
|
|
|
for ball in balls: |
|
|
@@ -36,13 +38,22 @@ def boost(): |
|
|
|
norm = np.array([vector[1], -vector[0]]) |
|
|
|
balls[1].velocity += norm * .5 |
|
|
|
|
|
|
|
def modulate(): |
|
|
|
x = pygame.mouse.get_pos()[0] |
|
|
|
fraction = x / SIZE[0] |
|
|
|
springs[-1].k = fraction*3 + 0.05 |
|
|
|
springs[-2].k = fraction*3 + 0.05 |
|
|
|
pygame.draw.rect(screen, (30, 30, 30), (0, 0, x, SIZE[1])) |
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__': |
|
|
|
balls = [Ball(0., 0., fixed=True), |
|
|
|
Ball(0., 100.), |
|
|
|
Ball(20., 120.), |
|
|
|
Ball(-20., 120.), |
|
|
|
Ball(0., 80.)] |
|
|
|
Ball(0., 80.), |
|
|
|
Ball(40., 100.), |
|
|
|
Ball(-40., 100.)] |
|
|
|
springs = [ |
|
|
|
Spring(balls[0], balls[1], length=100, k=3), |
|
|
|
Spring(balls[1], balls[2], k=5), |
|
|
@@ -50,7 +61,9 @@ if __name__ == '__main__': |
|
|
|
Spring(balls[2], balls[3], k=5), |
|
|
|
Spring(balls[1], balls[4], k=5), |
|
|
|
Spring(balls[2], balls[4], k=5), |
|
|
|
Spring(balls[3], balls[4], k=5) |
|
|
|
Spring(balls[3], balls[4], k=5), |
|
|
|
Spring(balls[3], balls[5], k=.1, color=(255, 0, 0)), |
|
|
|
Spring(balls[2], balls[6], k=.1, color=(255, 0, 0)) |
|
|
|
] |
|
|
|
|
|
|
|
while running: |
|
|
@@ -60,7 +73,9 @@ if __name__ == '__main__': |
|
|
|
|
|
|
|
screen.fill((0, 0, 0)) |
|
|
|
physics() |
|
|
|
physics() |
|
|
|
boost() |
|
|
|
modulate() |
|
|
|
draw() |
|
|
|
|
|
|
|
pygame.display.flip() |
|
|
|