Building a pseudo-3d game using SilverTile

27. juli 2010

I needed a break from my Zelda remake and decided to try something completely different. Being a fan of the Dungeon Master and Eye of the Beholder games I decided to build a 3d-engine for that kind of game.


A scene from Dungeon Master - tasty monsters!

The principle is simple - you only allow the player to turn 90 degrees and the entire world is built up of square blocks. When the player moves he always moves one square at a time. This means that we don't need 3d models of everything, 2d sprites are enough. All we need is to draw everything from all four sides and we are done! We get the 3d effect by drawing the objects furthest away before those that are closer.

Creating the effect in SilverTile

Doing this in SilverTile turned out to be quite easy. SilverTile already supports layering of sprites, it supports sprites of any size at any location and it supports transparent pixels. The major job was to decide where to place each sprite. We have three images for walls on each z-level supported by the game - front facing, left and right.


Wall tiles: Left, front facing, right

The screenshot below shows a screenshot from the game engine. The wall on the left is made up by three images stiched together, the floor and roof are static pictures.

A screenshot from the game engine running in Silverlight

The figure below shows and overhead view of the rendered scene. The red squares are walls and the green are floor.

The wall layout rendered in the screen shot

I have built a prototype game that runs in both Silverlight and on Windows Phone 7. The game lets you explare a randomly generated maze and is controlled by using the arrow keys on Silverlight and touch gestures on WP7.

The game runs on Windows Phone 7 as well as on Silverlight

You can try the Silverlight verison here. Contact me if you are interested in the source code. The game uses an unreleased version of Silvertile and the source code is quite messy (a real prototype!), so I won't post it here. :-)


Update (27. september 2010):

I decided to use my code and build a simple dungeon exploration game and submit it to the Norwegian Windows Phone 7 developer contest. I got a designer buddy (@hiemil) to make a pretty user interface, and I borrowed Ralf Hinrichsens custom DMJava graphics to draw the dungeon and the monsters. The end result was a much prettier game than what you can see on the screens here. Watch a short gameplay video here:



.NET, Silverlight, WP7 , , ,