中易网

求VB作品一个

答案:1  悬赏:60  
解决时间 2021-01-15 05:59
  • 提问者网友:辞取
  • 2021-01-14 05:30
求VB作品一个
最佳答案
  • 二级知识专家网友:不如潦草
  • 2021-01-14 06:55
以下是我自己做的一个小游戏,不知道算不算一个程序。只用了一个窗体,一个image,一个picture
代码如下:
Option Explicit
Dim t, su, f, h, s, r, un As Integer

Private Sub Form_Activate()
Picture2.SetFocus

End Sub

Private Sub Form_Load()
Form1.Caption = "撞球游戏"
Form1.Top = Screen.Height / 2 - Form1.Height / 2
Form1.Left = Screen.Width / 2 - Form1.Width / 2
Timer1.Enabled = True
Timer1.Interval = 1000
t = 3
Timer2.Enabled = False
Timer3.Enabled = False
Timer2.Interval = 1
Timer3.Interval = 1
Label1.Caption = ""
Label1.Caption = t
su = HScroll1.Value
f = su
h = su
s = su

End Sub

Private Sub HScroll1_Change()
su = HScroll1.Value
Picture2.SetFocus
Timer1.Enabled = True
Timer2.Enabled = False
Timer3.Enabled = False
Picture1.Top = 0
Label1.Caption = t
f = su
h = su
s = su

End Sub

Private Sub Picture2_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 37 Then
Picture2.Left = Picture2.Left - su
f = -su
Else
If KeyCode = 39 Then
Picture2.Left = Picture2.Left + su
f = su
End If
End If
If Picture2.Left <= 0 Then
Picture2.Left = 0
Else
If Picture2.Left >= Form1.Width - Picture2.Width Then
Picture2.Left = Form1.Width - Picture2.Width
End If
End If

End Sub

Private Sub Timer1_Timer()
t = t - 1
Label1.Caption = t
If t = 0 Then
Timer1.Enabled = False
t = 3
Timer2.Enabled = True
Timer3.Enabled = True
Label1.Caption = ""
End If

End Sub

Private Sub Timer2_Timer()
Picture2.Left = Picture2.Left + f
If Picture2.Left <= 0 Then
f = su
Else
If Picture2.Left >= Form1.Width - Picture2.Width Then
f = -su
End If
End If

End Sub

Private Sub Timer3_Timer()
Picture1.Move Picture1.Left + h, Picture1.Top + s
If Picture1.Left <= 0 Then
h = su
Else
If Picture1.Left >= Form1.Width - Picture1.Width Then
h = -su
End If
End If
If Picture1.Top = 0 Then
s = su
Else
If Picture1.Top >= Form1.Height - Picture1.Height Then
r = MsgBox("你输了,是否重来?", vbYesNo, "撞球游戏")
un = 0
If r = 6 Then
su = HScroll1.Value
Picture2.SetFocus
Timer1.Enabled = True
Timer2.Enabled = False
Timer3.Enabled = False
Picture1.Top = 0
Label1.Caption = t
f = su
h = su
s = su
Else
If r = 7 Then
End
End If
End If
End If
End If
'以下为浮木撞到球时发生的动作
If Picture1.Left + Picture1.Width / 2 >= Picture2.Left Then
If Picture1.Left + Picture1.Width / 2 <= Picture2.Left + Picture2.Width Then
If Picture1.Top + Picture1.Height >= Picture2.Top Then
If Picture1.Top + Picture1.Height <= Picture2.Top + Picture2.Height Then
s = -su
un = un + su
Label1.Caption = un
End If
End If
End If
End If

End Sub
'简单得很,不要见笑,或者我还有一个图书管理系统,一个计算器(不过计算器还有很多BUG)
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息!
大家都在看
推荐信息