I have been working on a Words Formation game (sample: http://www.popcap.com/games/bookworm/online) for quite long. Everything is done, except for one last thing that I can not figure out how to implement.
In short, I am displaying a 2D grid of Jbuttons with letters one them (I have implemented a graphical version of JButton). The user has to form words from the random letters on the buttons, and the score is added. Now when the user can no longer form any words, I want the game to end. The idea I tried using to implement this is as follows:
I store ALL the coordinates of the grid in an ArrayList (I will call this AllCoordinates). Then, I store the coordinates of the selected JButtons in a separate ArrayList (I will call this Coordinates). I compare the two lists, and store the coordinates in the ArrayList AllCoordinates that do not exist in Coordinates. I do not know how I can form various words with so many random coordinates. Could someone help me with a way of doing this?
If you have any better ideas of doing this, I would be grateful for your input.
PS
I am sorry for not posting the code. It is too long and complicated to be posted here
Thanks :)