Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


#Actualde_mattT

Posted 30 March 2013 - 03:57 PM

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

 

Is it possible you've got the comparison operators wrong?

I.e.

 

 

        if (ball.ballCircle.intersects(paddle.paddleRect)) {
            //left (was <=, now >=)
            if(ball.ballCircle.getMaxX() >= paddle.paddleRect.getMinX()){
                ball.ballCircle.setCenterX(paddle.paddleRect.getMinX()-ball.ballCircle.getRadius()-1);
                ball.setDx(-ball.getDx());
            }
            //Right (was >=, now <=)
            if( ball.ballCircle.getMinX() <= paddle.paddleRect.getMaxX()){
                ball.ballCircle.setCenterX(paddle.paddleRect.getMaxX()+ball.ballCircle.getRadius()+1);
                ball.setDx(-ball.getDx());
            }
            //Top (was <=, now >=)
            if(ball.balllCircle.getMaxY() >= paddle.paddleRect.getMinY()){
                ball.ballCircle.setCenterY(paddle.paddleRect.getMinY()-ball.ballCircle.getRadius()-1);
                ball.setDy(-ball.getDy());
            }    
        }
 

 

Matt


#2de_mattT

Posted 30 March 2013 - 03:56 PM

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

 

Is it possible you've got the comparison operators highlighted in red wrong?

I.e.

 

 

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

 

Matt


#1de_mattT

Posted 30 March 2013 - 03:56 PM

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

 

Is it possible you've got the comparison operators highlighted in red wrong?

I.e.

 

 

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

 

Matt


PARTNERS