Sleep() in processing

Hey guys,

I am currently coding on a game for school and I asked myself and googled how can I use the sleep() command in processing. I want to create a flappy bird like game and I want one loop to wait e.g. two seconds before it continues. Any ideas?

Greetings and thank you for response
Jeyeffkay

Hi @jeyeffkay,

Using “sleep()” is often not the best option to wait for something to happen because you’ll completely freeze your program during the sleeping time.

Instead you want to use millis() to check how much time elapsed since the last time you entered your draw loop and do something only if 2 seconds have passed.

There are plenty of exemple of that concept on the forum and I’m pretty sure you’ll find a nice example that will suit your situation.

1 Like

Thank you very much
I hope, I’ll find a suitable answer