What I would like to do is to define paths for the players to follow, when selected, and then in-game, have the player follow the selected path. Is there some function/class for doing this? If so, how do you define the path? Another basic question, sorry. I'm sure there's something for this...
Comments
I had planned to make alien waves based on mathematical curves, but I think if I was to do it based on a predefined path, I would keep a list of vectors in the config, a vector point at intervals along the path.
You might at least like to start reading about orxVECTORs: http://www.orx-project.org/orx/doc/html/group__orx_vector.html
And search through both the wiki and forum for use on orxVECTORs.
Iarwain will probably have a better way of doing this.
There used to be a grid-based A* pathfinder but I teared it apart years ago with the plans to make it more modular and never got around to it. If I do it in the future, it'll probably be either a node-based A* or a grid based JPS+.
However for now, you'll either need to roll your system (depending on your needs that can be a simple waypoint-based patrolling system) or use one of the AI framework out there, sorry.
The Bezier one (orxVector_Bezier) was added after the release of 1.5, so you'll find it mentioned in your own local doxygen doc (/orx/doc directory).
Those curves are combinations of simple primitive curves such as sine, sawtooth, triangle, square, smoothstep, ...
I haven't added catmull-rom or bezier to the list yet, and I also plan on adding free-form curves: https://bitbucket.org/orx/orx/issue/14/add-freeform-curves
The movement vector could have continually been updated to adjust to the next waypoint in your list of orxVECTORs.
And as Iarwain said, there's a lot of math calc functions in that API for distances, directions etc.
I'm currently using Bezier paths for one of my projects (purely for animated visuals). The way we do it is that the artist creates them in SVG format and I wrote a very simple converter that will output the path in orx's config format.
I'll then simply iterate over the points in the path and render them using a mesh with orxDisplay_DrawMesh.
I actually added the conversion utility to the game itself, as a command line parameter (just because it was very easy to plug it in than write a separate tool and I'm lazy that way).
Here's the code, it relies on Mikko Mononen's NanoSVG (a single C file SVG decoder):
Then using the command line switch -s, I can convert a .svg file.
I stopped hanging there because it was rather empty (and my current employer's firewall doesn't allow me to do so anymore), but I'll try to get there more often. As a reminder, it's on Freenode, #orx-project, there's a link on the site's left navigation panel.
I won't be able to come tonight as it's getting late and I have some IGF judging to do.
Ended up reading into how Catmull Rom splines work (thankfully pretty straight forward http://www.gamedev.net/topic/575181-catmull-rom-splines and http://schepers.cc/svg/path/dotty.svg)
Then started reading in the box2d forum to see how it will apply to physics and came to realise I'm comparing two incompatible methods.
If I want an alien wave, I either wait until free-form curves are available in the FX module.. or I have a clock that constantly updates object positions manually at interpolated x and y positions along the curve.
Am I right on this?
init
----
And the clock:
Works ok, smoothly sends the fighter object along points 2 and 3 (points 1 and 4 are just anchors to determine the shape of the path).
orxVector_CatmullRom outputs the x and y position, but does it also output the rotation? I suppose I will need to read one step ahead and calculate the orxVECTOR direction.
When I implemented this, lydesik suggested to also add a version that would compute the tangent along the position. If you find it useful, I can add that at some point, just open an issue for it.