So i have the game logic and render in the callback for requestAnimationFrame, and somehow the ticks run very weird.
In fact, the rendering happens alright.
But the ticks seem to skip an
if, to be specific.
The questionable code moves the entity a few pixels until an amount of pixels is traveled.
When the tab isn't viewed the movement happens, and gets rendered correctly, but when going back to the tab i see that the movement went way to far and to make it more dubious, the entity travels back to its actual target position.
It feels a bit like the frames get rendered with the tick-function using kind of a state, like the variables keep the same value while the tab isn't viewed, and when viewing the tab again all the frames get played back reverse until the movement should actually stop.
Is there any reason for this and maybe a solution, too?