主题:  帮忙看一下:动态路径的问题

chun_5d

职务:普通成员
等级:1
金币:0.0
发贴:8
#12003/7/28 16:34:52
写了一段东西,感觉没有错,但结果只画出两小段
--初始化
pathlen := 0
pathnum:=0
pen := 3
linelen := 25
blanklen := 5
path := 2
x := [50,200,200]
y := [50,50,350]
timelimit := 5
length:=[]
num:=[]
--计算长度
repeat with i:=0 to path
AddLinear(length ,SQRT((x[i+1]-x[i])*(x[i+1]-x[i])+(y[i+1]-y[i])*(y[i+1]-y[i])))
pathlen := pathlen + length[i]
num[i] := INT(length[i]/(blanklen+linelen))
pathnum := pathnum + num[i]
end repeat
--计算时间
pathtime := timelimit/pathnum
--绘制路径
repeat with i:=1 to path
Startline := SystemSeconds
j:=1
repeat while j <= num[i]
if SystemSeconds-Startline >= pathtime*j then
xs := x[j]+(x[j+1]-x[j])*(blanklen+linelen)*j/length[j]
xe := x[j]+(x[j+1]-x[j])*(blanklen*j+linelen*(j+1))/length[j]
ys := y[j]+(y[j+1]-y[j])*(blanklen+linelen)*j/length[j]
ye := y[j]+(y[j+1]-y[j])*(blanklen*j+linelen*(j+1))/length[j]
Line(pen,xs,ys,xe,ye )
j :=j+1
end if
end repeat
end repeat