MichaelSinsbeck / platformer

A ninja platformer written in LÖVE
7 stars 0 forks source link

Red bandana rope with bezier curves #98

Closed michalove closed 10 years ago

michalove commented 10 years ago

I want to find a way to draw the red bandana rope with bezier curves. The rope itself is for visual pleasure, anyway (no influence on physics). Right now, one can see the individual segments.

Germanunkol commented 10 years ago

While I always appreciate bezier curves, I don't quite understand... How can we make the lines bezier curves and then not use bezier curves for the movement? Wouldn't the ninja move away from the line, then?

I've already played around with 0.9.0's Beziers - and was having a blast. They're simple to use and look great.

michalove commented 10 years ago

The ninja-rope interaction and the visualization are separated.

Physically the rope acts like a constraint: the distance between anchor point and ninja is bounded. The physics do not take into account, what shape the rope has in between. And when the ninja is closer to the anchor, than the rope width, then the rope does not have any influence on the ninja movement.

The red line graphically is only there for looking beautiful (and for making it feel more physical). After solving for the ninjas position, the nodes of the rope are adjusted. The rope consists of 10 (I think) nodes, that are coupled by links. there is some simplified physics behind that. The ninjas position acts as a boundary condition for the rope physics, but the rope does not influence the ninja. So you could say, it's a hierarchical physical model.

So I thought to make the rope look even smoother, we could come up with a method for interpolating the nodes with smooth curves instead of piece-wise linear. And there are also approaches out there: http://www.benknowscode.com/2012/09/path-interpolation-using-cubic-bezier_9742.html http://www.antigrain.com/research/bezier_interpolation/index.html?utm_source=twitterfeed&utm_medium=twitter

That would correspond to what you get in Inkscape if you make a path of line segmens and then transform all nodes to smooth nodes.

So, in a nutshell, the visualization of the line is much more fancy than the physics behind it.

Germanunkol commented 10 years ago

Aha! I get it. I thought you were talking about the straight ropes which the ninja can slide down. Now it all makes sense. Thanks!

michalove commented 10 years ago

Done that some weeks ago.

Germanunkol commented 10 years ago

Don't know if I ever mentioned this: It looks very neat! Very rope-y!