Class: SDC::Event

Inherits:
Object
  • Object
show all
Defined in:
engine_docs/automatic_doc_Event.rb,
lib/core/Event.rb,
engine_docs/automatic_doc_Event.rb

Overview

Event container class

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeEvent

Creates an empty event object



# File 'engine_docs/automatic_doc_Event.rb', line 9

Instance Attribute Details

#key_codeInteger

Key value of the event if it is a key press

Returns:

  • (Integer)

See Also:



# File 'engine_docs/automatic_doc_Event.rb', line 19

#mouse_button_codeInteger

Mouse button value of the event if it is a mouse button press

Returns:

  • (Integer)

See Also:



# File 'engine_docs/automatic_doc_Event.rb', line 44

#mouse_button_xInteger

Mouse x coordinate in pixels, relative to the owning window, when a button was pressed

Returns:

  • (Integer)


# File 'engine_docs/automatic_doc_Event.rb', line 49

#mouse_button_yInteger

Mouse y coordinate in pixels, relative to the owning window, when a button was pressed

Returns:

  • (Integer)


# File 'engine_docs/automatic_doc_Event.rb', line 53

#mouse_move_xInteger

Mouse x coordinate in pixels, relative to the owning window, when the mouse was moved

Returns:

  • (Integer)


# File 'engine_docs/automatic_doc_Event.rb', line 57

#mouse_move_yInteger

Mouse y coordinate in pixels, relative to the owning window, when the mouse was moved

Returns:

  • (Integer)


# File 'engine_docs/automatic_doc_Event.rb', line 61

#mouse_scroll_deltaFloat

Mouse wheel scrolling distance

Returns:

  • (Float)


# File 'engine_docs/automatic_doc_Event.rb', line 69

#mouse_scroll_wheelInteger

Mouse wheel scrolled if a mouse scrolling event was triggered (0 for vertical, 1 for horizontal)

Returns:

  • (Integer)


# File 'engine_docs/automatic_doc_Event.rb', line 65

#mouse_scroll_xInteger

Mouse x motion in pixels, relative to the owning window, when a wheel was scrolled

Returns:

  • (Integer)


# File 'engine_docs/automatic_doc_Event.rb', line 73

#mouse_scroll_yInteger

Mouse y motion in pixels, relative to the owning window, when a wheel was scrolled

Returns:

  • (Integer)


# File 'engine_docs/automatic_doc_Event.rb', line 77

#text_unicodeString

Inputted text if an input happened

Returns:

  • (String)


# File 'engine_docs/automatic_doc_Event.rb', line 81

#typeInteger

Type of the event

Returns:

  • (Integer)

See Also:



# File 'engine_docs/automatic_doc_Event.rb', line 14

Instance Method Details

#has_type?(event_type) ⇒ Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/core/Event.rb', line 7

def has_type?(event_type)
	return self.type == SDC::EventType.const_get(event_type)
end

#key_alt?Boolean

Returns true if an alt key is pressed

Returns:

  • (Boolean)


# File 'engine_docs/automatic_doc_Event.rb', line 24

#key_control?Boolean

Returns true if a ctrl key is pressed

Returns:

  • (Boolean)


# File 'engine_docs/automatic_doc_Event.rb', line 29

#key_pressed?(key) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/core/Event.rb', line 11

def key_pressed?(key)
	return self.key_code == SDC.key(key)
end

#key_shift?Boolean

Returns true if a shift key is pressed

Returns:

  • (Boolean)


# File 'engine_docs/automatic_doc_Event.rb', line 34

#key_system?Boolean

Returns true if a system key is pressed

Returns:

  • (Boolean)


# File 'engine_docs/automatic_doc_Event.rb', line 39

#mouse_button_pressed?(button) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/core/Event.rb', line 15

def mouse_button_pressed?(button)
	return self.mouse_button_code == SDC.mouse_button(button)
end

#mouse_coordinatesObject



35
36
37
# File 'lib/core/Event.rb', line 35

def mouse_coordinates
	return SDC::Coordinates.new(self.mouse_button_x.to_f, self.mouse_button_y.to_f)
end

#mouse_left_click?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/core/Event.rb', line 19

def mouse_left_click?
	return mouse_button_pressed?(:Left)
end

#mouse_right_click?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/core/Event.rb', line 23

def mouse_right_click?
	return mouse_button_pressed?(:Right)
end

#mouse_scrolled_down?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/core/Event.rb', line 27

def mouse_scrolled_down?
	return self.mouse_scroll_wheel == SDC::EventMouse::VerticalWheel && self.mouse_scroll_delta < 0.0
end

#mouse_scrolled_up?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/core/Event.rb', line 31

def mouse_scrolled_up?
	return self.mouse_scroll_wheel == SDC::EventMouse::VerticalWheel && self.mouse_scroll_delta > 0.0
end

#new_mouse_coordinatesObject



39
40
41
# File 'lib/core/Event.rb', line 39

def new_mouse_coordinates
	return SDC::Coordinates.new(self.mouse_move_x.to_f, self.mouse_move_y.to_f)
end

#text_charObject



43
44
45
# File 'lib/core/Event.rb', line 43

def text_char
	return self.text_unicode.chr("UTF-8")
end