vb - contoh game sederhana


Untuk bisa memainkan game ini, anda perlu membuat :

- empat buah label
- tiga buah command button
- sebuah timer

properties - nya ga usah diubah - ubah juga gax pa pa dah......

Masukkan source code di bawah ini pada tempatnya masing - masing.
Kalau input - nya tepat, pasti game ini bisa dimainkan....hixhixhix

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 = "nainora.awardspace.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

0 comments:

Post a Comment