public class Flock
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
DetectionRange
The Detection range.
|
static int |
SeparationRange
The Separation range.
|
Constructor and Description |
---|
Flock(BirdCollection birds)
This is the flock contstructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addBird(Bird bird)
Add a bird to the flock.
|
com.jme3.math.Vector2f |
closestLocation(com.jme3.math.Vector2f p,
com.jme3.math.Vector2f otherPoint)
Sometimes, two birds are closer together if you go off one edge of the
map and return on the other.
|
java.util.Vector<Bird> |
move()
Tells each Bird in the Vector to move in the direction of the
generalHeading.
|
com.jme3.math.Vector2f |
normalisePoint(com.jme3.math.Vector2f p,
double n)
Normalize a point.
|
void |
setBirdParameters(java.awt.Color color,
float speed,
float theta)
Set the settings for all birds of a given color.
|
void |
setHunger(int hunger)
Set the hunger value for all predators
|
double |
sizeOfPoint(com.jme3.math.Vector2f p)
Distance from the top left of the map to a given point
|
com.jme3.math.Vector2f |
sumPoints(com.jme3.math.Vector2f p1,
double w1,
com.jme3.math.Vector2f p2,
double w2)
Add two points together, scaling both according to their weight
|
public static int DetectionRange
public static int SeparationRange
public Flock(BirdCollection birds)
public void addBird(Bird bird)
bird
- The bird to addpublic com.jme3.math.Vector2f closestLocation(com.jme3.math.Vector2f p, com.jme3.math.Vector2f otherPoint)
p
- The point to measure the distance to.otherPoint
- The point to measure the distance from.public java.util.Vector<Bird> move()
public com.jme3.math.Vector2f normalisePoint(com.jme3.math.Vector2f p, double n)
p
- The point to normalize.n
- The normalization value.public void setBirdParameters(java.awt.Color color, float speed, float theta)
color
- The color of the bird to removespeed
- The new speed of the birdtheta
- The new theta of the birdpublic void setHunger(int hunger)
hunger
- The new hunger value for all predatorspublic double sizeOfPoint(com.jme3.math.Vector2f p)
p
- The point to measure the distance to.public com.jme3.math.Vector2f sumPoints(com.jme3.math.Vector2f p1, double w1, com.jme3.math.Vector2f p2, double w2)
p1
- The first point to addw1
- The weight of the first poitnp2
- The second point to addw2
- The weight of the second point