How do I stop repeats on random variables?

I have my code set up to choose from a random selection of words. Only problem is, it often chooses the same one more than one time in a row. I want a variable to remove itself after I've chosen it. I'm pretty new to this so apologies if this is fairly obvious. I've put my code in it's current state below, encase that helps. Cheers!

int yPos = 40;
int shuffle = 16;

PFont ourFont;

void setup(){
size(500,250);
background(0,0,0);
ourFont = loadFont("Quicksand-Bold-24.vlw");

}



//click to start
void mouseClicked(){
  shuffle = shuffle -15;

}





void draw(){

    if( shuffle > 15){

  textFont(ourFont);
  fill(236 , 0, 140);
  text("Click to start.", 170, 125);
    }

  //move background after 'if( shuffle < 10){' then words stay when integer =10
  if( shuffle < 15){
    background(0,0,0);
  String[] words = {"I've been interviewed on national television dressed as a chicken.", "I've refereed in the world marbles championships.", "I once featured on the TV show 'Animals Do the Funniest Things' getting headbutted by a reindeer.", "I can speak Span(ish).", "I'm learning sign language.", "I like to sea-swim.", "I was once featured in the papers for a book signing when I hadn't read the book.", "My middle name is Nathan.", "I can count to 10 in 5 languages.", "My first TV appearance was at the age of 4.", "I cook a mean Sunday Roast.", "My initials are SnM.", "I can play the drums.", "I skateboard, mountain board and snowboard.", "I'm known for my puns.", "I have a beard.", "I'm 5ft 8 inches tall.", "I like to play table tennis.", "I was once attacked by a fox.", "I like to play pool.", "I like words.", "I've never seen Star Wars.", "I'm a purple belt in Karate", "I can diablo.", "I love hip-hop music.", "I have blue eyes.", "I'm quite hairy.", "I once ran a half marathon with 2 weeks training.",  "I love Stroop Waffles.", "My favourite biscuit is a malted milk." };
  int index = int(random(words.length));
  textFont(ourFont);
   fill(255 , 255, 255);
  text(words[index], 30, 30, 370, 200);
  shuffle = shuffle +1;

    }


  delay(100);

}

Answers

Sign In or Register to comment.