Loveballs, A love2d Softbody lib

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
IndieRetro
Citizen
Posts: 51
Joined: Mon Apr 15, 2013 8:21 pm
Contact:

Loveballs, A love2d Softbody lib

Post by IndieRetro »

LOVEBALLS



Loveballs is a small softbody lib I have been working on for personal projects.
It's pretty easy to use, here is a small example

Documentation

Code: Select all

--Creates a softbody
--smoothing is optional, the default settings are the best, essentially the number is how many nodes to pass in
--tessellate count, the higher the better quality, but anything too large will probably cause performance issues
--setting tessellate count to < 1 or a float/double will result in errors
--if you want some neat effects, try a somewhat high smoothing (6-8), with a tessellate count of 1-2
object = Softbody:new(world, x, y, radius, smoothing, tessellatecount)

--Sets the frequency of the softbody
objecy:setFrequency(f)

--Sets the damping ratio of the body
object:setDamping(d)

--Set friction of outer nodes
object:setFriction(f)

--Updates tesselation, required
object:update()

--Draws the softbody
object:draw()

--Draws only a line, instead of a full polygon
object:draw("line")

--Destroys the softbody
object:destroy()

Credit to Amadiro/Jonathan Ringstad for the tesselate function

Credit to me(Shorefire/Indieretro) and Jonathan Ringstad not required, but appreciated. Feel free to use the lib/code however you want, just as long as you dont claim it as your own.

To do list
-Allow the creation of arbitrary shapes
-Manually set the amount of nodes
-Manually set the size of nodes

Licence: http://opensource.org/licenses/Zlib
Github: https://github.com/siObyte/loveballs


----Update log
+Added tesselate count
+Added destroy function
+Added line width arg to draw
*Major change to node joints (Want to roll the softbody? apply a AngularImpulse to object.sourceBody!)

--Update 15/1/15
*Important change to softbody physics
*Cleaned up a little bit of code
*Renamed loveballs.lua to init.lua, just require the folder now

--Update 1/2/15
+Added getPoints()
+Added setFriction(f)
+Added update()
+Added comments
*Moved tess to update
*Cleaned up code
*Renamed sourceBody to centerBody (for shape & fixture to)

--Update 24/2/15
+New example in the github repo
*Moved source to github
*Fixed a few bugs
*Changed how the lib is required

--Update 27/2/15
+Indexing a softbody will return the node (see readme in repo)
*Removed yaci class lib depend
*Changed over to metatables
*Changed construction syntax a little
Attachments
example.love
Small demo, mouse click to create softbody
(2.35 KiB) Downloaded 535 times
Last edited by IndieRetro on Mon Jul 27, 2015 2:07 pm, edited 23 times in total.
irc.freenode.org ##oodnet
http://exez.in/
User avatar
undef
Party member
Posts: 438
Joined: Mon Jun 10, 2013 3:09 pm
Location: Berlin
Contact:

Re: Loveballs, A love2d Softbody lib

Post by undef »

That looks really nice!
Reminds me of "The Floor is Jelly".
twitter | steam | indieDB

Check out quadrant on Steam!
User avatar
artofwork
Citizen
Posts: 91
Joined: Mon Sep 15, 2014 1:17 am
Location: East Coast USA

Re: Loveballs, A love2d Softbody lib

Post by artofwork »

That's really awesome!

Makes me think of boobies :P
User avatar
Fenrir
Party member
Posts: 222
Joined: Wed Nov 27, 2013 9:44 am
Contact:

Re: Loveballs, A love2d Softbody lib

Post by Fenrir »

Really nice, good work!
User avatar
soulaymenc
Prole
Posts: 36
Joined: Thu Jul 11, 2013 2:03 pm
Contact:

Re: Loveballs, A love2d Softbody lib

Post by soulaymenc »

oh my god so fucking kawai :D :D <3
This world is so strange.
User avatar
SiENcE
Party member
Posts: 792
Joined: Thu Jul 24, 2008 2:25 pm
Location: Berlin/Germany
Contact:

Re: Loveballs, A love2d Softbody lib

Post by SiENcE »

Looks nice and quitschy.
User avatar
adnzzzzZ
Party member
Posts: 305
Joined: Sun Dec 26, 2010 11:04 pm
Location: Porto Alegre, Brazil

Re: Loveballs, A love2d Softbody lib

Post by adnzzzzZ »

This is really really neat. Is it possible to set different properties to different parts/sides of a blob? Like making it sticky but only on a certain part.
IndieRetro
Citizen
Posts: 51
Joined: Mon Apr 15, 2013 8:21 pm
Contact:

Re: Loveballs, A love2d Softbody lib

Post by IndieRetro »

adnzzzzZ wrote:This is really really neat. Is it possible to set different properties to different parts/sides of a blob? Like making it sticky but only on a certain part.
Not currently, I've been working on arbitrary shapes for softbodys, but I will try to implement this soon. There's a very important update I need to release asap. I've found that setting both anchors of the DistanceJoints to the same position on each node, instead of one on the center body and one on the node, results in a much better softbody. This way the softbody rolls instead of sliding when you give the nodes friction, unlike before it would just slide all over the place.

Anywho, more coming soon hopefully..

EDIT: Update's done \o/
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 »

New small update released, small changes but they improve the softbody physics a load. I recommend using the latest version.

Demos are outdated, but the source.zip is updated, also on github.
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 »

Loving this as its giving me some small idea to persue!

It took awhile to adapt to this, since i use onContact callbacks and normals of contacts to set a "isGrounded" variable for the player on the ground so that i can control when one may jump, but sadly the sofBody.fixture isnt exactly the right fixture to call setUserData() on.

After a tweak i now cycle through softBody.nodes and call setUserData() on those fixtures (it even opened for some funky jumping mechanic so i dont mind)

I do mind though the following and #suggestions# :

1. Open a function to fetch each nodes body/fixture/shape for fiddling, i feal dirty some-how using softBody.nodes[n].fixture
2. Method to change the radius of the softBody on the fly.

The following is more of a call for help on how I can go about implementing the feature in my game :
If i take a softBody and by some way "stretch" it and then have it split into two softBodies whom share the same radius that is half the original.
The above is what i hope to achieve as the main mechanic of the game/snippet I am attempting...something of a blob that splits and rejoins as needed but with the REALLY amazing tessellation and wobbles on the way...
Post Reply

Who is online

Users browsing this forum: No registered users and 23 guests