Results 1 to 6 of 6

Thread: i need ideas in...

  1. #1

    Thread Starter
    Member ariel_au's Avatar
    Join Date
    Mar 2001
    Posts
    48
    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)
    :
    :
    :

  2. #2
    pjvdg
    Guest
    Can't you just let it remember what picture you loaded in that imagebox???

  3. #3
    Fanatic Member PsychoMark's Avatar
    Join Date
    Feb 2001
    Location
    Netherlands
    Posts
    540
    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)

  4. #4
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    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)

  5. #5
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    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)

  6. #6
    Fanatic Member PsychoMark's Avatar
    Join Date
    Feb 2001
    Location
    Netherlands
    Posts
    540
    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
  •  



Click Here to Expand Forum to Full Width