void initialize() { Position p; operationID = 0; memset(visited, 0, sizeof(int)*WIDTH*HEIGHT); for(int l = 0; l < HEIGHT; ++l) { for(int c = 0; c < WIDTH; ++c) { theMap[l][c].pWall = PRIOR_WALL; theMap[l][c].pBall = PRIOR_BALL; theMap[l][c].wallType = NORMAL_WALL; theMap[l][c].visited = false; p.l = l; p.c = c; setNeighbors(p); } } }
//----------------------------------------------------------------------- void PagingLandScapePage::load() { touch(); if (isLoaded()) { S_LOG_WARNING("PagingLandScapePage at (" << mTableX << ", " << mTableZ << ") already loading/loaded, ignoring load() request"); return; } S_LOG_VERBOSE("Loading PagingLandScapePage at (" << mTableX << ", " << mTableZ << ")"); if (mPageState == STATE_INITED) { preloadInBackground(); // it takes a while to do it, so we don't bother trying to load and failing return; } if (mPageState == STATE_PRELOADED) { // load texture S_LOG_VERBOSE("Loading texture for PagingLandScapePage at (" << mTableX << ", " << mTableZ << ")"); mPageMgr.getSceneManager()->getTextureManager()->load(mTableX, mTableZ); // initialize tile containers mTiles.reserve(mNumTiles); mTiles.resize(mNumTiles); for (size_t i = 0; i < mNumTiles; ++i) { mTiles[i].reserve(mNumTiles); mTiles[i].resize(mNumTiles); } // initialize tiles PagingLandScapeTileManager* tileMgr = mPageMgr.getSceneManager()->getTileManager(); for (size_t i = 0; i < mTiles.size(); ++i) { for (size_t j = 0; j < mTiles[i].size(); ++j) { PagingLandScapeTile* tile = tileMgr->getTile(); assert (tile); mTiles[i][j] = tile; tile->init(mPageNode, mTableX, mTableZ, i, j); // set up tile neighbors within page if (j > 0) { PagingLandScapeTile* northTile = mTiles[i][j-1]; tile->_setNeighbor(NORTH, northTile); northTile->_setNeighbor(SOUTH, tile); } if (i > 0) { PagingLandScapeTile* westTile = mTiles[i-1][j]; tile->_setNeighbor(WEST, westTile); westTile->_setNeighbor(EAST, tile); } } } // set new state mPageState = STATE_LOADED; // set page neighbors setNeighbors(); // fire event fireEvent(EVENT_LOADED); } else if (mPageState == STATE_PRELOADING) { // wait... return; } else { S_LOG_WARNING("PagingLandScapePage at (" << mTableX << ", " << mTableZ << ") already loaded, proceeding to show it"); } show(true); }