ini ada source yang lebih mudah, mudah-mudahan kamu ngerti
Tampilan Game
Object yang di butuhkan
1 Buah Form
Beri nama : frmSulap
1 Buah Timer
Beri nama : Timer2
Ubah Interval Timer = 1000
1 Buah Modul
Beri nama : Module1
Listing Form [frmSulap]
Listing Modul [Module1]
Credit by Jun-Qz N3
1 Buah Form
Beri nama : frmSulap
1 Buah Timer
Beri nama : Timer2
Ubah Interval Timer = 1000
1 Buah Modul
Beri nama : Module1
Listing Form [frmSulap]
Dim Bagian As Byte, Nilai% Private Sub cmdNo_Click() If Bagian = 1 Then Unload Me ElseIf Bagian = 2 Then Bagian = 3 Pic(1).Visible = False Pic(2).Visible = True ElseIf Bagian = 3 Then Bagian = 4 Pic(2).Visible = False Pic(3).Visible = True ElseIf Bagian = 4 Then Bagian = 5 Pic(3).Visible = False Pic(4).Visible = True ElseIf Bagian = 5 Then Bagian = 6 Pic(4).Visible = False Pic(5).Visible = True ElseIf Bagian = 6 Then Bagian = 7 Pic(5).Visible = False Pic(6).Visible = True ElseIf Bagian = 7 Then Bagian = 8 Pic(6).Visible = False picNilai.Visible = True picBar.Visible = True tmrProgress.Enabled = True ElseIf Bagian = 8 Then Unload Me CloseWMP End If End Sub Private Sub cmdYes_Click() If Bagian = 1 Then Bagian = 2 Pic(0).Visible = False Pic(1).Visible = True lblKeterangan.Caption = "Apakah " & _"angka yang Anda pilih ada " & _"di kotak? Jika ada klik Yes" ElseIf Bagian = 2 Then Bagian = 3: Nilai = 1 Pic(1).Visible = False Pic(2).Visible = True ElseIf Bagian = 3 Then Bagian = 4: Nilai = Nilai + 2 Pic(2).Visible = False Pic(3).Visible = True ElseIf Bagian = 4 Then Bagian = 5: Nilai = Nilai + 4 Pic(3).Visible = False Pic(4).Visible = True ElseIf Bagian = 5 Then Pic(4).Visible = False Bagian = 6: Nilai = Nilai + 8 Pic(5).Visible = True ElseIf Bagian = 6 Then Bagian = 7: Nilai = Nilai + 16 Pic(5).Visible = False Pic(6).Visible = True ElseIf Bagian = 7 Then Bagian = 8: Nilai = Nilai + 32 Pic(6).Visible = False picNilai.Visible = True picBar.Visible = True tmrProgress.Enabled = True ElseIf Bagian = 8 Then Pic(0).Visible = True Me.tmrProgress.Enabled = False Me.tmrUlang.Enabled = False Bagian = 1: Nilai = 0 End If End Sub Private Sub Form_Load() Call WMPBagian = 1: Nilai = 0 End Sub Private Sub Form_Unload(Cancel As Integer) CloseWMP End Sub Private Sub Timer1_Timer() ServiceBackgroundMusic "WMP" End Sub Private Sub tmrProgress_Timer() Me.cmdYes.Enabled = False Me.cmdNo.Enabled = False Me.picBar.Visible = True Me.picProgress.Move 0, 0, picProgress.Width + 1, picProgress.Height Me.cmdNilai.Caption = Int(Rnd * 63) Me.lblKeterangan.Caption = "Angka yang Anda pilih..." If picProgress.Width >= picBar.ScaleWidth Then Me.picBar.Visible = False Me.picProgress.Width = 0 Me.tmrProgress.Enabled = False Me.cmdNilai.Caption = Nilai Me.tmrUlang.Enabled = True End If End Sub Private Sub tmrUlang_Timer() Me.picNilai.Visible = False lblKeterangan.Caption = "Mau mengulang?" Me.cmdYes.Enabled = True Me.cmdNo.Enabled = True End Sub
Listing Modul [Module1]
Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" _(ByVal lpstrCommand As String, _ByVal lpstrReturnString As String, _ByVal uReturnLength As Long, _ByVal hwndCallback As Long) As Long Sub WMP() mciSendString "open WMP.wav alias WMP", 0&, 0, 0 mciSendString "play WMP from 0", 0&, 0, 0 End Sub Sub CloseWMP() mciSendString "stop WMP", 0&, 0, 0 mciSendString "close WMP", 0&, 0, 0 End Sub Sub ServiceBackgroundMusic(Identifier As String) Dim rt As Long Dim Status As String Status = " " rt = mciSendString("STATUS " & Identifier & " MODE", Status, Len(Status), 0) If rt = 0 Then Status = Trim$(Status) If Left(UCase$(Status), Len("STOPPED")) = "STOPPED" Then mciSendString "PLAY " & Identifier & " FROM 0", "", 0, 0 End If End If End Sub
No comments:
Post a Comment
Jika masih bingung atau apa dengan artikel ini, bisa langsung comment di bawah ini :)