A First Project: Drawing A Spider
A First Project: Drawing A Spider
Now type
RIGHTLEG
Although this procedure makes a leg, the turtle stops at a funny place for making another spider leg. At this point stairs.
r ig h t l e g
... but we want spider legs. When in doubt about where you think the turtle should be when the procedure stops, put the tur tle where it was before the procedure was run. Now fix or debug r i g h t l e g using the editor.
EDIT "RIGHTLEG
( r ( I Now the Logo editor shows this procedure with the I (cursor) on the t of t o .
TO R I G H T L E G FD 3 0 RT 9 0 FD 3 0 END
These next 3 commands return the turtle to where it was at the start of r i g h t l e g .
Try
i ' ; ' T
RIGHTLEG.
RIGHTLEG
Now plan r i g h t s i d e , the procedure which will draw all the legs on the spiders right side. We want one leg horizontal, so ...
CS
R IG H T L E G
RT
90
RIGHTLEG
68
LT
20
RIGHTLEG
Good. Continue in this way until the turtle has drawn 4 legs. You can now make a procedure for
RIGHTSIDE.
TO R I G H T S I D E RT 9 0 REPEAT 4 [RIGHTLEG LT 1 0 END
LT
20]
Notice the last command in r i g h t s i d e , l t 1 0 , re turns the turtle to the same position and heading it was in at the start of the procedure. It is good practice to force procedures to adopt the rule of good behavior: Leave the turtle in the state you found it. Now work on a left leg. l
RIGHTLEG.
e f t l e g
will be similar to
TO L E F T L E G FD 3 0 LT 9 0 FD 3 0 BK 3 0 RT 9 0 BK 3 0 END
l e f t l e g
to write l
e f t s id e
RT
20]
and finally...
TO S P I D E R LEFTSIDE RIGHTSIDE FD 1 0 BK 1 0 HT END
H ID E T U R T L E n o w is d o n e.
t h a t th e jo b
r ig h t l e g
and l
e f t l e g
MAN