I overlooked suspicious points. Could you replace X2=X2+(X2-X)/D:Y2=Y2+(Y2-Y)/D with X2=X2+(X-X2)/D:Y2=Y2+(Y-Y2)/D ? An enemy will LEAVE a player with the former code.