Random word generator

Yo smart people, I am currently working on a random word generator. The reason for it is to give an objective either every 15 minutes or by key press. For instance “Draw the letter B”.
I got the randomiser, but it is either going too fast, or with delay so slow the program stops running? And also tried the keypress. (Currently has an image as background). I can’t seem to figure out how create a timer the redraws the objective.
Heres the code.

PFont font;
PImage bg;
int n = 0;

void setup() {
  size(1920, 1080);
//  frameRate(1);

bg = loadImage("backtest.png");

void draw() {
//var n = 0;
var o = 0;
var s = 0;

  font = loadFont("type1.vlw");
//arrays, which are int because they varray from 0 to 4
String[] nouns = {"A","B","C","D","E"};
String[] stasis = {"Draw letter"};
String[] objective = {"objective"};

//int n = int (random(5));
//int o = int(random(1));

text(nouns[n], 400, 700);
text(stasis[s], 110, 700);
text(objective[o], 110, 650);


void keyPressed(){
  if ( key == 'r') {
    n = 1;
    n = 4;


There are many examples of timers in this forum.

This is just one of them:

This is the reference for delay():

I suggest you read it before you consider using it.

Consider working on a simple timer first and then integrating it with your code once you understand it.


1 Like