Hey guys.
I’m making a scrabble type of game and i’m stuck in this.
I have a grid for the letters and i can check the lines and columns if they combine and create a word. But when i find a word, i cant extract the letters that formed the word from the rest of the line.
like here, i can find the word “if” in the line. But i cant locate it for using. What i want is to destroy the letters that formed a word like tetris. But for that, my code has to know where the letters that make the word in the grid. I’m using a basic “Contains” method to find the words. And here’s how i combine the letters in the lines and columns:
int xposition = stringGrid.GetGridObject(position).x;
int yposition = stringGrid.GetGridObject(position).y;
string line = stringGrid.GetGridObject(0, yposition).ToString() + stringGrid.GetGridObject(1, yposition).ToString() + stringGrid.GetGridObject(2, yposition).ToString() + stringGrid.GetGridObject(3, yposition).ToString() + stringGrid.GetGridObject(4, yposition).ToString() + stringGrid.GetGridObject(5, yposition).ToString();
string column = stringGrid.GetGridObject(xposition, 8).ToString() + stringGrid.GetGridObject(xposition, 7).ToString() + stringGrid.GetGridObject(xposition, 6).ToString() + stringGrid.GetGridObject(xposition, 5).ToString() + stringGrid.GetGridObject(xposition, 4).ToString() + stringGrid.GetGridObject(xposition, 3).ToString() + stringGrid.GetGridObject(xposition, 2).ToString() + stringGrid.GetGridObject(xposition, 1).ToString() + stringGrid.GetGridObject(xposition, 0).ToString();
I know it can be much better and optimized but my first goal is to make it work and then make it pretty. So please tell me a way to extract and locate the letters.
Thanks in advance.