I still can't seem to think, syntactically, how to implement this.
The logic of the code is in my head, actually, a couple of ways to do it is clear but I'm having trouble in creating a solution for the core part of my game.
So far so good, I've made the menu, added code to deal with the player, added methods to pass letters etc but, this part just hits the nail on the head.
The place where it says //TODO is where my problem is. Which in simpleton terms: How to change the label on the windows form to actually contain the letter. So at the moment the label shows _ _ _ _ _ _ where the word might be Usmaan. If I send a 'Letter' a then the label should become _ _ _ a a _
I have a loop which can go through all of the indexes of the array which in essence is the actual word but just cut up in to chars so that I can check each index if it == to the letter. I've tried to soooo hard but I can't get my head around it. And I've tried using IndexOf and IndexOfAny but still can't nail the solution.
If you can help me, i'd really appreciate it.
Code:
{
lblTesting.Text = gameLetter; // For Testing Purposes
char[] wordToCharArray = word.ToCharArray(); // Convert the word to a char array
lblTestingArray.Text = wordToCharArray[0].ToString(); // For Testing Purposes
for (int i = 0; i <= word.Length -1; i++)
{
if (wordToCharArray[i].ToString() == gameLetter)
{
//TODO
}
}
}
And these are my global variables so that they can be accessed in any of the methods:
string word;
int length;
Random random = new Random();
string[] wordArray = { "BLUE", "RED", "GOLD", "BLACK", "GREEN" };
char[] changingWordArray;
string underscores;
Some of the variables like underscore and changingWordArray don't do anything *YET* - I was just trying to perform certain methods of fixing the problem but, no progress.
PLEASE HELP