Class: Tea::Mouse::Move

Inherits:
Object
  • Object
show all
Defined in:
lib/tea/m_event_mouse.rb

Overview

Event generated when the mouse cursor is moved.

x, y

coordinates of the mouse cursor

buttons

an array that may contain :left, :middle and :right

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sdl_event) ⇒ Move

Returns a new instance of Move.



21
22
23
24
25
26
27
28
# File 'lib/tea/m_event_mouse.rb', line 21

def initialize(sdl_event)
  @x = sdl_event.x
  @y = sdl_event.y
  @buttons = {}
  @buttons[Mouse::LEFT]   = (sdl_event.state & SDL::Mouse::BUTTON_LMASK) != 0
  @buttons[Mouse::MIDDLE] = (sdl_event.state & SDL::Mouse::BUTTON_MMASK) != 0
  @buttons[Mouse::RIGHT]  = (sdl_event.state & SDL::Mouse::BUTTON_RMASK) != 0
end

Instance Attribute Details

#buttonsObject (readonly)

Returns the value of attribute buttons.



20
21
22
# File 'lib/tea/m_event_mouse.rb', line 20

def buttons
  @buttons
end

#xObject (readonly)

Returns the value of attribute x.



20
21
22
# File 'lib/tea/m_event_mouse.rb', line 20

def x
  @x
end

#yObject (readonly)

Returns the value of attribute y.



20
21
22
# File 'lib/tea/m_event_mouse.rb', line 20

def y
  @y
end