So after a pretty long hiatus from programming i've returned and made a useless thing that looks kinda neat.
Then i made another useless thing that looks kinda neat just for good measure. This one is contained in main.lua so i'll just post the code.
Code: Select all
local w, h, f = love.window.getMode()
love.window.setMode(800, 800, f)
screen = {
width = love.graphics.getWidth(),
height = love.graphics.getHeight()
}
love.graphics.setLineWidth(1)
love.graphics.setBackgroundColor(0, 0, 0)
local obj = {}
local count = 128
local orbit_radius = screen.width / 2 / 2
local radius = screen.width / 2 / 2
for i=1, count do
local a = ((math.pi * 2) / count) * i
local hue = (255 / count) * i
local o = {
x = 0,
y = 0,
angle = a,
rad = radius,
radius = radius,
orad = orbit_radius,
orbit_rad = orbit_radius,
orbit_speed = 0.5,
orbit_x = screen.width / 2,
orbit_y = screen.height / 2,
color = {
h = hue,
s = 255,
l = 126,
a = 8
},
t = math.pi / 2
}
obj[#obj + 1] = o
end
function love.update(dt)
for i,v in ipairs(obj) do
v.angle = v.angle + v.orbit_speed * dt
v.t = v.t + (dt / 2)
--v.radius = math.abs(math.sin(v.t)) * v.rad
v.orbit_rad = math.abs(math.sin(v.t)) * v.orad
v.x = math.cos(v.angle) * v.orbit_rad + v.orbit_x
v.y = math.sin(v.angle) * v.orbit_rad + v.orbit_y
end
end
function love.draw()
love.graphics.setBlendMode("additive")
for i,v in ipairs(obj) do
love.graphics.setColor(hsl(v.color.h, v.color.s, v.color.l, v.color.a))
--love.graphics.circle("fill", v.x, v.y, v.radius)
local a = v.color.a * 4
if a > 255 then a = 255 end
love.graphics.setColor(hsl(v.color.h, v.color.s, v.color.l, a))
love.graphics.circle("line", v.x, v.y, v.radius)
end
end
function love.keypressed(key)
if key == "escape" then love.event.push("quit") end
end
function love.mousepressed(x, y, key)
end
function hsl(h, s, l, a)
if s<=0 then return l,l,l,a end
h, s, l = h/256*6, s/255, l/255
local c = (1-math.abs(2*l-1))*s
local x = (1-math.abs(h%2-1))*c
local m,r,g,b = (l-.5*c), 0,0,0
if h < 1 then r,g,b = c,x,0
elseif h < 2 then r,g,b = x,c,0
elseif h < 3 then r,g,b = 0,c,x
elseif h < 4 then r,g,b = 0,x,c
elseif h < 5 then r,g,b = x,0,c
else r,g,b = c,0,x
end return (r+m)*255,(g+m)*255,(b+m)*255,a
end