Very simple while loop bugs

I have been having bugs and I deducted they were coming from the while conditions.
So i tested a very simple code below and indeed it freezes the screen at the start of the preview. The code should print “1 2 3 etc 11end check”

Reverse engineering the whole thing I guessed it was the timedelta not working in a loop. If there was a correct tutorial these huge loses of time would not happen. This is not serious! And the while loop remains a mystery as too how fast it turns.

Are you sure you didn’t do an infinite loop?

TimeDelta() woks fine in loops but I don’t understand why you sum it several times in a frame.

If you make assertions that something isn’t working then you can’t just guess why it is, you need to prove it. I’ve created the same events as you, and it works fine. So the claim that TimeDelta doesn’t work in a loop is not correct.

I do note that you are using an older version of GDevelop. My test was written using the online editor. Not sure if that’s an issue.

However, your testing needs to be a more thorough in order to pinpoint exactly where the issue lies.


I don’t understand this. First you say it freezes, and now it’s running too fast.

If you feel running too fast, then I’m not sure what you expected. The while loop is not running once every game frame. It’s running continuously, extending the length of that one game frame it’s being processed in. It’s most likely running thousands of times a second.

So variable “a” is not reducing to 0 over a second, but rather reaching 0 in a fraction of a second. Do this 11 times, and the “while” event will more than likely take less than a second to fully execute.

you copied the same code and it worked??
I don’t understand your remarks. I said this simple code freezes, black screen.

I tried online and it doesn’t work either.
And it’s the timedelta because if i replace it with 0.1 then it works on my computer and online. You can’t be more clear and logic. So don’t try to turn this on me

I quoted you saying it runs too fast.

Anyway, I’ve recreated the sample project you gave, and indeed this time it froze. What I don’t understand why this time, nor why it worked previously.

But I do understand why it freezes - the very first time it runs, so the very first frame, how many seconds have passed since the last frame? Zero, because there is no previous frame.

To confirm this, I ran this event, and got 0 in the text output:

So it’s not an issue with timedelta(), but it’s the expectation and usage of it.