added python3 support

This commit is contained in:
Simon Pirkelmann 2020-10-24 20:05:00 +02:00
parent 409a9980bd
commit 7f194f57f2

View File

@ -28,27 +28,27 @@ while running:
if event.key == pygame.K_LEFT: if event.key == pygame.K_LEFT:
u1 = -vmax u1 = -vmax
u2 = vmax u2 = vmax
print("turn left: ({},{})".format(u1, u2)) print(f"turn left: ({u1},{u2})")
elif event.key == pygame.K_RIGHT: elif event.key == pygame.K_RIGHT:
u1 = vmax u1 = vmax
u2 = -vmax u2 = -vmax
print("turn right: ({},{})".format(u1, u2)) print(f"turn right: ({u1},{u2})")
elif event.key == pygame.K_UP: elif event.key == pygame.K_UP:
u1 = vmax u1 = vmax
u2 = vmax u2 = vmax
print("forward: ({},{})".format(u1, u2)) print(f"forward: ({u1},{u2})")
elif event.key == pygame.K_DOWN: elif event.key == pygame.K_DOWN:
u1 = -vmax u1 = -vmax
u2 = -vmax u2 = -vmax
print("backward: ({},{})".format(u1, u2)) print(f"backward: ({u1},{u2})")
elif event.key == pygame.K_ESCAPE: elif event.key == pygame.K_ESCAPE:
print("quit") print("quit")
running = False running = False
u1 = 0.0 u1 = 0.0
u2 = 0.0 u2 = 0.0
rc_socket.send('({},{})\n'.format(u1, u2)) rc_socket.send(f'({u1},{u2})\n'.encode())
elif event.type == pygame.KEYUP: elif event.type == pygame.KEYUP:
print("key released, resetting: ({},{})".format(u1, u2)) print("key released, resetting: ({},{})".format(u1, u2))
rc_socket.send('({},{})\n'.format(u1, u2)) rc_socket.send(f'({u1},{u2})\n'.encode())