Wednesday, November 4, 2015

A Game(?) A Week(?): Dungeon Generator

You know, I'm running out of quirky ways to say "this took me more than a week, huh". Turns out that going to school full time and working on weekends doesn't leave as much time as I thought I had for game development. Anyway, this project, which is neither a game nor took a week to build, is a dungeon generator! For a rogue-like. I was actually hoping to build a full rogue-like this week but this is all I had time for. I'm quite proud of it.

Rogue-Like Dungeon Generator - total development time 2 weeks

What it is: A program that procedurally generates dungeons in the style of Rogue. There is a player character who can walk around the dungeon, but all the important features of rogue-likes - combat, items, treasure, stairs, field-of-view - are not currently implemented.


Where you can play it: Here.

What worked: Well, it generates dungeons! I've been wanting to make something like this since I first learned about procedural generation, and I'm really excited that I finally managed to build one. That being said...

What didn't work: Basically everything until three or four days ago. For the first week, I tried to implement in Game Maker Studio, thinking that it would be easier to implement game-play that way once I'd gotten the dungeon generator working. Problem was, I couldn't get it working. It's almost certain that that's my fault rather than Game Maker's - the program kept running out of RAM and crashing, which means either there was an infinite loop or I had an unclosed data structure somewhere. I couldn't find the problem, though, and I got frustrated by the limitations of Game Maker's scripting language. Plus, it costs $200 to buy the Game Maker module that exports to HTML5, and I wanted this program to run in a browser. So I ditched the game engine entirely and switched to HTML and JavaScript. This meant that I had to implement core features such as handling input and rendering the game myself, but it also gave me far greater control over the workings of the algorithm. I also found a really good article detailing pseudocode of a dungeon generation algorithm (earlier, I was trying to implement the procedure described in this fascinating article, which was much less straightforward than my new approach). It took me all of last week to get that working, but this morning I finally did. The results are great: a modular, easily-expandable dungeon generation algorithm. With no game attached, because I didn't have time. That'll have to be it's own weekly project (maybe several weekly projects).

What I learned: I learned how to use JavaScript and honed my HTML5, both of which are incredibly valuable life skills. I feel comfortable now building interactive websites, web applications, and online games. So that's awesome. I also learned loads about how to efficiently generate complex procedural objects, which involves everything from effective data structures to geometry, and how to optimize my code so it doesn't lag every time it has to generate a new object.

Development Breakdown:

  • Wasting time in Game Maker: Studio: 6 days
  • Writing the HTML doc, the CSS stylesheet and the main game loop: 1 day
  • Coding the dungeon generation algorithm: 4 days
  • Debugging and tweaking: 3 days
  • Build, publishing and write-up: 1 day

No comments:

Post a Comment