181
General chat / Re: Programming Codea on IPAD
« on: September 14, 2012 »
Can you explain what isn't looking smooth?
I'm not sure what your DY stands for, if it's like ball.vy you can multiply it by -1 to flip it's value from positive to negative and vice versa. In reality a bit of energy would be lost in the bounce so values between -1 and 0 would be better. (-0.8 or something)
My top bottom check looks like this:
I'm not sure what your DY stands for, if it's like ball.vy you can multiply it by -1 to flip it's value from positive to negative and vice versa. In reality a bit of energy would be lost in the bounce so values between -1 and 0 would be better. (-0.8 or something)
My top bottom check looks like this:
Code: [Select]
if ball.y-ball.size/2 < 0 then -- if ball bottom is below lower screen
ball.y = ball.size/2
ball.vy = ball.vy * -1
elseif ball.y+ball.size/2 > HEIGHT then -- use elseif to check either top or bottom colision
ball.y = HEIGHT - ball.size/2 -- HEIGHT gives the screen height
ball.vy = ball.vy * -1
end





