Skip to content

Instantly share code, notes, and snippets.

@potomak
Last active February 3, 2018 13:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save potomak/acebd8fe14942fab4e8e to your computer and use it in GitHub Desktop.
Save potomak/acebd8fe14942fab4e8e to your computer and use it in GitHub Desktop.
An interactive story
state style
cave
true
body { background: gold; color: red; } a { color: #900; }

You found a treasure!

You can steal the treasure or you can just go back to the forest.

init state style
function() { window.city = window.city + 1 || 1; }
cityCounter citizen
function() { return window.city + ' time' + (window.city > 1 ? 's' : ''); }
function() { return window.city > 4; }
body, footer { background: #222; color: #eee; }

A big and crowded city.

{{^citizen}} You have visited the city {{cityCounter}}. {{/citizen}}

city

{{#citizen}} You visited this city so many times... This is your new home now. {{/citizen}} {{^citizen}} Go back. {{/citizen}}

style
body, footer { background: #44e544; color: #fff; } a { color: #227222; }

You're in the forest.

forest

{{^cave}} Go back or explore the cave. {{/cave}}

{{#cave}} {{#treasure}} You feel guilty because you stole a treasure, but you're rich. You're ready to start a new life in the city. {{/treasure}} {{^treasure}} You have nothing, but yourself and the nature. You're happy. {{/treasure}} {{/cave}}

state
treasure
true

You take all the gold that you can and run back to the forest.

body, h1, h2, h3, h4 {
font-family: monospace;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment