摘要:[Visual Basic 6.0] 簡單的互動遊戲設計 打地鼠 (含倒數時間與計分)
[Visual Basic 6.0] 簡單的互動遊戲設計 打地鼠 (含倒數時間與計分)
#初始畫面
#圈圈模擬為地鼠
#圈圈模擬為地鼠
#當打中地鼠 紅圈會多黑色叉叉
Dim Inp
Private Sub Command1_Click()
Label4.Caption = 20
Label3.Caption = 0
Timer2.Enabled = True
Timer1.Enabled = True
End Sub
Private Sub Picture1_Click(Index As Integer)
If Index = Inp Then
Picture1(Index).Picture = LoadPicture(App.Path & "/B.jpg")
Label3 = Val(Label3) + 1
Inp = -1
End If
End Sub
Private Sub Timer1_Timer()
For i = 0 To 8
Picture1(i).Picture = Nothing
Next i
Inp = Int(Rnd * 8)
Picture1(Inp).Picture = LoadPicture(App.Path & "/A.jpg")
End Sub
Private Sub Timer2_Timer()
If Val(Label4) = 0 Then MsgBox "遊戲結束": Timer1.Enabled = False: Timer2.Enabled = False: Exit Sub
Label4 = Val(Label4) - 1
End Sub
#0xDe 從分享中學習
#Facebook:ProgrammerDe (https://www.facebook.com/MicrosoftDes) 有問題歡迎提問