Gamefic plots use scenes to handle player interactions. Player characters participate in one or more scenes every game turn.
How Scenes Work
Each scene has a start and a finish. The start is executed either at the beginning of the turn or whenever the scene is cued (see the “
cue” section). The finish executes after the game engine receives player input.
Note that characters can only participate in one scene at a time. If a character cues a new scene, the current scene will be discarded.
The scene’s finish is typically responsible for processing player 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.
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.
MultipleChoice scene. Each available option is mapped to a scene. The selected scene will be cued when the
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.
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.
Gamefic.script do introduction do |actor| actor.tell "You're in a library." end respond :read do |actor| actor.prepare @reading end @reading = pause do |actor| actor.tell "You spend some time with a good book." actor.prepare default_scene end end
$ rake ruby:run You're in a library. > read You spend some time with a good book. Press enter to continue... >
Characters enter scenes via the
cue methods. The difference between the methods is subtle but significant. The
prepare method specifies a scene to enter at the beginning of the next turn. The
cue method starts the new scene immediately.
Consider the example cutscene above. The READ action calls
actor.prepare @reading, which means the
@reading scene starts at the beginning of the next turn. If the action called
actor.cue @reading instead, the player would not be prompted to continue, because the
@reading scene would start immediately and prepare
default_scene for the next turn.
In most cases, authors should use
prepare instead of
Note that only one scene can be prepared at a time. When a character prepares for a new scene, any previously prepared 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