当前位置:首页 > 代码 > 正文

vb打地鼠timer上的代码(打地鼠vb程序图文)

admin 发布:2022-12-19 09:37 107


本篇文章给大家谈谈vb打地鼠timer上的代码,以及打地鼠vb程序图文对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。

本文目录一览:

大神快来 如何使用vb制作一个简单的打地鼠游戏?最好用教程

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

=

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

=

text1

=

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

求助:VB中打地鼠点击中了加分的代码过程。要不你教教我怎么做也行。不是很明白●﹏●

Private Sub Image1_Click()

n = n + 1 '分数。

Image1.Visible = False '点中后隐藏 防止多次点击重复计分。

End Sub

初学者求助VB!打地鼠……

嗯,很好,你是一个求学的好同学。

不要源码,要得就是自己的提高。

我想呢,

1,做界面,这个简单画就行了。九个按钮。

2,做个timer1,看看 有地鼠flg

有,清地鼠,随即 按钮的caption写,地鼠。标志 @有地鼠flg@

没有,随即 按钮的caption写,地鼠。标志 @有地鼠flg@

3,按钮,自己是地鼠,+1,自己不是地鼠,啥也不做。

你看咋样?

如何用VB程序设计打地鼠游戏

下面是源代码:

Form1:

Private Sub Form_Load() Dim temp As Integer Randomize

temp = Int(Rnd * 3) + 1

Form1.Picture = LoadPicture("C:\Users\Administrator\Desktop\打地鼠\picture" temp ".jpg") WindowsMediaPlayer1.URL = "C:\Users\Administrator\Desktop\打地鼠\Heaven's Devils.wma" End Sub

Private Sub Label1_Click() Form2.Show Form2.num = -1 Form1.Hide

WindowsMediaPlayer1.URL = ""

Open "C:\Users\Administrator\Desktop\打地鼠\primary.dat" For Append As #1 '写操作 Close #1

Open "C:\Users\Administrator\Desktop\打地鼠\intermediate.dat" For Append As #2 Close #2

Open "C:\Users\Administrator\Desktop\打地鼠\advanced.dat" For Append As #3 Close #3 End Sub

Private Sub Label2_Click() End End Sub

Form2:

Dim allnum As Integer, oknum As Integer '定义变化次数 打中次数 Public num As Integer '判别是否第一次开始游戏 Dim flags1 As Boolean '判别文件是否保存 Public flags As Boolean '判别是否播放声音 Private Sub countine_Click() pause.Enabled = True Timer1.Enabled = True countine.Enabled = False WLXZ.Enabled = True End Sub

Private Sub exit_Click() Dim X As Integer Dim tt As Integer

X = MsgBox("是否真的退出?", vbYesNo, "退出游戏框")

If X = 6 Then

tt = MsgBox("退出游戏之前,是否保存", vbYesNo, "保存提示") If tt = 6 Then

If flags1 = True Then End Else

If Timer1.Interval = 1000 Then

Open "C:\Users\Administrator\Desktop\打地鼠\primary.dat" For Append As #1 '写操作

Print #1, Text1.Text + " " + Format(Date, "M/d/yy") Close #1

ElseIf Timer1.Interval = 500 Then

Open "C:\Users\Administrator\Desktop\打地鼠\intermediate.dat" For Append As #2

Print #2, Text1.Text + " " + Format(Date, "M/d/yy") Close #2 Else

Open "C:\Users\Administrator\Desktop\打地鼠\advanced.dat" For Append As #3

Print #3, Text1.Text + " " + Format(Date, "M/d/yy") Close #3 End If End If End If End End If End Sub

Private Sub Form_Load() Form4.Check1.Value = 1

WindowsMediaPlayer1.Controls.stop countine.Enabled = False pause.Enabled = False WLXZ.Enabled = False

Form5.Top = Form2.Top + 700 Form5.Left = Form2.Left flags1 = False flags = True End Sub

Private Sub help_Click() Form3.Show End Sub

Private Sub new_game_Click() num = num + 1 Dim t As Integer

If (num 0) Then

t = MsgBox("新游戏开始之前,是否保存", vbYesNo, "保存提示") If t = 6 Then

flags1 = True

If Timer1.Interval = 1000 Then

Open "C:\Users\Administrator\Desktop\打地鼠\primary.dat" For Append As #1 '写操作

Print #1, Text1.Text + " " + Format(Date, "M/d/yy") Close #1

ElseIf Timer1.Interval = 500 Then

Open "C:\Users\Administrator\Desktop\打地鼠\intermediate.dat" For Append As #2

Print #2, Text1.Text + " " + Format(Date, "M/d/yy") Close #2 Else

Open "C:\Users\Administrator\Desktop\打地鼠\advanced.dat" For Append As #3

Print #3, Text1.Text + " " + Format(Date, "M/d/yy") Close #3 End If End If End If

Call Form_Load

allnum = 0 '变化次数初始为0 oknum = 0 '打中次数初始为0 Timer1.Enabled = True pause.Enabled = True WLXZ.Enabled = True End Sub

Private Sub options_Click() Timer1.Enabled = False Form4.Show

WLXZ.Enabled = False countine.Enabled = True End Sub

Private Sub pause_Click() Dim r, g, b As Integer Timer1.Enabled = False countine.Enabled = True pause.Enabled = False WLXZ.Enabled = False

Form5.Top = Form2.Top + 700 Form5.Left = Form2.Left Form5.Show

关于vb打地鼠timer上的代码和打地鼠vb程序图文的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。

版权说明:如非注明,本站文章均为 AH站长 原创,转载请注明出处和附带本文链接;

本文地址:http://ahzz.com.cn/post/6078.html


取消回复欢迎 发表评论:

分享到

温馨提示

下载成功了么?或者链接失效了?

联系我们反馈

立即下载