Hi guys, I just realised that if you don’t use background()
you can get neat motion blur on stuff. Most of you probably know this, so to other noobs like me, if you don’t use background, it doesn’t clear the previous drawing, and if you draw a semi-transparent rectangle over the whole screen, previous drawings will slowly fade.
An example is here:
--# Main
-- Bouncing ball
function setup()
rectMode(CORNERS)
ellipseMode(CENTER)
parameter.number("blurAmount", 0, 20, function() blurAlpha = 255/(blurAmount + 1) end)
ball = physics.body(CIRCLE, 100)
ball.restitution = 1
ball.x = WIDTH/2
ball.y = HEIGHT/2
box = physics.body(CHAIN, vec2(0,0), vec2(WIDTH,0), vec2(WIDTH,HEIGHT), vec2(0,HEIGHT), vec2(0,0))
end
function draw()
--background(0) -- You don't actually need to have a background
fill(0,blurAlpha)
rect(0,0,WIDTH,HEIGHT)
fill(255)
ellipse(ball.x, ball.y, 200)
physics.gravity(Gravity.x * 500, Gravity.y * 500)
end