Real Software Forums
http://forums.realsoftware.com/

Making a Card Game with Cards.dll
http://forums.realsoftware.com/viewtopic.php?f=4&t=964
Page 1 of 2

Author:  Aaron Ballman [ Mon Nov 14, 2005 11:42 pm ]
Post subject:  Making a Card Game with Cards.dll

Have you ever found yourself wondering how to make a card game, but don't want to go through all the hassles of making the graphics and putting all the logic into drawing cards? Then you're a lot like me! There are a lot of fun card games out there that I want to make (because I never seem to find them in commercial products -- like War and Pyramid Solitaire), but I'm a terrible artist. However, I've always found that it's better to avoid reinventing the wheel whenever possible -- and Microsoft has been kind enough to put all the legwork into card games for you!

I've concocted a tutorial on how to implement the graphics for a card game using Microsoft's Cards.dll file (installed already on every version of Windows that REALbasic supports). Additionally, I've created an example project that takes this knowledge and puts it to use by making the game "War." You can find the project on my website:

http://www.aaronballman.com/programming/REALbasic/Cards.php

Enjoy!

Author:  Jarab [ Wed Nov 16, 2005 7:53 pm ]
Post subject: 

So how does it work? Is it compiled into your project standalone or does the Cards.dll file need to be installed on the users computer already?

You can just scan a 2-10 card and just edit in new text and then scan the 18 cards for aces and royalty. The whole thing can be done with just two scans. I think I'll put my trust in those rather than in some Microsoft gobbledegook.

Author:  Aaron Ballman [ Thu Nov 17, 2005 5:45 pm ]
Post subject: 

The cards.dll file is already installed on every version of Windows that REALbasic compiles for. You're certainly welcome to scan in your own graphics and use those -- this is simply using the system facilities.

Author:  stratus [ Thu Nov 17, 2005 10:08 pm ]
Post subject: 

While a good idea for Windows users, it won't, as far as I know, cross-compile to Mac and Linux.

Quote:
and Microsoft has been kind enough

Haha. I love that! But you always do such quality work, Aaron. Nice job with that tutorial.

I'm writing a Poker game in Java in my spare time, just to get a feel for the language. I like the idea of scanning cards. And I was going to go try to draw them. Wow. You just saved me a ton of time. Thanks Jarab.

Author:  w2ed [ Fri Nov 18, 2005 1:01 am ]
Post subject: 

Yeah it could - you'd just have to supply some other means to get the same stuff the particular .DLL has.

Wayne C. Winquist

Author:  barrytraver [ Sat Nov 26, 2005 10:20 am ]
Post subject: 

Windows Users Only! Download REALbasic source code for a simple card trick program accessing the Windows file cards.dll. This program "piggy-backs" on the cards.rbp program by Aaron Ballman. His program is based on the card game "War," as he said, whereas my adaptation of his code is a simple card trick described in a chapter in Martin Gardner's book Magic, Mathematics, and Mystery.

