englercj / phaser-tiled

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

Isometric and some questions #61

Open MannyC opened 8 years ago

MannyC commented 8 years ago

I've been looking into adapting phaser-tiled to support isometric tiles. I've hacked in some changes which have been working so far. I was looking into doing it using Phaser's implementation but the way this plugin did its rendering made more sense to me.

My general thinking is to just adapt the various points to cope with isometric tiles/coordinates. Generally this consists of:

Thoughts on the above strategy and its sanity?

Also, while reviewing the code to get to grips with it, I've come across some things I don't fully understand yet. It seems that this was originally based on Phaser's Tilemap implementation, and it seems to still have some leftover code. Mainly this seems to be some overlapping of functionality between the classes. For instance, I'm not sure what the Tile class is doing. It isn't used by the Tilelayer class, only by the Tilemap.putTile method, which isn't actually called by the plugin itself. There seems to be some very similar looking code in the Tilelayer class and the Tile class, and it feels like the Tile class perhaps should be there at all (or should be used by Tilelayer instead of it using Sprites). I don't want to make too many potentially far reaching changes around this, particularly when I don't understand all of the plugins uses, but if we're implementing iso then the less code that has to be considered the better.

I know that performance is a concern. Do you have a base tileset/map we can use as a benchmark?

Also, is the general thinking to support Tiled maps + additional features, or to be a general Tiling engine that happens to support Tiled maps?

Anyway, just starting a conversation about all this.

englercj commented 8 years ago

Cool thoughts, I think this seems reasonable.

As far as testing I generally use this set of test Tiled maps: https://github.com/englercj/phaser-tiled-tests

It seems that this was originally based on Phaser's Tilemap implementation, and it seems to still have some leftover code.

Less based on, and more "trying to emulate". I think I will abandon that in v3 because it causes a lot of confusion and isn't really helpful.

For instance, I'm not sure what the Tile class is doing.

Not much, it was used previously but I forgot to remove it in recent versions :P

is the general thinking to support Tiled maps + additional features, or to be a general Tiling engine that happens to support Tiled maps?

Great question, I think I have been going with Tiled maps + additional features. Generally it is more specifically: Tiled maps with extra property support to be able to configure Phaser features from within Tiled.

I'm planning v3 which will remove the "sprite-per-tile" mentality in favor of a custom renderer for each type. A single shader for webgl and some custom tile placement for canvas (probably similar to current method but with some buffers). Also will abandon the "drop in replacement for built-in phaser tilemaps" and just do a better API that makes more sense for this plugin and its use-case.

MannyC commented 8 years ago

That's great. I'll write more as things move along/I investigate more.