Class: Zyps::Accelerator
- Inherits:
-
EnvironmentalFactor
- Object
- EnvironmentalFactor
- Zyps::Accelerator
- Defined in:
- lib/zyps/environmental_factors.rb
Overview
A force that pushes on all objects.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#vector ⇒ Object
Vector to apply to objects.
Instance Method Summary collapse
-
#act(environment) ⇒ Object
Accelerate the target away from the actor, but limited by elapsed time.
-
#initialize(vector) ⇒ Accelerator
constructor
A new instance of Accelerator.
Constructor Details
#initialize(vector) ⇒ Accelerator
Returns a new instance of Accelerator.
146 147 148 149 |
# File 'lib/zyps/environmental_factors.rb', line 146 def initialize(vector) self.vector = vector @clock = Clock.new end |
Instance Attribute Details
#vector ⇒ Object
Vector to apply to objects.
144 145 146 |
# File 'lib/zyps/environmental_factors.rb', line 144 def vector @vector end |
Instance Method Details
#act(environment) ⇒ Object
Accelerate the target away from the actor, but limited by elapsed time.
152 153 154 155 156 157 158 |
# File 'lib/zyps/environmental_factors.rb', line 152 def act(environment) elapsed_time = @clock.elapsed_time environment.objects.each do |object| #Push on object. object.vector += Vector.new(@vector.speed * elapsed_time, @vector.pitch) end end |