Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / need help on card game

Author
Message
t10dimensional
16
Years of Service
User Offline
Joined: 22nd Mar 2009
Location: Code Cave, USA
Posted: 26th Mar 2009 00:06
can someone give me code to a reall simple card game or a sample of one. im trying to make a matching game with all 52 cards.plz help.

im new at this
That1Smart Guy
16
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 26th Mar 2009 00:30
wait, ur trying to make a simple cards game so u ask for the code on the site, makes no sense to me but w/e
Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 26th Mar 2009 04:44
matching games shouldn't be hard.


heres the basics

at the beginning have a array of the Positions and set then randomly equal to the 1 of the 52 cards then when the players selects one card save it in another array (Mayber SelectedCards(1) ) then when it selects another one test it against the first one and see if its the same

New Site! Check it out \/
BN2 Productions
21
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 26th Mar 2009 07:26
I think the trick would be to ensure that no card is repeated.

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
MidKnight
16
Years of Service
User Offline
Joined: 26th Mar 2009
Location:
Posted: 26th Mar 2009 12:48
Can you give alittle more details razerx about your card game. Like how many players, how many cards will be used. That might help. A simple game like 21 might be alittle to simple.

A few years ago I was doing a game called Tiến LĂȘn aka killa, but I never completed it.
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 26th Mar 2009 18:07
Firstly you'll need a deck of cards.
A deck of 52 playing cards is split into four suits of 13 cards (Ace to King); this seems a complicated structure but we can think of the entire deck as numbered cards from 0 to 51 and write a formula to take care of the suits and card values.
Our first formula will work out the face value of any card in the deck...
Quote: "
n = card number
card value = n - int(n/13)*13
"

This formula cuts out the excess, from having multiple suits stacked on top of each other, and leaves us with the bare bones value of the card.

The next formula is to find which suit the card lies in...
Quote: "
n = card number
card suit = int(n/13)
"

This formula is similar to the first, but we don't inflate the suit value and remove it from the deck because we only wanted the suit value anyway.

It would have been more helpful to give these formulas the other way round but I can't cut and paste on here so meh.

Now you have to work out how to avoid duplicating the cards.

The Universe has been erased by a mod because it was larger
than 240x80 pixels.
That1Smart Guy
16
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 26th Mar 2009 22:00
id just use an array of 52 and wenever a card is used, u set its value to 1, then have an if checking the flag state of the random card
BN2 Productions
21
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 26th Mar 2009 23:49
Another way to check if a card is duplicated is to add the card number to a string, that would read:

"1,52,3,13,38,20,48...." and so on. This would be randomly generated for the shuffle. The beauty is that you can use the LEFT$() RIGHT$() and VAL() commands to determine what it is and then you can just read through the string to figure out if the card is already in the deck, similar to a data statement.

Conversely, you could create a second array, but the idea here is to avoid that (if for no other reason than to avoid a second array).

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose

Login to post a reply

Server time is: 2025-05-16 16:41:27
Your offset time is: 2025-05-16 16:41:27