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