Class: Ruck::GLApp::RuckSketch
- Inherits:
-
Object
- Object
- Ruck::GLApp::RuckSketch
- Includes:
- GLApp
- Defined in:
- lib/ruck/glapp/glapp.rb
Instance Method Summary collapse
- #draw ⇒ Object
-
#initialize(filenames) ⇒ RuckSketch
constructor
A new instance of RuckSketch.
- #keyboard_down(key, modifiers) ⇒ Object
- #keyboard_up(key, modifiers) ⇒ Object
- #mouse_click(button, state, x, y) ⇒ Object
- #mouse_motion(x, y) ⇒ Object
- #setup ⇒ Object
- #special_keyboard_down(key, modifiers) ⇒ Object
- #special_keyboard_up(key, modifiers) ⇒ Object
Constructor Details
#initialize(filenames) ⇒ RuckSketch
Returns a new instance of RuckSketch.
88 89 90 |
# File 'lib/ruck/glapp/glapp.rb', line 88 def initialize(filenames) @filenames = filenames end |
Instance Method Details
#draw ⇒ Object
103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/ruck/glapp/glapp.rb', line 103 def draw @events.each do |pair| ev, queue = pair SHREDULER.raise_event ev, queue end @events = [] SHREDULER.catch_up # execute shreds whose time came while drawing previous frame SHREDULER.raise_event Object.new, :frame end |
#keyboard_down(key, modifiers) ⇒ Object
115 116 117 |
# File 'lib/ruck/glapp/glapp.rb', line 115 def keyboard_down(key, modifiers) @events << [Struct.new(:key).new(key), :key_down] end |
#keyboard_up(key, modifiers) ⇒ Object
119 120 121 |
# File 'lib/ruck/glapp/glapp.rb', line 119 def keyboard_up(key, modifiers) @events << [Struct.new(:key).new(key), :key_up] end |
#mouse_click(button, state, x, y) ⇒ Object
131 132 133 134 135 136 137 |
# File 'lib/ruck/glapp/glapp.rb', line 131 def mouse_click(, state, x, y) if state == 0 @events << [Struct.new(:button, :x, :y).new(, x, y), :mouse_down] else @events << [Struct.new(:button, :x, :y).new(, x, y), :mouse_up] end end |
#mouse_motion(x, y) ⇒ Object
139 140 141 |
# File 'lib/ruck/glapp/glapp.rb', line 139 def mouse_motion(x, y) @events << [Struct.new(:x, :y).new(x, y), :mouse_move] end |
#setup ⇒ Object
92 93 94 95 96 97 98 99 100 101 |
# File 'lib/ruck/glapp/glapp.rb', line 92 def setup @filenames.each do |filename| SHREDULER.spork(filename) do require filename end end @events = [] SHREDULER.starting end |
#special_keyboard_down(key, modifiers) ⇒ Object
123 124 125 |
# File 'lib/ruck/glapp/glapp.rb', line 123 def special_keyboard_down(key, modifiers) @events << [Struct.new(:key).new(key), :key_down] end |
#special_keyboard_up(key, modifiers) ⇒ Object
127 128 129 |
# File 'lib/ruck/glapp/glapp.rb', line 127 def special_keyboard_up(key, modifiers) @events << [Struct.new(:key).new(key), :key_up] end |