求一个简单的vb程序代码

来源:百度知道 编辑:UC知道 时间:2024/05/27 05:17:13
弹球游戏
要求:在筐内圆球可以弹来弹去即可...

简单的要死 可是我就不会 可怜了 各位帮帮忙 谢谢了
注明所需要的控件
下面的程序只能撞到左右线 没撞到上下的线就弹回来了

控件:shape两个,timer1个
Private Sub Timer1_Timer()
Static a, b
If Shape2.Left <= Shape1.Left Then
a = 15
End If
If Shape2.Top <= Shape1.Top Then
b = 15
End If
If Shape2.Left >= Shape1.Width + Shape1.Left - Shape2.Width Then
a = -15
End If
If Shape2.Top >= Shape1.Height + Shape1.Top - Shape2.Height Then
b = -15
End If
Shape2.Move Shape2.Left + a, Shape2.Top + b
End Sub

Private Sub Form_Load()
Timer1.interval=10
Me.Width = 2900
Me.Height = 3300
With Shape1:
.Top = 100
.Left = 100
.Width = 2500
.Height = 2700
End With
With Shape2:
.Top = 100
.Left = 100
.Shape = 3
.Width = 400
.FillStyle = 0
End With
a = 15: b = 15
End Sub