samples/99_genre_rpg_narrative/choose_your_own_adventure/app/main.rb
def render_decision args
  decision = current_decision args
  # text is either the value of decision's description key or warning that no description exists
  args.labels << [640, 360, decision[:description] || "No definition found for #{args.state.decision_id}. Please update decision.rb.", 0, 1] # uses string interpolation

  # All decisions are stored in a hash
  # The descriptions output onto the screen are the values for the description keys of the hash.
  if decision[:option_one]
    args.labels << [10, 360, decision[:option_one][:description], 0, 0] # option one's description label
    args.labels << [10, 335, "(Press 'left' on the keyboard to select this decision)", -5, 0] # label of what key to press to select the decision
  end

  if decision[:option_two]
    args.labels << [1270, 360, decision[:option_two][:description], 0, 2] # option two's description
    args.labels << [1270, 335, "(Press 'right' on the keyboard to select this decision)", -5, 2]
  end

  if decision[:option_three]
    args.labels << [640, 45, decision[:option_three][:description], 0, 1] # option three's description
    args.labels << [640, 20, "(Press 'down' on the keyboard to select this decision)", -5, 1]
  end

  if decision[:option_four]
    args.labels << [640, 700, decision[:option_four][:description], 0, 1] # option four's description
    args.labels << [640, 675, "(Press 'up' on the keyboard to select this decision)", -5, 1]
  end
end
# Outputs the possible decision descriptions the user can choose onto the screen
# as well as what key to press on their keyboard to make their decision
Outputs the possible decision descriptions the user can choose onto the screen
as well as what key to press on their keyboard to make their decision
Outputs the possible decision descriptions the user can choose onto the screen as well as what key to press on their keyboard to make their decision
def render_decision args
  decision = current_decision args
  args.labels << [640, 360, decision[:description] || "No definition found for #{args.state.decision_id}. Please update decision.rb.", 0, 1] 
  if decision[:option_one]
    args.labels << [10, 360, decision[:option_one][:description], 0, 0] 
    args.labels << [10, 335, "(Press 'left' on the keyboard to select this decision)", -5, 0] 
  end
  if decision[:option_two]
    args.labels << [1270, 360, decision[:option_two][:description], 0, 2] 
    args.labels << [1270, 335, "(Press 'right' on the keyboard to select this decision)", -5, 2]
  end
  if decision[:option_three]
    args.labels << [640, 45, decision[:option_three][:description], 0, 1] 
    args.labels << [640, 20, "(Press 'down' on the keyboard to select this decision)", -5, 1]
  end
  if decision[:option_four]
    args.labels << [640, 700, decision[:option_four][:description], 0, 1] 
    args.labels << [640, 675, "(Press 'up' on the keyboard to select this decision)", -5, 1]
  end
end
def render_decision args decision = current_decision args args . labels << [ 640 , 360 , decision [ :description ] || "No definition found for #{args.state.decision_id}. Please update decision.rb." , 0 , 1 ] if decision [ :option_one ] args . labels << [ 10 , 360 , decision [ :option_one ] [ :description ] , 0 , 0 ] args . labels << [ 10 , 335 , "(Press 'left' on the keyboard to select this decision)" , - 5 , 0 ] end if decision [ :option_two ] args . labels << [ 1270 , 360 , decision [ :option_two ] [ :description ] , 0 , 2 ] args . labels << [ 1270 , 335 , "(Press 'right' on the keyboard to select this decision)" , - 5 , 2 ] end if decision [ :option_three ] args . labels << [ 640 , 45 , decision [ :option_three ] [ :description ] , 0 , 1 ] args . labels << [ 640 , 20 , "(Press 'down' on the keyboard to select this decision)" , - 5 , 1 ] end if decision [ :option_four ] args . labels << [ 640 , 700 , decision [ :option_four ] [ :description ] , 0 , 1 ] args . labels << [ 640 , 675 , "(Press 'up' on the keyboard to select this decision)" , - 5 , 1 ] end end
Outputs the possible decision descriptions the user can choose onto the screen
as well as what key to press on their keyboard to make their decision
Outputs the possible decision descriptions the user can choose onto the screen as well as what key to press on their keyboard to make their decision
# text is either the value of decision's description key or warning that no description exists # uses string interpolation # All decisions are stored in a hash # The descriptions output onto the screen are the values for the description keys of the hash. # option one's description label # label of what key to press to select the decision # option two's description # option three's description # option four's description
args