|
Post by rylan on Jan 30, 2007 22:09:23 GMT -5
i made black jack in VB6 for my culminating activity.
Made entirely out of If...Then, Elseif, and Nested if statements.
It worked, but had a few flaws. ill post the code later maybe. there was 10 pages of it when printed out.
|
|
|
Post by im_an_alien on Jan 31, 2007 17:58:56 GMT -5
Wow... That's awesome. Code, please.
I made a turn based fighting game in QBASIC once, it was 300 something lines of only if, then, else, print, input, chr$, and the QBASIC equivalent of getkey on TI calculators which I can't remember the name of. Some people might remember it, fighting smilies. I posted it a long time ago... you can still see it, it's on page one of the BASIC topic.
|
|
|
Post by rylan on Feb 3, 2007 20:56:02 GMT -5
Ok, ill go get the code, I saved it on my MP3 player
Edit: Here it is
Re-Edit Sorry it looks so bad without the proper Tabing.
'Rylan Stolar 'Jan 8, 07 'Black Jack, culm. Option Explicit
'players and dealers cards, bust variable, Tokens, and Totals, and Player and Dealer Ace variables
Dim intPlayerCard1 As Integer Dim intPlayerCard2 As Integer Dim intPlayerCard3 As Integer Dim intPlayerCard4 As Integer Dim intPlayerCard5 As Integer
Dim intDealerCard1 As Integer Dim intDealerCard2 As Integer Dim intDealerCard3 As Integer Dim intDealerCard4 As Integer Dim intDealerCard5 As Integer
Dim blnPAce1 As Boolean Dim blnPAce2 As Boolean Dim blnPAce3 As Boolean Dim blnPAce4 As Boolean
Dim intPPic1 As Integer Dim intPPic2 As Integer Dim intPPic3 As Integer Dim intPPic4 As Integer Dim intPPic5 As Integer
Dim blnPAce1used As Boolean Dim blnPAce2used As Boolean Dim blnPAce3used As Boolean Dim blnPAce4used As Boolean
Dim blnDAce1 As Boolean Dim blnDAce2 As Boolean Dim blnDAce3 As Boolean Dim blnDAce4 As Boolean
Dim intDPic1 As Integer Dim intDPic2 As Integer Dim intDPic3 As Integer Dim intDPic4 As Integer Dim intDPic5 As Integer
Dim blnDAce1used As Boolean Dim blnDAce2used As Boolean Dim blnDAce3used As Boolean Dim blnDAce4used As Boolean
Dim blnBust As Boolean
Dim intTokens As Integer
Dim intPtotal As Integer Dim intDtotal As Integer
Private Sub cmdDeal_Click()
'this resets all cards and captions, to start fresh
intPlayerCard1 = 0 intPlayerCard2 = 0 intPlayerCard3 = 0 intPlayerCard4 = 0 intPlayerCard5 = 0
lblPlayerCard1.Caption = "" lblPlayerCard2.Caption = "" lblPlayerCard3.Caption = "" lblPlayerCard4.Caption = "" lblPlayerCard5.Caption = ""
lblPlayerCard1.Visible = False lblPlayerCard2.Visible = False lblPlayerCard3.Visible = False lblPlayerCard4.Visible = False lblPlayerCard5.Visible = False
intDealerCard1 = 0 intDealerCard2 = 0 intDealerCard3 = 0 intDealerCard4 = 0 intDealerCard5 = 0
lblDealerCard1.Caption = "" lblDealerCard2.Caption = "" lblDealerCard3.Caption = "" lblDealerCard4.Caption = "" lblDealerCard5.Caption = ""
lblDealerCard1.Visible = False lblDealerCard2.Visible = False lblDealerCard3.Visible = False lblDealerCard4.Visible = False lblDealerCard5.Visible = False
blnPAce1 = False blnPAce2 = False blnPAce3 = False blnPAce4 = False
blnDAce1 = False blnDAce2 = False blnDAce3 = False blnDAce4 = False
picP1heart.Visible = False picP1club.Visible = False picP1spade.Visible = False picP1diamond.Visible = False picP2heart.Visible = False picP2club.Visible = False picP2spade.Visible = False picP2diamond.Visible = False picP3heart.Visible = False picP3club.Visible = False picP3spade.Visible = False picP3diamond.Visible = False picP4heart.Visible = False picP4club.Visible = False picP4spade.Visible = False picP4diamond.Visible = False picP5heart.Visible = False picP5club.Visible = False picP5spade.Visible = False picP5diamond.Visible = False
picD1heart.Visible = False picD1club.Visible = False picD1spade.Visible = False picD1diamond.Visible = False picD2heart.Visible = False picD2club.Visible = False picD2spade.Visible = False picD2diamond.Visible = False picD3heart.Visible = False picD3club.Visible = False picD3spade.Visible = False picD3diamond.Visible = False picD4heart.Visible = False picD4club.Visible = False picD4spade.Visible = False picD4diamond.Visible = False picD5heart.Visible = False picD5club.Visible = False picD5spade.Visible = False picD5diamond.Visible = False
lblTokens.Caption = "Tokens:" & intTokens
intPtotal = 0
lblWin.Caption = "" blnBust = False
'This will give you 2 random cards, face cards being 10 and ace 11. same goes for the dealer
intPlayerCard1 = Int(Rnd * 13 + 1) lblPlayerCard1.Visible = True If intPlayerCard1 = 11 Then intPlayerCard1 = 10 lblPlayerCard1.Caption = "J" ElseIf intPlayerCard1 = 12 Then intPlayerCard1 = 10 lblPlayerCard1.Caption = "Q" ElseIf intPlayerCard1 = 13 Then intPlayerCard1 = 10 lblPlayerCard1.Caption = "K" ElseIf intPlayerCard1 = 1 Then intPlayerCard1 = 11 lblPlayerCard1.Caption = "A" If blnPAce1 = False Then blnPAce1 = True ElseIf blnPAce2 = False Then blnPAce2 = True ElseIf blnPAce3 = False Then blnPAce3 = True ElseIf blnPAce4 = False Then blnPAce4 = True End If Else intPlayerCard1 = intPlayerCard1 lblPlayerCard1.Caption = intPlayerCard1 End If
'this decides what suit to display
intPPic1 = Int(Rnd * 4) + 1 If intPPic1 = 1 Then picP1heart.Visible = True ElseIf intPPic1 = 2 Then picP1club.Visible = True ElseIf intPPic1 = 3 Then picP1spade.Visible = True ElseIf intPPic1 = 4 Then picP1diamond.Visible = True End If
intPlayerCard2 = Int(Rnd * 13 + 1) lblPlayerCard2.Visible = True If intPlayerCard2 = 11 Then intPlayerCard2 = 10 lblPlayerCard2.Caption = "J" ElseIf intPlayerCard2 = 12 Then intPlayerCard2 = 10 lblPlayerCard2.Caption = "Q" ElseIf intPlayerCard2 = 13 Then intPlayerCard2 = 10 lblPlayerCard2.Caption = "K" ElseIf intPlayerCard2 = 1 Then intPlayerCard2 = 11 lblPlayerCard2.Caption = "A" If blnPAce1 = False Then blnPAce1 = True ElseIf blnPAce2 = False Then blnPAce2 = True ElseIf blnPAce3 = False Then blnPAce3 = True ElseIf blnPAce4 = False Then blnPAce4 = True End If Else intPlayerCard2 = intPlayerCard2 lblPlayerCard2.Caption = intPlayerCard2 End If
intPPic2 = Int(Rnd * 4) + 1 If intPPic2 = 1 Then picP2heart.Visible = True ElseIf intPPic2 = 2 Then picP2club.Visible = True ElseIf intPPic2 = 3 Then picP2spade.Visible = True ElseIf intPPic2 = 4 Then picP2diamond.Visible = True End If
'sums and displays your total, same for the dealer
intPtotal = intPlayerCard1 + intPlayerCard2
lblPtotal.Caption = "Players Total:" & intPtotal intDtotal = 0
intDealerCard1 = Int(Rnd * 13 + 1) lblDealerCard1.Visible = True If intDealerCard1 = 11 Then intDealerCard1 = 10 lblDealerCard1.Caption = "J" ElseIf intDealerCard1 = 12 Then intDealerCard1 = 10 lblDealerCard1.Caption = "Q" ElseIf intDealerCard1 = 13 Then intDealerCard1 = 10 lblDealerCard1.Caption = "K" ElseIf intDealerCard1 = 1 Then intDealerCard1 = 11 lblDealerCard1.Caption = "A" If blnDAce1 = False Then blnDAce1 = True ElseIf blnDAce2 = False Then blnDAce2 = True ElseIf blnDAce3 = False Then blnDAce3 = True ElseIf blnDAce4 = False Then blnDAce4 = True End If Else intDealerCard1 = intDealerCard1 lblDealerCard1.Caption = intDealerCard1 End If
intDPic1 = Int(Rnd * 4) + 1 If intDPic1 = 1 Then picD1heart.Visible = True ElseIf intDPic1 = 2 Then picD1club.Visible = True ElseIf intDPic1 = 3 Then picD1spade.Visible = True ElseIf intDPic1 = 4 Then picD1diamond.Visible = True End If
intDealerCard2 = Int(Rnd * 13 + 1) lblDealerCard2.Visible = True If intDealerCard2 = 11 Then intDealerCard2 = 10 lblDealerCard2.Caption = "J" ElseIf intDealerCard2 = 12 Then intDealerCard2 = 10 lblDealerCard2.Caption = "Q" ElseIf intDealerCard2 = 13 Then intDealerCard2 = 10 lblDealerCard2.Caption = "K" ElseIf intDealerCard2 = 1 Then intDealerCard2 = 11 lblDealerCard2.Caption = "A" If blnDAce1 = False Then blnDAce1 = True ElseIf blnDAce2 = False Then blnDAce2 = True ElseIf blnDAce3 = False Then blnDAce3 = True ElseIf blnDAce4 = False Then blnDAce4 = True End If Else intDealerCard2 = intDealerCard2 lblDealerCard2.Caption = intDealerCard2 End If
intDPic2 = Int(Rnd * 4) + 1 If intDPic2 = 1 Then picD2heart.Visible = True ElseIf intDPic2 = 2 Then picD2club.Visible = True ElseIf intDPic2 = 3 Then picD2spade.Visible = True ElseIf intDPic2 = 4 Then picD2diamond.Visible = True End If
intDtotal = intDealerCard1 + intDealerCard2
lblDtotal.Caption = "Dealers Total:" & intDtotal
End Sub Private Sub cmdDraw_Click()
'Draws you another card, checks which cards youve already drawn, and gives you the next, to a max of 5 cards, then adds your total
If intPlayerCard3 = 0 Then
intPPic3 = Int(Rnd * 4) + 1 If intPPic3 = 1 Then picP3heart.Visible = True ElseIf intDPic3 = 2 Then picP3club.Visible = True ElseIf intPPic3 = 3 Then picP3spade.Visible = True ElseIf intPPic3 = 4 Then picP3diamond.Visible = True End If
lblPlayerCard3.Visible = True intPlayerCard3 = Int(Rnd * 13 + 1) If intPlayerCard3 = 11 Then intPlayerCard3 = 10 lblPlayerCard3.Caption = "J" ElseIf intPlayerCard3 = 12 Then intPlayerCard3 = 10 lblPlayerCard3.Caption = "Q" ElseIf intPlayerCard3 = 13 Then intPlayerCard3 = 10 lblPlayerCard3.Caption = "K" ElseIf intPlayerCard3 = 1 Then intPlayerCard3 = 11 lblPlayerCard3.Caption = "A" If blnPAce1 = False Then blnPAce1 = True ElseIf blnPAce2 = False Then blnPAce2 = True ElseIf blnPAce3 = False Then blnPAce3 = True ElseIf blnPAce4 = False Then blnPAce4 = True End If Else intPlayerCard3 = intPlayerCard3 lblPlayerCard3.Caption = intPlayerCard3 End If
intPtotal = intPtotal + intPlayerCard3 ElseIf intPlayerCard4 = 0 And blnBust = False Then
intPPic4 = Int(Rnd * 4) + 1 If intPPic4 = 1 Then picP4heart.Visible = True ElseIf intDPic4 = 2 Then picP4club.Visible = True ElseIf intPPic4 = 3 Then picP4spade.Visible = True ElseIf intPPic4 = 4 Then picP4diamond.Visible = True End If
lblPlayerCard4.Visible = True intPlayerCard4 = Int(Rnd * 13 + 1) If intPlayerCard4 = 11 Then intPlayerCard4 = 10 lblPlayerCard4.Caption = "J" ElseIf intPlayerCard4 = 12 Then intPlayerCard4 = 10 lblPlayerCard4.Caption = "Q" ElseIf intPlayerCard4 = 13 Then intPlayerCard4 = 10 lblPlayerCard4.Caption = "K" ElseIf intPlayerCard1 = 1 Then intPlayerCard4 = 11 lblPlayerCard4.Caption = "A" If blnPAce1 = False Then blnPAce1 = True ElseIf blnPAce2 = False Then blnPAce2 = True ElseIf blnPAce3 = False Then blnPAce3 = True ElseIf blnPAce4 = False Then blnPAce4 = True End If Else intPlayerCard4 = intPlayerCard4 lblPlayerCard4.Caption = intPlayerCard4 End If intPtotal = intPtotal + intPlayerCard4 ElseIf intPlayerCard5 = 0 And blnBust = False Then
intPPic5 = Int(Rnd * 4) + 1 If intPPic5 = 1 Then picP5heart.Visible = True ElseIf intDPic5 = 2 Then picP5club.Visible = True ElseIf intPPic5 = 3 Then picP5spade.Visible = True ElseIf intPPic5 = 4 Then picP5diamond.Visible = True End If
lblPlayerCard5.Visible = True intPlayerCard5 = Int(Rnd * 13 + 1) If intPlayerCard5 = 11 Then intPlayerCard5 = 10 lblPlayerCard5.Caption = "J" ElseIf intPlayerCard5 = 12 Then intPlayerCard5 = 10 lblPlayerCard5.Caption = "Q" ElseIf intPlayerCard5 = 13 Then intPlayerCard5 = 10 lblPlayerCard5.Caption = "K" ElseIf intPlayerCard5 = 1 Then intPlayerCard5 = 11 lblPlayerCard5.Caption = "A" If blnPAce1 = False Then blnPAce1 = True ElseIf blnPAce2 = False Then blnPAce2 = True ElseIf blnPAce3 = False Then blnPAce3 = True ElseIf blnPAce4 = False Then blnPAce4 = True End If Else intPlayerCard5 = intPlayerCard5 lblPlayerCard5.Caption = intPlayerCard5 End If intPtotal = intPtotal + intPlayerCard5 End If
'Makes any aces you have equal 1 if your total is above 22
If intPtotal > 21 And blnPAce1used = False Then If blnPAce1 = True Then intPtotal = intPtotal - 10 blnPAce1used = True End If End If
'If you have more than 21, you have busted
If intPtotal > 21 Then blnBust = True lblWin.Caption = "Bust" intTokens = intTokens - 1 End If
lblPtotal.Caption = "Players Total:" & intPtotal
lblTokens.Caption = "Tokens:" & intTokens
End Sub
Private Sub cmdStay_Click()
'to make the dealer hit
If intDtotal <= 16 Then
intDPic3 = Int(Rnd * 4) + 1 If intDPic3 = 1 Then picD3heart.Visible = True ElseIf intDPic3 = 2 Then picD3club.Visible = True ElseIf intDPic3 = 3 Then picD3spade.Visible = True ElseIf intDPic3 = 4 Then picD3diamond.Visible = True End If
lblDealerCard3.Visible = True intDealerCard3 = Int(Rnd * 13 + 1) If intDealerCard3 = 11 Then intDealerCard3 = 10 lblDealerCard3.Caption = "J" ElseIf intDealerCard3 = 12 Then intDealerCard3 = 10 lblDealerCard3.Caption = "Q" ElseIf intDealerCard3 = 13 Then intDealerCard3 = 10 lblDealerCard3.Caption = "K" ElseIf intDealerCard3 = 1 Then intDealerCard3 = 11 lblDealerCard3.Caption = "A" If blnDAce1 = False Then blnDAce1 = True ElseIf blnDAce2 = False Then blnDAce2 = True ElseIf blnDAce3 = False Then blnDAce3 = True ElseIf blnDAce4 = False Then blnDAce4 = True End If Else intDealerCard3 = intDealerCard3 lblDealerCard3.Caption = intDealerCard3 End If intDtotal = intDtotal + intDealerCard3 End If
If intDtotal <= 16 Then
intDPic4 = Int(Rnd * 4) + 1 If intDPic4 = 1 Then picD4heart.Visible = True ElseIf intDPic4 = 2 Then picD4club.Visible = True ElseIf intDPic4 = 3 Then picD4spade.Visible = True ElseIf intDPic4 = 4 Then picD4diamond.Visible = True End If
lblDealerCard4.Visible = True intDealerCard4 = Int(Rnd * 13 + 1) If intDealerCard4 = 11 Then intDealerCard4 = 10 lblDealerCard4.Caption = "J" ElseIf intDealerCard4 = 12 Then intDealerCard4 = 10 lblDealerCard4.Caption = "Q" ElseIf intDealerCard4 = 13 Then intDealerCard4 = 10 lblDealerCard4.Caption = "K" ElseIf intDealerCard4 = 1 Then intDealerCard4 = 11 lblDealerCard4.Caption = "A" If blnDAce1 = False Then blnDAce1 = True ElseIf blnDAce2 = False Then blnDAce2 = True ElseIf blnDAce3 = False Then blnDAce3 = True ElseIf blnDAce4 = False Then blnDAce4 = True End If Else intDealerCard4 = intDealerCard4 lblDealerCard4.Caption = intDealerCard4 End If intDtotal = intDtotal + intDealerCard4 End If If intDtotal <= 16 Then
intDPic5 = Int(Rnd * 4) + 1 If intDPic5 = 1 Then picD5heart.Visible = True ElseIf intDPic5 = 2 Then picD5club.Visible = True ElseIf intDPic5 = 3 Then picD5spade.Visible = True ElseIf intDPic5 = 4 Then picD5diamond.Visible = True End If
lblDealerCard5.Visible = True intDealerCard5 = Int(Rnd * 13 + 1) If intDealerCard5 = 11 Then intDealerCard5 = 10 lblDealerCard5.Caption = "J" ElseIf intDealerCard5 = 12 Then intDealerCard5 = 10 lblDealerCard5.Caption = "Q" ElseIf intDealerCard5 = 13 Then intDealerCard5 = 10 lblDealerCard5.Caption = "K" ElseIf intDealerCard5 = 1 Then intDealerCard5 = 11 lblDealerCard5.Caption = "A" If blnDAce1 = False Then blnDAce1 = True ElseIf blnDAce2 = False Then blnDAce2 = True ElseIf blnDAce3 = False Then blnDAce3 = True ElseIf blnDAce4 = False Then blnDAce4 = True End If Else intDealerCard5 = intDealerCard5 lblDealerCard5.Caption = intDealerCard5 End If intDtotal = intDtotal + intDealerCard5 End If
If blnDAce1 = True Then intDtotal = intDtotal - 10 End If
lblDtotal.Caption = "Dealers Total:" & intDtotal
'**********************************************
If intDtotal > 21 Then lblWin.Caption = "Dealer Busts, you win" intTokens = intTokens + 1 ElseIf intPtotal > intDtotal Then lblWin.Caption = "Win" intTokens = intTokens + 1 ElseIf intPtotal < intDtotal Then lblWin.Caption = "Lose" intTokens = intTokens - 1 Else lblWin.Caption = "Draw" intTokens = intTokens End If
lblTokens.Caption = "Tokens:" & intTokens
End Sub
Private Sub Form_Load() Randomize intTokens = 100 End Sub
Private Sub cmdDone_Click() Unload Me End Sub
|
|
|
Post by rylan on Feb 7, 2007 22:39:10 GMT -5
yeah, I dont think anyone bothered to read that. ill post the Form sometime
|
|
hitler
Junior Member
KAKAKABOOM!!!!!!!!!!
Posts: 53
|
Post by hitler on Feb 27, 2007 13:14:00 GMT -5
\/\/()\/\/
|
|
|
Post by rylan on Apr 28, 2007 22:41:13 GMT -5
yeah, it took me a while... it looks awsome though.
|
|