Class: SDL2::Engine

Inherits:
Object
  • Object
show all
Defined in:
lib/sdl2/engine.rb,
lib/sdl2/engine/block_engine.rb

Overview

Input/Output engine.

Direct Known Subclasses

BlockEngine, Engines

Defined Under Namespace

Classes: BlockEngine, Engines

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Engine

Returns a new instance of Engine.



8
9
10
11
# File 'lib/sdl2/engine.rb', line 8

def initialize(opts = {})

  # TODO: ??
end

Instance Attribute Details

#surfaceObject (readonly)

Returns the value of attribute surface.



17
18
19
# File 'lib/sdl2/engine.rb', line 17

def surface
  @surface
end

Instance Method Details

#handle_event(event) ⇒ Object



32
33
34
35
36
37
38
39
40
41
# File 'lib/sdl2/engine.rb', line 32

def handle_event(event)

  on_handlers.each_pair do |event_hash, handler|

    return true if handler.call(event) if event == event_hash

  end
  
  return false # if we get to here.
end

#on(*args, &block) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/sdl2/engine.rb', line 23

def on(*args, &block)
  raise "Must specify EVENTTYPEs to handle" if args.empty?
  raise "Must give block to call on event" if args.empty? unless block.nil?
  args.each do |event_hash|
    raise "Expected Hash: #{event_hash.inspect}" unless event_hash.kind_of? Hash
    on_handlers[event_hash] = block
  end
end

#on_handlersObject



19
20
21
# File 'lib/sdl2/engine.rb', line 19

def on_handlers
  @on_handlers ||= {}
end

#paint_to(surface) ⇒ Object

This routine should be overriden.



44
45
46
# File 'lib/sdl2/engine.rb', line 44

def paint_to(surface)
  false
end

#quitObject



13
14
15
# File 'lib/sdl2/engine.rb', line 13

def quit()

end