![]() |
Pathfinding - rechteckige Spirale durchlaufen
DGL-Luke hat
![]() Was Pathfinding ist kann man auf dieser (aus dem Englischen übersetzten) Seite finden: ![]() Hier der Code:
Delphi-Quellcode:
HTH!
type PArray = array of TPoint;
function spirale(abstand,count,startstep:integer;startpunkt:tpoint;drehsinnnachrechts:boolean):PArray; var richtung,i,step:integer; actpos:tpoint; begin setlength(result,count); richtung:=1; actpos:=startpunkt; result[1]:=actpos; step:=startstep; for i:=1 to count-1 do begin case richtung of 1: actpos.x:=actpos.x+step; 2: actpos.y:=actpos.y+step; 3: actpos.x:=actpos.x-step; 4: actpos.y:=actpos.y-step; end; step:=step+abstand; if drehsinnnachrechts then begin richtung:=richtung+1; if richtung=5 then richtung:=1; end else begin richtung:=richtung-1; if richtung=0 then richtung:=4; end; result[i]:=actpos; end; end; end; MfG Florian :hi: [edit=Chakotay1308]Klassifizierung. Mfg, Chakotay1308[/edit] |
Re: Pathfinding - rechteckige Spirale durchlaufen
Liste der Anhänge anzeigen (Anzahl: 1)
Habe hier ein update:
durch den modifier kann man die spirale auch richtig eng machen.
Delphi-Quellcode:
Ausserdem ist im Anhang ein kleines Beispielprojekt.
type PArray = array of TPoint;
function spirale(abstand,count,startstep:integer;startpunkt:tpoint; drehsinnnachrechts:boolean):PArray; var richtung,i,step:integer; actpos:tpoint; modif:boolean; begin modif := true; setlength(result,count); richtung:=1; actpos:=startpunkt; result[1]:=actpos; step:=startstep; for i:=1 to count-1 do begin case richtung of 1: actpos.x:=actpos.x+step; 2: actpos.y:=actpos.y+step; 3: actpos.x:=actpos.x-step; 4: actpos.y:=actpos.y-step; end; step:=step+abstand; if modif then step := step-1; modif := not modif; if drehsinnnachrechts then begin richtung:=richtung+1; if richtung=5 then richtung:=1; end else begin richtung:=richtung-1; if richtung=0 then richtung:=4; end; result[i]:=actpos; end; end; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 01:21 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz