Alright. I had a look into your code.
I give you a hint, how to get started. Maybe you can work out the details on your own:
You initialize the ball with
Code: Select all
ball = {x = 50, y = 50, radius = 50, segments = 500, speed = level * 200, speed = math.random (360)}
Instead of having one "speed"-variable, you need two variables, namely for the to coordinate directions. Lets call them vx and vy (for velocity x and velocity y)
Also, for now, lets say that the initial speed is set in the beginning (I picked arbitrary numbers here). We'd get
Code: Select all
ball = {x = 50, y = 50, vx = 10, vy = 5, radius = 50}
Also for now, I leave away the segments property, as it is only a matter of drawing. It would only make sense if you have multiple balls and each one had a different number of segments.
Now in the update-function, you have to move the ball according to velocity
Code: Select all
ball.x = ball.x + ball.vx*dt
ball.y = ball.y + ball.vy*dt
And don't forget to draw the ball in the draw-function
Code: Select all
love.graphics.circle( "fill", ball.x, ball.y, ball.radius, 20)
Now you should get a ball moving across the playing field. However without any collision or interaction.
Try this next. What do you have to add, to make the ball bounce of the walls?
Here is an unrelated suggestion: Your code contains a lot of repitions. This is usually a sign that you can make the code shorter by programming in a more clever way. For example, you have a lot of rectangle-drawing function calls. Have a look into what tables are in lua and try to implement this drawing with a for loop.