Class: Ray::Input
- Inherits:
-
Object
- Object
- Ray::Input
- Defined in:
- ext/input.c,
ext/input.c
Overview
An input object is used to keep track of pressed keys and the position of the mouse. Methods are also provided to affect the state of the input, possibly useful in tests.
Instance Method Summary collapse
-
#holding?(key) ⇒ true, false
Checks if a key is being held.
-
#mouse_pos ⇒ Ray::Vector2
The position of the mouse.
-
#mouse_pos=(pos) ⇒ Object
Changes the known position of the mouse.
-
#press(key) ⇒ Object
Marks a key as pressed.
-
#release(key) ⇒ Object
Marks a key as released.
-
#reset ⇒ Object
Resets the input.
Instance Method Details
#holding?(key) ⇒ true, false
86 87 88 89 90 |
# File 'ext/input.c', line 86
static
VALUE ray_input_holding(VALUE self, VALUE key) {
return say_input_is_holding(ray_rb2input(self), NUM2INT(key)) ?
Qtrue : Qfalse;
}
|
#mouse_pos ⇒ Ray::Vector2
Returns The position of the mouse.
93 94 95 96 |
# File 'ext/input.c', line 93 static VALUE ray_input_mouse_pos(VALUE self) { return ray_vector2_to_rb(say_input_get_mouse_pos(ray_rb2input(self))); } |
#mouse_pos=(pos) ⇒ Object
73 74 75 76 77 |
# File 'ext/input.c', line 73
static
VALUE ray_input_set_mouse_pos(VALUE self, VALUE pos) {
say_input_set_mouse_pos(ray_rb2input(self), ray_convert_to_vector2(pos));
return pos;
}
|
#press(key) ⇒ Object
47 48 49 50 51 |
# File 'ext/input.c', line 47
static
VALUE ray_input_press(VALUE self, VALUE key) {
say_input_press(ray_rb2input(self), NUM2INT(key));
return Qnil;
}
|
#release(key) ⇒ Object
58 59 60 61 62 |
# File 'ext/input.c', line 58
static
VALUE ray_input_release(VALUE self, VALUE key) {
say_input_release(ray_rb2input(self), NUM2INT(key));
return Qnil;
}
|
#reset ⇒ Object
Resets the input
After a reset, all the keys are marked released and the mouse position is set to (0, 0).
36 37 38 39 40 |
# File 'ext/input.c', line 36 static VALUE ray_input_reset(VALUE self) { say_input_reset(ray_rb2input(self)); return self; } |