Game Development Reference
In-Depth Information
}
}
// player spawn point
else if
(BLOCK_TYPE.PLAYER_SPAWNPOINT.sameColor(currentPixel)) {
}
// feather
else if (BLOCK_TYPE.ITEM_FEATHER.sameColor(currentPixel)) {
}
// gold coin
else if (BLOCK_TYPE.ITEM_GOLD_COIN.sameColor(currentPixel)) {
}
// unknown object/pixel color
else {
int r = 0xff & (currentPixel >>> 24); //red color channel
int g = 0xff & (currentPixel >>> 16); //green color channel
int b = 0xff & (currentPixel >>> 8); //blue color channel
int a = 0xff & currentPixel; //alpha channel
Gdx.app.error(TAG, "Unknown object at x<" + pixelX + "> y<"
+ pixelY + ">: r<" + r+ "> g<" + g + "> b<" + b + "> a<" + a + ">");
}
lastPixel = currentPixel;
}
}
// decoration
clouds = new Clouds(pixmap.getWidth());
clouds.position.set(0, 2);
mountains = new Mountains(pixmap.getWidth());
mountains.position.set(-1, -1);
waterOverlay = new WaterOverlay(pixmap.getWidth());
waterOverlay.position.set(0, -3.75f);
// free memory
pixmap.dispose();
Gdx.app.debug(TAG, "level '" + filename + "' loaded");
}
This method starts by creating a new and empty list for the rocks. Then, it uses Gdx.
files.internal() to get a file handle, which in turn is used to create a new Pixmap
object. It contains the pixel data of the level image that is to be scanned
and interpreted.
 
Search WWH ::




Custom Search