Roguelike game programming and development in Javascript?

The Roguelike genre has been in development for decades–since 1980, in fact, when Rogue, the first Roguelike game, was written. Since then, Roguelike games have been created in many different programming languages. Among the more popular of these languages are C, C++, Java, and Python. However, a new contender is appearing: Javascript. Although it’s the new kid on the block, Javascript is quickly becoming a popular choice for Roguelike development and has already been used to make quite a few games.

Unfortunately, since it’s so new, there aren’t a lot of resources for those who want to begin working with Javascript. Many useful algorithms and formulas found in older development languages have yet to be ported to Javascript and most of the popular utility libraries aren’t available. Nonetheless, Javascript remains a powerful tool for Roguelike development, for those who are still interested.

Now, in order to combat this lack of resources, I’m going to be exploring the capabilities of Javascript for RL development. You can expect to see popular algorithms ranging from dungeon generation algorithms to A* pathfinding converted to Javascript and ready for you to use in your game. I’ll be explaining the shift in thinking required when switching from console-based programming languages to Javascript, which renders to the browser, and may even share with you the source code for the RL I’m currently working on.

Before we get to that, though, here are a few resources that I’m currently working with in my adventures into Javascript Roguelikes:

1. The one wiki to rule them all: RogueBasin

RogueBasin is an unparalleled resource for the aspiring Roguelike programmer. It’s a wikithe wiki, I might go so far as to say–for Roguelike gaming, whether you’re interested in development or playing. It contains a number of excellent articles on developing Roguelikes and even has a page on the pros and cons of developing Roguelikes in Javascript. What makes it such an invaluable resource, however, is the number of algorithms (and more importantly, explanations of algorithms) that it has. It would be worth your time to read and re-read all the articles on there. While not Javascript-specific, they explain many of the key concepts that go into a good Roguelike.

2. “Amit’s Game Programming Information”

While not strictly related to Roguelikes, Amit’s Game Programming Information has a number of links to various resources which can prove useful to Roguelike development. Among others, it has articles on pathfinding, line of site algorithms, AI programming, and other equally important facets of Roguelike development.

3. A few resources for A* pathfinding

I’m working on writing a decent implementation of A* pathfinding in Javascript to be used in my game. Here are a few of the resources I’m using to help me clean up my implementation:

A* Pathfinding for Beginners: Very explanatory and clear. If I were rating these (which I’m not) I’d give it a 5/5.

Path Finding Tutorial: A decent tutorial, explains some uses for A* other than monster AIs.

Introduction to A* Pathfinding: Another good tutorial. I like this article because it has cats in it.

I realize that I may have posted a few of these links already in my previous article on A* pathfinding, but if you didn’t catch that, no harm done. These should be enough to get you started with A* pathfinding, if you haven’t figured it out already. There aren’t really many changes we need to make to convert the algorithm to Javascript, as it’s fairly straightforward.

4. Several different algorithms for field of view computations

I’ve converted several different algorithms for field of view computations into Javascript, but I’m still cleaning them up, so I won’t publish them just yet. Until then, have a look at some of the resources I found useful in my ventures into field of view:

Field of view calculations via raycasting: This was the first psuedocode I ported to Javascript, but as it turns out it was too slow for my uses, so I looked around for some other implementations.

FOV using recursive shadowcasting: This article led me into writing a recursive shadowcasting algorithm in Javascript. It’s easily the fastest FOV algorithm I’ve found yet.

Walls and Shadows in 2D: This article contains the explanation of an algorithm for lighting I’ve not yet implemented, although it does seem pretty promising.

5. Finally, a quick look at some dungeon generation algorithms

Dungeon generation is a key factor in most modern Roguelikes, so you want to be sure you’re doing it right. This is one of my favorite parts of Roguelike development, and something I’ll be touching on again in the future. There are a few different methods you can use: let’s take a quick look at some of the more interesting ones I’ve come across:

Dungeon-Building Algorithm: This is an interesting algorithm and produces some nice results. I’ve played around with it on more than one occasion (in Javascript, of course).

Dungeon generation on the PCG wiki: The PCG (Procedural Content Generation) wiki has a number of resources for dungeon generation, and I’ve found it valuable in researching different methods of creating dungeons on more than one occasion.

Rogue’s original dungeon generation algorithm: The dungeon creation algorithm used in the original Rogue game. It’s actually pretty nifty.

6. In finis…

You’ll probably have noticed by now that most of the resources I’ve linked to have nothing to do with Javascript. That’s because, as I said earlier, there aren’t many resources for Javascript Roguelike development yet. I’ll be converting many of the algorithms I posted into Javascript in the upcoming months for your ease-of-use.

Eventually, if enough interest is shown, I may write a book on Roguelike development with Javascript. Let me know if you think such a book would be useful in the comments section, and as always, feel free to point out any mistakes I’ve made in this article!

real money casino

4 thoughts on “Roguelike game programming and development in Javascript?”

  1. Amit Patel says:

    Great set of links! BTW the link to “FOV using recursive shadowcasting” is now broken.

  2. admin says:

    Thanks! Oh, nice catch, I appreciate it. Fixing… :)

  3. Muzboz says:

    Awesome! I’m listening, looking forward to checking out your other posts.

    1. admin says:

      Great to have you on board! Thanks for stopping by. I’ve been meaning to post some more stuff, I have a few cool things I’d like to share.