Selasa, 11 Desember 2012

TUTORIAL PROGRAM CASINO MODUL 3


TUTORIAL GAME CASINO



  
KOMPONEN TOOLBOX :
NO
KOMPONEN
PROPERTIS
KETERANGAN
1
FORM
NAME
TEXT
FORM1
GAME
2
LABEL1
NAME
TEXT
LABEL1
0
3
LABEL2
NAME
TEXT
LABEL2
0
4
LABEL3
NAME
TEXT
LABEL3
0
5
LABEL4
NAME
TEXT
LABEL4
TARUHAN
6
LABEL5
NAME
TEXT
LABEL5
NB : UANG DIBAWAH 1000
7
LABEL8
NAME
TEXT
LABEL8
UANG
8
LABEL9
NAME
TEXT
LABEL9
UANG
9
TEXTBOX1
NAME
TEXT
TEXTBOX1
10
TEXTBOX2
NAME
TEXT
TEXTBOX2
11
TEXTBOX3
NAME
TEXT
TEXTBOX3
12
PICTUREBOX1
NAME
TEXT
PICTUREBOX1
13
PICTUREBOX2
NAME
TEXT
PICTUREBOX2
14
PICTUREBOX3
NAME
TEXT
PICTUREBOX3
15
PICTUREBOX4
NAME
TEXT
PICTUREBOX4
16
BUTTON1
NAME
TEXT
BUTTON1
START
17
BUTTON2
NAME
TEXT
BUTTON2
STOP
18
BUTTON3
NAME
TEXT
BUTTON3
COBA LAGI
19
BUTTON4
NAME
TEXT
BUTTON4
COBA LAGI
20
BUTTON5
NAME
TEXT
BUTTON5
STOP
21
BUTTON6
NAME
TEXT
BUTTON6
START
22
BUTTON7
NAME
TEXT
BUTTON7
EXIT
23
BUTTON8
NAME
TEXT
BUTTON8
KELUAR
24
TIMER1
NAME
TEXT
TIMER1
25
TIMER2
NAME
TEXT
TIMER2
26
IMAGELIST1
NAME
TEXT
IMAGELIST1
27
LABEL4
NAME
TEXT
LABEL4
SELAMAT ANDA MENANG

ANALISIS LISTING
Public Class Form1
    Dim m, n1, n2, n3 As Integer
    Dim spin As System.Media.SoundPlayer = New System.Media.SoundPlayer(WindowsApplication1.My.Resources.Spin)
    Dim sp As System.Media.SoundPlayer = New System.Media.SoundPlayer(WindowsApplication1.My.Resources.Tada)

Untuk mendeklarasikan dan memberi sound

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Label1.Text = CStr(Int(Rnd() * 10))
        Label2.Text = CStr(Int(Rnd() * 10))
        Label3.Text = CStr(Int(Rnd() * 10))

Untuk mengacak angka

        If TextBox1.Text = 1 Then Button1.Enabled = False
 If Val(TextBox1.Text) > Val(TextBox3.Text) Then TextBox1.Text = Val(TextBox1.Text - TextBox3.Text)
If Val(TextBox1.Text) < Val(TextBox3.Text) Then TextBox1.Text = Val(TextBox1.Text - 0)

Jika uang dalam textbox bernilai “1” maka button acak tidak aktif
Jika uang dalam textbox lebih besar daripada taruhan nya maka uang akan dikurangi oleh taruhnnya
      
 Timer1.Enabled = True
        Label1.Text = ""
        Label2.Text = ""
        Label3.Text = ""

Mengaktifkan waktu dan label lain kosong

        If Val(TextBox1.Text) < Val(TextBox3.Text) Then
            Timer1.Enabled = False
            Label1.Text = ""
            Label2.Text = ""
            Label3.Text = ""
            TextBox3.Text = ""
            MsgBox("UANG ANDA KURANG")
            Return
        End If

