Log In  

I'm trying to have an object travel along a curved path as defined by several x/y coordinates. Right now, I have several x/y points defined and my object travels from one to another in a straight line, so I got that far.

I've been trying to get my head around bezier curves, and I've ended up at a lot of math sites that are way to dense...and when I look through source code from carts, I don't know exactly what to look to try and work backwards.

Or is trying to figure out curves not worth the trouble if Pico8 will have trouble doing the math for what could be several paths going on at one time...? They would be fixed paths, not really dynamic or changing, so maybe that will help, dunno.

Any links, insight or examples are appreciated. Meanwhile, I'll keep scouring sites hoping something will click.

P#22549 2016-06-09 11:46 ( Edited 2016-06-12 00:50)

I don't know if it helps, but if you need a simple explanation of how bézier curves works, I think you should watch this video

P#22554 2016-06-09 13:08 ( Edited 2016-06-09 17:08)

That video does a solid job of explaining how the endpoints and control points create the curve. It's worth watching.

He doesn't note the difference between cubic and quadratic and so on, though. The difference, for anyone interested, is simply in how many control points there are. A cubic curve has two, as shown in the video, and a quadratic curve has one.

With a quadratic Bezier curve, you get the final tangent line at the first step, rather than the second, as seen in the cubic example in the video. Thus, the math is simpler and faster. The downside is that you cannot create an 'S' shape with a single curve segment. You can only make it convex or concave.

Conversely, a quartic curve (4th power, vs. quadratic's 2nd) has three control points and has to do one more step before it gets down to the single tangent line.

Bezier curves are great. There are other types of curves, but nothing so mathematically elegant, IMHO. I've mostly used quadratic Bezier curves in my career, for the sake of performance. You end up having more segments because they're less versatile, but evaluation is cheaper and moving through the extra segments isn't very expensive. The only real pain is in retro-fitting the cubic curves that usually come out of an art package with approximately equivalent quadratic ones.

P#22556 2016-06-09 14:01 ( Edited 2016-06-09 18:04)

I have been meaning to dive into this as well because I'm sure a lot of "polish" in games comes from using these kinda movements.

http://gizma.com/easing/

I found this site a while ago, it gives examples of what the movement looks like, and gives you the snippet of code to go with it. It looks very straightforward.

P#22673 2016-06-11 07:08 ( Edited 2016-06-11 11:08)

I published an Easing cart a while ago, it mostly works. Though I need to revisit it due to some of the easing not working with the limited maths in pico8: https://www.lexaloffle.com/bbs/?pid=14153

Anyway, I've also been thinking about more complicated paths, as I want to make a version of Mitchell Corp's Puzzloop (you might know it as Zuma, or Luxor)

I was going to start wth a spiral:
http://gamedev.stackexchange.com/questions/16745/moving-a-particle-around-an-archimedean-spiral-at-a-constant-speed

P#22717 2016-06-11 20:50 ( Edited 2016-06-12 00:53)

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-28 14:20:06 | 0.007s | Q:17