java.lang.Object Particle
public class Particle
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.
Constructor Summary | |
---|---|
Particle(double hue,
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 |
java.awt.Color |
getColor()
Get the color of this particle |
int |
getTimesMoved()
Return the number of times this Particle has been moved. |
double |
getXPosition()
Return the X position of this Particle |
double |
getXVelocity()
Return the X velocity of this Particle |
double |
getYPosition()
Return the Y position of this Particle |
double |
getYVelocity()
|
void |
setXPosition(double position)
Set the x position |
void |
setXVelocity(double velocity)
Set the x velocity |
void |
setYPosition(double position)
Set the y position |
void |
setYVelocity(double velocity)
Sets the y velocity |
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 |
Constructor Detail |
---|
public Particle(double hue, double startX, double startY)
hue
- A number from 0 to 1 that specifies desired hue of the
ParticlestartX
- The starting x coordinatestartY
- The starting y coordinateMethod Detail |
---|
public void drawSelf(java.awt.Graphics graphics)
graphics
- The Graphics object to draw onto.public void takeOneStep()
public int getTimesMoved()
public double getXPosition()
public double getYPosition()
public double getXVelocity()
public double getYVelocity()
public void setXPosition(double position)
position
- the xPosition to setpublic void setYPosition(double position)
position
- the yPosition to setpublic void setXVelocity(double velocity)
velocity
- the xVelocity to setpublic void setYVelocity(double velocity)
velocity
- the yVelocity to setpublic java.awt.Color getColor()