Re: Help With My Game of Black Jack
- Posted by Irv Mullins <irv at ELLIJAY.COM> Nov 30, 1999
- 574 views
----- Original Message ----- From: David Roach <roachd_76 at YAHOO.COM> To: <EUPHORIA at LISTSERV.MUOHIO.EDU> Sent: Tuesday, November 30, 1999 1:22 PM Subject: Help With My Game of Black Jack > I am making a game of black jack. It's my first euphoria program and I need > a little guidance. I've only been doing this for a realy short period of > time (2 weeks). I am using Dave Cunny's win32lib and I have figured out how > to open windows make menu bars, display text, and make butons and assign > actions to the buttons. My game is very simple. Visual black jack.The > dealer gets two cards to start and the player gets two cards to start. I > have only two buttons "Hit Me" and "Stay". What I need help with is setting > up the procedures that make the game work. For instance pulling random > cards (I am only using cards 2-9 and jack, queen, king, and an ace , four > of each of course, just to keep it simple), making it where the computer > will not any one card more than one time. Pretty much any thing beyond > simple window stuff I get lost. I can do it in QBasic but I like this > programming too much and I want to use it. I just nees some guidance in the > right direction. Please help. Hi: One way is to set up a list of cards in the deck, and then remove each card as it is drawn (so it can't be drawn again) -- put this part in (General) constant hearts = 1, diamonds = 2, clubs = 3, spades = 4 constant suit = {"Hearts","Diamonds","Clubs","Spades"} sequence deck deck = { {"Ace",1},{"Ace",2},{"Ace",3},{"Ace",4},{2,1},{2,2},{2,3},{2,4}, {3,1},.....{"Queen",4},{"King",1},{"King",2},{"King",3},{"King",4} } --put this part in the draw-a-card onClick button response: object newcard integer x -- the second number of each pair denotes the suit. -- each time you draw a card, use rand(length(deck)) to pick from what's left. x = rand(length(deck)) -- randomly select a card newcard = deck[x] --save the card deck = deck[1..x-1] & deck[x+1..length(deck)] -- remove that card from the deck printf(1,"You have drawn the %d of %s",newcard) Try this in text mode - there may be bugs. HTH Irv