Sedikit ulasan tentang pembuatan game sederhana visual basic langsung deh pertama kita buat dulu form yang didalamnya terdapat :
- 4Buah Label
- 3Buah Command Button
- 1Buah Timer
Untuk properti nggak usah dirubah juga nggak apa apa ,tapi kalau mau silahkan atur sebagian sudah ada pada source codenya, jadi kalau Caption label atau Command Button mau di edit langsung pada source codenya
Copy aja source codenya nih
Private Sub
Command1_Click()
Command1.Caption = "Stop"
Command2.Enabled = False
Command3.Enabled = False
Timer1.Enabled = Not Timer1.Enabled
If Timer1.Enabled = False Then
Command1.Caption = "Spin"
Command2.Enabled = True
Command3.Enabled = True
If (Label1.Caption = Label2.Caption) Or (Label1.Caption = Label3.Caption) Or (Label2.Caption = Label3.Caption) Then
MsgBox "You win !!", vbInformation
End If
End If
End Sub
Private Sub Command2_Click()
Label1.Caption = "1"
Label2.Caption = "2"
Label3.Caption = "3"
End Sub
Private Sub Command3_Click()
Do Until Form1.Top >= Screen.Height
Form1.Top = Form1.Top + 1
Loop
End
End Sub
Private Sub Timer1_Timer()
Label1.Caption = Int(Rnd * 10)
Label2.Caption = Int(Rnd * 10)
Label3.Caption = Int(Rnd * 10)
End Sub
Private Sub Form_Load()
Me.Height = 4500
Me.Width = 4700
Me.Caption = "mnoor2fam.bolgspot.com - game"
Randomize
Timer1.Interval = 100
Timer1.Enabled = False
Label1.Caption = "1"
Label1.BorderStyle = 1
Label1.Font = "courier new"
Label1.FontBold = True
Label1.Alignment = 2
Label1.FontSize = "26"
Label1.Height = 855
Label1.Top = 480
Label1.Width = 975
Label1.Left = 300
Label2.Caption = "2"
Label2.BorderStyle = 1
Label2.Font = "courier new"
Label2.FontBold = True
Label2.FontSize = "26"
Label2.Alignment = 2
Label2.Height = 855
Label2.Top = 480
Label2.Width = 975
Label2.Left = 1800
Label3.Caption = "3"
Label3.BorderStyle = 1
Label3.Font = "courier new"
Label3.Alignment = 2
Label3.FontBold = True
Label3.FontSize = "26"
Label3.Height = 855
Label3.Top = 480
Label3.Width = 975
Label3.Left = 3300
Label4.Caption = "Anda menang bila minimal 2 kotak ber-angka sama. Properti yang lain, edit sendiri ya..."
Label4.Height = 500
Label4.Width = 4000
Label4.Left = 200
Command1.Caption = "spin"
Command1.Left = 500
Command1.Height = 495
Command1.Top = 2280
Command1.Width = 800
Command2.Caption = "reset"
Command2.Left = 2000
Command2.Height = 495
Command2.Top = 2280
Command2.Width = 800
Command3.Caption = "quit"
Command3.Left = 3500
Command3.Height = 495
Command3.Top = 2280
Command3.Width = 800
End Sub
Command1.Caption = "Stop"
Command2.Enabled = False
Command3.Enabled = False
Timer1.Enabled = Not Timer1.Enabled
If Timer1.Enabled = False Then
Command1.Caption = "Spin"
Command2.Enabled = True
Command3.Enabled = True
If (Label1.Caption = Label2.Caption) Or (Label1.Caption = Label3.Caption) Or (Label2.Caption = Label3.Caption) Then
MsgBox "You win !!", vbInformation
End If
End If
End Sub
Private Sub Command2_Click()
Label1.Caption = "1"
Label2.Caption = "2"
Label3.Caption = "3"
End Sub
Private Sub Command3_Click()
Do Until Form1.Top >= Screen.Height
Form1.Top = Form1.Top + 1
Loop
End
End Sub
Private Sub Timer1_Timer()
Label1.Caption = Int(Rnd * 10)
Label2.Caption = Int(Rnd * 10)
Label3.Caption = Int(Rnd * 10)
End Sub
Private Sub Form_Load()
Me.Height = 4500
Me.Width = 4700
Me.Caption = "mnoor2fam.bolgspot.com - game"
Randomize
Timer1.Interval = 100
Timer1.Enabled = False
Label1.Caption = "1"
Label1.BorderStyle = 1
Label1.Font = "courier new"
Label1.FontBold = True
Label1.Alignment = 2
Label1.FontSize = "26"
Label1.Height = 855
Label1.Top = 480
Label1.Width = 975
Label1.Left = 300
Label2.Caption = "2"
Label2.BorderStyle = 1
Label2.Font = "courier new"
Label2.FontBold = True
Label2.FontSize = "26"
Label2.Alignment = 2
Label2.Height = 855
Label2.Top = 480
Label2.Width = 975
Label2.Left = 1800
Label3.Caption = "3"
Label3.BorderStyle = 1
Label3.Font = "courier new"
Label3.Alignment = 2
Label3.FontBold = True
Label3.FontSize = "26"
Label3.Height = 855
Label3.Top = 480
Label3.Width = 975
Label3.Left = 3300
Label4.Caption = "Anda menang bila minimal 2 kotak ber-angka sama. Properti yang lain, edit sendiri ya..."
Label4.Height = 500
Label4.Width = 4000
Label4.Left = 200
Command1.Caption = "spin"
Command1.Left = 500
Command1.Height = 495
Command1.Top = 2280
Command1.Width = 800
Command2.Caption = "reset"
Command2.Left = 2000
Command2.Height = 495
Command2.Top = 2280
Command2.Width = 800
Command3.Caption = "quit"
Command3.Left = 3500
Command3.Height = 495
Command3.Top = 2280
Command3.Width = 800
End Sub
Kalau di Run hasilnya kaya gini kalau saya yang bikin
Dah dulu ah... cape
Selamat mencoba ya.......
Good Luck


Tidak ada komentar:
Posting Komentar