Nytt API för smartare spelare

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å!


hockey.api
Class Util

java.lang.Object
  |
  +--hockey.api.Util

public class Util
extends java.lang.Object
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

solve

public static double solve(double a,
                           double b,
                           double c,
                           boolean pos)
Solve ax^2 + 2bx + c = 0 for x.

Parameters:
a - the quadratic factor.
b - half the linear factor.
c - the constant factor.
pos - determines whether to return the + solution.
Returns:
(-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.


collisionHeading

public 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.

Parameters:
target - the target.
origin - the origin.
speed - the speed.
Returns:
the collision heading or the target heading if no collision possible.