Mooncraft 2000

25 Apr 2022
Mooncraft 2000 screenshot.
Mooncraft 2000 screenshot.

The 1990's

Years ago I played around with a "90's algorithm" that is often referred to as ray-casting. I came across the code in Game Developer magazine from November, 1997 (article by André LaMothe). It was a fascinating little sloppy loop of code that could render a surprisingly realistic "voxel terrain" (though not quite mathematically accurate). The algorithm was introduced to gamers in 1992 as a PC helicopter simulator/combat game called Comanche: Maximum Overkill. PC gamers at that time had not seen anything quite as realistic running in real-time on their home machines.

The 2010's

The first time I played with the algorithm, I started with a fairly faithful AndrĂ© LaMothe implementation in straight C (well, Objective-C). To go a little beyond the Game Developer code, I experimented with adding a modest amount of roll (in addition to pitch and yaw) by faking it — in fact "shearing" each column of pixels to look like the horizon was banking.

To smooth out the chunkiness of the voxels, I experimented with interpolation (interpolating both color and elevation). It was interesting but considerably slowed the rendering down.

Interpolation experiment.
Interpolation experiment.

And since this was the Twentieth Century when I wrote it, I threaded the algorithm so that a machine with multiple cores could work on rendering the screen in swaths of pixels and boost the frame rate.

All told, it was a fun diversion. Something I found frustrating however was finding good terrain to render. The terrain data is pretty esoteric. I was looking for terrain files with color data as well as elevation data for every "voxel". I found a little bit of the Grand Canyon, a Hawaiian island, and Puget Sound. And that was it.

The 2020's

So when I kicked around the idea, ten years later, of playing with voxels again (this time in Javascript) I knew finding good terrain data was going to be half the battle.

But as it turns out, NASA (and a few other space agencies) have a fairly rich dataset representing the terrain of the Moon. The idea of rendering the surface of the Moon in voxels really appealed to me. As well, I think the old Lunar Lander video game had been the first "simulator" I had ever played and I think I have wanted to do a much improved "Lunar Lander" ever since.


Once I had actual Moon terrain rolling in front of me as I piloted my "lunar lander" over the craters, I have to say that I started to really get into the Moon. I found myself just flying around looking at the rough hills, dark craters, smooth mare. I would explore an area, try to land in the center of small, deep craters. I would scout out interesting locations where I might want to put a lunar base in the game…

I wanted to map out some of the larger craters to add to a sort of in-game map of the Moon and so pulled down maps of the Moon and would try to find the names of the various craters I would hover over. I recalled the classic The Earth's Moon map from the old National Geographic magazine.

Fold-out Moon map from 1969 National Geographic.
Fold-out Moon map from 1969 National Geographic.
There is a re-print (of sorts) available. It's nice in that it is not folded like the original map was, and it there is even a laminated version as well. (I indeed ordered one.) The 1969 original though had information about the Apollo mission and a graphic across the bottom of the map showing the course from Earth (lower left) to the Moon (lower right).
Lower-left detail of the 1969 map.
Lower-left detail of the 1969 map.
Also, the typography used to label all the lunar features in the "re-issue" are inferior to the original in my opinion.

I have to say though, that is perhaps what drew me to computers and simulators decades ago. Whether you were flying an airplane, commanding a submarine, or trying to land a lunar module on the surface of the Moon, the computer had the ability to pull you into the fantasy and you began to feel as though you were really there. Even without anything in the way of "game play" I found early on that when I was piloting the "mooncraft" over the lunar landscape I felt a sort of eeriness, sensed cold.

To Continue…

I'll try over the coming weeks or so to add to this page, talk about some of the various challenges I encountered. There were dead-ends I spent time wandering down — I can explain why I ultimately turned back. If you enjoy more technical discussions about programming, come back.

Meanwhile, the source to the game is here: EngineersNeedArt/Mooncraft2000