Pre-release
AdventureJS Docs Downloads Bundler Devlog Score: 0 Moves: 0
A simple example game. chalice, dungeon, demo DungeonDemo

Examples:Dungeon Demo

A super simple dungeon.

This very simple game demonstrates some basic features of AdventureJS.

 

// DungeonDemo.js
/*global AdventureJS A DungeonDemo*/

var DungeonDemo = new AdventureJS.Game("DungeonDemo", "DungeonDemoContainer");

DungeonDemo.settings.set({
  title: "Dungeon!",
  author: "Ivan Cockrum",
  description: "Welcome... to the dungeon!",
  version: "0.0.1",
  // debug: { general: true },
  if_input_is_empty_print_room_description: false,
  if_input_is_an_asset_name_examine_it: true,
  responses: {
    no_response: "I have no response to your input. ",
    empty_input: "I didn't see any input. ",
  },
});

DungeonDemo.createAsset({
  class: "Room",
  name: "Inner Sanctum",
  description:
    "It feels like days since you entered The Dungeon. You've sprung all the traps, won all the battles, answered all the riddles, retrieved your items from the thief, and finally arrived here, at the inner sanctum. After years of questing, {our} goal is finally within reach. You clench your fist around the melted brass key that hangs by a fine chain around your neck. ",
});

DungeonDemo.createAsset({
  class: "Player",
  name: "Swordy McSwordface",
  is: { active: true },
  place: { in: "Inner Sanctum" },
});

DungeonDemo.createAsset({
  class: "Key",
  name: "melted brass key",
  is: {
    known: true,
  },
  iov: { unlock: { with_assets: ["battered chest"] } },
  description:
    "It's a small key, made of brass. It's scarred and a bit melted from some unknown incident, but the teeth appear intact. You've carried it since it was given to you by your father. ",
  article: "a",
  adjectives: ["brass", "melted", "small"],
  synonyms: ["chain"],
  place: { in: "Swordy McSwordface" },
});

DungeonDemo.createAsset({
  class: "Chest",
  name: "battered chest",
  place: { in: "Inner Sanctum" },
  is: {
    closed: true,
    locked: true,
  },
  dov: {
    close: false,
    unlock: { with_assets: ["melted brass key"] },
    open: {
      doAfterSuccess: function () {
        if (DungeonDemo.$("glowing chalice").$is("in", "battered chest")) {
          DungeonDemo.print(
            "The chalice glows warmly inside the chest, drawing you to it. If half of the legends are true..."
          );
        }
      },
    },
  },
  description:
    "The battered chest appears to be made of fire hardened teak or walnut bound with straps of dark, tarnished brass. ",
  adjectives: [
    "treasure",
    "wood",
    "brass",
    "dark",
    "tarnished",
    "teak",
    "walnut",
  ],
  synonyms: ["lock"],
});

DungeonDemo.createAsset({
  class: "Chalice",
  name: "glowing chalice",
  place: { in: "battered chest" },
  description:
    "The chalice glows enticingly, continuously shifting color across the visible spectrum. You've never wanted anything so much in your life. ",
  contains: "godsmead",
  dov: {
    take: {
      doBeforeTry: function () {
        if (DungeonDemo.$("glowing chalice").$is("in", "battered chest")) {
          DungeonDemo.prependOutput(
            "Your hand trembles as you reach for the chalice. "
          );
        }
      },
      doAfterSuccess: function () {
        DungeonDemo.print("Something unseen rumbles deep beneath the earth. ");
      },
    },
  },
}); // chalice

DungeonDemo.createAsset({
  class: "Liquid",
  name: "godsmead",
  description: "The godsmead shimmers like liquid gold. ",
}); // godsmead

Demo Source files

Right-click and choose "Save as..." to download source files.

Notes:

  • Demo games are set to a small size to fit doc pages. They can easily be enlarged via display settings.
  • Demo games all use the same theme. Colors and fonts can be changed via custom CSS.
  • Demo games don't include the core AdventureJS code. To run downloaded games locally, you'll need to also download copies of the core JS and CSS and set up this local folder structure.
AdventureJS
└── js
|   └── adventure.min.js
└── css
|   └── adventurejs.min.css
└── games
    ├── demogame01
    ├── demogame02
    └── demogame03