I'm trying to allow for multiple colors of ball but I don't like how it wound up with this darker edge.
Here's the metaball.png I made (Wondering if it could be a problem with this? I tried to be sure it's only white pixels) I'm using LOVE 0.10.2
It's a modified version of this script:
viewtopic.php?t=9061
Code: Select all
function love.load()
mb_img = love.graphics.newImage("metaball.png")
t=0
--metaball gradient:
canv_mbg = love.graphics.newCanvas(128,128)
mb_x = {168,188,246,374,420,420,460,360,330,363}
mb_y = {140,108,91,73,103,103,120,190,214,219}
maxD = 20;
delta_x = {}
delta_y = {}
colors = {}
for i=1,#mb_x,1 do
delta_x[i] = (love.math.random()*maxD)-(.5*maxD)
delta_y[i] = (love.math.random()*maxD)-(.5*maxD)
colors[i] = {
80,
240,
30
}
end
canv = love.graphics.newCanvas()
effect_metaballs = love.graphics.newShader [[
vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 pixel_coords)
{
vec4 pixel = Texel(texture, texture_coords);
pixel.a = floor(pixel.a+0.5);
return pixel;
}
]]
end
function love.draw()
love.graphics.clear(0,0,0)
love.graphics.setCanvas(canv)
love.graphics.setShader()
love.graphics.clear(0,0,0,0)
for n=1,#mb_x,1 do
love.graphics.setColor(colors[n][1],colors[n][2],colors[n][3])
love.graphics.draw(mb_img,mb_x[n],mb_y[n],0,1,1,0,0,0,0)
end
love.graphics.setColor(255,255,255)
love.graphics.setCanvas()
love.graphics.setShader(effect_metaballs)
love.graphics.setColor(255,255,255,255)
love.graphics.draw(canv)
love.graphics.print(love.timer.getFPS(),32,32,0,1,1,0,0,0,0)
end
function love.mousepressed( x, y, button, istouch, presses)
i = #mb_x+1
mb_x[i] = x;
mb_y[i] = y;
delta_x[i] = (love.math.random()*maxD)-(.5*maxD)
delta_y[i] = (love.math.random()*maxD)-(.5*maxD)
colors[i] = {
80,
30,
240,
}
end
function love.update(dt)
t=t+dt
for i = 1,#mb_x,1 do
mb_x[i] = mb_x[i]+delta_x[i] * dt
mb_y[i] = mb_y[i]+delta_y[i] * dt
end
end