I have just make an object move continuously and Now I want to make it stop in 10 seconds if the space bar is pressed?
Does anyone know how to implement this in processing? Thank you in advanced!
I have just make an object move continuously and Now I want to make it stop in 10 seconds if the space bar is pressed?
Does anyone know how to implement this in processing? Thank you in advanced!
By default, Processing draws at 60 frames/second, so you can use that to your advantage.
//Global Variables
int countDownTimer = 600 //10 seconds * 60 FPS
boolean spacePressed = false;
void draw(){
if(spacePressed){
countDownTimer--;
if(countDownTimer == 0){
//Whatever happens after 10 seconds here
}
}
}
void keyPressed(){
if(key == " "){
spacePressed = true;
}
}