Sha256: b5c066bbaf77458fcc88a345a0ef921cecef5a261fa5c283e42b54e439ea804c
Contents?: true
Size: 812 Bytes
Versions: 15
Compression:
Stored size: 812 Bytes
Contents
# # module Turnable extend Trait Left = :turn_left Right = :turn_right def self.included base base.extend ClassMethods end # Defines a turn_speed method on the class. # # Calling it will define a turn_speed method on the instance # that lets the thing rotate with the given frequency. # 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