But I'm experiencing a problem:
I bet you all know how movement works in games, the graphic dosen't move, they jump.
For example: if they got let's say a speed of 10 they will "teleport" 10 pixels each tick.
But that causes a problem...
So my ball is bouncing around and my collision detection for the top and bottom surface is very simple
Code: Select all
-- My top walls ends at 5 pixles
if ball.y < 5 then
ball.y = 5
ball.yv = ball.yv * -1
-- ball.yv = the balls y velocity / speed
end
So I got it reverse it's direction if it's inside the area containing each bracket, similar to how I did the walls collision.
But if I got a high enough speed it will go right trough the bracket, without matching the condition for collision.
And I bet this is a common problem, for example if you got a gun and it's bullet got a massive speed then it will probably go trough everything.
So how would I make this work?
Do I check each pixel between it's "jump"? Or is there a simpler way?
The pong.love file: mediafire
You control the left bracket with W and S, and the right bracket with UP and DOWN.
Atm the right bracket is controlled by a very simple and bad "AI", you can change this in the brackets.lua file.