Jumat, 07 Desember 2012

FLOWCHART PROGRAM GAME SLOT MACHINE MODUL 3


TUTORIAL MEMBUAT GAME SLOT MACHINE MODUL 3


TUTORIAL CARA MEMBUAT GAME SLOT MACHINE MENGGUNAKAN APLIKASI VISUAL BASIC 2010
KELOMPOK 42 TEKNIK INDUSTRI UNDIP 2012

Disini kami akan menjelaskan bagaimana membuat program game slot machine menggunakan aplikasi Visual Basic 2010. Berikut ini adalah penjelasan berdasarkan contoh dari yang kami buat












Berikut adalah list tool yang kami gunakan untuk membuat program
KOMPONEN
PROPERTIES
KETERANGAN
Form 1
Name
Text
Form1
Kalkulator
Timer1
Name
Timer1
TextBox 1
Name
Text
TextBox1
0
TextBox 2
Name
Text
TextBox2
0
TextBox 3
Name
Text
TextBox3
0
TextBox 4
Name
Text
TextBox4

TextBox 5
Name
Text
TextBox5

Label 1
Name
Text
Label1
YOUR TRY
Label 2
Name
Text
Label2
CREDIT
Button 1
Name
Text
Button1
START
Button 2
Name
Text
Button2
STOP
Button 3
Name
Text
Button3
SELESAI
Form 2
Name
Text
Form2

Label 1
Name
Text
Label1
KASIHAAANNNN!!!!
Button 1
Name
Text
Button1
COBA LAGI
Button 2
Name
Text
Button2
SELESAI
Form 3
Name
Text
Form 3

Label 1
Name
Text
Label1
MENANG NIYEE!!
Button 1
Name
Text
Button1
COBA LAGI
Button 2
Name
Text
Button2
KELUAR

Berikut ini adalah listing programnya :

Listing program untuk mengacak 10 angka pertama (0-9)
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        TextBox1.Text = Int(Rnd() * 10)
        TextBox2.Text = Int(Rnd() * 10)
        TextBox3.Text = Int(Rnd() * 10)
    End Sub


Listing program untuk menghitung jumlah ‘CREDIT’ dan ‘YOUR TRY’

Public Class Form1
    Dim kurang As Integer

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Static counter As Integer
        counter = counter + 1
        kurang = 10 - counter
        TextBox4.Text = counter
        TextBox5.Text = kurang

        If TextBox4.Text = "" Then
            TextBox4.Text = ""
            TextBox5.Text = ""
            counter = ("0")
        End If
        If TextBox4.Text = "10" Then
            TextBox5.Text = ""
            counter = "0"
            MessageBox.Show("You lost! ")
            Form2.Show()
            Timer1.Enabled = False
        End If
      
       
        TextBox1.Text = CStr(Int(Rnd() * 10))
        TextBox2.Text = CStr(Int(Rnd() * 10))
        TextBox3.Text = CStr(Int(Rnd() * 10))

        Timer1.Enabled = True
        TextBox1.Text = ""
        TextBox2.Text = ""
        TextBox3.Text = ""
    End Sub

Listing program untuk menghentikan putaran atau acakan angka

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Timer1.Enabled = False
        If (TextBox2.Text = TextBox1.Text) Or (TextBox1.Text = TextBox3.Text) Or (TextBox2.Text = TextBox3.Text) Then
            MsgBox("YOU WIN!")
            Form3.Show()
        End If
    

    End Sub

Listing program untuk keluar dari permainan

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

Listing program untuk mencoba kembali saat sudah kalah bermain

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Form1.Show()
        Me.Hide()
        Form1.Timer1.Enabled = False
        Form1.TextBox1.Text = "0"
        Form1.TextBox2.Text = "0"
        Form1.TextBox3.Text = "0"
        Form1.TextBox4.Text = ""
        Form1.TextBox5.Text = ""
    End Sub

Listing program untuk mencoba kembali bermain saat sudah berhasil menang

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Form1.Show()
        Me.Hide()
        Form1.Timer1.Enabled = False
        Form1.TextBox1.Text = "0"
        Form1.TextBox2.Text = "0"
        Form1.TextBox3.Text = "0"
        Form1.TextBox4.Text = ""
        Form1.TextBox5.Text = ""
     
    End Sub




