Gamefic plots use scenes to handle player interactions. Player characters participate in one scene per game turn.
How Scenes Work
Each scene has a start and a finish. The start is executed at the beginning of the turn. The finish executes after the game engine receives player input.
The scene’s finish is typically responsible for processing the input. In a text adventure, for example, the default scene will treat the input as a command to be performed by the player’s character.
There are seven basic scene types provided by the Gamefic core.
The default scene type for most plots.
Activity parses player input into an action performed by the player’s character. In a text adventure, whenever players execute a command like GO NORTH or GET LAMP, they’re in an
:default_scene attribute is
Activity unless an author changes it.
A scene that ends the plot (or the player’s participation in it).
The plot provides a
:default_conclusion that can be used to end the game.
The scene that begins the player’s participation in the plot. Every plot has a single introduction that gets defined by the
A scene that requires the player to select from one of several options.
A scene that waits for player input before proceeding to the next turn. In a text adventure, for example, a
Pause will ask the player to press enter to continue. This can be useful when the author wants to bring attention to a block of text or split a long passage into smaller parts.
A scene which can only proceed after the player selects Yes or No.
Unlike the other scene types, a Default scene does not provide any functionality on its own, but is merely a framework for building highly customized scenes. The author is responsible for determining how player input is processed in the scene’s
on_start block. Without the block, player input will be ignored.
Plots provide several helper methods to simplify creation of various scene types.
A Simple Cutscene
The following example pauses the game in response to the READ command.
introduction do |actor|
actor.tell "You're in a library."
respond :read do |actor|
pause :reading do |actor|
actor.tell "You spend some time with a good book."
$ rake ruby:run
You're in a library.
You spend some time with a good book.
Press enter to continue...
Note that only one scene can be cued at a time. When a character cues a new scene, any previously cued scene is discarded.
Characters also have a
conclude method that is functionally equivalent to
cue, except it requires the specified scene to be a
Next: Creating subplots