Locatable
public interface Food extends Locatable
getHeight()
is zero) or it is in the air. If it is on the ground, it
will not move between turns. If it in the air, it will move a distance of
SPEED
each turn in the direction of getHeading()
, and its
height will decrease by FALL_SPEED
each turn.
For collision purposes, food pieces can be thought of as disks parallel to
the ground plane of the field. getHeight()
represents the distance
between the food piece disk and the ground. The radius of the disk is
dependent on the type of food, and can be retrieved with the
Food.Type.getRadius()
method. The center of the disk can be located with
Locatable.getLocation()
, which is relative to the lower-left corner of the
field when viewed from above.
Note that this class is not used to represent food on tables or in players'
inventories, only food on the ground or in the air. Food pieces on tables and
in inventories do not have a location, height, or heading, so they are
represented only by their Food.Type
.
Modifier and Type | Interface | Description |
---|---|---|
static class |
Food.Type |
A type of food.
|
Modifier and Type | Field | Description |
---|---|---|
static RandomScalar |
FALL_SPEED |
The vertical distance traveled by an airborne food piece each turn.
|
static double |
RESPAWN_RATE |
The probability of new food spawning on a turn with missing food.
|
static RandomScalar |
SPEED |
The horizontal distance traveled by an airborne food piece each turn.
|
Modifier and Type | Method | Description |
---|---|---|
Direction |
getHeading() |
Returns the direction of travel of this food piece.
|
double |
getHeight() |
Returns the distance between the ground plane and this piece of food.
|
Food.Type |
getType() |
Returns the type of this piece of food.
|
getLocation
static final RandomScalar SPEED
static final RandomScalar FALL_SPEED
static final double RESPAWN_RATE
Food.Type getType()
double getHeight()
Direction getHeading()