Thursday, March 19, 2009

Dungeon 3D So Far

Since "Dungeon 3D" has been in development for a few weeks, and I'm just getting this blog rolling, I thought it would be nice to give all of you a bit of background in the development process for the game.

"Dungeon 3D" started as an idea that I've always wanted to work on - a game that builds its levels procedurally (i.e. the program builds levels by itself, rather than loading levels built strictly by hand). I wanted to base my game loosely on a Rogue-like game (specifically, Nethack), but without the "drunken walk" generated hallways, so things would be a little cleaner.

After getting a good idea of what I wanted out of the game down on paper, I began work. Choosing to use a combination of C++ as the language and SDL and OpenGL as utility libraries, I sat down and started on the simple things - like getting stuff to draw.

Upon getting something to render, I added a homebrew lighting scheme that lights individual tiles, rather than lighting everything per-vertex or whatever. This is so the lighting between tiles is easily identified, as it will affect characters' ability to hit each other based on visibility.

Next thing I did was start on level generation, since I could now see what I was doing. After making sure I could see, I changed the view so that the level could be seen adequately.

Unfortunately, the rooms were a little too random. Many rooms were disconnected from each other, so I tweaked the level generator to fix that. However, the level was still largely too random.

I then decided to make dual views for the game, in the form of a minimap in the corner, and the player view in the rest of the screen, to get a "feel" for the maps. I went ahead and added text messages to a sort of heads-up display next to the mini-map.

To help alleviate the unwieldy randomness of levels, I decided to change how levels were generated. Instead of randomly choosing where to plant a room, then randomly setting the width and height, I created some small, hand-made "room definitions" and plugged it all in. Still not there, but getting closer.

After making some new, "optimized" room definitions, I added a frame rate counter to the bottom of the screen. Then I thought the player view looked a bit too bare. I wondered if adding a "ceiling" cap to the walls would help. After showing the before and after to a couple people, we all agreed that the game looked better with capped walls.

I decided it was time to work on something else. I opted to go after model loading and rendering. After all, what is a 3D game without a few 3D models? This wasn't a problem, since I already had an old OBJ loader lying around in an old project. After a few tweaks, I had models up and running.

With that small victory under my belt, the level layouts were still bugging me, so I made some final tweaks to the levels, until I was satisfied with the results.

Of course, the levels themselves are generated fine now, but they still looked a bit boring. I decided to add some trimmings to the levels. I started with pillars inset into inner wall corners, but that killed my frame rate. I was then shown the light.

I had been rendering everything in "immediate mode" - using glBegin() and glEnd() blocks to render it all. A friend of mine told me about vertex arrays and vertex buffer objects. After learning about and implementing those features, I was pleased with the outcome.

So, that's pretty much where I am at the moment. I'm currently working mostly on 3D models, and some minor tweaks. There is still much left to do in the grand scheme of things, though. It's interesting to see how far this project has come over the past three weeks or so when I first got the idea.

No comments:

Post a Comment