Code: Select all
function love.load()
love.window.setFullscreen(true, "desktop")
width, height = love.window.getDesktopDimensions(1)
circle = {}
circle.x = width/2
circle.y = height/2
circle.dx = 0
circle.dy = 0
circle.radius = 20
end
function love.update(dt)
down = love.keyboard.isDown("escape")
if down == true then
love.event.quit()
end
circle.dx = circle.dx + love.math.random() * 3 - 1.5
circle.dy = circle.dy + love.math.random() * 3 - 1.5
if circle.dx > 10 then circle.dx = 10 end
if circle.dx < -10 then circle.dx = -10 end
if circle.dy > 10 then circle.dy = 10 end
if circle.dy < -10 then circle.dy = -10 end
circle.x = circle.x + circle.dx
circle.y = circle.y + circle.dy
if circle.x > width - circle.radius then
circle.x = width - circle.radius
circle.dx = 0
end
if circle.x < circle.radius then
circle.x = circle.radius
circle.dx = 0
end
if circle.y > height - circle.radius then
circle.y = height - circle.radius
circle.dy = 0
end
if circle.y < circle.radius then
circle.y = circle.radius
circle.dy = 0
end
end
function love.draw()
local r = circle.x / width
local g = circle.y / height
local b = (circle.x * circle.y) / (height * width)
love.graphics.setColor(r, g, b)
love.graphics.circle("fill", circle.x, circle.y, circle.radius, 64)
end
Code: Select all
function love.load()
love.window.setFullscreen(true, "desktop")
width, height = love.window.getDesktopDimensions(1)
circle = {}
circle.x = width/2
circle.y = height/2
circle.z = 500
circle.dx = 0
circle.dy = 0
circle.dz = 0
circle.radius = 20
end
function love.update(dt)
down = love.keyboard.isDown("escape")
if down == true then
love.event.quit()
end
circle.dx = circle.dx + love.math.random() * 3 - 1.5
circle.dy = circle.dy + love.math.random() * 3 - 1.5
circle.dz = circle.dz + love.math.random() * 3 - 1.5
if circle.dx > 10 then circle.dx = 10 end
if circle.dx < -10 then circle.dx = -10 end
if circle.dy > 10 then circle.dy = 10 end
if circle.dy < -10 then circle.dy = -10 end
if circle.dz > 10 then circle.dz = 10 end
if circle.dz < -10 then circle.dz = -10 end
circle.x = circle.x + circle.dx
circle.y = circle.y + circle.dy
circle.z = circle.z + circle.dz
if circle.x > width - circle.radius then
circle.x = width - circle.radius
circle.dx = 0
end
if circle.x < circle.radius then
circle.x = circle.radius
circle.dx = 0
end
if circle.y > height - circle.radius then
circle.y = height - circle.radius
circle.dy = 0
end
if circle.y < circle.radius then
circle.y = circle.radius
circle.dy = 0
end
if circle.z > 1000 then
circle.z = 1000
circle.dz = 0
end
if circle.z < 0 then
circle.z = 0
circle.dz = 0
end
end
function love.draw()
local r = circle.x / width
local g = circle.y / height
local b = circle.z / 1000
circle.radius = circle.z / 50 + 10
love.graphics.setColor(r, g, b)
love.graphics.circle("fill", circle.x, circle.y, circle.radius, 64)
end