AdamsLair / duality

a 2D Game Development Framework
https://adamslair.github.io/duality
MIT License
1.41k stars 290 forks source link

Support rotated and flipped tiles in Tilemaps. #721

Open raycrasher opened 5 years ago

raycrasher commented 5 years ago

Summary

The ability to rotate and flip tiles in Tilemaps would greatly simplify tilesheet creation and reduce texture sizes, especially for top-down maps.

Modification points:

  1. Tile.cs
    • Add enums RotateDirs { Up, Right, Down, Left } and FlipMode { None, Horizontal, Vertical }
    • Add properties for above enums
  2. TilemapRenderer.cs
    • Modify Draw() to respect tile rotation and flipmode
  3. TilemapEditorCamViewState.cs
    • Rotate tile brush border according to current brush rotation and flip
  4. EditTilemapAction.cs
    • Rotate/flip added tiles.
  5. Add editor action to change current flip and rotate values.
ilexp commented 5 years ago

Interesting idea! Solid implementation outline too.

Some quick thoughts on the impact:

I guess I'm just trying to say, we should make sure the feature would be put to good use when implemented, especially since everyone will pay for it regardless of whether it is used. Would be interested in everyone's thoughts on this:

raycrasher commented 5 years ago

Thank you for the insight!

What are the main use cases / examples, e.g. when would you need or want to rotate or flip a tile?

Right now, it is most useful only on completely top-down maps where the camera is looking straight down the z-axis.

How many tiles in a tileset will typically be rotated or flipped?

An example from http://www.cr31.co.uk/stagecast/wang/3corn.html state that an 3-edge Wang tile set would be reduced from 81 tiles to 24, if rotations are supported.

Would it be viable for the user to just add rotated or flipped variants of tiles they need to the tileset manually?

After doing some thinking and testing, this is actually the best approach. Texture space is cheap, performance hits is not.

How big would the overlap with the existing AutoTiling feature be? Could this be useful to achieve the same effect at "zero impact"?

I did not consider this. I guess a lot of AutoTiling code would be changed also.


From the above, I guess it's better to create an editor plugin that generates the full tileset from an initial set of tiles. This way, impact is virtually nil.