Created
December 29, 2016 13:23
-
-
Save serpent7776/0a6b5b3dbe676e8cccd877d33ef8aea9 to your computer and use it in GitHub Desktop.
Revisions
-
serpent7776 created this gist
Dec 29, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ 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