samples/99_genre_rpg_narrative/choose_your_own_adventure/app/main.rb
# Uses keyboard input from the user to make a decision
# Assigns the decision as the value of the decision_id variable
Uses keyboard input from the user to make a decision
Assigns the decision as the value of the decision_id variable
Uses keyboard input from the user to make a decision Assigns the decision as the value of the decision_id variable
def process_inputs args
  decision = current_decision args 
  if args.keyboard.key_down.left! && decision[:option_one] 
    args.state.decision_id = decision[:option_one][:decision] 
  end
  if args.keyboard.key_down.right! && decision[:option_two] 
    args.state.decision_id = decision[:option_two][:decision] 
  end
  if args.keyboard.key_down.down! && decision[:option_three] 
    args.state.decision_id = decision[:option_three][:decision] 
  end
  if args.keyboard.key_down.up! && decision[:option_four] 
    args.state.decision_id = decision[:option_four][:decision] 
  end
end
def process_inputs args decision = current_decision args if args . keyboard . key_down . left! && decision [ :option_one ] args . state . decision_id = decision [ :option_one ] [ :decision ] end if args . keyboard . key_down . right! && decision [ :option_two ] args . state . decision_id = decision [ :option_two ] [ :decision ] end if args . keyboard . key_down . down! && decision [ :option_three ] args . state . decision_id = decision [ :option_three ] [ :decision ] end if args . keyboard . key_down . up! && decision [ :option_four ] args . state . decision_id = decision [ :option_four ] [ :decision ] end end
Uses keyboard input from the user to make a decision
Assigns the decision as the value of the decision_id variable
Uses keyboard input from the user to make a decision Assigns the decision as the value of the decision_id variable
# calls current_decision method # if left key pressed and option one exists # value of option one's decision hash key is set to decision_id # if right key pressed and option two exists # value of option two's decision hash key is set to decision_id # if down key pressed and option three exists # value of option three's decision hash key is set to decision_id # if up key pressed and option four exists # value of option four's decision hash key is set to decision_id
args