大神快来 如何使用vb制作一个简单的打地鼠游戏?最好用教程
发布网友
发布时间:2022-04-23 21:44
我来回答
共1个回答
热心网友
时间:2022-05-03 11:10
1、控件:
picture1(0~8)
排三列三排
timer1
interval设为1000
text1
text
设为0
command1
caption
设为“开始”
2、代码:
private
declare
sub
sleep
lib
"kernel32"
(byval
dwmilliseconds
as
long)
dim
m,
i,
n
as
integer
private
sub
form_load()
timer1.enabled
=
false
for
l
=
0
to
8
picture1(l).visible
=
false
next
l
end
sub
private
sub
command1_click()
timer1.enabled
=
true
end
sub
private
sub
timer1_timer()
if
i
<
9
then
picture1(i).visible
=
false
end
if
randomize
i
=
(rnd()
*
8)
mod
10
picture1(i).visible
=
true
picture1(i).zorder
if
n
=
10
then
picture1(i).visible
=
false
if
text1
>=
80
then
m
=
m
+
1
c
=
msgbox("恭喜你过关了。你的得分为"
text1
vbcrlf
"是否进入"
m
+
1
"关",
4)
if
c
=
vbyes
then
timer1.interval
=
timer1.interval
-
100
*
(11
-
m)
/
10
else
timer1.enabled
=
false
end
if
else
msgbox
"请重新开始!"
end
if
n
=
0
text1
=
0
end
if
n
=
n
+
1
end
sub
private
sub
picture1_click(index
as
integer)
select
case
index
case
index
if
index
=
i
then
timer1.enabled
=
false
text1
=
text1
+
10
msgbox
"恭喜你!"
timer1.enabled
=
true
end
if
end
select
end
sub