A program where you click your mouse then, a box appears from point 1 to 2 and box one moves to box 2
the "update" in the while loop does not seem to be updating the screen when the box moves
the pertaining code (not all):
frames = 0
speed = 20
def distance(x, y, x1, y1):
distance_ = x - x1, y - y1
return distance_
while True:
frames += 1
if box_two_x is not None:
pygame.draw.rect(win, (255, 0, 255), (box_two_x, box_two_y, 13, 13))
while distance(box_one_x, box_one_y, box_two_x, box_two_y)[1] != 0:
frames += 1
if frames % speed == 0:
box_one_y += 1
pygame.display.update()
if I need to provide more context as to the code or the problem feel free to ask.
p.s. what I've tried
- moving the update before the if statement
- calling a function to update the screen
- putting the whole code after the second while statement in a function
- drawing the square in the if statement (in the while loop)