diff --git a/app/src/main/java/jonathan/balljumper/GameSurfaceView.java b/app/src/main/java/jonathan/balljumper/GameSurfaceView.java index 5c4d418..c64dab8 100644 --- a/app/src/main/java/jonathan/balljumper/GameSurfaceView.java +++ b/app/src/main/java/jonathan/balljumper/GameSurfaceView.java @@ -150,14 +150,18 @@ panelHandler.move(i, -ballHeightLimit); } - // Bounce if the ball intersects with a panel. - if (ball.intersects(panel.getX(), panel.getY(), panel.getWidth(), panel.getHeight())) { - // Do not bounce if you're above the screen. - if (ball.getBottom() > 0) { - ball.bounce(); - // If the ball is falling. - if (ball.getDeltaY() > 0) { - ball.setY(ball.getY() - (ball.getBottom() - panel.getTop())); + if (!ball.getHasJumped()) { + // Bounce if the ball intersects with a panel. + if (ball.intersects(panel.getX(), panel.getY(), panel.getWidth(), panel.getHeight())) { + // Do not bounce if you're above the screen. + if (ball.getBottom() > 0) { + ball.bounce(); + highscoreHandler.addBounce(); + + // If the ball is falling. + if (ball.getDeltaY() > 0) { + ball.setY(ball.getY() - (ball.getBottom() - panel.getTop())); + } } } }