Tabnine Logo
MapCircleIterator
Code IndexAdd Tabnine to your IDE (free)

How to use
MapCircleIterator
in
jsettlers.common.map.shapes

Best Java code snippets using jsettlers.common.map.shapes.MapCircleIterator (Showing top 7 results out of 315)

origin: jsettlers/settlers-remake

private int countElements(MapCircle circle) {
  int counter = 0;
  MapCircleIterator iter = circle.iterator();
  while (iter.hasNext()) { // count the elements in the circle to create array
    iter.nextX();
    counter++;
  }
  return counter;
}
origin: jsettlers/settlers-remake

@Override
public final MapCircleIterator iterator() {
  return new MapCircleIterator(this);
}
origin: jsettlers/settlers-remake

/**
 * NOTE: nextY() MUST BE CALLED before this method is called!
 * 
 * @return gives the x of the current iterator position
 */
public final int nextX() {
  return computeNextXAndProgress();
}
origin: jsettlers/settlers-remake

public CachedViewCircle(int radius) {
  radius -= FogOfWar.PADDING / 2;
  MapCircle circle = new MapCircle(0, 0, radius + FogOfWar.PADDING);
  size = countElements(circle);
  x = new short[size];
  y = new short[size];
  sight = new byte[size];
  MapCircleIterator iter = circle.iterator();
  final float squaredViewDistance = radius * radius;
  int i = 0;
  while (iter.hasNext()) {
    int y = iter.nextY();
    int x = iter.nextX();
    this.x[i] = (short) x;
    this.y[i] = (short) y;
    double squaredDistance = MapCircle.getSquaredDistance(x, y);
    byte newSight;
    if (squaredDistance < squaredViewDistance) {
      newSight = CommonConstants.FOG_OF_WAR_VISIBLE;
    } else {
      newSight = (byte) (CommonConstants.FOG_OF_WAR_VISIBLE - (Math.sqrt(squaredDistance) - radius) / FogOfWar.PADDING
          * CommonConstants.FOG_OF_WAR_VISIBLE);
    }
    sight[i] = newSight;
    i++;
  }
}
origin: jsettlers/settlers-remake

@Test
public void testStream() {
  for (int i = 0; i < 40; i++) {
    MapCircle circle = new MapCircle(new ShortPoint2D(100, 100), i);
    MapCircleIterator iterator = circle.iterator();
    circle.stream().forEach((x, y) -> {
      assertTrue(iterator.hasNext());
      ShortPoint2D expected = iterator.next();
      assertEquals(expected, new ShortPoint2D(x, y));
    });
    assertFalse(iterator.hasNext());
  }
}
origin: jsettlers/settlers-remake

};
boolean result = AreaTraversingAlgorithm.traverseArea(containingProvider, visitor, c1.iterator().next(), WIDTH, HEIGHT);
assertTrue(result);
origin: jsettlers/settlers-remake

@Override
public ShortPoint2D next() {
  int y = currentY + centerY;
  int x = computeNextXAndProgress();
  return new ShortPoint2D(x, y);
}
jsettlers.common.map.shapesMapCircleIterator

Most used methods

  • hasNext
  • next
  • <init>
  • computeNextXAndProgress
  • nextX
    NOTE: nextY() MUST BE CALLED before this method is called!
  • nextY
    NOTE: nextX() MUST BE CALLED after this call to progress to the next position.

Popular in Java

  • Creating JSON documents from java classes using gson
  • setRequestProperty (URLConnection)
  • setContentView (Activity)
  • getSharedPreferences (Context)
  • Selector (java.nio.channels)
    A controller for the selection of SelectableChannel objects. Selectable channels can be registered w
  • KeyStore (java.security)
    KeyStore is responsible for maintaining cryptographic keys and their owners. The type of the syste
  • JButton (javax.swing)
  • JLabel (javax.swing)
  • FileUtils (org.apache.commons.io)
    General file manipulation utilities. Facilities are provided in the following areas: * writing to a
  • IsNull (org.hamcrest.core)
    Is the value null?
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now