Git Product home page Git Product logo

blade-ink's Introduction

blade-ink

This is a Java port of inkle's ink, a scripting language for writing interactive narrative.

blade-ink should support pretty much everything the original version does. If you find any bugs, please report them here!

Getting started

Loading a json file

First you need to turn your ink file into a json file as described here. Here is an example to load the ink JSON file as an String:

		
		InputStream systemResourceAsStream = ClassLoader.getSystemResourceAsStream(filename);

		BufferedReader br = new BufferedReader(new InputStreamReader(systemResourceAsStream, "UTF-8"));

		try {
			StringBuilder sb = new StringBuilder();
			String line = br.readLine();

			while (line != null) {
				sb.append(line);
				sb.append("\n");
				line = br.readLine();
			}

		} finally {
			br.close();
		}
		
		String json = sb.toSTring().replace('\uFEFF', ' ');

Starting a story

Here's a taster of the code you need to get started:

		
		// 1) Load story
		Story story = new Story(sourceJsonString);
		

		// 2) Game content, line by line
		while (story.canContinue()) {
				String line = story.Continue();
				System.out.print(line);
		}

		// 3) Display story.currentChoices list, allow player to choose one
		if (story.getCurrentChoices().size() > 0) {

				for (Choice c : story.getCurrentChoices()) {
					System.out.println(c.getText());
				}

				story.chooseChoiceIndex(0);
			}
		}
		
		// 4) Back to 2
		...

From there on, you can follow the official guide. All functions are named exactly the same.

Integration

The blade-ink library is available in the Maven archives.

Using with Gradle

Add the following line to your build.gradle file under the dependencies section of the core project:

compile "com.bladecoder.ink:blade-ink:{version}"

Replace {version} with the newest version number!

Then simply right-click the project and choose Gradle->Refresh All.

Using with Maven

Right-click on your project and choose Maven->Add Dependency and search for bladecoder. Make sure to choose the most recent version if multiple appear!

Eclipse

First, clone this project to your computer and add it to Eclipse. Then simply click on your project, and choose Build Path->Configure Build Path. Then go to Projects->Add and add the cloned project.

blade-ink's People

Contributors

arcnor avatar bladecoder avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.