I have an array of "food" and I have a for loop that gets the x and y of that food. The food is just a red dot that is placed randomly in the window. Having x and y, how do I move my circle to those coordinates with a certain speed?
pygame.draw.circle(win, (0, 255, 0), (round(x), round(y)), radius)
index = 0
for index in food_list:
food_x, food_y = index[0], index[1]
distance_x, distance_y = food_x - x, food_y - y
stepx, stepy = distance_x * speed, distance_y * speed
x = x + stepx
y = y + stepy
With this code, my circle moves to the first food item nicely but only goes half way to the second one, and it keeps moving less and less until it doesn't move at all. Also, the circle starts slowing down when it almost reaches its food which I do not want.