Drawing mode
Turtle Stories
Now that the core of our Turtle syntax is ready we can start telling stories with it ... To do this, we use the keyboard as an interface to control our turtle (reuse the code of the previous example)
First we redefine the word tag:
: tag 0. 0. 0. 0.05 rgba 100. square 0. 1. 0. rgb 0.8 square ;
Then you define some words that map keys 4 to 9 of your keyboard, to the turtles movements:
: key-7 left turn forward move tag ; : key-9 right turn forward move tag ; : key-5 backward move tag ; : key-4 left move tag ; : key-6 right move tag ;
To map to other keys, just create words that start with key followed by - and the key of your choice. For example, to map an action to the letter a, use : key-a blablabla ;.
To switch PF into hotkey-mode, type:
hotkey-mode
Now use keys 4 to 9 to move your turtle around, and when you're bored, hit the SPACE-BAR to exit hotkey-mode.
