xxxxxxxxxx
149
// variable to hold the count
var count = 0;
//attempt variable
let attempt;
function setup() {
createCanvas(800, 500);
}
function click1(){
attempt=1
}
function draw() {
//page 0
if(count == 0){
background(50,150,250);
textSize(38);
text('Visual Reaction Time Test', 180, 230);
textSize(70);
text('CLICK TO START', 120, 350);
textSize(23);
text('Click as fast as you can when the screen turns red', 140, 450);
}
//Try 1.1
if(count == 1){
background(50,150,250);
textSize(70);
text('GET READY...',155,280)
setTimeout(click1,1000) }
//Try 1.2
if (attempt==1){
background(250,50,30)
textSize(70);
text('CLICK !', 255, 280);
}
}
//fail 1
if (count == 2) {
background(50,150,250);
textSize(70)
text('Too early ! ',200,270)
textSize(25)
text('Click to try again',270,450) }
//Try 1 result
if(count == 3) {
background(40,240,50)
textSize(65);
text('XXX ms !',250,280);
textSize(30);
text('Click again for your next try',200,400);
textSize(25);
text('Try 1 : XXX ms ',600,400);
textSize(25);
text('Try 2 : ---',600,430);
textSize(25);
text('Try 3 : --- ',600, 460);
}
//
//Try 2.1
if (count== 4) {
background(50,150,250);
textSize(70);
text('GET READY...',155,280) }
//Try 2.2
if (count==5) {
background(250,50,30)
textSize(70);
text('CLICK !', 255, 280);
}
//Try 2.3
if (count==6) {
background(40,240,50);
textSize(65);
text('XXX ms !',250,280);
textSize(30);
text('Click again for your next try',200,400);
textSize(25);
text('Try 1 : XXX ms ',600,400);
textSize(25);
text('Try 2 : XXX ms ',600,430);
textSize(25);
text('Try 3 : --- ',600, 460);
}
//Try 3.1
if (count ==7) {
background(50,150,250);
textSize(70);
text('GET READY...',155,280); }
//Try 3.2
if (count==8) {
background(250,50,30);
textSize(70);
text('CLICK !',255,280);
}
//Try 3.3
if (count==9) {
background(40,240,50);
textSize(65);
text('XXX ms !',250,250);
textSize(30);
text('Click again to see your final result',180,320);
textSize(25);
text('Try 1 : XXX ms ',600,400);
textSize(25);
text('Try 2 : XXX ms ',600,430);
textSize(25);
text('Try 3 : XXX ms ',600, 460);
}
//Final screen
if (count==10) {
background(40,240,50);
textSize(55);
text('Your final average is...',110,170);
textSize(80);
text('XXX ms !', 240, 310);
textSize(35);
text('Click again to retry',250,440); }
// everytime the user presses on the mouse or trackpad
// the count goes up
function mousePressed(){
count = count + 1;}