Solved

Card Games

Posted on 2000-03-27
4
345 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 50 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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 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…

738 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