This function moves the object in a given "angle" for "a" pixels, untill "speed / a" reaches zero.
a = speed / 500
if a >= 0 then
if ball.x <= 6 or ball.x >= 460 then
angle = pi - angle
if ball.y <= 5 or ball.y >= 252 then
angle = angle * (-1)
ball.x = ball.x + math.cos(angle) * a
ball.y = ball.y + math.sin(angle) * a
speed = speed - 10
Now comes my problem: if call this function inside my mainloop, it gets repeated over and over, ball.x and ball.y would get resetted every time. How could I get this to work?
function moving(speed, angle, ball.x, ball.y, BallNumber)