I have problem but I don’t know how to describe it so I have drawn it.

As you can see ball bounces when collision is detected. Nevermind the angle – I have just drawn it that way.
But sometimes ball goes through the paddle leaving it other way.
Why that happens ? Becase when I detect the collision I change vx to -vx. What should I do in that case ? Change also y ? But how to check which side of the paddle ball hit?
Maybe other ideas?
This is quite a common problem for people writing pong clones. The solution is to, upon detecting a collision, not only reverse the velocity but also alter the ball position so that it doesn’t intersect the paddle.
Otherwise it is possible for the ball to become stuck inside the paddle, constantly negating vx = -vx = vx = -vx each frame. It won’t leave the paddle until its y momentum moves it far enough up or down to escape.