deepnight / ldtk

Modern, lightweight and efficient 2D level editor
https://ldtk.io
MIT License
3.37k stars 186 forks source link

Support for Entity Rotation #841

Open zissakos opened 1 year ago

zissakos commented 1 year ago

It would just be awesome if Entities supported Rotation (and stored a rotation value).

Imagine a level like this:

image

With the current implementation, I have to use tiles or entities for all 15 possible rotations of the revolving doors, and derive the rotation from the tile/entity ID:

image

With rotation support I would only need each door once (namely 5):

image

Anyone else? Is it on the roadmap maybe? UPDATE: Oh, I just found Issue #502 with the same.

Dandielo commented 1 year ago

I can only upvote this. Having them would be amazing.

Currently the lack of them is a bit problematic, which still forces me to use other tools. I can imagine that in LDtk rotations might be a bit tricky to implement, as they need to support the auto layer feature, however I might be mistaken.

deepnight commented 1 year ago

~There's an ongoing PR to add rotation support to Entities. I need to review it before validating it, but this should happen in the next update, hopefully :)~

My bad, the PR is for Entity flipping, which is not exactly the same thing!

https://github.com/deepnight/ldtk/pull/809

Currently the lack of them is a bit problematic, which still forces me to use other tools. I can imagine that in LDtk rotations might be a bit tricky to implement, as they need to support the auto layer feature, however I might be mistaken.

@Dandielo In your example, you're referring to Auto-Layers rules rotation, right?

Dandielo commented 1 year ago

Yes, it would require probably another special rule / option / set or rules to properly determine if a rotation can / should be applied. Maybe a "virtual" version of the same texture could be used, that has all the tiles pre-rotated and you would be able to create rules from all 4 versions (original + 3 rotations?) If required.

When it comes to the PR, I was looking at it, and generally was thinking that if you would add another flip (on the diagonal) you would actually end up with a similar rotation system like Tiled has. Their rotations are mostly flips on either the X, Y or Diagonal Axis.

zissakos commented 1 year ago

yeah, flipping is different. I mean, a simple way to rotate in 45 (or even 90) degree multiples would be enough. (for me at least)

MondayHopscotch commented 1 year ago

+1 for supporting entity rotation. I recently made a game where I had many enemies that can be made in any of the 4 primary directions (for example, to stick to walls/ceilings/floors). Visually, I love my level to look as close to how the game looks as possible. To achieve this, I ended up with 4 copies of each enemy entity, one for each direction. However, this required me to parse out 4 different entities in my code, and to make sure to keep the properties on the 4 entities synced in LDtk. Rotation on the entities would have made this much, much easier.