TGB Dungeon Builder

For those of you who remember the original “3D” dungeon crawlers, such as Stonekeep, Eye of the Beholder, Lands of Lore or Bard’s Tale … this might be of interest to you.

I saw a post on the GG forums a couple days ago, and it peaked an interest … and, being me, I had to scratch the itch … so I started working on it. I’ve got some pretty decent progress so far, especially for a few hours of prototyping work … Images are attached for your viewing pleasure.

The general concept is this, using a 2D Tile-Layer (multiple layers, possibly?), the “player”can move around a “pseudo-3D” environment.  Basically, using 2D Sprites, which are custom made (I’ll tell you how a little further down …), we draw the first set of sprites and only show a portion of them, to simulate ‘being in the room’, then we draw the next set of sprites … at a reduced size, and butted up against the previous sprites on the X/Y coords … and we repeat this process until we feel we have a good ‘distance’ in front of us (for my tests, 6 rooms seems about the extent of viewable distance with -my- artwork — other artwork may allow for up-to maybe 10 rooms?).

The trick is … if we have a 512×512 seamless tiling texture, and we skew the right side of it so that the right edge is only 256 tall and perfectly centered (128-384) and then we squish the graphic’s width and divide by 4 (512/4 = 128) … we wind up with a … Perspective Tile … Nice, eh?

Now, if we take the image we just created, and duplicate it so we now have 4 copies … then rotate one, place it ontop of the first so the top-left edges are have the same coords, then flip the next one and make it so the top-right corners are touching the one we just rotated … then rotate the next and smack it down at the bottom… we have a ‘pseudo-3D’ room.

Now, if it were only this simply in code, right?

Well, it sort of is … difference is, the code should be intelligent enough to draw the right texture in the right place, and only draw a texture when it should …

Say what?

Yeah, ok … so, we build a 2D Tile-Layer, and every three horizontal squares are a ‘room’ … the left tile is the left wall and the right tile is the right wall, and the center tile represents the floor/ceiling (eh?) … so, if we use this to determine what artwork to draw, the previous example still applies, we just don’t make 4 copies of the same image anymore, we make copies of the images we want to draw …

So what about drawing rooms in front of us? Well, the same logic as mentioned above applies, but, we have to just simply scale our images … given the 512×512 to 128×512 image example i mentioned, our scale is literally 50% (hence the simplicity of the image I made for testing).  We scale everything down by 50% … and just make sure that our left-wall image (the basis of our coordinates) is in the right place … which would be the width of the wall before it, minus the width of the current wall divided by four … why? I honestly don’t remember off hand… haha …

I intend to have a much more detailed description, and hopefully some more useful screenshots in the near future….

Here’s a diagram of the general concept:

Active Image

A working “prototype” layout, completely faked in Level Builder with scaling and positioning of artwork

Active Image

This is actually ‘rendered’ with some code that looks at a 2D Tile-Layer to know what to draw …

Active Image

And here we are after another hour of coding, with a hallway and a t-junction … all determined from a 2D tile-layer.

Active Image

Leave a Reply