Skip to content

Getting Started

Thomas edited this page Jul 30, 2023 · 3 revisions
  1. Getting Started Audax Engine provides a simple API for building interactive text-based stories and games. To get started, follow these steps:

Include the necessary libraries and packages. Create an instance of the AudaxEngine class. Define your main story and its starting point. Run the game by calling the onStart method of the main story. Here's a step-by-step guide to getting started:

Step 1: Include Libraries Make sure you have the necessary libraries and packages imported in your project. For this example, the required packages are:

package me.adversing;

import me.adversing.engine.core.AudaxEngine; import me.adversing.engine.core.handlers.StoryHandler; import me.adversing.story.MainStory;

Step 2: Create Audax Engine Instantiate the AudaxEngine class in your Main class:

public class Main {

private static AudaxEngine engine;
private static StoryHandler storyHandler;

public static void main(String[] args) {
    engine = new AudaxEngine();
    storyHandler = new StoryHandler();
    // Other setup code...
}

}

Step 3: Create the Main Story In this example, we have a MainStory class extending the Story class. This class represents the main story of your game and contains the chapters and episodes that constitute the narrative.

java Copy code package me.adversing.story;

import me.adversing.engine.story.Story; import me.adversing.story.chapters.FirstChapter; import me.adversing.story.characters.MainCharacter; import me.adversing.story.map.FirstGameMap;

import java.util.List;

public class MainStory extends Story { public MainStory() { super("storia-principale", "Storia Principale", "Test", List.of(new FirstChapter()), List.of(new MainCharacter()), new FirstGameMap(), false, true ); }

@Override
public void onStart() {
    getChapterById("chapter-1").onStart();
}

@Override
public void onEnd() {

}

}

Step 4: Run the Game Finally, in the main method, create an instance of your MainStory class, set it as active, and call its onStart method to start the game.

public static void main(String[] args) { engine = new AudaxEngine(); storyHandler = new StoryHandler(); MainStory mainStory = new MainStory(); storyHandler.getStories().add(mainStory); mainStory.setActive(true); mainStory.onStart(); } Now you have set up the basic structure of your game using Audax Engine. Next, we'll dive into more details on creating a story with chapters and episodes.