November 3rd, 2012, 07:07 AM
Join Date: Feb 2008
Time spent in forums: 18 h 50 m 14 sec
Reputation Power: 6
Problem with repeat words from array
Hi, I'm making a small wordpuzzle game, and I have trouble figuring out how to make the game discard the words it has already given to the player.
I load in the array from an external txt file, and it works just fine. However, it is chosen at random from the list, which means that words get repeated sometimes.
So I'm looking for help on how to make the words that has already been used unselectable.
var wordString:String = wordLoader.data;
var wordArray:Array = wordString.split('\r\n');
lineNumber = pickRandomLine(wordArray);
var oldString:String = wordArray[lineNumber];
word = oldString;
wordScore = word.length;
var newString:String = randomizeWord(oldString);
while(oldString == newString)
newString = randomizeWord(oldString);
jumble_txt.text = String(newString);
var linePick:Number = Math.round((lenght.length -1) * Math.random());
Any help and/or ideas are much appreciated.
Last edited by stillwell : November 3rd, 2012 at 07:41 AM.