|
-
May 22nd, 2004, 07:26 PM
#1
Thread Starter
New Member
Blackjack
hello all i am new to this forum but a big hello goes to you all!. Currently i am making a blackjack game with vb 6.0. My skills are pretty limited but this is my question
Currently i have 52 card images.
have decided to break them into two sets
first set : card suit
second set : cards and values
the question is
How do i get the computer to ranbdomly select a card, and give its value, display the card and total the cards the program is set up i just need a hand with getting the algorithms in there
-
May 22nd, 2004, 07:32 PM
#2
Do you know anything about objects? Or UDT?
The best way would probably be to gather all the cards in an array of objects or UDT and then use a Rnd function to pick one of them.
-
May 22nd, 2004, 07:37 PM
#3
Thread Starter
New Member
not really ....like i said im pretty new,,,have dealt with arrays in the past though if possible could you excplain in detail
-
May 22nd, 2004, 07:45 PM
#4
I am on my way to bed right now. But I have time for a short explenation.
You can make an UDT like this:
VB Code:
Private Type CardType
color As Long '1 = spade, 2=heart and so on
number As Long '1-13??
End Type
THen you can make an array of them like this
Then you can say that :
VB Code:
Card(0).color = 1
Card(0).nuber = 1
If you do this in a double loop you can tell all of the "cards" in the array what number and color they are.
Then you can use a Rnd (do a search if you don't know what it is) and bick one of the 52 elements in the array.
Hope that at least helped a little bi.
Good night.
ØØ
-
May 27th, 2004, 03:18 PM
#5
Fanatic Member
You could put all the cards in an array and swap them around for so many times to shuffle the deck. Then just pick the top card from the deck (i.e the next position in your array.)
If you are randomly picking from an array, you have a chance of picking the same card twice.
"Can't" and "shouldn't" are two totally separate things.
All questions should be answered. All answers should be true. That is why I post.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|