Section: Posts

Creating Interactive Dialogue in Javascript with JSON: Part 2

Jun 3, 2018 6 min.

In the last section, we got familiar with the problem and laid out what we’re trying to do; we talked about text nodes and how they store the dialogue, and either information about how to transition to the next node, or information about the choices to present the user with. Now, let’s get into writing the code to work on that file. To start we are going to focus on writing the code that iterates over the file, and then we will create the GUI with buttons and text afterwards.

Creating Interactive Dialogue in Javascript with JSON: Part 1

Jun 2, 2018 8 min.

In this series I’m going to go over creating a Javascript program that iterates over JSON to tell an interactive story. Here’s an example: var Story; if (Story !== undefined) { console.log("Story is already defined"); } else { import('/js/story.js') .then(result = { Story = result.Story; MakeUIHandler(); function MakeUIHandler() { const characterName = document.querySelector('#characterName1'); const buttons = document.querySelector('#buttons1'); const displayText = document.querySelector('#text1'); console.log('\/json\/introToDialogue.json') fetch('\/json\/introToDialogue.json') .then(function(response){ return response.