Class: Kawaii::InputManager
- Inherits:
-
Object
- Object
- Kawaii::InputManager
- Defined in:
- lib/kawaii/input_manager.rb
Instance Attribute Summary collapse
-
#game ⇒ Object
Returns the value of attribute game.
Instance Method Summary collapse
- #bind(buttons = []) ⇒ Object
- #button_clicked?(button) ⇒ Boolean
- #button_down?(button) ⇒ Boolean
-
#initialize(game, bound_buttons = []) ⇒ InputManager
constructor
A new instance of InputManager.
- #mouse_dif_x ⇒ Object
- #mouse_dif_y ⇒ Object
- #mouse_x ⇒ Object
- #mouse_y ⇒ Object
- #old_mouse_x ⇒ Object
- #old_mouse_y ⇒ Object
- #update ⇒ Object
Constructor Details
#initialize(game, bound_buttons = []) ⇒ InputManager
Returns a new instance of InputManager.
6 7 8 9 10 11 12 13 |
# File 'lib/kawaii/input_manager.rb', line 6 def initialize game, = [] @game = game @buttons = [] @bound_buttons = @old_mouse_x = 0.0 @old_mouse_y = 0.0 end |
Instance Attribute Details
#game ⇒ Object
Returns the value of attribute game.
4 5 6 |
# File 'lib/kawaii/input_manager.rb', line 4 def game @game end |
Instance Method Details
#bind(buttons = []) ⇒ Object
15 16 17 |
# File 'lib/kawaii/input_manager.rb', line 15 def bind = [] @bound_buttons = end |
#button_clicked?(button) ⇒ Boolean
32 33 34 |
# File 'lib/kawaii/input_manager.rb', line 32 def @buttons.include?() && !@game.() end |
#button_down?(button) ⇒ Boolean
28 29 30 |
# File 'lib/kawaii/input_manager.rb', line 28 def @game.() end |
#mouse_dif_x ⇒ Object
48 49 50 |
# File 'lib/kawaii/input_manager.rb', line 48 def mouse_dif_x mouse_x - old_mouse_x end |
#mouse_dif_y ⇒ Object
51 52 53 |
# File 'lib/kawaii/input_manager.rb', line 51 def mouse_dif_y mouse_y - old_mouse_y end |
#mouse_x ⇒ Object
36 37 38 |
# File 'lib/kawaii/input_manager.rb', line 36 def mouse_x @game.mouse_x end |
#mouse_y ⇒ Object
39 40 41 |
# File 'lib/kawaii/input_manager.rb', line 39 def mouse_y @game.mouse_y end |
#old_mouse_x ⇒ Object
42 43 44 |
# File 'lib/kawaii/input_manager.rb', line 42 def old_mouse_x @old_mouse_x end |
#old_mouse_y ⇒ Object
45 46 47 |
# File 'lib/kawaii/input_manager.rb', line 45 def old_mouse_y @old_mouse_y end |
#update ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/kawaii/input_manager.rb', line 19 def update @buttons.clear @bound_buttons.each do |btn| @buttons.push btn if btn end @old_mouse_x = mouse_x @old_mouse_y = mouse_y end |