Gamefic

Adventure Games and Interactive Fiction

Scenes

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.

Scene Types

There are seven basic scene types provided by the Gamefic core.

Activity

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 Activity scene.

The plot’s :default_scene attribute is Activity unless an author changes it.

Conclusion

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.

Introduction

The scene that begins the player’s participation in the plot. Every plot has a single introduction that gets defined by the introduction method.

MultipleChoice

A scene that requires the player to select from one of several options.

Pause

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.

YesOrNo

A scene which can only proceed after the player selects Yes or No.

Default

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.

Scene Methods

Plots provide several helper methods to simplify creation of various scene types.

  • introduction
  • conclusion
  • pause
  • multiple_choice
  • yes_or_no
  • block

A Simple Cutscene

The following example pauses the game in response to the READ command.

Mygame::Plot.script do
  introduction do |actor|
    actor.tell "You're in a library."
  end

  respond :read do |actor|
    actor.cue :reading
  end

  pause :reading do |actor|
    actor.tell "You spend some time with a good book."
    actor.cue :default_scene
  end
end

The result:

$ rake ruby:run

You're in a library.

> read

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 Conclusion.

Next: Creating subplots