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<l1(1)*D Then Timer1.Enabled=False
If 3.5*D-Width/2+cx+D<l1(2)*D Then Timer1.Enabled=False
If 3.5*D-(cx+3*D-Width/2)<l2(1)*D Then Timer1.Enabled=False
If 3.5*D-(cx+2*D-Width/2)<l2(2)*D Then Timer1.Enabled=False