gurkenlabs / litiengine

LITIENGINE 🕹 The pure 2D java game engine.
https://litiengine.com/
MIT License
718 stars 93 forks source link

Implement parallax scrolling #238

Open nightm4re94 opened 5 years ago

nightm4re94 commented 5 years ago

Most awesome 2D games have a parallax scrolling engine. We should support this too. Maybe the map creator would simply set some sort of "scrollSpeed" Layer property (default: 1.0) and then all layers would be scrolled by our wizardry.

TheRamenChef commented 5 years ago

It's currently open as a feature request on the Tiled forums. We should determine whether it's worth waiting for support from Tiled, or alternatively, reach out and see if we can figure out how it will eventually be implemented in Tiled.

Parallax scrolling for tile layers could be problematic, as it would need to be taken into account when resolving tiles, and the tiles would still be the same size as the other layers.

steffen-wilke commented 5 years ago

@TheRamenChef That's a nice finding. Seeing the creation date of that issue though, I don't have much hope that this will get implemented any time soon. But I totally agree on reaching out to bjorn and see what he has planned regarding this topic.

nightm4re94 commented 5 years ago

I can't imagine this feature being implemented in Tiled too soon either.

Regarding the calculation of tile boundaries on scrolling layers, I had in mind that the Tile grid would still persist as is, only considering the unscrolled tile layer (-> the default foreground plane). The offset of scrolled layers would be a solely visual effect, not influencing any Tile calculations. The following image taken from Stackoverflow shows quite well what I had intended: Parallax sample image Tile sizes would be the same for all layers, but the scrolling layers would need to "be bigger"(cover more tiles) than the layers with default scrolling. The default layers would only cover a smaller portion of the map, depending on how big the viewport is.

There are plenty of resources on implementing a parallax scrolling effect.

TheRamenChef commented 5 years ago

Any updates on this? Have we contacted bjorn yet?

steffen-wilke commented 5 years ago

No, not yet. And no other updates currently.

nightm4re94 commented 1 year ago

This is, in fact, already a feature in Tiled: https://doc.mapeditor.org/en/stable/manual/layers/#parallax-factor

We are still only supporting Tiled v1.2 maps - should update our map specifications urgently to the more recent versions of the tmx format.

Closing this issue in favor of #464.