Page 4 of 8

Re: Loveballs, A love2d Softbody lib

Posted: Tue Feb 03, 2015 6:11 am
by Germanunkol
IndieRetro wrote: Sticky blob you say? I've done that one ^^ https://www.youtube.com/watch?v=3IBy2uyvVHY
Very awesome! Looks great - I think it would be cool if the eyes were animated some more (squeeze them together when hitting a wall at great momentum, make them look into the direction of flight etc.).

Re: Loveballs, A love2d Softbody lib

Posted: Tue Feb 03, 2015 7:53 am
by Connorses
Okay I'm getting incredibly close to the sort of behaviors I want so I'm going to post the [WIP] and then get some sleep.
-u-

CONTROLS:
left/right arrows: spin
hold spacebar: expand (used for jumping)
hold S: become slippery (no friction, you can spin really fast without moving)
hold A: become sticky (adhere to whatever you touch, until you've let go of the button)

stickiness is a work-in-progress because I need to give it that elastic property, and the joints need to break if you pull them too hard so that you can crawl up the walls ( I seriously have no idea what I'm doing ) I'm really close, though!

The only thing I'm worried about is that I might want to zoom out the display to show more of the area around the player, but Box2D does not give me an easy way to do this. Any tips are appreciated. Thanks for the cool library, and all the coding help, you guys rule. I mean it. :)

Re: Loveballs, A love2d Softbody lib

Posted: Tue Feb 03, 2015 9:21 am
by IndieRetro
Connorses wrote:Okay I'm getting incredibly close to the sort of behaviors I want so I'm going to post the [WIP] and then get some sleep.
-u-

CONTROLS:
left/right arrows: spin
hold spacebar: expand (used for jumping)
hold S: become slippery (no friction, you can spin really fast without moving)
hold A: become sticky (adhere to whatever you touch, until you've let go of the button)

stickiness is a work-in-progress because I need to give it that elastic property, and the joints need to break if you pull them too hard so that you can crawl up the walls ( I seriously have no idea what I'm doing ) I'm really close, though!

The only thing I'm worried about is that I might want to zoom out the display to show more of the area around the player, but Box2D does not give me an easy way to do this. Any tips are appreciated. Thanks for the cool library, and all the coding help, you guys rule. I mean it. :)
It's looking good! As for the sticky-ness, I suggest using a distance joint, you can then set the dampingRatio and frequency, and destroy the joint when the node gets to far from the original place it stuck to, works pretty well.

For zooming out, You can use love.graphics.scale(0.5, 0.5), and love.graphics.translate() to move the view around, just like you would normally ^^

Re: Loveballs, A love2d Softbody lib

Posted: Tue Feb 03, 2015 10:17 am
by Jeeper
IndieRetro wrote:
Connorses wrote:OH MAN THIS IS SO COOL

It immediately reminded me of Gish (which is a game I highly recommend by the way). It makes me want to try and clone Gish's mechanics. It would be an interesting experiment...

Most of it would surprisingly easy, since I can adjust the Frequency to make a blob jump, and also the friction and density (Gish can change his physical properties when you hold down certain buttons). The hard one would be the "sticky key" where you can stick to objects and climb walls, because the blob has to un-stick if it's pulled with too much force. Looks like I could conceivably do this with joints!

EDIT: I think I could figure this out, but I would need a way to listen to the collisions for all the chain links. I'll look into it more tomorrow.

Sticky blob you say? I've done that one ^^ https://www.youtube.com/watch?v=3IBy2uyvVHY

What I did was create a distance joint for each outside node to whatever that node was touching, and change the frequency/damping of that node depending on how far the player pulls from it and what-not, works pretty well.
That looks amazing, would be cool if you made it into a full game!

Re: Loveballs, A love2d Softbody lib

Posted: Tue Feb 03, 2015 10:27 am
by IndieRetro
Jeeper wrote: That looks amazing, would be cool if you made it into a full game!
Heh thanks, I've re-made that game from scratch a few times now, including one with super mario galaxy type gravity (see later videos). I might re-start it again soon, I plan on figuring out an efficient way to make arbitrary softbody's first though!

Re: Loveballs, A love2d Softbody lib

Posted: Tue Feb 03, 2015 2:55 pm
by IndieRetro
Early version video of the new one I'm working on, this is proving to be difficult ._.


Re: Loveballs, A love2d Softbody lib

Posted: Tue Feb 03, 2015 4:34 pm
by ArchAngel075
IndieRetro wrote:Early version video of the new one I'm working on, this is proving to be difficult ._.
Arbitrary shapes you say :O

Actually this video brings forward a issue with node sizes and collision, you can see it pretty clearly.
The actual nodes extend beyond the drawn/tessellated polygon by their radius or so. Decreasing node size may help but that means more nodes (more accurate curvature but also more processing)

If one perhaps translated each point given outwards would this solve the issue?

Re: Loveballs, A love2d Softbody lib

Posted: Tue Feb 03, 2015 4:37 pm
by IndieRetro
ArchAngel075 wrote:
IndieRetro wrote:Early version video of the new one I'm working on, this is proving to be difficult ._.
Arbitrary shapes you say :O

Actually this video brings forward a issue with node sizes and collision, you can see it pretty clearly.
The actual nodes extend beyond the drawn/tessellated polygon by their radius or so. Decreasing node size may help but that means more nodes (more accurate curvature but also more processing)

If one perhaps translated each point given outwards would this solve the issue?

I've actually tried that, it works ok-ish with circles, but its a little buggy. With this they are so dynamic that it would just wouldnt work, what I normally do is I draw a line with the polygon vertices as points, and set the line width to 2x the radius of the outer nodes shape, it works really well.

I just had it off in these two videos because of another bug which was causing the lines to flip out. If you see in my circle softbody lib I do the same things with lines, I think its the quickest/most efficient fix.

Re: Loveballs, A love2d Softbody lib

Posted: Tue Feb 03, 2015 4:56 pm
by ArchAngel075
Then perhaps try scaling?

ie [psuedo code]
[psuedo/untested code uses previous sourceBody love.physics.body object btw]

Code: Select all

local p1 = softbody:getPoints()
local p2 = {}
local c = {softbody.sourceBody:getPosition()}
local r = {softBody.sourceShape:getRadius()}
for i = 1,#p1,2 do
 local x = p1[i]
 local y = p1[i+1]
 local dx = math.sqrt( ( x - c[1] )^2 + ( y - c[2] )^2 )
 local dxr = dx+r
 local angle = math.atan2(y-c[2],x-c[1])
 
 local new_x = dxr*math.cos(angle)+x
 local new_y = dxr*math.sin(angle)+y

 p2[i] = new_x
 p2[i+1] = new_y
this should shift all points outwards towards each node by its radius while respecting arbitrary/polygon shapes. afaik
[though this is more or less what i suggested in the first place?]

Line width method though is plausible and perhaps is best since its a matter of one change against an entire iteration over the original points array.

Re: Loveballs, A love2d Softbody lib

Posted: Tue Feb 03, 2015 5:07 pm
by IndieRetro
I'm not so good at math, lol. Feel free to try it yourself on loveballs though, if you have any luck I will probably implement what you do.

Making quick progress at the moment, the one major issue I have is collision, it all works fine until you fling things around to fast, nodes can get stuck in other softbody's, even with huge node sizes. Not sure what to do about this just yet.

Also that might be harder to do with the arbitrary shapes, the way you create them is by passing vertices into the constructor. So you'll have to figure out the radius somehow to, though it changes pretty constantly because of how flexable they are.