Package org.newdawn.fizzy

Examples of org.newdawn.fizzy.CompoundShape


    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();

    }
   
    if (terrainBody.isAttached()){
      world.remove(terrainBody);
    }
   
    compoundTerrain = new CompoundShape();
    for (int i = 0; i < Constants.MAX_WIDTH; i++){
      compoundTerrain.add(terrain[i]);
    }   
   
    terrainBody = new StaticBody(compoundTerrain, x0, y0);
View Full Code Here


        new Vec2(width, -height),
        new Vec2(-width, -height)
    }
    bottom.setPoints(bottomP);

    CompoundShape boundaryShape = new CompoundShape();
    boundaryShape.add(top);
    boundaryShape.add(left);
    boundaryShape.add(right);
    boundaryShape.add(bottom);

    return new StaticBody(boundaryShape,0,0);
  }
View Full Code Here

TOP

Related Classes of org.newdawn.fizzy.CompoundShape

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.