void Board::setSize(int x, int y) { if(x == x_tiles() && y == y_tiles()) return; if(field != 0) free(field); field = (int*)malloc(sizeof(int) * x * y); _x_tiles = x; _y_tiles = y; for(int i = 0; i < x; i++) for(int j = 0; j < y; j++) setField(i, j, EMPTY); loadTiles(); double scaler = 1.0; while(sizeHint().width() > kapp->desktop()->width() - 2*XBORDER || sizeHint().height() > kapp->desktop()->height() - 2*YBORDER) { scaler -= 0.2; loadTiles(scaler); } newGame(); emit changed(); emit sizeChange(); }
void Area::loadARE(const Aurora::GFF3Struct &are) { // Tag _tag = are.getString("Tag"); // Name _name = are.getString("Name"); if (!_name.empty() && (*--_name.end() == '\n')) _name.erase(--_name.end()); _displayName = createDisplayName(_name); // Tiles _width = are.getUint("Width"); _height = are.getUint("Height"); _tilesetName = are.getString("Tileset"); _tiles.resize(_width * _height); loadTiles(are.getList("Tile_List")); // Scripts readScripts(are); }
QGeoTileCache::QGeoTileCache(const QString &directory, QObject *parent) : QObject(parent), directory_(directory), minTextureUsage_(0), extraTextureUsage_(0) { qRegisterMetaType<QGeoTileSpec>(); qRegisterMetaType<QList<QGeoTileSpec> >(); qRegisterMetaType<QSet<QGeoTileSpec> >(); // We keep default values here so that they are in one place // rather than in each individual plugin (the plugins can // of course override them) if (directory_.isEmpty()) { QString dirname = QLatin1String(".tilecache"); QDir home = QDir::home(); if (!home.exists(dirname)) home.mkdir(dirname); directory_ = home.filePath(dirname); } // default values setMaxDiskUsage(20 * 1024 * 1024); setMaxMemoryUsage(3 * 1024 * 1024); setExtraTextureUsage(6 * 1024 * 1024); loadTiles(); }
int main() { int i = 0; int index = 0; int numResources = 0; char *resources; loadTiles(); loadResourceList(); while(1) { printf("\nIndex: "); scanf("%d", &index); resources = getResources(index); numResources = resources[0]; printf("Tile: %d\n", getTileType(index)); printf("Resources: "); printf("%d", resources[0]); for(i = 0; i < numResources; i++) { printf("%d", resources[i * 2 + 1] ); printf("%d", resources[(i * 2) + 2]); } } return 0; }
void imagesFromTiledBitmap(Graphics& graphics, const Bitmap& bmp, int tileWidth, int tileHeight, bool tileable, Container& appendTo) { std::vector<Gosu::Image> tiles = loadTiles(graphics, bmp, tileWidth, tileHeight, tileable); for (int i = 0, num = tiles.size(); i < num; ++i) appendTo.push_back(typename Container::value_type(new Gosu::Image(tiles[i]))); }
Board::Board(QWidget *parent) : QWidget(parent) { trying = FALSE; _solvable_flag = TRUE; // randomze setShuffle(DEFAULTSHUFFLE); clock_t t; struct tms dummy; t = times(&dummy); srandom((int)t); starttime = time((time_t *)0); for(int i = 0; i < 45; i++) pm_tile[i] = 0; setDelay(DEFAULTDELAY); _redo.setAutoDelete(TRUE); _undo.setAutoDelete(TRUE); loadTiles(1); field = 0; QPixmap bg((PICDIR + "/kshisen_bgnd.xpm").data()); setBackgroundPixmap(bg); connect(this, SIGNAL(fieldClicked(int, int)), this, SLOT(marked(int, int))); connect(this, SIGNAL(madeMove(int, int, int, int)), this, SLOT(slotMadeMove(int, int, int, int))); setShuffle(0); setSize(18, 8); highlighted_tile = -1; }
void TilesMap::resizeEvent(QResizeEvent *event) { m_width = width(); m_height = height(); calcTilesRect(); loadTiles(); }
void PanelButton::resizeEvent(QResizeEvent*) { loadTiles(); if (calculateIconSize()) { loadIcons(); } }
MapWidget::MapWidget(QWidget *parent) : QWidget(parent) { loadTiles(); setCenter(QPointF(0, 0)); installEventFilter(this); initializeFonts(); }
void TilesMap::setSource(QString source) { if (m_sources.contains(source)) { m_source = m_sources[source]; } else { m_source = m_sources["osm"]; } loadTiles(); }
/* Initialisation de l'affichage */ void init_affichage(map_t * m, SDL_Renderer ** s) { // Initialisation de la partie graphique // On ouvre une fenêtre représentant la carte : nombre de case * nombre de pixel par case //*s = openWindow(m->largeur * SIZE, m->hauteur * SIZE + HAUTEUR_INTERFACE); // Ouvre une fenêtre de largeur et hauteur pixels // ÉCran de SIZE*SIZE maxi *s = openWindow(m->largeur_affichage * SIZE, m->hauteur_affichage * SIZE + HAUTEUR_INTERFACE); // Ouvre une fenêtre de largeur et hauteur pixels loadTiles(*s); // Charge les tuiles (sprites carrés) qu'on va placer sur l'écran pour générer la carte init_sdlttf(); }
void PanelButton::setTile(const QString& tile, const QColor& color) { if (tile == m_tile && m_tileColor == color) { return; } m_tile = tile; m_tileColor = color; loadTiles(); update(); }
bool CLevel::loadGraal(CString& pFileName) { CPacket levelData; CString version; char* dataFile = getDataFile(pFileName.text()); if(!strlen(dataFile)) return false; if(!levelData.load(dataFile)) return false; fileName = pFileName; modTime = getFileModTime(dataFile); version = levelData.readChars(8); bool v0 = (version == "GR-V1.00"); bool v1 = (version == "GR-V1.01"); bool v2 = (version == "GR-V1.02"); bool v3 = (version == "GR-V1.03"); //printf("Loading map %s\n", pFileName.text()); //printf("Loading tiles..\n"); loadTiles(levelData, version); //printf("Loading links..\n"); loadLinks(levelData); //printf("Loading baddies..\n"); loadBaddies(levelData); if (v0 || v1 || v2 || v3) { //printf("Loading npcs..\n"); loadNpcs(levelData); } if (v1 || v2 || v3) { //printf("Loading chests..\n"); loadChests(levelData); } //printf("Loading signs..\n"); loadSigns(levelData); //Find our map id for(int i = 0; i < CMap::mapList.count(); i++) { CMap* m = (CMap*)CMap::mapList[i]; if((levelIndex = m->getLevelpos(pFileName)) >= 0) { map = m; break; } } return true; }
bool CLevel::loadZelda(CString& pFileName) { CPacket levelData; CString version; char* dataFile = getDataFile(pFileName.text()); if(!strlen(dataFile)) return false; if(!levelData.load(dataFile)) return false; fileName = pFileName; modTime = getFileModTime(dataFile); version = levelData.readChars(8); // Some clients will actually save .zelda levels as .graal. // If this is the case, parse it through the .graal loader. if (version.copy(0, 2) == "GR") return loadGraal(pFileName); bool v0 = (version == "unknown"); bool v1 = (version == "unknown"); bool v2 = (version == "unknown"); bool v3 = (version == "Z3-V1.03"); bool v4 = (version == "Z3-V1.04"); // If we encountered an unknown version, ask the user to send it in so we can add support for it. if (!v3 && !v4) { errorOut("errorlog.txt", CString() << "Level " << fileName << " is of version " << version << ". That version is unknown. Please send us the level so we may add support for it.", true); return false; } loadTiles(levelData, version); loadLinks(levelData); loadBaddies(levelData); loadSigns(levelData); //Find our map id for(int i = 0; i < CMap::mapList.count(); i++) { CMap* m = (CMap*)CMap::mapList[i]; if((levelIndex = m->getLevelpos(pFileName)) >= 0) { map = m; break; } } return true; }
Maze::Maze(const TextureHolder& textures, const sf::Vector2u& mazeSize) : mazeSize_(mazeSize), tileMap_(textures.resource(TextureId::Tiles)), mazeTexture_(), hitBox_(), contactNormals_(3), mazeMap_(), tileTextureById_(), tileHitBoxesById_(), wallCommand_() { assert(tileSize > wallSize); mazeMap_.resize(mazeSize_.y); for(std::size_t i = 0; i < mazeSize_.y; ++i) mazeMap_[i].resize(mazeSize_.x); mazeTexture_.setPrimitiveType(sf::Triangles); mazeTexture_.resize(mazeSize_.x * mazeSize_.y* 6); //It needs 2 triangles to make a quad which makes 6 vertices. loadTiles(); loadMaze(); }
QGeoTileCache::QGeoTileCache(const QString &directory, QObject *parent) : QObject(parent), directory_(directory), minTextureUsage_(0), extraTextureUsage_(0) { qRegisterMetaType<QGeoTileSpec>(); qRegisterMetaType<QList<QGeoTileSpec> >(); qRegisterMetaType<QSet<QGeoTileSpec> >(); // We keep default values here so that they are in one place // rather than in each individual plugin (the plugins can // of course override them) const QString basePath = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation) + QLatin1String("/QtLocation"); // delete old tiles from QtLocation 5.4 or prior // TODO Remove cache cleanup in Qt 6 QDir baseDir(basePath); if (baseDir.exists()) { const QStringList oldCacheFiles = baseDir.entryList(QDir::Files); foreach (const QString& file, oldCacheFiles) baseDir.remove(file); } if (directory_.isEmpty()) { directory_ = basePath; qWarning() << "Plugin uses uninitialized directory for QGeoTileCache" " which will was deleted during startup"; } QDir::root().mkpath(directory_); // default values setMaxDiskUsage(20 * 1024 * 1024); setMaxMemoryUsage(3 * 1024 * 1024); setExtraTextureUsage(6 * 1024 * 1024); loadTiles(); }
bool CLevel::loadGraal(CString& pFileName) { CPacket levelData; CString version; char* dataFile = getDataFile(pFileName.text()); if(!strlen(dataFile)) return false; if(!levelData.load(dataFile)) return false; fileName = pFileName; modTime = getFileModTime(dataFile); version = levelData.readChars(8); bool v0 = (version == "GR-V1.00"); bool v1 = (version == "GR-V1.01"); bool v2 = (version == "GR-V1.02"); bool v3 = (version == "GR-V1.03"); //printf("Loading map %s\n", pFileName.text()); //printf("Loading tiles..\n"); loadTiles(levelData, version); //printf("Loading links..\n"); loadLinks(levelData); //printf("Loading baddies..\n"); loadBaddies(levelData); if (v0 || v1 || v2 || v3) { //printf("Loading npcs..\n"); loadNpcs(levelData); } if (v1 || v2 || v3) { //printf("Loading chests..\n"); loadChests(levelData); } //printf("Loading signs..\n"); loadSigns(levelData); return true; }
void LoadedMap::loadTileset(XMLElement *element) { Logger.logMessage(LOG_STATE, LOG_MAP, "LoadedMap::loadTileset\n"); assert(element); TileSet tileset; tileset.name = element->Attribute(XML_TILESET_NAME.c_str()); stringstream tilewidth (element->Attribute(XML_TILESET_WIDTH.c_str())); stringstream tileheight (element->Attribute(XML_TILESET_HEIGHT.c_str())); stringstream spacing (element->Attribute(XML_TILESET_SPACING.c_str())); stringstream margin (element->Attribute(XML_TILESET_MARGIN.c_str())); tilewidth >> tileset.tilewidth; tileheight >> tileset.tileheight; spacing >> tileset.spacing; margin >> tileset.margin; XMLElement *image = element->FirstChildElement(XML_IMAGE.c_str()); assert(image); loadImageSource(image, &tileset); XMLElement *terrains = element->FirstChildElement(XML_TERRAINTYPE.c_str()); assert(terrains); loadTerrains(terrains, &tileset); XMLElement *first_tile = element->FirstChildElement(XML_TILE.c_str()); assert(first_tile); //NOTE: MUST push first because we reference afterwards (terrain //pointers) m_tilesets.push_back(tileset); loadTiles(first_tile, &m_tilesets.back()); Logger.logMessage(LOG_STATE, LOG_MAP, "LoadedMap::loadTileset end\n"); }
void editLevelScreen() { int currentType = TILE_RED; showType(currentType); Tile *tiles[TOTAL_TILES]; if(loadTiles(tiles) == false) { cleanUp(); exit(0); } while(true) { fps.start(); while(SDL_PollEvent(&event)) { //When the user clicks if( event.type == SDL_MOUSEBUTTONDOWN ) { //Put the tile putTile( tiles, currentType ); } if (event.type == SDL_KEYDOWN) { switch(event.key.keysym.sym) { case SDLK_1: case SDLK_q: { //Scroll forward through tiles currentType--; if( currentType < TILE_RED ) currentType = TILE_TOPLEFT; //Show the current tile type showType( currentType ); break; } case SDLK_2: case SDLK_w: { //Scroll backward through tiles currentType++; if( currentType > TILE_TOPLEFT ) currentType = TILE_RED; //Show the current tile type showType( currentType ); break; } case SDLK_s: { // save the tiles and display a "saved" message saveTiles(tiles); SDL_Color savedMessageColor = {255, 255, 255}; SDL_Surface* savedMessage = NULL; savedMessage = load_font("eva.ttf", "SAVED", savedMessageColor, 24); apply_surface(1, 1, savedMessage, screen); SDL_Delay(500); SDL_FreeSurface(savedMessage); break; } case SDLK_BACKSPACE: { deleteTiles(tiles); startScreen(); break; } default:; } } myWindow.handle_window(); handleMusic(); if( event.type == SDL_QUIT ) { //Quit the program deleteTiles(tiles); cleanUp(); exit(0); } } if (myWindow.error()) { cleanUp(); exit(0); } setEditorCamera(); for (int t = 0; t < TOTAL_TILES; t++) tiles[t]->show(); if (SDL_Flip(screen) == -1) { cleanUp(); exit(0); } //Cap the frame rate if( fps.get_ticks() < 1000 / FRAMES_PER_SECOND ) { SDL_Delay( ( 1000 / FRAMES_PER_SECOND ) - fps.get_ticks() ); } } }
Tiles() { loadTiles("tiles.txt"); }
//----------------------------------------------------------------------------- int SDL_main(int argc, char *argv[]) { // NOTE: check for the correct number of arguements if(argc<2) { fprintf(stderr, "Error: need a level name.\n"); return -1; } // NOTE: add the sqlite db to the levels directory char filename[0xFF]; sprintf(filename, "levels/%s.db", argv[1]); // NOTE: open database connection if(sqlite3_open_v2(filename, &db, SQLITE_OPEN_READONLY, NULL)) { fprintf(stderr, "sqlite3_open: %s\n", sqlite3_errmsg(db)); sqlite3_close(db); return -1; } /* === */ start(); /* === */ int wallSprite00Inds[2*3] = { 03, 04, 35, 36, 67, 68 }; SDL_Color wall00Color = {0xFF,0xFF,0xFF,0xFF}; SDL_Surface *wallSprite00 = buildSprite(2, 3, wall00Color, wallSprite00Inds); int floorSprite00Inds[2*3] = { 17, 18, 49, 50, 81, 82 }; SDL_Color floorSprite00Color = {0x33,0x33,0x33,0xFF}; SDL_Surface *floorSprite00 = buildSprite(2, 3, floorSprite00Color, floorSprite00Inds); int doorSprite00Inds[2*3] = { 29, 30, 61, 62, 93, 94 }; SDL_Color doorSprite00Color = {0xFF,0xFF,0xFF,0xFF}; SDL_Surface *doorSprite00 = buildSprite(2, 3, doorSprite00Color, doorSprite00Inds); int wallSprite01Inds[2*3] = { 97, 98, 129, 130, 161, 162 }; SDL_Color wall01Color = {0xFF,0xFF,0xFF,0xFF}; SDL_Surface *wallSprite01 = buildSprite(2, 3, wall01Color, wallSprite01Inds); int wallSprite02Inds[2*3] = { 105, 106, 137, 138, 169, 170 }; SDL_Color wallSprite02Color = {0xFF,0xFF,0xFF,0xFF}; SDL_Surface *wallSprite02 = buildSprite(2, 3, wallSprite02Color, wallSprite02Inds); /* === */ while(running) { /* === */ pollInput(); SDL_RenderClear(renderer); SDL_FillRect(screen, 0, 0x00); /* === */ loadTiles(); SDL_Rect tempRect = { 0, 0, SPRITE_W*2, SPRITE_H*3 }; int i, j; for(j=0; j<12; j++) { for(i=0; i<30; i++) { tempRect.x = SPRITE_W*2*i; tempRect.y = SPRITE_H*3*j; switch(lvl.tiles[j][i]) { case 0x01: { SDL_BlitSurface(wallSprite00, NULL, screen, &tempRect); } break; case 0x02: { SDL_BlitSurface(doorSprite00, NULL, screen, &tempRect); } break; case 0x03: { SDL_BlitSurface(wallSprite01, NULL, screen, &tempRect); } break; case 0x04: { SDL_BlitSurface(wallSprite02, NULL, screen, &tempRect); } break; default: { SDL_BlitSurface(floorSprite00, NULL, screen, &tempRect); } break; } } } /* === */ int pitch; void *pixels; // NOTE: get the pixels for the screen texture SDL_LockTexture(texture, NULL, &pixels, &pitch); // NOTE: set the pixels for the screen texture SDL_ConvertPixels( screen->w, screen->h, screen->format->format, screen->pixels, screen->pitch, SDL_PIXELFORMAT_RGBA8888, pixels, pitch ); // NOTE: lock the texture so that it may be presented SDL_UnlockTexture(texture); // NOTE: present the texture SDL_RenderCopy(renderer, texture, NULL, NULL); SDL_RenderPresent(renderer); SDL_Delay(10); /* === */ } /* === */ SDL_FreeSurface(wallSprite00); wallSprite00 = NULL; SDL_FreeSurface(floorSprite00); floorSprite00 = NULL; SDL_FreeSurface(doorSprite00); doorSprite00 = NULL; SDL_FreeSurface(wallSprite01); wallSprite01 = NULL; SDL_FreeSurface(wallSprite02); wallSprite02 = NULL; /* === */ quit(); /* === */ // NTOE: close the database connection sqlite3_close(db); db = NULL; fclose(stderr); return 0; }
int loadMap() { return loadTiles() && loadResourceList(); }
void Area::loadTileModels() { loadTileset(); loadTiles(); }
void TilesMap::setOnline(bool online) { m_online = online; loadTiles(); }
std::vector<Gosu::Image> Gosu::loadTiles(Graphics& graphics, const std::wstring& filename, int tileWidth, int tileHeight, bool tileable) { Bitmap bmp; loadImageFile(bmp, filename); return loadTiles(graphics, bmp, tileWidth, tileHeight, tileable); }