Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: The most popular Tiled maps parser for SFML, STP, is bugged  (Read 6775 times)

0 Members and 1 Guest are viewing this topic.

gmestanley

  • Newbie
  • *
  • Posts: 7
    • View Profile
The most popular Tiled maps parser for SFML, STP, is bugged
« on: February 21, 2017, 02:16:54 am »
As I've described in my first topic, I'm making a game using the original SFML, and to create maps for my game I'm using Tiled (if you don't know what it is, it's a program where you can build maps and save then as files). And to pass these maps to a SFML window, I need a Tiled map parser. I was using STP, until the point I tried compiling my game and MinGW gave me this extensive error log:
In file included from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\unordered_map:35:0,
                 from D:\Desktop\STP-master\include/STP/Core/TileMap.hpp:36,
                 from D:\Desktop\STP-master\include/STP/TMXLoader.hpp:30,
                 from game.cpp:4:
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
 #error This file requires compiler and library support for the \
  ^
In file included from D:\Desktop\STP-master\include/STP/Core/TileMap.hpp:39:0,
                 from D:\Desktop\STP-master\include/STP/TMXLoader.hpp:30,
                 from game.cpp:4:
D:\Desktop\STP-master\include/STP/Core/Properties.hpp:73:10: error: 'unordered_map' in namespace 'std' does not name a template type
     std::unordered_map<std::string, std::string> properties_;
          ^
In file included from D:\Desktop\STP-master\include/STP/Core/TileSet.hpp:40:0,
                 from D:\Desktop\STP-master\include/STP/Core/TileMap.hpp:40,
                 from D:\Desktop\STP-master\include/STP/TMXLoader.hpp:30,
                 from game.cpp:4:
D:\Desktop\STP-master\include/STP/Core/Image.hpp:66:11: error: 'int32_t' has not been declared
           int32_t trans = -1, const std::string& format = std::string());
           ^
D:\Desktop\STP-master\include/STP/Core/Image.hpp:95:5: error: 'int32_t' does not name a type
     int32_t trans_;
     ^
In file included from D:\Desktop\STP-master\include/STP/Core/TileMap.hpp:40:0,
                 from D:\Desktop\STP-master\include/STP/TMXLoader.hpp:30,
                 from game.cpp:4:
D:\Desktop\STP-master\include/STP/Core/TileSet.hpp:77:69: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
             unsigned int margin = 0, sf::Vector2i tileoffset = {0, 0});
                                                                     ^
In file included from D:\Desktop\STP-master\include/STP/Core/TileMap.hpp:41:0,
                 from D:\Desktop\STP-master\include/STP/TMXLoader.hpp:30,
                 from game.cpp:4:
D:\Desktop\STP-master\include/STP/Core/Layer.hpp:131:80: error: 'nullptr' was not declared in this scope
  void AddTile(unsigned int gid, sf::IntRect tile_rect, tmx::TileSet* tileset = nullptr);
                                                                                ^
D:\Desktop\STP-master\include/STP/Core/Layer.hpp:161:31: error: 'nullptr' was not declared in this scope
       tmx::TileSet* tileset = nullptr);
                               ^
In file included from D:\Desktop\STP-master\include/STP/Core/TileMap.hpp:42:0,
                 from D:\Desktop\STP-master\include/STP/TMXLoader.hpp:30,
                 from game.cpp:4:
D:\Desktop\STP-master\include/STP/Core/ObjectGroup.hpp:76:46: error: 'int32_t' has not been declared
                 float opacity, bool visible, int32_t hexcolor = -1);
                                              ^
D:\Desktop\STP-master\include/STP/Core/ObjectGroup.hpp:141:39: error: 'nullptr' was not declared in this scope
            tmx::TileSet::Tile* tile = nullptr);
                                       ^
In file included from D:\Desktop\STP-master\include/STP/TMXLoader.hpp:30:0,
                 from game.cpp:4:
D:\Desktop\STP-master\include/STP/Core/TileMap.hpp:62:37: warning: defaulted and deleted functions only available with -std=c++11 or -std=gnu++11
     TileMap(const TileMap& other) = delete;
                                     ^
D:\Desktop\STP-master\include/STP/Core/TileMap.hpp:63:43: warning: defaulted and deleted functions only available with -std=c++11 or -std=gnu++11
     TileMap& operator =(const TileMap&) = delete;
                                           ^
D:\Desktop\STP-master\include/STP/Core/TileMap.hpp:182:10: error: 'unordered_map' in namespace 'std' does not name a template type
     std::unordered_map<std::string, tmx::Layer*> layers_;
          ^
