Pre-release
AdventureJS Docs Downloads Bundler Devlog Score: 0 Moves: 0
Example showing how to create a Magnetic Scrolls layout for AdventureJS. tutorial, Magnetic Scrolls MagneticScrollsLayout styles

Display & Layouts:Magnetic Scrolls

This example shows a layout in the style of Magnetic Scrolls games such as Fish!, Corruption, and The Guild of Thieves. (Well, sort of, since Magnetic Scrolls windows could be dragged around by the player and didn't have a singular fixed layout.)

 

// MagneticScrollsLayout.js
/* global AdventureJS A Game */

var MagneticScrollsLayout = new AdventureJS.Game(
  "MagneticScrollsLayout",
  "MagneticScrollsLayoutContainer"
);

MagneticScrollsLayout.settings.set({
  display: "inline",
  layout: "magneticscrolls",
  title: "Magnetic Scrolls Layout",
  author: "Ivan Cockrum",
  description: "Here is an example of a Magnetic Scrolls layout. ",
  version: "0.0.1",
});

MagneticScrollsLayout.createImageLookup({
  images: [
    {
      id: "startroom",
      src: "images/startroom.png",
    },
    {
      id: "northroom",
      src: "images/northroom.png",
    },
    {
      id: "southroom",
      src: "images/southroom.png",
    },
    {
      id: "eastroom",
      src: "images/eastroom.png",
    },
    {
      id: "westroom",
      src: "images/westroom.png",
    },
  ],
});

// Create the room image widget.
MagneticScrollsLayout.createWidget({
  class: "RoomImage",
  id: "MyRoomImageWidget",
  cssclasses: [],
  region: "header",
  messages: {
    randomize: true,
    frequency: 0.33,
    array: [
      "{We} clicked the picture, but there's no need for that. It's just a visual reference. ",
      "There's no need to click. Sorry, but this isn't a point & click game.",
      "Move on, there's nothing to do in the picture. ",
      "Whattaya think this is, a point & click game? ",
    ],
  },
});

// Create the inventory widget.
MagneticScrollsLayout.createWidget({
  class: "InventoryList",
  id: "MyInventoryList",
  cssclasses: [],
  region: "left",
  print_images: true,
  hide_labels: false,
});

// Create the object widget.
MagneticScrollsLayout.createWidget({
  class: "ObjectList",
  id: "MyObjectList",
  cssclasses: [],
  region: "right",
  print_images: true,
  hide_labels: false,
});

// Create the compass widget.
MagneticScrollsLayout.createWidget({
  class: "Compass",
  id: "MyCompass",
  format: "rose1",
  cssclasses: [],
  region: "footer",
});

// Create the compass widget.
MagneticScrollsLayout.createWidget({
  class: "Compass",
  id: "MyMap",
  format: "map",
  cssclasses: [],
  region: "footer",
});

MagneticScrollsLayout.createAsset({
  class: "Player",
  name: "Explorer",
  place: { in: "Start Room" },
});
MagneticScrollsLayout.createAsset({
  class: "Pencil",
  name: "indigo pencil",
  a: "an",
  adjectives: "indigo, colored",
  place: { in: "Start Room" },
  description: "It's an indigo colored pencil. ",
});
MagneticScrollsLayout.createAsset({
  class: "Pencil",
  name: "violet pencil",
  article: "a",
  adjectives: "violet, colored",
  place: { in: "Start Room" },
  description: "It's a violet colored pencil. ",
});
MagneticScrollsLayout.createAsset({
  class: "Entity",
  name: "paint brush",
  article: "a",
  // adjectives: "",
  place: { in: "Start Room" },
  description: "It's a number 12 paint brush. ",
});

MagneticScrollsLayout.createAsset({
  class: "Room",
  name: "Start Room",
  image: "startroom",
  description: `
    This is the Start Room.
  `,
  exits: {
    east: "East Room",
    west: "West Room",
    north: "North Room",
    south: "South Room",
  },
});
MagneticScrollsLayout.createAsset({
  class: "Pencil",
  name: "yellow pencil",
  article: "a",
  adjectives: "yellow, colored",
  place: { in: "Start Room" },
  description: "It's a yellow colored pencil. ",
});

MagneticScrollsLayout.createAsset({
  class: "Room",
  name: "North Room",
  image: "northroom",
  description: `This is the North Room. `,
  exits: {
    northwest: "Northwest Room",
    northeast: "Northeast Room",
    south: "Start Room",
  },
});
MagneticScrollsLayout.createAsset({
  class: "Pencil",
  name: "blue pencil",
  article: "a",
  adjectives: "blue, colored",
  place: { in: "North Room" },
  description: "It's a colored pencil, zinc blue. ",
});
MagneticScrollsLayout.createAsset({
  class: "Crayon",
  name: "pink crayon",
  article: "a",
  adjectives: "pink, colored",
  place: { in: "North Room" },
  description: "It's a pink crayon. ",
});

MagneticScrollsLayout.createAsset({
  class: "Room",
  name: "South Room",
  image: "southroom",
  description: `This is the South Room. `,
  exits: {
    north: "Start Room",
    southwest: "Southwest Room",
    southeast: "Southeast Room",
  },
});
MagneticScrollsLayout.createAsset({
  class: "Pencil",
  name: "red pencil",
  article: "a",
  adjectives: "red, colored",
  place: { in: "South Room" },
  description: "It's a red colored pencil. ",
});
MagneticScrollsLayout.createAsset({
  class: "Crayon",
  name: "white crayon",
  article: "a",
  adjectives: "white, colored",
  place: { in: "South Room" },
  description: "It's a white crayon. ",
});

MagneticScrollsLayout.createAsset({
  class: "Room",
  name: "East Room",
  image: "eastroom",
  description: `This is the East Room. `,
  exits: {
    west: "Start Room",
    in: "In Room",
  },
});
MagneticScrollsLayout.createAsset({
  class: "Pencil",
  name: "orange pencil",
  // article: "a",
  adjectives: "orange, colored",
  place: { in: "Explorer" },
  description: "It's an orange colored pencil. ",
});
MagneticScrollsLayout.createAsset({
  class: "Crayon",
  name: "maroon crayon",
  article: "a",
  adjectives: "maroon, colored",
  place: { in: "Explorer" },
  description: "It's a maroon crayon. ",
});

MagneticScrollsLayout.createAsset({
  class: "Room",
  name: "West Room",
  image: "westroom",
  description: `This is the West Room. `,
  exits: {
    east: "Start Room",
    out: "Out Room",
  },
});
MagneticScrollsLayout.createAsset({
  class: "Pencil",
  name: "green pencil",
  article: "a",
  adjectives: "green, colored",
  place: { in: "West Room" },
  description: "It's a green colored pencil. ",
});
MagneticScrollsLayout.createAsset({
  class: "Crayon",
  name: "plum crayon",
  article: "a",
  adjectives: "plum, colored",
  place: { in: "West Room" },
  description: "It's a plum crayon. ",
});

MagneticScrollsLayout.createAsset({
  class: "Room",
  name: "Northwest Room",
  description: `This is the Northwest Room. `,
  exits: {
    southeast: "North Room",
  },
});

MagneticScrollsLayout.createAsset({
  class: "Room",
  name: "Northeast Room",
  description: `This is the Northeast Room. `,
  exits: {
    southwest: "North Room",
  },
});

MagneticScrollsLayout.createAsset({
  class: "Room",
  name: "Southwest Room",
  description: `This is the Southwest Room. `,
  exits: {
    northeast: "South Room",
    down: "Down Room",
  },
});

MagneticScrollsLayout.createAsset({
  class: "Room",
  name: "Southeast Room",
  description: `This is the Southeast Room. `,
  exits: {
    northwest: "South Room",
    up: "Up Room",
  },
});

MagneticScrollsLayout.createAsset({
  class: "Room",
  name: "In Room",
  description: `This is the In Room. `,
  exits: {
    out: "East Room",
  },
});

MagneticScrollsLayout.createAsset({
  class: "Room",
  name: "Out Room",
  description: `This is the Out Room. `,
  exits: {
    in: "West Room",
  },
});

MagneticScrollsLayout.createAsset({
  class: "Room",
  name: "Down Room",
  description: `This is the Down Room. `,
  exits: {
    up: "Southwest Room",
  },
});

MagneticScrollsLayout.createAsset({
  class: "Room",
  name: "Up Room",
  description: `This is the Up Room. `,
  exits: {
    down: "Southeast Room",
  },
});

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