evolutionleo / LDtkParser

A parser for .ldtk levels for GameMaker
https://discord.gg/bRpMgTquAr
MIT License
49 stars 2 forks source link

Just passing by to report :P #9

Closed MichelVGameMaker closed 1 year ago

MichelVGameMaker commented 1 year ago

Hello,

Just in case, this is of interest: When creating tilemap

1-if a tilemap currently exists for the currently processed layer, it can be usefull for this tilemap to be resized (in case room dimensions have changed) and cleared. I think... Row 408 of the main branch else { // respect layer offsets tilemap_set_width(tilemap, room_width div tile_size); tilemap_set_height(tilemap, room_height div tile_size);
tilemap_clear(tilemap, 0);
tilemap_x(tilemap, this_layer.pxTotalOffsetX) tilemap_y(tilemap, this_layer.pxTotalOffsetY) } Row 370 of the beta branch tilemap_set_width(tilemaps[t], room_width div tile_size); tilemap_set_height(tilemaps[t], room_height div tile_size);
tilemap_clear(tilemaps[t], 0);
tilemap_x(tilemaps[t], this_layer.pxTotalOffsetX) tilemap_y(tilemaps[t], this_layer.pxTotalOffsetY)

2-I think the use of cwid is wrong on row 407 (main branch) tileset_def.cWid gives the width of the tileset in number of tiles So it should not impact the width of the tilemap in the room this tilemap = layer_tilemap_create(gm_layer_id, this_layer.__pxTotalOffsetX, this_layer.pxTotalOffsetY, gm_tileset_id, cwid tile_size, chei tile_size) should be replaced by something like tilemap = layer_tilemap_create(gm_layer_id, this_layer.__pxTotalOffsetX, this_layer.__pxTotalOffsetY, gm_tileset_id, room_width div tile_size, room_height div tile_size);... At least I think

Thanks again for sharing this

evolutionleo commented 1 year ago

Thank you! Sounds good to me! Unfortunately I am currently really busy with other IRL stuff, so I don't really have time to work on LDtkParser. I will totally come back to implement this later when I have the time if I don't forget!

Thanks again for your contribution!

MichelVGameMaker commented 1 year ago

I hope everything is ok by your side. yeah I was just reporting this. I adapted what I needed on my side. Take care.

evolutionleo commented 1 year ago

Yeah, everything is okay, thank you, it's just the finals and the work and it's the last week of school etc.

evolutionleo commented 1 year ago

So, turns out I have been using the wrong __cWid all along! I should've used the one provided in the layer definition, instead of the one in the tileset definition. This way the correct width and height of the tilemap are now cwid and chei. Initially I used cwid * tile_size because I thought tilemaps' dimensions were defined in pixels other than cells. Anyhow, now it's fixed, thanks again!