Package org.newdawn.fizzy

Examples of org.newdawn.fizzy.Polygon


    if (terrain.length == 1) terrain = new CompoundShape[Constants.MAX_WIDTH];
    for (int x = 0; x < Constants.MAX_WIDTH; x++) {
      if (x < leftmostXFromExplosion && leftmostXFromExplosion != 1000000f) continue;
      if (x > rightmostXFromExplosion && rightmostXFromExplosion != -1f) continue;

      Polygon temp = new Polygon();
      CompoundShape compoundTemp = new CompoundShape();
      Vec2 firstPoint = null;
      Vec2 lastPoint = null;

      for (int y = 0; y < Constants.MAX_HEIGHT * 2; y++) {
        if (terrainBitmap[x][y] > 0.5) {
          if (firstPoint == null)
            firstPoint = new Vec2(x, y);
          else
            lastPoint = new Vec2(x, y);
        } else {
          if (firstPoint != null) {
            if (lastPoint == null)
              lastPoint = new Vec2(firstPoint.x + 0.1f,
                  firstPoint.y);
            temp.setPoints(new Vec2[] { firstPoint, lastPoint });
            compoundTemp.add(temp);
            temp = new Polygon();
            firstPoint = null;
            lastPoint = null;
          }
        }
      }
      if (firstPoint != null) {
        if (lastPoint == null)
          lastPoint = new Vec2(firstPoint.x + 0.1f, firstPoint.y);
        temp.setPoints(new Vec2[] { lastPoint, firstPoint });
        compoundTemp.add(temp);
        temp = new Polygon();
        firstPoint = null;
        lastPoint = null;
      }
      terrain[x] = compoundTemp;
      compoundTemp = new CompoundShape();
View Full Code Here


    }
  }
 
  protected StaticBody addBoundary(int width, int height){
   
    Polygon top = new Polygon();
    Polygon left = new Polygon();
    Polygon right = new Polygon();
    Polygon bottom = new Polygon();
    Vec2[] topP = {
        new Vec2(width, height),
        new Vec2(-width, height)
    };
    top.setPoints(topP);

    Vec2[] leftP = {
        new Vec2(-width, height),
        new Vec2(-width, -height)
    };
    left.setPoints(leftP);

    Vec2[] rightP = {
        new Vec2(width, -height),
        new Vec2(width, height)
    };
    right.setPoints(rightP);

    Vec2[] bottomP = {
        new Vec2(width, -height),
        new Vec2(-width, -height)
    }
    bottom.setPoints(bottomP);

    CompoundShape boundaryShape = new CompoundShape();
    boundaryShape.add(top);
    boundaryShape.add(left);
    boundaryShape.add(right);
View Full Code Here

TOP

Related Classes of org.newdawn.fizzy.Polygon

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.