Beispiel #1
0
  @Test
  public void ShouldCalculateEnemyCoordinatesCorrectlyWhenOrientedNorthEastWithEnemyWest() {
    IGearbox gearbox = new FakeGearbox().setPosition(300, 200).setHeading(Math.PI / 4);

    double bearingToEnemy = -3 * Math.PI / 4.0;
    double distance = 20;
    EnemyState state = new EnemyState().setPosition(gearbox, bearingToEnemy, distance);

    assertEquals(280, state.getX(), .00001);
    assertEquals(200, state.getY(), .00001);
  }
Beispiel #2
0
  @Test
  public void ShouldCalculateEnemyCoordinatesCorrectlyWhenOrientedNorthWithEnemySouth() {
    IGearbox gearbox = new FakeGearbox().setPosition(100, 200);

    double bearingToEnemy = -1 * Math.PI;
    double distance = 20;
    EnemyState state = new EnemyState().setPosition(gearbox, bearingToEnemy, distance);

    assertEquals(100, state.getX(), .00001);
    assertEquals(180, state.getY(), .00001);
  }