D:\Desktop\STP-master\include/STP/Core/TileMap.hpp:183:10: error: 'unordered_map' in namespace 'std' does not name a template type
     std::unordered_map<std::string, tmx::ObjectGroup*> object_groups_;
          ^
D:\Desktop\STP-master\include/STP/Core/TileMap.hpp:184:10: error: 'unordered_map' in namespace 'std' does not name a template type
     std::unordered_map<std::string, tmx::ImageLayer*> image_layers_;
          ^
D:\Desktop\STP-master\include/STP/Core/TileMap.hpp:185:17: error: 'unique_ptr' is not a member of 'std'
     std::vector<std::unique_ptr<tmx::MapObject>> map_objects_;
                 ^
D:\Desktop\STP-master\include/STP/Core/TileMap.hpp:185:17: error: 'unique_ptr' is not a member of 'std'
D:\Desktop\STP-master\include/STP/Core/TileMap.hpp:185:50: error: 'map_objects_' was not declared in this scope
     std::vector<std::unique_ptr<tmx::MapObject>> map_objects_;
                                                  ^
D:\Desktop\STP-master\include/STP/Core/TileMap.hpp:185:50: error: template argument 1 is invalid
D:\Desktop\STP-master\include/STP/Core/TileMap.hpp:185:50: error: template argument 2 is invalid
D:\Desktop\STP-master\include/STP/Core/TileMap.hpp:187:10: error: 'unordered_map' in namespace 'std' does not name a template type
     std::unordered_map<std::string, tmx::TileSet*> tilesets_hash_;
          ^
D:\Desktop\STP-master\include/STP/Core/TileMap.hpp:188:17: error: 'unique_ptr' is not a member of 'std'
     std::vector<std::unique_ptr<tmx::TileSet>> tilesets_;
                 ^
D:\Desktop\STP-master\include/STP/Core/TileMap.hpp:188:17: error: 'unique_ptr' is not a member of 'std'
D:\Desktop\STP-master\include/STP/Core/TileMap.hpp:188:48: error: 'tilesets_' was not declared in this scope
     std::vector<std::unique_ptr<tmx::TileSet>> tilesets_;
                                                ^
D:\Desktop\STP-master\include/STP/Core/TileMap.hpp:188:48: error: template argument 1 is invalid
D:\Desktop\STP-master\include/STP/Core/TileMap.hpp:188:48: error: template argument 2 is invalid

D:\Desktop\Elkiria>

My game's source code is the following:
// game.cpp - the main file
#include <Windows.h>
#include <SFML/Graphics.hpp>
#include <STP/TMXLoader.hpp>

int main()
{
    // Setting up window and resources
    sf::RenderWindow screen(sf::VideoMode(640, 480), "Elkiria");
    sf::Texture tex_titlebg;
    tex_titlebg.loadFromFile("bg_title.jpg");
    sf::Sprite spr_titlebg;
    spr_titlebg.setTexture(tex_titlebg);
    sf::Texture tex_tcursor;
    tex_tcursor.loadFromFile("spr_cursor.png");
    sf::Sprite spr_tcursor;
    spr_tcursor.setTexture(tex_tcursor);

    sf::Font fon_comicsans;
    fon_comicsans.loadFromFile("comic.ttf");
    sf::Text txt_tnewgame;
    txt_tnewgame.setFont(fon_comicsans);
    txt_tnewgame.setString("New Game");
    sf::Text txt_tcontinue;
    txt_tcontinue.setFont(fon_comicsans);
    txt_tcontinue.setString("Continue");
    sf::Text txt_texit;
    txt_texit.setFont(fon_comicsans);
    txt_texit.setString("Exit");

    int cursor = 0;
    int map;
    bool game_started = false;

    // While window is open, do stuff
    while (screen.isOpen())
    {
        // Operations with events
        sf::Event event;
        while (screen.pollEvent(event)) {
            if (event.type == sf::Event::Closed) {
                screen.close();
            }
            if (event.type == sf::Event::KeyPressed) {
                if (event.key.code == sf::Keyboard::Up) {
                    if (cursor == 0) {
                        break;
                    }
                    else {
                        cursor -= 1;
                    }
                }
                if (event.key.code == sf::Keyboard::Down) {
                    if (cursor == 2) {
                        break;
                    }
                    else {
                        cursor += 1;
                    }
                }
                if (event.key.code == sf::Keyboard::Z || event.key.code == sf::Keyboard::Return) {
                    if (cursor == 0) {
                        game_started = true;
                        map = 1;
                    }
                    else if (cursor == 1) {

                    }
                    else if (cursor == 2) {
                        ExitProcess(0);
                    }
                }
            }
        }

        // Operations with the window
        screen.clear(sf::Color::Black);
        screen.draw(spr_titlebg);
        screen.draw(txt_tnewgame);
        txt_tnewgame.setPosition(240, 300);
        screen.draw(txt_tcontinue);
        txt_tcontinue.setPosition(240, 340);
        screen.draw(txt_texit);
        txt_texit.setPosition(240, 380);
        screen.draw(spr_tcursor);
        screen.display();

        // If the game has started, the first map is drawn.
        if (game_started == true) {
            if (map == 1) {
                screen.clear(sf::Color::Black);
                tmx::TileMap map1("map1.tmx");
                map1.ShowObjects();
                screen.draw(map1);
                screen.display();
            }
        }

        // If not, the title screen remains and the arrow keys move the cursor.
        else if (game_started == false) {
            switch (cursor) {
            case 0:
                spr_tcursor.setPosition(200, 300);
                break;
            case 1:
                spr_tcursor.setPosition(200, 340);
                break;
            case 2:
                spr_tcursor.setPosition(200, 380);
                break;
            }
        }
    }

    // Source code ends here.
    return 0;
}

