Sha256: 94d73282cd30148696ce7fa109aae36fde5873168c23018bd5a666319f0cdae9

Contents?: true

Size: 517 Bytes

Versions: 2

Compression:

Stored size: 517 Bytes

Contents

module Gosu
  module Keyboard
    class NoKeyError < NoMethodError; end
    
    class DSL
      
      def initialize(window, &blk)
        @window = window
        
        instance_eval(&blk)
      end
      
      def method_missing(key_name, &blk)
        raise NoKeyError unless Keyboard.keys.has_key?(key_name)
        
        @window.button_down?( Keyboard.keys[key_name] )
      end
      
      def down?(condition, &blk)
        @window.instance_eval(&blk) if condition
      end
      
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gosu-keyboard-0.1.8 lib/gosu/keyboard/dsl.rb
gosu-keyboard-0.1.7 lib/gosu/keyboard/dsl.rb