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.

Newcomers DBPro Corner / Match Cards game, need help assigning card types to objects

Author
Message
Gyrich
21
Years of Service
User Offline
Joined: 21st Aug 2003
Location: Here, obviously.
Posted: 4th Jan 2006 09:46
'ello, I've created functions that animate the deck being assembled and that deal out the cards. I need a function that will assign each of my 52 card objects an identity of one of the 14 card types: 2,3,4...10,jack,queen,king,ace,joker. I've tried to make a function (its' the long one called CardAssign() at the bottom), it generates a random number from a range of 14 numbers (0 thru 13) and assigns the card whatever identity the case gives it. I've added counters to each case so that i can stop the function from making more than 4 types of each card but i don't know how to stop it from doing so. Any ideas? Here's my code:



Was wondering, would it be better to do it the way im doing it or set the identities of the cards first, then find a way to randomly deal them out? thx for your help

DBPro User
PC: WinXP, AthlonXP 2100+ 1.7ghz, 80gb HD, Nvidia GeForce FX 5200 (128mb onboard RAM), 512mn DDR400 system RAM. Thank you for your help.
crighton
18
Years of Service
User Offline
Joined: 5th Nov 2005
Location: In your soup.
Posted: 4th Jan 2006 12:58
i may be way off track here, but wouldnt it be easier to use arrays?



thats just off the top of my head, with out to much thought process( usually normality for me )
but u could also use

3=avaliable and facing up

just my take on it.


aye!
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 4th Jan 2006 19:15 Edited at: 4th Jan 2006 19:16
Set up an array with 52 cards. To make this example, I'm just going to number them 1 to 52, and assume you can make a routine to assign values and suits to them.

dim MyCards(52)

Now you can shuffle them by swapping two array elements at a time, many times over...



Now, you can deal the array in order, knowing that they are shuffled.

Gyrich
21
Years of Service
User Offline
Joined: 21st Aug 2003
Location: Here, obviously.
Posted: 4th Jan 2006 21:36
sweeet thx guys i'll try ur suggestions out.

DBPro User
PC: WinXP, AthlonXP 2100+ 1.7ghz, 80gb HD, Nvidia GeForce FX 5200 (128mb onboard RAM), 512mn DDR400 system RAM. Thank you for your help.
Gyrich
21
Years of Service
User Offline
Joined: 21st Aug 2003
Location: Here, obviously.
Posted: 5th Jan 2006 09:56 Edited at: 5th Jan 2006 10:02
@crighton:

I found a way to make it work the way I had it, so i kept it that way, but thanx a ton for your advice

@BatVink:

Man ur shuffling code is awesome, works perfectly just switching in the proper name for my card array. Thank you

Hopefully after I implement a few more functions(mouseclick detection, animated card flipping, is card flipped detection, match detection, a few others), i'll have something to post in the Showcase

DBPro User
PC: WinXP, AthlonXP 2100+ 1.7ghz, 80gb HD, Nvidia GeForce FX 5200 (128mb onboard RAM), 512mn DDR400 system RAM. Thank you for your help.
crighton
18
Years of Service
User Offline
Joined: 5th Nov 2005
Location: In your soup.
Posted: 5th Jan 2006 12:02
np



aye!
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 5th Jan 2006 12:53
glad to be of assistance

I once wasted several hours of my life working on routines for shuffling cards, generating lottery numbers, calculating probabilities and permutations, and general problem solving logic. Then I lost it in a hard drive crash It was in the days of 486 PCs, some problems that would take seconds now took minutes and sometimes hours.

Login to post a reply

Server time is: 2024-09-24 13:30:42
Your offset time is: 2024-09-24 13:30:42