Module: DXRubySDL::Input

Defined in:
lib/dxruby_sdl/input.rb

Class Method Summary collapse

Class Method Details

.key_push?(key_code) ⇒ Boolean Also known as: keyPush?

Returns:

  • (Boolean)


47
48
49
# File 'lib/dxruby_sdl/input.rb', line 47

def key_push?(key_code)
  return key_press?(to_sdl_key(key_code))
end

.mouse_pos_xObject Also known as: mousePosX



39
40
41
# File 'lib/dxruby_sdl/input.rb', line 39

def mouse_pos_x
  return SDL::Mouse.state[0]
end

.mouse_pos_yObject Also known as: mousePosY



43
44
45
# File 'lib/dxruby_sdl/input.rb', line 43

def mouse_pos_y
  return SDL::Mouse.state[1]
end

.pad_down?(button_code, pad_number = 0) ⇒ Boolean Also known as: padDown?

Returns:

  • (Boolean)


29
30
31
32
33
34
35
36
37
# File 'lib/dxruby_sdl/input.rb', line 29

def pad_down?(button_code, pad_number = 0)
  if button_code == P_BUTTON0 && key_press?(SDL::Key::Z) ||
      button_code == P_BUTTON1 && key_press?(SDL::Key::X) ||
      button_code == P_BUTTON2 && key_press?(SDL::Key::C) ||
      ((j = joystick(pad_number)) && j.button(button_code))
    return true
  end
  return false
end

.x(pad_number = 0) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'lib/dxruby_sdl/input.rb', line 7

def x(pad_number = 0)
  res = 0
  if key_press?(SDL::Key::LEFT)
    res -= 1
  end
  if key_press?(SDL::Key::RIGHT)
    res += 1
  end
  return res
end

.y(pad_number = 0) ⇒ Object



18
19
20
21
22
23
24
25
26
27
# File 'lib/dxruby_sdl/input.rb', line 18

def y(pad_number = 0)
  res = 0
  if key_press?(SDL::Key::UP)
    res -= 1
  end
  if key_press?(SDL::Key::DOWN)
    res += 1
  end
  return res
end