A. KONSEP
APLIKASI GAME PUZZLE
 
Aplikasi ini
adalah sebuah permainan yang sudah terkenal di masyarakat. Aplikasi game ini dinamakan “Puzzles”. Aplikasi ini hanya
terdiri dari satu form saja. Cara kerja game ini adalah menyusun kembali urutan
angka-angka yang telah diacak sesuai dengan urutan yang benar.
          Cara
menggunakan aplikasi ini sangatlah mudah. Begitu pengguna membuka aplikasi ini,
maka form “Puzzles” akan muncul. Pengguna dapat langsung memainkan game
tersebut dengan mengklik button “Acak”. Button “Acak” berfungsi untuk mengacak
letak nomor menjadi tidak teratur. Selanjutnya, pengguna
mengklik button “Stop” untuk menghentikan proses acak letak angka. Selanjutnya,
pengguna mulai menyusun urutan angka-angka yang telah diacak dengan benar.
Pengguna cukup mengklik salah satu button angka yang ada di samping button yang
kosong (tidak memiliki angka). Jika pengguna ingin keluar dari game ini, maka
pengguna dapat mengklik button “Exit”. Jika pengguna ingin mengganti susunan
acak yang telah ada, pengguna cukup mengklik button “Acak” lalu “Stop”.
1.     
Cara menampilkan welcome form
Cara membuat
display form Jumbled Number :
1.      Bukalah
program Visual Basic 2010.
2.      Setelah
Visual Basic 2010 dibuka, maka otomatis akan muncul satu form baru yang belum
berisi.
3.      Pilihlah
Label pada kotak “Toolbox” dan kliklah pada ujung kiri atas form. Lalu pada
“Text” ketik “WELCOME”. Pada “Font”, ubahlah ukuran dan jenis huruf sesuai
dengan yang diinginkan.
4.      Untuk
mengubah background form, klik form tersebut,  pada “Properties” bagian “BackgroundImage”
pilihlah salah satu gambar dari folder computer sesuai dengan yang pengguna
inginkan.
5.      Untuk
mengubah icon, pada “Properties”
bagian icon pilihlah salah satu
gambar dengan ekstensi .ico.
6.      Untuk
membuat button “Let’s Play”, pada “Toolbox” pilihlah Button, arahkan  dan klik kursor ke bagian ujung kanan bawah
form. Pada “Properties” bagian Text ketik “Let’s Play” dan pada “Font” ubahlah
ukuran dan jenis huruf sesuai dengan yang diinginkan.
7.      Untuk
menjalankan form ini, masukkanlah listing yang ada di bawah ini sesuai dengan
button yang telah ditentukan.
Komponen toolbox yang digunakan:
| 
Form | 
Komponen | 
Properties | 
Keterangan  | 
| 
Form2 | 
Form2 | 
Name 
Text  | 
Form2 
Jumbled Text | 
| 
Label1 | 
Name 
Text  | 
Label1 
WELCOME | |
| 
Button1 | 
Name 
Text  | 
Button1 
Let’s Play | 
Public Class Form2
    Private Sub
Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
       
Me.Hide()
       
Form1.Show()
    End Sub
End Class
Listing di atas berguna jika button1 diklik, maka form
“Welcome” ini akan disembunyikan dan form selanjutnya (form 2) akan muncul.
  
2.  
Cara membuat form game
Cara menampilkan display form
Puzzles :
1.     
Pada menu “Project” pilihlah Add Windows Form. Lalu, pilih Windows Form dan klik Add.
2.     
Pada
form2, pilihlah button pada “Toolbox” dan posisikan sesuai dengan gambar.
Lakukan hal sebanyak 12 kali.
3.     
Pada
button1 ketik “1”, button2 ketik “2”, button3 ketik “3”, button4 ketik “4”,
button5 ketik “5”, button6 ketik “6”, button7 ketik “7”, button8 ketik “8”,
button10 ketik “Acak”, button11 ketik “Stop”, dan pada button12 ketik “Exit”. Khusus
pada button9 kosongkan teks.
4.      Untuk
mengubah background form, klik form tersebut,  pada “Properties” bagian “BackgroundImage”
pilihlah salah satu gambar dari folder computer sesuai dengan yang pengguna
inginkan.
5.      Untuk
mengubah icon, pada “Properties”
bagian icon pilihlah salah satu
gambar dengan ekstensi .ico.
6.     
Untuk
menjalankan fungsi-fungsi setiap button, masukkanlah listing berikut sesuai
dengan button yang benar.
Komponen toolbox yang digunakan:
| 
Form
  3 | 
