用VB.NET做的小游戏--打地鼠
Public Class Form1
Inherits System.Windows.Forms.Form
Dim pic As New PictureBox
Dim goal As Integer
Dim i As Integer
Dim j As Integer
Dim xx1() As Integer = {135, 277, 417}
Dim xx2() As Integer = {157, 367}
Dim xx3() As Integer = {32, 251, 482}
Dim timer As Double = 1
Dim count As Integer '计时器跳动次数
Dim ifclick As Boolean
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Text = "小游戏"
Me.Size = New Size(650, 465)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Timer1.Interval = 600
Timer1.Enabled = True
Button2.Visible = True
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If Button2.Text = "暂停" Then
Button2.Text = "继续"
Timer1.Enabled = False
PictureBox1.Enabled = False
ElseIf Button2.Text = "继续" Then
Button2.Text = "暂停"
Timer1.Enabled = True
PictureBox1.Enabled = True
End If
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Me.Close()
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
ifclick = False
PictureBox1.Enabled = True
If timer = 0 Then
Timer1.Enabled = False
MsgBox("游戏结束,您的得分:" + goal.ToString)
Button3.Visible = False
Exit Sub
End If
addpic()
timer = 10 - count * 0.5
1