It's a simple trick. Twenty-seven cards are dealt face-up into three columns. The spectator is asked to secretly select a card and then to indicate the column in which the card appears. The cards are picked up and re-dealt into three columns. The spectator is asked in which column his card appears now. The cards are dealt a third time with the same question, and then the computer reveals the selected card. Not a very spectacular trick, but the source code does show how one person's code might be adapted for a rather different purpose. Perhaps it may inspire you to write a much better program than mine. You may even learn something from this sample program (even if it's how NOT to code). Who knows? Try it out and see!

P.S. Here's where you can find the original project by Aaron Ballman:

http://www.aaronballman.com/programming/REALbasic/Cards.php

Here's basically where to go for my simple card trick program in RB:

http://traver.org/rb/cardtrick/

Here's the REALbasic source code for my simple card trick, if you want it:

http://traver.org/rb/cardtrick/cardtrick.rbp (77 KB)

Here's the card trick as a Windows executable program if you want to avoid having to compile it:

http://traver.org/rb/cardtrick/cardtrick.exe (2,491 KB)

And here's the card trick as a Windows executable program in zip format:

http://traver.org/rb/cardtrick/cardtrick.zip (825 KB)

Enjoy!

Barry Traver

Author:  benji [ Mon Nov 20, 2006 4:30 pm ]
Post subject: 

stratus wrote:
While a good idea for Windows users, it won't, as far as I know, cross-compile to Mac and Linux.


I'm writing a Poker game in Java in my spare time, just to get a feel for the language. I like the idea of scanning cards. And I was going to go try to draw them. Wow. You just saved me a ton of time. Thanks Jarab.



still sounds complicated! do you have to invest lots of time?

i for myself am very happy for being able to play poker via internet, hence otherwise very unskillfull with the pc :oops:
my favorite site at the moment is http://www.pokerstrategy.org.uk

dont know what i would do without :wink:

Author:  Cartwright [ Mon Jan 21, 2008 7:36 pm ]
Post subject: 

Bringing this back from the dead . . .

I've been working on a card game in RB, but it would play better with Jokers. Any idea how to add them in? Thanks.

Author:  Steve Garman [ Tue Jan 22, 2008 5:20 am ]
Post subject: 

No idea I'm afraid.

I don't know if cards.dll has gone missing from Vista but if I run this
if System.IsFunctionAvailable( "cdtInit", "Cards" ) then
MsgBox "cards available"
else
MsgBox "not available"
end if
I get "not available"

Author:  Cartwright [ Tue Jan 22, 2008 2:57 pm ]
Post subject: 

Interesting. I'm still using XP, so I haven't run into this issue. Is Aaron around and still reading this forums? If not, I may try to drop him a line and see if he has any ideas.

I have .png of the jokers, but I don't know how to work them into the deck.

Author:  npalardy [ Tue Jan 22, 2008 3:18 pm ]
Post subject: 

He does read from time to time

Does the GetDeck function return a deck that includes jokers at all ?


Oh ... and the DLL does not seem to exist on Vista

Author:  Cartwright [ Tue Jan 22, 2008 7:36 pm ]
Post subject: 

No, it just builds a deck by suit and number. It does not include the jokers. There are decks online that contain jokers, but I'm not quite sure how to implement them. I can always create a fake card that refers to the joker, but I don't know how to take the joker.png and have the card draw correctly without doing some nasty workaround hacks that would take forever.

Author:  Cartwright [ Wed Jan 23, 2008 5:34 pm ]
Post subject: 

I think I'm gonna go with Plan B: I'll download pngs of all the cards (including jokers) and just build my own classes for this. I may have to rewrite some of the code, but hopefully this shouldn't take too long.

Author:  astrodan [ Tue Feb 17, 2009 12:16 pm ]
Post subject:  Re: Making a Card Game with Cards.dll

Hello,

I hate to ask such a question, but newbies must be allowed to ask. Is a dll only able to be utilized with the operating system on which it was developed??

I was thinking dlls were machine code binaries, that as long as the software calling to the dll used the proper syntax, the code would function, provided the hardware could handle it. By that I mean, no call to the OS by the dll, only lower level BIOS type calls. I thought these things were supposed to be fast machine language subroutines??

Next question: If one owns a copy of XP. And if, the dll can be called and used separate of the operating system, is this legal to use on ones own machine?

Last question, and I don't want anyone in legal land to go nuts, but, I take it that dlls are fully copyrighted material and can not be disseminated?

Thanks for any opinions and thoughts.

Dan

Author:  timhare [ Tue Feb 17, 2009 1:22 pm ]
Post subject:  Re: Making a Card Game with Cards.dll

astrodan wrote:
Hello,

I hate to ask such a question, but newbies must be allowed to ask.

You bet!

Quote:
Is a dll only able to be utilized with the operating system on which it was developed??

That is correct. dll's are dependent on the OS. You can look at them as snippets of .EXE code that have been packaged separately and that you can interact with. But a Windows .exe will not run on a Mac or on Linux, so neither will a Windows .dll. Same goes for the other platforms. Library code is OS specific. Now, some dll's will run on multiple versions of Windows (98, NT, XP), but others will not. It depends on what features of the OS they use.

Quote:
I was thinking dlls were machine code binaries, that as long as the software calling to the dll used the proper syntax, the code would function, provided the hardware could handle it. By that I mean, no call to the OS by the dll, only lower level BIOS type calls. I thought these things were supposed to be fast machine language subroutines??

No, dll's call through to the OS, not the BIOS, in almost all cases. The OS is there to be the intermediary between user code and the hardware. dll's are more like user code in this regard.

Quote:
Next question: If one owns a copy of XP. And if, the dll can be called and used separate of the operating system, is this legal to use on ones own machine?

Last question, and I don't want anyone in legal land to go nuts, but, I take it that dlls are fully copyrighted material and can not be disseminated?

You should treat them like any .exe; the same rules apply. They are licensed by somebody, and that license dictates how they can be used.

Tim

Page 1 of 2 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/