Angka dalam textbox1 kurang dari textbox3 maka akan muncul msgbox dan waktu tidak berfungsi, serta label kosong

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Timer1.Enabled = False
        If (Label1.Text = Label2.Text) Or Label1.Text = Label3.Text Or Label2.Text = Label3.Text Then MessageBox.Show("Selamat anda menang")
        If (Label1.Text = Label2.Text) Or Label1.Text = Label3.Text Or Label2.Text = Label3.Text Then TextBox1.Text = Val(TextBox1.Text) + (2 * Val(TextBox3.Text))
        If TextBox1.Text = 0 Then
            MsgBox("ANDA KURANG BERUNTUNG", 0, "Peringatan")
        End If

Jika distop keluar angka yang sama maka keluar informasi msgbox bertuliskan “selamat anda menang”, jika tidak keluar msgbox bertuliskan “ANDA KURANG BERUNTUNG”.

    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        TextBox1.Text = TextBox1.Text
        If TextBox1.Text > 1 Then Button1.Enabled = True
        Label1.Text = ""
        Label2.Text = ""
        Label3.Text = ""
        TextBox1.Text = ""
        TextBox3.Text = ""
    End Sub

Jika textbox1 lebih dari 1 maka button aka aktif dan label 1,2,3 serta textbox1,3 kosong untuk memulai baru

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Label1.Text = CStr(Int(Rnd() * 10))
        Label2.Text = CStr(Int(Rnd() * 10))
        Label3.Text = CStr(Int(Rnd() * 10))
    End Sub

Memberi perintah didalam waktu untuk mengacak gambar

    Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
        If MessageBox.Show("COBA LAGI BERMAIN") Then Me.Close()
    End Sub

Ketika akan keluar muncul msgbox dan keluar

    Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
        m = m + 1
        If m < 1000 Then
            n1 = Int(1 + Rnd() * 5)
            n2 = Int(1 + Rnd() * 5)
            n3 = Int(1 + Rnd() * 5)
            Select Case n1
                Case 1
                    PictureBox1.Image = ImageList1.Images.Item(0)
                Case 2
                    PictureBox1.Image = ImageList1.Images.Item(1)
                Case 3
                    PictureBox1.Image = ImageList1.Images.Item(2)
                Case 4
                    PictureBox1.Image = ImageList1.Images.Item(3)
                Case 5
                    PictureBox1.Image = ImageList1.Images.Item(4)
                Case 6
                    PictureBox1.Image = ImageList1.Images.Item(5)
                Case 7
                    PictureBox1.Image = ImageList1.Images.Item(6)
            End Select

Untuk megacak animasi gambar

            Select Case n2
                Case 1
                    PictureBox2.Image = ImageList1.Images.Item(0)
                Case 2
                    PictureBox2.Image = ImageList1.Images.Item(1)
                Case 3
                    PictureBox2.Image = ImageList1.Images.Item(2)
                Case 4
                    PictureBox2.Image = ImageList1.Images.Item(3)
                Case 5
                    PictureBox2.Image = ImageList1.Images.Item(4)
                Case 6
                    PictureBox2.Image = ImageList1.Images.Item(5)
                Case 7
                    PictureBox2.Image = ImageList1.Images.Item(6)
            End Select

Untuk megacak animasi gambar

            Select Case n3
                Case 1
                    PictureBox3.Image = ImageList1.Images.Item(0)
                Case 2
                    PictureBox3.Image = ImageList1.Images.Item(1)
                Case 3
                    PictureBox3.Image = ImageList1.Images.Item(2)
                Case 4
                    PictureBox3.Image = ImageList1.Images.Item(3)
                Case 5
                    PictureBox3.Image = ImageList1.Images.Item(4)
                Case 6
                    PictureBox3.Image = ImageList1.Images.Item(5)
                Case 7
                    PictureBox3.Image = ImageList1.Images.Item(6)
            End Select
        End If
    End Sub

Untuk megacak animasi gambar

    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        If TextBox2.Text = 1 Then Button6.Enabled = False
