Sha256: f4a9706a0733ecd16babde8cee97749ae9b44037c59be11adf2ea81a5e18b4d0
Contents?: true
Size: 991 Bytes
Versions: 12
Compression:
Stored size: 991 Bytes
Contents
# This is a convenience trait. # # Instead of calling # @controls << Control.new(self, @player1, :some_key_code => :action) # you can define the controls in the object itself. # module Controllable extend Trait def self.included controllable controllable.extend ClassMethods end module ClassMethods # Enables to define the controls in the object itself, as in the Example: # # class Spaceship < Thing # it_is Controllable # controls Gosu::Button::KbA => Turnable::Left, # Gosu::Button::KbD => Turnable::Right, # Gosu::Button::KbW => Moveable::Accelerate, # Gosu::Button::KbS => Moveable::Backwards, # Gosu::Button::KbSpace => Shooter::Shoot # def controls mapping attr_accessor :controls_mapping InitializerHooks.register self do self.controls_mapping = mapping self.window.add_controls_for self end end end end
Version data entries
12 entries across 12 versions & 1 rubygems