Results 1 to 2 of 2

Thread: Matching Game

  1. #1
    tokki is offline Member
    Join Date
    Oct 2012
    Posts
    1
    Rep Power
    0

    Default Matching Game

    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!

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default 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.

Similar Threads

  1. Problem with Memory Matching Game
    By thesonyuh in forum New To Java
    Replies: 6
    Last Post: 09-24-2011, 04:59 AM
  2. Matching picture game in java
    By iswan in forum New To Java
    Replies: 1
    Last Post: 09-08-2011, 02:02 AM
  3. Need help with matching game
    By soundymcsoundsound in forum New To Java
    Replies: 2
    Last Post: 11-02-2010, 11:09 PM
  4. Picture Matching Game
    By schnappi in forum AWT / Swing
    Replies: 3
    Last Post: 08-09-2009, 01:38 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •