Hi, I’m trying to get my if statement (which I’m trying to have stay “activated” for a few moments upon triggering it then disappear after staying up for a few seconds) to revert back to it’s state before the else if upon the else if staying visible and active for a few moments. (basically have the sound play for a few seconds then everything goes back to how it was before)
I’m new to coding and even after watching a video or two I’m entirely stuck on this likely simple problem! All I want is for the sound and cube to change colors for a set amount of time then pop back to the sketches previous state.
int time;
import ddf.minim.*;
Minim minim;
AudioPlayer player2;
void setup() {
size(400, 400);
minim = new Minim(this);
player2= minim.loadFile("Shhh Sound effect.mp3");
time = millis();
}
void draw() {
background(0);
if (dist(mouseX, mouseY, 200, 200)<100) {
fill(36);
player2.play();
if (millis() < time) {
fill(255,0,0);
}
} else if(millis() < time) {
time = millis() + 300;
player2.rewind();
fill(36);
}
ellipse(200, 200, 200, 200);
}