-
Notifications
You must be signed in to change notification settings - Fork 1
Working with Characters
- Working with Characters Characters play a crucial role in your interactive story. They represent the various entities and individuals with which the player can interact. In this section, we'll cover how to create and work with characters using Audax Engine.
Step 1: Create a Character Class To create a character, create a new class that extends the Character class provided by Audax Engine. For example:
java Copy code package me.adversing.story.characters;
import me.adversing.engine.obj.entities.character.Character; import me.adversing.engine.obj.entities.character.info.CharacterInformation; import me.adversing.engine.obj.entities.character.inv.Inventory; import me.adversing.engine.obj.entities.character.status.CharacterStatus; import me.adversing.engine.obj.entities.gameobject.GameObject; import me.adversing.engine.obj.entities.gameobject.properties.Interactable; import me.adversing.story.map.areas.FirstGameArea;
import java.util.ArrayList; import java.util.List;
public class MainCharacter extends Character {
public MainCharacter() {
super(new CharacterInformation("character-1", "Test", "test", 19, "test", new ArrayList<>()),
CharacterStatus.ALIVE,
new Inventory(5, List.of()),
new ArrayList<>(),
new FirstGameArea());
}
@Override
public void interactedBy(Interactable interactable) {
// Implement how the character interacts with other entities or objects.
}
@Override
public void onInteract(Character character) {
// Implement how the character interacts with another character.
}
@Override
public void onInteract(GameObject gameObject) {
// Implement how the character interacts with a game object.
}
} Step 2: Character Properties In the constructor of your MainCharacter class, you can configure various properties of the character, such as its information, status, inventory, and starting game area.
java Copy code public MainCharacter() { super(new CharacterInformation("character-1", "Test", "test", 19, "test", new ArrayList<>()), CharacterStatus.ALIVE, new Inventory(5, List.of()), new ArrayList<>(), new FirstGameArea()); } Here's a breakdown of the parameters:
"character-1": This is the unique ID of the character. Replace it with a suitable ID for your character. "Test": The name of the character, which will be displayed to players. "test": A brief description or profile of the character. 19: The age of the character. "test": Any additional information or details about the character. CharacterStatus.ALIVE: The initial status of the character. You can use different status types such as ALIVE, DEAD, INCAPACITATED, etc. new Inventory(5, List.of()): The character's inventory, which can store items. In this example, the character has a maximum inventory size of 5 and starts with an empty list of items. new ArrayList<>(): A list of game areas the character can access. In this example, the character starts in the FirstGameArea. Step 3: Implement Interactions In the MainCharacter class, you can implement various methods related to character interactions:
interactedBy(Interactable interactable): This method is called when the character is interacted with by another entity or object. onInteract(Character character): This method is called when the character interacts with another character. onInteract(GameObject gameObject): This method is called when the character interacts with a game object. You can customize the behavior of the character based on these interactions.
java Copy code @Override public void interactedBy(Interactable interactable) { // Implement how the character interacts with other entities or objects. }
@Override public void onInteract(Character character) { // Implement how the character interacts with another character. }
@Override public void onInteract(GameObject gameObject) { // Implement how the character interacts with a game object. } With these steps, you have successfully created and configured a character using Audax Engine. You can now use this character in your story to enable interactions with other entities and game objects.