the red dot uses a A* pathfinder to move towards the cursor. you may want to use turbowarp: https://turbowarp.org/1205918154
all code by me uses what I believe is the A* algorithm