Class Particle

java.lang.Object
  extended by Particle

public class Particle
extends java.lang.Object

A Particle is a 2D colored dot that follows basic physics. It has a velocity and is affected by gravity. It is able to move itself and to draw itself.

Author:
Tim

Field Summary
static double GRAVITY
          The acceleration (in pixels per frame) due to "Gravity"
 
Constructor Summary
Particle(double hue, double angle, double speed, double startX, double startY)
          Creates a new Particle based on the given parameters.
 
Method Summary
 void drawSelf(java.awt.Graphics graphics)
          Draw this Particle onto the provided Graphics object
 int getTimesMoved()
          Return the number of times this Particle has been moved.
 double getXPosition()
          Return the X position of this Particle
 double getYPosition()
          Return the Y position of this Particle
 void takeOneStep()
          Move this Particle one frame's worth of movement
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GRAVITY

public static final double GRAVITY
The acceleration (in pixels per frame) due to "Gravity"

See Also:
Constant Field Values
Constructor Detail

Particle

public Particle(double hue,
                double angle,
                double speed,
                double startX,
                double startY)
Creates a new Particle based on the given parameters. You can specify the color, position, and velocity. The angle should be in degrees from 0 to 360. The speed should be in pixels per frame. The coordinates should be in java coordinates, so (0,0) is the upper lefthand corner
If you give 0 for the color, you get green. .2 gives orange, .3 gives pink, .4 gives magenta, .5 gives violet, .6 gives blue, .8 gives cyan, and 1 returns to green.

Parameters:
hue - A number from 0 to 1 that specifies desired hue of the Particle
angle - The desired angle in degress
speed - The desired speed in pixels per frame
startX - The starting x coordinate
startY - The starting y coordinate
Method Detail

drawSelf

public void drawSelf(java.awt.Graphics graphics)
Draw this Particle onto the provided Graphics object

Parameters:
graphics - The Graphics object to draw onto.

takeOneStep

public void takeOneStep()
Move this Particle one frame's worth of movement


getXPosition

public double getXPosition()
Return the X position of this Particle

Returns:
The X position

getYPosition

public double getYPosition()
Return the Y position of this Particle

Returns:
The Y position

getTimesMoved

public int getTimesMoved()
Return the number of times this Particle has been moved.

Returns:
The number of times this particle has been moved