Module: Input

Defined in:
lib/input.rb

Overview

A module that handles input data from a gamepad or keyboard.

Constant Summary collapse

DOWN =
2
LEFT =
4
RIGHT =
6
UP =
8
A =
11
B =
12
C =
13
X =
14
Y =
15
Z =
16
L =
17
R =
18
SHIFT =
21
CTRL =
22
ALT =
23
F5 =
25
F6 =
26
F7 =
27
F8 =
28
F9 =
29

Class Method Summary collapse

Class Method Details

.dir4Object

Checks the status of the directional buttons, translates the data into a specialized 4-direction input format, and returns the number pad equivalent (2, 4, 6, 8).

If no directional buttons are being pressed (or the equivalent), returns 0.



45
46
47
# File 'lib/input.rb', line 45

def self.dir4()
  raise "not implemented"
end

.dir8Object

Checks the status of the directional buttons, translates the data into a specialized 8-direction input format, and returns the number pad equivalent (1, 2, 3, 4, 6, 7, 8, 9).

If no directional buttons are being pressed (or the equivalent), returns 0.



54
55
56
# File 'lib/input.rb', line 54

def self.dir8()
  raise "not implemented"    
end

.press?(num) ⇒ Boolean

Determines whether the button num is currently being pressed.

If the button is being pressed, returns TRUE. If not, returns FALSE.

if Input.press?(Input::C)

do_something

end

Examples:

Example

Returns:

  • (Boolean)


16
17
18
# File 'lib/input.rb', line 16

def self.press?(num)
  raise "not implemented"
end

.repeat?(num) ⇒ Boolean

Determines whether the button num is being pressed again.

Unlike trigger?, takes into account the repeat input of a button being held down continuously.

If the button is being pressed, returns TRUE. If not, returns FALSE.

Returns:

  • (Boolean)


36
37
38
# File 'lib/input.rb', line 36

def self.repeat?(num)
  raise "not implemented"
end

.trigger?(num) ⇒ Boolean

Determines whether the button num is being pressed again.

“Pressed again” is seen as time having passed between the button being not pressed and being pressed.

If the button is being pressed, returns TRUE. If not, returns FALSE.

Returns:

  • (Boolean)


26
27
28
# File 'lib/input.rb', line 26

def self.trigger?(num)
  raise "not implemented"
end

.updateObject

Updates input data. As a rule, this method is called once per frame.



4
5
6
# File 'lib/input.rb', line 4

def self.update()
  raise "not implemented"
end