Const bt/16.shtml' target='_blank' class='article'>BT = 3000 注释:跑道底部的y坐标
Dim l1(22) As Integer 注释:每层跑道左边有几个方块
Dim l2(22) As Integer 注释:每层跑道右边有几个方块
Dim cx As Single 注释:赛车的在x轴的位置
Private Sub Command1_Click()
cx = Width / 2 - 3 * D / 2
cy = Height - D
drawcar
For i = 1 To 20
l1(i) = 0
l2(i) = 0
drawway (i)
Next i
Timer1.Enabled = True
End Sub
Private Sub drawcar()
Line (cx, BT - 100)-Step(3 * D, D), BackColor, BF
Line (cx + D, BT - 200)-Step(D, D), BackColor, BF 注释:先擦
Line (cx, BT - 100)-Step(3 * D, D), RGB(225, 0, 0), BF
Line (cx + D, BT - 200)-Step(D, D), RGB(225, 0, 0), BF
End Sub
Private Sub drawway(n)
Line (Width/2-3*D/2-2*D,BT-n*D)-Step(7*D,D),BackColor, BF
注释:先擦后画
Line (Width/2-3*D/2-2*D,BT-n*D)-Step(l1(n)*D, D), ,BF
Line (Width/2-3*D/2+5*D,BT-n*D)-Step(-l2(n)*D,D), ,BF
End Sub
Private Sub Form_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case Asc("a"), Asc("A")
cx = cx - D
Case Asc("s"), Asc("S")
cx = cx + D
End Select
End Sub
Private Sub Timer1_Timer()
Randomize
For i = 1 To 19
l1(i) = l1(i + 1)
l2(i) = l2(i + 1)
drawway (i)
Next i
Do
l1(20) = Int(Rnd * 5)
l2(20) = Int(Rnd * 5)
Loop Until ((l1(20) + l2(20) <= 4) And (l1(20) - l1(19) <= 1) And _
(l2(20) - l2(19) <= 1) And (l1(19) + l2(20) <= 4) And _
(l1(20) + l2(19) <= 4)) 注释:这里生成新一层跑道,
注释:注意要筛去玩家不可能通过的情况!
drawway (20)
注释:以上画出跑道
drawcar
test
End Sub
Private Sub test()
If 3.5*D-Width/2+cx If 3.5*D-Width/2+cx+D If 3.5*D-(cx+3*D-Width/2) If 3.5*D-(cx+2*D-Width/2)
End Sub








