Does it do what you want?
with full screen you don’t see the console anyway
do you mean println(result);
How to do this
This
randomWait= random(4000, 10000);
won’t work.
you need this command where you start a new rect otherwise the value is random once and keeps the value forever. Bad.
same here:
int timer2=millis();
int result= millis()-timer2;
you need to have
int timer2;
int result;
before setup()
BUT
say
timer2=millis(); // start measurement
and
result = millis()-timer2; // stop measurement
println(result);
in the correct places in your code where you want to start and stop (measure) the timer!!!
Chrisir
i need the result in console because after the program i need copy the times
yes, follow my ideas above
I just finished here your Sketch
by the way: say frameRate(1900); or so, because a very low frameRate like 30 would destroy the measurements
don’t know probably we measure how fast your keyboard is also…
343
300
351
294
320
311
300
260
340
255
321
319
30
549
294
401
291
350
275
400
284
345
289
240
I have this but in console when i click a button put a all the values 0
int cuadrado=20;
float recX, recY;
float randomWait= random(2000,6000);
int timer;
int timer2;
int result;
boolean showingRect=true;
String timeString = “”;
void setup() {
fullScreen();
noCursor();
fill(250);
frameRate(1900);
recX = random (width-cuadrado);
recY = random (height-cuadrado);
background(0);
timer2= millis();
result= millis()-timer2;
}
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);
}
please make sure you start the measurement in the correct place in your code.
When does the measurement begin?
and end it in the right section of your code.
Hint: setup() is not the right place and having one directly after the other won’t work either.
As I tried to explain:
479
280
236
260
250
239
260
280
256
271
306
270
266
280
280
370
238
250
289
269
300
400
270
450
270
330
290
270
340
270
290
29662
343
340
350
300
348
335
310
320
290
275
320
279
380
280
250
361
311
280
339
521
311
350
330
291
260
284
290
1381
296
340
30
hi chrissir i cant reply this days but i think im finished is this correct?
int cuadrado=20;
float recX, recY;
float randomWait= random(2000,6000);
int timer;
int timer2;
int result;
boolean showingRect=true;
String timeString = “”;
void setup() {
fullScreen();
noCursor();
fill(250);
frameRate(1900);
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);
timer2=millis();
}
}
}
void keyPressed () {
// pause the rect
timer=millis();
result=millis()-timer2;
showingRect=false;
println(result);
I think that’s correct!!
Did you test it?
This you must have where you start a new rect
Yes and is perfect for my project
I will try it
…,…
Chrissir the game is going as I wanted to do it, thank you very much for your help.
I hope everything goes very well
bye.
Thanks for your feedback.
This: randomWait= random(2000,6000);
is important so that the time between appearances of rect is always different
i do it and of course is perfect