Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Card Games

Posted on 2000-03-27
4
Medium Priority
?
368 Views
Last Modified: 2011-09-20
I'd like to find some example VB code for card games.

If anybody can give me link...

WillP
willmar@syix.com
0
Comment
Question by:WillP
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 3

Accepted Solution

by:
wpsjr1 earned 150 total points
ID: 2662598
Here is a class module I wrote to encapsulate the Cards32 API:

Option Explicit

' Cards32.dll Class module by Wpsjr1@syix.com

Public Enum Suit
  Clubs
  Diamonds
  Heart
  Spades
End Enum

Public Enum Surface
  Face
  Back
  Inverted
End Enum

Public Enum Face
  Ace = 0
  Two = 4
  Three = 8
  Four = 12
  Five = 16
  Six = 20
  Seven = 24
  Eight = 28
  Nine = 32
  Ten = 36
  Jack = 40
  Queen = 44
  King = 48
End Enum

Public Enum Back
  Crosshatch = 53
  Plaid = 54
  Weave = 55
  Robot = 56
  Roses = 57
  Black = 58
  Blue = 59
  FishCyan = 60
  FishBlue = 61
  Shell = 62
  Castle = 63
  beach = 64
  Cardhand = 65
  Unused = 66
  Ex = 67
  Oh = 68
End Enum

Private Declare Function cdtAnimate Lib "cards32.dll" (ByVal hdc As Long, ByVal lCardBack As Long, ByVal x As Long, ByVal y As Long, ByVal iState As Long) As Long
Private Declare Function cdtDraw Lib "cards32.dll" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal lCard As Long, ByVal iDraw As Long, ByVal color As Long) As Long
Private Declare Function cdtDrawExt Lib "cards32.dll" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal dx As Long, ByVal dy As Long, ByVal ordCard As Long, ByVal iDraw As Long, ByVal color As Long) As Long
Private Declare Function cdtInit Lib "cards32.dll" (dx As Long, dy As Long) As Long
Private Declare Function cdtTerm Lib "cards32.dll" () As Long

Event Error(errString As String)

Dim m_lWidth&
Dim m_lHeight&

Private Sub Class_Initialize()
  ' initialize the cards32.dll
  If cdtInit(m_lWidth, m_lHeight) <> 1 Then RaiseEvent Error("Could not initialize Cards32.dll")
End Sub

Private Sub Class_Terminate()
  cdtTerm ' free resources
End Sub

Public Property Get Height() As Long
  Height = m_lHeight
End Property

Public Property Get Width() As Long
  Width = m_lWidth
End Property

' show an animation on the card
Public Function Animate(ByVal hdc As Long, ByVal eBack As Back, ByVal x As Long, ByVal y As Long, ByVal lState As Long) As Long
  Animate = cdtAnimate(hdc, eBack, x, y, lState)
End Function

' draws cards to the dx/dy returned in cdtInit
Public Function Draw(ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal eSuit As Suit, ByVal eType As Surface, ByVal lColor As Long) As Long
  Draw = cdtDraw(hdc, x, y, eSuit, eType, lColor)
  If Draw = 0 Then RaiseEvent Error("Could not Draw card")
End Function

' draws cards to non-standard sizes
Public Function DrawEx(ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal dx As Long, ByVal dy As Long, ByVal eSuit As Suit, ByVal eType As Surface, ByVal lColor As Long) As Long
  DrawEx = cdtDrawExt(hdc, x, y, dx, dy, eSuit, eType, lColor)
  If DrawEx = 0 Then RaiseEvent Error("Could not DrawEx card")
End Function

' end module


To draw the Ace of Clubs with an animation on your form try the following code:

Dim i%

c.Draw hdc, 0, 0, 0, Surface.Face, BackColor
For i = 3 To 0 Step -1
  c.Animate hdc, beach, 0, 0, i
  Sleep 100
Next i
c.Draw hdc, 0, 0, 0, Surface.Face, BackColor

Good Luck!  :)

Paul

0
 
LVL 28

Expert Comment

by:AzraSound
ID: 2663153
Here are several examples of code to look at:
http://www.planet-source-code.com/vb/scripts/BrowseCategoryOrSearchResults.asp?lngWId=1

wpsjr, please leave your posts as comments
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 2663158
bad link: go here and type in "Card games" to search
http://www.planet-source-code.com/vb/scripts/search.asp?lngWId=1
0
 

Author Comment

by:WillP
ID: 2752551
Not exactly what I had in mind, but interesting.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

660 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question