Ejemplo n.º 1
0
unsigned int World::getAreaID()
{
	MapTile *curTile;

	int mtx,mtz,mcx,mcz;
	mtx = (int) (camera.x / TILESIZE);
	mtz = (int) (camera.z / TILESIZE);
	mcx = (int) (fmod(camera.x, TILESIZE) / CHUNKSIZE);
	mcz = (int) (fmod(camera.z, TILESIZE) / CHUNKSIZE);

	if ((mtx<cx-1) || (mtx>cx+1) || (mtz<cz-1) || (mtz>cz+1)) return 0;
	
	curTile = current[mtz-cz+1][mtx-cx+1];
	if(curTile == 0) return 0;

	MapChunk *curChunk = curTile->getChunk(mcx, mcz);

	if(curChunk == 0) return 0;

	return curChunk->areaID;
}