diff --git a/app/src/main/java/jonathan/balljumper/GameSurfaceView.java b/app/src/main/java/jonathan/balljumper/GameSurfaceView.java index 0991865..e02bc24 100644 --- a/app/src/main/java/jonathan/balljumper/GameSurfaceView.java +++ b/app/src/main/java/jonathan/balljumper/GameSurfaceView.java @@ -102,7 +102,13 @@ */ protected void update() { // Game mechanics - ball.setY(ball.getY() + ball.getSpeed()); + if (ball.getBottom() >= screenSize.y) { + ball.bounce(); + } else if (ball.getTop() <= 0) { + ball.bounce(); + } + + ball.setY(ball.getY() + ball.getSpeed() * ball.getDirectionY()); } /** @@ -145,7 +151,7 @@ int sleepTime = (int) (FRAME_PERIOD - deltaTime); if (sleepTime > 0) { try { - gameThread.sleep(sleepTime); + gameThread.sleep(sleepTime / 2); } catch (InterruptedException e) { }