QCard DLL Lesson 11

Lesson 10 Lesson 12

- Alyce Alyce
QCard DLL Lesson 11 | Drawing Symbol Cards | Disabled Cards | Card Backs | DEMO
See Lesson 1 for QCard DLL and WAV files needed for the demo code.

Drawing Symbol Cards


QCard gives us three symbol cards. We draw them with DrawSymbol. We need the handle of our graphicbox, the index number of the symbol and the x and y location to draw the card. The index to draw an X is 1, the O is 2 and a place holder card is 3.

    calldll #qc, "DrawSymbol",_
        hndle as ulong,_    'handle of graphicbox
        nV as long,_        '1=X 2=O 3=place holder
        nx as long,_        'x location
        ny as long,_        'y location
        re as void          'no return

Disabled Cards


We can set a card's disabled value. We won't allow our users to interact with a disabled card. We do that with SetCardDisabled. We pass the index of the card and the disabled value. 1 is a disabled card and 0 means it is not disabled.

    calldll #qc, "SetCardDisabled",_
        nC as long,_    'card to set
        nV as long,_    '1=disable,0=not disabled
        re as void      'no return

We can later discover if a card is disabled by calling IsCardDisabled. We pass the index of the card to query and a return of 1 tells us the card is disabled. A return of 0 means it is not disabled.

    calldll #qc, "IsCardDisabled",_
        nC as long,_    'card to query
        IsCardDisabled as long '1=disabled

Card Backs


We can also draw a card back image. This is not the same as displaying one of the 104 cards face-down.

    'nV can be 1,2,3,4,5,6 for 6 possible designs
    'draws a cardback image on screen
    calldll #qc, "DrawBack",_
        hndle as ulong,_   'handle of graphicbox
        nV as long,_       'index of card back, 1-6
        x as long,_        'x location
        y as long,_        'y location
        r as void


DEMO

See Lesson 1 for QCard DLL and WAV files needed for the demo code.

The code for all of the QCard functions for this lesson is demonstrated in the program below.

cards11.gif

'An open project card game, begun by Alyce Watson, May 27, 2003.
'Uses Qcard32.dll, a freeware library of playing card images.
'DLL by Stephen Murphy.  Qcard32.DLL website:
'http://www.telusplanet.net/public/stevem/
 
nomainwin
    WindowWidth=640:WindowHeight=480
    UpperLeftX=1:UpperLeftY=1
 
    menu #1, "&File", "E&xit", [quit]
    graphicbox #1.g, 0, 0, 640, 440
    open "Demo" for window_nf as #1
    #1 "trapclose [quit]"
 
    'get graphicbox handle
    hBox=hwnd(#1.g)
 
    'open the dll
    open "qcard32.dll" for dll as #qc
    'initialize the deck
    Call InitializeDeck hBox
 
[new]
    Call SetDefaultValues
 
    'draw a nice background
    #1.g "down; fill 10 190 225"
    #1.g "backcolor 10 190 225"
 
    call DrawBack hBox, 6, 10, 10  'draw card back design 6 at 10,10
    call DrawSymbol hBox,1,100,10  'draw X at 100,10
    call DrawSymbol hBox,2,190,10  'draw O at 190,10
    call DrawSymbol hBox,3,280,10  'draw placeholder at 280,10
 
    call DealCard hBox,33,10,200   'draw card at 10,200
    call DealCard hBox,43,100,200  'draw card at 100,200
 
    call SetCardDisabled 43,1      'set card 43 to disabled status
    card1=IsCardDisabled(33)
    card2=IsCardDisabled(43)
    #1.g "place 20 400"
    #1.g "\Card 1 disabled value is ";card1;"  Card 2 disabled value is ";card2
wait
 
[quit] close #qc:close #1:end
 
 
''''''''''''''''''''
'subs and functions:
 
Sub InitializeDeck hndle
    calldll #qc, "InitializeDeck",_
    hndle as ulong,r as long
    End Sub
 
Sub DealCard hndle,nC,x,y
    'places card on window whose handle is hndle at x,y
    'nC is number of card - 1-52 in first deck and
    '53-104 in second deck, if used
    calldll #qc, "DealCard",hndle as ulong,nC as long,_
    x as long,y as long,r as void
    End Sub
 
Sub DrawBack hndle, nV, x, y
    'nV can be 1,2,3,4,5,6 for 6 possible designs
    'draws a cardback image on screen
    calldll #qc, "DrawBack",hndle as ulong,_
    nV as long,x as long,y as long,r as void
    End Sub
 
Sub DrawSymbol hndle,nV,nx,ny
    calldll #qc, "DrawSymbol",_
        hndle as ulong,_    'handle of graphicbox
        nV as long,_        '1=X 2=O 3=place holder
        nx as long,_        'x location
        ny as long,_        'y location
        re as void          'no return
end sub
 
function IsCardDisabled(nC)
    calldll #qc, "IsCardDisabled",_
        nC as long,_    'card to query
        IsCardDisabled as long '1=disabled
    end function
 
sub SetCardDisabled nC, nV
    calldll #qc, "SetCardDisabled",_
        nC as long,_    'card to set
        nV as long,_    '1=disable,0=not disabled
        re as void      'no return
    end sub
 
Sub SetDefaultValues
    'reset all card properties back to their default values.
    calldll #qc, "SetDefaultValues",r as void
    End Sub
 

QCard DLL Lesson 11 | Drawing Symbol Cards | Disabled Cards | Card Backs | DEMO
Lesson 10 Lesson 12