Med en ny funktion i Util kan man beräkna åt vilket håll man ska åka för att möta upp med ett IObject om man åker i en viss hastighet.
Spelarnas skate() och shoot()-metoder anropar automatiskt den funktionen när man skickar in ett IObject. Det gör att det är lättare att sikta både för att passa och ta emot en pass! Dessutom gör en förbättring i spelmotorn att spelarna är bättre på att faktiskt fånga upp en passad puck.
Passa på!
java.lang.Object | +--hockey.api.Util
Method Summary | |
static int |
collisionHeading(IObject target,
IObject origin,
int speed)
Calculate the heading for collision from origin to
target travelling at speed speed
relative to the ice. |
static double |
solve(double a,
double b,
double c,
boolean pos)
Solve ax^2 + 2bx + c = 0 for x. |
Method Detail |
public static double solve(double a, double b, double c, boolean pos)
a
- the quadratic factor.b
- half the linear factor.c
- the constant factor.pos
- determines whether to return the +
solution.
(-b +/- sqrt(b*b - a*c)) / a
or NaN
if there is no solution.
or -c / 2 / b
if a +
solution is requested
and the equation is (nearly) linear.
public static int collisionHeading(IObject target, IObject origin, int speed)
origin
to
target
travelling at speed speed
relative to the ice.
target
- the target.origin
- the origin.speed
- the speed.