VB题~急需

来源:百度知道 编辑:UC知道 时间:2024/07/07 08:14:16
利用Timer和Paintpicture的方法使篮球作自由落体的移动-下~上~下......直到篮球最於弹到地面停止.
用"1"在表示个篮球,最好用image做.不用理会"@"符号
1
@1
@@1@@@@@1
@@@1@@@1@1@@@1
@@@@1@1@@@1@1@1@1
@@@@@1@@@@@1@@1@11
----------------------------
像以上这样运动.
用最简单的方法..不需要用太复杂的计算..

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Private Sub Form_Click()
Dim i As Integer
Dim x As Integer
Dim y As Integer
Dim start As Integer
Dim b As Integer
Dim k As Double
Dim r As Integer
Dim f As Boolean
Dim s As Integer
Dim rd As Integer

start = 1 '相对起点
b = 0 '顶点
k = 0.04 '抛物线系数
r = 50 '每次抛物线顶点的下降距离
s = 1 '速度
rd = 5 '圆的尺寸
Me.ScaleMode = 3
Me.Line (1, 200 + rd)-(400, 200 + rd)
For i = 1 To 400 Step s

x = Abs(i - start)
If x < 2 Then f = True
y = k * x * x + b

Me.Circle (i, y), rd, vbBlack
Me.PSet (i, y) '为的观察曲线,显示圆心坐标,这行可以删除
Sleep 30
DoEvents
Me.Circle (i, y), rd, &H8000000F
y = k * (x + s) * (x + s) + b
If y >= 200 And f = True Then
b = b + r
f = False
If y - b < 0 Then Exit For
s