|
-
Apr 7th, 2001, 10:16 PM
#1
Thread Starter
Member
well, i had loaded array of images during run-time and when the user clicks on the imagebox then the image is shown and when the user clicks on the other imagebox then the other image also shown.
well my problem is that, how can i compare the image which is first clicked with the image which is second clicked?
if both pics are of the same then both pics will remain in the imagebox (means shown), else both pics is closed (means unload picture).
Code:
Private Sub imagebox_Click(Index As Integer)
:
:
:
-
Apr 8th, 2001, 03:39 AM
#2
Can't you just let it remember what picture you loaded in that imagebox???
-
Apr 8th, 2001, 06:31 AM
#3
Fanatic Member
Code:
Private iLastClick As Integer
Private Sub Form_Load()
iLastClick = -1
End Sub
Private Sub imagebox_Click(Index As Integer)
If iLastClick = -1 Then
' This is the first image we clicked, save the index
iLastClick = Index
' And you can Do the picture changing here, like:
' imagebox(Index).Picture = sourceimgbox.Picture
Else
' This is the second image we clicked, reset the index
iLastClick = -1
' Check If they're the same
If imagebox(Index).Picture = imagebox(iLastClick).Picture Then
' The images should stay
Else
' Make them go away
End If
End Sub
Is that what you mean?
Teaudirenopossum.Musasapientumfixaestinaure.
(I can't hear you. There's a banana in my ear)
-
Apr 8th, 2001, 08:15 AM
#4
Good Ol' Platypus
Ummm... PsychoMark, you reset the index before checking it... I think he wants to make a simple concentration game. (for this you may want to have another array of stdpictures so the images are just card backs, if that's what you are making: )
Code:
Dim Pics(0 to 9, 0 to 9) as StdPicture
Dim LastClickedX as Integer
Dim LastClickedY as Integer
Dim DonePic(0 to 9, 0 to 9) as Boolean
Private Sub Picture1_Click(Index as Integer)
If DonePic(Index Mod 10, Int(Index / 10)) Then Exit Sub
If LastClickedX < 0 or LastClickedY < 0 Then
LastClickedY = Int(Index / 10)
LastClickedX = Index Mod 10
End If
If LastClickedX > -1 or LastClickedY > -1 Then
If Pics(Index Mod 10, Int(Index / 10)) = Pics(LastClickedX, LastClickedY) Then
Picture1(LastClickedY * 10 + LastClickedX).Picture = Pics(LastClickedX, LastClickedY)
Picture1(Index).Picture = Pics(LastClickedX, LastClickedY)
DonePic(Index Mod 10, Int(Index / 10)) = True
DonePic(LastClickedX, LastClickedY) = True
End If
End If
End Sub
Private Sub Form_Load()
Dim I as Integer: Dim J as Integer
LastClickedX = -1: LastClickedY = -1
For I = 0 to 9: For J = 0 to 9
Pics(J, I) = LoadPicture(App.Path & "\pic" & J & I & ".bmp"
Next I: Next J
End Sub
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Apr 8th, 2001, 08:16 AM
#5
Good Ol' Platypus
To find out if the user has "won", loop through donepic. If they are all true, then the user has won. (The above code does a 10 x 10 card game.
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Apr 8th, 2001, 08:34 AM
#6
Fanatic Member
Ummm.... Sastraxi 
I resetted the index at Form_Load, and whenever someone had selected the second image...
* looks again *
Oops, wait, my mistake, just saw what I did. You're right, the iLastIndex = -1 should be after the If imagebox.....
Teaudirenopossum.Musasapientumfixaestinaure.
(I can't hear you. There's a banana in my ear)
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
|