Link to home
Start Free TrialLog in
Avatar of moseyduck
moseyduck

asked on

concentration game

I need to know how to make the game "concentration" using pictures that you flip over instead of cards.  I want to make about 20 green colored rectangles that you click on and a picture appears. I can't figure out how to do this.
please help.  I'm just a vb5.0 beginner. thanks.
Avatar of scrapdog
scrapdog
Flag of United States of America image

Could you be a little more specific?  What have you already figured out, and what have you not?
Simplest solution will be to have 20 picture boxes generated dynamically and filinng them with the colour what it should contain when turn aside. In the click event check the index proprty of the control array and assign the picture you want to put. These pictures once again can be placed  in a resource file for faster access and you  don't have to ship it with your application.
If you have anything more to know about let me know?
Avatar of moseyduck
moseyduck

ASKER

In regards to scrapdogs comment, I have not even figured out how to start my form.  I don't know whether to use a text box with a picture underneath or a control box with a picture underneath or maybe not even that at all.  I would like to see what your suggestion is.
To vbguru, please provide some coding and be more specific about how to assign a picture to the control array.  
Then you get info regarding "What is a control  array" from the VBONLINE. for to do that you have to set index property of that control to 0.
Let me know what is your next doubt
I would also suggest using picture boxes.  To make a control array, put one picture box on your form.  Then select it and go to copy (in the edit menu?).  Then paste it somewhere.  It will ask you if you want to create a control array.  Keep pasting the boxes until you have 20.  Then line them up the way you want.

In the click event of these, a variable called index is passed.  This will tell you which picture box was clicked.  I would suggest using another array to indicate what is stored in these picture boxes, and use index to check what it is.
I still don't understand how many arrays are needed if i am going to be able to click on a square for example, and see an image, then click on another square to see another image. Does this have to be done with arrays?  How do i code this so that if the two images are not the same, after 2 or 3 seconds the square comes back and you have to pick two more squares to figure out where the matching images are.  if the images are matching, i want them to stay visible.
I still don't understand how many arrays are needed if i am going to be able to click on a square for example, and see an image, then click on another square to see another image. Does this have to be done with arrays?  How do i code this so that if the two images are not the same, after 2 or 3 seconds the square comes back and you have to pick two more squares to figure out where the matching images are.  if the images are matching, i want them to stay visible.
Have each image be represented by a number in an array.  You could even store this in the tag property of the picture box.  To determine whether or not they are the same, just compare the values in the tag property.

If Picture(a).Tag = Picture(b).Tag Then Match
Unfortunately I need more specific instructions.  I can't get the array to work.  Isn't there a way to do this without an array?  I also can't center the icon in the picture box anyway.  I know how to make an array using picture boxes.  I just don't know how to create another one using the tag property.  
Don't create another one.  Use the array of picture boxes.  The tag a property of the picture box, which is an element of the array.
I mean "The tag *is* a property of the picture box"
This sounds like an assignment for class.  If you are gunna get
help you should at least make the points worth it so we feel
better about cheating ;)
Well, this is kind of a project for school, but we're allowed to use whatever means necessary.  We have to make something, anything, and this was all I could think of that sounded kind of fun.  How many points do you want? I only have 156 left and need some for another question.
ASKER CERTIFIED SOLUTION
Avatar of scrapdog
scrapdog
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
oops

"If you call the variables Card1 and Card2" = "If you call the variable FirstCard"

Another typo!

If PictureBox(FirstCard).Tag = PictureBox(Index).Tag Then Match
If I can call you on the phone and work this out, I'll give you extra points.  I think it would be faster for me. If you want to, send your phone number to moseyduck@stic.net and I'll call you or you can call me @ 1-800-749-6488 tomorrow (Texas time). I would really appreciate this.  I'm getting confused with the picture boxes and tags and variables.  If I make 20 green empty picture boxes and make this an array, then how to I give each box a certain picture in the click event?
Check the help file on picture boxes.  It will show you how to assign an image to a picture box.  When a card is flipped, assign the image to it.  Otherwise assign a blank image or an image of the back of the card.

You could use a set of filenames to images or whatever in an array to indicate an image, and this array would be indexed by the number found in the picture box's tag property.  In the beginning of the program you would randomly assign these numbers to the picture box's tag property.

In other words, in your ShowCard subroutine, assign the image, and in HideCard, assign the image of the back of the card.

Sorry, I can't help you on the phone, because I don't have Visual Basic, so I wouldn't be able to walk you through it.