这个一个打地鼠的游戏,代码如下:(谁能帮我看看,现在整个能运行了,但是窗体显示的却没有地鼠,请高手指导,我到底哪错了?)
这个一个打地鼠的游戏,代码如下:(谁能帮我看看,现在整个能运行了,但是窗体显示的却没有地鼠,请高手指导,我到底哪错了?)
Dim 鼠x As Single
Dim 鼠y As Single
Dim 鼠 As Byte
Dim 对数 As Integer
Dim 总数 As Integer
Sub 判断(x, y)
Select Case 地鼠
Case 0, 1, 2
x = 地鼠
y = 0
Case 3, 4, 5
x = 地鼠 - 3
y = 1
Case 6, 7, 8
x = 地鼠 - 3
y = 1
Case 6, 7, 8
x = 地鼠 - 6
y = 2
End Select
End Sub
Private Sub form1_load()
Randomize
Show
Print
For 地鼠 = 0 To 8
判断 x, y
Form1.PaintPicture Image5.Picture, 1000 + 1050 * x, 1000 + 1050 * y
Next
总数 = 1
End Sub
Private Sub form_mouse(botton As Integer, shift As Integer, x As Single, y As Single)
Image1.Move x - Image1.Width / 2, y - Image1.Height / 2
鼠 x = Image1.Left
鼠 y = Image2.Top
Timer1.Enabled = True
Label2.Caption = "运行中..."
End Sub
Private Sub image1_mousedown(botton As Integer, shift As Integer, x As Single, y As Single)
Image1.Picture = Image3.Picture
xy = 99
If 鼠x > 800 And 鼠x < 1850 Then
If 鼠y + 1500 > 1600 And 鼠y + 1500 < 2350 Then xy = 0
If 鼠y + 1500 > 2650 And 鼠y + 1500 < 3400 Then xy = 3
If 鼠y + 1500 > 3700 And 鼠y + 1500 < 4450 Then xy = 6
End If
If 鼠x > 1850 And 鼠x < 2900 Then
If 鼠y + 1500 > 1600 And 鼠y + 1500 < 2350 Then xy = 1
If 鼠y + 1500 > 2650 And 鼠y + 1500 < 3400 Then xy = 4
If 鼠y + 1500 > 3700 And 鼠y + 1500 < 4450 Then xy = 7
End If
If 鼠x > 2900 And 鼠x < 3950 Then
If 鼠y + 1500 > 1600 And 鼠y + 1500 < 2350 Then xy = 2
If 鼠y + 1500 > 2650 And 鼠y + 1500 < 3400 Then xy = 5
If 鼠y + 1500 > 3700 And 鼠y + 1500 < 4450 Then xy = 8
End If
If 地鼠 = xy Then
对数 = 对数 + 1
Label1.Caption = "打中次数 :“ & 对数"
判断 x, y
Form1.PaintPicture Image6, Picture, 1000 + 1050 * x, 1000 + 1050 * y
End If
End Sub
Private Sub image1_mouse(button As Integer, shift As Integer, x As Single, y As Single)
Image1.Move 鼠x - (Image1.Width / 2 - x), 鼠y - (Image1.Height / 2 - y)
鼠x = Image1.Left
鼠y = Image1.Top
End Sub
Private Sub image1_mouseup(botton As Integer, shift As Integer, x As Single, y As Single)
Image1.Picture = Image2.Picture
End Sub
Private Sub timer1_timer()
总数 = 总数 + 1
判断x , y
Form1.PaintPicture Image5.Picture, 1000 + 1050 * x, 1000 + 1050 * y
地鼠 = Int(Rnd * 9)
判断 x, y
Form1.PaintPicture imge4.Picture, 1000 + 1050 * x, 1000 + 1050 * y
If 总数 > 100 Then
Timer1.Enabled = False
判断 x, y
Form1.PaintPicture Image5.Picture, 1000 + 1050 * x, 1000 + 1050 * y
If 对数 > 100 Then
msg = MsgBox("恭喜" + Chr(13) + "您已经爆机了,还要继续吗?", vbYesNo, "地鼠娱乐部")
Else
msg = MsgBox("您已经过关了,您打中了" & 对数 & "次.还要继续吗?", vbYesNo, "地鼠娱乐部")
End If
If msg = vbYes Then
总数 = 1
对数 = 0
Timer1.Enabled = True
Else
Unload Me
End If
End If
Private Sub 退出_click(index As Integer)
End
End Sub
Private Sub 关于_click()
MsgBox "地鼠娱乐部" + Chr(13) + Chr(13) + "这是一个基于windows98以上操作系统下" + Chr(13) + "用VB编写的程序", , "地鼠娱乐部"
End Sub
Private Sub 使用_click()
MsgBox "欢迎来到地鼠娱乐部", Chr(13) + "使用说明:" + Chr(13) + "鼠标左右键都可打击" + "想要能更快地打中地鼠,连续左右键," + Chr(13) + "这样能加快打地鼠的次数", , "地鼠娱乐部"
End Sub