Listing program untuk menunjukan petunjuk permainan
  
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        Form4.Show()
    End Sub

Listing program untuk kembali ke form sebelumnya


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Form1.Show()
        Me.Hide()

    End Sub

Program Puzzle Angka


Analisis Listing Program Puzzle Angka

Form 1
   Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Form2.Show()
        Me.Hide()
        Dim a(8), i, j, RN As Integer
        Dim jalan As Boolean

        jalan = False
        i = 1
        a(j) = 1

        Do While i <= 8
            Randomize()
            RN = CInt(Int((8 * Rnd()) + 1))
            For j = 1 To i
                If (a(j) = RN) Then
                    jalan = True
                    Exit For
                End If
            Next
            If jalan = True Then
                jalan = False
            Else
                a(i) = RN
                i = i + 1
            End If
        Loop
        Form2.Button1.Text = a(1)
        Form2.Button2.Text = a(2)
        Form2.Button3.Text = a(3)

        Form2.Button4.Text = a(4)
        Form2.Button5.Text = a(5)
        Form2.Button6.Text = a(6)

        Form2.Button7.Text = a(7)
        Form2.Button8.Text = a(8)
        Form2.Button9.Text = ""
    End Sub
Ø  Menunjukan bahwa apabila kita mengklik tombol start, maka puzzle angka pada form selanjutnya akan randomize dan melanjutkan ke form selanjutnya
Form2
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        CheckButton(Button1, Button2)
        CheckButton(Button1, Button4)

        CheckSolved()
    End Sub
Ø  Listing ini menunjukan jika puzzle angka diklik maka akan pindah ke button lainnya (berlaku untuk button lainnya)

   Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click
        Dim x = MsgBox("Are you sure want to exit?", vbYesNo + vbQuestion)
        If (x = Windows.Forms.DialogResult.No) Then
            Me.Show()
        Else
            Me.Close()
            Solve_the_Puzzle.Close()

        End If


    End Sub
Ø  Menunjukan apabila kita mengklik tombol exit, maka akan muncul messagebox (yes dan no)

    Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click
        Dim a(8), i, j, RN As Integer
        Dim jalan As Boolean

        jalan = False
        i = 1
        a(j) = 1

        Do While i <= 8
            Randomize()
            RN = CInt(Int((8 * Rnd()) + 1))
            For j = 1 To i
                If (a(j) = RN) Then
                    jalan = True
                    Exit For
                End If
            Next
            If jalan = True Then
                jalan = False
            Else
                a(i) = RN
                i = i + 1
            End If
        Loop
        Button1.Text = a(1)
        Button2.Text = a(2)
        Button3.Text = a(3)

        Button4.Text = a(4)
        Button5.Text = a(5)
        Button6.Text = a(6)

        Button7.Text = a(7)
        Button8.Text = a(8)
        Button9.Text = ""

    End Sub
Ø  Maksudnya agar kita dapat mengacak kembali puzzlenya
Form3
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        TextBox1.Clear()
    End Sub
Ø  Menunjukan apabila kita mengklik tombol clear maka textbox akan clear dari tulisan

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Form4.Show()
        Me.Hide()

    End Sub
Ø  Menunjukan jika kita mengklik ok maka akan muncul form selanjutnya

Form4
Private Sub Form4_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Label2.Text = Form3.TextBox1.Text
    End Sub
Ø  Menunjukan bahwa teks pada label2 sama dengan teks pada textbox1 di form sebelumnya

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Form2.Show()
        Me.Close()

        Form2.Show()
        Me.Hide()


    End Sub
Ø  Menjelaskan bahwa apabila kita mengklik tombol replay, maka akan kembali ke form puzzle

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim x = MsgBox("Are you sure want to exit?", vbYesNo + vbQuestion)
        If (x = Windows.Forms.DialogResult.No) Then
            Me.Show()
        Else
            Me.Close()
            Solve_the_Puzzle.Close()
        End If
    End Sub
Ø  Menunjukan apabila kita mengklik tombol exit, maka akan muncul messagebox(yes dan no)

   FLOWCHART

untuk mendownload program, klik disini