-
CARD GAMES
[Originally posted by mann]
anyone who can provide me logarithm or the idea in creating card game application . . like blackjack, etc . . or majhong. ..
thanks!
-
Re:CARD GAMES
[Originally posted by Greg Givler]
I would go to the Home Page of freevbcode.com and search for Card Game. I got a page full of hits, including blackjack games, draw poker and more. It should inspire you to some sort of program.
Greg
-
Re:CARD GAMES
[Originally posted by JohnPap]
I have the following examples stored in my VB archives but I have never used any of them. However, I am posting it here, so that you can get an idea of how things should be done.
I am clearly stating that I have found these examples on the internet. I am afraid that I can't remember where from, so I am really sorry for being unable to give credit to the original authors.
Kind Regards,
John
-----> FROM MY ARCHIVES. EXAMPLE #1.
Declarations and utilities for using Cards.Dll
CARDS.DLL is standard with Microsoft Windows.
It is used by Solitaire (SOL.EXE), Hearts, etc...
as a standard card drawing library.
FORM1.FRM
'general (form level) declarations
Dim nWidth As Integer, nHeight As Integer
Sub Form_Load ()
x% = CdtInit(nWidth, nHeight)
End Sub
Sub Form_Unload (Cancel As Integer)
ret% = CdtTerm()
End Sub
'a command button placed on form1
Sub Cards_Click ()
'clubs
Xleft% = 0
For i = 0 To 51 Step 4
ret% = CdtDraw(hdc, Xleft%, 0, i, C_FACES, &HFFFF&)
Xleft% = Xleft% + nWidth / 4
Next
'diamonds
Xleft% = 0
For i = 1 To 51 Step 4
ret% = CdtDraw(hdc, Xleft%, nHeight, i, C_FACES, &HFFFF&)
Xleft% = Xleft% + nWidth / 4
Next
'hearts
Xleft% = 0
For i = 2 To 51 Step 4
ret% = CdtDraw(hdc, Xleft%, nHeight * 2, i, C_FACES, &HFFFF&)
Xleft% = Xleft% + nWidth / 4
Next
'spades
Xleft% = 0
For i = 3 To 51 Step 4
ret% = CdtDraw(hdc, Xleft%, nHeight * 3, i, C_FACES, &HFFFF&)
Xleft% = Xleft% + nWidth / 4
Next
'draw card backs
For i = 53 To 68
xx% = (i - 53) * nWidth / 3.74
ret% = CdtDraw(hdc, 4.1 * nWidth, xx%, i, C_BACKS, &HFFFF&)
Next
End Sub
MODULE1.BAS (global module)
'Delarations and utilities for using CARDS.DLL
'Actions for CdtDraw/Ext
' use in the nDraw field
Global Const C_FACES = 0
Global Const C_BACKS = 1
Global Const C_INVERT = 2
'Card Numbers
' use in the nCard field
'from 0 to 51 [Ace (club,diamond,heart,spade), Deuce, ... , King]
'Card Backs
' use in the nCard field
' CAUTION: when nCard > 53 then nDraw must be = 1 (C_BACKS)
Global Const crosshatch = 53
Global Const weave1 = 54
Global Const weave2 = 55
Global Const robot = 56
Global Const flowers = 57
Global Const vine1 = 58
Global Const vine2 = 59
Global Const fish1 = 60
Global Const fish2 = 61
Global Const shells = 62
Global Const castle = 63
Global Const island = 64
Global Const cardhand = 65
Global Const UNUSED = 66
Global Const THE_X = 67
Global Const THE_O = 68
'Initialization
' call before anything else. Returns the default
' width and height for the cards, in pixels.
Declare Function CdtInit _
Lib "CARDS.DLL" _
(nWidth As Integer, _
nHeight As Integer) As Integer
'CdtDraw used to draw a card with the default size
'at a specified location in a form, picture box or whatever.
'It can draw any of the 52 faces an 13 different Back designs,
'as well as pile markers such as the X and O. Cards can also
'be drawn in the negative image, eg to show selection.
'xOrg = x origin in pixels
'yOrg = y origin in pixels
'nCard = one of the Card Back constants or a card number 0 to 51
'nDraw = one of the Action constants
'nColor = The highlight color
Declare Function CdtDraw _
Lib "CARDS.DLL" _
(ByVal hDC As Integer, _
ByVal xOrg As Integer, _
ByVal yOrg As Integer, _
ByVal nCard As Integer, _
ByVal nDraw As Integer, _
ByVal nColor&) As Integer
'CdtDrawExt used to draw a card in any size
'Much the same as CdtDraw, but you can specify the height & width
'of the card, as well as location.
'nWidth = Width of card in pixels
'nHeight = Height of card in pixels.
Declare Function CdtDrawExt _
Lib "CARDS.DLL" _
(ByVal hDC As Integer, _
ByVal xOrg As Integer, _
ByVal yOrg As Integer, _
ByVal nWidth As Integer, _
ByVal nHeight As Integer, _
ByVal nCard As Integer, _
ByVal nDraw As Integer, _
ByVal nColor&) As Integer
'CdtTerm should be called when the program terminates.
' Primarily it releases memory back to Windows.
Declare Function CdtTerm _
Lib "CARDS.DLL" _
() As Integer
-----> FROM MY ARCHIVES. EXAMPLE #2.
Making card games in Vb is not always an easy task
but thanks to Microsofts Cards.dll library, creation
of a card game deck is simplified to just a few
API calls. Below you will find the proper API calls
needed to use the file cards.dll. This dll is usually
included in most MS card games and thus allows you,
the programmer, to not have to bother shipping it
with your application.
First before we start, create a new module and place
the following code in it:
'Delarations and utilities for using CARDS.DLL
'Actions for CdtDraw/Ext
' use in the nDraw field
Global Const C_FACES = 0
Global Const C_BACKS = 1
Global Const C_INVERT = 2
'Card Numbers
' use in the nCard field
'from 0 to 51 [Ace (club,diamond,heart,spade), Deuce, ... , King]
'Card Backs
' use in the nCard field
' CAUTION: when nCard > 53 then nDraw must be = 1 (C_BACKS)
Global Const crosshatch = 53
Global Const weave1 = 54
Global Const weave2 = 55
Global Const robot = 56
Global Const flowers = 57
Global Const vine1 = 58
Global Const vine2 = 59
Global Const fish1 = 60
Global Const fish2 = 61
Global Const shells = 62
Global Const castle = 63
Global Const island = 64
Global Const cardhand = 65
Global Const UNUSED = 66
Global Const THE_X = 67
Global Const THE_O = 68
'Initialization
' call before anything else. Returns the default
' width and height for the cards, in pixels.
Declare Function CdtInit _
Lib "CARDS.DLL" _
(nWidth As Integer, _
nHeight As Integer) As Integer
'CdtDraw used to draw a card with the default size
'at a specified location in a form, picture box or whatever.
'It can draw any of the 52 faces an 13 different Back designs,
'as well as pile markers such as the X and O. Cards can also
'be drawn in the negative image, eg to show selection.
'xOrg = x origin in pixels
'yOrg = y origin in pixels
'nCard = one of the Card Back constants or a card number 0 to 51
'nDraw = one of the Action constants 'nColor = The highlight color
Declare Function CdtDraw _
Lib "CARDS.DLL" _
(ByVal hDC As Integer, _
ByVal xOrg As Integer, _
ByVal yOrg As Integer, _
ByVal nCard As Integer, _
ByVal nDraw As Integer, _
ByVal nColor&) As Integer
'CdtDrawExt used to draw a card in any size
'Much the same as CdtDraw, but you can specify the height & width
'of the card, as well as location.
'nWidth = Width of card in pixels
'nHeight = Height of card in pixels.
Declare Function CdtDrawExt _
Lib "CARDS.DLL" _
(ByVal hDC As Integer, _
ByVal xOrg As Integer, _
ByVal yOrg As Integer, _
ByVal nWidth As Integer, _
ByVal nHeight As Integer, _
ByVal nCard As Integer, _
ByVal nDraw As Integer, _
ByVal nColor&) As Integer
'CdtTerm should be called when the program terminates.
' Primarily it releases memory back to Windows.
Declare Function CdtTerm _
Lib "CARDS.DLL" _
() As Integer
Well, that should be just about it. Remember to use it
in VB 16-bit not 32 because the dll is 16-bit.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|