If Val(TextBox2.Text) > Val(TextBox3.Text) Then TextBox2.Text = Val(TextBox2.Text - TextBox3.Text)
If Val(TextBox2.Text) < Val(TextBox3.Text) Then TextBox2.Text = Val(TextBox2.Text - 0)

Jika uang dalam textbox bernilai “1” maka button acak tidak aktif
Jika uang dalam textbox lebih besar daripada taruhan nya maka uang akan dikurangi oleh taruhnnya

        Timer2.Enabled = True
        PictureBox1.Visible = True
        PictureBox2.Visible = True
        PictureBox3.Visible = True

Animasi teracak

        If Val(TextBox2.Text) < Val(TextBox3.Text) Then
            Timer1.Enabled = False
            PictureBox1.Visible = False
            PictureBox2.Visible = False
            PictureBox3.Visible = False
            TextBox3.Text = ""
            MsgBox("UANG ANDA KURANG")
            Return
        End If
    End Sub

Jika uang lebih kecil dari taruhan maka animasi tidak muncul dan keluar bertuliskan “uang anda kurng”

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        Timer2.Enabled = False
        If (n1 = n2) Or n1 = n3 Or n2 = n3 Then MessageBox.Show("Selamat anda menang")
        If (n1 = n2) Or n1 = n3 Or n2 = n3 Then TextBox2.Text = Val(TextBox2.Text) + (2 * Val(TextBox3.Text))
            If TextBox2.Text = 0 Then
                MsgBox("ANDA KURANG BERUNTUNG", 0, "Peringatan")
            End If
    End Sub

Jika distop keluar angka yang sama maka keluar informasi msgbox bertuliskan “selamat anda menang”, jika tidak keluar msgbox bertuliskan “ANDA KURANG BERUNTUNG”.

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        TextBox2.Text = TextBox2.Text
        If TextBox2.Text > 1 Then Button4.Enabled = True
        PictureBox1.Visible = False
        PictureBox2.Visible = False
        PictureBox3.Visible = False
        TextBox2.Text = ""
        TextBox3.Text = ""
    End Sub

Jika uang lebih dari “1” maka button acak berfugsi untuk memulai game

    Private Sub TextBox1_keypress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
        Dim masukan As Boolean = Char.IsDigit(e.KeyChar)
        If Not masukan Then e.Handled = True
    End Sub

Memasukkan khusus angka

    Private Sub TextBox2_keypress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox2.KeyPress
        Dim masukan As Boolean = Char.IsDigit(e.KeyChar)
        If Not masukan Then e.Handled = True
    End Sub

Memasukkan khusus angka

    Private Sub TextBox3_keypress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox3.KeyPress
        Dim masukan As Boolean = Char.IsDigit(e.KeyChar)
        If Not masukan Then e.Handled = True
    End Sub
Memasukkan khusus angka

    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
        If Val(TextBox1.Text) > 1000 Then
            sp.Play()
            PictureBox4.Show()
            PictureBox4.Image = My.Resources.animasi
            Me.BackColor = Color.Black
            Label4.Show()
            Button8.Show()
        End If
    End Sub

Jika uang lebih dari 1000 maka akan keluar gambar animasi dan sound yang sudah ditambahkan

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Label4.Hide()
        PictureBox4.Hide()
        Button8.Hide()
    End Sub

Saat form 1 aktif animasi setelah menang akan hilang terlebih dahulu 

    Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
        Close()
    End Sub

Mengeluarkan game tersebut(exit)

    Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged
        If Val(TextBox2.Text) > 1000 Then
            sp.Play()
            PictureBox4.Show()
            PictureBox4.Image = My.Resources.animasi
            Me.BackColor = Color.Black
            Label4.Show()
            Button8.Show()
        End If
    End Sub

Jika uang lebih dari 1000 maka keluar gambar animasi dan sound yang sudah ditambahkan

End Class


Tidak ada komentar:

Posting Komentar