Computer Science Canada Playing Cards Arrays |
Author: | Naveg [ Sun Mar 20, 2005 8:34 pm ] |
Post subject: | Playing Cards Arrays |
For making a playing card game, would it be best to have an array 1..52 of cards, or a two dimensional array 1..4,1..14 of cards?? perhaps i could make a type called card with values suit and number, and then make an array of type card?? which way is best? |
Author: | Bacchus [ Sun Mar 20, 2005 8:38 pm ] |
Post subject: | |
i think a 2d array would be best and if you wanted to, you could make variables so you dont have to remmeber the corisponding number |
Author: | Naveg [ Sun Mar 20, 2005 8:43 pm ] |
Post subject: | |
Bacchus wrote: i think a 2d array would be best and if you wanted to, you could make variables so you dont have to remmeber the corisponding number
what exactly do you mean? i'll be using BMP images for all the cards. They're numbered like d5, c14 etc...(diamond 5, club king) |
Author: | Bacchus [ Sun Mar 20, 2005 8:51 pm ] | ||
Post subject: | |||
well 1st off, kings arnt 14, they're 13 ![]() ![]()
cards(club,13) since club =4 it would be: cards(4,13) thats it just to avoid some confusion, preference really and if you can remember which suit is which num lol |
Author: | Naveg [ Sun Mar 20, 2005 9:21 pm ] | ||
Post subject: | |||
ok i got that down, and i assigned the pictures to the array. but now, when i use Pic.Draw to show a card, it cuts off like the top quarter of the image. The image is fine on its own. an example:
|
Author: | Mr. T [ Sun Mar 20, 2005 10:37 pm ] |
Post subject: | |
hmm... |
Author: | Cervantes [ Sun Mar 20, 2005 10:41 pm ] |
Post subject: | |
cut the spam, Pwned. -10 bits |
Author: | jamonathin [ Wed Mar 23, 2005 7:03 am ] |
Post subject: | |
that's a really good idea, gj bacchus, ima use that for my game ![]() |
Author: | zylum [ Wed Mar 23, 2005 4:08 pm ] | ||
Post subject: | |||
a better idea is to make a record... i mean, how would you go about shuffling a deck in a 2d array? i mean you could but its much harder. records are much easier to read and easier to program with. here's what the code looks like (i've also included an initialize procedure and shuffle procedure)
|
Author: | GlobeTrotter [ Wed Mar 30, 2005 10:35 pm ] | ||
Post subject: | |||
zylum wrote:
That doesn't make sense. First of all, what is the point in the temp vars, second of all, it gives you repeats. |
Author: | StarGateSG-1 [ Thu Mar 31, 2005 8:35 am ] |
Post subject: | |
First off, you need temp variables to store the data when you pass it out of the procedure, otherwise it will get messy if you have to use the real variable as a temp and real value. Secondly, Of course it gives you doubles that is a shuffler not a dealer. |
Author: | Martin [ Thu Mar 31, 2005 9:02 am ] | ||||
Post subject: | |||||
Bacchus wrote: well 1st off, kings arnt 14, they're 13
![]() ![]()
cards(club,13) since club =4 it would be: cards(4,13) thats it just to avoid some confusion, preference really and if you can remember which suit is which num lol I'm assuming that the value of spade will never change, so make it a constant. Also, use caps to indicated that it's a constant.
|
Author: | zylum [ Thu Mar 31, 2005 9:24 am ] |
Post subject: | |
my bad, code fixed.. forgot to reassign the the temp vars to the actual arrays. |
Author: | GlobeTrotter [ Thu Mar 31, 2005 9:49 pm ] |
Post subject: | |
StarGateSG-1 wrote: First off, you need temp variables to store the data when you pass it out of the procedure, otherwise it will get messy if you have to use the real variable as a temp and real value. Secondly, Of course it gives you doubles that is a shuffler not a dealer.
Call me crazy, but that makes absolutely no sense to me at all. First of all, I didn't mention real variables at all. Second of all, a shuffler should not repeat, under any circumstances. |
Author: | zylum [ Fri Apr 01, 2005 1:36 am ] |
Post subject: | |
ok guys calm down. problem fixed, no repeats in the shuffler, it was a small error. lets get on with our lives |