Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

246
Visualizações
Read and use data from js file in C++

I have a C++ game project using SDL. Besides, I have a .js file for the tiled map (I attach a pastebin link for more detailed: https://pastebin.com/GKqs3km5). How can I use this to create map in my project? I try ifstream to read this file but it seems doesn't right.

//from lesson 39 Lazyfoo
for (int i = 0; i < TOTAL_TILES; ++i)
        {
            //Determines what kind of tile will be made
            int tileType = -1;

            //Read tile from file
            js >> tileType;

            //If the was a problem in reading the map
            if (js.fail())
            {
                //Stop loading map
                printf("Error loading map: Unexpected end of file!\n");
                tilesLoaded = false;
                break;
            }

            //If the number is a valid tile number
            if ((tileType >= 0) && (tileType < TOTAL_TILE_SPRITES))
            {
                tiles[i] = new Tile(x, y, tileType);
            }
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Ditch the .js format. It was exported from Tiled, so open it in Tiled and re-export as JSON (or XML). Then use any JSON (or XML) parsing library.

There are probably specialized libraries for parsing the JSON/XML tiled maps, but since the format is so simple, you might as well use a generic library.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda