Results 1 to 7 of 7

Thread: Card games

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2000
    Posts
    82

    Smile

    Hi

    Just for fun, I've written a sample program which includes functions in a module for drawing any card back or front, shuffling, dragging and dropping and basically anything else I thought people might need to make a card game. I've heard Cards32.dll can draw the cards, but all the other bits you might need you have to do yourself. This should make it simpler.

    If anybody wants the sample, send me an email, and I'll send it back to them
    Andrew Empson
    vb6(ent) SP4

  2. #2

    Thread Starter
    Lively Member
    Join Date
    Jun 2000
    Posts
    82

    Anybody else interested?

    If anyone else is interested, please let me know.
    Andrew Empson
    vb6(ent) SP4

  3. #3
    Addicted Member RCharlton's Avatar
    Join Date
    Mar 2000
    Location
    London, UK
    Posts
    202

    Question I am making various card games,

    but I have tried to make the card drag along with the mouse by

    Code:
    Public tempX As Single
    Public tempY As Single
    
    Private Sub Form_DragOver(Source As Control, X As Single, Y As Single, State As Integer)
    Source.Move X - tempX, Y - tempY
    End Sub
    
    Private Sub Card_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
    Dim lRetVal As Long
    lRetVal = ShowCursor(False)
    tempX = X
    tempY = Y
    End Sub
    
    Private Sub Card_DragDrop(Index As Integer, Source As Control, X As Single, Y As Single)
    Source.Left = Source.Left + X - tempX
    Source.Top = Source.Top + Y - tempY
    End Sub
    and

    Code:
    Card.DragIcon = imglist.Listimages(4).ExtractIcon
    The first works very slowly, but the drag icon is whatever a standard icon size is.

    Could you please help.

    Richard CHarlton

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jun 2000
    Posts
    82

    Cards

    Are you using my sample?
    Here is how I drag cards using my module:

    Code:
    Private Sub Form_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
        'Prepare for Dragging
        If Button = 1 Then
            Oldx = x
            Oldy = y
            toDrag = GetCard(x, y)
            Dragged = False
            BeginDrag Me, toDrag
        End If
    End Sub
    
    Private Sub Form_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
        'Drag in progress
        Dim xx As Single
        Dim yy As Single
        If Button = 1 Then
            If toDrag > -1 Then
                xx = Pack(toDrag).xPos
                yy = Pack(toDrag).yPos
                xx = xx + (x - Oldx)
                yy = yy + (y - Oldy)
                Drag Me, xx, yy
                Dragged = True
                Oldx = x
                Oldy = y
            End If
        End If
    End Sub
    
    Private Sub Form_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
        'Flip the clicked card, or Drag complete
        If Dragged = True Then
            ToTop toDrag
            ReleaseDrag
            Me.Cls
            DrawPack Me
        Else
            Card = GetCard(x, y)
            If Card > -1 Then
                Pack(Card).Face = Not Pack(Card).Face
                DrawPack Me
            End If
        End If
        toDrag = -1
        Dragged = False
    End Sub
    There are some form-level variables I haven't mentioned in this scrap. Try painting the cards directly onto the form or a picture box and using MouseMove events on the object rather than drag methods to move the cards.
    Andrew Empson
    vb6(ent) SP4

  5. #5
    Addicted Member RCharlton's Avatar
    Join Date
    Mar 2000
    Location
    London, UK
    Posts
    202

    Arrow I was using another piece of code with dragging.

    With your code, how can you tell when the card being dragged is over another card? Also could you please send me the modules which you have referred to.

    Thank you very very much


    Richard Charlton

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Jun 2000
    Posts
    82
    Hi Richard.

    My routine includes a GetCard function, which you supply the X and Y positions, and it returns the card at that position. Send me your email address, and I'll forward it to you.

    [email protected]
    Andrew Empson
    vb6(ent) SP4

  7. #7
    Addicted Member RCharlton's Avatar
    Join Date
    Mar 2000
    Location
    London, UK
    Posts
    202

    Arrow Slowness

    In my first reply on this post, I said that my original code worked but was very slow. Perhaps this could be to do with my using a picture box - maybe an image would refresh faster.

    Anyone like to (dis)agree with me? (please)


    Thank you

    Richard Charlton

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