Results 1 to 11 of 11

Thread: [RESOLVED] Writing a card game

  1. #1

    Thread Starter
    Fanatic Member AccessShell's Avatar
    Join Date
    Oct 2013
    Posts
    790

    Resolved [RESOLVED] Writing a card game

    I am running VB6 on WIN10.
    I have already figured out how to shuffle the deck.

    I do not know how to place the cards on the form. I think the hard way is to have a jpg of all the cards (52) and load the pictures. Then with then mouse move the pics to another place when necessary.
    I think there is an easier way. It may be cards.dll, which I cannot find. Also I don't know to install it or use it.

    Any suggestions would be appreciated.

    Thanks

  2. #2
    PowerPoster
    Join Date
    Nov 2017
    Posts
    3,116

    Re: Writing a card game

    Can't help you out if you are looking for full dealing and playing animation (IE you play a card and the card smoothly moves from your "hand" onto the "board", or when the cards are dealt, you see the "top" of each card smoothly making its way from the dealer's deck to the player's hand).

    But I've written numerous card games in VB 6.0 and Borland C++ Builder and in each case I simply used arrays of PictureBoxes that were used to display the card images, and the act of clicking on a card in hand would be interpreted as playing the card, and then the image of the card would simply be moved from the "hand" picturebox to the appropriate "board" picturebox (provided the card was legally able to be played, etc.)

    This does require having an image for each card in a deck, but in the case of Borland C++ Builder, I built a custom deck of cards component (equivalent to an OCX in VB 6.0) where the parent type was an ImageList, so I was able to store all of the card images into the component, and also all of the logic of shuffling, dealing cards, card ranks, suit information, multiple decks, multiple jokers per deck, etc. Drop that onto a form and I've got everything I need to start writing a card game as far as the cards part goes.

    If you put some time into it, the same type of thing should be able to be built into an OCX in VB 6.0.

  3. #3
    Frenzied Member
    Join Date
    Dec 2008
    Location
    Melbourne Australia
    Posts
    1,487

    Re: Writing a card game

    You could search PSC, there should be lots of examples.
    PSC being dead, you would be using the clones our members have created.

  4. #4
    Frenzied Member
    Join Date
    May 2014
    Location
    Kallithea Attikis, Greece
    Posts
    1,289

    Re: Writing a card game

    Look this. You can use png files and here is a program to move it around form.
    https://www.vbforums.com/showthread....a-DrawIconEx()

  5. #5
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,145

    Re: Writing a card game

    Well, here is Cards.dll. How to use it is at this link: https://www.codeproject.com/Articles...sing-Cards-dll
    Attached Files Attached Files
    Sam I am (as well as Confused at times).

  6. #6

    Thread Starter
    Fanatic Member AccessShell's Avatar
    Join Date
    Oct 2013
    Posts
    790

    Re: Writing a card game

    I know this msg doesn't belong here, but I don't know where tto put it.
    I did not get a notification when members posted to my original question. How do I correct this problem?

    Thanks

  7. #7
    Frenzied Member
    Join Date
    May 2014
    Location
    Kallithea Attikis, Greece
    Posts
    1,289

    Re: Writing a card game

    VB6 use double buffer on forms (using the autoredraw). The name of the property is not exactly what it say. Autoredraw just place the double buffer. When a refresh produced we get the next buffer. So to draw a form, we have to place the cards, and when this done we give a refresh.
    Don't use picture boxes. VB6 is very fast to redraw a form, and handling the refresh is the way to do anything very fast (you draw in the buffer not shown). Don't use dovents in events. Never do a lot of process in an event. Use a timer to render the next frame Timers have a resolution of ms, so you need a redrav each 1000/50 (for 50 hz) or (1000/60) for 60 hz.
    You have to thing using specific variables for specific objects. These objects are the cards. Another set of variables are the "state" of the game. One of them unlock the players mouse to do something. You have to use flags to bypass or not the mouse down event. You have to check the player "grab" of a card.
    So you have to worry about on event, not many events from many pictureboxes.

  8. #8
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    6,582

    Re: Writing a card game

    Quote Originally Posted by AccessShell View Post
    I know this msg doesn't belong here, but I don't know where tto put it.
    I did not get a notification when members posted to my original question. How do I correct this problem?

    Thanks
    I think it should be the default. An email should be sent, I don't know if you have to enable allowing Admin to send e-mail for the notification e-mail to work or not.
    But, you can just click on the Settings menu selection at the upper right of the forum page, and then select "General Settings" under "My Settings" on the left, and make sure you have "Default Thread Subscription Mode:" set to "Instantly, using email", if that is what you want.
    "Anyone can do any amount of work, provided it isn't the work he is supposed to be doing at that moment" Robert Benchley, 1930

  9. #9

    Thread Starter
    Fanatic Member AccessShell's Avatar
    Join Date
    Oct 2013
    Posts
    790

    Re: Writing a card game

    For years I have been getting e-mail notifications. I did not change any settings. This is the first thread that no notifications were sent. The new thread also did not have any notifications.

  10. #10
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,145

    Re: Writing a card game

    Per your ORIGINAL post, here is an example (pretty simple---does not include the shuffling, which you say you can do) on how to move pictureboxes (card images) to a blank space.

    EDIT: it does NOT use cards.dll, but simply a directory (supplied--could have used resources but didn't so you can modify as needed) of 52 card images (clubs hearts, spades, diamonds), no jokers.

    oops, sorry ..will post an update shortly...noted that the Ace of Spades is missing...BUT, you can figure out the movement of the pbs from what i have already posted
    Attached Files Attached Files
    Last edited by SamOscarBrown; Dec 2nd, 2020 at 11:46 AM.
    Sam I am (as well as Confused at times).

  11. #11
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,145

    Re: Writing a card game

    Revised.....
    Attached Files Attached Files
    Sam I am (as well as Confused at times).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width