Sha256: 1a9bd7830be9f053c42f1b59222913a42942c0df7ad61e960fea92c096750653

Contents?: true

Size: 492 Bytes

Versions: 7

Compression:

Stored size: 492 Bytes

Contents

#
#
class Control
  
  #
  #
  def initialize window, controllable, mapping = nil
    @window = window
    @controllable = controllable
    @mapping = mapping || controllable.respond_to?(:controls_mapping) && controllable.controls_mapping
  end
  
  #
  #
  def mapping?
    @mapping && !@mapping.empty?
  end
  
  # 
  #
  def handle
    return if @controllable.destroyed?
    @mapping.each do |key, command|
      @controllable.send(command) if @window.button_down? key
    end
  end
  
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
gosu_extensions-0.1.26 lib/core/control.rb
gosu_extensions-0.1.25 lib/core/control.rb
gosu_extensions-0.1.24 lib/core/control.rb
gosu_extensions-0.1.23 lib/core/control.rb
gosu_extensions-0.1.22 lib/core/control.rb
gosu_extensions-0.1.21 lib/core/control.rb
gosu_extensions-0.1.20 lib/core/control.rb