Jump to content

  • Log In with Google      Sign In   
  • Create Account

#Actualstein102

Posted 31 March 2013 - 06:23 PM

Okay, I think I have it fixed now. I changed it to the following and after a few tests, it seems to hold. What was happening was that if you hit the paddle right on the corner, the overlap on the Y-axis was coming out to a really large number for some reason and bypassing my collision check. Any ideas why the overlap would be so large? I'm curious now about why that happened.

 

		if (ball.ballCircle.intersects(paddle.paddleRect)) {
			//Top
			//left
			if(ball.ballCircle.getMaxX()-ball.getAbsDx() <= paddle.paddleRect.getMinX()){
				ball.ballCircle.setCenterX(paddle.paddleRect.getMaxX()+ball.ballCircle.getRadius()-ball.getAbsDx());
				ball.setDx(-ball.getDx());
			}
			//Right
			else if( ball.ballCircle.getMinX()+ball.getAbsDx() >= paddle.paddleRect.getMaxX()){
				ball.ballCircle.setCenterX(paddle.paddleRect.getMaxX()+ball.ballCircle.getRadius()+ball.getAbsDx());
				ball.setDx(-ball.getDx());
			}	
			else{
				ball.ballCircle.setCenterY(paddle.paddleRect.getMinY()-ball.ballCircle.getRadius()-ball.getAbsDy());
				ball.setDy(-ball.getDy());
			}
			solidSound.play();
		}

#4stein102

Posted 31 March 2013 - 06:22 PM

Okay, I think I have it fixed now. I changed it to the following and after a few tests, it seems to hold. What was happening was that if you hit the paddle right on the corner, the overlap on the Y-axis was coming out to a really large number for some reason and bypassing my collision check. Any ideas why the overlap would be so large? I'm curious now about why that happened.

if (ball.ballCircle.intersects(paddle.paddleRect)) { //Top //left if(ball.ballCircle.getMaxX()-ball.getAbsDx() <= paddle.paddleRect.getMinX()){ ball.ballCircle.setCenterX(paddle.paddleRect.getMaxX()+ball.ballCircle.getRadius()-ball.getAbsDx()); ball.setDx(-ball.getDx()); } //Right else if( ball.ballCircle.getMinX()+ball.getAbsDx() >= paddle.paddleRect.getMaxX()){ ball.ballCircle.setCenterX(paddle.paddleRect.getMaxX()+ball.ballCircle.getRadius()+ball.getAbsDx()); ball.setDx(-ball.getDx()); } else{ ball.ballCircle.setCenterY(paddle.paddleRect.getMinY()-ball.ballCircle.getRadius()-ball.getAbsDy()); ball.setDy(-ball.getDy()); } }

#3stein102

Posted 31 March 2013 - 06:22 PM

Okay, I think I have it fixed now. I changed it to the following and after a few tests, it seems to hold. What was happening was that if you hit the paddle right on the corner, the overlap on the Y-axis was coming out to a really large number for some reason and bypassing my collision check.

Any ideas why the overlap would be so large? I'm curious now about why that happened.

if (ball.ballCircle.intersects(paddle.paddleRect)) {			//Top			//left			if(ball.ballCircle.getMaxX()-ball.getAbsDx() <= paddle.paddleRect.getMinX()){				ball.ballCircle.setCenterX(paddle.paddleRect.getMaxX()+ball.ballCircle.getRadius()-ball.getAbsDx());				ball.setDx(-ball.getDx());			}			//Right			else if( ball.ballCircle.getMinX()+ball.getAbsDx() >= paddle.paddleRect.getMaxX()){				ball.ballCircle.setCenterX(paddle.paddleRect.getMaxX()+ball.ballCircle.getRadius()+ball.getAbsDx());				ball.setDx(-ball.getDx());			}				else{				ball.ballCircle.setCenterY(paddle.paddleRect.getMinY()-ball.ballCircle.getRadius()-ball.getAbsDy());				ball.setDy(-ball.getDy());			}		}

#2stein102

Posted 31 March 2013 - 06:22 PM

Okay, I think I have it fixed now. I changed it to the following and after a few tests, it seems to hold. What was happening was that if you hit the paddle right on the corner, the overlap on the Y-axis was coming out to a really large number for some reason and bypassing my collision check.

Any ideas why the overlap would be so large? I'm curious now about why that happened.

if (ball.ballCircle.intersects(paddle.paddleRect)) {			//Top			//left			if(ball.ballCircle.getMaxX()-ball.getAbsDx() <= paddle.paddleRect.getMinX()){				ball.ballCircle.setCenterX(paddle.paddleRect.getMaxX()+ball.ballCircle.getRadius()-ball.getAbsDx());				ball.setDx(-ball.getDx());			}			//Right			else if( ball.ballCircle.getMinX()+ball.getAbsDx() >= paddle.paddleRect.getMaxX()){				ball.ballCircle.setCenterX(paddle.paddleRect.getMaxX()+ball.ballCircle.getRadius()+ball.getAbsDx());				ball.setDx(-ball.getDx());			}				else{				ball.ballCircle.setCenterY(paddle.paddleRect.getMinY()-ball.ballCircle.getRadius()-ball.getAbsDy());				ball.setDy(-ball.getDy());			}		}

#1stein102

Posted 31 March 2013 - 06:21 PM

Okay, I think I have it fixed now. I changed it to the following and after a few tests, it seems to hold. What was happening was that if you hit the paddle right on the corner, the overlap on the Y-axis was coming out to a really large number for some reason and bypassing my collision check.

 

		if (ball.ballCircle.intersects(paddle.paddleRect)) {
			//Top
			//left
			if(ball.ballCircle.getMaxX()-ball.getAbsDx() <= paddle.paddleRect.getMinX()){
				ball.ballCircle.setCenterX(paddle.paddleRect.getMaxX()+ball.ballCircle.getRadius()-ball.getAbsDx());
				ball.setDx(-ball.getDx());
			}
			//Right
			else if( ball.ballCircle.getMinX()+ball.getAbsDx() >= paddle.paddleRect.getMaxX()){
				ball.ballCircle.setCenterX(paddle.paddleRect.getMaxX()+ball.ballCircle.getRadius()+ball.getAbsDx());
				ball.setDx(-ball.getDx());
			}	
			else{
				ball.ballCircle.setCenterY(paddle.paddleRect.getMinY()-ball.ballCircle.getRadius()-ball.getAbsDy());
				ball.setDy(-ball.getDy());
			}
		}

PARTNERS