Here's my main game loop:
...or something like that.
Everything in my game is scaled against timePassed (it's a 2D game, so no tweening), so the movement should be pretty steady.
On average, the timePassed value flickers between 16 and 17 (milliseconds), but when there's a ton of stuff going on, rather than having timePassed go to 20~ish, it jumps straight to 32 - 34, which is exactly double the normal amount. Then, when the game calms down again, it goes right back to 16 and 17. The effect is very noticeable.
Is there something wrong with my code that's causing this? The reason I have the "If currentTime > lastTime + 10" is so that I can do things like "timePassed = timePassed / 4", which makes everything go slow-mo. If I didn't make sure that the difference was greater than 10, then on a fast computer, "timePassed = timePassed / 4" could make timePassed round down to zero, effectively stopping the game.
If that made any sense whatsoever, please help me.
While Not KeyDown(1) currentTime = Millisecs() ;prevents timePassed being too small If currentTime > lastTime + 10 timePassed = currentTime - lastTime lastTime = currentTime Cls doEverything() drawEverything() Text 0, 0, timePassed Flip Endif Wend
...or something like that.
Everything in my game is scaled against timePassed (it's a 2D game, so no tweening), so the movement should be pretty steady.
On average, the timePassed value flickers between 16 and 17 (milliseconds), but when there's a ton of stuff going on, rather than having timePassed go to 20~ish, it jumps straight to 32 - 34, which is exactly double the normal amount. Then, when the game calms down again, it goes right back to 16 and 17. The effect is very noticeable.
Is there something wrong with my code that's causing this? The reason I have the "If currentTime > lastTime + 10" is so that I can do things like "timePassed = timePassed / 4", which makes everything go slow-mo. If I didn't make sure that the difference was greater than 10, then on a fast computer, "timePassed = timePassed / 4" could make timePassed round down to zero, effectively stopping the game.
If that made any sense whatsoever, please help me.