lib/gamebox/core/input_mapper.rb
# map_controls is to be setup outside of an actor and passed in at construction
# time ie:
#
# mapper.map_controls {
#  '+a' => :jump,   # emit jump when 'a' is _pressed_
#  '-b' => :duck,   # emit duck when 'b' is _released_
#  'c'  => :block   # emit block when 'c' is _pressed_ AND _released_
# }
#
# all keys will have a <key_name>? defined for checking state at anytime
# create_actor :fighter, input: mapper
# 
# all of the actor's behaviors can / should use the input mapper instead of raw key bindings
map_controls is to be setup outside of an actor and passed in at construction
time ie.



all keys will have a . defined for checking state at anytime
create_actor :fighter, input: mapper

all of the actor's behaviors can / should use the input mapper instead of raw key bindings
map_controls is to be setup outside of an actor and passed in at construction time ie . all keys will have a . defined for checking state at anytime create_actor : fighter input : mapper all of the actor ' s behaviors can / should use the input mapper instead of raw key bindings
def map_controls(input_hash)
    input_hash.each do |input, actions|
      if input.start_with? '-'
        register_key_released(input[1..-1], actions)
      elsif input.start_with? '+'
        register_key_pressed(input[1..-1], actions)
      else
        register_key_released(input, actions)
        register_key_pressed(input, actions)
      end
    end
  end
def map_controls ( input_hash ) input_hash . each do | input , actions | if input . start_with? '-' register_key_released ( input [ 1 .. - 1 ] , actions ) elsif input . start_with? '+' register_key_pressed ( input [ 1 .. - 1 ] , actions ) else register_key_released ( input , actions ) register_key_pressed ( input , actions ) end end end
map_controls is to be setup outside of an actor and passed in at construction
time ie:
map_controls is to be setup outside of an actor and passed in at construction time ie :
input_hash
<not_specific>