Metaballs

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
User avatar
unixfreak
Citizen
Posts: 77
Joined: Thu Oct 15, 2015 6:25 am
Location: Bristol, UK
Contact:

Metaballs

Post by unixfreak » Wed Jul 31, 2019 6:01 pm

Image

This module creates a drawable surface with some HSL bouncing metaballs.

Maybe someone will find this useful as a starting point for something else. Code can be found here:
https://github.com/Jigoku/love2d_metaballs

Basic Usage:

Code: Select all

function love.load()
	require("metaballs") 
	metaballs.create(8) 	-- spawn 8 metaballs
end

function love.draw()
	love.graphics.draw(metaballs.surface(),0,0)
end

function love.update(dt)
	metaballs.update(dt)
end
This was inspired by a coding challenge video i came across recently: https://www.youtube.com/watch?v=ccYLb7cLB1I
Attachments
metaballs.love
(1.99 KiB) Downloaded 61 times

azoyan
Prole
Posts: 18
Joined: Wed Dec 27, 2017 5:19 pm

Re: Metaballs

Post by azoyan » Thu Aug 01, 2019 9:17 am

Looks great!

User avatar
YoungNeer
Party member
Posts: 114
Joined: Wed May 15, 2019 7:49 am

Re: Metaballs

Post by YoungNeer » Thu Aug 01, 2019 1:00 pm

Perhaps I could use this as background in my MainMenuState. Thanks a lot :awesome:
My Github- your contribution is highly appreciated

grump
Party member
Posts: 586
Joined: Sat Jul 22, 2017 7:43 pm

Re: Metaballs

Post by grump » Thu Aug 01, 2019 2:18 pm

Looks nice! I played around with it for a bit and made some optimizations. The calculation is now done in a shader, and the texture is not recreated every frame. It's quickly hacked in though, so the code is far from optimal and not very pretty. ;)
Attachments
metaballs2.love
(2.02 KiB) Downloaded 56 times

User avatar
unixfreak
Citizen
Posts: 77
Joined: Thu Oct 15, 2015 6:25 am
Location: Bristol, UK
Contact:

Re: Metaballs

Post by unixfreak » Thu Aug 01, 2019 4:13 pm

grump wrote:
Thu Aug 01, 2019 2:18 pm
Looks nice! I played around with it for a bit and made some optimizations. The calculation is now done in a shader, and the texture is not recreated every frame. It's quickly hacked in though, so the code is far from optimal and not very pretty. ;)
Hey, that's cool. Yeah, runs much faster as a shader. I still haven't a clue at writing things via shader language, will have to dig into that more in the future. :awesome:

Post Reply

Who is online

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