org.jrabbit.standard.game.objects.particles.generic
Class SwarmParticle

java.lang.Object
  extended by org.jrabbit.standard.game.objects.base.Spatial
      extended by org.jrabbit.standard.game.objects.base.BaseSprite
          extended by org.jrabbit.standard.game.objects.particles.base.Particle
              extended by org.jrabbit.standard.game.objects.particles.generic.SwarmParticle
All Implemented Interfaces:
Renderable, Updateable, Skin, GLTransform, Colored, Dimensioned, GLGroupTransformed, Located, Rotated, Scaled, ScreenObject, Visible

public class SwarmParticle
extends Particle

A SwarmParticle is by far the most complex default particle, and the only one that creates a persistent effect instead of dying over time. A SwarmParticle creates a "swarming" effect - think like flies over a piece of meat. Each particle randomly wanders around a target point, moving back towards it if it gets to far away. As a group, these particles form a dynamic cloud of moving points.

Author:
Chris Molini

Field Summary
protected  Vector2f acceleration
          The acceleration currently being applied.
protected  float baseAccel
          The base magnitude of the acceleration.
protected  int counter
          This value keeps track of the duration of each acceleration phase.
protected  int interval
          The current interval between acceleration changes.
protected  int intervalBase
          The base value to calculate intervals.
protected  float maxSpeed
          The maximum speed of the particle at any time.
protected  float range
          The maximum distance the particle can move away from its target without being forced back in.
protected  Vector2f target
          The Vector2f that the Swarm will follow.
protected  Vector2f velocity
          The current velocity of the particle.
 
Fields inherited from class org.jrabbit.standard.game.objects.particles.base.Particle
parent, skinID
 
Fields inherited from class org.jrabbit.standard.game.objects.base.BaseSprite
color, screenCoords, transforms, visible
 
Fields inherited from class org.jrabbit.standard.game.objects.base.Spatial
location, rotation, scalar
 
Constructor Summary
SwarmParticle(float range, float speed, float maxSpeed, float baseAccel, int interval)
          Creates a SwarmParticle with the indicated settings.
 
Method Summary
protected  void appendToParent()
          Adjust the particle to its parent ParticleSprite.
 void update(int delta)
          Updates the particle, causing it to swarm around the target point.
 
Methods inherited from class org.jrabbit.standard.game.objects.particles.base.Particle
draw, height, kill, setParent, setSkinID, skin, skinID, width
 
Methods inherited from class org.jrabbit.standard.game.objects.base.BaseSprite
bind, color, onscreen, release, render, screenCoords, setVisible, shouldRender, transforms, visible
 
Methods inherited from class org.jrabbit.standard.game.objects.base.Spatial
location, rotation, scalar, scaledDiameter, scaledHeight, scaledWidth
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

target

protected Vector2f target
The Vector2f that the Swarm will follow.


range

protected float range
The maximum distance the particle can move away from its target without being forced back in.


velocity

protected Vector2f velocity
The current velocity of the particle.


maxSpeed

protected float maxSpeed
The maximum speed of the particle at any time.


acceleration

protected Vector2f acceleration
The acceleration currently being applied.


baseAccel

protected float baseAccel
The base magnitude of the acceleration.


counter

protected int counter
This value keeps track of the duration of each acceleration phase.


intervalBase

protected int intervalBase
The base value to calculate intervals.


interval

protected int interval
The current interval between acceleration changes.

Constructor Detail

SwarmParticle

public SwarmParticle(float range,
                     float speed,
                     float maxSpeed,
                     float baseAccel,
                     int interval)
Creates a SwarmParticle with the indicated settings.

Parameters:
range - The distance from the target that the particle should treat as it's boundary.
speed - The initial speed of the particle.
maxSpeed - The maximum speed the particle can travel at any time.
baseAccel - The base magnitude of acceleration.
interval - The interval, in microseconds, between each change in acceleration.
Method Detail

appendToParent

protected void appendToParent()
Adjust the particle to its parent ParticleSprite. This also tells the SwarmParticle to follow the location of its parent.

Overrides:
appendToParent in class Particle

update

public void update(int delta)
Updates the particle, causing it to swarm around the target point.

Parameters:
delta - The number of microseconds that have passed.