打小地鼠

作者在 2011-04-09 10:11:13 发布以下内容
打小地鼠
     我是一个菜鸟,对程序还是不怎么了解,做了一个小游戏大家参考参考
 
Public Class 打小地鼠
Dim rnd As New Random()
Dim leter As New Random()
Dim num, num1, time, time1, mark As Integer
Dim a As String
Dim time2 As Integer = 2
Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
RadioButton2.Checked = False
RadioButton3.Checked = False
time2 = 3
End Sub

Private Sub RadioButton3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton3.CheckedChanged
RadioButton1.Checked = False
RadioButton2.Checked = False
time2 = 1
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Timer1.Enabled = True
TextBox1.Clear()
TextBox2.Clear()
TextBox1.Focus()
time = 0
time1 = 0
End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
a = TextBox1.Text.ToUpper
time += 1
time1 += 1
If time1 < 120 Then
If a = Chr(num) Then
mark += 1
TextBox2.Text = mark
End If
If time = time2 Or a = Chr(num) Then
num = rnd.Next(65, 90)
num1 = leter.Next(0, 10)
If num1 = 1 Or num1 = 0 Then
Label1.Text = Chr(num)
Label2.Text = "*"
Label3.Text = "*"
Label4.Text = "*"
Label5.Text = "*"
Label6.Text = "*"
Label7.Text = "*"
Label8.Text = "*"
Label9.Text = "*"
If a = (Label1.Text) Then
mark += 1
TextBox2.Text = mark
End If
End If
If num1 = 2 Then
Label2.Text = Chr(num)
Label1.Text = "*"
Label3.Text = "*"
Label4.Text = "*"
Label5.Text = "*"
Label6.Text = "*"
Label7.Text = "*"
Label8.Text = "*"
Label9.Text = "*"
If a = (Label2.Text) Then
mark += 1
TextBox2.Text = mark
End If
End If
If num1 = 3 Then
Label3.Text = Chr(num)
Label2.Text = "*"
Label1.Text = "*"
Label4.Text = "*"
Label5.Text = "*"
Label6.Text = "*"
Label7.Text = "*"
Label8.Text = "*"
Label9.Text = "*"
If a = (Label3.Text) Then
mark += 1
TextBox2.Text = mark
End If
End If
If num1 = 4 Then
Label4.Text = Chr(num)
Label2.Text = "*"
Label3.Text = "*"
Label1.Text = "*"
Label5.Text = "*"
Label6.Text = "*"
Label7.Text = "*"
Label8.Text = "*"
Label9.Text = "*"
If a = (Label4.Text) Then
mark += 1
TextBox2.Text = mark
End If
End If
If num1 = 5 Then
Label5.Text = Chr(num)
Label2.Text = "*"
Label3.Text = "*"
Label4.Text = "*"
Label1.Text = "*"
Label6.Text = "*"
Label7.Text = "*"
Label8.Text = "*"
Label9.Text = "*"
If a = (Label5.Text) Then
mark += 1
TextBox2.Text = mark
End If
End If
If num1 = 6 Then
Label6.Text = Chr(num)
Label2.Text = "*"
Label3.Text = "*"
Label4.Text = "*"
Label5.Text = "*"
Label1.Text = "*"
Label7.Text = "*"
Label8.Text = "*"
Label9.Text = "*"
If a = (Label6.Text) Then
mark += 1
TextBox2.Text = mark
End If
End If
If num1 = 7 Then
Label7.Text = Chr(num)
Label2.Text = "*"
Label3.Text = "*"
Label4.Text = "*"
Label5.Text = "*"
Label6.Text = "*"
Label1.Text = "*"
Label8.Text = "*"
Label9.Text = "*"
If a = (Label7.Text) Then
mark += 1
TextBox2.Text = mark
End If
End If
If num1 = 8 Then
Label8.Text = Chr(num)
Label2.Text = "*"
Label3.Text = "*"
Label4.Text = "*"
Label5.Text = "*"
Label6.Text = "*"
Label7.Text = "*"
Label1.Text = "*"
Label9.Text = "*"
If a = (Label8.Text) Then
mark += 1
TextBox2.Text = mark
End If
End If
If num1 = 9 Or num1 = 10 Then
Label9.Text = Chr(num)
Label2.Text = "*"
Label3.Text = "*"
Label4.Text = "*"
Label5.Text = "*"
Label6.Text = "*"
Label7.Text = "*"
Label8.Text = "*"
Label1.Text = "*"
If a = (Label9.Text) Then
mark += 1
TextBox2.Text = mark
End If
End If
time = 0
End If
TextBox1.Clear()
TextBox1.Focus()
End If
If time1 = 120 Then
Timer1.Enabled = False
MsgBox("您的得分为:" & mark, , "打小地鼠")
time1 = 0
time = 0
End If
Label10.Text = (120 - time1) & "s"
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Timer1.Enabled = False
MsgBox("您的得分为:" & mark, , "打小地鼠")
time = 0
time1 = 0
TextBox2.Clear()
Timer1.Enabled = False
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Timer1.Enabled = False
End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Timer1.Enabled = True
End Sub

End Class
这是我做的一个类似打地鼠的小游戏,大家多提意见,也挺好玩的这是图片
默认分类 | 阅读 499 次
文章评论,共0条
游客请输入验证码
文章分类
文章归档
最新评论