The Zone.js - A Roguelike in the making

| 3 min read
  • 🐙 You can see the code here
  • 👾 You can play the latest build here

Since I first laid my eyes on Dwarf Fortress a bunch of years ago, I've been in love with the genre. There is something just magical to that simple look and incredible complexity capable of immersing your mind away into an alternate reality.

Stuff like the Dwarf Fortress drunk cats bug kept me dreaming of building my own game some day. Create a set of rules, get some systems in place give it a little push to set everything in motion and... Surprise! That's why I'm really into programming for. The idea of building some uncharted territory you can explore yourself seems to good to be true.

So, without a clue on how to build a system like this I decided to finally give it a go and try to build my own!

Progress

Without further ado here you can see some progress shots of what I have been hacking together in the past few months.

1 Playing around with the rot.js tutorial to get something moving on the screen (~150 commits ago)

2 Experimenting with the tile palette and the use of emojis (~120 commits ago)

3 More entities get introduced. A crude "AI" moves enemies towards the player although they don't know how to avoid obstacles(~100 commits ago)

4 Shit gets serious. Field of view is implemented plus I decided to use a tileset for the graphics (~80 commits ago)

5 Player can move in between areas, enemies persist (now)

Progress up until now:

  • Player can travel in between areas
  • World is persistent when traveling
  • Enemies use A* pathfinding to follow the player
  • Melee Combat works
  • Terrain generator can generate different layers of detail, including "crude" buildings
  • Field of view works

So far I've focused mostly on "engine" stuff, the basics that could be part of any game. Development is sometimes fun and sometimes frustrating, but I'm enjoying it so much. I shall be more aware to avoid falling in rabbit holes if I want this to be playable at some point though.

I recommend checking this article by Josh Ge for a primer on roguelike development.

Why I'm doing this?

I've had this idea in my mind for ages, and it seems like an amazing Forever Project (big shotout to Scott Turner for the inspiration) to pursue and keep over the fire.

I have 0 expectations with the project, but some crystal clear goals:

  • Build something capable of surprising myself
  • Have a programming sandbox to play with algorithms and procedural generation
  • Have tons of fun!

The plot

You are a rookie S.T.A.L.K.E.R

You start on the rookie camp, sad guitars can be heard in the distance. A faint smell of vodka, cold sausage and blood fills the air.

Every morning you venture yourself around the camp to scavenge some stuff. Sometimes you find the balls to get into an anomaly and look for an artifact. Most of times you don't.

You come back to sell the little you can find to the local smugglers. You spend most of your profits in more vodka and sausage, not everyone was lucky today, you share it with your comrades. On lucky days you still have some remainder to upgrade your gear.

You dream of venturing far away, to the virgin lands where few stalkers had the courage to step on. Where the artifacts pile on every corner waiting to be discovered. Where the mutants haven't been decimated yet and rarely eat, hungrier and more ferocious than anywhere else. But not today.

You must survive to live another day. Every few nights, blowouts happen, the camp is secure, but The Zone changes. Anomalies switch place, herds of mutants appear out of nowhere, comrades unlucky enough to be caught out there disappear to never be seen again.

But you are still alive today. The grind never ends. Maybe tomorrow. Take care stalker.

The stack

I settled on building a web based game for a a bunch of reasons:

  • Very easy to distribute and deploy
  • Extremely fast development cycle
  • I'm very proficient with the stack

I started using vanilla HTML + CSS + JS. But things where getting pretty big, and I decided to sacrifice the addition of a build step in favor of having static typing, so I switched JS for Typescript.

I'm also leaning on the amazing ROT.js for some cool ass utilities like FOV, pathfinding etc... although I would love to switch the modules for my own implementations.

This talk by Chris McCormick was a big inspiration for following this approach.

The community

At the start I was extremely lost, but luckily, since then I've found an amazing community around roguelike development with tons of resources to learn and share.

Vilva.