How can i make a block follow another block in pygame [duplicate]
问题 This question already has answers here : How to make smooth movement in pygame (2 answers) Closed 4 months ago . I have two blocks, one is controlled by the user. When i move my block, i want the other block to follow me. I tried doing something like this def follow(): distance = math.hypot(abs(m.x - p.x), abs(m.y - p.y)) angle_radians = math.atan2(abs(m.y - p.y), abs(m.x - p.x)) if distance != 0: p.y += math.sin(angle_radians) p.x += math.cos(angle_radians) However, the block ends up moving