Results 1 to 4 of 4

Thread: Match Two Game

  1. #1

    Thread Starter
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,297

    Match Two Game

    I saw someone asking about this the other day so I thought that I'd throw a demo together. It's a simple game that displays a 5x4 grid of cards containing 10 matching pairs. The back of all cards is displayed initially and, after starting a game, the user clicks on a pair to reveal them. If the pair matches then both cards are removed and if they don't match then they are turned over again. The application times the game and displays the running time as well as the total time when the game is completed. The game can also be paused and restarted.

    I'm considering adding some more features to the game in the future, e.g. a list of best times and the ability to load an arbitrary number of image files from an arbitrary folder. We'll see if the mood strikes me.

    The attached solution was created in VS 2010 and contains projects in both VB and C#. If you're using VB Express 2010 or C# Express 2010 then only one of the projects will be loaded. If you try to open the MainWindow form in the designer and it won't display, just close it and then open it in the code window first and you should be OK from there.
    Attached Files Attached Files

  2. #2
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    11,711

    Re: Match Two Game

    Should this be in the game demo's section? Nice job by the way. I like the delay after selecting two cards, where did you do that at? Also, a quick suggestion: after you display "Congratulations! You have matched all cards..." you may want to call DisplayAllCardBacks.
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | Code Tags | Sword of Fury - Jameram

  3. #3

    Thread Starter
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,297

    Re: Match Two Game

    Quote Originally Posted by dday9 View Post
    Should this be in the game demo's section?
    I guess it could be but I didn't really do it as a game demo specifically. It was just a vehicle to demonstrate some programming principles. If the mods want to move it though, I won't complain.
    Quote Originally Posted by dday9 View Post
    Nice job by the way. I like the delay after selecting two cards, where did you do that at?
    After the Click of the second card, it starts a Timer. When that Timer Ticks, it stops itself and then calls a method that either hides a matched pair or turns an unmatched pair back over.
    Quote Originally Posted by dday9 View Post
    Also, a quick suggestion: after you display "Congratulations! You have matched all cards..." you may want to call DisplayAllCardBacks.
    I did think about that, although you have to click Start to start the game again so I thought that displaying the cards right away might imply that you could start playing again right away. That said, the card backs are displayed before you click Start when the app is first started, so I guess that That's an inconsistency. I should probably do as you suggest or not show the cards at startup. I'll decide which and implement it if and when I add new features.

  4. #4
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    11,711

    Re: Match Two Game

    Ahh, ok. You set the viewtime's interval to one second and then just stop it after one tick, then calling the ProcessSelection. I like how simple that is, it actually helps me out to improve some of my games that I've uploaded.
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | Code Tags | Sword of Fury - Jameram

Posting Permissions

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



Click Here to Expand Forum to Full Width