• Stars
    star
    180
  • Rank 213,097 (Top 5 %)
  • Language
    JavaScript
  • Created about 11 years ago
  • Updated almost 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Simple HTML Storytelling Engine

cyo

CYO (Choose Your Own) is an extremely simple, but powerful, storytelling engine built JavaScript.

Check Out the Project Page

Introduction

CYO lets you create exciting adventures using nothing but HTML code!

See how it works at the project page.

Patch Notes v3.1

  • Version 3.1 is a huge update that completely revises CYO - now way easier and simpler to use!
  • CYO 3.1 is no longer dependent on angular.js - just copy the script tag (see Getting Started) and you're good to go
  • Improved performance all around

Getting Started

Setting Up a Project

Getting started couldn't be easier! Just copy this script tag onto your document.

<script src="https://raw.githubusercontent.com/danielstern/cyo/master/cyo.js"></script>

Now you're ready to add <story>, <page> and <choice> tags to your web page!

Follow the tutorial to get started with your project

The Characters

Also known as "The Directives", wherein an interactive adventure is created, and Javascript (and Angular) fume about not being needed.

You can use these tools freely in your project to create your own interactive story adventure.

Story

The story tag initializes your story by pointing to your first chapter.

You initialize your CYO with a simple story tag.

<story>
And a splendid story it will be.
</story>

This element has to contain all the other elements. You can have multiple stories on a single page.

Page

Pages are hidden automatically and appear when choices are pressed.

<page>
	<p>
		You see a grizzled old man tending a hearth.
		<i>Something doesn't feel right here.</i>
	</p>
</page>

Choice

Choices are what make the storytelling process interactive. Clicking a choice will reveal the corresponding page.

<page>
    <p>You see a fork in the path. </p>
    <p>*Hmm... should I go left or right?*</p>
	<choice go-left>Guess I'll go left.</choice>
	<choice go-right>Right, definitely right.</choice>
</page>

Event

Events allow you to remember something special happening, for use later in your story.

<p>You find a flashlight.</p>
<event found-flashlight></event>

event tags are powerful tools that are automatically remembered for the whole story. They can change what the user sees and what choices they have when used in conjunction with the equally simple condition tag.

Condition

Condition tags will show or hide content conditionally, perfect for use in combination with the event tag.

condition tags will show or hide the content inside them based on event tags that the storygoer has previously encountered in their adventure.

<p>Suddenly, you hear a terrifying noise.</p>
<condition found-flashlight>
	<p>Don't be afraid, for the night is dark and full of terrors.</p>
	<choice use-flashlight>Turn on your flashlight</choice>
</condition>
<choice run-away>Run for it!</choice>

In this example, if the storygoer had previously found the flashlight, they would see another paragraph and have the option to use their flashlight, going to the use-flashlight page.

You can reverse a condition to its negative by adding the word not

<p>
	The tall gate is locked and made of heavy iron bars.
</p>
<choice go-home>These guys are closed.</choice>
<condition not pocket-knife-broke>
         <p>
		"Don't worry... we can use my trusty pocket knife!"
         <p></p>
		"Don't you mean your *rusty* pocket knife?"
         </p>
	<choice break-lock>Looks like they're not closed after all.</choice>
</condition>

Example

The markup of your typical page looks like this.

<page exploring-the-house>
<p>
	The floor creaks as you step into the house's massive foyer. Grimy paintings 
	of gaunt and ghastly figures line the walls, and go all the way up to the 
	ceiling. There is table in the middle of the room. 
</p>
<p>
	"Looks like Sal already got this room pretty good," says Brad nervously.
</p>
<p>
	"Looks like it."
</p>
<!-- The following paragraph will only appear if you got the necklace in 
	chapter one -->
<condition get-necklace>
	<p>
		The figures in the wall all seem old and tired. Rarely are they smiling. 
		Many of the men have long mustaches. You notice someone familiar in one of 
		the paintings.
	</p>
	<p>
		<i>That's impossible.</i> Suddenly, you reach for the necklace in your 
		pocket and pop it open. Sure enough. The woman is clearer in the picture. 
		She is has blonde hair and a striking face. She is not smiling in the 
		picture on the wall either. Below the picture you see the words <i>Eliza 
		Bedford.</i>
	</p>
	<!-- Your character learns Eliza's name and this comes in handy later. This 
	event never triggers if the condition it's inside isn't fulfilled. -->
	<event learned-elizas-name></event>
	<p>
		"What are you looking at?" asks Brad.
	</p>
	<p>
		"Nothing."
	</p>
