• 主页

# 这个一个打地鼠的游戏，代码如下：（谁能帮我看看，现在整个能运行了，但是窗体显示的却没有地鼠，请高手指导，我到底哪错了？）

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
Randomize
Show
Print
For 地鼠 = 0 To 8

Form1.PaintPicture Image5.Picture, 1000 + 1050 * x, 1000 + 1050 * y
Next

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

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

Label1.Caption = "打中次数 ：“ & 对数"

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)

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()

Form1.PaintPicture Image5.Picture, 1000 + 1050 * x, 1000 + 1050 * y

Form1.PaintPicture imge4.Picture, 1000 + 1050 * x, 1000 + 1050 * y
If 总数 > 100 Then
Timer1.Enabled = False

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

Timer1.Enabled = True
Else
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

zhecaishiwo 2003-12-15

zmrok 2003-12-13

zhecaishiwo 2003-12-13

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
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
Caption = "地鼠帮助(&H)"
Caption = "关于地鼠娱乐部(&A)"
End
Caption = "使用(&R)"
End
End
Caption = "游戏"
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
Randomize
Show
Print
For 地鼠 = 0 To 8

Form1.PaintPicture Image5.Picture, 1000 + 1050 * X, 1000 + 1050 * Y
Next

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

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

Label1.Caption = "打中次数 :" & 对数

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)

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()

Form1.PaintPicture Image5.Picture, 1000 + 1050 * X, 1000 + 1050 * Y

Form1.PaintPicture Image4.Picture, 1000 + 1050 * X, 1000 + 1050 * Y
If 总数 > 100 Then
Timer1.Enabled = False

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

Timer1.Enabled = True
Else
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基础类

7451

VB 基础类