How to change the speed of the game loop ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

How to change the speed of the game loop ?

hy there. i make a coding course for the FAB and one thingg is coding the UI. my problem is that the range slider of the motor rpm (line 37) has to change with the code (line 93) the speed of the loop (line 151) during running the loop. So the idea. But the code doesnt work as it should. can someone help me pls ? https://sololearn.com/compiler-playground/WbZHdG83mFVe/?ref=app

6th Mar 2024, 4:03 PM
Shiko
Shiko - avatar
2 Answers
7th Mar 2024, 9:59 PM
JaScript
JaScript - avatar
+ 1
You would need to clear the inteval and set a new one. https://stackoverflow.com/questions/10576106/setintervalfunction-time-change-time-on-runtime#10576119 Maube requestAnimationFrame would be more suitable to what you try to do.
6th Mar 2024, 4:52 PM
Lisa
Lisa - avatar