I have this code and I want to make the square disappear when clicking a key and two seconds after clicking it, the square reappears in another position.
Thanks!
Thank you very much but I think I did not express myself well I meant to put the time in the console. It is to later be able to use that time in something else
Sorry, it is a policy of this forum not to write full code for newbies, that’s why I am giving only hints at the moment. Not because I am lazy, haha…
It’s so that you can figure it out by yourself.
I want to mention that when you plan a “reaction time test” you want to have a random time passing before the rect appears
I understand what you say haha
That would be the idea but for a beginner that would be even more difficult to do and if it is already difficult for me to do the timer
i do that is correct?
int cuadrado=20;
float recX, recY;
float randomWait= random(4000,10000);
int timer;
int timer2=millis();
int result= millis()-timer2;
boolean showingRect=true;
String timeString = “”;
void setup() {
fullScreen();
noCursor();
fill(250);
frameRate(30);
recX = random (width-cuadrado);
recY = random (height-cuadrado);
background(0);
}
void draw() {
background(0);
// Eval flag showingRect
if (showingRect) {
// show rect
rect(recX, recY, cuadrado, cuadrado);
} else {
// pausing, wait for timer
text(timeString, 100, 122);
if (millis() - timer > randomWait) {
// NEW RECT
showingRect=true;
recX = random (width-cuadrado);
recY = random (height-cuadrado);
}
}
}
void keyPressed () {
// pause the rect
timer=millis();
showingRect=false;
println(result);
}