Computer Science Canada Help Making a BlackJack Game |
Author: | king202 [ Wed Apr 21, 2004 1:12 pm ] |
Post subject: | Help Making a BlackJack Game |
Hey I need some help making a graphical Blackjack game. If someone can help me out I would be greatful |
Author: | Cervantes [ Wed Apr 21, 2004 2:37 pm ] |
Post subject: | |
what do you mean by "help"? How are you planning to do it and what exactly have you done so far? We need more information in order to "help" you. And if on the off chance you mean "do this for me" when you say "help" you won't get it. So tell us what you need help with, and we will surely provide. |
Author: | king202 [ Wed Apr 21, 2004 2:55 pm ] |
Post subject: | |
OK I have a Blackjack game That just plays the game blackjack. I was woundering if you could help me make the bet part of it. I can seem to be able to place a bet and have the money either take away or addon to the total amount. can you help |
Author: | Dan [ Wed Apr 21, 2004 5:18 pm ] |
Post subject: | |
well u just have a var that holdes how much money they curenly have, then u get input from the users about how much money they whont to bet. if it is more then what they have or an invaled number u ask the qeustion intill they put in vaild input. then once the game is done u add or take away money from the 1st money var deponding on the value of the input of how much to bet. so if they start with 1000: var money:int:=1000 vet bet:int put "put in $ to bet" get bet %put some error checking here %put game here %if they lose the game: money := money - bet %else if they win the game money := money + bet |
Author: | gamer [ Wed Apr 21, 2004 5:30 pm ] |
Post subject: | |
if u want u may wish to post wut ur program is so far, then we can hav more understanding of ur game |
Author: | king202 [ Wed Apr 21, 2004 9:54 pm ] |
Post subject: | |
Ok here is my program can you please help me Set you the bet part % BlackJack var card : int var input : string var plays : string var total : int var dealer : int var dcard : int loop total := Rand.Int (1, 10) loop put total :2 put "would you like to Hit or Stay? <H/S> ".. get input if input = "H" or input = "h" then card := Rand.Int (1, 10) else exit end if total := card + total exit when total > 21 end loop loop dealer := Rand.Int (1, 11) if dealer < 16 then dcard := Rand.Int (1, 11) dealer := dealer + dcard end if exit when dealer >= 16 end loop put "The dealer has " delay (500) put dealer, "!" put "You have " delay (500) put total, "!" if total > 21 and dealer > 21 then put "You and the dealer busted!" elsif total > 21 then put "You busted, dealer wins!" elsif total = dealer then put "You and the dealer tied!" elsif total > dealer then put "You win!" elsif dealer > 21 then put "The dealer busted, you win!" else put "The dealer wins!" end if end loop |
Author: | gamer [ Wed Apr 21, 2004 10:09 pm ] | ||
Post subject: | |||
is this wut ya want?
|
Author: | king202 [ Thu Apr 22, 2004 6:57 am ] |
Post subject: | |
That is Great man Thanks. I have just a couple more question if someone could help. First Can you explain what you did with the program? Second How to you assign a king queen jack and ace thanks alot |
Author: | AsianSensation [ Thu Apr 22, 2004 7:31 am ] |
Post subject: | |
I'm assuming you need this for the graphical part. When you did the Rand.Int (1, 10), you are essentially getting a random card from Ace to 10. Now for the Jack, Queen, and King, just assign each the value of 11, 12, and 13. So Rand.Int (1, 13) would get a random card between Ace and King. Now, using Rand.Int would not essentially be good for a complex blackjack game, like the real blackjack with every single rules. The best way of handling a blackjack game is to do string manipulation. Such that your "deck" is a long string, and you are cutting and appending on the string, "shuffling" the deck by rearranging substrings. It is a bit more complex, but it's easier to work if you want to implement every rules. |
Author: | king202 [ Thu Apr 22, 2004 9:25 am ] |
Post subject: | |
ok so If i want to do this right at the top would i do jack:=11 queen:=12 king:=13 How would i put these values into the Rand.Int |
Author: | Delta [ Thu Apr 22, 2004 9:39 am ] | ||
Post subject: | |||
Boom! its in a Randint lol I'm not sure what you mean and if it is... ummm...well... ya... good luck with programming.
|
Author: | Flashkicks [ Thu Apr 22, 2004 9:41 am ] |
Post subject: | |
EeEeEeK.. Lets hope that wasnt too harsh my friend..lol.. But yeah.. Your problem should be fixed.. [Delta's heartLess] |
Author: | king202 [ Thu Apr 22, 2004 10:04 am ] |
Post subject: | |
Great Thanks But i would like it to display King Queen Jack or ace. How would you get it to do that |
Author: | Delta [ Thu Apr 22, 2004 2:00 pm ] | ||
Post subject: | |||
ok.... try something like this...
|
Author: | king202 [ Thu Apr 22, 2004 3:26 pm ] |
Post subject: | |
where would i put that in the code at the top middle or end |
Author: | Delta [ Thu Apr 22, 2004 3:33 pm ] |
Post subject: | |
you would put it in your main loop where you plan on outputting which cards the player is holding. |
Author: | king202 [ Fri Apr 23, 2004 4:47 am ] |
Post subject: | |
Great man Thanks I just want to thank you guys for your help Just If someone could help me on this i was hoping I could figure this out on my own but i cant. How do you assign the ace to a one or eleven? Thanks again |
Author: | AsianSensation [ Fri Apr 23, 2004 6:23 am ] | ||
Post subject: | |||
the easiest way is to ask the player for the answer. So when you draw an Ace, you prompt the player to input what value they want the ace to be. ex:
|
Author: | king202 [ Fri Apr 23, 2004 7:30 am ] |
Post subject: | |
Ok I need some help I would like to include these codes if card = 11 then put "Jack" elsif card = 12 then put "Queen" elsif card = 13 then put "King" end if if Rand.Int (1, 13) = 1 then put "What would you like the value of Ace be?" get input if input = 1 then total += 1 elsif input = 11 thne total += 11 end if end if I am always getting errors. Can someone help set them up for me % BlackJack var card, total, dealer, dcard, bet, money : int var input, plays : string money := 1000 loop randint (card, 1, 10) total:= (card) put "You have $", money, "." loop put "How much would you like to bet for this game? $" .. get bet exit when bet > 0 or bet <= money %so the user can only use what he has end loop put "Your card is " delay (500) put card : 2 delay (500) randint (card, 1, 10) total:= (total+card) put "Your card is " delay (500) put card : 2 put "you have ", total loop put "would you like to Hit or Stay? <H/S> " .. get input if input = "H" or input = "h" then randint (card, 1, 10) else exit end if put "Your card is " delay (500) put card total:= (total+card) put "You have ",total exit when total > 21 end loop loop randint (dealer, 1, 10) if dealer < 16 then randint (dcard,1,10) dealer := dealer + dcard end if exit when dealer >= 16 end loop put "The dealer has " delay (500) put dealer, "!" put "You have " delay (500) put total, "!" if total > 21 and dealer > 21 then put "You and the dealer busted!" money -= bet elsif total > 21 then put "You busted, dealer wins!" money -= bet elsif total = dealer then put "You and the dealer tied!" elsif total > dealer then put "You win!" money +=bet elsif dealer > 21 then put "The dealer busted, you win!" money -=bet else put "The dealer wins!" money -= bet end if exit when money <= 0 end loop |
Author: | king202 [ Tue Apr 27, 2004 4:49 am ] |
Post subject: | |
can someone help me include this code into my program if card = 11 then put "Jack" elsif card = 12 then put "Queen" elsif card = 13 then put "King" end if if Rand.Int (1, 13) = 1 then put "What would you like the value of Ace be?" get input |