Sha256: 13462c01d6f807cafb0c52e6a1c982a3812e67dbc22db2ea809ae7dcd13fc638

Contents?: true

Size: 640 Bytes

Versions: 15

Compression:

Stored size: 640 Bytes

Contents

#
#
module Turnable
  
  Left  = :turn_left
  Right = :turn_right
  
  def self.included base
    base.extend ClassMethods
  end
  
  # TODO meta
  #
  module ClassMethods
    def turn_speed amount
      amount = amount.to_f / 2
      define_method :turn_speed do
        amount
      end
    end
  end
  
  #
  #
  def turn_speed
    0.5 # Default turn speed
  end
  
  # Turns the thing left, depending on turn speed.
  #
  def turn_left
    self.rotation -= self.turn_speed / (SUBSTEPS**2)
  end
  
  # Turns the thing right, depending on turn speed.
  #
  def turn_right
    self.rotation += self.turn_speed / (SUBSTEPS**2)
  end
  
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
gosu_extensions-0.1.14 lib/traits/turnable.rb
gosu_extensions-0.1.13 lib/traits/turnable.rb
gosu_extensions-0.1.12 lib/traits/turnable.rb
gosu_extensions-0.1.11 lib/traits/turnable.rb
gosu_extensions-0.1.10 lib/traits/turnable.rb
gosu_extensions-0.1.9 lib/traits/turnable.rb
gosu_extensions-0.1.8 lib/traits/turnable.rb
gosu_extensions-0.1.7 lib/traits/turnable.rb
gosu_extensions-0.1.6 lib/traits/turnable.rb
gosu_extensions-0.1.5 lib/traits/turnable.rb
gosu_extensions-0.1.4 lib/traits/turnable.rb
gosu_extensions-0.1.3 lib/traits/turnable.rb
gosu_extensions-0.1.2 lib/traits/turnable.rb
gosu_extensions-0.1.1 lib/traits/turnable.rb
gosu_extensions-0.1.0 lib/traits/turnable.rb