void MapIndex::setChanged(int x, int z) { // change the changed flag of the map tile if(hasTile(x, z)) { if(!mTiles[x][z].tile) loadTile(x, z); if(mTiles[x][z].tile->changed == 1) return; mTiles[x][z].tile->changed = 1; } for (int posaddx = -1; posaddx < 2; posaddx++) { for (int posaddz = -1; posaddz < 2; posaddz++) { if(!hasTile(x+posaddx,z+posaddz)) continue; if(!mTiles[x+posaddx][z+posaddz].tile) loadTile(x+posaddx, z+posaddz); if(mTiles[x+posaddx][z+posaddz].tile->changed == 1) continue; mTiles[x+posaddx][z+posaddz].tile->changed = 2; } } }
void hrAdventureScreen::loadMap(hrH3MReader *reader) { Q_ASSERT(reader); clearMap(); size.setSize(QSize(reader->getSize(), reader->getSize())); hasUnderground = reader->hasUnderground(); hrCache& cache = hrCache::Get(); for (int i = 0; i < size.width() * size.height(); i++) { hrTile tile = reader->getTile(i); tilesGround.append(tile); loadTile(tile); if (hasUnderground) { tile = reader->getTile(i, true); tilesUnderground.append(tile); loadTile(tile); } } for (int i = 0; i < reader->getObjectsCount(); i++) { hrSceneObject object = reader->getObject(i); hrGraphicsItem item; if (!itemsObject.contains(object.getId())) { QString name = reader->getObjectName(object.getId()); item = cache.loadItem(name); itemsObject[object.getId()] = item; } else { item = itemsObject[object.getId()]; } object.setFrames(item.countFrames); object.setSize(coord::toCell(item.getSize())); if (!object.isUnderground()) objectsGround.append(object); else objectsUnderground.append(object); } std::sort(objectsGround.begin(), objectsGround.end()); std::sort(objectsUnderground.begin(), objectsUnderground.end()); loadCursor("cradvntr.def"); setCursor(CURSOR_POINTER); animateTimer.start(200); }
/*! * Loads all tile from the file. */ bool TileManager::loadTiles() { int size; uint8 *type_data; // first reads types type_data = File::loadOriginalFile(TILE_TYPES, size); if (!type_data) { return false; } // then reads tiles uint8 *tileData = File::loadOriginalFile(TILE_SET, size); if (!tileData) { FSERR(Log::k_FLG_IO, "TileManager", "loadTiles", ("Failed to load tiles data\n")); delete[] type_data; return false; } // Loads all tiles for (int i = 0; i < kNumOfTiles; ++i) { a_tiles_[i] = loadTile(tileData, i, toTileType(type_data[i])); } delete[] type_data; delete[] tileData; return true; }
void MapIndex::enterTile( int x, int z ) { if( !hasTile( z, x ) ) { noadt = true; return; } noadt = false; cx = x; cz = z; for( int i = std::max(cz - 2, 0); i < std::min(cz + 2, 64); ++i ) { for( int j = std::max(cx - 2, 0); j < std::min(cx + 2, 64); ++j ) { mTiles[i][j].tile = loadTile( i, j ); } } if( autoheight && tileLoaded( cz, cx ) ) //ZX STEFF HERE SWAP! { float maxHeight = mTiles[cz][cx].tile->getMaxHeight(); maxHeight = std::max( maxHeight, 0.0f ); gWorld->camera.y = maxHeight + 50.0f; autoheight = false; } }
QPixmap ImageManager::getImage(const QString& host, const QString& url) { //qDebug() << "ImageManager::getImage"; QPixmap pm; //pm.fill(Qt::black); //is image cached (memory) or currently loading? if (!QPixmapCache::find(url, pm) && !net->imageIsLoading(url)) // if (!images.contains(url) && !net->imageIsLoading(url)) { //image cached (persistent)? if (doPersistentCaching && tileExist(url)) { loadTile(url,pm); QPixmapCache::insert(url.toAscii().toBase64(), pm); } else { //load from net, add empty image net->loadImage(host, url); //QPixmapCache::insert(url, emptyPixmap); return emptyPixmap; } } return pm; }
void Area::loadTiles(const Aurora::GFF3List &tiles) { size_t n = 0; for (Aurora::GFF3List::const_iterator t = tiles.begin(); t != tiles.end(); ++t, ++n) { assert(n < (_width * _height)); loadTile(**t, _tiles[n]); } assert(n == _tiles.size()); }
void PanelButton::loadTiles() { if (m_tileColor.isValid()) { setBackgroundOrigin(WidgetOrigin); m_up = m_down = QPixmap(); } else if (m_tile.isNull()) { setBackgroundOrigin(AncestorOrigin); m_up = m_down = QPixmap(); } else { setBackgroundOrigin(WidgetOrigin); // If only the tiles were named a bit smarter we wouldn't have // to pass the up or down argument. m_up = QPixmap(loadTile(m_tile, size(), "up")); m_down = QPixmap(loadTile(m_tile, size(), "down")); } }
void MapWidget::loadTiles() { int totalTiles = std::pow(2, ZOOM); for (int x = 0; x < totalTiles; ++x) { for (int y = 0; y < totalTiles; ++y) { QPoint tp(x, y); if (!tilePixmaps.contains(tp)) { tilePixmaps.insert(tp, loadTile(ZOOM, x, y)); } } } }
void Pony48Engine::clearBoardAnimations() { for(int i = 0; i < BOARD_HEIGHT; i++) { for(int j = 0; j < BOARD_WIDTH; j++) { if(m_Board[j][i] == NULL) continue; m_Board[j][i]->drawSlide.SetZero(); m_Board[j][i]->drawSize.Set(TILE_WIDTH, TILE_HEIGHT); } } //Check slide-and-join anims for(list<TilePiece*>::iterator i = m_lSlideJoinAnimations.begin(); i != m_lSlideJoinAnimations.end();) { //Hit the end; join with destination tile if((*i)->destx >= 0 && (*i)->desty >= 0) { if(m_Board[(*i)->destx][(*i)->desty] != NULL) { addScore((*i)->value * 2); float32 xPos = ((float32)(*i)->destx - 2.0f); if(xPos >= 0) xPos++; xPos /= SOUND_DIV_FAC; playSound("jointile", m_fSoundVolume, xPos); if(m_highestTile == m_Board[(*i)->destx][(*i)->desty]) m_highestTile = NULL; rumbleController(0.2, 0.1); delete m_Board[(*i)->destx][(*i)->desty]; ostringstream oss; oss << "res/tiles/" << min((*i)->value * 2, MAX_TILE_VALUE) << ".xml"; //"Duh, muffins" is highest possible tile m_Board[(*i)->destx][(*i)->desty] = loadTile(oss.str()); m_Board[(*i)->destx][(*i)->desty]->drawSize.Set(TILE_WIDTH, TILE_HEIGHT); //Don't have a newly-created piece make an appear animation here if(!(m_highestTile) || m_highestTile->value < m_Board[(*i)->destx][(*i)->desty]->value) { m_highestTile = m_Board[(*i)->destx][(*i)->desty]; m_newHighTile->firing = true; if(m_highestTile->value == 2048) achievementGet("wutup"); else if(m_highestTile->value == 4096) achievementGet("ermahgerd"); } } } //Wipe this out (Step through list this way, rather than incrementing i) delete (*i); i = m_lSlideJoinAnimations.erase(i); } }
void Pony48Engine::placenew() { ostringstream oss; oss << "res/tiles/" << randInt(1,2) * 2 << ".xml"; if(movePossible()) //Make sure there aren't no blank spaces or something { while(true) //Could possibly hang here for a while { int x = randInt(0, BOARD_WIDTH-1); int y = randInt(0, BOARD_HEIGHT-1); if(m_Board[x][y] != NULL) continue; m_Board[x][y] = loadTile(oss.str()); break; } } }
void Tileset::load(const Common::ConfigFile &set) { const Common::ConfigDomain *general = set.getDomain("GENERAL"); if (!general) throw Common::Exception("Tileset has no \"GENERAL\" domain"); loadGeneral(*general); const Common::ConfigDomain *tiles = set.getDomain("TILES"); if (!general) throw Common::Exception("Tileset has no \"TILES\" domain"); _tiles.resize(tiles->getUint("Count")); for (uint i = 0; i < _tiles.size(); i++) loadTile(set, i, _tiles[i]); }
QPixmap ImageManager::getImage(const QString& host, const QString& url) { //qDebug() << "ImageManager::getImage"; QPixmap pm; if ( net->imageIsLoading(url) ) { //currently loading an image return loadingPixmap; } else if ( QPixmapCache::find( md5hex(url), &pm) ) { //image found in cache, use this version return pm; } else if ( doPersistentCaching ) //image disk-caching (persistent) enabled { if ( tileExist(url) && !tileCacheExpired(url) ) { loadTile(url,pm); QPixmapCache::insert(md5hex(url), pm); return pm; } else { //no file yet, go and request an image net->loadImage(host, url); } } //is image cached (memory) else if ( QPixmapCache::find(md5hex(url), &pm) && !pm.isNull() ) { //we had a valid copy cached in memory (not disk) so return this return pm; } else { //load from net, add empty image net->loadImage(host, url); } return emptyPixmap; }
void TileManager::initialize() { Logging::GRAPHICS->info("Loading Tiles"); DIR *pDIR; struct dirent *entry; if( pDIR=opendir("./Data/Tiles") ) { while(entry = readdir(pDIR)) { if( strcmp(entry->d_name, ".") != 0 && strcmp(entry->d_name, "..") != 0 ) { loadTile(string("./Data/Tiles/") + entry->d_name); } } closedir(pDIR); } Logging::GRAPHICS->info("Done Loading Tiles"); }
Map::Map(int stage) { _mapSize = 0; this->_stage = stage; loadInfo(); loadPretties(); loadAnimatedPretties(); loadTile(); loadMobs(); loadSignatureObjects(); // Concatenate all map object's reference to split into 4tree. vector<Object*> mapObjects; mapObjects.insert(mapObjects.end(), _pretties.begin(), _pretties.end()); _mapObjects = new QuadTree(new RECT(Default::createRECT(0, _mapSize, _mapSize, 0))); _mapObjects->assign(mapObjects); }
void Pony48Engine::resetBoard() { clearBoard(); //Start with 2 random tiles for(int start = 0; start < 2; start++) { while(true) { int x = randInt(0, BOARD_WIDTH-1); int y = randInt(0, BOARD_HEIGHT-1); if(m_Board[x][y] != NULL) continue; m_Board[x][y] = loadTile("res/tiles/2.xml"); break; } } m_iScore = 0; //Reset score also m_highestTile = NULL; m_fLastMovedSec = getSeconds(); m_bHasBoredVox = false; }
void BitmapData::load() { if (_loaded) { return; } Common::SeekableReadStream *data = g_resourceloader->openNewStreamFile(_fname.c_str()); uint32 tag = data->readUint32BE(); switch(tag) { case(MKTAG('B','M',' ',' ')): //Grim bitmap loadGrimBm(data); break; case(MKTAG('T','I','L','0')): // MI4 bitmap loadTile(data); break; default: if (!loadTGA(data)) // Try to load as TGA. Debug::error(Debug::Bitmaps, "Invalid magic loading bitmap"); break; } delete data; _loaded = true; }
void LevelThree::load(){ bool checkSave = Game::instance().getSaves().isSaved(Game::instance().currentSlot); int savedLevel = Game::instance().getSaves().getSavedLevel(Game::instance().currentSlot); // Changing the music. Game::instance().getAudioHandler().changeMusic("res/audio/lv3.wav"); // Loading the tile/tilemap. loadTile(); // Setting the level width/height. settingLevelBoundaries(); // Setting Instances. settingLevelInstances(); // Getting information from lua script. LuaScript luaLevel1("lua/Level1.lua"); const std::string pathPlayerSpriteSheet = luaLevel1.unlua_get<std::string>( "level.player.spriteSheet"); const std::string pathBackgroundAudio = luaLevel1.unlua_get<std::string>( "level.audio.background"); const std::string pathEnemy = luaLevel1.unlua_get<std::string>("level.enemy"); // Changing the music. // Game::instance().getAudioHandler().changeMusic(pathBackgroundAudio); // Loading the player and the camera. Player* lPlayer = nullptr; if(checkSave && savedLevel == 3){ double savedPX = 0.0; double savedPY = 0.0; Game::instance().getSaves().getPlayerPosition(savedPX, savedPY, Game::instance().currentSlot); lPlayer = new Player(savedPX, savedPY, pathPlayerSpriteSheet); } else{ lPlayer = new Player(this->tileMap->getInitialX(), this->tileMap->getInitialY(), pathPlayerSpriteSheet); } Camera* lCamera = new Camera(lPlayer); this->playerHud = new PlayerHUD(lPlayer); // Load all the enemies from the tileMap. loadEnemiesFromTileMap(); // Finally, setting the player and the camera. setPlayer(lPlayer); Enemy::pLife = this->player->life; setCamera(lCamera); Game::instance().getFade().fadeOut(0, 0.002); }
void Pony48Engine::updateBoard(float32 dt) { m_fArrowAdd += dt * ARROW_SPEED; if(m_fArrowAdd >= ARROW_RESET) m_fArrowAdd -= ARROW_RESET; //Check slide-and-join animations for(list<TilePiece*>::iterator i = m_lSlideJoinAnimations.begin(); i != m_lSlideJoinAnimations.end();) { if((*i)->drawSlide.y < 0) { (*i)->drawSlide.y += dt * PIECE_MOVE_SPEED; if((*i)->drawSlide.y > 0) (*i)->drawSlide.y = 0; } else if((*i)->drawSlide.y > 0) { (*i)->drawSlide.y -= dt * PIECE_MOVE_SPEED; if((*i)->drawSlide.y < 0) (*i)->drawSlide.y = 0; } if((*i)->drawSlide.x < 0) { (*i)->drawSlide.x += dt * PIECE_MOVE_SPEED; if((*i)->drawSlide.x > 0) (*i)->drawSlide.x = 0; } else if((*i)->drawSlide.x > 0) { (*i)->drawSlide.x -= dt * PIECE_MOVE_SPEED; if((*i)->drawSlide.x < 0) (*i)->drawSlide.x = 0; } if((*i)->drawSlide.x == 0 && (*i)->drawSlide.y == 0) { if((*i)->destx >= 0 && (*i)->desty >= 0) { //Hit the end; join with destination tile if(m_Board[(*i)->destx][(*i)->desty] != NULL) { addScore((*i)->value * 2); float32 xPos = ((float32)(*i)->destx - 2.0f); if(xPos >= 0) xPos++; xPos /= SOUND_DIV_FAC; playSound("jointile", m_fSoundVolume, xPos); if(m_highestTile == m_Board[(*i)->destx][(*i)->desty]) m_highestTile = NULL; rumbleController(0.2, 0.1); delete m_Board[(*i)->destx][(*i)->desty]; ostringstream oss; oss << "res/tiles/" << min((*i)->value * 2, MAX_TILE_VALUE) << ".xml"; //"Duh, muffins" is highest possible tile m_Board[(*i)->destx][(*i)->desty] = loadTile(oss.str()); m_Board[(*i)->destx][(*i)->desty]->drawSize.Set(TILE_WIDTH+0.001, TILE_HEIGHT+0.001); //Start bounce animation m_Board[(*i)->destx][(*i)->desty]->iAnimDir = 1; if(!(m_highestTile) || m_highestTile->value < m_Board[(*i)->destx][(*i)->desty]->value) { m_highestTile = m_Board[(*i)->destx][(*i)->desty]; m_newHighTile->firing = true; if(m_highestTile->value == 2048) achievementGet("wutup"); else if(m_highestTile->value == 4096) achievementGet("ermahgerd"); } } else errlog << "Err board[x][y] == NULL" << (*i)->destx << "," << (*i)->desty << endl; } else errlog << "Err destx/y < 0: " << (*i)->destx << "," << (*i)->desty << endl; delete (*i); i = m_lSlideJoinAnimations.erase(i); continue; } i++; } for(int i = 0; i < BOARD_HEIGHT; i++) { for(int j = 0; j < BOARD_WIDTH; j++) { if(m_Board[j][i] == NULL) continue; //Check sliding animations if(m_Board[j][i]->drawSlide.y < 0) { m_Board[j][i]->drawSlide.y += dt * PIECE_MOVE_SPEED; if(m_Board[j][i]->drawSlide.y > 0) m_Board[j][i]->drawSlide.y = 0; } if(m_Board[j][i]->drawSlide.y > 0) { m_Board[j][i]->drawSlide.y -= dt * PIECE_MOVE_SPEED; if(m_Board[j][i]->drawSlide.y < 0) m_Board[j][i]->drawSlide.y = 0; } if(m_Board[j][i]->drawSlide.x < 0) { m_Board[j][i]->drawSlide.x += dt * PIECE_MOVE_SPEED; if(m_Board[j][i]->drawSlide.x > 0) m_Board[j][i]->drawSlide.x = 0; } if(m_Board[j][i]->drawSlide.x > 0) { m_Board[j][i]->drawSlide.x -= dt * PIECE_MOVE_SPEED; if(m_Board[j][i]->drawSlide.x < 0) m_Board[j][i]->drawSlide.x = 0; } //Check appearing animations if(m_Board[j][i]->drawSize.x < TILE_WIDTH) { m_Board[j][i]->drawSize.x += PIECE_APPEAR_SPEED * dt; if(m_Board[j][i]->drawSize.x > TILE_WIDTH) m_Board[j][i]->drawSize.x = TILE_WIDTH; } else if(m_Board[j][i]->drawSize.x > TILE_WIDTH) //And bouncing animations { m_Board[j][i]->drawSize.x += m_Board[j][i]->iAnimDir * PIECE_BOUNCE_SPEED * dt; if(m_Board[j][i]->drawSize.x > PIECE_BOUNCE_SIZE) m_Board[j][i]->iAnimDir = -1; //Reverse animation direction else if(m_Board[j][i]->drawSize.x < TILE_WIDTH) m_Board[j][i]->drawSize.x = TILE_WIDTH; //This also stops bouncing } if(m_Board[j][i]->drawSize.y < TILE_HEIGHT) { m_Board[j][i]->drawSize.y += PIECE_APPEAR_SPEED * dt; if(m_Board[j][i]->drawSize.y > TILE_HEIGHT) m_Board[j][i]->drawSize.y = TILE_HEIGHT; } else if(m_Board[j][i]->drawSize.y > TILE_HEIGHT) { m_Board[j][i]->drawSize.y += m_Board[j][i]->iAnimDir * PIECE_BOUNCE_SPEED * dt; if(m_Board[j][i]->drawSize.y > PIECE_BOUNCE_SIZE) m_Board[j][i]->iAnimDir = -1; else if(m_Board[j][i]->drawSize.y < TILE_HEIGHT) m_Board[j][i]->drawSize.y = TILE_HEIGHT; } } } }
ossimRefPtr<ossimImageData> ossimKakaduJ2kReader::getTile( const ossimIrect& rect, ossim_uint32 resLevel) { // This tile source bypassed, or invalid res level, return a blank tile. if(!isSourceEnabled() || !isOpen() || !isValidRLevel(resLevel)) { return ossimRefPtr<ossimImageData>(); } if (theTile.valid()) { // Rectangle must be set prior to getOverviewTile call. theTile->setImageRectangle(rect); if (resLevel) { if ( getOverviewTile(resLevel, theTile.get() ) == false ) { theTile->makeBlank(); } } else { //--- // See if the whole tile is going to be filled, if not, start out with // a blank tile so data from a previous load gets wiped out. //--- if ( !rect.completely_within(theImageRect) ) { // Start with a blank tile. theTile->makeBlank(); } //--- // See if any point of the requested tile is in the image. //--- if ( rect.intersects(theImageRect) ) { ossimIrect clipRect = rect.clipToRect(theImageRect); ossimIrect exandedRect = clipRect; //--- // Shift the upper left corner of the "clip_rect" to the an even // j2k tile boundry. //--- exandedRect.stretchToTileBoundary(ossimIpt(theTileSizeX, theTileSizeY)); // Vertical tile loop. ossim_int32 y = exandedRect.ul().y; while (y < exandedRect.lr().y) { // Horizontal tile loop. ossim_int32 x = exandedRect.ul().x; while (x < exandedRect.lr().x) { if ( loadTileFromCache(x, y, clipRect) == false ) { if ( loadTile(x, y) ) { //--- // Note: Clip the cache tile to the image clipRect // since there are j2k tiles that go beyond the image // dimensions, i.e., edge tiles. //--- ossimIrect cr = theCacheTile->getImageRectangle(). clipToRect(clipRect); theTile->loadTile(theCacheTile->getBuf(), theCacheTile->getImageRectangle(), cr, OSSIM_BSQ); } } x += theTileSizeX; // Go to next tile. } y += theTileSizeY; // Go to next row of tiles. } // Set the tile status. theTile->validate(); } // matches: if ( rect.intersects(theImageRect) ) } // r0 block } // matches: if (theTile.valid()) return theTile; }