</condition>
<p>
	The room has a dreary air of sadness about it. The wallpaper, purpled with 
	time, peels from the walls. Engraved candlesticks stand guard in neatly 
	ordered rows all around upper wall of the massive room. <i>Those look 
	valuable. A wonder someone hasn't taken them yet.</i>
</p>
<p>
	"Well, boys," says crazy Jake, rubbing his hands together. "Let's not get too 
	comfortable."
</p>
<p>
	"I'm going to look upstairs," says Brad. "Get a handful of jewels and get out 
	of here."
</p>
<p>
	You get a weird feeling in your stomach. You can't figure out what it is.
</p>
<!-- This page ends with two choices thereby allowing the story to go on
 as a new page is loaded. -->
<choice go-with-brad>Go with Brad</choice>
<choice go-with-jake>Go with Jake</choice>
</page>

Once you click a choice, all the other choices on the page disappear.

Making Your Own

Please use this tool to make your own adventures and share them. If you have any questions, or need a new feature to complete your latest epic, post it up here. Better yet, add the feature yourself and make a pull request.

Made a Game with CYO?

I'd be happy to link to it on the project page! Get in touch with me @danieljackstern or [email protected]

Happy adventuring!

Check Out the Project Page for More Examples

CYO was created by Daniel Stern

Configuration

Limited configuration objects can be set per story by using an HTML tag.

Example

<story the-aztec-ruins>
    <pageDirectory pages/>
    ...
</story>

Supported Configuration Settings

| Name | Effect | Default | Example | | ------------- | --------------- | ----- | | pageDirectory | Specifies where to look for external pages | "" |

Troubleshooting

No one gets it perfect the first time!

Help! My story just won't work!

Follow the Creating a Story Tutorial (click here).

Some page I made isn't appearing or isn't loading correctly

Open the Developer Console in Chrome by pressing F12. Helpful messages will appear in yellow indicating common mistakes like mismatched file names.

More Repositories

1

range.css

Awesome Cross-Browser CSS Styles Made with LESS
JavaScript
618
star
2

isomorphic-react

A simple but powerful React application built on a standards-compliant back-end
JavaScript
380
star
3

ngAudio

Angular Directive for Playing Sounds
CSS
369
star
4

express-react-fullstack

Simple, Useful Full Stack Express and React Application
JavaScript
360
star
5

redux-saga-cart

A fully-functional shopping cart built with Redux Saga using Yield - Run with accompanying server https://github.com/danielstern/redux-saga-shopping-cart-server
JavaScript
106
star
6

vue-todomvc

A TodoMVC Application Built With Vue ⭐
HTML
105
star
7

server-rendered-react-app

JavaScript
98
star
8

MagicCircles

The world's awesomest, most useless library.
JavaScript
95
star
9

advanced-redux

A messenger service built with Redux
JavaScript
92
star
10

highground

ES6-Based Unit Testing
JavaScript
62
star
11

redux-saga-shopping-cart-server

A back-end server to be used with the accompanying Shopping Cart tutorial - Run with this https://github.com/danielstern/redux-saga-cart
JavaScript
52
star
12

redux-saga-sandbox

A console-based Redux Saga sandbox
HTML
39
star
13

compiling-typescript

A Simple, Extensible TypeScript Application
TypeScript
35
star
14

styling-react-native

JavaScript
32
star
15

react-express-examplar

JavaScript
27
star
16

flux-redux

An application implementing Flux and Redux with few other dependencies
JavaScript
24
star
17

vue-jest

JavaScript
22
star
18

force-graph-example

A Simple D3 Force Graph with Familiar Data
JavaScript
18
star
19

angular-tdd-exemplar

angular TDD sample project
JavaScript
18
star
20

rxjs-operators

A collection of simple examples for RxJS operators
JavaScript
15
star
21

jest-examplar

A repository containing a Jest Example for React
JavaScript
15
star
22

array.visualize

JOKES
JavaScript
11
star
23

TodoMVC

Identitical TodoMVC in Vue AND in React AND in Angular
JavaScript
11
star
24

eCommerce-application

commerce-app
JavaScript
11
star
25

assassin-game

A Responsive Angular.js Open Source Assassin Game
JavaScript
8
star
26

react-insights

HTML
7
star
27

configuring-typescript

