abstract struct Scene
- Scene
- Struct
- Value
- Object
Overview
Represents a single scene in the game.
Players navigate through the game by visiting different scenes.
Scenes describe the environment and provide the user with different Command
options.
Direct Known Subclasses
Defined in:
engine/scene.crConstructors
Instance Method Summary
-
#commands(state : State) : Array(Command)
Returns an ordered list of commands available to the user.
-
#persist_scene_state(state : State) : State
Persists the scene information to the state so we can keep track of a player's progress between saves.
-
#render(state : State)
Render the scene description.
-
#run(state : State) : Tuple(Scene, State)?
Execute the scene and return the next scene and state
Constructor Detail
Instance Method Detail
Returns an ordered list of commands available to the user.
These commands will be displayed after the scene description produced in #render
Persists the scene information to the state so we can keep track of a player's progress between saves.
Example:
If we also had a timstamp field on State
we could set it here
protected def persist_scene_state(state : State) : State
state = super(state)
state.timstamp = Time.utc
return state
end
Render the scene description.
Note: There is no need to explain the scene's available options sinceCommand
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
Execute the scene and return the next scene and state