Created
October 30, 2014 05:06
-
-
Save floybix/8877d623ab5744906944 to your computer and use it in GitHub Desktop.
saving and restoring turtle state
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
make "states (list) | |
to savehere | |
push "states (list heading pos pendown?) | |
end | |
to gosaved :heading :pos | |
localmake "old (pop "states) | |
localmake "oldheading (pop "old) | |
localmake "oldpos (pop "old) | |
localmake "oldpd (pop "old) | |
penup | |
if :heading [ | |
setheading :oldheading | |
] | |
if :pos [ | |
setpos :oldpos | |
] | |
if :oldpd [ | |
pendown | |
] | |
end | |
cs | |
penup | |
setpos [-200 0] | |
pendown | |
repeat 20 [ | |
fd 80 | |
rt 18 | |
savehere | |
rt 30 | |
fd 50 | |
setheading towards [0 0] | |
fd 50 | |
(gosaved TRUE TRUE) | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment