lua - How do I invert this equation? -
i'm making simple animation ball bounces repeatedly. equation bounce h = rt / 16t^2, h height, t time in seconds, , r initial speed. problem ball bounces up-side-down. i've been playing around equation, can't right. can see wrong this?
function move_ball() count = count + 0.3 local h = (ints*count)-(16*(math.pow(count,2))) if (h < 0) count = 0 move_ball() collision() else ball.y = h / scale end if (ball.x - ball.rad < 0) ball.dir = ball.speed collision() elseif (ball.x + ball.rad > length) ball.dir = -ball.speed collision() end ball.x = ball.x + ball.dir end
perhaps need like:
ball.y = height - (h / scale)
with test sure ball.y doesn't go negative.
Comments
Post a Comment