I even have put the SFML include and lib folders into STP's extlibs folder:


What am I doing wrong? Please, someone help me.
« Last Edit: February 21, 2017, 06:33:18 pm by gmestanley »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
The most popular Tiled maps parser for SFML, STP, is bugged
« Reply #1 on: February 21, 2017, 02:31:30 am »
And STP is...?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

gmestanley

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: The most popular Tiled maps parser for SFML, STP, is bugged
« Reply #2 on: February 21, 2017, 06:35:11 pm »
And STP is...?
I wonder if you're actually questioning what it is or this question is ironic and you made it because the topic shows what is STP twice.

Rosme

  • Full Member
  • ***
  • Posts: 169
  • Proud member of the shoe club
    • View Profile
    • Code-Concept
Re: The most popular Tiled maps parser for SFML, STP, is bugged
« Reply #3 on: February 21, 2017, 06:44:21 pm »
I'd say it is more or less a serious question. Because to be honest, I have never heard about it. I had to google. Also, it is not bugged. From the errors, it seems you are not using a C++11 Compiler or you may have just forgotten to set up the C++11 flag. And from the readme, it is written that you must have a C++11 compiler. Did you forget that part?
GitHub
Code Concept
Twitter
Rosme on IRC/Discord

gmestanley

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: The most popular Tiled maps parser for SFML, STP, is bugged
« Reply #4 on: February 21, 2017, 06:52:21 pm »
I'd say it is more or less a serious question. Because to be honest, I have never heard about it. I had to google. Also, it is not bugged. From the errors, it seems you are not using a C++11 Compiler or you may have just forgotten to set up the C++11 flag. And from the readme, it is written that you must have a C++11 compiler. Did you forget that part?
Hmmm, that would be nearly impossible. Because the MinGW version I have here is the most recent.
Also, I've only saw now that there is a forum for Tiled, so when I discover why the C++11 error is appearing even though I have the most recent MinGW, please someone lock this topic.

Rosme

  • Full Member
  • ***
  • Posts: 169
  • Proud member of the shoe club
    • View Profile
    • Code-Concept
Re: The most popular Tiled maps parser for SFML, STP, is bugged
« Reply #5 on: February 21, 2017, 07:11:12 pm »
I'll still answer though. Even if you have the most recent compiler, unless you specify the C++11 flag, it won't compile with C++11 features.
GitHub
Code Concept
Twitter
Rosme on IRC/Discord

gmestanley

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: The most popular Tiled maps parser for SFML, STP, is bugged
« Reply #6 on: February 21, 2017, 08:40:06 pm »
Oh...now I understand what I have to do.

ratzlaff

  • Newbie
  • *
  • Posts: 33
    • View Profile
Re: The most popular Tiled maps parser for SFML, STP, is bugged
« Reply #7 on: February 21, 2017, 09:44:27 pm »
So... what is STP? I have never heard of it either.

jamesL

  • Full Member
  • ***
  • Posts: 124
    • View Profile
Re: The most popular Tiled maps parser for SFML, STP, is bugged
« Reply #8 on: February 28, 2017, 10:48:14 am »
he must be referring to

https://github.com/edoren/STP

"STP is an extension library for SFML2 designed to read the Tiled map format. It uses the new C++11 standard features, so be sure to have a C++11 compatible compiler like g++ 4.7, clang 3.3 or Visual Studio 2013 compiler."

but I've never heard of it either

I don't know why he thinks its the most popular