-
Notifications
You must be signed in to change notification settings - Fork 16
Description
I'd like to suggest the introduction of additional curved slopes like the ones below:
I understand that collision bodies for the sloped tiles are generated from polygons which are made of straight edges, but I think with some interpolation, curved slopes can also be generated programmatically.
The formula for the curved part of the 4 tiles above are:
- y = w - c(x)
- y = w - c(x + w)
- y = c(2w - x)
- y = c(w-x)
where c(x) = x^2 / 4w
and w is the width of the tile (e.g. 16, 32, 64, 128 etc.)
Note: I'm assuming that the Y axis points downwards, as per normal display convention.
When generating the curved slope, x would be sweeped from 0 to w by a step of 1 and y would be computed accordingly. For practical purposes, x can be incremented by a larger step, e.g. by w / 4 to reduce the number of sides.
An additional point for tile 1 and 4, or two points for 2 and 3, would need to be generated for the lower corner(s).
I can give you the formulas for the 4 tiles going down right, but as you might imagine, they are simple variants of tiles 1 to 4.
Notice how 2 and 3 have 45 degree slopes at one end, which makes it possible to combine them with straight 45 degree slopes.
Flatter versions (1/2 height) can be generated for transitioning on to straight 22.5 degree slopes as well, since their edge would end at halfway up the second tile with a tangent corresponding to the 22.5 slopes, so the second 22.5 straight slope can be placed next to it for a smooth transition.
These could be also extended to curved ceiling tiles, but they're not really that useful.
I could try extending your library myself, but I'm not sure I understand the rest of your code!
What are your thoughts on this?