struct Menu

Overview

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.

Defined in:

engine/menu.cr

Constructors

Instance Method Summary

Instance methods inherited from struct Scene

commands(state : State) : Array(Command) commands, persist_scene_state(state : State) : State persist_scene_state, render(state : State) render, run(state : State) : Tuple(Scene, State)? run

Constructor methods inherited from struct Scene

new new

Constructor Detail

def self.new(description : String, starting_scene : Scene.class) #

[View source]
def self.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.


[View source]

Instance Method Detail

def commands(state : State) : Array(Command) #
Description copied from struct Scene

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


[View source]
def 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.


[View source]
def render(state : State) #
Description copied from struct Scene

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

[View source]