Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


Help with some problems with word search game


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 Manhattanisgr8   Members   -  Reputation: 487

Like
0Likes
Like

Posted 21 November 2013 - 07:33 PM

I am having some trouble with a word search game I am making in Java. For starters, when I click on new game in the menu bar, it draws the puzzle just fine. However, if you click it again, it doesn't draw the new puzzle. I know it is drawing the puzzle because I have it displaying in the output window, it's just not drawing on screen.
 
My other problem really isn't a problem, more of a question. How would I go about highlighting the user's selection? I know I should be using the MouseListener, however, how would I snap that to the 2D array that has the puzzle?
 

WordSearchDriver.java:

Spoiler

 

TextFileReader.java

Spoiler

 

WordsToFindPanel.java:

Spoiler

 

SearchBoardPanel.java

Spoiler

 

Frame.java:

Spoiler

 

MainPanel.java:

Spoiler

 

SearchBoard.java:

Spoiler

 

Listeners.java:

Spoiler

 

 


Cpl Alt, Travis A

USMC


Sponsor:

#2 boogyman19946   Members   -  Reputation: 1078

Like
3Likes
Like

Posted 21 November 2013 - 10:27 PM

You should consider that when you add new things to a container, the old things that are already in there do not go away. The new game button just creates a new MainPanel and adds it, but if there is one already in there, it might be added somewhere where you can't see it. Try removing mp first and the adding it again. Consider that you might run into a problem of adding items out of order. If there are components added after the MainPanel, they will be relocated because the MainPanel is now going to be the last component to be added.

 

Also don't abbreviate complicated names like SearchBoardPanel to sbp. It makes it harder to figure out what the code means.


Edited by boogyman19946, 21 November 2013 - 10:28 PM.

"If highly skilled generalists are rare, though, then highly skilled innovators are priceless." - ApochPiQ

My personal links :)
- Khan Academy - For all your math needs
- Java API Documentation - For all your Java info needs :D
- C++ Standard Library Reference - For some of your C++ needs ^.^

#3 Manhattanisgr8   Members   -  Reputation: 487

Like
1Likes
Like

Posted 22 November 2013 - 02:40 AM


Try removing mp first and the adding it again.

 

Thanks, that worked. Now I just need help getting pointed in the right direction for the highlighting / circling the words the user finds


Cpl Alt, Travis A

USMC


#4 Eck   Crossbones+   -  Reputation: 3356

Like
0Likes
Like

Posted 22 November 2013 - 08:30 AM


Also don't abbreviate complicated names like SearchBoardPanel to sbp. It makes it harder to figure out what the code means.

 

Good naming is a small cost, high gain thing you can do to become a much better programmer. It makes your programs so much easier to understand which has all kinds of benefits. When I was in school, I dismissed my professors' wisdom. "I can keep this straight, it's no problem for me." But later on in the real world, I'd be cussing my predecessors who wrote the garbage code I had to debug. :)

 


Thanks, that worked. Now I just need help getting pointed in the right direction for the highlighting / circling the words the user finds

 

You'll need to define how you'd like the user to "circle a word".

Spoiler

 

Your search board will need to be able to identify what's been found. Currently the board is just a 2d array of strings. You need to start tracking the state for "circling" and "circled" words.

Spoiler

 

- Eck






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS