Class: BeltsOpengl::InputManager

Inherits:
Object
  • Object
show all
Defined in:
lib/belts_opengl/input_manager.rb

Constant Summary collapse

KEY_MAP =
{
  GLFW::KEY_W => :w,
  GLFW::KEY_A => :a,
  GLFW::KEY_S => :s,
  GLFW::KEY_D => :d,
}
BUTTON_MAP =
{
  GLFW::MOUSE_BUTTON_1 => :mouse_1,
  GLFW::MOUSE_BUTTON_2 => :mouse_2,
  GLFW::MOUSE_BUTTON_3 => :mouse_3
}

Instance Method Summary collapse

Constructor Details

#initialize(game, window) ⇒ InputManager

Returns a new instance of InputManager.



16
17
18
19
20
21
22
23
24
# File 'lib/belts_opengl/input_manager.rb', line 16

def initialize(game, window)
  @game = game
  @window = window
  @input_changes = {}

  GLFW.SetKeyCallback(@window, key_callback)
  GLFW.SetCursorPosCallback(@window, cursor_callback)
  GLFW.SetMouseButtonCallback(@window, mouse_button_callback)
end

Instance Method Details

#updateObject



26
27
28
29
# File 'lib/belts_opengl/input_manager.rb', line 26

def update
  @game.input.update(@input_changes)
  @input_changes = {}
end