Class: Hemi::Event::LoopMachine
- Inherits:
-
Object
- Object
- Hemi::Event::LoopMachine
- Includes:
- Singleton
- Defined in:
- lib/hemi/event/loop_machine.rb
Class Attribute Summary collapse
-
.current ⇒ Object
readonly
Returns the value of attribute current.
-
.loops ⇒ Object
readonly
Returns the value of attribute loops.
Instance Attribute Summary collapse
-
#event ⇒ Object
readonly
Returns the value of attribute event.
Class Method Summary collapse
- .[](name) ⇒ Object
- .purge! ⇒ Object
- .register(name, logic = -> {}, events = {}) ⇒ Object
- .switch(name) ⇒ Object
Instance Method Summary collapse
Class Attribute Details
.current ⇒ Object (readonly)
Returns the value of attribute current.
27 28 29 |
# File 'lib/hemi/event/loop_machine.rb', line 27 def current @current end |
.loops ⇒ Object (readonly)
Returns the value of attribute loops.
27 28 29 |
# File 'lib/hemi/event/loop_machine.rb', line 27 def loops @loops end |
Instance Attribute Details
#event ⇒ Object (readonly)
Returns the value of attribute event.
8 9 10 |
# File 'lib/hemi/event/loop_machine.rb', line 8 def event @event end |
Class Method Details
.[](name) ⇒ Object
37 38 39 |
# File 'lib/hemi/event/loop_machine.rb', line 37 def [](name) @loops[name] end |
.purge! ⇒ Object
45 46 47 48 |
# File 'lib/hemi/event/loop_machine.rb', line 45 def purge! @loops = {} @current = nil end |
.register(name, logic = -> {}, events = {}) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/hemi/event/loop_machine.rb', line 29 def register(name, logic = -> {}, events = {}) event_loop = EventLoop.new(logic, events) @current = event_loop if loops.empty? @loops[name] = event_loop event_loop end |
.switch(name) ⇒ Object
41 42 43 |
# File 'lib/hemi/event/loop_machine.rb', line 41 def switch(name) @current = LoopMachine[name] end |
Instance Method Details
#call ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/hemi/event/loop_machine.rb', line 10 def call loop do Hemi::Render::Window.wipe_screen handle_events while poll_event process_logic Hemi::Render::Window.renderer.present debug? break if Hemi::Engine.stop sleep 0.1 end end |