Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Card Games

Posted on 2000-03-27
4
Medium Priority
?
378 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
  • 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

927 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