Add support for Tiled collisions in macroquad-tiled
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
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