org.newdawn.slick.particles
Class Particle

java.lang.Object
  extended by org.newdawn.slick.particles.Particle

public class Particle
extends java.lang.Object

A single particle within a system

Author:
kevin

Field Summary
protected  Color color
          The colour of the particle
protected static SGL GL
          The renderer to use for all GL operations
protected  Image image
          The image for this particle
static int INHERIT_POINTS
          Indicates the particle should inherit it's use of points
protected  float life
          The life left in the particle
protected  boolean oriented
          True if this particle's quad should be oritented based on it's direction
protected  float originalLife
          The original life of this particle
protected  float scaleY
          The currently scalar applied on the y axis
protected  float size
          The current size in pixels of the particle
protected  int type
          The type identifier of this particle
static int USE_POINTS
          Indicates the particle should explicitly use points
static int USE_QUADS
          Indicates the particle should explicitly not use points
protected  int usePoints
          How this particle should be rendered
protected  float velx
          The x component of the direction vector of the particle
protected  float vely
          The y component of the direction vector of the particle
protected  float x
          The x coordinate of the particle
protected  float y
          The y coordinate of the particle
 
Constructor Summary
Particle(ParticleSystem engine)
          Create a new particle belonging to given engine
 
Method Summary
 void adjustColor(float r, float g, float b, float a)
          Adjust (add) the color of the particle
 void adjustColor(int r, int g, int b, int a)
          Adjust (add) the color of the particle
 void adjustLife(float delta)
          Adjust the life othe particle
 void adjustPosition(float dx, float dy)
          Adjust (add) the position of this particle
 void adjustSize(float delta)
          Adjust the size of the particle
 void adjustVelocity(float dx, float dy)
          Adjust (add) the direction of this particle
 Color getColor()
          Get the color of this particle
 ParticleEmitter getEmitter()
          Get the emitter that owns this particle
 float getLife()
          Get the life remaining in the particle in milliseconds
 float getOriginalLife()
          Get the original life of this particle
 float getScaleY()
          Get the current scalar applied on the y axis
 float getSize()
          Get the size of this particle
 int getType()
          Get the type of this particle
 float getX()
          Get the x offset of this particle
 float getY()
          Get the y offset of this particle
 void init(ParticleEmitter emitter, float life)
          Initialise the state of the particle as it's reused
 boolean inUse()
          Check if this particle is currently in use (i.e.
 boolean isOriented()
          Check if this particle is being oriented based on it's velocity
 void kill()
          Kill the particle, stop it rendering and send it back to the engine for use.
 void move(float x, float y)
          Move this particle a fixed amount
 void render()
          Render this particle
 void setColor(float r, float g, float b, float a)
          Set the color of the particle
 void setImage(Image image)
          Set the image used to render this particle
 void setLife(float life)
          Set the life of the particle
 void setOriented(boolean oriented)
          Indicate if this particle should be oriented based on it's velocity
 void setPosition(float x, float y)
          Set the position of this particle
 void setScaleY(float scaleY)
          Set the current scalar applied on the y axis
 void setSize(float size)
          Set the size of the particle
 void setSpeed(float speed)
          Set the current speed of this particle
 void setType(int type)
          Set the type of this particle
 void setUsePoint(int usePoints)
          Indicate how this particle should be renered
 void setVelocity(float velx, float vely)
          Set the velocity of the particle
 void setVelocity(float dirx, float diry, float speed)
          Set the velocity of the particle
 java.lang.String toString()
           
 void update(int delta)
          Update the state of this particle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

GL

protected static SGL GL
The renderer to use for all GL operations


INHERIT_POINTS

public static final int INHERIT_POINTS
Indicates the particle should inherit it's use of points

See Also:
Constant Field Values

USE_POINTS

public static final int USE_POINTS
Indicates the particle should explicitly use points

See Also:
Constant Field Values

USE_QUADS

public static final int USE_QUADS
Indicates the particle should explicitly not use points

See Also:
Constant Field Values

x

protected float x
The x coordinate of the particle


y

protected float y
The y coordinate of the particle


velx

protected float velx
The x component of the direction vector of the particle


vely

protected float vely
The y component of the direction vector of the particle


size

protected float size
The current size in pixels of the particle


color

protected Color color
The colour of the particle


life

protected float life
The life left in the particle


originalLife

protected float originalLife
The original life of this particle


image

protected Image image
The image for this particle


type

protected int type
The type identifier of this particle


usePoints

protected int usePoints
How this particle should be rendered


oriented

protected boolean oriented
True if this particle's quad should be oritented based on it's direction


scaleY

protected float scaleY
The currently scalar applied on the y axis

Constructor Detail

Particle

public Particle(ParticleSystem engine)
Create a new particle belonging to given engine

Parameters:
engine - The engine the new particle belongs to
Method Detail

getX

public float getX()
Get the x offset of this particle

Returns:
The x offset of this particle

getY

public float getY()
Get the y offset of this particle

Returns:
The y offset of this particle

move

public void move(float x,
                 float y)
Move this particle a fixed amount

Parameters:
x - The amount to move the particle on the horizontal axis
y - The amount to move the particle on the vertical axis

getSize

public float getSize()
Get the size of this particle

Returns:
The size of this particle

getColor

public Color getColor()
Get the color of this particle

Returns:
The color of this particle

setImage

public void setImage(Image image)
Set the image used to render this particle

Parameters:
image - The image used to render this particle

getOriginalLife

public float getOriginalLife()
Get the original life of this particle

Returns:
The original life of this particle

getLife

public float getLife()
Get the life remaining in the particle in milliseconds

Returns:
The life remaining in the particle

inUse

public boolean inUse()
Check if this particle is currently in use (i.e. is it rendering?)

Returns:
True if the particle is currently in use

render

public void render()
Render this particle


update

public void update(int delta)
Update the state of this particle

Parameters:
delta - The time since the last update

init

public void init(ParticleEmitter emitter,
                 float life)
Initialise the state of the particle as it's reused

Parameters:
emitter - The emitter controlling this particle
life - The life the particle should have (in milliseconds)

setType

public void setType(int type)
Set the type of this particle

Parameters:
type - The type of this particle

setUsePoint

public void setUsePoint(int usePoints)
Indicate how this particle should be renered

Parameters:
usePoints - The indicator for rendering
See Also:
USE_POINTS, USE_QUADS, INHERIT_POINTS

getType

public int getType()
Get the type of this particle

Returns:
The type of this particle

setSize

public void setSize(float size)
Set the size of the particle

Parameters:
size - The size of the particle (in pixels)

adjustSize

public void adjustSize(float delta)
Adjust the size of the particle

Parameters:
delta - The amount to adjust the size by (in pixels)

setLife

public void setLife(float life)
Set the life of the particle

Parameters:
life - The life of the particle in milliseconds

adjustLife

public void adjustLife(float delta)
Adjust the life othe particle

Parameters:
delta - The amount to adjust the particle by (in milliseconds)

kill

public void kill()
Kill the particle, stop it rendering and send it back to the engine for use.


setColor

public void setColor(float r,
                     float g,
                     float b,
                     float a)
Set the color of the particle

Parameters:
r - The red component of the color
g - The green component of the color
b - The blue component of the color
a - The alpha component of the color

setPosition

public void setPosition(float x,
                        float y)
Set the position of this particle

Parameters:
x - The new x position of the particle
y - The new y position of the particle

setVelocity

public void setVelocity(float dirx,
                        float diry,
                        float speed)
Set the velocity of the particle

Parameters:
dirx - The x component of the new velocity
diry - The y component of the new velocity
speed - The speed in the given direction

setSpeed

public void setSpeed(float speed)
Set the current speed of this particle

Parameters:
speed - The speed of this particle

setVelocity

public void setVelocity(float velx,
                        float vely)
Set the velocity of the particle

Parameters:
velx - The x component of the new velocity
vely - The y component of the new velocity

adjustPosition

public void adjustPosition(float dx,
                           float dy)
Adjust (add) the position of this particle

Parameters:
dx - The amount to adjust the x component by
dy - The amount to adjust the y component by

adjustColor

public void adjustColor(float r,
                        float g,
                        float b,
                        float a)
Adjust (add) the color of the particle

Parameters:
r - The amount to adjust the red component by
g - The amount to adjust the green component by
b - The amount to adjust the blue component by
a - The amount to adjust the alpha component by

adjustColor

public void adjustColor(int r,
                        int g,
                        int b,
                        int a)
Adjust (add) the color of the particle

Parameters:
r - The amount to adjust the red component by
g - The amount to adjust the green component by
b - The amount to adjust the blue component by
a - The amount to adjust the alpha component by

adjustVelocity

public void adjustVelocity(float dx,
                           float dy)
Adjust (add) the direction of this particle

Parameters:
dx - The amount to adjust the x component by
dy - The amount to adjust the y component by

getEmitter

public ParticleEmitter getEmitter()
Get the emitter that owns this particle

Returns:
The emitter that owns this particle

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
See Also:
Object.toString()

isOriented

public boolean isOriented()
Check if this particle is being oriented based on it's velocity

Returns:
True if this particle being oriented based on it's velocity

setOriented

public void setOriented(boolean oriented)
Indicate if this particle should be oriented based on it's velocity

Parameters:
oriented - True if this particle is being oriented based on it's velocity

getScaleY

public float getScaleY()
Get the current scalar applied on the y axis

Returns:
The scalar applied on the y axis

setScaleY

public void setScaleY(float scaleY)
Set the current scalar applied on the y axis

Parameters:
scaleY - The new scalar to apply on the y axis


Copyright © 2006 New Dawn Software. All Rights Reserved.