struct

Menu

Inherits Scene < Struct < Value < Object

A special scene that provides some basic game controls to the user such as starting a new game or opening a saved game.

The menu description introduces the player to your game. The starting_scene is where players will go first when starting a new game.

Constructors

new(description : String, starting_scene : Scene.class)
Source
new

Provides a default initializer to make the compiler happy. Since elsewhere we are initializing instances of Scene.class without any arguments, the compile expects all instances of Scene to be initialized with no arguments.

Source

Instance methods

commands(state : State) : Array(Command)

Returns an ordered list of commands available to the user. These commands will be displayed after the scene description produced in #render

Source
persist_scene_state(state : State) : State

Overrides the normal behavior so that navigating to the menu does not interupt the user's current Scende location.

Source
render(state : State)

Render the scene description.

Note: There is no need to explain the scene's available options since Command options are automatically generated from #commands.

Example:

def render(state : State)
  puts "You are in an empty room. To your left is an open door."
end
Source