# Random word generator

**URL:** <https://discourse.processing.org/t/random-word-generator/37667>\
**Category:** Coding Questions\
**Tags:** homework\
**Created:** [June 21, 2022, 11:10am UTC](https://discourse.processing.org/t/random-word-generator/37667 "2022-06-21T11:10:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![FrankyWes](https://avatars.discourse-cdn.com/v4/letter/f/9de0a6/32.png) [@FrankyWes](https://discourse.processing.org/u/FrankyWes)\
**Post date:** [June 21, 2022, 11:10am UTC](https://discourse.processing.org/t/random-word-generator/37667/1 "2022-06-21T11:10:07Z")

</div>

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.

```auto
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;
  

  background(bg);
//background(255);
  fill(255);
  
  
  font = loadFont("type1.vlw");
  textFont(font);
  
//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));
//delay(50000);

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

}

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

```

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [June 21, 2022, 11:26am UTC](https://discourse.processing.org/t/random-word-generator/37667/2 "2022-06-21T11:26:18Z")

</div>

Hello,

There are many examples of timers in this forum.

This is just _one_ of them:

> [@Need assistance with timing! \[millis()\]](https://discourse.processing.org/t/need-assistance-with-timing-millis/18854/4):
>
> I provided a simple example: int whattimeisitnow; int whattimeisitatstartofstopwatch; int timepassedtoresetstopwatch = 1000; //setup runs once void setup() { whattimeisitatstartofstopwatch = millis(); } //draw loops 60 frames per sec void draw() { whattimeisitnow = millis(); if (whattimeisitnow \> whattimeisitatstartofstopwatch + timepassedtoresetstopwatch) { println("1000 ms have passed!"); whattimeisitatstartofstopwatch = millis(); //reset st…

This is the reference for delay():

> **[delay() / Reference](https://processing.org/reference/delay_.html)**
>
> The delay() function causes the program to halt for a specified time. Delay times are specified in thousandths of a second. For example, running delay(3000) will stop the program for thr…

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.

`:)`
