Class: SDL2::Engine
- Inherits:
-
Object
- Object
- SDL2::Engine
- Defined in:
- lib/sdl2/engine.rb,
lib/sdl2/engine/block_engine.rb
Overview
Input/Output engine.
Direct Known Subclasses
Defined Under Namespace
Classes: BlockEngine, Engines
Instance Attribute Summary collapse
-
#surface ⇒ Object
readonly
Returns the value of attribute surface.
Instance Method Summary collapse
- #handle_event(event) ⇒ Object
-
#initialize(opts = {}) ⇒ Engine
constructor
A new instance of Engine.
- #on(*args, &block) ⇒ Object
- #on_handlers ⇒ Object
-
#paint_to(surface) ⇒ Object
This routine should be overriden.
- #quit ⇒ Object
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
#surface ⇒ Object (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_handlers ⇒ Object
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 |
#quit ⇒ Object
13 14 15 |
# File 'lib/sdl2/engine.rb', line 13 def quit() end |