One Key
by Marcia Berg-Chandler
Use this little program to move the turtle with single key strokes. A separate explanation screen lists all available keys.
OneKey.lgo
TO ONEKEY.INFO
MAKE "ORIGPOS GETXY
MAKE "ORIGSHOW SHOWN?
MAKE "ORIGPD PENDOWN?
PENUP HIDETURTLE
SETXY [-350 250] SETHEADING 0
PD
TURTLETEXT [MOVE THE TURTLE WITH SINGLE KEYS.]
PU BK 30 PD
TURTLETEXT [PRESS F TO GO FORWARD]
PU BK 30 PD
TURTLETEXT [PRESS B TO GO BACK]
PU BK 30 PD
TURTLETEXT [PRESS L TO GO LEFT]
PU BK 30 PD
TURTLETEXT [PRESS R TO GO RIGHT]
PU BK 30 PD
TURTLETEXT [PRESS U TO PUT THE PEN UP]
PU BK 30 PD
TURTLETEXT [PRESS D TO PUT THE PEN DOWN]
PU BK 30 PD
TURTLETEXT [PRESS E TO MAKE THE PEN AN ERASER]
PU BK 30 PD
TURTLETEXT [PRESS C TO CHANGE THE PEN COLOR]
PU BK 30 PD
TURTLETEXT [PRESS W TO INCREASE THE PEN WIDTH]
PU BK 30 PD
TURTLETEXT [PRESS O TO START OVER]
PU BK 30 PD
TURTLETEXT [PRESS ? TO SHOW THIS HELP]
PU BK 30 PD
TURTLETEXT [PRESS Q TO QUIT]
PU
SETXY :ORIGPOS
IF :ORIGSHOW THEN ST
IF :ORIGPD THEN PD
END
TO ONEKEY
MAKE "INPUT RC
; RC waits for a key press and puts it in the variable :INPUT
IF :INPUT = "F THEN FD 20
IF :INPUT = "B THEN BK 20
IF :INPUT = "R THEN RT 30
IF :INPUT = "L THEN LT 30
IF :INPUT = "U THEN PU
IF :INPUT = "D THEN PD
IF :INPUT = "E THEN PE
IF :INPUT = "W THEN SETW WIDTH + 1
IF :INPUT = "C THEN SETPC ITEM RANDOM COUNT COLORS COLORS
; chooses a random color from the color list
IF :INPUT = "O THEN DRAW
IF :INPUT = "Q THEN SS QUIT
IF :INPUT = "? THEN ONEKEY.INFO
ONEKEY
END
TO MAIN
DRAW FULLSCREEN
ONEKEY.INFO
ONEKEY
END
MAIN
Procedure | ONEKEY |
Description | Move the turtle with single keystrokes |
Level | Intermediate |
Tags | Keyboard, Turtle, Drawing |