Computer Science Canada Making a card game, need help on how to elimant a card |
Author: | kirkwood [ Sun Dec 17, 2006 3:08 pm ] |
Post subject: | Making a card game, need help on how to elimant a card |
well im makign a card game xD doign 52 cards, anyways i need to know how to elimant a card from them, say i get a 10 of hearts, i want to know how to elimant that from being picked again doign randint, but if thers a better way tell me exp: var card : int (card being picked) var h10 : int:=10 (this is the 10 of hearts) randint (card, 1, 52) if card = 10 then (some how get rid of this card beign picked again until the game has ended) help please if u know how, its for my final project and we werent shown how to do it, but we have to make a game |
Author: | Clayton [ Sun Dec 17, 2006 4:41 pm ] |
Post subject: | |
whenever you pick that card, either use a flexible array, and 'pop' that card out of the list of possible cards, or use a record to hold the card value and a boolean value. Whenever that card has been picked, set the boolean value to true, so that it can't be picked any more. |
Author: | Clayton [ Sun Dec 17, 2006 4:42 pm ] |
Post subject: | |
whenever you pick that card, either use a flexible array, and 'pop' that card out of the list of possible cards, or use a record to hold the card value and a boolean value. Whenever that card has been picked, set the boolean value to true, so that it can't be picked any more. All of these things can be found in the Turing Walkthrough |
Author: | kirkwood [ Sun Dec 17, 2006 5:46 pm ] |
Post subject: | |
im totaly confused! use a array? havent learned it a school, is there a way to do it with randint or somethign along those lines, wel didi a program that when the computer guesses to high, that number takes place of the highest number so it wont go pas that, is there a way to do that, but not get rid of the numbers above that? |
Author: | TokenHerbz [ Sun Dec 17, 2006 6:32 pm ] | ||
Post subject: | |||
eh... well since im bored, heres the sloppy way to do things...
|
Author: | TokenHerbz [ Sun Dec 17, 2006 6:35 pm ] |
Post subject: | |
/sigh at no EDIT button: You wrote: "help please if u know how, its for my final project and we werent shown how to do it, but we have to make a game" Well since you didn't learn arrays, and im assuming other things needed for most games, that you make the basic easy games. 1) PONG. Overal its easy to make, i suggest you add somthing unique to this to boost marks, several ideas would to have say, each level getting slightly harder, skill settings? Good Luck. |
Author: | kirkwood [ Sun Dec 17, 2006 9:47 pm ] |
Post subject: | |
THANKS ALOT! it helps alot, do u think i should use 1..52 though cuz im using cards i made on flash, to display them or is there a way that u have like 10 (number 10 card) and 1 (hearts) and it will put up that pic i made? thanks again ![]() i dont want to do a pong game, cuz its been made alot in class, plus i want a chanallage, a hard 1 if its ok, could i use part of that program for mine? |
Author: | kirkwood [ Sun Dec 17, 2006 11:20 pm ] |
Post subject: | |
......... i dont get it now ![]() i tried puttign parts in my game, and im just confused im havign thr problems at the discard parts heres my program u have to delete the Pic.Draw and stuff like that cuz i have the pics of the cards, i dont get whats wrong with it ps. just doing 10 cards rigth now ------------------------------------------- randint (discard1, 1, 10) if discard1 = (secondcard or firstcard) then loop randint (discard1, 1, 10) exit when discard1 not= (secondcard or firstcard) end loop end if this is the part im having trouble with ^ the stuff of my program i have done so far ------------------------------------------- var firstcard, secondcard : int var discard1, discard2, discard3 : int var dis1, dis2, dis3, dis4 : int var flop1, flop2, flop3, turn, river : int var cardback : int := Pic.FileNew ("cb.bmp") var hA : int := Pic.FileNew ("Ah.bmp") var h2 : int := Pic.FileNew ("2h.bmp") var h3 : int := Pic.FileNew ("3h.bmp") var h4 : int := Pic.FileNew ("4h.bmp") var h5 : int := Pic.FileNew ("5h.bmp") var h6 : int := Pic.FileNew ("6h.bmp") var h7 : int := Pic.FileNew ("7h.bmp") var h8 : int := Pic.FileNew ("8h.bmp") var h9 : int := Pic.FileNew ("9h.bmp") var h10 : int := Pic.FileNew ("10h.bmp") View.Set ("graphics") Draw.FillBox (0, 0, 1000, 1000, green) Pic.Draw (cardback, 0, 250, picMerge) randint (firstcard, 1, 10) if firstcard = 1 then Pic.Draw (hA, 0, 0, picMerge) elsif firstcard = 2 then Pic.Draw (h2, 0, 0, picMerge) elsif firstcard = 3 then Pic.Draw (h3, 0, 0, picMerge) elsif firstcard = 4 then Pic.Draw (h4, 0, 0, picMerge) elsif firstcard = 5 then Pic.Draw (h5, 0, 0, picMerge) elsif firstcard = 6 then Pic.Draw (h6, 0, 0, picMerge) elsif firstcard = 7 then Pic.Draw (h7, 0, 0, picMerge) elsif firstcard = 8 then Pic.Draw (h8, 0, 0, picMerge) elsif firstcard = 9 then Pic.Draw (h9, 0, 0, picMerge) elsif firstcard = 10 then Pic.Draw (h10, 0, 0, picMerge) end if randint (secondcard, 1, 10) if secondcard = firstcard then loop randint (secondcard, 1, 10) exit when secondcard not= firstcard end loop end if if secondcard = 1 then Pic.Draw (hA, 150, 0, picMerge) elsif secondcard = 2 then Pic.Draw (h2, 150, 0, picMerge) elsif secondcard = 3 then Pic.Draw (h3, 150, 0, picMerge) elsif secondcard = 4 then Pic.Draw (h4, 150, 0, picMerge) elsif secondcard = 5 then Pic.Draw (h5, 150, 0, picMerge) elsif secondcard = 6 then Pic.Draw (h6, 150, 0, picMerge) elsif secondcard = 7 then Pic.Draw (h7, 150, 0, picMerge) elsif secondcard = 8 then Pic.Draw (h8, 150, 0, picMerge) elsif secondcard = 9 then Pic.Draw (h9, 150, 0, picMerge) elsif secondcard = 10 then Pic.Draw (h10, 150, 0, picMerge) end if randint (discard1, 1, 10) if discard1 = (secondcard or firstcard) then loop randint (discard1, 1, 10) exit when discard1 not= (secondcard or firstcard) end loop end if if discard1 = 1 then Pic.Draw (cardback, 150, 250, picMerge) elsif discard1 = 2 then Pic.Draw (cardback, 150, 250, picMerge) elsif discard1 = 3 then Pic.Draw (cardback, 150, 250, picMerge) elsif discard1 = 4 then Pic.Draw (cardback, 150, 250, picMerge) elsif discard1 = 5 then Pic.Draw (cardback, 150, 250, picMerge) elsif discard1 = 6 then Pic.Draw (cardback, 150, 250, picMerge) elsif discard1 = 7 then Pic.Draw (cardback, 150, 250, picMerge) elsif discard1 = 8 then Pic.Draw (cardback, 150, 250, picMerge) elsif discard1 = 9 then Pic.Draw (cardback, 150, 250, picMerge) elsif discard1 = 10 then Pic.Draw (cardback, 150, 250, picMerge) end if dis2 := discard1 or dis1 randint (discard2, 1, 10) if discard2 = dis2 then loop randint (discard2, 1, 10) exit when discard2 not= dis2 end loop end if put discard1 ---------------------------- if u notice, when u run it, discard1 will sometimes show up as a card already put down i was working on discard2 trying to see if was doign the same thing |
Author: | richcash [ Tue Dec 26, 2006 11:31 pm ] | ||
Post subject: | |||
Use this way for cards.
Then you just have to have an array of values for the non-numeric face values and the suits (so instead of having 12 of 1 you have perhaps Ace of Clubs). But, since you're drawing pictures and not outputting, all you need to do is put your pictures in an array and draw the appropriate element in the array. Do you get it? |