java.lang.ObjectBanana
public class Banana
This class represents a banana. It keeps track of the position of the banana, its radius, its direction and its velocity. The banana produces a shock wave when it splats after hitting a gorilla or a building. The class keeps track of the range in which a banana's shock wave hurts gorillas as well as the progress of the shock wave.
| Field Summary | |
|---|---|
static int |
MAX_SHOCK_WAVE_RADIUS
The reach of the bananas' explosion shock waves |
static double |
RADIUS
The radius of all bananas |
| Constructor Summary | |
|---|---|
Banana(double x,
double y,
double xVel,
double yVel)
Makes a new banana with the specified position. |
|
| Method Summary | |
|---|---|
int |
getCurrentShockWaveRadius()
Returns the current radius of the banana's shock wave |
double |
getX()
Returns the x coordinate of the center of the banana |
double |
getY()
Returns the y coordinate of the center of the banana |
boolean |
isSplatting()
Indicates whether the banana splatted already. |
void |
splat()
Sets the banana to the splatting state. |
void |
tick(double time,
double gravity)
Simulates the behavior of the banana for one tick. |
java.lang.String |
toString()
Returns information about the banana as a string. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final double RADIUS
public static final int MAX_SHOCK_WAVE_RADIUS
| Constructor Detail |
|---|
public Banana(double x,
double y,
double xVel,
double yVel)
x - The x coordinate of the center of the banana.y - The y coordinate of the center of the banana.xVel - The velocity of the banana in the direction of the x axis.yVel - The velocity of the banana in the direction of the y axis.| Method Detail |
|---|
public void splat()
public double getX()
public double getY()
public boolean isSplatting()
public int getCurrentShockWaveRadius()
public void tick(double time,
double gravity)
time - The length of a tickgravity - Gravitational constantpublic java.lang.String toString()
toString in class java.lang.Object