Sha256: ea2b4c3ba07cfcd7416a5ff975b75dedce96ba3e4232133e1845bb1c278c1dc5

Contents?: true

Size: 742 Bytes

Versions: 20

Compression:

Stored size: 742 Bytes

Contents

# Controls for a controllable.
# Example:
#   # Note: left, right, full_speed_ahead, reverse, revive are
#   #       methods on the @player.
#   #
#   @controls << Controls.new(self, @player,
#     Gosu::Button::KbA => :left,
#     Gosu::Button::KbD => :right,
#     Gosu::Button::KbW => :full_speed_ahead,
#     Gosu::Button::KbS => :reverse,
#     Gosu::Button::Kb1 => :revive
#   )
#
#
#
class Controls
  
  #
  #
  def initialize window, controllable
    @window = window
    @controllable = controllable
    @mapping = controllable.controls_mapping
  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

20 entries across 20 versions & 1 rubygems

Version Path
gosu_extensions-0.1.19 lib/core/controls.rb
gosu_extensions-0.1.18 lib/core/controls.rb
gosu_extensions-0.1.17 lib/core/controls.rb
gosu_extensions-0.1.16 lib/core/controls.rb
gosu_extensions-0.1.15 lib/core/controls.rb
gosu_extensions-0.1.14 lib/controls.rb
gosu_extensions-0.1.13 lib/controls.rb
gosu_extensions-0.1.12 lib/controls.rb
gosu_extensions-0.1.11 lib/controls.rb
gosu_extensions-0.1.10 lib/controls.rb
gosu_extensions-0.1.9 lib/controls.rb
gosu_extensions-0.1.8 lib/controls.rb
gosu_extensions-0.1.7 lib/controls.rb
gosu_extensions-0.1.6 lib/controls.rb
gosu_extensions-0.1.5 lib/controls.rb
gosu_extensions-0.1.4 lib/controls.rb
gosu_extensions-0.1.3 lib/controls.rb
gosu_extensions-0.1.2 lib/controls.rb
gosu_extensions-0.1.1 lib/controls.rb
gosu_extensions-0.1.0 lib/controls.rb