Turtle Graphics in BASIC - 40+ years ago and now

A bit of 40 years ago I was introduced to Logo and turtle graphics - I didn’t care much for Logo but the Turtle Graphics really interested me - so I wrote my own Turtle Graphics interpreter… In (Applesoft) BASIC, as we did back then…

And when 12 or so years later I wanted to write my own “ideal” BASIC, I incorporated Turtle commands into the language…

And so, for your amusement I made a little video of that old Apple II system and my new system running a few very simple Turtle graphics demos…

Cheers,

-Gordon

7 Likes

That final demo - animating by clearing and redrawing, in a Basic - that’s very impressive.

2 Likes

“Is that useful? I don’t know.”

That’s the story of my computing experience, in a nutshell.

Beautifully done, thank you!

2 Likes

That’s rather lovely! I’m amazed at how fast your parser was in AppleSoft BASIC: speedy it isn’t. If you ever feel the urge to share the Apple II program, I’d be happy to upload a disk image to Internet Archive so people could play with it in the browser …

As for useful, I’ve used the output from Python’s turtle module and from UCBLogo to drive laser cutters. I think MMBasic for various micro-controller boards includes turtle graphics, if anyone feels the need to trundle a virtual turtle

Thanks.

I’ll need to investigate how to get it off an Apple floppy and onto something else (other than printing it to a serial port!) I think ADT is the software to use there though…

Cheers,

-Gordon

2 Likes

Yes, ADTPro is little short of magic. While serial is quicker, it can also work over audio

Thanks.

I have a raycasting demo in BASIC which achieves about 10-12fps on a Pi 1B - it’s fast enough to write a ‘Wolfenstein’ type game on a modern PC… With tweaks, DOOM written in BASIC? :wink:

Cheers,

-Gordon

2 Likes

Ah. now I have a lasercutter … and back then I did make it output to a pen plotter via serial and the code for that is still there… How hard can it be …

Although I’ve always wanted to make a ‘real’ turtle… One day!

Cheers,

-Gordon

1 Like

Just a little addition to this… Some time back (1st April, 2022 to be precise) there was (as there usually is) an April Fool edition of the XKCD comic:

This was an audio transcript of a rather long LOGO program featuring Turtle Graphics to draw a picture in a sort of “Bob Ross” style.

The audio was eventually transcribed back into a LOGO program and other folks ran it and it was good.

So in a fit of idleness and “how hard can it be” (Something I’ll get engraved on my gravestone) I re-coded it in my BASIC…

I used an editor (vim) to do some global search/replaces then got bored with that, so wrote another BASIC program to generate a BASIC program with all the turtle graphics commands suitably changed to my dialect.

Here is the result:

It’s turtles all the way, as they say…

-Gordon

3 Likes

Nice! UCBLogo (which has recently gone back into active maintenance, so there are likely working versions available for your non-retro computer of choice) runs the saved workspace from theinternetftw/xkcd2601: Transcription of xkcd 2601 to runnable logo code in about the same time as your video on my system.

load "/full/path/to/your/saved/xkcd.lgo
xkcd
1 Like

In terms of time … I slowed the generation down by forcing a screen update (it’s double-buffered) on every little line segment drawn. If I remove the update then it completes in about 100 milliseconds and the picture appears almost instantly…

Which isn’t too bad as I added in a scale factor to every turtle move and segment drawn to make it fit nicely into a 1280x1024 window. The code looks like:

t$ = "We start with a vision in our hearts and we put it on canvas."
proc scrollText (t$)
proc cubic (scale * -469,scale * 424,scale * -458,scale * 416,scale * -456,scale * 389)
penUp
moveTo (scale * -471, scale * 400)
penDown
tangle = 87
move (scale * 14)
penUp

and so on…

(Also note, as I’m sure you’ve seen - “cubic” is recursive too) I also had to add 2 new keywords into my system to read-back the turtle X & Y positions for the cubic function to work).

I tried to “get into” Logo (back then, and now) but it just isn’t “sticking” in these old grey cells, so will consider it read only for now… :slight_smile:

Cheers,

-Gordon