Git Product home page Git Product logo

Comments (4)

SomeGuyDoinWork avatar SomeGuyDoinWork commented on May 29, 2024 1

Yeah a way to get all tagged/typed int grid tiles would be fantastic.

from ldtkloader.

Madour avatar Madour commented on May 29, 2024

To get the int grid values, you can use the getIntGridValue method of a Layer. It will return an IntGridValue that contains the value, name and color.

To get the tiles rendered in an Autolayer, you can use the allTiles and getTile methods of a Layer. These methods return Tile instances that are created using the "autoLayerTiles" data from the ldtk file. You can look at the SFML or SDL examples, they both use layer.allTiles() to iterate on the tiles in an Autolayer to render the tiles.

This made me realize the wiki page for the ldtk::Tile class is missing. I will create it soon.

from ldtkloader.

SomeGuyDoinWork avatar SomeGuyDoinWork commented on May 29, 2024

Thanks. But is there any way to get a list of tiles with their int grid id specifically? For example, if i wanted to mark those tiles as impassible, for creating collision boxes, or if i wanted to mark specific terrain types, etc. Maybe a key value pair of position, intgridvalue?

Something like: map<vec2, intgrid> ?

from ldtkloader.

Madour avatar Madour commented on May 29, 2024

Okay, so if I understand correctly, you would like a way to get all tiles that have a specific intgrid value ?

An API like this:

auto Layer::getIntGridValuePositions(const string& name) -> vector<InPoint>;
auto Layer::getIntGridValuePositions(int intgrid_value) -> vector<InPoint>;

This could return all the position in grid coordinates of an IntGridValue occurrences.

For example, to get the positions of tiles that have the IntGridValue { 1, "collision", Color::Red} , you would do:

const auto& collision_tiles_pos = layer.getIntGridValuePositions("collision");

for (const auto& pos : collision_tiles_pos) {
    const auto& tile = layer.getTile(pos.x, pos.y);
    if (tile != ldtk::Tile::None) {
        // a tile exists, create a collision
    }
}

Is this what you are looking for ?

from ldtkloader.

Related Issues (13)

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.