Windows Solitaire Clone - I need some help
Hey guys, this is my first post here :wave:
Anyways as the thread title indicates, I'm attempting to do a clone of the windows Solitaire game. I'm also new to VB, so its not the easiest thing in the world to code, for me. I'm using VB 2005 Express Edition. Basically so far I've got most of the interface part done (menubar, statusbar, options, deck, help), but now I'm trying to get the cards to work now.
I've split things into two projects, one for the interface, and the other for the class library. I've got several classes that each have properties and such, but one part I'm having trouble with is the Card class. I have a sub called Draw in it, which I want to draw an image of the card to the screen based on its properties. The images of all the cards are contained in the interface project. So the sub needs to get the image from that project and then display it on the screen. But, I can't figure out how to do that...I need help, any ideas?
If you need more info, here's my project at this very moment:
The link for the project (.rar archive)
Thanks in advance.
Re: Windows Solitaire Clone - I need some help
I haven't looked at your project (need to be logged in on that forum to download it), but this is how I did it:
I've got a Deck class that contains an array of 52 Cards.
The card class contains a Value attribute.
Values go from:
102 -> 114 for Clubs
202 -> 214 for Diamonds
302 -> 314 for Spades
402 -> 414 for Hearts
When I want to show a card I retrieve its value attribute and load a picture from a resource file I made, using the value as parameter (the name of the picture).
Re: Windows Solitaire Clone - I need some help
ya, sorry about the link. I didn't realize that you have to be logged in to their forums. Anyways most of what you said is basically what I'm doing. I should have stated my question a little better though, so I'll try again.
I have the program split into two projects: one a Windows Form application, one a Class Library. The windows form contains the resource files(images, etc.), and contains a reference to the class library. So, since I can't have the class library reference the windows form too, how do I draw something from within the class library. I can't access the windows form from the class library, the windows form can only access the class library(it's a one-way street type thing).
Well maybe thats not so clear either...but I think you can get the idea...BAISCALLY, how do I draw from a class library without a reference to a windows form???
Re: Windows Solitaire Clone - I need some help
Why do you want it to be drawn in the Class Library?
I think you can create your image object in your class library and return that to your form, where you draw the image object.
Re: Windows Solitaire Clone - I need some help
I'm trying to follow this:
http://www.vbforums.com/showthread.php?t=375594
It says that the card class should be able to draw itself, so that would mean from the class library right?
Re: Windows Solitaire Clone - I need some help
You can't let the class library do everything, since they should be reusable. You can't for example let them determine in what picturebox you want to draw your image in.
However, maybe you can pass a picturebox (or whatever you want to draw your picture on) as a parameter to the Card Class, then the class does know where to draw it.