void draw()
{
background(#AAFFEE);
if (bDisplayMessage)
{
fill(#FFAA88);
text("You got it!", 150, height / 2);
// If the spent time is above the defined duration
if (millis() - startTime > DISPLAY_DURATION)
{
// Stop displaying the message, thus resume the ball moving
bDisplayMessage = false;
}
}
else
{
moveBall();
displayBall();
}
}
void mousePressed()
{
bDisplayMessage = dist(mouseX, mouseY, posX, posY) < radius;
// Record the time of the event
startTime = millis();
}