   Collision Problem in Brick Breaker
  I made the collision for paddle and ball.When the ball hit top of paddle, ball.y *=-1;this is normal case but.....When the ball hit the side of paddle, I got problem.The ball moves into paddle (inside paddle)So I make more collision for the left and right side of paddleand put the code as ball.x*=-1; and ball.y *=-1;to make the ball not bounce to the opposite direction sothe ball will not come inside but it is not work.I also found that when I quickly move paddle to hit side of the ballthe ball comes to inside the paddle.I am confused to set collision about this.//this in BallClassif(this->CheckCollide(bar.x,bar.y,bar.width,bar.height))//if they collided (I use bounding box theory for this method){if(ball.x <= bar.x && ball.x >=bar.x-ball.width)//hit left side of paddle{speedX = -speedX;  speedY = -speedY;}else if(ball.x >= bar.x+ bar.width)//hit the right of paddle{  speedX = -speedX;  speedY = -speedY;}else{  speedY = -speedY;}}bool BallClass::CheckCollide(float Ex, float Ey, float EsizeX, float EsizeY){if(ball.x >= Ex - sizeX && ball.x <= Ex + EsizeX && ball.y >= Ey - sizeY && ball.y <= Ey + EsizeY){return true;}else{return false;}}
  You could set a flag indicating that a collision has occurred and don't allow another collision until the flag is unset when the ball clears the paddle.   ;  if the velocity of the ball is the same sign as side, don't reverse velocity.I'll rephrase that, if you hit the left wall, and you are already moving to the right, you do not want to flip the velocity again, as you'll be moving to the left again.[Edited by - oliii on April 9, 2010 5:16:43 AM]