Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 455
  • Last Modified:

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.
0
moseyduck
Asked:
moseyduck
  • 9
  • 7
  • 2
  • +1
1 Solution
 
scrapdogCommented:
Could you be a little more specific?  What have you already figured out, and what have you not?
0
 
VBGuruCommented:
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?
0
 
moseyduckAuthor Commented:
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.
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
moseyduckAuthor Commented:
To vbguru, please provide some coding and be more specific about how to assign a picture to the control array.  
0
 
VBGuruCommented:
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
0
 
scrapdogCommented:
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.
0
 
moseyduckAuthor Commented:
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.
0
 
moseyduckAuthor Commented:
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.
0
 
scrapdogCommented:
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
0
 
moseyduckAuthor Commented:
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.  
0
 
scrapdogCommented:
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.
0
 
scrapdogCommented:
I mean "The tag *is* a property of the picture box"
0
 
myqlGCommented:
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 ;)
0
 
moseyduckAuthor Commented:
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.
0
 
scrapdogCommented:
Use a variables that indicates which card was flipped first.  If the variable is 0, then no card was flipped.  In the click event for the picture box, show the picture.  If the variable has a value of 0 then set the variable to the index of the picture box.  If the value is not 0, then a card has already been flipped, so you have to check if the two cards match.

If you call the variables Card1 and Card2, in the click event you would do something like this:

If FirstCard = 0 Then
  FirstCard = Index
  ShowTheCard(Index)
Else
  ShowTheCard(Index)
  If PictureBox(FirstCard).Tag = PictureBox(Index) Then Match
  Else NoMatch
  {....}
  HideTheCard(PictureBox(FirstCard))
  HideTheCard(Index)
  FirstCard = 0
End If
 
Note that this is pseudocode.  ShowTheCard and HideTheCard are functions you would implement (the purpose of these is self-explanatory).



0
 
scrapdogCommented:
oops

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

0
 
scrapdogCommented:
Another typo!

If PictureBox(FirstCard).Tag = PictureBox(Index).Tag Then Match
0
 
moseyduckAuthor Commented:
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?
0
 
scrapdogCommented:
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.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 9
  • 7
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now