-
Card Game Control
I've been working on my own custom control that I would like to compare to Microsoft's Cards32.dll. I have created a class object for a single card and that portion works fine. However, when I try to create another control encapsulating 52 (a deck) cards, nothing seems to work well at all. The cards are movable individually as I wanted. The problem with the entire deck control is that to allow the cards to move anywhere in the form (which I intend to simulate a card table with green felt -- just for visualization purposes) I have to set the width and height of the deck control to match that of the form. Otherwise the cards are limited to movement within the deck control. I didn't think using the Dock style of 'Fill' would be much of a problem, because anytime the form resizes, the cards can still move anywhere in the form. But now the problem is that any other controls I place on the form (maybe a label for a score) are hidden behind the deck since it takes up the entire form's space. If I SendToBack the deck, then I can see the other controls, but when the cards move, they float UNDER the controls.
My closest solution is to just not use a DeckOfCards control, but I would really like to, since I believe that's what Microsoft does, and it would make things easier. I have searched all over the Internet looking for help on this and I can never find help in this. I am slowly learning VB.NET on my own. I'm having a harder time with the advanced stuff, though. I learned the basics within a heartbeat, but the API, BitBlt, DirectX, and all advanced techniques just seem so hard to me. Any help with this project or these advanced techniques would be appreciated. Thanks in advance.
-
Why not just draw the cards on the form? That way you can control where the cards go in relation to the other controls on the form.
-
Well I was wanting to isolate the cards into a re-usable control, that way I can carry them into multiple card games. All I would have to do with the form is adjust things for the rules of the game and not worry about coding the cards. My card controls work fine individually, but I'm having trouble creating a deck control with 52 cards (each assigned as a unique card of the deck) that has some card game methods (shuffle, etc). I know I can create 52 of my card controls on the form, and perform my deck methods in that form, but I would rather it was bundled into a control so I'm not repeating code. The book I have been using as a guide calls this refactoring.
One idea I've had, but not sure that it's plausible, is if maybe my deck would add the 52 card controls it creates into the form's control collection. Or in some way bind them to the form, rather than to a unique control. All I want is some way to have 52 of my cards pre-created on the form (by pre-created I mean, created with unique values). I plan on creating many card games with this one deck control, so it would be easier than just copying-pasting code, not to mention, more size-, memory-, and processor-efficient.
I've looked at many different ideas at various different websites and it seems plausible, but I'm not sure how Microsoft does it. You don't think they just created a card control and then coded all the shuffling, card defining, and everything within each card game's form, do you? Anyone have a way to break down the cards32.dll and send it to me in a coded manner (I'm not sure if you can de-compile those or not, I'm still in the learning phases).
Thanks again for all help and ideas.
-
-
Why don't you simply resize the control manually on the Resize event of the form? This way you can leave some space for the other controls (sorry if that's not what you want I didn't read the whole thread) :)