Class: Hemi::Event::EventLoop

Inherits:
Object
  • Object
show all
Includes:
KeyHandler
Defined in:
lib/hemi/event/event_loop.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(logic, events) ⇒ EventLoop

Returns a new instance of EventLoop.



5
6
7
8
# File 'lib/hemi/event/event_loop.rb', line 5

def initialize(logic, events)
  @logic  = logic
  register_events!(events)
end

Instance Attribute Details

#eventObject (readonly)

Returns the value of attribute event.



10
11
12
# File 'lib/hemi/event/event_loop.rb', line 10

def event
  @event
end

#eventsObject (readonly)

Returns the value of attribute events.



10
11
12
# File 'lib/hemi/event/event_loop.rb', line 10

def events
  @events
end

#logicObject (readonly)

Returns the value of attribute logic.



10
11
12
# File 'lib/hemi/event/event_loop.rb', line 10

def logic
  @logic
end

Instance Method Details

#handle(event) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/hemi/event/event_loop.rb', line 12

def handle(event)
  @event = event

  case event
  when SDL2::Event::KeyDown
    handle_key
  end
end

#processObject



21
22
23
# File 'lib/hemi/event/event_loop.rb', line 21

def process
  logic.call
end