Module: DXRubySDL::Input
- Defined in:
- lib/dxruby_sdl/input.rb
Class Method Summary collapse
- .key_push?(key_code) ⇒ Boolean (also: keyPush?)
- .mouse_pos_x ⇒ Object (also: mousePosX)
- .mouse_pos_y ⇒ Object (also: mousePosY)
- .pad_down?(button_code, pad_number = 0) ⇒ Boolean (also: padDown?)
- .x(pad_number = 0) ⇒ Object
- .y(pad_number = 0) ⇒ Object
Class Method Details
.key_push?(key_code) ⇒ Boolean Also known as: keyPush?
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_x ⇒ Object 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_y ⇒ Object 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?
29 30 31 32 33 34 35 36 37 |
# File 'lib/dxruby_sdl/input.rb', line 29 def pad_down?(, pad_number = 0) if == P_BUTTON0 && key_press?(SDL::Key::Z) || == P_BUTTON1 && key_press?(SDL::Key::X) || == P_BUTTON2 && key_press?(SDL::Key::C) || ((j = joystick(pad_number)) && j.()) 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 |