Page 1 of 1

Procedural animation?

Posted: Mon May 02, 2016 9:06 am
by adge
I'm just curious how would you do something like that?

https://twitter.com/LorenSchmidt/status ... 4802542592

I think it would be easy to do it on a plane but with stairs? Would you use different types of stairs and then check for them or would you use pixel perfect collision?

Re: Procedural animation?

Posted: Mon May 02, 2016 9:28 am
by zorg
Get the horizontal (x) position of the player, get the horizontal offsets for the feet, then color the topmost pixels of the ground (any type, stairs, whatever) below the player's lowest y coords where those horizontal x + offset positions are... would be one way.

Re: Procedural animation?

Posted: Mon May 02, 2016 9:32 am
by ivan
As long as all of your stairs have the same slope you could probably get away by using two separate animations: going up and going down. Once you have these two animations, the problem could be simplified to: which frame do you draw, depending on the player's position on stairs. This is the sensible solution.

If you want to support ANY type of slope in your stairs, then we're talking inverse kinematics and other physics nightmares.

Re: Procedural animation?

Posted: Mon May 02, 2016 10:44 am
by adge
Well i don't quite get that.

The way I would do it:
Have a pixel perfect collision system that checks beneath the body if its a flat plane or stairs. If its a flat plane it determines the step points and draws two lines from the lower body to these points. If the body moves only the endpoints of the lines are changed to the new ones.
It there is a stair coming check for stair height locate step points and move the "feet" (lines endpoints) there if the body moves over them.

Does this make sense?

But how is pixel perfect collision done in love2d? Or how would you check for collisions in this case. Assuming that a plane can be just a rectangle drawn by love.graphics.rectangle and the stairs could also consist out of small rectangles by love.graphics. Or .pngs for both.

Re: Procedural animation?

Posted: Mon May 02, 2016 12:26 pm
by marco.lizza
Why not marking each tile with a "lightable" with white pixels. Then, when your paint the tiles you check if they are near the player. If yes, you fill the white pixels region with magenta/purple/whatever... otherwise in black.

No need for collision detection, just to measure the (linear) distance.

Re: Procedural animation?

Posted: Mon May 02, 2016 2:03 pm
by damountie
If I might have a go... If I am standing at tile 19, do an array check of the tile that is next in the direction faced.

Is its height higher, lower or same as current tile? Draw player image appropriately.

If overhanging a lower tile (stair going down), then the answer is lower. Determining that overhang could then be done a few different ways.