Sitemap
Better Programming

Advice for programmers.

Member-only story

Adding Key Placement to a JavaScript Roguelike

8 min readNov 17, 2022

--

Photo by Jason D on Unsplash

In most video games, any level should allow the player to reach the goal. While that may sound obvious, it’s easier said than done in a roguelike, where levels are procedurally generated. While making each level solvable was never a problem in the early stages of building Rogue of Rhondar, it became a challenge after adding doors and keys. This article discusses the series of tests and refinements that ultimately led to my current key placement algorithm.

Getting Oriented

Below is a quick screenshot of the in-progress game.

Well, this key was pretty easy to find at least.

So far, each level in this game is procedurally generated and consists of the following:

  • rooms connected by hallways
  • locked doors
  • small keys
  • enemies
  • a relic, which must be found to complete the

The keys in the game are called “small keys” because any key can unlock any door, and each key can only be used once. Below is a quick clip of the player…

--

--

Nevin Katz
Nevin Katz

Written by Nevin Katz

Developer at EDC. I write about web development and biology. Subscribe at https://buttondown.email/nevkatz for article roundups.

No responses yet