0 Replies - 12017 Views - Last Post: 16 May 2011 - 07:52 AM Rate Topic: -----

#1 BrentR   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 16-May 11

Blackjack game help

Posted 16 May 2011 - 07:52 AM

-------------------------------------------------------------------------------------------------------------------
im new to programming and im not sure how to make the cards more random. i also cant figure out how to get the dealer to keep drawing cards untill his card count reaches 17. So if someone could help me out id be most grateful.
Thanks
--------------------------------------------------------------------------------------------------------------------



Heres the pastebin its much easier to read.
http://pastebin.com/A5qLupdy
Public Class Form1
    '1st hit button gives player 3rd
    Private Sub btnHit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnHit.Click
        Const intMAXIMAGES As Integer = 11
        Dim strImageArray(intMAXIMAGES - 1 * Rnd()) As String
        strImageArray(0) = "H:\1.bmp"
        strImageArray(1) = "H:\2.bmp"
        strImageArray(2) = "H:\3.bmp"
        strImageArray(3) = "H:\4.bmp"
        strImageArray(4) = "H:\5.bmp"
        strImageArray(5) = "H:\6.bmp"
        strImageArray(6) = "H:\7.bmp"
        strImageArray(7) = "H:\8.bmp"
        strImageArray(8) = "H:\9.bmp"
        strImageArray(9) = "H:\10.bmp"
        strImageArray(10) = "H:\11.bmp"

        Static intImage As Integer = 0
        Me.picMyCard3.Image = Image.FromFile(strImageArray(intImage))
        intImage = (intImage * Rnd(Rnd())) Mod intMAXIMAGES

        Me.btnHit.Visible = False
        Me.btnHit2.Visible = True





    End Sub
    'resets the dealers and players hand
    Private Sub btnNewHand_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDeal.Click

        Randomize()

        Const intMAXIMAGES As Integer = 11


        Dim strImageArray(intMAXIMAGES - 1 * Rnd()) As String
        strImageArray(0) = "H:\1.bmp"
        strImageArray(1) = "H:\2.bmp"
        strImageArray(2) = "H:\3.bmp"
        strImageArray(3) = "H:\4.bmp"
        strImageArray(4) = "H:\5.bmp"
        strImageArray(5) = "H:\6.bmp"
        strImageArray(6) = "H:\7.bmp"
        strImageArray(7) = "H:\8.bmp"
        strImageArray(8) = "H:\9.bmp"
        strImageArray(9) = "H:\10.bmp"
        strImageArray(10) = "H:\11.bmp"



        Static intImage As Integer = 0
        Me.picMyCard1.Image = Image.FromFile(strImageArray(intImage))
        intImage = (intImage + Rnd()) Mod intMAXIMAGES

        Me.picMyCard2.Image = Image.FromFile(strImageArray(intImage))
        intImage = (intImage + Rnd(Rnd())) Mod intMAXIMAGES

        Me.picDealer1.Image = Image.FromFile(strImageArray(intImage))
        intImage = (intImage + Rnd(Rnd())) Mod intMAXIMAGES

        Me.picDealer2.Image = Image.FromFile("H:\cardBack.bmp")


    End Sub

    Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
        End

    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.btnHit2.Visible = False
        Me.btnHit3.Visible = False

    End Sub
    '2nd hit button gives player a 4th card
    Private Sub btnHit2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnHit2.Click
        Const intMAXIMAGES As Integer = 11
        Dim strImageArray(intMAXIMAGES - 1 * Rnd()) As String
        strImageArray(0) = "H:\1.bmp"
        strImageArray(1) = "H:\2.bmp"
        strImageArray(2) = "H:\3.bmp"
        strImageArray(3) = "H:\4.bmp"
        strImageArray(4) = "H:\5.bmp"
        strImageArray(5) = "H:\6.bmp"
        strImageArray(6) = "H:\7.bmp"
        strImageArray(7) = "H:\8.bmp"
        strImageArray(8) = "H:\9.bmp"
        strImageArray(9) = "H:\10.bmp"
        strImageArray(10) = "H:\11.bmp"

        Static intImage As Integer = 3
        Me.picMyCard4.Image = Image.FromFile(strImageArray(intImage))
        intImage = (intImage * Rnd()) Mod intMAXIMAGES

        Me.btnHit2.Visible = False
        Me.btnHit3.Visible = True
    End Sub
    '3rd hit button that gives player 5th card
    Private Sub btnHit3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnHit3.Click
        Const intMAXIMAGES As Integer = 11
        Dim strImageArray(intMAXIMAGES - 1 * Rnd()) As String
        strImageArray(0) = "H:\1.bmp"
        strImageArray(1) = "H:\2.bmp"
        strImageArray(2) = "H:\3.bmp"
        strImageArray(3) = "H:\4.bmp"
        strImageArray(4) = "H:\5.bmp"
        strImageArray(5) = "H:\6.bmp"
        strImageArray(6) = "H:\7.bmp"
        strImageArray(7) = "H:\8.bmp"
        strImageArray(8) = "H:\9.bmp"
        strImageArray(9) = "H:\10.bmp"
        strImageArray(10) = "H:\11.bmp"

        Static intImage As Integer = 1
        Me.picMyCard5.Image = Image.FromFile(strImageArray(intImage))
        intImage = (intImage * Rnd()) Mod intMAXIMAGES

        Me.btnHit2.Visible = False
        Me.btnHit3.Visible = False

    End Sub

    Private Sub btnClearHand_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClearHand.Click
        Me.picDealer1.Image = Nothing
        Me.picDealer2.Image = Nothing
        Me.picDealer3.Image = Nothing
        Me.picDealer4.Image = Nothing
        Me.picDealer5.Image = Nothing
        Me.picMyCard1.Image = Nothing
        Me.picMyCard2.Image = Nothing
        Me.picMyCard3.Image = Nothing
        Me.picMyCard4.Image = Nothing
        Me.picMyCard5.Image = Nothing

        Me.btnHit.Visible = True
        Me.btnHit2.Visible = False
        Me.btnHit3.Visible = False


    End Sub
    'players stop getting cards and flips the dealers hidden card
    Private Sub btnStand_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStand.Click
        Const intMAXIMAGES As Integer = 11
        Dim strImageArray(intMAXIMAGES - 1 * Rnd()) As String
        strImageArray(0) = "H:\1.bmp"
        strImageArray(1) = "H:\2.bmp"
        strImageArray(2) = "H:\3.bmp"
        strImageArray(3) = "H:\4.bmp"
        strImageArray(4) = "H:\5.bmp"
        strImageArray(5) = "H:\6.bmp"
        strImageArray(6) = "H:\7.bmp"
        strImageArray(7) = "H:\8.bmp"
        strImageArray(8) = "H:\9.bmp"
        strImageArray(9) = "H:\10.bmp"
        strImageArray(10) = "H:\11.bmp"

        Static intImage As Integer = 0
        Me.picDealer2.Image = Image.FromFile(strImageArray(intImage))
        intImage = (intImage * Rnd()) Mod intMAXIMAGES

        Me.btnHit.Visible = False
        Me.btnHit2.Visible = False
        Me.btnHit3.Visible = False






    End Sub
End Class


This post has been edited by ButchDean: 16 May 2011 - 12:36 PM
Reason for edit:: Please use code tags!


Is This A Good Question/Topic? 0
  • +

Page 1 of 1