class BadSdl::Engine
Input/Output engine.
Attributes
surface[R]
Public Class Methods
new(opts = {})
click to toggle source
# File lib/bad_sdl/engine.rb, line 10 def initialize(opts = {}) # TODO: ?? end
Public Instance Methods
handle_event(event)
click to toggle source
# File lib/bad_sdl/engine.rb, line 34 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)
click to toggle source
# File lib/bad_sdl/engine.rb, line 25 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_handlers()
click to toggle source
# File lib/bad_sdl/engine.rb, line 21 def on_handlers @on_handlers ||= {} end
paint_to(surface)
click to toggle source
This routine should be overridden.
# File lib/bad_sdl/engine.rb, line 46 def paint_to(surface) result = false painter.each do |one| result = true if one.call(surface) end return result end
painter(&block)
click to toggle source
# File lib/bad_sdl/engine.rb, line 57 def painter(&block) @painter ||= [] @painter << block unless block.nil? @painter end
quit()
click to toggle source
# File lib/bad_sdl/engine.rb, line 15 def quit() end