I need to pause the entire animation indefinitely until the user presses the same key again. I have a crude pause using usleep:
#include <unistd.h>
...
if(key == 'p')
usleep(200000);
Ideally though, I want the time to be indefinite until p is pressed again (and usleep measures in milliseconds so it’s not very useful) Can someone point me in the direction of how to do this?
You’ll also probably want to try checking for key up and not key down, otherwise you’ll pause and resume very rapidly.