Movement in Random Intervals | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Movement in Random Intervals

How can I make this box move in a random direction in random intervals without clicking it? https://code.sololearn.com/WzO620NuNO3U/?ref=app

8th Sep 2020, 7:15 AM
Unrealistic Engineer
Unrealistic Engineer - avatar
2 Answers
+ 1
Using window.onload event handler and calling a function when window uploads ,
8th Sep 2020, 7:45 AM
Abhay
Abhay - avatar
+ 1
create an interval or timeout wuth random wait time to call moveit here's one way to do it. function rmove(){ moveit(); setTimeout(rmove, parseInt(Math.random() * 3000)); }
8th Sep 2020, 8:09 AM
Rei
Rei - avatar