Loveballs, A love2d Softbody lib

Showcase your libraries, tools and other projects that help your fellow love users.
Germanunkol
Party member
Posts: 712
Joined: Fri Jun 22, 2012 4:54 pm
Contact:

Re: Loveballs, A love2d Softbody lib

Post 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.).
trAInsported - Write AI to control your trains
Bandana (Dev blog) - Platformer featuring an awesome little ninja by Micha and me
GridCars - Our jam entry for LD31
Germanunkol.de
Connorses
Citizen
Posts: 63
Joined: Fri Sep 06, 2013 7:02 am

Re: Loveballs, A love2d Softbody lib

Post 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. :)
Attachments
slimygame.love
(6.81 KiB) Downloaded 108 times
IndieRetro
Citizen
Posts: 51
Joined: Mon Apr 15, 2013 8:21 pm
Contact:

Re: Loveballs, A love2d Softbody lib

Post 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 ^^
irc.freenode.org ##oodnet
http://exez.in/
User avatar
Jeeper
Party member
Posts: 611
Joined: Tue Mar 12, 2013 7:11 pm
Contact:

Re: Loveballs, A love2d Softbody lib

Post 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!
IndieRetro
Citizen
Posts: 51
Joined: Mon Apr 15, 2013 8:21 pm
Contact:

Re: Loveballs, A love2d Softbody lib

Post 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!
irc.freenode.org ##oodnet
http://exez.in/
IndieRetro
Citizen
Posts: 51
Joined: Mon Apr 15, 2013 8:21 pm
Contact:

Re: Loveballs, A love2d Softbody lib

Post by IndieRetro »

Early version video of the new one I'm working on, this is proving to be difficult ._.

irc.freenode.org ##oodnet
http://exez.in/
User avatar
ArchAngel075
Party member
Posts: 319
Joined: Mon Jun 24, 2013 5:16 am

Re: Loveballs, A love2d Softbody lib

Post 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?
IndieRetro
Citizen
Posts: 51
Joined: Mon Apr 15, 2013 8:21 pm
Contact:

Re: Loveballs, A love2d Softbody lib

Post 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.
irc.freenode.org ##oodnet
http://exez.in/
User avatar
ArchAngel075
Party member
Posts: 319
Joined: Mon Jun 24, 2013 5:16 am

Re: Loveballs, A love2d Softbody lib

Post 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.
IndieRetro
Citizen
Posts: 51
Joined: Mon Apr 15, 2013 8:21 pm
Contact:

Re: Loveballs, A love2d Softbody lib

Post 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.
irc.freenode.org ##oodnet
http://exez.in/
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 232 guests