Class: Carbuncle::Player::Binding
- Defined in:
 - gems/carbuncle-input/mrblib/player.rb
 
Instance Attribute Summary collapse
- 
  
    
      #gamepad_index  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
Returns the value of attribute gamepad_index.
 - 
  
    
      #key  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
Returns the value of attribute key.
 - 
  
    
      #origin  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
Returns the value of attribute origin.
 
Instance Method Summary collapse
- #down? ⇒ Boolean
 - 
  
    
      #initialize(key:, origin: 'keyboard', gamepad_index: 0)  ⇒ Binding 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of Binding.
 - #press? ⇒ Boolean
 - #release? ⇒ Boolean
 - #up? ⇒ Boolean
 
Constructor Details
#initialize(key:, origin: 'keyboard', gamepad_index: 0) ⇒ Binding
Returns a new instance of Binding.
      8 9 10 11 12  | 
    
      # File 'gems/carbuncle-input/mrblib/player.rb', line 8 def initialize(key:, origin: 'keyboard', gamepad_index: 0) @origin = origin @key = key @gamepad_index = gamepad_index end  | 
  
Instance Attribute Details
#gamepad_index ⇒ Object
Returns the value of attribute gamepad_index.
      6 7 8  | 
    
      # File 'gems/carbuncle-input/mrblib/player.rb', line 6 def gamepad_index @gamepad_index end  | 
  
#key ⇒ Object
Returns the value of attribute key.
      6 7 8  | 
    
      # File 'gems/carbuncle-input/mrblib/player.rb', line 6 def key @key end  | 
  
#origin ⇒ Object
Returns the value of attribute origin.
      6 7 8  | 
    
      # File 'gems/carbuncle-input/mrblib/player.rb', line 6 def origin @origin end  | 
  
Instance Method Details
#down? ⇒ Boolean
      32 33 34 35 36 37 38 39  | 
    
      # File 'gems/carbuncle-input/mrblib/player.rb', line 32 def down? case origin when 'keyboard' Keyboard.down?(key) when 'gamepad' Gamepad[gamepad_index].down?(key) end end  | 
  
#press? ⇒ Boolean
      14 15 16 17 18 19 20 21  | 
    
      # File 'gems/carbuncle-input/mrblib/player.rb', line 14 def press? case origin when 'keyboard' Keyboard.press?(key) when 'gamepad' Gamepad[gamepad_index].press?(key) end end  |