Form3 | 
Name 
Text | 
Form3 
Puzzles
   | 
| 
Button1 | 
Name 
Text | 
Button1 
1 | |
| 
Button2 | 
Name 
Text | 
Button2 
2 | |
| 
Button3 | 
Name 
Text | 
Button3 
3 | |
| 
Button4 | 
Name 
Text | 
Button4 
4 | |
| 
Button5 | 
Name 
Text | 
Button5 
5 | |
| 
Button6 | 
Name 
Text | 
Button6 
6 | |
| 
Button7 | 
Name 
Text | 
Button7 
7 | |
| 
Button8 | 
Name 
Text | 
Button8 
8 | |
| 
Button9 | 
Name 
Text | 
Button9 
9 | |
| 
Button10 | 
Name 
Text | 
Button10 
Acak
   | |
| 
Button11 | 
Name 
Text | 
Button11 
Stop
   | |
| 
Button12 | 
Name 
Text | 
Button12 
Exit
   | 
Public Class Form1
    Dim place, stp As String
    Dim acak As Integer
    Dim Second As Integer
Listing di atas berguna untuk
mendeklarasikan nilai-nilai yang diinput menjadi bentuk string (String), dan
bilangan bulat (Integer).
    Private Sub Button10_Click(ByVal sender As
System.Object, ByVal
e As System.EventArgs)
Handles Button10.Click
       
Timer1.enabled = True
       
acak = Rnd() * 10
    End Sub
Listing
diatas berfungsi untuk mengacak nomor yang ada di dalam kotak kotak button.
    Private Sub
Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button11.Click
       
Timer1.Enabled = False
    End Sub
Listing diatas berfungsi untuk menghentikan
pengacakan nomor yang sedang berlangsung.
    Private Sub Button1_Click(ByVal sender As
System.Object, ByVal
e As System.EventArgs)
Handles Button1.Click
       
If Button2.Text = "" Then
           
place = Button1.Text
           
Button1.Text = Button2.Text
           
Button2.Text = place
       
ElseIf Button4.Text = "" Then
           
place = Button1.Text
           
Button1.Text = Button4.Text
           
Button4.Text = place
       
End If
    End Sub
    Private Sub
Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button2.Click
       
If Button1.Text = "" Then
           
place = Button2.Text
           
Button2.Text = Button1.Text
           
Button1.Text = place
       
ElseIf Button3.Text = "" Then
           
place = Button2.Text
           
Button2.Text = Button3.Text
           
Button3.Text = place
       
ElseIf Button5.Text = "" Then
           
place = Button5.Text
           
Button5.Text = Button2.Text
           
Button2.Text = place
       
End If
    End Sub
    Private Sub
Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button3.Click
       
If Button2.Text = "" Then
           
place = Button3.Text
           
Button3.Text = Button2.Text
           
Button2.Text = place
       
ElseIf Button6.Text = "" Then
           
place = Button3.Text
           
Button3.Text = Button6.Text
           
Button6.Text = place
       
End If
    End Sub
    Private Sub
Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button4.Click
       
If Button1.Text = "" Then
           
place = Button4.Text
           
Button4.Text = Button1.Text
           
Button1.Text = place
       
ElseIf Button5.Text = "" Then
           
place = Button4.Text
           
Button4.Text = Button5.Text
           
Button5.Text = place
       
ElseIf Button7.Text = "" Then
            place = Button4.Text
           
Button4.Text = Button7.Text
           
Button7.Text = place
       
End If
    End Sub
    Private Sub
Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button5.Click
       
If Button2.Text = "" Then
           
place = Button5.Text
           
Button5.Text = Button2.Text
           
Button2.Text = place
       
ElseIf Button4.Text = "" Then
           
place = Button5.Text
           
Button5.Text = Button4.Text
           
Button4.Text = place
       
ElseIf Button6.Text = "" Then
           
place = Button5.Text
           
Button5.Text = Button6.Text
           
Button6.Text = place
       
ElseIf Button8.Text = "" Then
           
place = Button5.Text
           
