I want to move some sprites for my Pygame over the display. Its a given route and I want to move them with vectors. So I got the positions of my route and so I got the magnitude and the heading. You can see the formulas and how I want to change the way of the spirts (with "if"). I put the vectors in tuples and I think thats not correctly. I get an error
TypeError: can't multiply sequence by non-int of type 'float' line 51
I think that is the way I mutliply the tuples. But I hope you get my idea behind this and you can help me
clock = pygame.time.Clock()
speed = 25.
position = (30.0,50.0)
magnitude = [509, 141, 128, 409, 293, 330, 251, 532]
heading = [(0.7,0.73),(0.71,0.71),(0.78,0.63),(-0.52,0.65),(0.97,0.24),(0.58,-0.82),(-0.88,-0.48),(0.08,-0.99)]
while True:
for event in pygame.event.get():
if event.type == QUIT:
exit()
screen.blit(background, (0.0,0.0))
screen.blit(x1, position)
screen.blit(x2, (300,30))
screen.blit(x3, (500,30))
screen.blit(x4,(800,30))
time_passed = clock.tick()
time_passed_seconds = time_passed / 1000.0
route = time_passed_seconds * speed
position += heading[0] * route
if route >= magnitude[0]:
route = 0
route1 = time_passed_seconds * speed
position += heading[1] * route1
if route1 >= magnitude[1]:
route2 = time_passed_seconds * speed
position += heading[2] *route2
if route2 >= magnitude[2]:
route3 = time_passed_seconds * speed
position += heading[3] * route3
if route3 >= magnitude[3]:
route4 = time_passed_seconds * speed
position += heading[4] * route4