Do not post questions here!
This forum is for example code you want to show other people. Ren'Py questions should be asked in the Ren'Py Questions and Announcements forum.
- Eileen-Class Veteran
- Posts: 1463
- Joined: Tue May 30, 2017 6:10 am
- Completed: None... yet (as I'm still looking for an artist)
- Projects: An un-named anime based trainer game
(image borrowed from https://package.elm-lang.org/packages/f ... test/Curve)
Unlike other curved paths such as Bezier, we do not have to pre-calculate control points to get the curves to hit our known points. We just tell it the points we want to go through and the clever math does all the rest.
The script is a drop-in example of the code with a little aeroplane flying around and some dots to show the computed path. Just drop it in a new project and have a see what it can do.
There are bars to adjust:
Steps: number of calculated points between nodes
Alpha: A value between 0.0 and 1.0 makes most sense (0.5 is suitable for most use cases)
note: adjusting these re-calculates the spline so may tickle your CPU a teeny bit
The start of the script is the class and subclass, followed by a python transform, a Ren'Py transform, a screen and a couple of calls to show the screen. Hopefully it is simple enough to pull apart and find the bits you need.
The class actually support N-dimension nodes (for if you were working in 3d or 4d or weird stuff beyond that) and defaults to re-evaluating the calculated points to make them equidistant along the full path. As the math is not trivial, computed splines are added to a rolling spline_cache - so referencing a spline with the same args and kwargs will return a cached version rather than recompute.
Feel free to let me know what you think (or if you find a bug or snaffu type critter)
Users browsing this forum: No registered users