After finishing “The Book” of Rust I decided to sink my teeth into a larger project. My interest in generative algorithms led me down the path of creating an ASCII roguelike game. Choosing a simple art style allowed me to focus on applying the language well and implementing cool algorithms like Wave Function Collapse.

The game utilizes the Specs library to run an entity component system, the RLTK libary which provides some handy utilities for games, and the Serde library for serialization and deserialization. Utilizing composition provided tremendous flexibility in adding unique properties to otherwise identical entities. Graphics consist of the CP437 character set and a scanline postprocessing effect to mimic the look of CRT screens.

An assortment of algorithms procedurally generate each level and outputs can be fed into other algorithms to increase the variation between levels. Most algorithms also benefit from having variables that can be tweaked using my map builder API to provide even more variety. Currently, the following algorithms have been implemented:

  • Binary Space Partition-like
  • Cellular Automata
  • Diffusion Limited Aggegation
  • Drunkards Walk
  • Mazes
  • Prefabricated maps and sectionals
  • Rooms and Corridors (rectangles connected by paths)
  • Voronoi Hive
  • Wave Function Collapse
Map generation displayed at startup.
A cave map with a variety of enemies and items. You can see the bloodstains from combat around the yellow player. Good thing there's a potion nearby! FOV increased for this picture.

Other features include:

  • Hunger
  • Item System
    • Potions, rations
    • Spell scrolls
  • Equipment System
    • Armor slot
    • Weapon slot
  • Enemy AI
    • Each enemy has its own field of view
  • Scaling
    • New items spawn and enemies get stronger as you go down levels
  • Particle effects
    • Combat
    • Bloodstains
    • Effects from items
  • Loading maps from ASCII or REX files

Serde is used to create and load save files via serialization. A savefile.json is created when exiting the game by pressing escape. The presence of this file enables the load game option. Death deletes the save file.

Source code available on GitHub