We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello there! I need to make keyboard inputs fail for a limited time during a game made in Processing. I also need to randomize those failures.
I don't know if the "delay" is the best option. I'm new in Processing and I need it to test my research, so I will be eternally grateful to anyone who can help me!
Answers
Do not use
delay()
. It does not do what you think it does. It is not the function you want. Do not use it. Do not. No. No. No. Do not usedelay()
.Let me be very clear: DO NOT USE DELAY().
What you should use, instead, is a boolean that records if key presses are currently enabled, and a number that represents a time when that boolean should next switch values. You can get the current time represented as a number from the function
millis()
. You should usemillis()
.Here is an example:
In short:
delay()
BAD!millis()
GOOD!Ok, I got it. Delay() is the enemy. Bad bad delay(). Thank you!