Posted 16 March 2012 - 12:29 AM
Good day.
I'm sure that somebody invented this first, but I'll show it anyway. Well, I hope that I spared the time someone. The dependent Turtle moving API allows the Turtle to make different moves depending on the side it's facing, for example:
>The API is loaded and the side is set to front
>Turtle is told to move forward
>Turtle moves forward
>Turtle is told to move left
>Turtle turns left, moves forward and the side is set to left
>Turtle is told to move forward
>Turtle turns right, moves forward and the side is set to front
This allows the programmer to use less imagination and lets him/her focus on the code. In addition, the API has built-in function "force forward", which, as you can guess, will end only if Turtle's moving forward was succesful (functions "force up" and "force down" exist too). Currently it may be unsafe and needs some corrections, but I'll do that later. Every moving function uses it. …Now the commands:
Example program with DTM API
The API
I'm sure that somebody invented this first, but I'll show it anyway. Well, I hope that I spared the time someone. The dependent Turtle moving API allows the Turtle to make different moves depending on the side it's facing, for example:
>The API is loaded and the side is set to front
>Turtle is told to move forward
>Turtle moves forward
>Turtle is told to move left
>Turtle turns left, moves forward and the side is set to left
>Turtle is told to move forward
>Turtle turns right, moves forward and the side is set to front
This allows the programmer to use less imagination and lets him/her focus on the code. In addition, the API has built-in function "force forward", which, as you can guess, will end only if Turtle's moving forward was succesful (functions "force up" and "force down" exist too). Currently it may be unsafe and needs some corrections, but I'll do that later. Every moving function uses it. …Now the commands:
f() - Move forward
l() - Move left
r() - Move right
b() - Move back
u() - Move up
d() - Move down
Example program with DTM API
The API