diff --git a/app/src/main/java/jonathan/balljumper/GameSurfaceView.java b/app/src/main/java/jonathan/balljumper/GameSurfaceView.java index d30e0a0..ee3fdac 100644 --- a/app/src/main/java/jonathan/balljumper/GameSurfaceView.java +++ b/app/src/main/java/jonathan/balljumper/GameSurfaceView.java @@ -64,8 +64,11 @@ ball = new Ball(screenSize.x / 2 - ballRadius, (screenSize.y / 3) * 2 - ballRadius, ballRadius, + 0.4f, Color.argb(255, 200, 34, 34)); + ball.bounce(); + // Initialize panelHandler. panelHandler = new PanelHandler(10, screenSize); } @@ -100,14 +103,21 @@ */ protected void update() { // Game mechanics + /* if (ball.getBottom() >= screenSize.y) { ball.bounce(); } else if (ball.getTop() <= 0) { ball.bounce(); } + */ - ball.setY(ball.getY() + ball.getSpeed() * ball.getDirection().y); + if (ball.getBottom() >= screenSize.y) { + pause(); + } + ball.setY((ball.getY() + ball.getSpeed() * ball.getDirection().y) + ball.velocity); + + ball.velocity += ball.getResistance(); for (int i = 0; i < panelHandler.getPanelList().length; ++i) { Panel panel = panelHandler.getPanelList()[i]; @@ -122,11 +132,11 @@ // Move the panel down. panel.setY(panel.getY() + panel.getSpeed()); } - } else { - if (ball.intersects(panel.getX(), panel.getY(), panel.getWidth(), panel.getHeight())) { - ball.bounce(); - } } + if (ball.intersects(panel.getX(), panel.getY(), panel.getWidth(), panel.getHeight())) { + ball.bounce(); + } + } }