On this page you start your own story. By the end, the game shows the Palacio de Bellas Artes and three lines of narration.

Get the tutorial’s pictures and music

The tutorial’s story uses a few pictures and sounds, and the starter game’s assets/ folders are empty. Download them in one file:

  1. Download the tutorial assets (monogatari-tutorial-assets-v2.9.0.zip, about 7 MB) and unzip it, the same way as the starter game. Inside, you’ll find a folder called monogatari-tutorial-assets.

  2. Copy the four folders inside it, characters, music, scenes and sounds, into your game’s assets folder. Your game already has folders with those names: if your computer asks whether to merge or replace them, either answer works, since they’re empty.

  3. Check one: assets/scenes/ in your game now holds afternoon.jpg, morning.jpg, night.jpg and night-light.jpg, four pictures of the same place.

The pictures, the Palacio de Bellas Artes in Mexico City at four times of day and the characters Yui and Mio, are by Queen BeeBee. The music is Monogatari’s sample music. They belong to the Monogatari project, and you can use them to learn and to try things out; CREDITS.txt in the download says where each file comes from. Queen BeeBee’s pictures also have terms of their own, in TERMS.txt: always credit her, and never use them with AI or in anything that makes money.

The script

Open js/script.js in your text editor. Near the bottom, it starts like this:

monogatari.script({
  // The game starts here.
  'Start': [
    'show scene #f7f6f6 with fadeIn',

That part is the script: everything that happens in your game, in order. It’s made of two kinds of pieces:

  • A label is a name followed by a list, between [ and ]. 'Start' is a label, and the game begins with it. The sample story has two more, 'Yes' and 'No'.
  • A statement is one step of the story, written as text between quotes and followed by a comma. Each statement is a line of dialog, or an instruction, such as 'show scene #f7f6f6 with fadeIn', which shows a background.

When the player clicks, the game moves to the next statement.

Write a line of narration

Replace the sample story with yours.

  1. Select everything from the line monogatari.script({ to the end of the file, the last line being });, and delete it.

  2. Type or paste this in its place:

    monogatari.script({
      'Start': [
        'show scene #2b2340',
        'The bell rings at the end of the drawing class.',
        'end',
      ],
    });
  3. Save the file and reload the game. Click Start.

The screen turns dark purple, and the text box at the bottom says The bell rings at the end of the drawing class. Click once more and the game goes back to the main menu.

A plain dark purple screen. The text box at the bottom says "The bell rings at the end of the drawing class."
A plain color as the background, and one line of narration.

Each of the three statements does one thing:

  • 'show scene #2b2340' sets the background. #2b2340 is a color code: a # and six digits or letters from a to f, the way web pages write colors.
  • 'The bell rings at the end of the drawing class.' is narration: text without a speaker. Any statement that isn’t an instruction and doesn’t start with a character’s short name (you’ll give characters one on the next page) is shown as narration.
  • 'end' ends the game and takes the player back to the main menu. End every label with end, or with a statement that goes somewhere else, which you’ll meet on the Choices and endings page.

IMPORTANT

Three rules keep the script working:

  • Each statement starts and ends with the same quote: ' or ".
  • Statements are separated by commas. A comma after the last one of a label is allowed, so put one after every statement and you’ll never miss one.
  • Quotes must be straight ('), not curly (’). A curly apostrophe inside a line of text is fine.

Break one of them and the game doesn’t start. When something goes wrong shows what you’ll see, and how to find the mistake.

Show a picture as the background

A picture you use in the game is an asset. Before the script can show an asset, you give it a name in js/script.js, so the script can call it by that name instead of by its file.

  1. Find the list of backgrounds in js/script.js, above the characters. It starts with a comment, the line beginning with //:

    // Define the backgrounds for each scene.
    monogatari.assets('scenes', {
    
    });
  2. Add the afternoon picture to it:

    // Define the backgrounds for each scene.
    monogatari.assets('scenes', {
      'afternoon': 'afternoon.jpg',
    });

    The first part, 'afternoon', is the name you’ll use in the script. The second, 'afternoon.jpg', is the file, and Monogatari looks for it in assets/scenes/, the folder for backgrounds.

  3. Change the script so it shows the palace after the first line:

    monogatari.script({
      'Start': [
        'show scene #2b2340',
        'The bell rings at the end of the drawing class.',
        'show scene afternoon with fadeIn',
        'Everyone hurries off, and soon the path to the Palacio de Bellas Artes is quiet.',
        'Someone left a sketchbook on the low wall by the path.',
        'end',
      ],
    });
  4. Save, reload and click Start. Click through the lines.

After the first line, the palace fades in over the purple, and the narration goes on.

The Palacio de Bellas Artes in the afternoon, at the end of a stone path lined with lamps and bushes. The text box says "Someone left a sketchbook on the low wall by the path."
Your first scene: a background and narration.

with fadeIn is an animation: the palace fades in instead of appearing at once. Leave it out and the background changes instantly. Show Scene explains the statement and what else it can do.

WARNING

The file must be in the right folder, with the exact name you wrote, and the name in the script must match the one in the list. If either is wrong, the screen turns black where the background should be, and no dialog tells you why. Online, Afternoon.jpg and afternoon.jpg are two different files, even when your computer treats them as the same, so match the capitals too.

What you have so far

The end of your js/script.js:

// Define the backgrounds for each scene.
monogatari.assets('scenes', {
  'afternoon': 'afternoon.jpg',
});

// Define the Characters
monogatari.characters({
  'y': {
    name: 'Yui',
    color: '#5bcaff',
  },
});

monogatari.script({
  'Start': [
    'show scene #2b2340',
    'The bell rings at the end of the drawing class.',
    'show scene afternoon with fadeIn',
    'Everyone hurries off, and soon the path to the Palacio de Bellas Artes is quiet.',
    'Someone left a sketchbook on the low wall by the path.',
    'end',
  ],
});

The characters part comes from the starter game, and you’ll change it on the next page.

Next

Characters and expressions: someone else is still on the path.