Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

244
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda