Related questions
let speed = 10 steps = Math.max(Math.abs(dx), Math.abs(dy)) / speed;
Find more questions by tags AnimationJavaScriptCanvas