Advertisement
Tony041010

打地鼠

Jul 6th, 2021
450
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Private Sub Command1_Click()
  2.     Timer1.Interval = 800  '時鐘1,控制地鼠跳動
  3.    Timer2.Interval = 1000 '時鐘2,控制遊戲時間
  4.    Label1.Caption = 0   '得分歸零
  5.    If Text1.Text = Empty Then
  6.         Label2 = 10
  7.     Else
  8.         Label2 = Int(Text1)
  9.     End If
  10.    
  11. End Sub
  12.  
  13. Private Sub Image1_Click(Index As Integer)
  14.     'index會傳回()後面的數字,比如左上角那塊0,中上1,右上2,其餘依此類推
  15.    If Timer1.Interval = 0 Or Timer2.Interval = 0 Then
  16.     Else
  17.         If Image1(Index).Picture = Image3.Picture Then
  18.             Label1 = Label1 + 1
  19.         Else
  20.             Label1 = Label1 - 1
  21.         End If
  22.     End If
  23. End Sub
  24.  
  25. Private Sub Option1_Click()
  26.     Timer1.Interval = 800
  27. End Sub
  28.  
  29. Private Sub Option2_Click()
  30.     Timer1.Interval = 500
  31. End Sub
  32.  
  33. Private Sub Option3_Click()
  34.     Timer1.Interval = 300
  35. End Sub
  36.  
  37. Private Sub Timer1_Timer()  '控制地鼠出沒
  38.    '清除地鼠
  39.    For i = 0 To 8
  40.         Image1(i).Picture = Image2.Picture
  41.     Next
  42.    
  43.     '亂數產生地鼠
  44.    Image1(Int(Rnd * 9)).Picture = Image3.Picture
  45. End Sub
  46.  
  47. Private Sub Timer2_Timer()
  48.     Label2 = Label2 - 1
  49.         If Label2 = 0 Then
  50.         Timer1.Interval = 0
  51.         Timer2.Interval = 0
  52.     End If
  53. End Sub
  54.  
Advertisement
RAW Paste Data Copied
Advertisement