Class: Bestguigui::Input

Inherits:
Object
  • Object
show all
Defined in:
lib/bestguigui_lab/input.rb

Overview

Mappe une action à plusieurs touches/boutons (ex. right: [KB_RIGHT, KB_D]).

Instance Method Summary collapse

Constructor Details

#initialize(bindings = {}) ⇒ Input

Returns a new instance of Input.



6
7
8
# File 'lib/bestguigui_lab/input.rb', line 6

def initialize(bindings = {})
    @bindings = bindings
end

Instance Method Details

#button_down(action, id) ⇒ Object



11
# File 'lib/bestguigui_lab/input.rb', line 11

def button_down(action, id) = @bindings[action].any? { |key| key == id }

#button_down?(action) ⇒ Boolean

Returns:

  • (Boolean)


10
# File 'lib/bestguigui_lab/input.rb', line 10

def button_down?(action) = @bindings[action].any? { |key| Gosu.button_down?(key) }

#button_up(action, id) ⇒ Object



12
# File 'lib/bestguigui_lab/input.rb', line 12

def button_up(action, id) = @bindings[action].any? { |key| key == id }