The Imaginary 3-D Dungeon Simulator of the Year, 1983...
NOW ON THE WEB!!
http://hostilefork.com/media/shared/replpad-js/?do=dungeon
Source code:
https://github.com/hostilefork/teenage-coding/blob/master/DUNGEON/dungeon.reb
Backstory
When I was a kid (circa 1983, I'd be about 8 or 9), I played the Intellivision game Advanced Dungeons and Dragons: Treasure of Tarmin. The 3-D graphics put you in a first-person-perspective point of view with shocking realism:
But a year or two later, I got a C-64. And I was able to draw on the 40x25 character grid by cursoring around the screen, setting the color with the Ctrl key and a digit, and putting symbols anywhere I wanted (why doesn't bash
let me do that?). The character set had triangular components and solid block components.
So I was able to reason through how one might generate a rendering of one's perspective in a grid through that medium.
In 2013, I found the nearly-three-decades-old spec, in spiral-bound notebook paper, about "Dungeon Construction Set":
(Careful readers will notice that while it's almost right, this doesn't quite hold together on the slanted parts...)
Though Treasure of Tarmin was played on a grid, the walls existed only on the edges of grid squares. Having learned what bytes were, I realized that if I made the map out of bytes...then each square on the map could have four possible states for each of its edges:
- Unobstructed
- Wall
- Door
- Something Else?
The design allows for the opportunity that adjacent cells would "disagree"...e.g. have a wall on one side and a door on the other. I considered this a feature; these situations would give rise to one-way doors and walls that didn't appear until you passed through them and then turned around.
My idea was that a position on the map and a direction you were facing could "light up" regions on the screen...a bit like lighting up segments of a digit on an LCD.
But an implementation of the ideas eluded me. It was a trickier program than I had written at the time, made even trickier because I was trying to implement it in a "machine language monitor". I had no assembler, and the book I read didn't discuss them...just the instruction set and workings of the 6502 chip.
(The machine-language-monitor programs could encode single instructions into specific memory locations. But unlike an assembler, it had no labels or other abstractions...all addresses had to be kept track of on paper.)
By the time I knew enough about programming that I could do something like this in an evening, I no longer cared much about the idea. But better late than never, right?
Although Unicode/ASCII don't have good "seamless drawing" characters to do this like the C-64 could, it can still get the idea across.
Originally Wrote this in Red (2013)
I decided I'd use this relatively simple task as something where I would use Red the whole time--as opposed to writing it in Rebol2 or R3-Alpha and then porting the differences. So that let me get a sense of where the pain points were regarding things like syntax error reporting, that sort of stuff.
Anyway, about a decade later, it's now a Ren-C sample. Minor modifications were made, including taking advantage of the ReplPad's CLEAR-SCREEN ability (if running on the web).