GithubHelp home page GithubHelp logo

stp's Introduction

What is STP?

Build Status

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.

Features

  • Low memory usage.
  • Supports all the encoding and compression formats.
  • Support for orthogonal, isometric and staggered maps.

Usage

STP is easy to use; here is some example code.

#include "SFML/Graphics.hpp"
#include "STP/TMXLoader.hpp"

int main()
{
    sf::RenderWindow window(sf::VideoMode(360, 280), "STP Example");
    tmx::TileMap map("path/to/my/file/map.tmx");

    map.ShowObjects(); // Display all the layer objects.
    
    map.GetLayer("World").visible = false; // Hide a Layer named World

    // Start the game loop
    while (window.isOpen()) {
        // Process events
        sf::Event event;
        while (window.pollEvent(event)) {
            // Close window : exit
            if (event.type == sf::Event::Closed)
                window.close();
        }
        // Clear screen
        window.clear();
        // Draw the map
        window.draw(map);
        // Update the window
        window.display();
    }

    return EXIT_SUCCESS;
}

stp's People

Contributors

edoren avatar caerind avatar cesarizu avatar autonopey avatar

Stargazers

Raman Verma avatar Mence avatar  avatar Iván Ayala avatar Jussi Räsänen avatar  avatar Thomas Bécavin avatar Emre Kovanci avatar  avatar Sébastien Maes avatar Dan Shelley avatar sindney avatar Émilie avatar Mohab Abd El-Dayem avatar Hail_Polaris avatar Pawel Mstowski avatar Shailesh Kadam avatar Nikos Batsaras avatar Gonzalo Nicolás Cifaldi Ruano avatar Emerson MX avatar Randy Schütt avatar Kamil Jakubus avatar AJ Weeks avatar Adrian Grigo avatar Richèl Bilderbeek avatar René Mujica Moreau avatar Patryk Szczygło avatar Kazin avatar Wilfried Le Cor avatar  avatar

Watchers

James Cloos avatar  avatar Kazin avatar KRaV avatar Artur Leonov (Depish) avatar Shailesh Kadam avatar

stp's Issues

getlayer function

i use windows 7, visual studio 2015 and sfml 2.3.2.
if i add this line map.GetLayer("World").visible = false; t

he program gives error that "has stopped working"

How to use this in Ubuntu?

Hi, I am using Ubuntu 14.04 and Code::Blocks.
I am unsure how to include this library in my code.
Can you add some more information to the Wiki?
I have added

include "include/STP/TMXLoader.hpp"

and made a directory called STP containing the TMXLoader. (in my include dir)
and the Core folder.... but I am missing something. I have only used libraries available on the system (SFML, Box2D, tinyxml, etc...) through the repositories up to this point.

So... the first thing that needs clarification is needing this compiler flag
-std=c++11
I'm using GNU C++ compiler, and it tells me I need this.

Then, I get this error:
/usr/bin/ld: obj/Debug/src/STP/Core/Parser.o||undefined reference to symbol 'inflateInit2_'|

Not sure quite what I am missing here, but I'd like to try your library out :)

STP crashes the app with std::bad_alloc

Hi,

I was writing some testing code with STP and SFML 2.1. Basically, I was just loading a TMX file as the tutorial teaches and I got this:

terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
Aborted (core dumped)

Process returned 134 (0x86) execution time : 0.703 s
Press ENTER to continue.

After insisting for a few times, it was able to crash the entire OS (in this case Ubuntu Linux 14.04).

Any clues? Let me know if I can provide further info.

Cmake error - finding SFML directories

Whenever I run cmake on the cmakelists.txt, everything works fine until I get down to finding SFML. I set the SFML_INCLUDE_DIR variable to <sfml root>/include through the GUI, and always get the following error:

Could NOT find SFML (missing:  SFML_GRAPHICS_LIBRARY SFML_WINDOW_LIBRARY SFML_SYSTEM_LIBRARY)

-> SFML directory not found. Put the SFML's top-level path (containing "include" and "lib" directories) in the /extlibs folder.

Not sure how to add the path to the /extlibs folder, and I'm assuming that's where my problems are from

Sorry if I opened up an old repo.

thanks

const

Many functions can be implemented as const version.

Orthogonal map example from Tiled does not get recognized

When I use the STP example code on an orthogonal map that is an example from Tiled, STP does not recognize it:

Error loading the XML document.
The document is not a valid TMX file.

I use this example map from Tiled.

Here is the STP example code, that I point to a correct file (STP correctly detects if the file is absent):

#include "SFML/Graphics.hpp"
#include "STP/TMXLoader.hpp"

int main()
{
  sf::RenderWindow window(sf::VideoMode(360, 280), "STP Example");
  tmx::TileMap map("~/GitHubs/tiled/examples/orthogonal-outside.tmx"); //Modified by me

  map.ShowObjects(); // Display all the layer objects.

  map.GetLayer("World").visible = false; // Hide a Layer named World

  // Start the game loop
  while (window.isOpen()) {
      // Process events
      sf::Event event;
      while (window.pollEvent(event)) {
          // Close window : exit
          if (event.type == sf::Event::Closed)
              window.close();
      }
      // Clear screen
      window.clear();
      // Draw the map
      window.draw(map);
      // Update the window
      window.display();
  }

  return EXIT_SUCCESS;
}

I am willing to help out, I just need a little push to get started.

Isometric objects are not rendered correctly

Awesome library! And simple! I wanted to let you know isometric objects are not drawn correctly. This may be frustrating for devs who want to render debug object layers. Since you have access to the vertices in STP, applying the isometric projection for the corners should be trivial.

Untitled2

As you can see the "exit" objects would be correct if they were on an orthogonal map.

Not all maps load correctly with newer libs

I'm unsure why this is because I am using the same assets from your example directory. I see this lib is a little old, but it still works!

I am:

  • using zlib:x64-windows (version 1.2.11-6)
  • using pugixml:x64-windows (version 1.10-1)
  • using sfml:x64-windows (version 2.5.1-7)

Each of these was installed with vcpkg. I want to also note that I had to manually change the linker settings to use -d debug sfml libs for DEBUG builds and that vcpkg paths were not automatically added to the project even though the packages were found correctly using cmake's find_package().

Untitled

specifically some tiles are swapped around and for whatever reason the bushes on the left side of the screen are missing.

Also, you want to document I MUST use zlib compression if I use any compression. I made some custom maps and was unsure why it was crashing. There doesn't seem to be a check for that. Once I stepped in the code and made that change in my .tmx maps, they loaded!

Segfault when GetLayer("nonexistant layer")

When using GetLayer, it would be quite useful to have some way to detect if the layer doesn't exist; currently, it returns some unallocated memory and causes a segfault.

Documentation?

Where can I find/create documentation for this library? Doxygen fails with
Error: tag HTML_HEADER: header file '@DOXYGEN_INPUT_DIR@/doc/header.html' does not exist

-DSFML_ROOT is overriden in extlibs

I'm using -DSFML_ROOT to point my dependancies (STP included) at my unusual SFML install location.
Adding cache to either SFML_DIR or SFML_ROOT allows the user (via cmake-gui, or with arguments) to override the default.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.