• Advertisement

Archived

This topic is now archived and is closed to further replies.

Memory game - I really need help!

This topic is 5018 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, in a project in school I am supposed to make a memory game of matching pairs in visual studio .net using C++ and a Windows interface application. The cards will be buttons that change image when you click on them, but I need help with a few things... * Random placement of images on the buttons. * Lock two cards if they are a matching pair. * Time limit. Please, I really need help!

Share this post


Link to post
Share on other sites
Advertisement
What the question is? You want me to code this for you?! No way.



"C lets you shoot yourself in the foot rather easily. C++ allows you to reuse the bullet!"

Share this post


Link to post
Share on other sites
Random placement should be pretty easy.

I imagine you'll be storing your cards in a 2D array, assuming the first index are the rows (top to bottom) and the second index are the columns (left to right).

Place all your cards in a uniform pattern in this 2D array.

So 0,0 put your Ace and 0,1 put your other Ace. Now in 0,2 put your King and your 0,3 put your other King. Do this for all the cards (no idea how many you'll have).

To randomly place them, loop through your cards 500 times. Pick one card, and swap it with another card.

Psuedo Code:
Loop 1 to 500
Randomly Pick X1, Y1
Randomly Pick X2, Y2
Store Tempoary Card Of X2, Y2
Set X2, Y2 as the card from X1, X2
Assign Tempoary Card to X1, X2
End Loop

That should help you get started.

[edited by - GroZZleR on May 25, 2004 1:41:14 AM]

Share this post


Link to post
Share on other sites

  • Advertisement