|
-
Dec 7th, 2003, 08:21 PM
#1
Thread Starter
New Member
Looking for some coding help.
Hey people, I'm a newbie in programming; taking my first class in VB.NET at my school.
I'm trying to work on my last assignment and I'm completely stuck. So any help would be appreciated. Sorry for the long post.
I'll try to explain the assignment to you the best I can.
It's a simple game. There are 16 (equal size) picboxes arranged 4x4. There's also another picbox to the side. Each picbox in the 4x4 will be randomly assigned an image from the bin folder.
The 17th picbox (lets call it picWin) to the side will also be assigned randomly an image.
The goal of the game is to find (by clicking on) the image in 4x4 of boxes until you find the image that matches the image in picWin.
I have no problem figuring out how to code random assignment to each box. The problem I do have is figuring out how to pick the winning image which will match the image in picWin.
I hope that makes sense.
Thanks.
-
Dec 7th, 2003, 09:17 PM
#2
Frenzied Member
How, exactly, are you displaying your pics? Looking into properties and methods of the control you use might help.
-
Dec 7th, 2003, 09:47 PM
#3
Thread Starter
New Member
they are being displayed with the image property.
Here's some line of code from my program:
VB Code:
Private Sub Load_Image(ByRef PBImage)
'Procedure that will assign a random picture from the array to the picture box
myNum = randomNum.Next(0, 15)
PBImage.Image = Image.FromFile(Application.StartupPath & "\" & PicturesArray(myNum))
End Sub
This code is being called by: Load_Image(pic1) in a click event.
pic1 is one of the picture boxes in the 4x4 arrangement. There's an array that has been dimensioned with the file names of the images.
Last edited by afrdzak; Dec 7th, 2003 at 09:51 PM.
-
Dec 7th, 2003, 09:51 PM
#4
PowerPoster
My suggestion would be to put the file name in the PB's .Tag property. Then you can compare the Tags to see if they match.
PBImage.Tag = PicturesArray(myNum)
-
Dec 7th, 2003, 09:53 PM
#5
Thread Starter
New Member
Originally posted by hellswraith
My suggestion would be to put the file name in the PB's .Tag property. Then you can compare the Tags to see if they match.
PBImage.Tag = PicturesArray(myNum)
Yeah, that's one of the methods my dad mentioned, however, a problem with using this method is this. There's no guarantee that all the pictures will be assigned to a PictureBox. So, it's possible that some instances of the game, there's no chance of winning because there was never a randomly selected image assigned into the group of Picture Boxes.
Last edited by afrdzak; Dec 8th, 2003 at 01:31 AM.
-
Dec 8th, 2003, 07:45 AM
#6
Wow, how cool is it to have a Dad that can code.
Respect.
I don't live here any more.
-
Dec 8th, 2003, 10:06 AM
#7
PowerPoster
Originally posted by afrdzak
Yeah, that's one of the methods my dad mentioned, however, a problem with using this method is this. There's no guarantee that all the pictures will be assigned to a PictureBox. So, it's possible that some instances of the game, there's no chance of winning because there was never a randomly selected image assigned into the group of Picture Boxes.
OK, so run a routine that goes through the 16 PB's to see if any of the tags match up with the other PB tag. If one of them does, you know you have a match in there, if not, well, you don't have a match. This looks to be about 10 - 20 lines of code to do all you are talking about. I think you are making this too hard.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|