这个一个打地鼠的游戏,代码如下:(谁能帮我看看,现在整个能运行了,但是窗体显示的却没有地鼠,请高手指导,我到底哪错了?)

zhecaishiwo 2003-12-09 03:53:18
这个一个打地鼠的游戏,代码如下:(谁能帮我看看,现在整个能运行了,但是窗体显示的却没有地鼠,请高手指导,我到底哪错了?)
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
...全文
88 点赞 收藏 10
写回复
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
vbcainiao 2004-03-26
哪个有这个源代码啊,这个代码有错误啊
回复
xmzorro 2003-12-16
到这里给分吧!
http://expert.csdn.net/Expert/TopicView2.asp?id=2544849&datebasetype=now
回复
sysmaster 2003-12-15
在VB中可以用中文名,不过以后程序的可移植性就不高了!
回复
zhecaishiwo 2003-12-15
对,对,中文怎么了?能运行出来最重要,这里的部分人很横的,我不敢惹,他们都是高手.
回复
zmrok 2003-12-13
楼上的,谁说不可用中文做变量?请不要戴有色眼镜看,好不好!
回复
zhecaishiwo 2003-12-13
我刚到这个BBS,不懂这的情况,怎么样才能给你分,为什么这么多人都要分呢?分高能做什么?

能告诉我吗?
回复
xmzorro 2003-12-12
怎么不给分数?
回复
ucme 2003-12-10
建议你去用易语言,你的代码真的贻笑大方啊,哪有人用中文做变量的
回复
zhecaishiwo 2003-12-10
谢谢,你的程序,我去试试.
回复
xmzorro 2003-12-09
完全版:希望对你有帮助!
VERSION 5.00
Begin VB.Form Form1
AutoRedraw = -1 'True
BackColor = &H00004080&
BorderStyle = 1 'Fixed Single
Caption = "地鼠娱乐部"
ClientHeight = 5055
ClientLeft = 150
ClientTop = 435
ClientWidth = 5610
ClipControls = 0 'False
FillColor = &H00008000&
BeginProperty Font
Name = "楷体_GB2312"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00008000&
Icon = "地鼠娱乐部1.0.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
ScaleHeight = 5055
ScaleWidth = 5610
StartUpPosition = 2 '屏幕中心
Begin VB.Timer Timer1
Enabled = 0 'False
Interval = 700
Left = 90
Top = 585
End
Begin VB.Label Label2
Alignment = 1 'Right Justify
BackStyle = 0 'Transparent
Caption = "鼠标进入画面开始"
BeginProperty Font
Name = "楷体_GB2312"
Size = 14.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = -1 'True
Strikethrough = 0 'False
EndProperty
ForeColor = &H0000FFFF&
Height = 285
Left = 2835
TabIndex = 1
Top = 4680
Width = 2715
End
Begin VB.Label Label1
BackStyle = 0 'Transparent
BorderStyle = 1 'Fixed Single
Caption = "得分"
BeginProperty Font
Name = "楷体_GB2312"
Size = 14.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = -1 'True
Strikethrough = 0 'False
EndProperty
ForeColor = &H0000FFFF&
Height = 345
Left = 45
TabIndex = 0
Top = 120
Width = 2280
End
Begin VB.Image Image6
Height = 1050
Left = 2280
Picture = "地鼠娱乐部1.0.frx":7BBA
Top = 3000
Visible = 0 'False
Width = 1050
End
Begin VB.Image Image5
Height = 1050
Left = 2280
Picture = "地鼠娱乐部1.0.frx":B5F4
Top = 1920
Visible = 0 'False
Width = 1050
End
Begin VB.Image Image4
Height = 1050
Left = 2280
Picture = "地鼠娱乐部1.0.frx":F02E
Top = 840
Visible = 0 'False
Width = 1050
End
Begin VB.Image Image3
Height = 1500
Left = 135
Picture = "地鼠娱乐部1.0.frx":12A68
Top = 1260
Visible = 0 'False
Width = 1500
End
Begin VB.Image Image2
Height = 1500
Left = 810
Picture = "地鼠娱乐部1.0.frx":1A622
Top = 630
Visible = 0 'False
Width = 1500
End
Begin VB.Image Image1
Height = 1500
Left = 3480
MouseIcon = "地鼠娱乐部1.0.frx":221DC
MousePointer = 99 'Custom
Picture = "地鼠娱乐部1.0.frx":224E6
Top = 1305
Width = 1500
End
Begin VB.Menu 帮助
Caption = "地鼠帮助(&H)"
Begin VB.Menu 关于
Caption = "关于地鼠娱乐部(&A)"
End
Begin VB.Menu 使用
Caption = "使用(&R)"
End
End
Begin VB.Menu 发生
Caption = "游戏"
Begin VB.Menu nend
Caption = "退出"
Index = 1
End
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim 鼠X As Single, 鼠Y As Single, 地鼠 As Byte, 对数 As Integer, 总数 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 = 地鼠 - 6
Y = 2
End Select
End Sub
Private Sub Form_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_MouseMove(Button 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 = Image1.Top
Timer1.Enabled = True
Label2.Caption = "运行中..."
End Sub
Private Sub Image1_MouseDown(Button 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_MouseMove(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(Button As Integer, Shift As Integer, X As Single, Y As Single)
Image1.Picture = Image2.Picture
End Sub

Private Sub nend_Click(Index As Integer)
End
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 Image4.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
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
回复
发动态
发帖子
VB基础类
创建于2007-09-28

7451

社区成员

VB 基础类
申请成为版主
社区公告
暂无公告