[VB2005]打地鼠遊戲的問題
我想請問一下
我有三張圖片 希望能在遊戲中隨機顯示這三張圖片 請問程式要怎麼改?
麻煩大大幫我解答 謝謝
以下是我寫的程式
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Randomize()
Timer1.Start()
Timer2.Start()
Label1.Text = "分數=0"
Label2.Text = "時間=0"
S = 0
T = 30
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Timer1.Tick
M1.Visible = False : M2.Visible = False : M3.Visible = False
M4.Visible = False : M5.Visible = False : M6.Visible = False
Dim i As Integer = Int(Rnd() * 6) + 1
Dim M As Label = Controls("M" + i.ToString)
M.Image = My.Resources.未命名
M.Enabled = True
M.Visible = True
Timer1.Interval = 1000
End Sub
Private Sub M1_MouseDown(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles M1.MouseDown, M2.MouseDown,
M3.MouseDown, M4.MouseDown, M5.MouseDown, M6.MouseDown
sender.image = My.Resources.boom
sender.enabled = False
S += 1
Label1.Text = "分數=" + S.ToString
End Sub
Dim S As Integer = 0
Dim T As Integer = 30
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Timer2.Tick
T -= 1
Label2.Text = "時間=" + T.ToString
If T = 0 Then
Timer1.Stop()
Timer2.Stop()
MsgBox("Game over! You got " + S.ToString + " points.")
End If
End Sub
End Class
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 220.134.181.170