Dungeon Mode Kit menu: ☜ Back to Index

Dungeon Mode Kit

November 21, 2025

Dungeon Mode Kit - Design Document

Project Overview

Dungeon Mode Kit is a modular web-based roguelike framework designed to create multiple small game prototypes with different mechanics, all sharing common assets and core systems. This would allow me to make small embeddable games that correspond to the different topic in The Dungeon Mode

Core Philosophy

Technical Architecture

Rendering System

Core Architecture

Entity System Hierarchy

Entity (Base Class)

Purpose: Any object with sprites and semantic attributes

class Entity {
  constructor(x, y, type) {
    this.x = x;
    this.y = y;
    this.type = type;
    this.attributes = new Map(); 
    this.sprite = null;
    this.tint = 0xFFFFFF;
  }
  
  // Helper methods for attribute management
  setAttribute(key, value) { this.attributes.set(key, value); }
  getAttribute(key) { return this.attributes.get(key) || false; }
  hasAttribute(key) { return this.attributes.has(key) && this.attributes.get(key); }
}

Base Attributes:

Item (extends Entity)

Purpose: Single-tile pickupable objects

Actor (extends Entity)

Purpose: Interactive 2-tile entities with behavior

Personality System

Data-Driven AI: JSON files defining behavioral attributes

// personalities/guard.json
{
  "controlled": false,
  "mutiply_chance": 0.2,
  "hostile": true,
  "tactical": true,
  "patrol_range": 5,
  "vision_range": 8,
  "memory_duration": 10,
  "preferred_positions": ["doorway", "corner", "chokepoint"],
  "behaviors": ["patrol", "guard_area", "pursue_intruders"]
  etc
}

Switchable: Personalities can change during gameplay (charm effects, mind control, etc.)

Shared Behaviors: Common AI routines (pathfinding, line-of-sight, etc.) used across personalities

Map System

Tiled Integration

Layers:

Wildcard System

Procedural Zones: Special tiles painted in Tiled that trigger generation

Processing Pipeline

  1. Load prototype: Check for map.tmj in prototype folder
  2. Map handling:
    • If map.tmj exists → load authored map
    • If no map.tmj → generate fully procedural level using ROT.js
  3. Process wildcard tiles → replace with ROT.js generated content:

    // Wildcard maze generation
    if (tileType === WILDCARD_MAZE) {
      const maze = new ROT.Map.Uniform(width, height);
      maze.create((x, y, value) => {
        floorMap[x][y] = value === 0 ? FLOOR_TILE : null;
        if (value === 1) spawnWallActor(x, y);
      });
    }
    
  4. Auto-generate wall actors around floor perimeters (procgen areas)
  5. Load entities:
    • Start with global actors/items
    • Override with prototype-specific variants
  6. Validate item placements (must be on walkable floor)
  7. Instantiate entities from tile IDs using lookup tables

Prototype System

Game Definition

Each prototype is a JSON file defining complete game rules:

// prototypes/puzzle_cave/prototype.json
{
  "name": "Strength Puzzle Cave",
  "mechanics": {
    "fog_of_war": false,
    "darkness": false,
    "turn_based": true,
    "line_of_sight": false
  },
  "stats": {
    "strength": {
      "max": 10,
      "current": 10,
      "depletes_on": ["push_wall"],
      "restore_items": ["strength_potion"]
    },
    "health": { "max": 100, "current": 100 },
    "hunger": { "max": 100, "current": 100, "depletes_per_turn": 1 }
  },
  "inventory": { "max_items": 5 },
  "available_items": ["key", "strength_potion", "lever", "food"],
  "available_actors": ["wall", "pushable_wall", "door", "switch"],
  "win_conditions": ["reach_exit", "activate_all_switches"],
  "transitions": {
    "stairs_down": "dungeon_level2",
    "stairs_up": "previous_prototype"
  }
}

State Management

Multi-Prototype Navigation:

Flexible Stats: Each prototype defines its own character attributes

Game Systems

Hybrid ROT.js Integration

ROT.js Components (Kept):

Custom Components:

Turn Engine

Collision & Physics

Rendering Pipeline

  1. Background: Auto-generated shadows behind floor
  2. Floor: Walkable terrain tiles
  3. Entities: Items (1 tile) and actors (2 tiles)
  4. Effects: Fire, smoke, tinting, animations
  5. UI: Inventory, stats, messages

Asset Management

Shared Resources

Sprite System

Development Workflow

Creating New Prototypes

  1. Create folder: Make new directory in prototypes/
  2. Define game: Create prototype.json with mechanics and stats
  3. Choose content approach:
    • Authored: Create map.tmj with floor/item/actor layers + wildcards
    • Procedural: Omit map.tmj for fully generated levels
    • Mixed: Use wildcard tiles in authored maps
  4. Customize entities: Add prototype-specific actors/items in local folders
  5. Test: Embed canvas in explanatory web page

Asset Loading Priority

  1. Global First: Load global actors/items as defaults
  2. Local Overrides: Prototype-specific actors/items override globals
  3. Auto-Detection: Engine automatically detects and loads map.tmj if present

Content Authoring