Procedural animation?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
adge
Citizen
Posts: 54
Joined: Mon Dec 14, 2015 8:50 pm

Procedural animation?

Post 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?
User avatar
zorg
Party member
Posts: 3465
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Procedural animation?

Post 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.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
User avatar
ivan
Party member
Posts: 1915
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: Procedural animation?

Post 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.
adge
Citizen
Posts: 54
Joined: Mon Dec 14, 2015 8:50 pm

Re: Procedural animation?

Post 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.
marco.lizza
Citizen
Posts: 52
Joined: Wed Dec 23, 2015 4:03 pm

Re: Procedural animation?

Post 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.
damountie
Prole
Posts: 3
Joined: Thu Feb 25, 2016 5:49 pm
Contact:

Re: Procedural animation?

Post 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.
Twitter: @notdamountie
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 4 guests