0 Members and 1 Guest are viewing this topic.
function CastRay(X1,Y1,X2,Y2,Accuracy: single; Maxdist: integer): single;var dst,dx,dy,h,d: single;beginif raycast(x1,y1,x2,y2,d,maxdist) then begin result := maxdist; exit; end;dst := accuracy;h := distance(x1,y1,x2,y2);dx := (x2 - x1);dy := (y2 - y1);while(raycast(x1+((dst-accuracy)/h)*dx,y1+((dst-accuracy)/h)*dy,x1+dst/h*dx,y1+dst/h*dy,d,maxdist)) do dst := dst + accuracy;result := dst;end;
function RayCast2(vx, vy: single; range: word; var x, y: single): boolean;var i: word; rd,d,x2,y2: single;begin d:=Sqrt(vx*vx + vy*vy); x2:=x; y2:=y; for i:=1 to 1+Round(range/d) do begin x2:=x2+vx; y2:=y2+vy; if not RayCast(x, y, x2, y2, rd, Trunc(d+1)) then exit; x:=x+vx; y:=y+vy; end; Result:=true;end;