How could i set a “speed” for the point in pygame/python?

i am working on a little Game with Pygame and i stumbled across a little thing i couldnt fix by myself. So here is the Problem:

    px, py =
    sx, sy =
    direction = (px - sx, py - sy)

    dx, dy = (px - sx, py - sy) = (sx + dx / 60, sy + dy / 60)

When i now execute it the snail will speed up the farther it is away from the player. But i now i want that the snail have the same speed no matter how far it is away. Im pretty new and i hope this snipped is enought so you guys can help me ^^


You need to normalize your vector to a unit vector and then properly scale it by a constant speed factor. Try this:

import math
dx, dy = (px - sx, py - sy)
length = math.sqrt(dx*dx + dy*dy)
dx /= length
dy /= length

# you can use this already
# or you can do

c = 5
dx = c * dx
dy = c * dy