This is the dev log for Coin Crypt, a procedural adventure game about magical coins.

How We “Fake” 3D in GameMaker for Coin Crypt

image

Most people seem really surprised to learn that Coin Crypt is made in Game Maker, an ostensibly 2D game engine. In truth, Coin Crypt uses no 3D models or assets, nor does it use any 3D functions or libraries. For all intents and purposes it’s actually a 2D game whose objects render themselves deceptively. Of course, all 3D on a 2D screen is “fake,” but… ours is especially fake.

image

This is what a typical room layout looks like in our level editor. Everything is aligned to a flat 2D grid, with all collision information and such also being 2D only.

image

Each solid “box,” at render time, draws a “3D” version of itself. The blue square in the above image represents the actual grid-aligned 2D collision box that we place in the level editor, and from each of the 4 points we extrude from the camera bottom to get a second top square. It’s basically one-point perspective, with the vanishing point being the bottom-center of the camera view. This makes objects visibly shift around as the player moves and the camera follows, which is pleasing to look at. Game Maker has functions for drawing textured vertices like this, which is the foundation for most 3D rendering tech, it’s just that we place the points algorithmically instead of with any 3D assets. To make this work, we kind of had to hijack Game Maker’s standard render pipeline to render every object in the right order.

image

You also may point out that it’s pretty wasteful to render every visible side of each individual box instead of consolidating them into lots of big surfaces, but that’s what lets us create the neat-looking “stepped” lighting effect on walls when you’re in dark areas like the crypts.

image

For objects whose ground-plane level is surrounded by shorter objects, they’ll project to up to get a new bottom square, then project again to get a new top. Varying the projection distance lets us make objects with different heights; treetops use a similar method, but they also extrude outward from their center to be thicker than the one-block sized tree trunks. 

image

All the enemies and characters are just 2D images. Enemies bodies are separate from the tops of their heads; we fake some perspective by scaling their body and keeping the head-tops the same size. As long as you don’t look at them too closely, the sensation of their slight shifting as you walk around is enough to trick your eye into believing they’re 3D. We actually gamified this fakeness slightly by having fake chests render with the enemy scaling technique and regular chests render using proper perspective–you can tell a chest is fake when you can’t see its sides. 

Since player characters are always centered, they don’t have to fake their 3D at all. This ended up being a problem later when we wanted to re-introduce playable characters as occasional NPCs who would teach you new powers, since we never designed them to render in fake 3D. That’s secretly what motivated us to make them ghosts in the game, so that we could have them fade into view only when they’re near the player and therefore always viewed from a relatively small range of perspectives. It worked out: ghosts became a major thematic in the game, and it adds interesting context to their appearance, suggesting they’re from the player’s other failed runs.

image

The only other kind of 3D is in the coins, and theirs is the simplest of them all. They’re just 2D images–to make them “3D” we scale the image and then repeat it several times offset, with some color blending, to create thickness. The outlines are rendered separately in-game as well, again using more color blending and offsets. Drawing one coin to the screen entails drawing the same 2D image probably around a dozen times with different offsets and colors, but it totally works. You’ll notice this is why coins only ever rotate in one direction at a time.

Game Maker is actually a crazy powerful tool, and while a lot of our rendering techniques ended up being pretty unorthodox, in sum total it also shapes the look of our game to be a pretty unique one. We hope you guys are looking forward to the official launch of the game, which should be in about a month… we’ll have more details on that soonish! :o

  1. anniversaryblend reblogged this from coincrypt
  2. dark-shadowsky reblogged this from coincrypt
  3. blog-of-horribleness reblogged this from coincrypt
  4. rockythechao reblogged this from coincrypt
  5. xackorizik reblogged this from sintekoe
  6. civil-anarchy reblogged this from coincrypt
  7. coincrypt posted this