Logo!

A few days ago, I had the idea to put together a copy of a program I used to use way back in elementary school – Logo. I know enough about how to do all the basic tasks – moving an object, manipulating data structures and collecting and parsing user input – that I thought I’d be able to slap together a rudimentary version fairly quickly. And I was right – mostly.

Almost immediately, I ran into a problem. Drawing 640,000 pixels individually from my data structure 60 times per second just didn’t work. I was lucky enough to occasionally push it up to two. That just wasn’t acceptable. Fortunately, I knew of a system in Game Maker – Surfaces – that would solve my problem. Unfortunately, I knew absolutely nothing about using them. It turned out that they’re relatively simple to use; in a bit over an hour, I had the system drawing to the surface, and vastly improving my Frames Per Second.

After I got that working, I started in on my text input. Like the graphics portion of the screen, I know that it was not the most efficient method, but it works, and I don’t currently have a reason to make massive changes to it.

Next was the text parser. Not that I could get user input, I needed to convert it into commands that the system could use. Again, I feel that I’m not using the best methods, but it (mostly) works, so again, I’m sticking with what I’ve got.

At this point, I noticed a flaw in my graphics system. My surface was redrawing itself every time it changed, and when the turtle started moving, the surface was once again drawing all 640,000 pixels multiple times per second. So, once again, I had to rewrite the graphics system, making it draw directly to the surface, and only recalculating the full contents when absolutely necessary.

If you’re familiar with Logo, this version will come as a disappointment to you. It only has a handful of basic commands implemented. But since it’s the fruit of only about 10-12 hours labor, including learning some new tools, I’m willing to consider it a good start.

Commands

FW or FORWARD # – Move the turtle forward # pixels.

BK or BACK # – Move the turtle backwards # pixels.

RT or RIGHT # – Turn the turtle right # degrees (360 degrees in a circle).

LT or LEFT # – Turn the turtle left # degrees.

HOME – Return the turtle to the center of the drawing area.

CG or CLEAN – Remove everything from the drawing area.

PU or PENUP – Lift the pen, making it so that the turtle doesn’t draw when it moves.

PD or PENDOWN – Lower the pen, making the turtle draw as it moves.

PC or PENCOLOR # # # – Changes the color of the trail the turtle leaves. The three numbers are Red, Green and Blue levels, each from 0 to 255.

RP or REPEAT # [command list] – Repeat all the commands contained in the [square brackets] # times.

Commands are not case sensitive. You can enter multiple commands in a single line, up to a maximum of 60 characters.

Known Issues

PENCOLOR does not properly clear its parameters from the input buffer. As a result, any commands on the same line will not execute properly, if at all. This does not affect commands typed on a new line following a PC command.

REPEAT does not properly parse nested loops. In some situations they may perform as expected. At other times, they will act unpredictably.

HT, HIDETURTLE, ST and SHOWTURTLE commands are implemented in a manner that is not compatible with HTML5. While you can use these commands, they currently do nothing.

The application window is too large to properly fit in a blog post, so follow the link to try it out HERE.