englercj / phaser-tiled

A tilemap implementation for phaser focusing on large complex maps built with the Tiled Editor.
MIT License
290 stars 31 forks source link

Better body combine algorithm #62

Open JimVliet opened 8 years ago

JimVliet commented 8 years ago

I thought I'd make a seperate issue for this, since it didn't seem like you saw it in the main issue.

Anyway I made my own kind of algorithm recently and while it's not perfect, it works alright. Result is here: http://jimvliet.github.io/HTML5-Game/objectConverter

The code is in this file: https://github.com/JimVliet/HTML5-Game/blob/master/scripts/functionFile.ts

It works like this: It starts at the top left and goes to the bottom right. Everytime it finds a solid object which isn't already used it will create a rectangle with the largest possible area from that position. Then the tiles used in that rectangle won't be able to be used again.

If you have any questions, feel free to ask.

This is my current game: http://jimvliet.github.io/HTML5-Game/ in which this is used

englercj commented 8 years ago

I did, it looks cool. I just haven't had time to do anything with it yet (I don't do this full time).