Class: AGL::Mouse
- Inherits:
-
Object
- Object
- AGL::Mouse
- Defined in:
- lib/minigl/global.rb
Class Method Summary collapse
- .button_down?(btn) ⇒ Boolean
- .button_pressed?(btn) ⇒ Boolean
- .button_released?(btn) ⇒ Boolean
- .double_click?(btn) ⇒ Boolean
- .initialize ⇒ Object
- .over?(x, y, w, h) ⇒ Boolean
- .update ⇒ Object
- .x ⇒ Object
- .y ⇒ Object
Class Method Details
.button_down?(btn) ⇒ Boolean
154 155 156 |
# File 'lib/minigl/global.rb', line 154 def self. btn @@down[btn] end |
.button_pressed?(btn) ⇒ Boolean
150 151 152 |
# File 'lib/minigl/global.rb', line 150 def self. btn @@down[btn] and not @@prev_down[btn] end |
.button_released?(btn) ⇒ Boolean
158 159 160 |
# File 'lib/minigl/global.rb', line 158 def self. btn @@prev_down[btn] and not @@down[btn] end |
.double_click?(btn) ⇒ Boolean
162 163 164 |
# File 'lib/minigl/global.rb', line 162 def self.double_click? btn @@dbl_click[btn] end |
.initialize ⇒ Object
114 115 116 117 118 119 |
# File 'lib/minigl/global.rb', line 114 def self.initialize @@down = {} @@prev_down = {} @@dbl_click = {} @@dbl_click_timer = {} end |
.over?(x, y, w, h) ⇒ Boolean
166 167 168 |
# File 'lib/minigl/global.rb', line 166 def self.over? x, y, w, h @@x >= x and @@x < x + w and @@y >= y and @@y < y + h end |
.update ⇒ Object
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/minigl/global.rb', line 121 def self.update @@prev_down = @@down.clone @@down.clear @@dbl_click.clear @@dbl_click_timer.each do |k, v| if v < Game.double_click_delay; @@dbl_click_timer[k] += 1 else; @@dbl_click_timer.delete k; end end k1 = [Gosu::MsLeft, Gosu::MsMiddle, Gosu::MsRight] k2 = [:left, :middle, :right] for i in 0..2 if Game.window. k1[i] @@down[k2[i]] = true @@dbl_click[k2[i]] = true if @@dbl_click_timer[k2[i]] @@dbl_click_timer.delete k2[i] elsif @@prev_down[k2[i]] @@dbl_click_timer[k2[i]] = 0 end end @@x = Game.window.mouse_x.round @@y = Game.window.mouse_y.round end |
.x ⇒ Object
147 |
# File 'lib/minigl/global.rb', line 147 def self.x; @@x; end |
.y ⇒ Object
148 |
# File 'lib/minigl/global.rb', line 148 def self.y; @@y; end |