Button5.Text = Button8.Text
           
Button8.Text = place
       
End If
    End Sub
    Private Sub
Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button6.Click
       
If Button3.Text = "" Then
       
    place = Button6.Text
           
Button6.Text = Button3.Text
           
Button3.Text = place
       
ElseIf Button5.Text = "" Then
           
place = Button6.Text
           
Button6.Text = Button5.Text
           
Button5.Text = place
       
ElseIf Button9.Text = "" Then
           
place = Button6.Text
           
Button6.Text = Button9.Text
           
Button9.Text = place
       
End If
    End Sub
    Private Sub
Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button7.Click
       
If Button4.Text = "" Then
           
place = Button7.Text
           
Button7.Text = Button4.Text
           
Button4.Text = place
       
ElseIf Button8.Text = "" Then
           
place = Button7.Text
           
Button7.Text = Button8.Text
           
Button8.Text = place
       
End If
    End Sub
    Private Sub
Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button8.Click
       
If Button7.Text = "" Then
        
   place = Button8.Text
           
Button8.Text = Button7.Text
           
Button7.Text = place
       
ElseIf Button5.Text = "" Then
           
place = Button8.Text
           
Button8.Text = Button5.Text
           
Button5.Text = place
       
ElseIf Button9.Text = "" Then
           
place = Button8.Text
           
Button8.Text = Button9.Text
           
Button9.Text = place
       
End If
    End Sub
    Private Sub
Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button9.Click
       
If Button6.Text = "" Then
           
place = Button9.Text
           
Button9.Text = Button6.Text
           
Button6.Text = place
       
ElseIf Button8.Text = "" Then
           
place = Button9.Text
           
Button9.Text = Button8.Text
           
Button8.Text = place
 If Button1.Text = "1" And Button2.Text = "2" And Button3.Text = "3" And Button4.Text = "4" And Button5.Text = "5" And Button6.Text = "6" And Button7.Text = "7" And Button8.Text = "8" Then
MessageBox.Show("Congrulation")
End If
Listing di atas (Button9) berguna jika button-button yang lain telah sesuai dengan urutan teks yang ada (1-8), maka akan muncul messagebox yang mengatakan "Congrulation".
MessageBox.Show("Congrulation")
End If
Listing di atas (Button9) berguna jika button-button yang lain telah sesuai dengan urutan teks yang ada (1-8), maka akan muncul messagebox yang mengatakan "Congrulation".
       
End If
    End Sub
    Private Sub
Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Timer1.Tick
       
place = Button9.Text
       
Button9.Text = Button4.Text
       
Button4.Text = place
       
place = Button9.Text
       
Button9.Text = Button3.Text
       
Button3.Text = place
       
place = Button2.Text
       
Button2.Text = Button7.Text
       
Button7.Text = place
       
place = Button2.Text
       
Button2.Text = Button6.Text
       
Button6.Text = place
       
place = Button3.Text
       
Button3.Text = Button8.Text
       
Button8.Text = place
       
place = Button3.Text
       
Button3.Text = Button1.Text
       
Button1.Text = place
       
place = Button5.Text
       
Button5.Text = Button8.Text
       
Button8.Text = place
       
place = Button5.Text
       
Button5.Text = Button7.Text
       
Button7.Text = place
       
place = Button6.Text
      
 Button6.Text = Button1.Text
       
Button1.Text = place
    End Sub
Listing
diatas berfungsi untuk memfungsikan button1 – button 9 supaya dapat berpindah
ketika di ‘klik’ sesuai yang diinginkan.
  Private Sub
Button12_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button12.Click
       
Response = MsgBox("Do you want to
Exit?", vbYesNo, "Exit")
       
If Response = vbYes Then
           
Me.Hide()
       
Else 'do nothing
       
End If
    End Sub
Listing
diatas berfungsi untuk memunculkan message box “do you want to exit?” ketika
mengeklik “exit”. dan jika pengguna mengklik "Yes", maka aplikasi akan ditutup. namun, jika pengguna mengklik "No", maka aplikasi tidak akan tertutup dan pengguna dapat bermain kembali.
    Private Sub
Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
MyBase.Load
    End Sub
End Class
C. Flowchart
 



 
0 Response to "Konsep, Analisis, dan Flowchart Aplikasi Jumbled Number"
Posting Komentar