Alyce Jul 6, 2011
=QCard DLL Lesson Two= //Changing the Carl Back Design// [[user:Alyce]] See [[QCard01|Lesson 1]] for QCard DLL and WAV files needed for code. [[toc|flat]] ---- =Changing the Card Back Design= Six designs are available for the card backs: [[image:cardback.gif]] The default design is number one, which is the spheres. You can change the design easily with **SetCurrentBack**. The argument to pass is simply the number of the design you want, 1 - 6. There is no return, so the return type is void. All cards dealt after this call is made display the selected card design. You can change the design as the program runs, and all six designs can be displayed at the same time, if desired. [[code format="lb"]] 'nV can be 1,2,3,4,5,6 for 6 possible designs calldll #qc, "SetCurrentBack",_ 'function name nV as long,_ 'number of design desired r as void 'no return [[code]] =DEMO= [[code format="lb"]] 'cards2.bas, shows how to change card back design. 'Cards are dealt in lines across the screen. [varSetup] i=0 'i will be our counter var in for/next loops design=1 'default design is circles nomainwin WindowWidth=640:WindowHeight=480 UpperLeftX=1:UpperLeftY=1 menu #1, "&File", "E&xit", [quit] menu #1, "&Card Back Design","&Circles",[circles],"&Blue",[blue],_ "&Red",[red],"&Mountain",[mountain],"&Purple",[purple],"M&usic",[music] graphicbox #1.g, 0, 0, 640, 440 open "Card Game" 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] 'draw a nice background #1.g "down; fill 10 190 225" playwave "shuffle.wav",sync Call SetCurrentBack design 'design can be 1,2,3,4,5,6 for 6 possible designs 'The DLL allows for two decks. 'The first deck includes cards 1 - 52. 'By default, cards are face up. 'Deal first deck face up, across the screen, 'incrementing x position for each card. for i = 1 to 52 'window handle, card index number, x, y Call DealCard hBox,i,i*12,10 playwave "card.wav",sync 'pause 100 milliseconds between cards call Pause 100 scan next playwave "shuffle.wav",sync 'Cards 53 to 104 are in the second deck. 'Deal second deck face down, lower on screen than first deck. 'Set status of all cards to 0, which is face down. for i = 53 to 104 call SetCardStatus i, 0 Call DealCard hBox,i,(i-52)*6,67+i playwave "card.wav",sync 'pause 100 milliseconds between cards call Pause 100 scan next wait [quit] close #qc:close #1:end [circles] design=1:goto [new] [blue] design=2:goto [new] [red] design=3:goto [new] [mountain] design=4:goto [new] [purple] design=5:goto [new] [music] design=6:goto [new] '''''''''''''''''''' 'subs and functions: Sub Pause ms 'pause ms number of milliseconds calldll #kernel32,"Sleep",_ ms as long, re as void End Sub Sub InitializeDeck hndle calldll #qc, "InitializeDeck",_ hndle as long,r as long End Sub Sub SetCardStatus nC,face 'nC is number of card - 1-52 in first deck and '53-104 in second deck, if used 'face: 0=facedown,1=faceup calldll #qc, "SetCardStatus",nC as long,_ face as long,r as void 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 long,nC as long,_ x as long,y as long,r as void End Sub Sub SetCurrentBack nV 'nV can be 1,2,3,4,5,6 for 6 possible designs calldll #qc, "SetCurrentBack",nV as long,r as void End Sub [[code]] ---- [[toc|flat]] ---- [[QCard01|Lesson 1]] [[QCard03|Lesson 3]]