Results 1 to 2 of 2
Thread: Matching Game
- 10-07-2012, 02:44 PM #1Member
- Join Date
- Oct 2012
- Rep Power
I'm a begginer in java. and I'm doing a Matching/Memory Game in JCreator using buttons and if-else statements.
It's just the typical Matching/Memory Game. When you click the buttons, the image clicked will pop up then if you click the next one, but it's not the same image, then both will close. If you get the correct matching image, they both disable. My problem is the logic of matching it.
What will I do or use to make my program know that two buttons match?
I hope someone is getting what i mean here :(
This is how it looks when the buttons are clicked. New game button is working too. It reverts back to the closed buttons.
I really need help with this asap! This is my assignment, to be passed this tuesday.
I'll be really grateful if someone could help me!
Re: Matching Game
One way to get this to work is to use ImageIcons. Note that two buttons can share the same ImageIcon, and so you could distribute 8 pairs of ImageIcons to the 16 buttons, and then compare ImageIcons with the equals(...) method.
Myself when I've done this, I've separated the game logic from the GUI, and created a "model" with buttons, that could be compared to see if they were equal, but this is not necessary if you're creating this game.
- By thesonyuh in forum New To JavaReplies: 6Last Post: 09-24-2011, 05:59 AM
- By iswan in forum New To JavaReplies: 1Last Post: 09-08-2011, 03:02 AM
- By soundymcsoundsound in forum New To JavaReplies: 2Last Post: 11-03-2010, 12:09 AM
- By schnappi in forum AWT / SwingReplies: 3Last Post: 08-09-2009, 02:38 PM