Class: BulldogPhysics::Particles::Generators::ParticleGravity

Inherits:
ParticleForceGenerator show all
Defined in:
lib/Particles/particle_gravity.rb

Overview

A force generator that applies a gravitational force. One instance * can be used for multiple particles.

Instance Attribute Summary collapse

Attributes inherited from ParticleForceGenerator

#registrations

Instance Method Summary collapse

Constructor Details

#initialize(gravityForce = Vector3.new(0,-9.8,0)) ⇒ ParticleGravity

Returns a new instance of ParticleGravity.



9
10
11
12
13
# File 'lib/Particles/particle_gravity.rb', line 9

def initialize(gravityForce = Vector3.new(0,-9.8,0))
  #super if defined?(super)
  @gravity = gravityForce # vector3
  super()
end

Instance Attribute Details

#gravityObject

Returns the value of attribute gravity.



7
8
9
# File 'lib/Particles/particle_gravity.rb', line 7

def gravity
  @gravity
end

Instance Method Details

#update_force(particle, duration) ⇒ Object

override



16
17
18
19
20
21
22
# File 'lib/Particles/particle_gravity.rb', line 16

def update_force(particle, duration)
  unless particle.has_infinite_mass
    force_to_add = @gravity * particle.mass
    particle.addForce(force_to_add)
  end
  particle
end