1
\$\begingroup\$

I want to create a polyline which should be quite smooth for my game. A point is following moving on the line, but can accelerate/brake and has to get slower in corners.

In the end I want to set up some stats (good acceleration, low topspeed, "good" cornering") and simulate the time it has taken to go from start to finish (drawning it to the player would be just a bonus). Yes, this will be some sort of a racing simulation.

I'm quite new to this style of games and I have no idea to do that. I don't even know how to create such a polyline I can easily use.

I don't want a finished algorithm but rather some hints in the right direction. I thought about using the angle of the corner to determine the speed, but that's not really much. I want to implement the time simulation in python, outputting the movement with html/javascript.

How would I start implementing such a mechanism?

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

Usually, you would want to look for an API or lib that provides you with sufficiently sophisticated curve rendering and querying, as the underlying math can be quite difficult.

However, if you want to figure it out yourself, you can look into Bézier curves, which are about the easiest clean curve definition.

Alternatively, a good-enough curve can be just a set of very short lines, so you could just ditch more complicated math and work on point/list arrays.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .