Page 1 of 1

Metaballs

Posted: Wed Jul 31, 2019 6:01 pm
by unixfreak
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

Re: Metaballs

Posted: Thu Aug 01, 2019 9:17 am
by azoyan
Looks great!

Re: Metaballs

Posted: Thu Aug 01, 2019 1:00 pm
by YoungNeer
Perhaps I could use this as background in my MainMenuState. Thanks a lot :awesome:

Re: Metaballs

Posted: Thu Aug 01, 2019 2:18 pm
by grump
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. ;)

Re: Metaballs

Posted: Thu Aug 01, 2019 4:13 pm
by unixfreak
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: