作者ray60216 (咪鲁)
看板Visual_Basic
标题[VB2005]打地鼠游戏的问题
时间Wed Dec 29 18:33:27 2010
我想请问一下
我有三张图片 希望能在游戏中随机显示这三张图片 请问程式要怎麽改?
麻烦大大帮我解答 谢谢
以下是我写的程式
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