A simple TypeScript application with instructions for usage
TypeScript
6
star
28

jukeboxjs

An audio synthesis API for Javascript
JavaScript
5
star
29

photoshopSpritesheet

A simple script for generating a spritesheet
JavaScript
5
star
30

generator-es6-webapp

A Yeoman generator to create an app which automatically transpiles ES6 to ES5 - also includes LESS and Skeleton
JavaScript
5
star
31

rxjs-observable-playground

A low overhead environment for experimenting with Reactive programming and observables
HTML
5
star
32

financejs

A library for calculating things
HTML
4
star
33

science

Demonstrating data manipulation
JavaScript
4
star
34

workshop-functional-programming-closures

Examples to Teach Closures and Functional Programming
JavaScript
3
star
35

mortgage-calculator

An angular app for calculating mortgage payments
JavaScript
3
star
36

Monopoly-D3

So you can win at Monopoly
JavaScript
3
star
37

angular-synthesizer

A Synthesizer for WebAudio with Angular JS
JavaScript
3
star
38

Squaretide

A colorful tile game compatible with all platforms
JavaScript
2
star
39

google-analytics-demo

HTML
2
star
40

nurl

Node-based Curl-like Command Line Interface Installed through NPM
JavaScript
2
star
41

vue-jest-demo-repo

JavaScript
2
star
42

async-js-demos

HTML
2
star
43

Rectangular

It's Box2D, It's Angular, It's Totally Square!
JavaScript
2
star
44

react-redux-app

A Simple App Built with React and Redux
JavaScript
2
star
45

integration-test-repo-demo

A demo of integration with Github
JavaScript
2
star
46

Lisa

A JavaScript Neuro-Computational Matrix
JavaScript
2
star
47

pokemon-d3

don't ask
JavaScript
2
star
48

redux-tool

A CLI Tool for React-Redux Applications
JavaScript
2
star
49

english-language-api

An API To Internet the Words Until they are Things that Computer
JavaScript
2
star
50

flashforum

ITS A FORUM HELLA FAST
JavaScript
1
star
51

EliteBattleArena

sweet open source video game
CSS
1
star
52

elite-battle-arena-2

JavaScript
1
star
53

danielsternwebsite

JavaScript
1
star
54

express-rest-api

An API Built with Express on a Node Framework
JavaScript
1
star
55

modern-webapp

A new take on the webapp template with typescript and angular built in
JavaScript
1
star
56

Lisa4

A Neuro-computational Matrix Built with TypeScript
JavaScript
1
star
57

ai-chess-duels

See Which AI is the Best at Chess
JavaScript
1
star
58

websockets-exemplar

A useful message board application with Socket.io / Node.js + Websockets
JavaScript
1
star
59

LorienIpsum

Tall and Fair Filler for Your Projects
JavaScript
1
star
60

react-router-example

A dynamic application built with React Router
JavaScript
1
star
61

calculator

Angular Powered Responsive Calculator
JavaScript
1
star
62

chat-app

A simple chat application demonstrating async programming
JavaScript
1
star
63

Underscore-Without-Underscore

Underscore's Handy Functions without the need for the library Underscore
JavaScript
1
star
64

react-newsfeed

JavaScript
1
star
65

apparel-image-generator

Generates Colorized, Customizable Images of Apparel with Logos
JavaScript
1
star
66

simplest-heroku-node-app

An extremely simple boilerplate for templating quick apps on Heroku using Node
JavaScript
1
star
67

Simplest.React.Boilerplate

JavaScript
1
star
68

RateofReturnCalculator

JavaScript
1
star
69

volca-beats

node.js driver for korg VOLCA BEATS vintage analogue synthesizer
JavaScript
1
star
70

simple_react_boilerplate

HTML
1
star
71

navatar

Navatar, the Node.js Avatar Generator
JavaScript
1
star
72

calculon

A Friendly Library for a Time When Conventional Calculators are No Longer Needed... 2011.
JavaScript
1
star
73

workshop-testing-linting

Materials for workshop on Testing / Linting
JavaScript
1
star
74

demo-data-pipeline

Python
1
star
75

jest-typescipt-testing

TypeScript
1
star
76

vue-testing-vitest

JavaScript
1
star
77

purescript-sandbox

PureScript
1
star
78

purescript-fundamentals

A series of simple and effective PureScript examples
Dhall
1
star
79

debugging-typescript

TypeScript
1
star
80

dungeonjs

JavaScript
1
star