Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Tiled collisions in macroquad-tiled #701

Open
kmeshavkin opened this issue Feb 24, 2024 · 0 comments
Open

Add support for Tiled collisions in macroquad-tiled #701

kmeshavkin opened this issue Feb 24, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@kmeshavkin
Copy link

kmeshavkin commented Feb 24, 2024

Hey!
It would be great to add support for Tiled collisions (see screenshot below) in macroquad-tiled. See screenshot below:

Screenshot of Tiled collisions in editor

image

From what I understand macroquad-tiled does not support object type properties in tile objects in tileset JSON in case of embedded tilemap (tilesets[0].tiles[0]). When Tiled exports tileset, it adds objectgroup property on each tile where Tiled collisions were used. See how generated JSON for the shapes on the screenshot above looks:

Example of JSON generated for collisions from the screenshot above (warning - long code block)
 "tilesets":[
        {
         "columns":7,
         "firstgid":50,
         "image":"tileset.png",
         "imageheight":224,
         "imagewidth":224,
         "margin":0,
         "name":"test_tileset",
         "spacing":0,
         "tilecount":49,
         "tileheight":32,
         "tiles":[
                {
                 "id":43,
                 "objectgroup":
                    {
                     "draworder":"index",
                     "id":2,
                     "name":"",
                     "objects":[
                            {
                             "height":0,
                             "id":1,
                             "name":"",
                             "polygon":[
                                    {
                                     "x":0,
                                     "y":0
                                    }, 
                                    {
                                     "x":19.8181818181818,
                                     "y":6.90909090909091
                                    }, 
                                    {
                                     "x":4.63636363636364,
                                     "y":19.9090909090909
                                    }, 
                                    {
                                     "x":5.09090909090909,
                                     "y":7
                                    }, 
                                    {
                                     "x":-3.90909090909091,
                                     "y":7.09090909090909
                                    }],
                             "rotation":0,
                             "type":"",
                             "visible":true,
                             "width":0,
                             "x":5.18181818181818,
                             "y":0.818181818181817
                            }, 
                            {
                             "height":16.5454545454545,
                             "id":3,
                             "name":"",
                             "rotation":0,
                             "type":"",
                             "visible":true,
                             "width":25.6363636363636,
                             "x":3.27272727272727,
                             "y":13
                            }, 
                            {
                             "ellipse":true,
                             "height":16.6363636363636,
                             "id":4,
                             "name":"",
                             "rotation":0,
                             "type":"",
                             "visible":true,
                             "width":12.2727272727273,
                             "x":14.6363636363636,
                             "y":4
                            }],
                     "opacity":1,
                     "type":"objectgroup",
                     "visible":true,
                     "x":0,
                     "y":0
                    }
                }],
         "tilewidth":32
        }],

Right now it's not possible to access these properties, and macroquad-tiled actually panics when it encounters object property in tiles.

As far as I understand, macroquad doesn't add any generic physics or shapes that can be used to calculate collisions out of the box (I think only platformer physics crate is available?), so it would be good to add ability to access these properties, and maybe actually implement some shape structs to populate them from Tiled collision areas.

Reference from #593

@not-fl3 not-fl3 added the enhancement New feature or request label Feb 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants