Skip to content

Instantly share code, notes, and snippets.

@serpent7776
Created Dec 29, 2016
Embed
What would you like to do?
function love.load()
canvas = love.graphics.newCanvas(800, 600)
x = 400
y = 300
r = 10
vx = math.random() * 100
vy = math.random() * 100
end
function love.update(dt)
x = x + vx * dt
y = y + vy * dt
if x < 0 or x > 800 - r then
vx = - vx
end
if y < 0 or y > 600 - r then
vy = - vy
end
end
function love.draw()
love.graphics.setCanvas(canvas)
love.graphics.setBlendMode("alpha")
love.graphics.setColor(0, 0, 0, 5)
love.graphics.rectangle("fill", 0, 0, 800, 600)
love.graphics.setColor(255, 255, 255, 255)
love.graphics.rectangle("fill", x, y, r, r)
-- draw
love.graphics.setCanvas()
love.graphics.clear()
love.graphics.setBlendMode("alpha", "premultiplied")
love.graphics.draw(canvas)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment