if(ball.y > rect.y - rect.height && ball.x > rect.x - rect.widht && ball.x < rect.x + rect.widht){ vel.y *= -1; //collision check for pong game }