-
Notifications
You must be signed in to change notification settings - Fork 1
Creating a Story
- Creating a Story A story is the main narrative of your game. It consists of chapters, episodes, characters, maps, and other essential components. In this section, we'll cover how to create and configure a story.
Step 1: Create a Story Class To create a story, create a new class that extends the Story class provided by Audax Engine. For example:
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() {
// Start the first chapter when the story begins.
getChapterById("chapter-1").onStart();
}
@Override
public void onEnd() {
// Perform any actions when the story ends.
}
} Step 2: Configuring the Story In the constructor of your MainStory class, you can configure various properties of the story, such as its title, description, chapters, characters, and the starting map.
For example, in the MainStory constructor:
java Copy code public MainStory() { super("storia-principale", // Story ID "Storia Principale", // Story title "Test", // Story description List.of(new FirstChapter()), // List of chapters List.of(new MainCharacter()), // List of characters new FirstGameMap(), // Starting game map false, // Indicate if the story is a multiplayer session (false for single-player) true // Indicate if the story supports saving and loading (true for saving enabled) ); } Here's a breakdown of the parameters:
"storia-principale": This is the unique ID of the story. Replace it with a suitable ID for your story. "Storia Principale": The title of the story, which will be displayed to players. "Test": A brief description or summary of the story. List.of(new FirstChapter()): The chapters that make up the story. Replace FirstChapter with your own chapter classes. List.of(new MainCharacter()): The characters in the story. Replace MainCharacter with your own character classes. new FirstGameMap(): The starting game map for the story. Replace FirstGameMap with your own map class. false: Indicates whether the story is a multiplayer session or not. Set to true for multiplayer. true: Indicates whether the story supports saving and loading. Set to false to disable saving. Step 3: Implement onStart and onEnd Methods Override the onStart and onEnd methods in your MainStory class. The onStart method will be called when the story begins, and the onEnd method will be called when the story ends.
java Copy code @Override public void onStart() { // Start the first chapter when the story begins. getChapterById("chapter-1").onStart(); }
@Override public void onEnd() { // Perform any actions when the story ends. } With these steps, you've successfully created and configured your story using Audax Engine. Next, let's move on to adding chapters and episodes to the story.