Solved

Card Games

Posted on 2000-03-27
4
320 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 50 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Not exactly what I had in mind, but interesting.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library 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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

772 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now