Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

251
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!