I've completed a very basic implementation of Pong.
I would like to make it nicer adding a classic mode that looks and plays as close to the original as possible.
To do so I'd need, for starters, to increase my paddles speed but when I do so the paddles end out of the screen.
I cannot understand why, this is the code causing the issue, it is very simple:
-- check if pad goes out of the upper part of the screen if button_up and pad.y > game.upper_bound then pad.y-=1 elseif button_up and pad.y <= game.upper_bound then pad.y=game.upper_bound end -- check if paddle goes out of the bottom parte of the screen if button_down and pad.y + pad.h < game.lower_bound then pad.y+=1 elseif button_down and pad.y + pad.h > game.lower_bound then pad.y=game.lower_bound end
If instead of using 1 I use 2 or more the paddles get out of bounds (or start shaking).
In case you want to check the complete code you can find it here:
[Please log in to post a comment]