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

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

Best Java code snippets using jsettlers.common.map.shapes.MapCircleIterator.hasNext (Showing top 3 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

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());
  }
}
jsettlers.common.map.shapesMapCircleIteratorhasNext

Popular methods of MapCircleIterator

  • 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

  • Making http post requests using okhttp
  • startActivity (Activity)
  • getExternalFilesDir (Context)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • IOException (java.io)
    Signals a general, I/O-related error. Error details may be specified when calling the constructor, a
  • ConnectException (java.net)
    A ConnectException is thrown if a connection cannot be established to a remote host on a specific po
  • PriorityQueue (java.util)
    A PriorityQueue holds elements on a priority heap, which orders the elements according to their natu
  • UUID (java.util)
    UUID is an immutable representation of a 128-bit universally unique identifier (UUID). There are mul
  • Manifest (java.util.jar)
    The Manifest class is used to obtain attribute information for a JarFile and its entries.
  • FileUtils (org.apache.commons.io)
    General file manipulation utilities. Facilities are provided in the following areas: * writing to a
  • Top Sublime Text 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