Why orange blocks don't have constantly speed? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Why orange blocks don't have constantly speed?

Hello guys, in my next game project -> https://code.sololearn.com/Wxann6l3d3tJ/#html orange blocks don't have constantly speed, they don't move smoothly. But why? Thank you and have nice day!

17th Jul 2018, 11:56 AM
Yuri Biasi
Yuri Biasi - avatar
3 Answers
+ 1
Hi Yuri Biasi! As you're requesting an animation frame for the_game function, the_game will be called repeatedly. And, every call will set a new interval for timer function because of: setInterval ( timer, 1000 ); // 88th line To solve this, move your 88th line out of the the_game function and place it in 84th line.
17th Jul 2018, 12:17 PM
777
777 - avatar
+ 2
Yuri Biasi, welcome :)
17th Jul 2018, 12:23 PM
777
777 - avatar
+ 1
Thank you very very much! :)
17th Jul 2018, 12:21 PM
Yuri Biasi
Yuri Biasi - avatar